{
 "commit": "03dc2d5a727b1195ec82857a98506f632529e280",
 "lens": "intake",
 "verdict": "findings",
 "counts": {
  "high": 1,
  "medium": 1,
  "low": 1,
  "info": 1
 },
 "findings": [
  {
   "id": "intake-1",
   "severity": "high",
   "title": "A delivered success whose result document cannot be proven freezes the site for good",
   "where": "src/Changeme.sol onResult, _head, retry, skip, _tryDispatch",
   "scenario": [
    "1. Fresh deployment; Alice contributes 0.5 IMD; round 1 is sent (attempt 1).",
    "2. Intake delivers onResult with a resultHash whose document proveJob cannot accept: the document is never pinned/lost, is over MAX_RESULT_DOC_BYTES, has a jobId that is not a lowercase UUID, or the hash is wrong.",
    "3. onResult sets activeAttempt=0 and status Succeeded; _head returns NeedsProof forever.",
    "4. retry reverts HeadNeedsProof, skip reverts NothingToRecover (no active attempt), dispatch/contribute never send. New contributions pile up in openPool with no way out, at any time."
   ],
   "impact": "Permanent freeze of builds and of every later contributor's IMD in openPool; breaks 'nothing may freeze the site for good' and 'retry or skip after a day'. Trigger depends only on off-chain document availability/shape or on the writer (see intake-2).",
   "proof": "test/scratch IntakeLens.t.sol testUnprovableSuccessFreezes: success(req, '{\"jobId\":\"NOT-A-UUID\"}'); proveJob reverts BadResultDocument; warp 30 days; retry reverts HeadNeedsProof(1); skip reverts NothingToRecover; two more 0.5 IMD contributions are not sent; dispatch()==false; openPool==1 IMD. Result: PASS (gas 2,816,009).",
   "fix": "In _head, when the newest attempt Succeeded without a proven jobId and block.timestamp >= settledAt + RECOVERY_DELAY, return HeadMode.Unknown instead of NeedsProof, so a sponsor can retry() naming the head (parent required since versionCount != 0). About 60-90 bytes of runtime (one SLOAD of settledAt, compare, branch); fits the 214 bytes left.",
   "liveOnly": false
  },
  {
   "id": "intake-2",
   "severity": "medium",
   "title": "Intake does not bind success args to the completed request: a misbehaving writer can settle changeme's attempt through any request naming changeme",
   "where": "src/Changeme.sol onResult; real Intake.complete (status 0 path)",
   "scenario": [
    "1. Fresh deployment; Alice contributes 0.5 IMD; round 1 sent as request R.",
    "2. Anyone buys their own request X at the live price with callback (changeme, onResult).",
    "3. The writer completes X with status 0 and args abi.encode(R, junkHash, uri). Intake checks only failure args against the request id, so the call is delivered with msg.sender == Intake.",
    "4. changeme records version 1 with junkHash; the honest completion of R later only emits StaleCallback; head is NeedsProof with an unprovable hash, i.e. intake-1's freeze."
   ],
   "impact": "Wrong version records and, with intake-1 unfixed, a permanent freeze. Requires a faulty or compromised Intake writer (privileged); the outsider alone cannot do it (see checked).",
   "proof": "testForgedSuccessThroughThirdPartyRequest: SPONSOR's own request(OPEN,'{}',Callback(site,onResult)) completed by WRITER with abi.encode(real, keccak256('junk'), URI); lastDelivered true, versionCount 1, attempt(1).resultHash == keccak256('junk'), head NeedsProof; the real success afterwards leaves versionCount 1. PASS. Real Intake source: success path does bytes.concat(selector, args) with no requestId check (only status != 0 checks args[0:32]).",
   "fix": "In onResult also require IIntake(INTAKE).requests(requestId).completed == true (Intake sets completed before calling back, so a forged id whose own request is still open is refused). About 120-150 bytes and ~2,700 gas inside the callback. The intake-1 fix bounds the residual damage to one day.",
   "liveOnly": false
  },
  {
   "id": "intake-3",
   "severity": "low",
   "title": "Doubles are kinder than the real Intake: fixed callbackGas and no owner-mutable writer/price",
   "where": "test/doubles/IntakeDouble.sol initialize; real Intake setCallbackGas/setWriter/setPrice",
   "scenario": [
    "1. Real Intake owner may setCallbackGas below what onResult/onFailure need, or to any value; the double hard-codes 200,000 with no setter.",
    "2. Callbacks then fail (delivered=false); the attempt stays Pending until RECOVERY_DELAY, after which retry/skip work."
   ],
   "impact": "At most a one-day stall per attempt and a paid-for build that is not recorded; no permanent freeze. Tests never exercise a lowered stipend.",
   "proof": "Reasoned from the verified source: 'function setCallbackGas(uint64 gas) external onlyOwner'. testHugeUriOOGThenRecoverable shows an undelivered success can be skipped after 1 day (PASS).",
   "fix": "Documentation only (README): callback gas is the Intake owner's setting; add a double test with a lowered stipend. 0 bytes.",
   "liveOnly": true
  },
  {
   "id": "intake-4",
   "severity": "info",
   "title": "onResult gas is bounded by uri length chosen by the writer",
   "where": "src/Changeme.sol onResult (uri emitted, not stored)",
   "scenario": [
    "1. First version, cold slots: an 8 KiB uri is delivered within 200,000 gas.",
    "2. A 60,000-byte uri runs out of gas; the attempt stays Pending and is skippable after a day."
   ],
   "impact": "None beyond a one-day delay; normal ipfs:// result URIs are ~80 bytes.",
   "proof": "testLongUriGas (8192-byte uri delivered) PASS; testHugeUriOOGThenRecoverable (60000 bytes: lastDelivered false, skip after 1 day succeeds) PASS.",
   "fix": "None needed.",
   "liveOnly": false
  }
 ],
 "checked": [
  "Selectors: onResult(bytes32,bytes32,string) and onFailure(bytes32,uint8,bytes32,uint16,uint16,bytes) match the envelope documented in the verified Intake complete() natspec.",
  "Action encoding: JOB_OPEN/JOB_CONTINUE are right-padded bytes32 strings, priced via priceOf(action, IMD); zero price treated as unavailable.",
  "requestWithFailure signature and argument order match the verified Intake; FailureHookWithoutTarget cannot fire because target is address(this).",
  "Request ids: both real and double use keccak256(abi.encode(block.chainid, address(this), ++nonce)); ids are unique, so a third-party request cannot collide with changeme's.",
  "Payment: exact approve of the live price, allowance reset before and required zero after; real Intake uses safeTransferFrom from payer to payTo; price re-read and compared to the budget atomically.",
  "Callback caller: only msg.sender == Intake accepted; unknown request id reverts (delivered=false, no state change). An honest completion of an outsider's own request naming changeme cannot move state (testOwnRequestCannotMoveState PASS).",
  "Failure args: real Intake requires args[0:32]==requestId and args[32:64]==status, so onFailure cannot be forged across requests; empty args suppress the callback and the attempt is recoverable after a day.",
  "Reverting or OOG callback: real Intake marks completed first and records delivered=false; completion cannot be replayed; changeme stays Pending and retry/skip open after RECOVERY_DELAY.",
  "Stale callbacks for abandoned attempts only emit StaleCallback and never overwrite the active attempt.",
  "Real Intake reserve CALLBACK_RESERVE = 20_000 equals the double's literal 20_000; gas check formula identical.",
  "Full suite: 88 tests passed at this commit."
 ],
 "commands": [
  "git clone https://github.com/identity-md-launches/goal-3599-have-swarm-build-test && git checkout 03dc2d5a727b1195ec82857a98506f632529e280: ok",
  "forge test: 88 passed, 0 failed",
  "forge test --offline ...: failed, solc 0.8.26 not installed offline; rerun online",
  "curl https://sourcify.dev/server/v2/contract/1/0xa43e6F75ee006411F79Ac1C84120606C2330DE82?fields=sources: ok, src/Intake.sol read",
  "forge test --match-path test/scratch/IntakeLens.t.sol -vv: 5 passed, 0 failed"
 ]
}