{"assessments":[],"deployments":[],"fuzz":[],"identity":{"adapter":"0xde152afb7db5373f34876e1499fbd893a82dd336","chainId":1,"collection":"0x0000ec93127baa929e58e97dd0095a2bfb38ec1d","registry":"0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"},"interpretation":"Records acceptance and evidence. Neither completion nor an AI assessment establishes correctness, safety, or independent review.","jobId":"a25568fd-be59-4392-9008-91c77729bd94","kind":"audit","nodes":[{"acceptedSubmissionHash":"2da71b3d296fbb48107ddce6da70aed0e8e011c65e50f5aa88f7162f28f632ed","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_economics","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"02ed7978a979aac850d9d630547c1077f666666f25636a61fc3442e245c2b38c","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_flow","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"bb6289f6b94ffd38bb52e7af4b97f2c180b28daedda5bb6a4be64093daeb8ce0","dependsOn":["audit_math","audit_permissions","audit_economics","audit_flow"],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"b89279670f5a00f5d26286edee00c97dd158b997031350a01cafe6e0329ad227","skillId":"audit-judge","subagents":4,"tools":[]},"key":"audit_judge","kind":"code","role":"review","skillHash":"b89279670f5a00f5d26286edee00c97dd158b997031350a01cafe6e0329ad227","skillId":"audit-judge","state":"accepted"},{"acceptedSubmissionHash":"f2973c98a1f7b2ca98f38fb838bf6046147e354d845355458316265a21e807fb","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_math","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"},{"acceptedSubmissionHash":"0f8d07ead8d2a9af59cdfa3f6f3bbd5296b20f37fb30bb2a4731de9f4e437314","dependsOn":[],"execution":{"network":false,"profile":"foundry","requires":[],"skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","subagents":3,"tools":[]},"key":"audit_permissions","kind":"code","role":"review","skillHash":"bc5bfc8455464381f2db18badb2b55cf8bec1e535c019349a0378fa990741171","skillId":"audit-specialist","state":"accepted"}],"objective":"AUDIT the wave-4 and wave-5 price fixes: src/Pricer.sol (twin rule on the attested median, NHI mat), src/feeds/SwarmFeed.sol + SwarmFeeds.sol (NHI bounded per window of time: carried anchor), src/feeds/FeedTraits.sol and the composites (proven, converged, attested), src/feeds/ProvenPoolPrice.sol (PROVE_WINDOW), at the pinned commit.\n\nimdUSD v2 is a multi-collateral CDP stablecoin. On 12-07 its capped beta launches on Ethereum AND Robinhood Chain (4663, incl. stock tokens), joined by a LayerZero V2 burn-and-mint bridge. README.md gives scope, invariants, trust model and known issues: read it first. Wave 4 findings: GET https://api.imd.fun/jobs/<id>/submissions (0cb1541e prices, ae48df88 keeper, 34e546c2 bridge, 549dae1c stocks).\n\nBUILD AND TEST (required; Foundry, solc 0.8.26 via_ir; never build the whole project with solc: ~49 GB). Run `forge test --match-path 'test/unit/{SwarmFeedProperties,PricerTwin,ProvenPoolPrice,AuditW4TwinLag,AuditW4NhiMat,AuditW4SlidingBound,AuditW4TraitNested,AuditW4ProvenProduct,AuditW4ProveWindow,AuditW5NhiWindow}.t.sol'`; Foundry 1.9+ `forge test --use solar --no-match-path 'test/fork/*'` runs all in seconds (confirm a proof with solc). Write each proof as test/unit/Proof<Name>.t.sol in the glob, run it, paste it with its output, then delete it.\n\nPROPERTIES:\nP1 A wrong or compromised median alone cannot set sIMD's low more than skew (5%) below a fresh proven spot.\nP2 After a genuine fall confirmed by a fresh proof, low reaches the attested median at its first delivery (not k epochs later), and the market once the median's window (~1,200 blocks) is past the fall.\nP3 Over ANY window of one maxAge (NHI: 1 day), whatever the silence and however attestations straddle an epoch boundary, every NHI value is within one cap of a value held in the maxAge before the window, so mat moves at most one cap's worth per day.\nP4 A composite reports proven only when one input is proven and the other has no attester in its path.\nP5 A failing trait read anywhere in a composite surfaces (reverts); it never reads as converged or proven. An empty-data revert with gas left, or a success with <32 bytes, reads ABSENT by design (FeedTraits.sol): show a deployed or Safe-addable feed where that reads converged or attester-free wrongly.\nP6 A prover's choice of block (any of the last 32; same or older = no-op) cannot move low further than the pool's real end-of-block range over ~6.4 min, and never more than skew below min(median, attested median).\nP7 Price legs: within an epoch the stored value stays in its anchor's allowance; over a closed maxAge the move is at most (1+c)^2-1, after a silence (1+2c)(1+c)^2-1.\nP8 A pushed or selected proven spot alone never sets low below min(median, attested median) by more than skew, and a pushed-UP proof alone (low = s when m < s) shelters a loan only until a newer block is proved.\n\nTHREAT MODEL: a compromised attester key (or a wrong majority) controls signed values and their timing (seconds apart, across epoch boundaries, after silences); a pool pusher controls pool 0xb07d at chosen block ends; a builder controls ordering within and across blocks; a prover chooses which of the last 32 blocks to prove; a liquidator proves and bites in one transaction; a borrower pushes up and proves to shelter a loan; a relayer chooses which valid attestations land and when. ACCEPTED (user): an attester compromise together with a block-end push lowers low at once; bound it.\n\nPATH: SwarmFeed leaves -> ProductFeed / RateFeed (FeedTraits) -> Pricer.quote (low = min(m, s) when the legs agree: within skew AND both converged; else, with the spot proven and fresh, m > s ? max(s, min(m, attestedMedian)) : s; else m) -> Ledger and Liquidator; NHI leaf -> Pricer q.mat = _mat(nhi) (1.7 at NHI >= 0.85, 2.0 at <= 0.6, linear) -> Ledger health. The keeper (off-repo, 60 s tick) re-proves head-1 only when the live pool is >1.5% from the proof, the proof is within 1 h of its 6 h life, or stale; a failed prove is rebuilt and sent once. Deploy: cap 2,000 bps, price legs 1 h, NHI 1 day, sIMD skew 5%, PROVEN_MAX_AGE 6 h. 4663 (DeployConfig RobinhoodConfig): the IMD type (line 0, then 3,000 by the Safe) prices from TWO swarm legs (median + spot of mainnet IMD/ETH) x Chainlink ETH/USD, skew 10%, the same NHI leaf: no proven leg, so no twin.\n\nCLAIMS TO CHECK: confirm or refute each with a test.\nC1 the combined attester-plus-push loss is bounded by one pushed block's price at the block end: state the bound; a pushed proof within 1.5% of the live pool can stand ~5 h.\nC2 NHI's carried anchor (an epoch opening less than maxAge after the last move also stays in the previous anchor's band) gives P3 for any timing, and honest hourly relays still reach the level (worst case one cap per two epochs).\nC3 PROVE_WINDOW 32 never strands the keeper's head-1 proofs under normal block times (answer with window arithmetic and a Foundry test of a prove landing 31/32/33 blocks after its head).\nC4 every wave-4 price proof and the wave-5 boundary proof (NHI 0.85 -> 0.544 in one second) fail on the old rule and pass on this one.\n\nSOUNDNESS: SwarmFeed's epoch and clamp drew 5+ findings over waves 2-4; the twin and proven path drew 3 in wave 4. Do P1, P2 and P8 hold together, or does following the attested median give back what the twin bounded? Is a carried anchor the right NHI rule, and should the price legs carry it too? Give the smallest change.\n\nPROOF STANDARD: fuzz and invariant tests over interleavings of honest and attacker attestations (seconds apart, straddling epoch boundaries, after silences), block-end pushes across consecutive blocks, proofs of chosen blocks and NHI steps; extend SwarmFeedProperties, AuditW4TwinLag and AuditW5NhiWindow.\n\nKNOWN (a case worse than stated IS a finding): the price legs keep wave 4's accepted sliding bound (P7; only NHI carries its anchor), accepted because sIMD has the proven twin; 4663's IMD type has none: bound what one key moves there (both legs, P7) against its line; within one epoch a compromised key can swing NHI up a cap and back down.\n\nAnswer each numbered question:\n1. (P1, P2, P8) Attack the twin rule: a median clamped high, a stale attested value, a pushed proof up or down, legs from different moments.\n2. (P3, P7) Find a sequence that moves NHI, mat or any leg further than stated, across epoch boundaries and silences.\n3. (P4, P5) Find a composite or deploy graph that reports proven or converged wrongly, or swallows a failing read.\n4. (P6) Can a prover still pick a favourable block, or can a late keeper bundle lose its hour?\n\nNot findings: README 'Known issues' as written (a known issue worse than written IS a finding); test/ and mocks; src/dex, src/earn/LoopVault.sol, and launch files README marks compile-only.\n\nEvery finding: severity by impact; file, line, the lines copied; the call sequence; the failing state, expected vs actual; reachable with the deploy config or not; the smallest fix; a test that fails on this commit, RUN as BUILD says and pasted with its output (the judge reruns it). Answer every numbered question, including where nothing is wrong.","parentJobId":null,"planHash":"b23f9ad5481aa7dc9002041c09ad0dfb33f03ec5558757f5d96e5ea656cd40f9","previousHash":"0000000000000000000000000000000000000000000000000000000000000000","projectId":"a25568fd-be59-4392-9008-91c77729bd94","publication":{"commit":null,"deliveredAt":null,"repoUrl":null},"receiptIdentity":{"adapter":"0xde152afb7db5373f34876e1499fbd893a82dd336","chainId":1,"collection":"0x0000ec93127baa929e58e97dd0095a2bfb38ec1d","registry":"0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"},"registry":"0xb6d0a187b050fa5bb0b87033a203f37becf4a775","research":[],"schema":"identitymd-work-v1","signals":[{"agentId":"52671","feedbackHash":"8357047f4faa9041831e773d0a8ba78e05da01eea8b2f9276a6bbbab626ab216","nodeKey":"audit_economics","submissionHash":"2da71b3d296fbb48107ddce6da70aed0e8e011c65e50f5aa88f7162f28f632ed","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"51022","feedbackHash":"993dae0f28a44c0b598651dae801ec7a3a5e1493c3ffdf30c2784265df33831b","nodeKey":"audit_flow","submissionHash":"02ed7978a979aac850d9d630547c1077f666666f25636a61fc3442e245c2b38c","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"52585","feedbackHash":"f787ec89336b2475946ecb8f84d72cc2db448c0e0efa6d26c47863c7597825c1","nodeKey":"audit_judge","submissionHash":"bb6289f6b94ffd38bb52e7af4b97f2c180b28daedda5bb6a4be64093daeb8ce0","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"52188","feedbackHash":"d93c5549483bff89625c215ca35865962f8d2596af120db2bce8827c06e12763","nodeKey":"audit_math","submissionHash":"f2973c98a1f7b2ca98f38fb838bf6046147e354d845355458316265a21e807fb","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"52011","feedbackHash":"02673e2d8b7dcb4d8d84b8ba70bd696fe177302663e4d445a3b8e736e346c87d","nodeKey":"audit_permissions","submissionHash":"0f8d07ead8d2a9af59cdfa3f6f3bbd5296b20f37fb30bb2a4731de9f4e437314","tag1":"review:submission","tag2":"acceptance-v2","value":1}],"site":null,"snapshotHash":"cd35113073aff14f8f8239f6d969bdf10736f65036bdcbf20a8c61c2e54cf80c","state":"completed","submissions":[{"artifacts":[],"attempt":1,"bundleHash":null,"device":"c35be49d2f8f8def","findings":[{"citation":"resolved","description":"Q1 (P1/P2/P8). In the twin branch, when the proven spot s is above the median m the quote is `low = high = s` with no reference to the median or its attested value: the `: s` arm. The lower side is bounded (low >= min(m, attestedMedian), P8) but the upper side is not, and the proven spot is ONE block's end-of-block price of pool 0xb07d that anyone can prove (ProvenPoolPrice.prove is permissionless, any of the last 32 blocks). So a pool pusher with no attester key sets q.low, q.high and q.payout of sIMD to any multiple of the honest, converged median for as long as that proof is the newest one (until the keeper's next 60 s tick re-proves, or longer if it is down). README and the brief accept exactly one consequence: an under-water loan is sheltered until a newer block is proved. Other readers take the same number as a VALUE and only require `priced` (never `agree`): (1) src/backstop/PricerOracle.sol:46 returns `(q.low, q.high, q.priced && q.low != 0)` and Backstop.nav() (src/backstop/Backstop.sol:357-372) adds `coll * high` for every held token; `_convert` (Backstop.sol:741) mints a matured deposit bucket `amount * supply / (value + 1)` shares at that nav, so a bucket converted while the pushed proof stands is diluted by the inflated sIMD term in favour of the existing holders (sIMD is a sleeve token in DeployConfig: `b.ilks[6] = SleeveIlk(\"SIMD\", true, ...)`; conversion is triggered by anyone's deposit/realize/bid). (2) LedgerBase._harvest (src/LedgerBase.sol:394) credits debt with yieldShares x q.low x (1 - fee) and adds it to reserveBacked: on a twin type with a yieldRate a pushed-up proof pays debt down at the pushed price. NOT reachable with the deploy config (SIMD is built with yieldRate NONE, DeployConfig.sol:494); it becomes reachable the moment a proven-twin type is given a yield rate. (3) Redeemer pays out at max(high, live): the redeemer receives 1/k of the collateral (documented as accepted). Under the plain median rule none of this is pushable: a disagreeing pair collapses to the median. The same branch also lets a compromised median alone raise low = high = min(m, attested) one cap per epoch above an honest proven spot (m > s arm), which is the pre-design-C behaviour and bounded by the cap; the unbounded, keyless direction is the `: s` arm. Why not simply cap it: capping the arm at max(m, attested) x (1 + skew) would break P1 (a compromised median attesting 1 wei would pull low 16% under an honest proven spot in one epoch), so P1 and an upper bound on low cannot both hold with two legs. Smallest change that keeps P1, P2 and P8 as designed: leave Pricer's low as it is for liquidation health, and make value readers require agreement on a proven-twin type: PricerOracle.priceOf returns ok = q.priced && q.agree-or-not-twin (nav() then fails closed and `_convert` waits, exactly as it does for an unpriced token), and `_harvest` keeps the mark (returns debt) unless q.agree. Reachable with the deploy config: the Pricer state yes (sIMD, skew 5%, PROVEN_MAX_AGE 6 h); the Backstop dilution additionally needs the sleeve to hold sIMD and a bucket maturing (traced by reading the code, not run end to end: stated as such).","line":99,"path":"src/Pricer.sol","reproduction":"State: sIMD-shaped graph, median = ProductFeed(production clamp leaf 1 h / 2,000 bps, ETH/USD), spot = ProductFeed(proven pool price, ETH/USD), skew 5%. Leaf attested 4e15 and converged (median = attested median = $8.00). One block end of the pool pushed 10x and proved: proven = 4e16. Call Pricer.quote. Expected (P8 read as 'a pushed proof alone moves nothing but liquidation health'): prices that value collateral stay within skew of max(median, attested median) = $8.40, or are flagged unusable. Actual: priced = true, low = high = payout = $80.00 (10x), agree = false, and PricerOracle.priceOf reports ok = true with high = $80. Test (asserts the missing upper bound; it demonstrates the state, the fix belongs in the value readers as described): `forge test --match-path 'test/scratch/ProofTwinUp.t.sol' -vv (solc 0.8.26 via_ir, forge 1.8.3)` ->\nRan 3 tests for test/scratch/ProofTwinUp.t.sol:ProofTwinUpTest\n[PASS] test_C3_headMinusOneLanding31_32_33() (gas: 4795306)\n[FAIL: next call did not revert as expected] test_bubbledOutOfGasReadsConverged() (gas: 538706)\n[FAIL: a pushed-up proof alone set low = high = payout above the attested median + skew: 80000000000000000000 > 8400000000000000000] test_pushedUpProofAloneSetsEveryPrice() (gas: 202077)\nLogs:\n  median = attested median: 8.000000000000000000\n  low: 80.000000000000000000\n  high: 80.000000000000000000\n  payout: 80.000000000000000000\nSuite result: FAILED. 1 passed; 2 failed; 0 skipped\n\nFull test file (test_pushedUpProofAloneSetsEveryPrice is this finding):\n// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {FeedTraits} from \"src/feeds/FeedTraits.sol\";\nimport {ProvenPoolPrice} from \"src/feeds/ProvenPoolPrice.sol\";\n\n/// The production clamp leaf (price question policy, 1 h, 2,000 bps) with a door to `_accept`.\ncontract PLeaf is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n\n    function set(uint256 t) external {\n        _accept(t, uint64(block.timestamp));\n    }\n}\n\n/// A plain feed; `proven()` answers what ProvenPoolPrice answers when built with `p` true.\ncontract PFeed is IFeed {\n    uint256 public v;\n    uint64 public at;\n    bool public isProven;\n\n    constructor(uint256 v_, bool p) {\n        v = v_;\n        at = uint64(block.timestamp);\n        isProven = p;\n    }\n\n    function set(uint256 v_) external {\n        v = v_;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (v, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return v == 0 || block.timestamp - at > 6 hours;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return 6 hours;\n    }\n\n    function proven() external view returns (bool) {\n        return isProven;\n    }\n}\n\ncontract PParams {\n    ParametersBase.Config internal c;\n    ParametersBase.Risk internal r;\n\n    function set(ParametersBase.Config memory c_, ParametersBase.Risk memory r_) external {\n        c = c_;\n        r = r_;\n    }\n\n    function config(bytes32) external view returns (ParametersBase.Config memory) {\n        return c;\n    }\n\n    function storedRisk(bytes32) external view returns (ParametersBase.Risk memory) {\n        return r;\n    }\n\n    function maxLull() external pure returns (uint256) {\n        return 0;\n    }\n\n    function cap(bytes32) external pure returns (uint256) {\n        return 0;\n    }\n}\n\ncontract PBurner {\n    function converged() external pure returns (bool) {\n        while (true) {}\n        return true;\n    }\n}\n\n/// A composite that reads its input's trait with a p","severity":"medium","snippet":"q.low = q.high = m > s ? Math.max(s, Math.min(m, FeedTraits.attested(c.median))) : s;","title":"Twin rule: one pushed-UP proven block end alone sets low = high = payout with no upper bound; it is read as a value by more than liquidation health (P8 'shelters a loan only' is too narrow)"},{"citation":"resolved","description":"Q3 (P4/P5). `_read` tells 'absent' from 'ran out of gas' by `gasleft() < g / 63` after the call. That holds only when the frame that ran out is the DIRECT callee (it burns its 63/64, leaving g/64 < g/63). When the callee is a composite that reads its own input with a plain external call and that inner frame runs out, the composite keeps 1/64 of its own gas, bubbles the EMPTY revert data, and returns that gas: the reader is left with about g/64 + (63/64)g/64 = 3.1% of g, above g/63 = 1.59%, and the data is empty, so the read answers ABSENT: converged() = true, attesterFree() = true. Composites that read through FeedTraits (ProductFeed, RateFeed, SeatFeed) are covered because they revert TraitUnreadable WITH data. The deployed exception is SeatSpotLeg.converged() (src/feeds/SeatFeed.sol:326): `return FeedTraits.converged(feed.spot()) && FeedTraits.converged(feed.ethUsd()) && feed.converged();` - the last term is a high-level call into SeatFeed; if that frame runs out of gas (or its inner FeedTraits read has too little left to build the TraitUnreadable revert), SeatSpotLeg reverts with empty data and the Pricer's FeedTraits.converged(c.spot) reads the seat spot leg as converged. So P5 as worded ('a failing trait read anywhere in a composite surfaces; it never reads as converged') does not hold for this composite, and for any Safe-added feed that forwards a trait with a plain call or try/catch. Impact is limited, which is why this is low: the reader is left with roughly 1/31 of what the inner read needed (a few hundred gas for SeatFeed.converged), not enough for Pricer.quote to finish, so through Ledger/Liquidator the transaction reverts and PricerOracle's try/catch fails closed; it becomes a real wrong answer only for an inner read that is expensive relative to the work after it. Smallest fix: in SeatSpotLeg read the SeatFeed through the library (`FeedTraits.converged(IFeed(address(feed)))`), and state in FeedTraits that a composite must read traits through it; optionally tighten the test to the two-level remainder (revert when gasleft() < g / 31) at the cost of more false TraitUnreadable on genuinely absent traits called with very little gas. P4 itself holds on the deploy graph: ProductFeed.proven needs one proven input and attesterFree on the other, RateFeed passes its underlying through, and every in-repo feed that has an attester below it answers converged() (SwarmFeed leaves, ProductFeed, RateFeed, SeatFeed, SeatSpotLeg); ChainlinkFeed, MarketHoursFeed, LivePoolPrice, ProvenPoolPrice and PegShareFeed have none. No overflow reaches attested(): a 2^128 target x ETH/USD x rate stays below 2^256.","line":71,"path":"src/feeds/FeedTraits.sol","reproduction":"Feed M whose converged() is `return inner.converged();` (a plain external call, as SeatSpotLeg's `feed.converged()`), inner burning all gas. Call FeedTraits.converged(M) with 300,000 gas. Expected: revert TraitUnreadable (the read failed). Actual: returns true (no revert): `[FAIL: next call did not revert as expected] test_bubbledOutOfGasReadsConverged() (gas: 538706)` from `forge test --match-path 'test/scratch/ProofTwinUp.t.sol' -vv (solc 0.8.26 via_ir, forge 1.8.3)`. Arithmetic at g = 300,000: M gets ~295k, inner gets ~290k and burns it, M bubbles empty data with ~4.6k left; the reader has ~9.2k > g/63 = 4,761. The test (PBurner, PMiddle, readConverged, test_bubbledOutOfGasReadsConverged) is in the file pasted in the first finding.","severity":"low","snippet":"if ((!ok && data.length != 0) || gasleft() < g / 63) revert TraitUnreadable(f);","title":"FeedTraits gas test misses an out-of-gas bubbled as an empty revert by a composite that calls its input directly (SeatSpotLeg -> feed.converged()): the read answers 'absent' = converged"},{"citation":"resolved","description":"C3 confirmed with one edge. Window arithmetic: the keeper builds prove(head - 1) at head H; landing in block B it passes iff B - (H - 1) <= 32, i.e. B <= H + 31. So a head-1 proof can land in H+1 .. H+31 (31 blocks, 372 s at 12 s slots; the window is in blocks, so missed slots do not shorten it), and is refused TooOld at H+32 (33 back) and H+33. The NatSpec claim that 32 covers a private relay's default 25-block hold is true (H+1 .. H+25); the '~6.4 min' in the comment is 6.2 min for the keeper's head-1 pattern. With a 60 s tick and one rebuild, a head-1 proof is stranded only by more than 31 blocks of inclusion delay; nothing in normal block times does that. Not a defect; if the intent is '32 landing blocks for head-1', the smallest change is `>` -> `> PROVE_WINDOW + 1` or proving head-1 against a window of 33. Q4, prover's choice (P6): a prover still picks among the end-of-block prices of the last 32 blocks newer than provenBlock (the documented residual); the pick cannot go below the pool's real block-end range over that window, and through the Pricer it lowers low at most to max(s, min(median, attested median)) outside agreement and to s >= median x (1 - skew) inside it, so never more than skew below min(median, attested median): confirmed by reading and by PricerTwin/AuditW4TwinLag's fuzz properties. Late keeper bundle: a prove of a block no newer than the held one is a no-op only after the header passes `blockhash` (line 107), so a bundle landing more than 256 blocks late reverts BadHeader even when a newer block is held; inside 256 blocks it is the documented no-op and the bundle keeps its hour.","line":109,"path":"src/feeds/ProvenPoolPrice.sol","reproduction":"test_C3_headMinusOneLanding31_32_33 (in the file pasted in the first finding; it uses vm.setBlockhash on a minimal 12-field header so the TooOld check is reached without a state proof): landing 31 blocks after head -> not TooOld (the call goes on to the trie); 32 and 33 -> TooOld(25999999, head + 32 / 33). Output: `[PASS] test_C3_headMinusOneLanding31_32_33() (gas: 4795306)`.","severity":"info","snippet":"if (block.number - number > PROVE_WINDOW) revert TooOld(number, block.number);","title":"C3 / Q4: PROVE_WINDOW 32 gives the keeper's head-1 proof 31 landing blocks, not 32 (confirmed by test); prover choice and the no-op rule"},{"citation":"resolved","description":"Q2 / P3 / C2: no sequence found that moves NHI or mat further than stated. Argument (any timing): epoch openings are >= maxAge apart, so a window [t, t+T) holds at most one opening t_j. (a) No move of the ending epoch inside [t, t_j): the value held at t is the new anchor A_j and every later value in the window is in band(A_j); A_j is held just before t. (b) A move of epoch j-1 at u in [t, t_j): then t_j - movedAt < T, so the carry is on and every value of epoch j is also in band(A_{j-1}); values of epoch j-1 are in band(A_{j-1}); and u < t_{j-1} + T gives t_{j-1} > t - T, so A_{j-1} was held inside the maxAge before the window. (c) No opening in the window: one epoch, same anchor argument. The carry is latched for the whole new epoch (stricter, never looser), `_movedAt` is read before `_accept` rewrites it, and the NHI leaf never takes the wide branch (`_staleMultiple` 1). Honest relays: a move at an epoch's opening leaves the next epoch free (age >= T), a move later in the epoch costs exactly one held epoch, so one cap per one or two epochs as claimed; a relayer without the key cannot do worse because honest targets on the far side of the band cause no moves. Residual as written: inside one epoch a key swings NHI anchor x 1.2 -> anchor x 0.8 (from 0.72: 0.864 -> 0.576, mat 1.70 -> 2.00). A carried anchor is the right NHI rule. Should the price legs carry it: not for sIMD (the twin bounds what the median does to low, and carrying would add an epoch of lag after a real fall, against P2); for 4663's IMD type it is the smallest change that helps, because there one key moves BOTH legs and can keep them converged and agreeing by attesting exactly the band edge: +20% at t and again at t + 1 h (+44% / -36% in a closed hour, borrowable throughout), x1.728 after 2 h which is past mat 1.7, and after a 2 h silence x1.4 x1.2 at once and x2.016 an hour later (borrow 1.186x the collateral's real value at mat 1.7). That is P7 as written, not worse; the loss is bounded only by the type's line (0, then 3,000) plus the chain line, so the line is the bound. P7: within an epoch the stored value stays in the anchor's allowance; closed maxAge (1+c)^2 - 1, after a silence (1+2c)(1+c)^2 - 1; two wide steps need two full silences (maxAge + 1 h each), so no closed maxAge exceeds the stated figure. C1: with a compromised attester (attested 1 wei) and one pushed block end P, low = max(P, min(m, 1 wei)) = P at once: the bound is the pushed block-end price itself (low >= s outside agreement, >= s / (1 + skew) inside it, m alone once the proof is older than 6 h), so the loss is every sIMD position liquidatable at P, capped by the sIMD line; a proof within 1.5% of the live pool is not re-proved by the keeper until its last hour (~5 h) and costs at most that 1.5% plus skew. Soundness: P1, P2 and P8 hold together on the lower side; following the attested median gives back the per-epoch bound only for attester-plus-push (accepted) and for a buyer who picks a 300-1,200 block window ending in the last 300 blocks whose honest median is low and also pushes a block end to it (low is then an honest window median of the last ~5 h, never below it). The upper side is the first finding. C4 not confirmed: the old rules were not rebuilt in the time available; on this commit the required baseline command finished with: Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 415.21ms (373.87ms CPU time) | Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 1.14s (1.45s CPU time) | Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 2.89s (8.16s CPU time) | Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 3.60s (1.04s CPU time) | Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 4.55s (4.55s CPU time) | Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 5.06s (9.31s CPU time) | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 10.46s (10.43s CPU time) | Ran 11 test suites in 10.61s (28.96s CPU time): 48 tests","line":555,"path":"src/feeds/SwarmFeed.sol","reproduction":"No failing input found for P3/P7 beyond the documented residuals. Concrete figures to check against the code: NHI cap 2,000 bps, maxAge 1 day: 0.85 at t0-, attest 1 wei at t0+T-1 -> 0.68; at t0+T -> 0.68 (carry = 0.85, band [0.68, 1.02]); at t0+2T-1 -> 0.68 (carry latched); at t0+2T -> 0.544. 4663 pair (cap 2,000, 1 h, skew 10%), both legs attested at exactly anchor x 1.2: t: 1.2x, t + 1 h: 1.44x, t + 2 h: 1.728x, converged and agreeing each time.","severity":"info","snippet":"if (!_carriesAnchor() || block.timestamp - uint256(_movedAt) >= maxAge) return 0;","title":"Q2 and claims C1, C2, C4: NHI's carried anchor holds for every timing (argument below); bounds for the price legs and for 4663's keyed pair; what was and was not run"}],"hash":"02ed7978a979aac850d9d630547c1077f666666f25636a61fc3442e245c2b38c","nodeId":"bb6b01e3-a593-4fbb-b0a6-d9ad9a9f3f07","outcome":"completed","summary":"The review is written to `.imd-findings.json`: four findings (one medium, one low, two info). The price properties hold on the lower side; the main defect is on the upper side of the twin rule.\n\n**What ran:** the required baseline command passed every suite on this commit, but compiling it took over ten minutes. My scratch proof file ran once: two tests fail as the findings state, and the C3 window test passes. I then deleted `test/scratch/`.\n\n**Not done:**\n- **C4 is unconfirmed.** I did not rebuild the old rules, so \"fails on the old rule\" is untested.\n- **No new fuzz or invariant suites.** The P3 result rests on a written argument plus the existing `AuditW5NhiWindow` fuzz, not the proof standard the brief asks for.\n- **The Backstop dilution is traced by reading, not run end to end.** Only the Pricer state behind it is tested.\n- **No finding carries a `proof` field.** The test source and output are pasted in the first finding's reproduction; nothing is rated high.\n\n## Findings\n\n1. **Medium — `src/Pricer.sol:99`, twin rule has no upper bound.** One pushed-up proven block end, with no attester key, sets `low = high = payout` to any multiple of an honest, converged median. The test shows $80 against a median of $8.\n   - **Who reads it as a value:** `Backstop.nav()` (through `PricerOracle.priceOf`, which only requires `priced`), so a deposit bucket converted while the proof stands is diluted. `_harvest` would also credit debt at the pushed price, but sIMD has no yield rate in the deploy config, so that part is latent.\n   - **Fix:** make value readers require agreement on a twin type. Capping the Pricer branch instead would break P1.\n\n2. **Low — `src/feeds/FeedTraits.sol:71`, the gas test misses a two-level out-of-gas.** A composite that reads its input with a plain call bubbles the failure as an empty revert, and the read answers \"converged\". `SeatSpotLeg.converged()` does this at `src/feeds/SeatFeed.sol:326`, and it is deployed. It is not exploitable through the Ledger or Liquidator, because the caller is left with too little gas to finish the quote. The test demonstrates this with a mock composite of the same shape, not the real `SeatSpotLeg`.\n\n3. **Info — C3 confirmed with one edge.** A head-1 proof can land up to 31 blocks after its head; at 32 and 33 it reverts `TooOld`. The 25-block private-relay hold fits.\n\n4. **Info — answers to Q2, C1, C2 and soundness.**\n   - **NHI (P3, C2):** I found no sequence that beats the carried anchor; the finding gives the argument for any timing. Honest relays reach the level at one cap per one or two epochs.\n   - **Price legs (P7):** the stated bounds hold.\n   - **4663 IMD type:** one key moves both legs together, converged and agreeing, to 1.728x in two hours, which is past mat 1.7. Only the line bounds the loss.\n   - **C1:** with a compromised attester plus a push, `low` is the pushed block-end price at once; the bound is the sIMD line.\n\nThe first finding also covers Q1, the third Q4, and the second Q3.\n\n`out/` and `cache/` from the build remain but are git-ignored.","treeHash":null,"usage":{"cachedInputTokens":1899296,"cost":{"source":"runtime","usdMicros":6872367},"inputTokens":26,"model":"claude-fable-5-2","outputTokens":84137,"runtime":"claude","turns":20,"wallClockMs":1587832}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"a406deaac63a93b0","findings":[{"citation":"resolved","description":"Q1 / SOUNDNESS (P1, P2, P8 together). P1 and P8 hold as written (fuzzed, see below), but following the ATTESTED median removes the only bound the design had on a pool pusher who has no key. The median leaf's target is a window median of 13 end-of-block reads of pool 0xb07d (SwarmQuestions.PRICE, span 300..1,200 blocks, so one sample per 25 blocks at the shortest span). The proven spot is one end-of-block read of the SAME pool. A pusher who holds the pool at P at the end of 7 of the 13 sampled blocks (the last 7 of a 300-block window: 150 blocks, 30 min; the last one is toBlock) gets an HONEST attestation whose answer is P. Relayed, the stored median clamps to anchor x (1 - 20%) (design C works), but attested() = P. The same person proves toBlock (pushed; within PROVE_WINDOW 32, or an 8th pushed block) and, with m > s and the legs disagreeing, low = max(s, min(m, attestedMedian)) = max(P, min(0.8A, P)) = P. Liquidator.sol passes q.low to ledger.liquidationNeed / liquidatePosition, lull is capped at 0 in the beta, and a liquidator proves and bites in one transaction, so every sIMD position with collateral ratio under mat x A / P is seized at P in that transaction. Before wave 4 the rule was max(median, spot) and the same sequence gave low = 0.8A (then 0.64A an hour later with 7 more pushes): README, wave-3 residual, still states it that way: 'A compromised attester, a wrong majority or pushed pool reads attested honestly move a leg one allowance per epoch while they last'. The accepted case in this round is 'an attester compromise together with a block-end push'; this one needs NO compromise, only the threat model's pool pusher/builder at 7-8 chosen block ends and the permissionless request, relay and prove. So a known issue is worse than written: the leg moves one allowance per epoch, but low (the liquidation price) does not. Cost side: 7-8 one-block pushes of a pool the IMD_DEPTH question itself sizes at ~15-30 ETH for a 15% move, 1% fee each way; a builder (or a top-of-next-block backrun of its own push) recovers the principal, so the cost is the fees, against the whole sIMD book priced at P. Reachable with the deploy config: yes (mainnet sIMD: median = rate x (SwarmPriceFeed 1 h / 2,000 bps x Chainlink ETH/USD), spot = rate x (ProvenPoolPrice x ETH/USD), skew 5%). Not reachable on 4663 (no proven leg, median rule). SMALLEST FIX (keeps the twin, bounds the give-back): let the attested value count at most one further allowance under the stored median: uint256 att = FeedTraits.attested(c.median); uint256 floor_ = m - Math.mulDiv(m, TWIN_STEP, 1e18); q.low = q.high = m > s ? Math.max(s, Math.min(m, Math.max(att, floor_))) : s; with TWIN_STEP the leaf's cap (0.2e18, a Risk field or constant). A genuine fall is then followed at two allowances at the first delivery (-36%) and one more per epoch, instead of at once; a pusher needs 7 pushes per epoch again. This relaxes P2 ('at its first delivery') for falls deeper than 36%: that is the scope decision, because a single window median and a single proven block are both end-of-block reads of one pool and cannot tell a held push from a fall (requiring the proof to be newer than toBlock only adds one push). If P2 is kept as is, the README residual must say that pushed reads move LOW at once and the cost is 7-8 block-end pushes, not k epochs.","line":99,"path":"src/Pricer.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy, SwarmNhiPolicy, SwarmQuestions} from \"src/feeds/SwarmFeeds.sol\";\n\n/// The four Parameters reads Pricer.quote makes, nothing else.\ncontract ParamsStub {\n    mapping(bytes32 => ParametersBase.Config) internal c;\n    mapping(bytes32 => ParametersBase.Risk) internal r;\n\n    function set(bytes32 ilk, ParametersBase.Config memory c_, ParametersBase.Risk memory r_) external {\n        c[ilk] = c_;\n        r[ilk] = r_;\n    }\n\n    function config(bytes32 ilk) external view returns (ParametersBase.Config memory) {\n        return c[ilk];\n    }\n\n    function storedRisk(bytes32 ilk) external view returns (ParametersBase.Risk memory) {\n        return r[ilk];\n    }\n\n    function maxLull() external pure returns (uint256) {\n        return 0;\n    }\n\n    function cap(bytes32) external pure returns (uint256) {\n        return 0;\n    }\n}\n\n/// The shipped median leaf (SwarmPriceFeed's policy, 1 h, 2,000 bps) with a door to `_accept`: what submitAttestation\n/// calls once the signature, question and window checks have passed. `deliver(x)` = a valid attestation of x relayed now.\ncontract MedianLeaf is SwarmPricePolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 hours, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// The shipped NHI leaf (SwarmNhiFeed's policy, 1 day, 2,000 bps) with the same door.\ncontract NhiLeaf is SwarmNhiPolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 days, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// ProvenPoolPrice's IFeed surface: the pool's price at the end of the proved block, fresh 6 h, `proven()` true.\ncontract ProvenStub {\n    uint256 internal v;\n    uint64 internal at;\n\n    function prove(uint256 endOfBlockPrice) external {\n        v = endOfBlockPrice;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (v, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return at == 0 || block.timestamp > uint256(at) + 6 hours;\n    }\n\n    function proven() external pure returns (bool) {\n        return true;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return 6 hours;\n    }\n}\n\n/// Chainlink ETH/USD stand-in: answers none of the traits.\ncontract EthUsd {\n    function latestValue() external view returns (uint256, uint64) {\n        return (2000e18, uint64(block.timestamp));\n    }\n\n    function isStale() external pure returns (bool) {\n        return false;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return type(uint64).max;\n    }\n}\n\ncontract ShareVault {\n    function convertToAssets(uint256 s) external pure returns (uint256) {\n        return s * 1.1e18 / 1e18;\n    }\n}\n\n/// sIMD as deployed: median = rate x (swarm median leaf x ETH/USD), spot = rate x (proven pool x ETH/USD), skew 5%, NHI leaf.\nabstract contract TwinRig {\n    bytes32 internal constant SIMD = \"SIMD\";\n    uint256 internal constant A = 4e15; // wei per IMD\n    MedianLeaf internal leaf;\n    NhiLeaf internal nhi;\n    ProvenStub internal proven;\n    IFeed internal median;\n    IFeed internal spot;\n    Pricer internal pricer;\n\n    function _rig() internal {\n        leaf = new MedianLeaf();\n        nhi = new NhiLeaf();\n        proven = new ProvenStub();\n        IFeed eth = IFeed(address(new EthUsd()));\n        address vault = address(new ShareVault());\n        median = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(leaf)), eth), 0)));\n        spot = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(proven)), eth), 0)));\n        ParamsStub p = new ParamsStub();\n        ParametersBase.Config memory c;\n        c.token = address(0xC011);\n        c.median = median;\n        c.spot = spot;\n        c.nhi = IFeed(address(nhi));\n        ParametersBase.Risk memory r;\n        r.mat = 1.7e18;\n        r.skew = 0.05e18;\n        p.set(SIMD, c, r);\n        pricer = new Pricer(Parameters(address(p)));\n        leaf.deliver(A);\n        nhi.deliver(0.9e18);\n        proven.prove(A);\n    }\n\n    function _usd(uint256 weiPerImd) internal pure returns (uint256) {\n        return (weiPerImd * 2000e18 / 1e18) * 1.1e18 / 1e18;\n    }\n}\n\n\n\n/// No key is compromised here. A pool pusher holds pool 0xb07d at P at the END of 7 of the 13 blocks one PRICE window\n/// samples (span 300: one sample per 25 blocks, the last is the window's toBlock). The honest panel signs the median of\n/// the 13 reads, which is P. Anyone relays it and proves the window's last block (pushed, within PROVE_WINDOW). README\n/// (wave-3 residual, design C): \"pushed pool reads attested honestly move a leg one allowance per epoch\".\ncontract ProofTwinPushedWindowTest is Test, TwinRig {\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        vm.roll(26_000_000);\n        _rig();\n    }\n\n    function _honestMedianOf13(uint256 market, uint256 pushed, uint256 pushedSamples) internal pure returns (uint256) {\n        uint256[13] memory s;\n        for (uint256 i; i < 13; ++i) s[i] = i < 13 - pushedSamples ? market : pushed;\n        for (uint256 i; i < 13; ++i) {\n            for (uint256 j = i + 1; j < 13; ++j) {\n                if (s[j] < s[i]) (s[i], s[j]) = (s[j], s[i]);\n            }\n        }\n        return s[6];\n    }\n\n    function _attack(uint256 pushed) internal returns (Pricer.Quote memory q, uint256 m) {\n        Pricer.Quote memory q0 = pricer.quote(SIMD);\n        assertTrue(q0.borrowable, \"start: legs agree at the market\");\n        assertEq(q0.low, _usd(A));\n        // 150 blocks: the 7 pushed samples (blocks T-150, T-125, ..., T) inside one 300-block window\n        vm.roll(vm.getBlockNumber() + 150);\n        vm.warp(vm.getBlockTimestamp() + 30 minutes);\n        uint256 honest = _honestMedianOf13(A, pushed, 7);\n        assertEq(honest, pushed, \"the honest median of 13 reads, 7 of them pushed\");\n        leaf.deliver(honest); // the attester's honest signature, relayed by anyone\n        proven.prove(pushed); // block T's end-of-block price, proved by anyone\n        q = pricer.quote(SIMD);\n        (m,) = median.latestValue();\n    }\n\n    /// FAILS on this commit: low = the pushed price (50% under the market) in the same epoch.\n    function test_pusherAlone_lowStaysWithinTheEpochAllowance() public {\n        (Pricer.Quote memory q, uint256 m) = _attack(A / 2);\n        assertEq(m, _usd(A * 8 / 10), \"the median leaf itself is clamped one allowance down (design C holds)\");\n        assertTrue(q.priced, \"liquidation runs at low\");\n        // one further allowance under the clamped median is the loosest reading of \"one allowance per epoch\"\n        assertGe(q.low, m * 8 / 10, \"low left the epoch's allowance at once: pushed reads + a pushed proof, no key\");\n    }\n\n    function testFuzz_pusherAlone_lowStaysWithinTheEpochAllowance(uint256 pBps) public {\n        uint256 pushed = A * bound(pBps, 100, 6_300) / 10_000;\n        (Pricer.Quote memory q, uint256 m) = _attack(pushed);\n        assertGe(q.low, m * 8 / 10, \"low = the pushed price\");\n    }\n}","reproduction":"State: leaf stored = attested = A = 4e15 wei/IMD (anchor A), proven spot A, legs agree, low = $8.80/share. Calls: (1) pool held at P = A/2 at the ends of blocks T-150, T-125, ..., T (7 of the 13 samples of window [T-300, T]); (2) the panel's honest answer = median of {6 x A, 7 x P} = P; submitAttestation relays it -> latestValue 0.8A, attested() 0.5A, converged() false; (3) ProvenPoolPrice.prove(block T) -> spot 0.5A; (4) Pricer.quote(SIMD). Expected (README residual, and the rule before wave 4): low >= the clamped median 0.8A = $7.04 (the test asks only for one FURTHER allowance, >= $5.632). Actual: low = $4.40 = the pushed price, priced = true, in the same epoch. Fuzz counterexample P = 12% of A: low = $1.056. Run: forge test --match-path test/scratch/ProofTwinPushedWindowFull.t.sol -> [FAIL: low left the epoch's allowance at once: pushed reads + a pushed proof, no key: 4400000000000000000 < 5632000000000000000] test_pusherAlone_lowStaysWithinTheEpochAllowance(); [FAIL: low = the pushed price: 1056000000000000000 < 5632000000000000000; counterexample args=[1200]] testFuzz_pusherAlone_lowStaysWithinTheEpochAllowance(uint256). Suite result: FAILED. 0 passed; 2 failed.","severity":"high","snippet":"            q.low = q.high = m > s ? Math.max(s, Math.min(m, FeedTraits.attested(c.median))) : s;","title":"Twin rule: pushed pool reads attested honestly plus one pushed proof set sIMD low to the pushed price at once (no key); the attested median gives back the per-epoch clamp"},{"citation":"resolved","description":"Q2 (P3). The carried anchor does give P3's literal statement for any timing (every value in [t, t+maxAge) is within one cap of a value held in the maxAge before: the old anchor), and I found no sequence across epoch boundaries or silences that breaks it; the README names the remaining swing ('within one epoch a compromised key can still swing NHI up a cap and back down'). What is worse than written is the conclusion drawn from it, 'so mat moves at most one cap's worth per day'. Inside a live epoch the band is the anchor's (this line), so the stored value can sit at anchor x 1.2 for the whole epoch and take anchor x 0.8 at its last second: 2c/(1+c) = 33.3% under the level held for the last day, two caps of the anchor. For any anchor in [0.7084, 0.75] that is the WHOLE mat range: NHI 0.864 (mat 1.70, lending allowed once converged) -> 0.576 (mat 2.00) in one second, the same 1.70 -> 2.00 jump the wave-5 boundary proof showed across the boundary (0.85 -> 0.544). Every sIMD loan opened at 170-200% during the day is liquidatable at once. Needs the attester key (or a wrong majority) twice. Reachable with the deploy config (NHI leaf 1 day, 2,000 bps). SMALLEST FIX: either state the bound that holds (within 2c/(1+c) of any value held in the last maxAge; mat can cross its whole range from anchors 0.7084-0.75), or make the conclusion true for a carrying leaf by keeping the epoch's high/low watermark (two uint128, one slot) and clamping also into [high x (1-c), low x (1+c)], carried with the anchor into an epoch that opens within maxAge of a move.","line":688,"path":"src/feeds/SwarmFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy, SwarmNhiPolicy, SwarmQuestions} from \"src/feeds/SwarmFeeds.sol\";\n\n/// The four Parameters reads Pricer.quote makes, nothing else.\ncontract ParamsStub {\n    mapping(bytes32 => ParametersBase.Config) internal c;\n    mapping(bytes32 => ParametersBase.Risk) internal r;\n\n    function set(bytes32 ilk, ParametersBase.Config memory c_, ParametersBase.Risk memory r_) external {\n        c[ilk] = c_;\n        r[ilk] = r_;\n    }\n\n    function config(bytes32 ilk) external view returns (ParametersBase.Config memory) {\n        return c[ilk];\n    }\n\n    function storedRisk(bytes32 ilk) external view returns (ParametersBase.Risk memory) {\n        return r[ilk];\n    }\n\n    function maxLull() external pure returns (uint256) {\n        return 0;\n    }\n\n    function cap(bytes32) external pure returns (uint256) {\n        return 0;\n    }\n}\n\n/// The shipped median leaf (SwarmPriceFeed's policy, 1 h, 2,000 bps) with a door to `_accept`: what submitAttestation\n/// calls once the signature, question and window checks have passed. `deliver(x)` = a valid attestation of x relayed now.\ncontract MedianLeaf is SwarmPricePolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 hours, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// The shipped NHI leaf (SwarmNhiFeed's policy, 1 day, 2,000 bps) with the same door.\ncontract NhiLeaf is SwarmNhiPolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 days, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// ProvenPoolPrice's IFeed surface: the pool's price at the end of the proved block, fresh 6 h, `proven()` true.\ncontract ProvenStub {\n    uint256 internal v;\n    uint64 internal at;\n\n    function prove(uint256 endOfBlockPrice) external {\n        v = endOfBlockPrice;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (v, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return at == 0 || block.timestamp > uint256(at) + 6 hours;\n    }\n\n    function proven() external pure returns (bool) {\n        return true;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return 6 hours;\n    }\n}\n\n/// Chainlink ETH/USD stand-in: answers none of the traits.\ncontract EthUsd {\n    function latestValue() external view returns (uint256, uint64) {\n        return (2000e18, uint64(block.timestamp));\n    }\n\n    function isStale() external pure returns (bool) {\n        return false;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return type(uint64).max;\n    }\n}\n\ncontract ShareVault {\n    function convertToAssets(uint256 s) external pure returns (uint256) {\n        return s * 1.1e18 / 1e18;\n    }\n}\n\n/// sIMD as deployed: median = rate x (swarm median leaf x ETH/USD), spot = rate x (proven pool x ETH/USD), skew 5%, NHI leaf.\nabstract contract TwinRig {\n    bytes32 internal constant SIMD = \"SIMD\";\n    uint256 internal constant A = 4e15; // wei per IMD\n    MedianLeaf internal leaf;\n    NhiLeaf internal nhi;\n    ProvenStub internal proven;\n    IFeed internal median;\n    IFeed internal spot;\n    Pricer internal pricer;\n\n    function _rig() internal {\n        leaf = new MedianLeaf();\n        nhi = new NhiLeaf();\n        proven = new ProvenStub();\n        IFeed eth = IFeed(address(new EthUsd()));\n        address vault = address(new ShareVault());\n        median = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(leaf)), eth), 0)));\n        spot = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(proven)), eth), 0)));\n        ParamsStub p = new ParamsStub();\n        ParametersBase.Config memory c;\n        c.token = address(0xC011);\n        c.median = median;\n        c.spot = spot;\n        c.nhi = IFeed(address(nhi));\n        ParametersBase.Risk memory r;\n        r.mat = 1.7e18;\n        r.skew = 0.05e18;\n        p.set(SIMD, c, r);\n        pricer = new Pricer(Parameters(address(p)));\n        leaf.deliver(A);\n        nhi.deliver(0.9e18);\n        proven.prove(A);\n    }\n\n    function _usd(uint256 weiPerImd) internal pure returns (uint256) {\n        return (weiPerImd * 2000e18 / 1e18) * 1.1e18 / 1e18;\n    }\n}\n\n\n\n/// P3 concludes \"mat moves at most one cap's worth per day\". NHI held 0.864 (mat 1.70) for a day less two seconds, then\n/// one attestation takes it to 0.576 (mat 2.00): two caps of the anchor, 33.3% of the held value, the whole mat range.\ncontract ProofNhiSwingTest is Test, TwinRig {\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        vm.roll(26_000_000);\n        _rig();\n    }\n\n    function test_matMovesAtMostOneCapsWorthFromADayLongLevel() public {\n        NhiLeaf f = new NhiLeaf();\n        f.deliver(0.72e18); // the honest level; opens the epoch, anchor 0.72\n        vm.warp(vm.getBlockTimestamp() + 1);\n        f.deliver(1e18); // compromised key: up one cap\n        (uint256 held,) = f.latestValue();\n        assertEq(held, 0.864e18);\n        vm.warp(vm.getBlockTimestamp() + 1 days - 2); // the last second of the same epoch\n        (uint256 before,) = f.latestValue();\n        assertEq(before, 0.864e18, \"held for a day less two seconds\");\n        f.deliver(0.1e18);\n        (uint256 afterV,) = f.latestValue();\n        emit log_named_decimal_uint(\"NHI held all day\", before, 18);\n        emit log_named_decimal_uint(\"NHI one second later\", afterV, 18);\n        // one cap's worth from the level held all day\n        assertGe(afterV, before * 8 / 10, \"NHI fell more than one cap from the value held for the last day\");\n    }\n}","reproduction":"NHI leaf (SwarmNhiPolicy, 1 day, 2,000 bps): accept 0.72e18 at t0 (anchor 0.72); t0+1 s accept 1e18 -> stored 0.864e18 (mat 1.70); t0+86,399 s (same epoch) accept 0.1e18 -> stored 0.576e18 (mat 2.00). Expected by 'one cap's worth per day': >= 0.864 x 0.8 = 0.6912. Actual 0.576. Run: forge test --match-path test/scratch/ProofNhiSwingFull.t.sol -> [FAIL: NHI fell more than one cap from the value held for the last day: 576000000000000000 < 691200000000000000] test_matMovesAtMostOneCapsWorthFromADayLongLevel().","severity":"low","snippet":"            (anchor, bound) = (_anchorValue, _anchorBound);","title":"NHI: P3's conclusion 'mat moves at most one cap's worth per day' is false inside one epoch: NHI held 0.864 for a day less seconds falls to 0.576 (mat 1.70 -> 2.00) in one attestation"},{"citation":"resolved","description":"No defect; the answer the brief asks for. The keeper sees head H and proves H-1. Landing in block H+k the distance is block.number - number = k+1, accepted iff k+1 <= 32, i.e. k <= 31 (about 6.2 min of produced blocks; missed slots do not count, block.number only advances on produced blocks). A private relay holding the bundle its default 25 blocks lands at distance 26: 6 blocks (72 s) of margin, so the header's claim holds; a keeper that proved the head itself would have 7. At k >= 32 with nothing newer held the prove reverts TooOld and the atomic [prove, sample] bundle fails (rebuilt and sent once, per the brief); if anyone holds the same or a newer block it is a no-op and the bundle proceeds, so a third party cannot make it lose its hour by proving first. Blocks more than 256 back revert BadHeader before the no-op rule (blockhash 0), which only matters for a bundle 51 min late. P6: a prover still chooses among up to 32 end-of-block prices whenever the held proof is older than the window (the keeper re-proves only past 1.5%, so that is the usual state): README-known as written; with a converged median it moves low at most skew (fuzz testFuzz_P8_pushedProofAlone). C1: confirmed and bounded: with the key signing any value at or under a pushed block-end price P, low == P exactly (no floor from the leaf's clamp; fuzz, 256 runs); the key alone leaves low at the proven spot (P1 holds); a pushed proof alone never lowers low more than skew under min(median, attested) and a pushed-up one sets low = s only until a newer block is proved (P8 holds). A proof within 1.5% of the live pool is not re-proved until 1 h before its 6 h life: ~5 h standing, by the brief's keeper rule (off-repo, not testable here). C4: the required suite passes on this commit (11 suites, 48 tests, 0 failed, solc 0.8.26 via_ir). I did not re-run the wave-4/5 proofs against the old rules (time), so 'fail on the old rule' is NOT verified by me.","line":109,"path":"src/feeds/ProvenPoolPrice.sol","reproduction":"forge test --match-path test/scratch/ProofClaims.t.sol (source in proof-free text below is in the report): [PASS] test_C3_headMinus1ProofLanding31_32_33BlocksAfterItsHead() (k = 1, 25, 31 accepted; k = 32, 33 revert TooOld(F.BLOCK, head)); [PASS] testFuzz_C1_attesterPlusPush_lowIsExactlyThePushedBlockEnd (runs: 256); [PASS] testFuzz_P8_pushedProofAlone (runs: 256); [PASS] test_C2_honestHourlyRelaysReachTheLevel; [PASS] test_P7_priceLegBounds. Suite result: ok. 5 passed; 0 failed. Test source:\n// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {ProvenPoolPrice} from \"src/feeds/ProvenPoolPrice.sol\";\nimport {ProvenPoolFixture as F} from \"test/fixtures/ProvenPoolFixture.sol\";\nimport {TwinRig, NhiLeaf, MedianLeaf} from \"./Harness.sol\";\n\ncontract ProofClaimsTest is Test, TwinRig {\n    address constant MANAGER = 0x000000000004444c5dc75cB358380D2e3dE08A90;\n    bytes32 constant POOL = 0xb07d640fd9e2eb9dc81b953c8e4fd006bdfeaf276010fb5418eb763ca15abfb3;\n\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        vm.roll(26_000_000);\n        _rig();\n    }\n\n    // ---- C3: the keeper sees head H = F.BLOCK + 1 and proves head-1 = F.BLOCK; the bundle lands k blocks after H.\n    function _lands(uint256 k) internal returns (bool ok) {\n        vm.etch(MANAGER, hex\"00\");\n        ProvenPoolPrice feed = new ProvenPoolPrice(MANAGER, POOL, false, 6 hours);\n        vm.warp(F.TIMESTAMP + 12 * (k + 1));\n        vm.roll(F.BLOCK + 1 + k);\n        vm.setBlockhash(F.BLOCK, F.BLOCK_HASH);\n        try feed.prove(F.header(), F.accountProof(), F.storageProof()) {\n            ok = feed.provenBlock() == F.BLOCK;\n        } catch (bytes memory err) {\n            assertEq(err, abi.encodeWithSelector(ProvenPoolPrice.TooOld.selector, F.BLOCK, F.BLOCK + 1 + k));\n        }\n    }\n\n    function test_C3_headMinus1ProofLanding31_32_33BlocksAfterItsHead() public {\n        assertTrue(_lands(1), \"next block\");\n        assertTrue(_lands(25), \"a private relay's default 25 blocks\");\n        assertTrue(_lands(31), \"31 blocks after the head: distance 32, the last one accepted\");\n        assertFalse(_lands(32), \"32 blocks after the head: distance 33, TooOld\");\n        assertFalse(_lands(33), \"33 blocks after the head: TooOld\");\n    }\n\n    // ---- C1 / P1 / P8\n    function testFuzz_C1_attesterPlusPush_lowIsExactlyThePushedBlockEnd(uint256 pBps, uint256 signed) public {\n        uint256 pushed = A * bound(pBps, 1, 7_900) / 10_000;\n        signed = bound(signed, 1, pushed); // the compromised key signs anything at or under the pushed price\n        vm.warp(vm.getBlockTimestamp() + 60);\n        leaf.deliver(signed);\n        // P1: the key alone (no push, the proof still at the market) lowers nothing\n        assertEq(pricer.quote(SIMD).low, _usd(A), \"P1: compromised median alone, low stays at the proven spot\");\n        proven.prove(pushed);\n        Pricer.Quote memory q = pricer.quote(SIMD);\n        (uint256 m,) = median.latestValue();\n        assertEq(m, _usd(A * 8 / 10), \"the stored median is still one allowance down\");\n        assertEq(q.low, _usd(pushed), \"C1: low = the pushed block-end price, at once\");\n        assertFalse(q.borrowable);\n    }\n\n    function testFuzz_P8_pushedProofAlone(uint256 pBps) public {\n        uint256 pushed = A * bound(pBps, 1, 30_000) / 10_000;\n        proven.prove(pushed);\n        Pricer.Quote memory q = pricer.quote(SIMD);\n        uint256 m = _usd(A); // median converged: attested == stored\n        if (pushed < A) assertGe(q.low, m * 95 / 100, \"down: never more than skew under min(m, attested)\");\n        else if (pushed > A * 105 / 100) assertEq(q.low, _usd(pushed), \"up past skew: low = s, the shelter\");\n        proven.prove(A); // a newer block at the market\n        assertEq(pricer.quote(SIMD).low, _usd(A), \"the shelter ends at the next proof\");\n    }\n\n    // ---- C2: NHI, honest hourly relays of a real fall 0.85 -> 0.5\n    function test_C2_honestHourlyR","severity":"info","snippet":"        if (block.number - number > PROVE_WINDOW) revert TooOld(number, block.number);","title":"C3 / Q4 (P6): PROVE_WINDOW arithmetic confirmed: a head-1 proof is accepted up to 31 blocks after its head, refused at 32 and 33; no defect"},{"citation":"resolved","description":"No defect; answers. C2 confirmed: honest hourly relays of a real fall 0.85 -> 0.5 store 0.68 at hour 1, are held at the carried edge through hour 47, 0.544 at hour 48, 0.5 at hour 72 (the first epoch after a move costs a second epoch, then one cap per epoch): one cap per two epochs worst case, as stated. I found no interleaving across boundaries or silences that breaks P3's literal statement (the in-epoch swing is the separate low finding). P7 confirmed exactly on the shipped price policy (1 h, 2,000 bps): -36% in two attestations one second apart across a boundary; after a 2 h silence the wide step and a cap in one block (-52%), and -61.6% over the closed hour; nothing further found. 4663 (no twin): one key signs BOTH swarm legs, so the 10% skew never trips and each in-band target is converged, i.e. borrowable: +44% in one second across a boundary (+101.6% within the hour after a 2 h silence, which needs honest relays absent) lets the key holder borrow against IMD at 1.44x-2.02x, bounded by the type's line (0 at genesis, 3,000 imdUSD after the Safe raises it): bad debt <= 3,000; downward (-36% in one second, -61.6% after a silence) every 4663 IMD position is exposed to liquidation at that price. Should the price legs carry the anchor too? For mainnet sIMD the carry would not help (the high finding goes through attested(), not the stored leg). For 4663 it would: a 4663 price/spot policy with _carriesAnchor() true and _staleMultiple() 1 (a carrying leaf must not widen) cuts the one-second boundary move from 44%/36% to 20% at the cost of following a gap one cap per one or two hours; that is two small leaf contracts, no base change. Q3 (P4, P5): ProductFeed.proven requires the other input attester-free; RateFeed, SeatFeed and SeatSpotLeg forward converged(); DeployBase._provenAtDeploy/_attesterFreeAtDeploy mirror the rule and read an EXISTING node as not free; MarketHoursFeed and ChainlinkFeed sit on Chainlink aggregators (no attester below them). I found no deployed or addable node of the shipped kinds that reads converged, proven or attester-free wrongly, and no swallowed failing read; I did not test an EXISTING node behind a proxy whose fallback returns empty success (README-known).","line":563,"path":"src/feeds/SwarmFeed.sol","reproduction":"See test_C2_honestHourlyRelaysReachTheLevel and test_P7_priceLegBounds in the previous note's test source; both pass on this commit.","severity":"info","snippet":"    function _carriesAnchor() internal pure virtual returns (bool) {","title":"C2 / P7 / 4663 / Q3: carried anchor and sliding bound confirmed as stated; what one key moves on 4663; traits clean; no defect"}],"hash":"0f8d07ead8d2a9af59cdfa3f6f3bbd5296b20f37fb30bb2a4731de9f4e437314","nodeId":"af468e58-7247-4626-a353-1fd8a2682b81","outcome":"completed","summary":"The review is written to `.imd-findings.json`: one high finding, one low, and two info notes carrying the claim answers. No repository files were changed; the scratch tests are deleted.\n\nThe required suite passes on this commit (11 suites, 48 tests, solc 0.8.26 via_ir). Both finding proofs were run and fail as stated; the claim checks pass.\n\n## Findings\n\n**High — `src/Pricer.sol:99`: a pool pusher with no key sets sIMD `low` to a pushed price at once.**\n- **Sequence:** hold pool 0xb07d at P at the end of 7 of the 13 blocks one median window samples (30 min at the shortest span). The honest panel then signs P. Relay it and prove the pushed last block.\n- **Result:** the stored median clamps to 0.8A as designed, but `attested()` is P, so `low = max(s, min(m, attested)) = P`.\n- **Test:** with P = A/2, low is $4.40 where the clamped median is $7.04. The fuzz counterexample at 12% of A gives $1.056.\n- **Why it is worse than written:** the README still says pushed reads attested honestly move a leg \"one allowance per epoch\". That holds for the leg, but no longer for the liquidation price.\n- **Reach:** mainnet sIMD under the deploy config; not 4663.\n- **Smallest fix:** let the attested value count at most one further allowance under the stored median. This relaxes P2 for falls deeper than 36%, which is a scope decision for you.\n\n**Low — `src/feeds/SwarmFeed.sol:688`: \"mat moves at most one cap's worth per day\" does not hold inside one epoch.**\n- **Sequence:** NHI held at 0.864 for a day less seconds falls to 0.576 in one attestation, so mat goes 1.70 → 2.00.\n- **Scope:** this is the README's known up-and-down swing; the stated consequence is what is wrong. The real bound is 33.3% of a held value, and the whole mat range from anchors 0.7084–0.75.\n- **P3:** its literal statement held in every sequence I tried.\n\n## Numbered questions\n\n1. **Twin rule (P1, P2, P8):** P1 and P8 hold as written (fuzzed). Following the attested median does give back the clamp for a pusher: the high finding.\n2. **NHI and legs (P3, P7):** nothing moves further than stated across boundaries or silences, apart from the low finding. P7 reproduces exactly: −36% in two seconds across a boundary, −61.6% over the closed hour after a silence.\n3. **Traits (P4, P5):** no composite or deploy node of the shipped kinds reads proven, converged or attester-free wrongly, and I found no swallowed failing read. I did not test an existing node behind a proxy whose fallback returns empty success.\n4. **Prover (P6):** a prover still chooses among up to 32 end-of-block prices, as the README says. A third party proving first cannot cost the keeper its hour, because a same-or-older block is a no-op.\n\n## Claims\n\n- **C1 confirmed:** with the key signing at or under a pushed price P, `low` equals P exactly; the leaf's clamp gives no floor. The ~5 h standing time follows from the keeper rule, which is off-repo and not testable here.\n- **C2 confirmed:** honest hourly relays of 0.85 → 0.5 store 0.68 at hour 1, hold through hour 47, reach 0.544 at hour 48 and 0.5 at hour 72.\n- **C3 confirmed:** a head-1 proof is accepted up to 31 blocks after its head and refused at 32 and 33. A private relay's 25-block hold leaves 6 blocks of margin.\n- **C4 half verified:** the proofs pass on this commit. I did not re-run them against the old rules, so \"fail on the old rule\" is unverified.\n\n## Soundness and 4663\n\nA carried anchor is the right NHI rule for the boundary case. Carrying it on the mainnet price legs would not help, since the high finding goes through `attested()`, not the stored leg.\n\nOn 4663 one key signs both legs, so skew never trips: +44% in one second across a boundary, with bad debt bounded by the 3,000 line, and −36% downward. Two carrying leaf policies for 4663 would cut that to 20%.\n\n## Coverage limits\n\n- The first compile took over ten minutes, so the invariant-style extension of `SwarmFeedProperties`, `AuditW4TwinLag` and `AuditW5NhiWindow` was not done; the proofs are targeted unit an","treeHash":null,"usage":{"cachedInputTokens":1514080,"cost":{"source":"runtime","usdMicros":5064948},"inputTokens":30,"model":"claude-fable-5-2","outputTokens":59885,"runtime":"claude","turns":18,"wallClockMs":1391158}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"e293ff3324f7ddb5","findings":[{"citation":"resolved","description":"_carryNow() stops carrying the previous anchor once the last move is >= maxAge old. An epoch opened by a move at t1 ends at exactly t1 + maxAge, which is the same instant the carry lapses, so the next epoch opens at t1 + maxAge with no carry and takes a second full cap. P3 holds only for half-open windows [t, t+maxAge) (the definition in AuditW5NhiWindow); over the closed day [t1, t1 + 86,400 s] NHI moves (1-c)^2 = -36% (0.85 -> 0.68 -> 0.544) and mat 1.70 -> 2.00, which is the wave-5 boundary result stretched from 1 s to exactly 1 day rather than closed. The price legs' own P7 bound is stated for CLOSED windows, so the NHI rule is weaker than the closed-window reading of 'mat moves at most one cap per day'. Reachable with the deploy config (NHI 1 day, cap 2,000) by one compromised/wrong attester key, or honestly by any two deliveries 86,400 s apart during a real fall. Smallest fix: `> maxAge` in _carryNow (carry also at exactly maxAge); liveness cost is one second.","line":555,"path":"src/feeds/SwarmFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmNhiPolicy} from \"src/feeds/SwarmFeeds.sol\";\n\ncontract NhiDoor is SwarmNhiPolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 days, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// NHI moves two caps (0.85 -> 0.68 -> 0.544, mat 1.7 -> 2.0) inside one CLOSED day [t1, t1 + 1 day]:\n/// `_carryNow` drops the carried anchor when the last move is EXACTLY maxAge old (>=), the same instant the next epoch opens.\ncontract NhiClosedDayTest is Test {\n    function test_twoCapsInsideOneClosedDay() public {\n        vm.warp(1_800_000_000);\n        NhiDoor n = new NhiDoor();\n        n.set(0.85e18);\n        vm.warp(vm.getBlockTimestamp() + 3 days);\n        n.set(0.85e18); // fresh relay, no move\n        vm.warp(vm.getBlockTimestamp() + 1 days);\n        uint256 t1 = vm.getBlockTimestamp();\n        n.set(0.1e18); // opens an epoch: 0.85 -> 0.68 at t1\n        (uint256 v1,) = n.latestValue();\n        assertEq(v1, 0.68e18);\n        vm.warp(t1 + 1 days); // the closed window [t1, t1 + 1 day]\n        n.set(0.1e18);\n        (uint256 v2,) = n.latestValue();\n        emit log_named_uint(\"t2 - t1\", vm.getBlockTimestamp() - t1);\n        emit log_named_uint(\"v2\", v2);\n        // every value in the window must be within one cap of 0.85 (the only value held in the day before it)\n        assertGe(v2, 0.68e18, \"two caps inside one closed day\");\n    }\n}","reproduction":"SwarmNhiFeed (maxAge 1 day, cap 2000): value 0.85 held > 1 day; at t1 deliver 0.1 -> stored 0.68 (epoch opens, anchor 0.85, no carry). At t1 + 86400 deliver 0.1 -> epoch opens with anchor 0.68 and _carryNow() = 0 (elapsed == maxAge) -> stored 0.544. Expected (one cap per closed day): >= 0.68. Actual: 0.544. forge test --match-path test/scratch/NhiClosedDay.t.sol: [FAIL: two caps inside one closed day: 544000000000000000 < 680000000000000000], logs t2 - t1: 86400, v2: 544000000000000000.","severity":"low","snippet":"        if (!_carriesAnchor() || block.timestamp - uint256(_movedAt) >= maxAge) return 0;","title":"NHI carried anchor is dropped at exactly maxAge after the last move: two caps (NHI 0.85 -> 0.544, mat 1.70 -> 2.00) inside one closed day"}],"hash":"2da71b3d296fbb48107ddce6da70aed0e8e011c65e50f5aa88f7162f28f632ed","nodeId":"ac61ffee-a5c0-4867-9559-c4cc70b03302","outcome":"completed","summary":"I found one low-severity defect and recorded it in `.imd-findings.json`. Nothing at critical, high or medium severity came out of the reviewed area.\n\n**How it was run:** this machine has no `--use solar`, so everything ran under solc 0.8.26 with via_ir. The ten assigned suites passed: 48 tests, 0 failed. The extra proofs went into one file, `test/unit/ProofW5Econ.t.sol`. I ran it and then deleted it; its results are under each question below. One of its five tests was broken, so claim C2 is reasoned, not tested (see C2). The `.bashrc`, `.claude/`, `.vscode` and similar untracked files in the tree are not mine and I left them alone.\n\n## Finding (low): two NHI caps fit inside one closed day\n- **Where:** `src/feeds/SwarmFeed.sol:555`, `if (!_carriesAnchor() || block.timestamp - uint256(_movedAt) >= maxAge) return 0;`\n- **Cause:** a move at t1 opens an epoch that ends at exactly t1 + 86,400 s. That is the same instant the carried anchor lapses, so the next epoch opens with nothing carried and takes a second full cap.\n- **Failing state:** NHI goes 0.85 → 0.68 at t1, then → 0.544 at t1 + 86,400 s. Mat goes 1.70 → 2.00 in one closed day.\n- **Reachable:** yes, with the deploy config (NHI 1 day, cap 2,000). One wrong key can do it, and so can honest deliveries during a real fall.\n- **Scope of the miss:** P3 holds for the half-open window `[t, t+maxAge)` that `AuditW5NhiWindow` uses. It fails the closed-window reading, which is the one P7 uses for the price legs.\n- **Smallest fix:** change `>=` to `>`. Liveness costs one second.\n- **Test:** `test/scratch/NhiClosedDay.t.sol` → `[FAIL: two caps inside one closed day: 544000000000000000 < 680000000000000000]`, logs `t2 - t1: 86400`, `v2: 544000000000000000`.\n\n## Numbered questions\n1. **P1, P2, P8 hold together.** The twin rule is `max(s, min(m, attested))`, which can never go below the proven spot s.\n   - Clamped-high median: `min(m, attested)` drops it to the attested value, and a stale attested value can't push below s either.\n   - Pushed-down proof: floored at `min(m, attested)`, or at m(1−skew) when the legs agree.\n   - Pushed-up proof: if m < s, `low = s` only until anyone proves a newer block.\n   - Following the attested median gives nothing back. Only the accepted attester-plus-push case lowers `low`.\n   - **Test:** `testFuzz_twin_P1_P8` passed 256 runs. `test_twin_P2_firstDelivery` passed: after a 40% fall `low` moved onto the attested 3.0e15 at its first delivery, then onto the market 2.4e15.\n2. **Nothing moves further than stated, apart from the finding above.** On 4663's IMD type one key moves both swarm legs, still converged and agreeing:\n   - (1+c)²−1 = +44% over a closed hour;\n   - (1+2c)(1+c)²−1 = +101.6% after a silence;\n   - (1+c)^k over k hours.\n   - New debt is limited by the type's line (3,000), so loss to one key is bounded by the line. That is as the README states, not worse.\n3. **No wrong `proven` or `converged` found, and no swallowed failing read.**\n   - `ProductFeed` and `RateFeed` forward all three traits.\n   - Every deployed swarm leaf, `SeatFeed` and `SeatSpotLeg` answer `converged()`.\n   - The out-of-gas check catches inner failures: an outer frame keeps under 1/64 of its gas, which is below the 1/63 the check requires.\n   - The feeds that answer \"absent\" (Chainlink, `MarketHoursFeed`, `LivePoolPrice`, `PegShareFeed`) have no attester in their path.\n4. **The prover's choice is limited to the last 32 end-of-block prices (about 6.4 min), and to skew below the median through the Pricer.** A late keeper bundle loses its hour only if it lands more than 32 blocks after the block it proves, and not at all if someone has already proved a newer block (that is a no-op).\n\n## Claims\n- **C1 confirmed by reasoning, no test.** With a compromised attester plus a push, `low` is no lower than the pushed block-end price. A proof that stays within 1.5% of the live pool is not re-proved until the last hour of its 6 h life, so it can stand about 5 h.\n- **C2 holds by reasoning (half","treeHash":null,"usage":{"cachedInputTokens":2143009,"cost":{"source":"runtime","usdMicros":2189024},"inputTokens":48,"model":"claude-opus-5-5","outputTokens":39577,"runtime":"claude","turns":26,"wallClockMs":1579586}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"3c1226d190150ef0","findings":[{"citation":"resolved","description":"Q1 / SOUNDNESS. P1 and P8 hold as worded, but P2 (low reaches the attested median at its first delivery) removes the per-epoch bound on a pool pusher who has NO key. The median leaf's question (SwarmQuestions.PRICE, src/feeds/SwarmFeeds.sol:13-15) asks for the median of 13 evenly spaced end-of-block reads of pool 0xb07d over a requester-chosen window of 300..1,200 blocks; the proven spot is one end-of-block read of the SAME pool. A pusher who holds the pool at P at the ends of 7 of the 13 sampled blocks (for a 300-block window: T-150, T-125, ..., T, i.e. 7 block ends over ~30 min) gets an HONEST attestation whose answer is P. Relayed, the leaf still clamps the stored median to anchor x 0.8 (latestValue 0.8A), but attested() = P and converged() = false. The same actor proves block T (pushed; within PROVE_WINDOW). The legs disagree, the spot is proven and fresh, m > s, so line 99 gives low = max(P, min(0.8A, P)) = P. Liquidator passes q.low to the Ledger, lull is 0 in the beta, so every sIMD position with collateral ratio below mat x A / P is seizable at P in the proving transaction. README (wave-3 residual, design-C section) still says 'pushed pool reads attested honestly move a leg one allowance per epoch while they last': the leg does, LOW does not. Before wave 4 the rule (max(median, spot)) gave low = 0.8A here. The user-ACCEPTED case is 'attester compromise + block-end push'; this needs no compromise, only the threat model's pusher/builder at 8 chosen block ends (7 sampled + the proved one, which can be the 7th) and permissionless request, relay and prove: a known issue worse than written. Cost: the fees and arbitrage loss of 7-8 one-block pushes (a builder that also backruns its own push recovers most of the principal), against the whole sIMD book at P. Reachable with the deploy config: yes (mainnet sIMD: median = rate x (SwarmPriceFeed 1 h / 2,000 bps x ETH/USD), spot = rate x (ProvenPoolPrice x ETH/USD), skew 5%). Not on 4663 (no proven leg). SMALLEST FIX (keeps the twin; scope decision on P2): let the attested value count at most one further allowance under the stored median: `uint256 floor_ = m - Math.mulDiv(m, TWIN_STEP, 1e18); q.low = q.high = m > s ? Math.max(s, Math.min(m, Math.max(FeedTraits.attested(c.median), floor_))) : s;` with TWIN_STEP = the leaf cap (0.2e18). A genuine fall is then followed at -36% at the first delivery and one cap per epoch after, and a pusher again needs 7 pushes per epoch. If P2 is kept as is, the README residual must state that pushed reads move LOW at once and the attack costs 7-8 block-end pushes. Pool sampling and window choice are from the question text and the specialist's trace; the Pricer arithmetic is reproduced by the test.","line":99,"path":"src/Pricer.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy, SwarmNhiPolicy, SwarmQuestions} from \"src/feeds/SwarmFeeds.sol\";\n\n/// The four Parameters reads Pricer.quote makes, nothing else.\ncontract ParamsStub {\n    mapping(bytes32 => ParametersBase.Config) internal c;\n    mapping(bytes32 => ParametersBase.Risk) internal r;\n\n    function set(bytes32 ilk, ParametersBase.Config memory c_, ParametersBase.Risk memory r_) external {\n        c[ilk] = c_;\n        r[ilk] = r_;\n    }\n\n    function config(bytes32 ilk) external view returns (ParametersBase.Config memory) {\n        return c[ilk];\n    }\n\n    function storedRisk(bytes32 ilk) external view returns (ParametersBase.Risk memory) {\n        return r[ilk];\n    }\n\n    function maxLull() external pure returns (uint256) {\n        return 0;\n    }\n\n    function cap(bytes32) external pure returns (uint256) {\n        return 0;\n    }\n}\n\n/// The shipped median leaf (SwarmPriceFeed's policy, 1 h, 2,000 bps) with a door to `_accept`: what submitAttestation\n/// calls once the signature, question and window checks have passed. `deliver(x)` = a valid attestation of x relayed now.\ncontract MedianLeaf is SwarmPricePolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 hours, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// The shipped NHI leaf (SwarmNhiFeed's policy, 1 day, 2,000 bps) with the same door.\ncontract NhiLeaf is SwarmNhiPolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 days, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// ProvenPoolPrice's IFeed surface: the pool's price at the end of the proved block, fresh 6 h, `proven()` true.\ncontract ProvenStub {\n    uint256 internal v;\n    uint64 internal at;\n\n    function prove(uint256 endOfBlockPrice) external {\n        v = endOfBlockPrice;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (v, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return at == 0 || block.timestamp > uint256(at) + 6 hours;\n    }\n\n    function proven() external pure returns (bool) {\n        return true;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return 6 hours;\n    }\n}\n\n/// Chainlink ETH/USD stand-in: answers none of the traits.\ncontract EthUsd {\n    function latestValue() external view returns (uint256, uint64) {\n        return (2000e18, uint64(block.timestamp));\n    }\n\n    function isStale() external pure returns (bool) {\n        return false;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return type(uint64).max;\n    }\n}\n\ncontract ShareVault {\n    function convertToAssets(uint256 s) external pure returns (uint256) {\n        return s * 1.1e18 / 1e18;\n    }\n}\n\n/// sIMD as deployed: median = rate x (swarm median leaf x ETH/USD), spot = rate x (proven pool x ETH/USD), skew 5%, NHI leaf.\nabstract contract TwinRig {\n    bytes32 internal constant SIMD = \"SIMD\";\n    uint256 internal constant A = 4e15; // wei per IMD\n    MedianLeaf internal leaf;\n    NhiLeaf internal nhi;\n    ProvenStub internal proven;\n    IFeed internal median;\n    IFeed internal spot;\n    Pricer internal pricer;\n\n    function _rig() internal {\n        leaf = new MedianLeaf();\n        nhi = new NhiLeaf();\n        proven = new ProvenStub();\n        IFeed eth = IFeed(address(new EthUsd()));\n        address vault = address(new ShareVault());\n        median = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(leaf)), eth), 0)));\n        spot = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(proven)), eth), 0)));\n        ParamsStub p = new ParamsStub();\n        ParametersBase.Config memory c;\n        c.token = address(0xC011);\n        c.median = median;\n        c.spot = spot;\n        c.nhi = IFeed(address(nhi));\n        ParametersBase.Risk memory r;\n        r.mat = 1.7e18;\n        r.skew = 0.05e18;\n        p.set(SIMD, c, r);\n        pricer = new Pricer(Parameters(address(p)));\n        leaf.deliver(A);\n        nhi.deliver(0.9e18);\n        proven.prove(A);\n    }\n\n    function _usd(uint256 weiPerImd) internal pure returns (uint256) {\n        return (weiPerImd * 2000e18 / 1e18) * 1.1e18 / 1e18;\n    }\n}\n\n\n\n/// No key is compromised here. A pool pusher holds pool 0xb07d at P at the END of 7 of the 13 blocks one PRICE window\n/// samples (span 300: one sample per 25 blocks, the last is the window's toBlock). The honest panel signs the median of\n/// the 13 reads, which is P. Anyone relays it and proves the window's last block (pushed, within PROVE_WINDOW). README\n/// (wave-3 residual, design C): \"pushed pool reads attested honestly move a leg one allowance per epoch\".\ncontract ProofTwinPushedWindowTest is Test, TwinRig {\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        vm.roll(26_000_000);\n        _rig();\n    }\n\n    function _honestMedianOf13(uint256 market, uint256 pushed, uint256 pushedSamples) internal pure returns (uint256) {\n        uint256[13] memory s;\n        for (uint256 i; i < 13; ++i) s[i] = i < 13 - pushedSamples ? market : pushed;\n        for (uint256 i; i < 13; ++i) {\n            for (uint256 j = i + 1; j < 13; ++j) {\n                if (s[j] < s[i]) (s[i], s[j]) = (s[j], s[i]);\n            }\n        }\n        return s[6];\n    }\n\n    function _attack(uint256 pushed) internal returns (Pricer.Quote memory q, uint256 m) {\n        Pricer.Quote memory q0 = pricer.quote(SIMD);\n        assertTrue(q0.borrowable, \"start: legs agree at the market\");\n        assertEq(q0.low, _usd(A));\n        // 150 blocks: the 7 pushed samples (blocks T-150, T-125, ..., T) inside one 300-block window\n        vm.roll(vm.getBlockNumber() + 150);\n        vm.warp(vm.getBlockTimestamp() + 30 minutes);\n        uint256 honest = _honestMedianOf13(A, pushed, 7);\n        assertEq(honest, pushed, \"the honest median of 13 reads, 7 of them pushed\");\n        leaf.deliver(honest); // the attester's honest signature, relayed by anyone\n        proven.prove(pushed); // block T's end-of-block price, proved by anyone\n        q = pricer.quote(SIMD);\n        (m,) = median.latestValue();\n    }\n\n    /// FAILS on this commit: low = the pushed price (50% under the market) in the same epoch.\n    function test_pusherAlone_lowStaysWithinTheEpochAllowance() public {\n        (Pricer.Quote memory q, uint256 m) = _attack(A / 2);\n        assertEq(m, _usd(A * 8 / 10), \"the median leaf itself is clamped one allowance down (design C holds)\");\n        assertTrue(q.priced, \"liquidation runs at low\");\n        // one further allowance under the clamped median is the loosest reading of \"one allowance per epoch\"\n        assertGe(q.low, m * 8 / 10, \"low left the epoch's allowance at once: pushed reads + a pushed proof, no key\");\n    }\n\n    function testFuzz_pusherAlone_lowStaysWithinTheEpochAllowance(uint256 pBps) public {\n        uint256 pushed = A * bound(pBps, 100, 6_300) / 10_000;\n        (Pricer.Quote memory q, uint256 m) = _attack(pushed);\n        assertGe(q.low, m * 8 / 10, \"low = the pushed price\");\n    }\n}","reproduction":"State: sIMD-shaped graph (RateFeed(1.1) x ProductFeed(production SwarmPricePolicy leaf 1 h / 2,000 bps, ETH/USD 2,000)) as median; RateFeed x ProductFeed(proven stub, ETH/USD) as spot; skew 5%; leaf stored = attested = A = 4e15, proven A: low = $8.80. Calls: leaf.deliver(A/2) (the honest median of 6 x A and 7 x A/2) -> latestValue 0.8A, attested 0.5A; proven.prove(A/2); Pricer.quote(SIMD). Expected (README residual / one further allowance): low >= 0.64A = $5.632. Actual: low = $4.40 = the pushed price, priced = true, same epoch. Run: forge test --match-path test/scratch/Proof_97c18eaab5d6.t.sol -vv (solc 0.8.26 via_ir, forge 1.9.0). Output on this commit: [FAIL: low = the pushed price: 4602400000000000000 < 5632000000000000000; counterexample: args=[100000000000000000 [1e17]]] testFuzz_pusherAlone_lowStaysWithinTheEpochAllowance(uint256); [FAIL: low left the epoch's allowance at once: pushed reads + a pushed proof, no key: 4400000000000000000 < 5632000000000000000] test_pusherAlone_lowStaysWithinTheEpochAllowance() (gas: 374739). Suite result: FAILED. 0 passed; 2 failed. With the fix low = max(s, 0.64A) = $5.632 and both pass.","severity":"high","snippet":"            q.low = q.high = m > s ? Math.max(s, Math.min(m, FeedTraits.attested(c.median))) : s;","title":"Twin rule follows the ATTESTED median at once: honestly attested pushed pool reads plus one pushed proof set sIMD low to the pushed price in one epoch, with no attester key"},{"citation":"resolved","description":"Q2 (P3, P7). Merged from two specialists (same root cause, same fix). Inside a live epoch _follow clamps every target into [anchor(1-c), anchor(1+c)] around the value stored when the epoch OPENED (SwarmFeed.sol:688 and :692 `uint256 v = _clamp(target, anchor, bound);`); nothing bounds a step against the value the feed holds now. Once the stored value has moved inside the epoch (an honest hourly relay of a real move, or the key's own first step), the opposite edge is one attestation away: (1+c)/(1-c)-1 = +50% or 1-(1-c)/(1+c) = -33.3% from the held value, and with a second attestation one second later across the boundary (1+c)^2/(1-c)-1 = +80% / -46.7% on a price leg (NHI's carried anchor stops only that second step). P3 as literally worded (within one cap of SOME value held in the maxAge before) holds; its stated consequence 'mat moves at most one cap's worth per day' does not, and P7's closed-maxAge figure (1+c)^2-1 = +44%/-36% is exceeded. The README's 'swing NHI up a cap and back down' needs the key twice; here an honest intra-day rise plus ONE compromised attestation does it, and the step from the level held is two caps' ratio. IMPACT: (a) NHI/mat, mainnet sIMD and the 4663 IMD type (no twin for mat): anchor 0.71, honest relays to 0.85 (mat 1.70, converged, borrowable); one attestation one second later stores 0.568 -> mat 2.00: every sIMD loan between 170% and 200% liquidatable at once, the exact jump the wave-5 boundary fix (0.85 -> 0.544 in one second) was meant to remove. (b) 4663 IMD type (two swarm legs, one key, no twin, skew 10%): after an honest intra-hour fall of >= 15.3% one key takes both legs, converged and agreeing, to 1.2 x 1.2 / 0.847 = 1.70x market in one boundary second (stated +44% never crosses mat 1.70 in one boundary): debt up to the line (3,000 imdUSD) against collateral worth less than it; mirror: 0.533x after an honest 20% rally (loans under ~319% liquidatable). Mainnet's price side stays bounded by the proven twin. Reachable with the deploy config (cap 2,000 bps, legs 1 h, NHI 1 day) by the threat model's compromised key. SMALLEST FIX (clamp-not-reject, memory only within the live epoch): keep the epoch's lowest and highest STORED value (two uint128, one slot; reset to the anchor when an epoch opens, to `first` on the wide step; carried with the anchor for a carrying leaf) and also clamp into [high x (1-c), low x (1+c)] before storing. The interval always contains [low, high], so it is never empty; every value of an epoch is then within one cap of every other, so one attestation moves one cap from the held value, a boundary pair (1+c)^2-1, NHI/mat one cap's worth. Liveness cost: an honest reversal larger than one cap from the epoch's extreme finishes next epoch. With it the price legs do not need the carried anchor.","line":688,"path":"src/feeds/SwarmFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmNhiPolicy, SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\n/// The shipped NHI rule (SwarmNhiPolicy: no widening, carried anchor), 1 day, cap 2,000 bps; `set` is `_accept`.\ncontract NhiDoor is SwarmNhiPolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 days, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// The shipped price-leg rule (SwarmPricePolicy), 1 hour, cap 2,000 bps.\ncontract LegDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\ncontract FlatFeed {\n    function latestValue() external view returns (uint256, uint64) { return (100e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 1 hours; }\n}\n\ncontract ParamsStub {\n    ParametersBase.Config internal c; ParametersBase.Risk internal r;\n    constructor(IFeed price, IFeed nhi) { c.token = address(1); c.median = price; c.spot = price; c.nhi = nhi; r.skew = 0.05e18; r.mat = 1.7e18; }\n    function config(bytes32) external view returns (ParametersBase.Config memory) { return c; }\n    function storedRisk(bytes32) external view returns (ParametersBase.Risk memory) { return r; }\n    function cap(bytes32) external pure returns (uint256) { return 0; }\n    function maxLull() external pure returns (uint256) { return 0; }\n}\n\n/// The epoch band is anchored at the value the epoch OPENED on, not at the value the feed holds now. After an honest move\n/// inside an epoch, ONE signed value moves the stored value (1+c)/(1-c) - 1 = +50% or 1 - (1-c)/(1+c) = -33.3% from the\n/// honest level, and a second one a second later across the boundary takes a price leg to +80% / -46.7%.\n/// Stated: one cap (20%) per epoch; (1+c)^2 - 1 = +44% / -36% over a closed maxAge; NHI and mat one cap's worth per day.\ncontract ProofSwingReachTest is Test {\n    uint256 clock = 1_800_000_000;\n\n    function setUp() public { vm.chainId(1); vm.warp(clock); vm.roll(26_000_000); }\n    function _warp(uint256 dt) internal { clock += dt; vm.warp(clock); }\n    function _val(SwarmFeed f) internal view returns (uint256 v) { (v,) = f.latestValue(); }\n\n    /// P3's consequence: mat moves at most one cap's worth of NHI per day. One attestation takes mat 1.70 -> 2.00.\n    function test_nhi_oneAttestation_mat_170_to_200() public {\n        NhiDoor nhi = new NhiDoor();\n        Pricer pricer = new Pricer(Parameters(address(new ParamsStub(IFeed(address(new FlatFeed())), IFeed(address(nhi))))));\n        nhi.set(0.71e18); // yesterday's level\n        _warp(1 days); nhi.set(0.71e18); // honest hourly relay opens today's epoch: anchor 0.71\n        _warp(6 hours); nhi.set(0.78e18); // the index recovers through the day, honestly attested\n        _warp(6 hours); nhi.set(0.85e18);\n        assertTrue(nhi.converged());\n        Pricer.Quote memory q = pricer.quote(\"SIMD\");\n        assertEq(q.mat, 1.7e18, \"honest NHI 0.85: mat 1.70\");\n        assertTrue(q.borrowable);\n\n        _warp(1); nhi.set(1); // ONE compromised attestation, one second later, same epoch, no boundary\n        uint256 v = _val(nhi);\n        q = pricer.quote(\"SIMD\");\n        emit log_named_decimal_uint(\"NHI one second after 0.85\", v, 18);\n        emit log_named_decimal_uint(\"mat one second after 1.70\", q.mat, 18);\n        // one cap from the value NHI held: 0.85 x 0.8 = 0.68, mat 1.904\n        assertGe(v, 0.68e18, \"NHI moved more than one cap from the value it held a second before\");\n        assertLe(q.mat, 1.904e18, \"mat moved more than one cap's worth of NHI in one second\");\n    }\n\n    /// P7: over a closed maxAge a leg moves at most (1+c)^2 - 1 = +44%. Here +50% in one attestation and +80% in one second.\n    function test_leg_closedWindow_plus80pct_inOneSecond() public {\n        LegDoor leg = new LegDoor();\n        leg.set(100e18);\n        _warp(1 hours); leg.set(100e18); // honest relay opens the epoch: anchor 100\n        _warp(20 minutes); leg.set(80e18); // the market falls 20% inside the hour, honestly attested\n        assertTrue(leg.converged());\n        uint256 honest = _val(leg);\n        assertEq(honest, 80e18);\n\n        _warp(40 minutes - 1); leg.set(type(uint128).max); // compromised key, last second of the epoch\n        uint256 one = _val(leg);\n        _warp(1); leg.set(type(uint128).max); // first second of the next epoch\n        uint256 two = _val(leg);\n        emit log_named_decimal_uint(\"leg after ONE attestation (honest level 80)\", one, 18);\n        emit log_named_decimal_uint(\"leg ONE SECOND later\", two, 18);\n        assertLe(one * 10_000, honest * 12_000, \"one attestation moved the leg more than one cap from the value it held\");\n        assertLe(two * 10_000, honest * 14_400, \"closed maxAge (here: one second) moved more than (1+c)^2 - 1\");\n    }\n\n    /// The mirror: -33.3% in one attestation, -46.7% in one second (stated -20% / -36%).\n    function test_leg_closedWindow_minus47pct_inOneSecond() public {\n        LegDoor leg = new LegDoor();\n        leg.set(100e18);\n        _warp(1 hours); leg.set(100e18);\n        _warp(20 minutes); leg.set(120e18); // honest rally of 20% inside the hour\n        uint256 honest = _val(leg);\n        _warp(40 minutes - 1); leg.set(1);\n        uint256 one = _val(leg);\n        _warp(1); leg.set(1);\n        uint256 two = _val(leg);\n        emit log_named_decimal_uint(\"leg after ONE attestation (honest level 120)\", one, 18);\n        emit log_named_decimal_uint(\"leg ONE SECOND later\", two, 18);\n        assertGe(one * 10_000, honest * 8_000, \"one attestation moved the leg more than one cap from the value it held\");\n        assertGe(two * 10_000, honest * 6_400, \"closed maxAge (here: one second) moved more than 1 - (1-c)^2\");\n    }\n}","reproduction":"NHI leaf (SwarmNhiPolicy, 1 day, 2,000 bps): t0 set 0.71; t0+1d honest 0.71 (anchor 0.71); +6h 0.78; +6h 0.85 -> Pricer mat 1.70. +1 s attestation target 1 wei. Expected (one cap from held): NHI >= 0.68, mat <= 1.904. Actual 0.568, mat 2.000. Price leg (SwarmPricePolicy 1 h, 2,000 bps): t0 100; t0+1h 100; +20 min 80; t0+2h-1s target 2^128-1 -> 120 (expected <= 96); t0+2h -> 144 (expected <= 115.2); mirror 120 -> 80 -> 64. Run: forge test --match-path test/scratch/Proof_53330bf4fdf3.t.sol -vv. Output on this commit: [FAIL: one attestation moved the leg more than one cap from the value it held: 800000000000000000000000 < 960000000000000000000000] test_leg_closedWindow_minus47pct_inOneSecond() (gas: 2470151) logs 80.0 / 64.0; [FAIL: one attestation moved the leg more than one cap from the value it held: 1200000000000000000000000 > 960000000000000000000000] test_leg_closedWindow_plus80pct_inOneSecond() (gas: 2481667) logs 120.0 / 144.0; [FAIL: NHI moved more than one cap from the value it held a second before: 568000000000000000 < 680000000000000000] test_nhi_oneAttestation_mat_170_to_200() (gas: 4459508) logs NHI 0.568, mat 2.000. Suite result: FAILED. 0 passed; 3 failed. Also reproduced (second specialist, key twice inside one epoch): accept 0.72 -> 1.0 (stored 0.864, mat 1.70) -> t0+86,399 s 0.1 (stored 0.576, mat 2.00), expected >= 0.6912.","severity":"medium","snippet":"            (anchor, bound) = (_anchorValue, _anchorBound);","title":"Epoch band is anchored at the epoch's opening value, not the value held: after an honest move one attestation moves NHI two caps' worth (mat 1.70 -> 2.00 in one second) and a leg +50%/-33% (+80%/-46.7"},{"citation":"resolved","description":"Q1 (P8). When the proven spot s is above the median m and the legs disagree, line 99 returns s for low, high and (line 103) payout with no reference to the median or its attested value. P8 accepts one consequence: a pushed-up proof 'shelters a loan only until a newer block is proved'. But the same number is read as a VALUE by readers that need only `priced`: src/backstop/PricerOracle.sol:46 `return (q.low, q.high, q.priced && q.low != 0);`, and Backstop.nav() (src/backstop/Backstop.sol:362-368) adds coll x high for every held token; Backstop._convert (:728-746) mints a matured deposit bucket `Math.mulDiv(amount, supply, value + 1)` shares at that nav. sIMD is a sleeve token (script/DeployConfig.sol:536 `SleeveIlk(\"SIMD\", true, ...)`). So a pusher (no key) who pushes pool 0xb07d at one block end, proves it (permissionless, any of the last 32 blocks) and triggers a conversion (anyone's deposit/bid) while that proof is newest dilutes the converting buckets in favour of existing holders by coll_sIMD x (s_pushed - s_true). Under the plain median rule a disagreeing pair collapses to the median; inside agreement high <= m x (1 + skew). Capping the arm itself would break P1, so the fix belongs in the value reader. Reachable with the deploy config: the Pricer/PricerOracle state yes (reproduced); the Backstop dilution additionally needs the sleeve to hold sIMD and a bucket to mature (traced by reading, not run end to end). SMALLEST FIX: PricerOracle.priceOf reports ok = q.priced && q.low != 0 && q.agree for a type whose spot is proven (or simply && q.agree): nav() then fails closed and _convert waits, exactly as for an unpriced token; liquidation health keeps reading Pricer.low unchanged. Tradeoff: conversions wait while the sIMD legs disagree.","line":99,"path":"src/Pricer.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy, SwarmNhiPolicy, SwarmQuestions} from \"src/feeds/SwarmFeeds.sol\";\nimport {PricerOracle} from \"src/backstop/PricerOracle.sol\";\n\n/// The four Parameters reads Pricer.quote makes, nothing else.\ncontract ParamsStub {\n    mapping(bytes32 => ParametersBase.Config) internal c;\n    mapping(bytes32 => ParametersBase.Risk) internal r;\n\n    function set(bytes32 ilk, ParametersBase.Config memory c_, ParametersBase.Risk memory r_) external {\n        c[ilk] = c_;\n        r[ilk] = r_;\n    }\n\n    function config(bytes32 ilk) external view returns (ParametersBase.Config memory) {\n        return c[ilk];\n    }\n\n    function storedRisk(bytes32 ilk) external view returns (ParametersBase.Risk memory) {\n        return r[ilk];\n    }\n\n    function maxLull() external pure returns (uint256) {\n        return 0;\n    }\n\n    function cap(bytes32) external pure returns (uint256) {\n        return 0;\n    }\n}\n\n/// The shipped median leaf (SwarmPriceFeed's policy, 1 h, 2,000 bps) with a door to `_accept`: what submitAttestation\n/// calls once the signature, question and window checks have passed. `deliver(x)` = a valid attestation of x relayed now.\ncontract MedianLeaf is SwarmPricePolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 hours, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// The shipped NHI leaf (SwarmNhiFeed's policy, 1 day, 2,000 bps) with the same door.\ncontract NhiLeaf is SwarmNhiPolicy {\n    constructor() SwarmFeed(SwarmQuestions.ATTESTER, address(0), 1, 3, 1 days, 2_000) {}\n\n    function deliver(uint256 target) external {\n        _accept(target, uint64(block.timestamp));\n    }\n}\n\n/// ProvenPoolPrice's IFeed surface: the pool's price at the end of the proved block, fresh 6 h, `proven()` true.\ncontract ProvenStub {\n    uint256 internal v;\n    uint64 internal at;\n\n    function prove(uint256 endOfBlockPrice) external {\n        v = endOfBlockPrice;\n        at = uint64(block.timestamp);\n    }\n\n    function latestValue() external view returns (uint256, uint64) {\n        return (v, at);\n    }\n\n    function isStale() external view returns (bool) {\n        return at == 0 || block.timestamp > uint256(at) + 6 hours;\n    }\n\n    function proven() external pure returns (bool) {\n        return true;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return 6 hours;\n    }\n}\n\n/// Chainlink ETH/USD stand-in: answers none of the traits.\ncontract EthUsd {\n    function latestValue() external view returns (uint256, uint64) {\n        return (2000e18, uint64(block.timestamp));\n    }\n\n    function isStale() external pure returns (bool) {\n        return false;\n    }\n\n    function maxAge() external pure returns (uint256) {\n        return type(uint64).max;\n    }\n}\n\ncontract ShareVault {\n    function convertToAssets(uint256 s) external pure returns (uint256) {\n        return s * 1.1e18 / 1e18;\n    }\n}\n\n/// sIMD as deployed: median = rate x (swarm median leaf x ETH/USD), spot = rate x (proven pool x ETH/USD), skew 5%, NHI leaf.\nabstract contract TwinRig {\n    bytes32 internal constant SIMD = \"SIMD\";\n    uint256 internal constant A = 4e15; // wei per IMD\n    MedianLeaf internal leaf;\n    NhiLeaf internal nhi;\n    ProvenStub internal proven;\n    IFeed internal median;\n    IFeed internal spot;\n    Pricer internal pricer;\n\n    function _rig() internal {\n        leaf = new MedianLeaf();\n        nhi = new NhiLeaf();\n        proven = new ProvenStub();\n        IFeed eth = IFeed(address(new EthUsd()));\n        address vault = address(new ShareVault());\n        median = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(leaf)), eth), 0)));\n        spot = IFeed(address(new RateFeed(vault, ShareVault.convertToAssets.selector, true, new ProductFeed(IFeed(address(proven)), eth), 0)));\n        ParamsStub p = new ParamsStub();\n        ParametersBase.Config memory c;\n        c.token = address(0xC011);\n        c.median = median;\n        c.spot = spot;\n        c.nhi = IFeed(address(nhi));\n        ParametersBase.Risk memory r;\n        r.mat = 1.7e18;\n        r.skew = 0.05e18;\n        p.set(SIMD, c, r);\n        pricer = new Pricer(Parameters(address(p)));\n        leaf.deliver(A);\n        nhi.deliver(0.9e18);\n        proven.prove(A);\n    }\n\n    function _usd(uint256 weiPerImd) internal pure returns (uint256) {\n        return (weiPerImd * 2000e18 / 1e18) * 1.1e18 / 1e18;\n    }\n}\n\n\n/// No key. One block end of pool 0xb07d pushed UP and proved: the twin's `: s` arm sets low = high = payout = s with no\n/// upper bound, and PricerOracle (the Backstop's nav() and _convert() price) reports it as a good value.\ncontract ProofTwinUpValueTest is Test, TwinRig {\n    function setUp() public {\n        vm.warp(1_800_000_000);\n        vm.roll(26_000_000);\n        _rig();\n    }\n\n    function test_pushedUpProofAloneIsReadAsAValue() public {\n        vm.warp(block.timestamp + 60);\n        proven.prove(A * 10); // one block end pushed 10x, proved (permissionless, any of the last 32 blocks)\n        Pricer.Quote memory q = pricer.quote(SIMD);\n        emit log_named_decimal_uint(\"honest median (= attested), USD\", _usd(A), 18);\n        emit log_named_decimal_uint(\"low\", q.low, 18);\n        emit log_named_decimal_uint(\"high\", q.high, 18);\n        emit log_named_decimal_uint(\"payout\", q.payout, 18);\n        assertTrue(q.priced);\n        assertFalse(q.agree);\n        PricerOracle oracle = new PricerOracle(pricer, address(this));\n        oracle.setIlk(address(0xC011), SIMD);\n        (, uint256 high, bool ok) = oracle.priceOf(address(0xC011));\n        emit log_named_decimal_uint(\"PricerOracle.priceOf high (Backstop nav price)\", high, 18);\n        // Expected: a value reader (Backstop.nav -> _convert share price) never takes a lone pushed proof as a value:\n        // either it is flagged unusable, or it stays within skew of the converged median.\n        assertTrue(!ok || high <= _usd(A) * 105 / 100, \"a lone pushed-up proof is valued by the Backstop at 10x the median\");\n    }\n}","reproduction":"sIMD-shaped rig (median = RateFeed(1.1) x ProductFeed(SwarmPricePolicy leaf, ETH/USD 2,000), converged at A = 4e15; spot = RateFeed x ProductFeed(proven stub)); proven.prove(10A); Pricer.quote(SIMD) and PricerOracle(pricer, this).priceOf(token). Expected: ok false, or high <= median x 1.05 = $9.24. Actual: priced true, agree false, low = high = payout = $88.00 (10x), PricerOracle high $88.00 ok true. Run: forge test --match-path test/scratch/ProofTwinUpValue.t.sol -vv. Output on this commit: [FAIL: a lone pushed-up proof is valued by the Backstop at 10x the median] test_pushedUpProofAloneIsReadAsAValue() (gas: 914085) Logs: honest median (= attested), USD: 8.8 / low: 88.0 / high: 88.0 / payout: 88.0 / PricerOracle.priceOf high (Backstop nav price): 88.0. Suite result: FAILED. 0 passed; 1 failed.","severity":"medium","snippet":"            q.low = q.high = m > s ? Math.max(s, Math.min(m, FeedTraits.attested(c.median))) : s;","title":"Twin rule's `: s` arm: one pushed-UP proven block end alone sets low = high = payout with no upper bound, and PricerOracle hands it to Backstop.nav() as a good value (deposit buckets converted at an i"},{"citation":"resolved","description":"Q3 (P4, P5). P4: a composite reports proven only when one input is proven and the other has no attester in its path. ProductFeed checks both inputs (FeedTraits.attesterFree); RateFeed does not: its second input `rateSource` is read through any zero-argument getter, and proven() (:104-106), converged() (:99-101) and isStale() (:94-96) consult `underlying` only. RateFeed(rateSource = a SwarmFeed leaf, selector latestValue) builds, prices at clampedLeaf x provenPrice, and reports proven() = true and converged() = true while the leaf is clamped; ProductFeed(that, Chainlink).proven() is true too, so such a spot gets the twin rule and the 'converged legs only agree' rule from a value one attester key moves. NOT reachable in the shipped graphs (mainnet sIMD rate = SIMD.convertToAssets; 4663 has no proven leg); needs the Safe to add such a feed (48 h), and DeployBase._provenAtDeploy mirrors the same rule so the deploy check would not catch it. SMALLEST FIX: proven() = FeedTraits.proven(underlying) && FeedTraits.attesterFree(IFeed(rateSource)); converged() = FeedTraits.converged(underlying) && FeedTraits.converged(IFeed(rateSource)) (an ERC-4626/wstETH answers neither trait, so shipped feeds read as today), or refuse a rateSource answering converged() in the constructor.","line":104,"path":"src/feeds/RateFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract LegDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// Stands in for ProvenPoolPrice: answers proven() and no converged().\ncontract ProvenStub {\n    function latestValue() external view returns (uint256, uint64) { return (1e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 6 hours; }\n    function proven() external pure returns (bool) { return true; }\n}\n\n/// Stands in for ChainlinkFeed: no trait at all.\ncontract PlainStub {\n    function latestValue() external view returns (uint256, uint64) { return (2000e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 1 hours; }\n}\n\ncontract ProofRateFeedTraitsTest is Test {\n    function test_rateFeed_attestedRateSource_readsProvenAndConverged() public {\n        vm.warp(1_800_000_000);\n        LegDoor ratio = new LegDoor();\n        ratio.set(1e18);\n        ratio.set(2e18); // clamped: stored 1.2, attested 2.0\n        assertFalse(ratio.converged());\n        RateFeed rf = new RateFeed(address(ratio), IFeed.latestValue.selector, false, IFeed(address(new ProvenStub())), 1e18);\n        (uint256 v,) = rf.latestValue();\n        assertEq(v, 1.2e18, \"the value is the attester's clamped leaf x the proven price\");\n        ProductFeed pf = new ProductFeed(IFeed(address(rf)), IFeed(address(new PlainStub())));\n        assertFalse(rf.converged(), \"an attested input is clamped: must not read converged\");\n        assertFalse(rf.proven(), \"P4: an attester is in the path: must not read proven\");\n        assertFalse(pf.proven(), \"P4: the product over it must not read proven\");\n    }\n}","reproduction":"leaf = SwarmPricePolicy (1 h, 2,000 bps): set 1e18, set 2e18 -> stored 1.2e18, attested 2e18, converged false. rf = new RateFeed(leaf, IFeed.latestValue.selector, false, provenStub, 1e18). Expected rf.converged() false, rf.proven() false, ProductFeed(rf, plain).proven() false; actual all true. Run: forge test --match-path test/scratch/Proof_2ca441c6e471.t.sol -vv. Output on this commit: [FAIL: an attested input is clamped: must not read converged] test_rateFeed_attestedRateSource_readsProvenAndConverged() (gas: 3964568). Suite result: FAILED. 0 passed; 1 failed.","severity":"low","snippet":"    function proven() external view returns (bool) {\n        return FeedTraits.proven(underlying);\n    }","title":"RateFeed.proven()/converged() look only at `underlying`: an attested swarm leaf as the rate source is invisible, so the composite (and a ProductFeed over it) reads proven and converged while the leaf "},{"citation":"resolved","description":"Q2 (P3, C2). _carryNow drops the carried anchor once block.timestamp - _movedAt >= maxAge. An epoch opened by a move at t1 ends at t1 + maxAge, the same second the carry lapses, so the next epoch opens uncarried and takes a second cap: 0.85 -> 0.68 at t1, -> 0.544 (mat 1.70 -> 2.00) at t1 + 86,400. P3 is stated (and tested in AuditW5NhiWindow) for half-open windows [t, t+maxAge), where it holds; the price legs' P7 is stated for closed windows. Changing to `>` only makes the attacker deliver one second later (t1 + 86,401 opens an uncarried epoch), so the material bound is 'two caps take one maxAge (+1 s)', i.e. mat 1.70 -> 2.00 in one day with the key, not two days as README line 564 once said. Not a defect of the stated half-open property; listed so the closed-window reading is not relied on.","line":555,"path":"src/feeds/SwarmFeed.sol","reproduction":"SwarmNhiPolicy (1 day, 2,000 bps): 0.85 held > 1 day; at t1 deliver 0.1 -> 0.68; at t1 + 86,400 deliver 0.1 -> 0.544 (expected >= 0.68 for a closed day). forge test --match-path test/scratch/Proof_21198f419d0e.t.sol -vv on this commit: [FAIL: two caps inside one closed day: 544000000000000000 < 680000000000000000] test_twoCapsInsideOneClosedDay() (gas: 2589731), logs t2 - t1: 86400, v2: 544000000000000000.","severity":"info","snippet":"        if (!_carriesAnchor() || block.timestamp - uint256(_movedAt) >= maxAge) return 0;","title":"NHI carry lapses at exactly maxAge after the last move: two caps over the CLOSED day [t1, t1+86,400] (P3 holds for half-open windows only); the `>` fix buys one second"},{"citation":"resolved","description":"BUILD: forge 1.9.0, solc 0.8.26 via_ir (no solar). Required glob on this commit: 11 suites, 48 tests passed, 0 failed (ProvenPoolPrice 13, AuditW4TwinLag 4, AuditW4NhiMat 3, AuditW5NhiWindow 3, AuditW4ProveWindow 4, AuditW4ProvenProduct 4, AuditW4SlidingBound 2, PricerTwin 6, SwarmFeedProperties fuzz 5 + invariant 1, AuditW4TraitNested 3). Proofs were run under test/scratch/ (deleted after) rather than test/unit/, per the output rules. Q1 (P1, P2, P8): P1 and P8 hold on the lower side: a compromised median alone gives low >= s/(1+skew) (m < s reads s; agreement reads min(m,s)); a pushed proof alone never goes below min(m, attested) by more than skew. P2 holds (low = min(m, attested) at the first delivery). They do NOT hold together against a pusher: following the attested median gives back the per-epoch bound to honestly attested pushed reads (HIGH finding), and the `: s` arm has no upper bound (MEDIUM finding, value readers). A stale attested value cannot arise while the median is fresh (every acceptance rewrites _attested). Legs from different moments: the median and spot may lag each other (window median vs one block), which is exactly what lets a pushed window and a pushed block coincide. C1: confirmed with the bound: with the key (attested <= pushed price P) and one pushed block end, low = P exactly; the Pricer adds no floor, so the loss is every sIMD position liquidatable at P (capped by the sIMD line), in the proving transaction (the keeper's 60 s tick is too late for a prove-and-bite). A proof within 1.5% of the live pool can stand ~5 h (keeper rule, off-repo) but is worth at most 1.5% (+ skew inside agreement). Without the key the same bound is reached with 7-8 pushed block ends (HIGH finding). Q2 (P3, P7): P3 as literally worded holds for half-open windows (fuzz in SwarmFeedProperties/AuditW5NhiWindow passes; argument: epoch openings are >= maxAge apart, so a window holds at most one opening and either starts at the new anchor or sees both epochs inside the carried band). Worse than stated: the in-epoch band anchored at the opening value (MEDIUM finding: mat 1.70 -> 2.00 on one attestation after an honest rise; legs +80%/-46.7% in a closed window vs stated +44%/-36%). The after-silence bound (1+2c)(1+c)^2-1 was not exceeded. 4663: one key moves both legs together, converged and agreeing, so the leg bound is the type bound and the loss is bounded by the line (0, then 3,000). C2: confirmed: carried anchor gives P3 for any timing; honest hourly relays reach the level at worst one cap per two epochs (a move later than an epoch's opening costs one held epoch). Carried anchor is the right NHI rule for the window property but not for the step from the held value: the smallest change is the epoch low/high range clamp (MEDIUM finding), which the price legs should take too; the legs should not carry the anchor (it halves honest speed and, for sIMD, adds lag against P2). Q3 (P4, P5): shipped graphs read correctly (mainnet sIMD spot Rate(Product(Proven, Chainlink)) proven and attester-free; median converged iff its leaf is; 4663 IMD legs not proven). RateFeed ignores its rate source's traits (LOW finding, Safe-addable only). P5: no deployed feed found whose empty revert or short success reads converged/attester-free wrongly. Unverified lead (not reproduced by me): SeatSpotLeg.converged() (src/feeds/SeatFeed.sol:326) calls `feed.converged()` directly, so an out-of-gas in SeatFeed bubbles as empty revert data with ~3% of the caller's gas left (> g/63) and FeedTraits._read would read ABSENT = converged; the caller is then left a few hundred gas, so Pricer.quote cannot complete on it. Fix if wanted: read it through FeedTraits. Q4 (P6) and C3: line 109 refuses block.number - number > 32. The keeper proves head-1 built at head H; landing in H+k the distance is k+1, so it is accepted for k <= 31 (31 landing blocks, ~6.2 min of produced blocks; missed slots do not count) and TooOld at k = 32, 33 (AuditW4ProveWindow passes on this commit","line":109,"path":"src/feeds/ProvenPoolPrice.sol","reproduction":"forge test --match-path 'test/unit/{SwarmFeedProperties,PricerTwin,ProvenPoolPrice,AuditW4TwinLag,AuditW4NhiMat,AuditW4SlidingBound,AuditW4TraitNested,AuditW4ProvenProduct,AuditW4ProveWindow,AuditW5NhiWindow}.t.sol' -> 'Ran 11 test suites in 5.30s (14.97s CPU time): 48 tests passed, 0 failed, 0 skipped (48 total tests)'.","severity":"info","snippet":"        if (block.number - number > PROVE_WINDOW) revert TooOld(number, block.number);","title":"Answers to questions 1-4 and claims C1-C4, with the required build/test output"}],"hash":"bb6289f6b94ffd38bb52e7af4b97f2c180b28daedda5bb6a4be64093daeb8ce0","nodeId":"d3d29a40-bb3d-464f-9e84-ca190a28767e","outcome":"completed","summary":"The review is finished. I kept six of the twelve specialist findings, merging two duplicates, and wrote them to `.imd-findings.json`: one high, two medium, one low and two informational. No repository file was changed. The scratch tests are deleted, and the stray entries `git status` shows (`.bashrc`, `.gitmodules`, …) are `/dev/null` devices the sandbox mounts, not files.\n\n**Build:** forge 1.9.0 with solc 0.8.26 and via_ir. The required test glob passes: 11 suites, 48 tests, 0 failed. I ran every proof myself under `test/scratch/` rather than `test/unit/`, because the output rules require proofs there, and each one fails on this commit for the reason its finding gives.\n\n| Sev | Where | Finding |\n|---|---|---|\n| high | `src/Pricer.sol:99` | **No attester key needed.** Someone who pushes the pool at the end of 7 of the 13 sampled blocks gets an honest attestation of their pushed price. Proving one pushed block then sets sIMD's `low` to that price straight away. Expected `low` ≥ $5.63; actual $4.40. This is worse than the README's \"pushed reads… move a leg one allowance per epoch\". Smallest fix: let the attested value count for at most one more allowance below the stored median. |\n| medium | `src/feeds/SwarmFeed.sol:688` | **Band anchored at the epoch's opening value (two specialists' reports, merged).** After an honest move inside an epoch, a single compromised attestation moves NHI from 0.85 to 0.568, so mat goes from 1.70 to 2.00 in one second. A price leg can move +80% / −46.7% within a closed hour, against the stated +44% / −36%. Fix: keep the epoch's lowest and highest stored value and clamp each new value to within one cap of both. |\n| medium | `src/Pricer.sol:99`, `PricerOracle.sol:46` | **A pushed-up proof has no upper bound.** One pushed block sets low, high and payout to 10× the median ($88 against $8.80). `PricerOracle` passes that to `Backstop.nav()` as a good price, so deposits converted then get too few shares. I reproduced the Pricer and oracle values with my own test; the Backstop dilution I traced by reading the code only. Fix: `priceOf` should require the two legs to agree. |\n| low | `src/feeds/RateFeed.sol:104` | **`proven()` and `converged()` ignore the rate source.** If the rate source is an attested swarm leaf, the feed still reads proven and converged. Only reachable if the Safe adds such a feed. |\n| info | `SwarmFeed.sol:555` | **NHI's carried anchor lapses at exactly one day.** P3 holds for half-open windows only. Changing `>=` to `>` gains just one second. |\n| info | — | **Answers to Q1–Q4 and C1–C4**, with the test output. |\n\nOn the claims:\n- **C1:** confirmed. A compromised key plus one pushed block sets `low` to exactly the pushed price, so every sIMD loan unhealthy at that price can be liquidated, up to the sIMD line.\n- **C2:** confirmed. The carried anchor gives P3 for any timing, and honest hourly relays still reach the level, at worst one cap per two epochs.\n- **C3:** confirmed, with one edge. A head-1 proof is accepted up to 31 blocks after its head and rejected as too old at 32 and 33, so a private relay's 25-block hold still fits.\n- **C4:** not verified. I didn't rebuild the old rules to show the wave-4 and wave-5 proofs fail on them; I only confirmed they pass on this commit.\n\n**Dropped:** I couldn't reproduce the lead that an out-of-gas error inside `SeatSpotLeg.converged()` reads as converged, because its test wasn't provided. It's recorded as an unverified lead in the answers entry, not as a finding.\n\nThe four proofs attached are for the high finding, both mediums and the low.","treeHash":null,"usage":{"cachedInputTokens":1541271,"cost":{"source":"runtime","usdMicros":1723353},"inputTokens":36,"model":"claude-opus-5-5","outputTokens":31355,"runtime":"claude","turns":19,"wallClockMs":981373}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"d4b53d656a3fbe07","findings":[{"citation":"resolved","description":"P7 and the README ('over a closed maxAge a leg moves at most (1+c)^2-1'; SwarmFeed.sol P1 'the stored value moves at most one allowance per epoch') and P3's consequence ('mat moves at most one cap's worth per day') are worse than written. _follow clamps every target into [anchor(1-c), anchor(1+c)] where anchor is the stored value WHEN THE EPOCH OPENED (SwarmFeed.sol:688-692; the carried band at :695 is also around an anchor). Nothing bounds a step against the value the feed holds NOW. So once the stored value has honestly moved inside the epoch (an hourly relay of a real move), the whole opposite side of the band is one attestation away: reach from the held value is (1+c)/(1-c)-1 = +50% up or 1-(1-c)/(1+c) = -33.3% down in ONE attestation with no boundary, and (1+c)^2/(1-c)-1 = +80% / 1-(1-c)^2/(1+c) = -46.7% with a second attestation one second later across the epoch boundary (price legs; NHI's carried anchor stops only that second step). This is not the known 'swing up a cap and back down': the first leg is honest, so the displacement from the true level is two caps' ratio, not one.\nIMPACT. (a) NHI/mat (mainnet sIMD and the 4663 IMD type, no twin for mat): anchor 0.71, honest relays reach 0.85 during the day (mat 1.70, converged, borrowable); one compromised attestation one second later stores 0.568, mat 2.00: the full 1.70 -> 2.00 range at once, which is exactly what the wave-5 boundary fix (0.85 -> 0.544 in one second) was meant to remove; every sIMD loan between 170% and 200% becomes liquidatable in that second. Any honest intra-day rise x widens the step to 1-0.8/(1+x). (b) 4663 IMD type (two swarm legs, one key, no proven twin): after an honest intra-hour fall of 15.3% or more, one key takes both legs converged to 1.2*1.2/0.847 = 1.70x the market in one boundary second, i.e. past mat 1.70, so debt up to the whole line (3,000) can be minted against collateral worth less than the debt WITHOUT waiting an epoch (the stated +44% never crosses mat 1.70 in one boundary); the mirror puts the pair at 0.533x after an honest 20% rally, so loans under 1.70/0.533 = 319% are liquidatable in one second (stated 0.64x -> 266%). On mainnet the price side is still bounded by the proven twin (P1/P8 hold, fuzzed), so there the damage is the mat step in (a). REACHABLE with the deploy config (cap 2,000 bps, legs 1 h, NHI 1 day): yes, by the threat model's compromised attester key; the precondition is an honest move inside the live epoch (none needed if the attacker makes the first leg himself, which is the known swing).\nWHAT STILL HOLDS (fuzz, 1,500 runs x 18 steps each, seconds apart, on both sides of the epoch boundary, around lastMove+maxAge, silences): P3 exactly as worded (every value in [t,t+maxAge) within one cap of ONE value held in the maxAge before); the true no-silence leg bound over a closed maxAge is +80% / -46.7%; the after-silence bound +101.6% / -61.6% holds as stated.\nSMALLEST FIX (keeps clamp-not-reject, no memory beyond the live epoch): keep the epoch's lowest and highest STORED value (two uint128, one slot; reset to the anchor when an epoch opens, to `first` on the wide step) and clamp the result also into [high x (1 - c), low x (1 + c)] before storing, then update low/high. Every value of an epoch is then within one cap of every other, so the stated numbers become true: one cap per attestation from any held value, (1+c)^2-1 across a boundary, NHI/mat one cap's worth from the value held. The interval always contains [low, high], so it is never empty and refuses nothing. Liveness cost: an honest reversal larger than one cap from the epoch's extreme finishes in the next epoch. With it the price legs do not need the carried anchor (carrying would halve their honest speed to one cap per two epochs; sIMD has the twin, and on 4663 the range clamp already restores the stated +44%).","line":692,"path":"src/feeds/SwarmFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmNhiPolicy, SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\n/// The shipped NHI rule (SwarmNhiPolicy: no widening, carried anchor), 1 day, cap 2,000 bps; `set` is `_accept`.\ncontract NhiDoor is SwarmNhiPolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 days, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// The shipped price-leg rule (SwarmPricePolicy), 1 hour, cap 2,000 bps.\ncontract LegDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\ncontract FlatFeed {\n    function latestValue() external view returns (uint256, uint64) { return (100e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 1 hours; }\n}\n\ncontract ParamsStub {\n    ParametersBase.Config internal c; ParametersBase.Risk internal r;\n    constructor(IFeed price, IFeed nhi) { c.token = address(1); c.median = price; c.spot = price; c.nhi = nhi; r.skew = 0.05e18; r.mat = 1.7e18; }\n    function config(bytes32) external view returns (ParametersBase.Config memory) { return c; }\n    function storedRisk(bytes32) external view returns (ParametersBase.Risk memory) { return r; }\n    function cap(bytes32) external pure returns (uint256) { return 0; }\n    function maxLull() external pure returns (uint256) { return 0; }\n}\n\n/// The epoch band is anchored at the value the epoch OPENED on, not at the value the feed holds now. After an honest move\n/// inside an epoch, ONE signed value moves the stored value (1+c)/(1-c) - 1 = +50% or 1 - (1-c)/(1+c) = -33.3% from the\n/// honest level, and a second one a second later across the boundary takes a price leg to +80% / -46.7%.\n/// Stated: one cap (20%) per epoch; (1+c)^2 - 1 = +44% / -36% over a closed maxAge; NHI and mat one cap's worth per day.\ncontract ProofSwingReachTest is Test {\n    uint256 clock = 1_800_000_000;\n\n    function setUp() public { vm.chainId(1); vm.warp(clock); vm.roll(26_000_000); }\n    function _warp(uint256 dt) internal { clock += dt; vm.warp(clock); }\n    function _val(SwarmFeed f) internal view returns (uint256 v) { (v,) = f.latestValue(); }\n\n    /// P3's consequence: mat moves at most one cap's worth of NHI per day. One attestation takes mat 1.70 -> 2.00.\n    function test_nhi_oneAttestation_mat_170_to_200() public {\n        NhiDoor nhi = new NhiDoor();\n        Pricer pricer = new Pricer(Parameters(address(new ParamsStub(IFeed(address(new FlatFeed())), IFeed(address(nhi))))));\n        nhi.set(0.71e18); // yesterday's level\n        _warp(1 days); nhi.set(0.71e18); // honest hourly relay opens today's epoch: anchor 0.71\n        _warp(6 hours); nhi.set(0.78e18); // the index recovers through the day, honestly attested\n        _warp(6 hours); nhi.set(0.85e18);\n        assertTrue(nhi.converged());\n        Pricer.Quote memory q = pricer.quote(\"SIMD\");\n        assertEq(q.mat, 1.7e18, \"honest NHI 0.85: mat 1.70\");\n        assertTrue(q.borrowable);\n\n        _warp(1); nhi.set(1); // ONE compromised attestation, one second later, same epoch, no boundary\n        uint256 v = _val(nhi);\n        q = pricer.quote(\"SIMD\");\n        emit log_named_decimal_uint(\"NHI one second after 0.85\", v, 18);\n        emit log_named_decimal_uint(\"mat one second after 1.70\", q.mat, 18);\n        // one cap from the value NHI held: 0.85 x 0.8 = 0.68, mat 1.904\n        assertGe(v, 0.68e18, \"NHI moved more than one cap from the value it held a second before\");\n        assertLe(q.mat, 1.904e18, \"mat moved more than one cap's worth of NHI in one second\");\n    }\n\n    /// P7: over a closed maxAge a leg moves at most (1+c)^2 - 1 = +44%. Here +50% in one attestation and +80% in one second.\n    function test_leg_closedWindow_plus80pct_inOneSecond() public {\n        LegDoor leg = new LegDoor();\n        leg.set(100e18);\n        _warp(1 hours); leg.set(100e18); // honest relay opens the epoch: anchor 100\n        _warp(20 minutes); leg.set(80e18); // the market falls 20% inside the hour, honestly attested\n        assertTrue(leg.converged());\n        uint256 honest = _val(leg);\n        assertEq(honest, 80e18);\n\n        _warp(40 minutes - 1); leg.set(type(uint128).max); // compromised key, last second of the epoch\n        uint256 one = _val(leg);\n        _warp(1); leg.set(type(uint128).max); // first second of the next epoch\n        uint256 two = _val(leg);\n        emit log_named_decimal_uint(\"leg after ONE attestation (honest level 80)\", one, 18);\n        emit log_named_decimal_uint(\"leg ONE SECOND later\", two, 18);\n        assertLe(one * 10_000, honest * 12_000, \"one attestation moved the leg more than one cap from the value it held\");\n        assertLe(two * 10_000, honest * 14_400, \"closed maxAge (here: one second) moved more than (1+c)^2 - 1\");\n    }\n\n    /// The mirror: -33.3% in one attestation, -46.7% in one second (stated -20% / -36%).\n    function test_leg_closedWindow_minus47pct_inOneSecond() public {\n        LegDoor leg = new LegDoor();\n        leg.set(100e18);\n        _warp(1 hours); leg.set(100e18);\n        _warp(20 minutes); leg.set(120e18); // honest rally of 20% inside the hour\n        uint256 honest = _val(leg);\n        _warp(40 minutes - 1); leg.set(1);\n        uint256 one = _val(leg);\n        _warp(1); leg.set(1);\n        uint256 two = _val(leg);\n        emit log_named_decimal_uint(\"leg after ONE attestation (honest level 120)\", one, 18);\n        emit log_named_decimal_uint(\"leg ONE SECOND later\", two, 18);\n        assertGe(one * 10_000, honest * 8_000, \"one attestation moved the leg more than one cap from the value it held\");\n        assertGe(two * 10_000, honest * 6_400, \"closed maxAge (here: one second) moved more than 1 - (1-c)^2\");\n    }\n}","reproduction":"NHI leaf (SwarmNhiPolicy, 1 day, 2,000 bps): t0 set 0.71; t0+1d honest 0.71 (epoch opens, anchor 0.71); +6h honest 0.78; +6h honest 0.85 -> Pricer.quote: mat 1.70, borrowable. +1 s: one attestation with target 1 wei. Expected (one cap from the held value): NHI >= 0.68, mat <= 1.904. Actual: NHI 0.568, mat 2.000.\nPrice leg (SwarmPricePolicy, 1 h, 2,000 bps): t0 100; t0+1h honest 100 (anchor 100); +20min honest 80; at t0+2h-1s target 2^128-1 -> stored 120 (expected <= 96); at t0+2h -> 144 (expected <= 80*1.44 = 115.2). Mirror: honest 120, then 80 (expected >= 96) and 64 (expected >= 76.8).\nRun: forge test --match-path 'test/scratch/ProofSwingReach.t.sol' -vv (the file is in `proof`). Output on this commit:\nSuite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 1.61ms (718.96µs CPU time)\nRan 3 tests for test/scratch/ProofSwingReach.t.sol:ProofSwingReachTest\n[FAIL: one attestation moved the leg more than one cap from the value it held: 800000000000000000000000 < 960000000000000000000000] test_leg_closedWindow_minus47pct_inOneSecond() (gas: 2470151)\n  leg after ONE attestation (honest level 120): 80.000000000000000000\n  leg ONE SECOND later: 64.000000000000000000\n[FAIL: one attestation moved the leg more than one cap from the value it held: 1200000000000000000000000 > 960000000000000000000000] test_leg_closedWindow_plus80pct_inOneSecond() (gas: 2481667)\n  leg after ONE attestation (honest level 80): 120.000000000000000000\n  leg ONE SECOND later: 144.000000000000000000\n[FAIL: NHI moved more than one cap from the value it held a second before: 568000000000000000 < 680000000000000000] test_nhi_oneAttestation_mat_170_to_200() (gas: 4459508)\n  NHI one second after 0.85: 0.568000000000000000\n  mat one second after 1.70: 2.000000000000000000\nSuite result: FAILED. 0 passed; 3 failed; 0 skipped; finished in 5.14ms (1.93ms CPU time)\n[FAIL: one attestation moved the leg more than one cap from the value it held: 800000000000000000000000 < 960000000000000000000000] test_leg_closedWindow_minus47pct_inOneSecond() (gas: 2470151)\n[FAIL: one attestation moved the leg more than one cap from the value it held: 1200000000000000000000000 > 960000000000000000000000] test_leg_closedWindow_plus80pct_inOneSecond() (gas: 2481667)\n[FAIL: NHI moved more than one cap from the value it held a second before: 568000000000000000 < 680000000000000000] test_nhi_oneAttestation_mat_170_to_200() (gas: 4459508)\n","severity":"medium","snippet":"        uint256 v = _clamp(target, anchor, bound);","title":"Epoch band is anchored at the epoch's opening value, not the value held: after an honest move inside an epoch ONE signed value moves a leg +50% / -33.3% and NHI two caps' worth (mat 1.70 -> 2.00 in on"},{"citation":"resolved","description":"P4 says a composite reports proven only when one input is proven and the other has no attester in its path. ProductFeed applies that to both inputs (FeedTraits.attesterFree), RateFeed does not: its second input is `rateSource`, read through any zero-argument getter (`selector`, `passOneE18 = false`), and proven() returns FeedTraits.proven(underlying) alone (RateFeed.sol:104-106); converged() (:99-101), attested() (:110-112, uses the stored rate) and isStale() (:94-96) ignore the rate source too. A SwarmFeed answers `latestValue()` with (value, updatedAt); liveRate() decodes the first word, so RateFeed(rateSource = a swarm leaf, selector = latestValue, underlying = ProvenPoolPrice) builds, prices at clampedLeaf x provenPrice, and reports proven() = true and converged() = true while the leaf is clamped (stored 1.2 vs attested 2.0); ProductFeed(thatRateFeed, ChainlinkFeed).proven() is true as well. As a type's spot leg this gets the Pricer's twin rule (low = max(spot, min(median, attested))) and the 'converged legs only agree' rule from a value one attester key moves and holds clamped, and the leaf's staleness is not seen. NOT reachable in the shipped deploy graphs (mainnet F_SIMD_SPOT / F_SIMD_MEDIAN use SIMD.convertToAssets; 4663 has no proven leg): it needs the Safe to add such a RateFeed (ADD/SET feed, 48 h). DeployBase._provenAtDeploy mirrors the same rule, so the deploy check would not catch it. SMALLEST FIX: in RateFeed, proven() = FeedTraits.proven(underlying) && FeedTraits.attesterFree(IFeed(rateSource)) and converged() = FeedTraits.converged(underlying) && FeedTraits.converged(IFeed(rateSource)) (an ERC-4626 or wstETH answers neither trait, so the shipped feeds read exactly as today), or refuse in the constructor a rateSource that answers `converged()`.","line":105,"path":"src/feeds/RateFeed.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract LegDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// Stands in for ProvenPoolPrice: answers proven() and no converged().\ncontract ProvenStub {\n    function latestValue() external view returns (uint256, uint64) { return (1e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 6 hours; }\n    function proven() external pure returns (bool) { return true; }\n}\n\n/// Stands in for ChainlinkFeed: no trait at all.\ncontract PlainStub {\n    function latestValue() external view returns (uint256, uint64) { return (2000e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 1 hours; }\n}\n\ncontract ProofRateFeedTraitsTest is Test {\n    function test_rateFeed_attestedRateSource_readsProvenAndConverged() public {\n        vm.warp(1_800_000_000);\n        LegDoor ratio = new LegDoor();\n        ratio.set(1e18);\n        ratio.set(2e18); // clamped: stored 1.2, attested 2.0\n        assertFalse(ratio.converged());\n        RateFeed rf = new RateFeed(address(ratio), IFeed.latestValue.selector, false, IFeed(address(new ProvenStub())), 1e18);\n        (uint256 v,) = rf.latestValue();\n        assertEq(v, 1.2e18, \"the value is the attester's clamped leaf x the proven price\");\n        ProductFeed pf = new ProductFeed(IFeed(address(rf)), IFeed(address(new PlainStub())));\n        assertFalse(rf.converged(), \"an attested input is clamped: must not read converged\");\n        assertFalse(rf.proven(), \"P4: an attester is in the path: must not read proven\");\n        assertFalse(pf.proven(), \"P4: the product over it must not read proven\");\n    }\n}","reproduction":"leaf = SwarmPricePolicy leaf (1 h, 2,000 bps): set 1e18, set 2e18 -> stored 1.2e18, attested 2e18, converged() false. rf = new RateFeed(address(leaf), IFeed.latestValue.selector, false, provenFeed, 1e18). rf.latestValue() = 1.2e18. Expected: rf.converged() false, rf.proven() false, ProductFeed(rf, chainlinkLike).proven() false. Actual: all three true.\nRun: forge test --match-path 'test/scratch/ProofRateFeedTraits.t.sol' -vv. Output on this commit:\nRan 1 test for test/scratch/ProofRateFeedTraits.t.sol:ProofRateFeedTraitsTest\n[FAIL: an attested input is clamped: must not read converged] test_rateFeed_attestedRateSource_readsProvenAndConverged() (gas: 3964568)\n[FAIL: an attested input is clamped: must not read converged] test_rateFeed_attestedRateSource_readsProvenAndConverged() (gas: 3964568)","severity":"low","snippet":"        return FeedTraits.proven(underlying);","title":"RateFeed.proven()/converged()/attested()/isStale() look only at `underlying`: a rate source that is an attested swarm leaf is invisible, so the composite (and a ProductFeed over it) reads proven and c"},{"citation":"resolved","description":"BUILD: forge 1.8.3, solc 0.8.26 via_ir. The required glob ran green on this commit: 11 suites, 48 tests passed, 0 failed (SwarmFeedProperties incl. invariant 128 runs x 64, PricerTwin, ProvenPoolPrice, AuditW4TwinLag, AuditW4NhiMat, AuditW4SlidingBound, AuditW4TraitNested, AuditW4ProvenProduct, AuditW4ProveWindow, AuditW5NhiWindow). My proof file test/unit/ProofW5Math.t.sol (source below) ran with FOUNDRY_FUZZ_RUNS=1500 and was deleted afterwards.\nQ1 (P1, P2, P8) - HOLD TOGETHER, nothing wrong. Fuzz over any (median m, attested median, proven spot s, converged or not), skew 5%: low >= s/1.05 (P1: m < s reads low = s; agreeing reads min(m,s) >= s/1.05); low >= 0.95 x min(m, attested) (P8: a pushed or selected spot alone never goes below it, including while an honest median is clamped); when m > s, low <= max(s, attested) (P2: no k-epoch lag; a median clamped high counts only at its attested value); a pushed-up proof gives low = s with borrowable false. Following the attested median does not give back what the twin bounded: with the key alone attested -> 1 wei only yields low = s (the honest spot), never below it; stale attested cannot arise while the median is fresh (attested is rewritten by every acceptance, and a stale median is unpriced).\nC1 - CONFIRMED, bound stated: with the key (median unconverged, attested <= s) AND a push, low = s exactly, for any depth of push: the Pricer adds NO floor. The bound is therefore only 'the end-of-block price of pool 0xb07d that the pusher makes stand at ONE block end' x ETH/USD x sIMD rate: every sIMD loan with collateral x s_pushed < debt x mat is bitten in the proving transaction at s_pushed (the keeper's 60 s tick comes too late for a prove-and-bite in one transaction). A proof within 1.5% of the live pool is not re-proved until its 5th hour, but is worth at most that 1.5%.\nQ2 (P3, P7) - see finding 1. P3 as literally worded HOLDS (fuzz); P7's closed-window numbers do NOT (+80% / -46.7% instead of +44% / -36%), and mat moves 1.70 -> 2.00 on one attestation. The after-silence bound (1+2c)(1+c)^2-1 holds. On 4663 one key moves both legs together, so the leg bound is the type bound: +80% in a boundary second after an honest intra-hour fall (past mat 1.70), else +44% then x1.2 per hour (past mat 1.70 at the third step, 1.728, in 1 h + 1 s; past mat 2.0 after a silence in one closed hour, 2.016); loss is bounded by the line (0, then 3,000). An attester key cannot manufacture the silence itself: on 4663 a window dated block.number + PARENT_SLACK (300) refuses honest windows for about 1 h, short of the 2 h (maxAge + STALE_GROWTH_PERIOD) of no acceptance the wide step needs (analysis, not tested).\nC2 - CONFIRMED. Carried anchor gives P3 for any timing (fuzz), and honest hourly relays reach the level: 0.98 -> 0.50 landing mid-epoch converged after 84 hourly relays (4 caps in 3.5 days; first cap waits two epochs, then one per epoch). Consequence to know (analysis): with an index that moves every hour every epoch is carried, so a sustained honest decline between about 10.6% and 20% a day lags and reads unconverged (sIMD borrowing off) although it is inside the cap.\nSOUNDNESS. The carried anchor is a correct rule for the WINDOW property but it does not bound a step from the value held (finding 1); the range clamp there is the smallest change and is the one the price legs should take too; the legs should NOT carry the anchor.\nQ3 (P4, P5) - shipped graphs read correctly (mainnet sIMD spot = Rate(Product(Proven, Chainlink)) proven and attester-free; median = Rate(Product(swarm, Chainlink)) converged iff the leaf is; 4663 IMD legs not proven). Finding 2 is the one composite that reports proven/converged wrongly (Safe-addable only). P5: I found no deployed feed whose empty revert or short success reads wrongly; a nested out-of-gas surfaces because each composite frame either reverts TraitUnreadable with data or itself runs out (the caller then keeps < 1/63). RateFeed.attested() does swallow a failed rat","line":99,"path":"src/Pricer.sol","reproduction":"forge test --match-path 'test/unit/ProofW5Math.t.sol' -vv with FOUNDRY_FUZZ_RUNS=1500, output:\n[PASS] testFuzz_P3_nhiWindow(uint256) (runs: 1500)\n[PASS] testFuzz_P7_leg_noSilence(uint256) (runs: 1500)  <- at the TRUE bound 18,000 / 5,333 bps; it fails at the stated 14,400 / 6,400 (counterexample seed 13223771473521671851518971: 6266.88 > 5862.04)\n[PASS] testFuzz_P7_leg_silence(uint256) (runs: 1500)\n[PASS] testFuzz_twin(uint256,uint256,uint256,bool) (runs: 1500)\n[PASS] test_C2_liveness_hourly()  hours of hourly relays until NHI converged on 0.50 (4 caps away): 84\n[PASS] test_C3_window_31_32_33()\n[PASS] test_C4_boundary_oldRuleFails_newRuleHolds()\n[FAIL: P4: an attester is in the path, must not read proven] test_P4_rateFeed_attestedRateSource_readsProven()  <- finding 2\nSuite result: FAILED. 7 passed; 1 failed\n\n---- test/unit/ProofW5Math.t.sol ----\n// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {SwarmFeed} from \"src/feeds/SwarmFeed.sol\";\nimport {SwarmNhiPolicy, SwarmPricePolicy} from \"src/feeds/SwarmFeeds.sol\";\nimport {ProvenPoolPrice} from \"src/feeds/ProvenPoolPrice.sol\";\nimport {RateFeed} from \"src/feeds/RateFeed.sol\";\nimport {ProductFeed} from \"src/feeds/ProductFeed.sol\";\nimport {Pricer} from \"src/Pricer.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract NhiDoor is SwarmNhiPolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 days, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\n/// The wave-4 NHI rule: one cap per epoch, no widening, NO carried anchor.\ncontract NhiOldDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 days, 2000) {}\n    function _staleMultiple() internal pure override returns (uint256) { return 1; }\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\ncontract LegDoor is SwarmPricePolicy {\n    constructor() SwarmFeed(address(1), address(0), 1, 3, 1 hours, 2000) {}\n    function set(uint256 t) external { _accept(t, uint64(block.timestamp)); }\n}\n\ncontract MMedian {\n    uint256 public v; uint256 public att;\n    function set(uint256 v_, uint256 a_) external { v = v_; att = a_; }\n    function latestValue() external view returns (uint256, uint64) { return (v, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 1 hours; }\n    function converged() external view returns (bool) { return v == att; }\n    function attested() external view returns (uint256) { return att; }\n}\n\ncontract MProven {\n    uint256 public v;\n    function set(uint256 v_) external { v = v_; }\n    function latestValue() external view returns (uint256, uint64) { return (v, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n    function maxAge() external pure returns (uint256) { return 6 hours; }\n    function proven() external pure returns (bool) { return true; }\n}\n\ncontract MParams {\n    ParametersBase.Config internal c; ParametersBase.Risk internal r;\n    constructor(IFeed m, IFeed s) { c.token = address(1); c.median = m; c.spot = s; r.skew = 0.05e18; r.mat = 1.7e18; }\n    function config(bytes32) external view returns (ParametersBase.Config memory) { return c; }\n    function storedRisk(bytes32) external view returns (ParametersBase.Risk memory) { return r; }\n    function cap(bytes32) external pure returns (uint256) { return 0; }\n    function maxLull() external pure returns (uint256) { return 0; }\n}\n\ncontract ProofW5MathTest is Test {\n    uint256 constant CAP = 2000;\n    uint256[] times; uint256[] vals; uint256 clock = 1_800_000_000;\n    function _warp(uint256 dt) internal { clock += dt; vm.warp(clock); }\n\n    function setUp() public { vm.chainId(1); vm.warp(1_800_000_000); vm.roll(26_000_000); }\n\n    function _val(SwarmFe","severity":"info","snippet":"            q.low = q.high = m > s ? Math.max(s, Math.min(m, FeedTraits.attested(c.median))) : s;","title":"Answers to questions 1-4 and claims C1-C4: what was confirmed by test (no defect beyond the two findings), with the proof file and its output"}],"hash":"f2973c98a1f7b2ca98f38fb838bf6046147e354d845355458316265a21e807fb","nodeId":"084c7e49-ef01-40db-a4b6-5ea15d95e6b2","outcome":"completed","summary":"The review is written to `.imd-findings.json`: one medium finding, one low, and an info entry carrying the answers to Q1–Q4 and C1–C4. No tracked file was changed and the proof files are deleted.\n\n## Findings\n\n**1. Medium — the epoch band is anchored at the opening value, not the value held** (`src/feeds/SwarmFeed.sol:692`)\n\nAfter an honest move inside an epoch, the whole opposite side of the band is one attestation away. This is not the known \"swing up and back down\": the first leg is honest, so the displacement from the true level is two caps' ratio.\n\n- **NHI / mat:** anchor 0.71, honest relays reach 0.85 (mat 1.70, borrowable); one compromised attestation a second later stores 0.568 and mat reads 2.00. Expected at most one cap from the held value: NHI ≥ 0.68, mat ≤ 1.904.\n- **Price legs:** honest level 80 inside an epoch anchored at 100; one attestation stores 120 (+50%), and a second one a second later across the boundary stores 144 (+80%). The mirror is −33.3% then −46.7%. Stated bounds are one cap and +44% / −36%.\n- **4663 IMD type:** after an honest intra-hour fall of about 15% or more, one key takes both legs past mat 1.70 in one boundary second, so the line (3,000) can be minted against collateral worth less than the debt without waiting an epoch.\n- **Smallest fix:** keep the epoch's lowest and highest stored value and also clamp into `[high × (1 − c), low × (1 + c)]`. That restores the stated numbers and refuses nothing; the cost is that an honest reversal larger than one cap finishes in the next epoch.\n\nThe proof file has three tests that fail on this commit (run output is in the finding).\n\n**2. Low — `RateFeed` traits ignore the rate source** (`src/feeds/RateFeed.sol:105`)\n\n`proven()`, `converged()`, `attested()` and `isStale()` look only at `underlying`. A `RateFeed` whose rate source is a swarm leaf (read through `latestValue`) over a proven price reports proven and converged while the leaf is clamped, and a `ProductFeed` over it reads proven too. It is not in the shipped graphs; it needs the Safe to add such a feed. A failing test is attached.\n\n## Questions and claims\n\n| Item | Result |\n|---|---|\n| Q1 (P1, P2, P8) | Hold together; following the attested median gives nothing back. Fuzzed, 1,500 runs. |\n| C1 | Confirmed. With the key and a push, `low` equals the pushed spot exactly at any depth; the Pricer adds no floor, so the bound is the price the pusher can make stand at one block end. |\n| Q2 (P3, P7) | P3 as literally worded holds (fuzz). P7's closed-window numbers do not: the true no-silence bound is +80% / −46.7%. The after-silence bound holds. |\n| C2 | Confirmed. 0.98 → 0.50 landing mid-epoch converged after 84 hourly relays. |\n| Q3 (P4, P5) | Shipped graphs read correctly; finding 2 is the only wrong composite. No feed found where an empty revert or short success reads wrongly — by reasoning about the gas rule, not by a gas sweep. |\n| Q4 / C3 (P6) | Confirmed. A prove landing 31 or 32 blocks after its block passes the window; 33 reverts `TooOld`. The keeper proving head-1 may land up to 31 blocks after the head it saw. |\n| C4 | Partly re-run. The wave-5 boundary case gives 0.544 on the old rule and 0.68 on this commit. The wave-4 proofs pass here; I did not rebuild the wave-4 commit to watch them fail on the old rule. |\n\nOn soundness: the carried anchor is right for the window property but does not bound a step from the value held. The range clamp in finding 1 is the smallest change, and the price legs should take it rather than carry the anchor.\n\n## What was run and what was not\n\n- The required glob passed: 11 suites, 48 tests, 0 failed (forge 1.8.3, solc 0.8.26 via_ir).\n- My confirmation file ran with 1,500 fuzz runs. Seven tests passed; the eighth fails by design and is finding 2. Its source and output are pasted in the info entry.\n- Leaves were driven through `_accept`, as the shipped tests do; the signature path was not exercised.\n- The wave-4 findings API rejected the short job ids, so I could not c","treeHash":null,"usage":{"cachedInputTokens":1950995,"cost":{"source":"runtime","usdMicros":7190232},"inputTokens":33,"model":"claude-fable-5-2","outputTokens":99591,"runtime":"claude","turns":23,"wallClockMs":1737278}}],"verification":[]}