{
  "commit": "03dc2d5a727b1195ec82857a98506f632529e280",
  "lens": "wishes",
  "verdict": "findings",
  "counts": {
    "high": 2,
    "medium": 0,
    "low": 1,
    "info": 0
  },
  "findings": [
    {
      "id": "wishes-1",
      "severity": "high",
      "title": "An unprovable success permanently blocks later rounds",
      "where": "src/Changeme.sol:278-289 proveJob, :454-468 _head, :487-555 _topLevelJobId; :220-273 retry/skip",
      "scenario": "1. Deploy and send a paid first round; put another 0.5 IMD of wishes in the next round.\n2. The Intake writer reports success with a hash of valid JSON whose UUID uses a JSON unicode escape, for example {\"jobId\":\"\\u00311111111-1111-1111-1111-111111111111\"}. Alternatively, a valid 262,145-byte result exceeds the cap, or a valid 262,144-byte result with a long files value exceeds the observed mainnet block gas budget when scanned.\n3. proveJob cannot record the head. After a day dispatch returns false, retry reverts HeadNeedsProof, and skip reverts NothingToRecover. Later contributions also cannot send.",
      "impact": "A successful version can leave the queued IMD and all subsequent builds stuck indefinitely. The triggering result formats are valid JSON but were not observed in a live changeme order; the contract failure and lack of recovery are reproduced locally.",
      "proof": "IndependentWishesTest.testValidEscapedValueCannotBeProvenAndBlocksPoolAfterDay (Intake/IMD doubles):\ncontribute(ALICE, \"add a sky\", PRICE, true);\ncontribute(BOB, \"add sun\", PRICE, false);\nbytes memory doc = abi.encodePacked('{\"jobId\":\"\\\\u0031', '1111111-1111-1111-1111-111111111111\"}');\nsuccess(site.attempt(1).requestId, doc);\nvm.expectRevert(abi.encodeWithSelector(Changeme.BadResultDocument.selector)); site.proveJob(1, doc);\nvm.warp(3 days); require(!site.dispatch());\nvm.expectRevert(abi.encodeWithSelector(Changeme.HeadNeedsProof.selector, 1)); site.retry(JOB1, PRICE);\nvm.expectRevert(abi.encodeWithSelector(Changeme.NothingToRecover.selector)); site.skip();\nOutcome: PASS; pool remained 0.5 IMD, activeAttempt was zero. Python json.loads decoded the same document's jobId to the 36-byte UUID. testOversizeValidDocumentCannotBeProven also PASSed. testMaxDocumentScansAndOversizeBlocksProof PASSed with a valid 262,144-byte JSON files string; the proveJob call alone used 97,277,326 gas, above block 26,545,730's observed 59,941,408 gas limit.",
      "fix": "After RECOVERY_DELAY, let _head treat a succeeded but unproven newest attempt as Unknown. Then anyone can sponsor retry of the queued round with a validated parent, while proveJob remains available. Prototype passed a sponsored-continuation test and added 61 runtime bytes: 24,362 to 24,423, within the 24,576 limit. This restores liveness; supporting every valid result encoding directly would require a fuller parser.",
      "liveOnly": false
    },
    {
      "id": "wishes-2",
      "severity": "high",
      "title": "Escaped duplicate jobId proves the wrong parent",
      "where": "src/Changeme.sol:488-539 _topLevelJobId; :278-289 proveJob; :400-434 _send",
      "scenario": "1. Deploy, fund and send a first round.\n2. The Intake writer commits a valid JSON result with a first literal jobId J1 and a later jo\\u0062Id J2. Decoding the latter key yields jobId; a conventional JSON parser uses J2.\n3. proveJob stores J1 because it compares raw key bytes and sees no duplicate. The next pooled job.continue body names J1. If J2 is the real project head, that paid continuation is refused; subsequent pooled rounds can repeat the error.",
      "impact": "A hash-committed but ambiguous result can misdirect pooled IMD into a continuation against the wrong parent. The wrong parent is proven locally; actual admission loss requires such a live result and is conditional, with no paid order placed in this review.",
      "proof": "IndependentWishesTest.testEscapedDuplicateJobIdProvesWrongParent:\ncontribute(ALICE, \"add a sky\", PRICE, true);\nbytes memory doc = abi.encodePacked('{\"jobId\":\"', JOB1, '\",\"jo\\\\u0062Id\":\"', JOB2, '\"}');\nsuccess(site.attempt(1).requestId, doc);\nsite.proveJob(1, doc); same(site.attempt(1).jobId, JOB1);\ncontribute(BOB, \"add sun\", PRICE, true); same(site.attempt(2).parentJobId, JOB1);\nOutcome: PASS. Python json.loads on that exact JSON returned JOB2 for jobId. The emitted continuation used JOB1 and an exact 0.5 IMD approval in the double.",
      "fix": "Reject backslashes in every top-level key before selecting jobId; raw duplicate jobId keys are already rejected. This conservative fix prevents escaped aliases from proving a false parent. Measured incremental cost: +36 runtime bytes (24,423 to 24,459 when paired with wishes-1; 24,362 baseline). Escaped-key documents then need the wishes-1 timeout escape.",
      "liveOnly": false
    },
    {
      "id": "wishes-3",
      "severity": "low",
      "title": "A mismatched root closing bracket is accepted as JSON proof",
      "where": "src/Changeme.sol:524-539 _topLevelJobId",
      "scenario": "1. Deploy and send a first round.\n2. The Intake double reports success for bytes {\"jobId\":\"J1\"] (with J1 expanded to a UUID).\n3. proveJob accepts the invalid JSON because any closing bracket decrements depth; it records J1.",
      "impact": "JobProven can attest a non-JSON result if the trusted writer commits one. No user-controlled callback hash or live malformed result was observed; this is a parser correctness defect.",
      "proof": "IndependentWishesTest.testMalformedClosingBracketAccepted:\ncontribute(ALICE, \"add a sky\", PRICE, true);\nbytes memory doc = abi.encodePacked('{\"jobId\":\"', JOB1, '\"]');\nsuccess(site.attempt(1).requestId, doc);\nsite.proveJob(1, doc); same(site.attempt(1).jobId, JOB1);\nOutcome: PASS; a JSON parser rejects the document.",
      "fix": "Require '}' rather than ']' when depth is one before decrementing. The prototype added 60 runtime bytes (24,362 to 24,422); all three prototype changes together used 24,519 bytes. This closes the demonstrated root-delimiter case, not every malformed JSON grammar case.",
      "liveOnly": false
    }
  ],
  "checked": [
    "Pinned commit 03dc2d5a727b1195ec82857a98506f632529e280 checked out; source and Foundry fixture examined at that commit. The original source diff was empty after prototype measurements.",
    "WishOrders.validateWish: an exhaustive test of all 256 possible second bytes after 'a' accepted exactly a-z, 0-9, space and the listed punctuation; the suite rejects empty, punctuation-only, >140-byte and non-ASCII wishes.",
    "For every allowed byte, both job.open and job.continue bodies equalled the baseline body with only that wish byte inserted (JSON escaping added for quote and backslash). Skill, ipfs, and parent fields stayed fixed. The official suite also checked exact representative open and continuation bodies.",
    "A 50-wish batch of 140-byte wishes with maximum escaping encoded to 14,898 bytes for open and 14,941 for continue, below IntakeBinding's 16,384-byte door.",
    "Wishes cannot contain newline, slash, square brackets or braces, so they cannot spell a closing [/WISHES] marker or break out of the JSON string. An instruction-shaped lowercase wish was accepted but remained inside the wishes block; the fixed brief says to ignore job-changing wishes. No model job was run, so model compliance is unproven.",
    "Parent job IDs must be exactly 36 lowercase hex/hyphen bytes; malformed and quote-bearing values revert. The continuation body uses boolean ipfs true and a validated parentJobId; the open body uses ipfs made-by-chat.",
    "proveJob checks status, size and exact keccak256 hash before scanning. Nested jobId keys and braces inside escaped strings were ignored in a valid document; a raw duplicate top-level jobId and nonwhitespace trailing data were rejected.",
    "All tests used local IntakeDouble and IMDDouble. No live transaction, signing or paid order was sent."
  ],
  "commands": [
    {
      "command": "git clone https://github.com/identity-md-launches/goal-3599-have-swarm-build-test test/scratch/goal-3599; git checkout 03dc2d5a727b1195ec82857a98506f632529e280; git rev-parse HEAD",
      "ended": "exit 0; exact pinned commit"
    },
    {
      "command": "rg --files src test docs; nl -ba src/Changeme.sol src/orders/WishOrders.sol docs/intake.md test/WishOrders.t.sol test/lifecycle/Fixture.sol test/lifecycle/Recovery.t.sol src/protocol/IntakeBinding.sol; cat foundry.toml; forge --version",
      "ended": "exit 0; inspected source, fixtures and Foundry 1.9.0"
    },
    {
      "command": "forge test --offline",
      "ended": "initial pinned suite: 88 passed, 0 failed"
    },
    {
      "command": "curl -LsS https://api.imd.fun/jobs/f310ba3c-9087-4a6f-8b51-4739737aeee1/result",
      "ended": "HTTP 200, 802 bytes; illustrative public result only, not a changeme result or proof hash"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol -vv",
      "ended": "first scratch run: 5 passed, 1 failed because a diagnostic asserted proof gas below 30 million; the observed proof exceeded it"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol --match-test testMaxDocumentScansAndOversizeBlocksProof -vvvv",
      "ended": "whitespace-padded 262,144-byte JSON proof used 66,611,729 gas; later realistic files-string variant used 97,277,326 gas; both executed in the local test VM"
    },
    {
      "command": "python3 json.loads on escaped-duplicate, escaped-value and escaped-key JSON examples",
      "ended": "all parsed; duplicate resolved to JOB2 and both escaped single-key cases resolved to JOB1"
    },
    {
      "command": "forge inspect Changeme deployedBytecode --offline",
      "ended": "baseline 24,362 bytes; scratch prototypes measured 24,423 with timeout fallback, 24,459 with escaped-key rejection, 24,422 for root-delimiter check alone, 24,519 combined"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol --match-test testProposedTimeoutFallbackAllowsSponsoredContinuation",
      "ended": "1 passed against scratch prototype; prototype source was restored"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol --match-test testAllByteValuesMatchAlphabet",
      "ended": "1 passed; all 256 byte values classified"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol --match-test testEveryAllowedWishByteStaysInWishesBlock",
      "ended": "1 passed; exact open and continuation byte insertion for each allowed byte"
    },
    {
      "command": "forge test --offline --match-path test/scratch/IndependentWishes.t.sol --match-test testWorstCaseFiftyWishBodyLengths -vvvv",
      "ended": "1 passed; BodyLengths event 14,898 open and 14,941 continuation"
    },
    {
      "command": "eth_getBlockByNumber(0x1950e42,false) via task chain-1 RPC; same read via https://ethereum-rpc.publicnode.com",
      "ended": "block 26,545,730 gasLimit 59,941,408; read-only"
    },
    {
      "command": "curl -LsS raw.githubusercontent.com/.../03dc2d5a727b1195ec82857a98506f632529e280/{src/Changeme.sol,src/orders/WishOrders.sol,docs/intake.md}",
      "ended": "HTTP 200 for each pinned source"
    },
    {
      "command": "forge test --offline",
      "ended": "final pinned source plus scratch review tests: 101 passed, 0 failed; git diff --stat empty in checkout"
    },
    {
      "command": "python3 urllib.request.urlopen for every sources.json URL and exact quote",
      "ended": "20/20 quotes verified against 4 pinned raw URLs; each quote at most 500 characters"
    },
    {
      "command": "python3 -m json.tool result.json sources.json and byte-length checks",
      "ended": "passed before submission"
    }
  ]
}
