{
 "item": "house-proven-pool-feeds",
 "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40",
 "forge": "forge 1.8.3 (cae51ad, 2026-09-15), older than 1.9: no --use solar. solc 0.8.38 is not installed (only 0.8.24/0.8.26), so tests ran in a scratch copy of src/ at the commit with only `pragma solidity 0.8.38` relaxed to ^0.8.24, compiled with solc 0.8.26 via_ir; src/house/Parameters.sol replaced by a 4-getter stub (config/storedRisk/cap/maxLull) for the Pricer. No other source change.",
 "verdict": "findings",
 "findings": [
  {
   "id": "F1",
   "severity": "low",
   "title": "One signed future-dated window locks a remote leaf out of honest windows for up to days: the wave-3 cap limits clockBlock but lastToBlock takes the uncapped toBlock",
   "property": "P3",
   "claim": "C4",
   "files": [
    "src/house/feeds/SwarmFeed.sol:437",
    "src/house/feeds/SwarmFeed.sol:452",
    "src/house/feeds/SwarmFeed.sol:474",
    "src/house/feeds/SwarmFeed.sol:488",
    "README.md:1355"
   ],
   "sequence": "Remote leaf (data chain 1, consumer chain with no block clock, e.g. Base 8453). First value relayed by the deployer at (b0,t0). After the feed has run N days, the attester key signs ONE window with toBlock = most = originBlock + (issuedAt-originAt)/12 + PARENT_SLACK (accepted: _tickClock:474 only refuses toBlock > most). Line 488 caps clockBlock at projected+300, but line 452 stores lastToBlock = toBlock; every honest window with toBlock <= lastToBlock reverts WindowNotAdvancing (:437) until the real Ethereum head passes `most`, which runs ahead of it by the missed slots since the origin (~1%) + 300.",
   "expected": "P3: a remote clock never outruns the head; the wave-3 note (SwarmFeed.sol:484-487) says one window moves the clock at most PARENT_SLACK past the projection, so honest windows keep landing. README:1355 states only 'k validly signed, future-dated windows can still step a remote feed's clock k x PARENT_SLACK (bounded by the slow projection's most)'.",
   "actual": "The clock is capped (assert holds) but the window order is not: with 1% of slots missed, honest windows are refused for 4,800 s at a 1-day-old feed (> maxAge 1 h, the leaf goes stale) and 322,200 s (~3.7 days) at 365 days. That is one window, not k, and a lock-out that grows with the feed's age, so it is worse than README:1355 says. The leaf reads stale for that long, so a type priced by it is unpriced: no liquidation, no borrowing.",
   "reachableAtDeploy": false,
   "fix": "Cap the window order the same way as the clock: refuse toBlock > projectedHead(issuedAt) + PARENT_SLACK once clockAt != 0 (instead of the origin bound), or store lastToBlock = min(toBlock, clockBlock) and compare honest windows against that.",
   "test": {
    "source": "    /// P3 / C4: remote time clock (a feed whose data chain is not this chain and has no block clock: Base attesting\n    /// Ethereum). ONE validly signed window dated at the origin bound `most` (accepted: toBlock <= most) caps the CLOCK at\n    /// projection + PARENT_SLACK, but lastToBlock takes the uncapped toBlock: honest windows are refused (WindowNotAdvancing)\n    /// until the honest head passes it. Fuzzed over the feed's age; property: no lock-out past the leaf's maxAge.\n    function testFuzz_P3_remoteFutureWindowLocksOut(uint256 ageDays) public {\n        ageDays = bound(ageDays, 1, 365);\n        vm.chainId(8453);\n        uint64 t0 = 1_790_000_000; vm.warp(t0);\n        TLeaf leaf = new TLeaf(vm.addr(PK), 1, 1 hours, 2000);\n        uint64 b0 = 21_000_000;\n        _submit(leaf, M0, b0 - 400, b0, t0); // first value: deployer-only rule (this contract deployed the leaf)\n        uint64 t1 = t0 + uint64(ageDays) * 1 days; vm.warp(t1);\n        // honest window just before (keeps the clock honest; 1% of slots missed)\n        uint64 h1 = b0 + uint64((t1 - t0) * 99 / 100 / 12);\n        _submit(leaf, M0, h1 - 400, h1, t1);\n        uint64 most = uint64(uint256(b0) + (t1 - t0) / 12 + leaf.PARENT_SLACK());\n        _submit(leaf, M0, most - 400, most, t1); // signed, future-dated, within the bound: accepted\n        assertLe(leaf.clockBlock(), leaf.projectedHead(t1) + 300, \"clock capped (wave-3 fix holds)\");\n        assertEq(leaf.lastToBlock(), most, \"lastToBlock is NOT capped\");\n        uint256 dt;\n        for (dt = 5 minutes; dt < 30 days; dt += 5 minutes) {\n            uint64 h = b0 + uint64((t1 + dt - t0) * 99 / 100 / 12);\n            vm.warp(t1 + dt);\n            (SwarmFeed.OracleAttestation memory a, bytes memory sig) = _att(leaf, M0, h - 400, h, uint64(t1 + dt));\n            try leaf.submitAttestation(a, sig) { break; } catch {}\n        }\n        emit log_named_uint(\"feed age (days)\", ageDays);\n        emit log_named_uint(\"honest windows refused for (s)\", dt);\n        assertLe(dt, 1 hours, \"remote leaf locked out past maxAge by one future-dated window\");\n    }\n    function test_P3_age365() public { testFuzz_P3_remoteFutureWindowLocksOut(365); }\n\n// harness (TLeaf, _att, _submit): see F2.test.source",
    "ran": "RAN: forge 1.8.3, solc 0.8.26 via_ir, scratch copy (see forge field), fuzz runs 2000",
    "result": "[FAIL: remote leaf locked out past maxAge by one future-dated window: 48300 > 3600] testFuzz_P3_remoteFutureWindowLocksOut(uint256) (first run; the age was not logged then). A later fuzz run shrank to feed age (days): 1 with honest windows refused for (s): 4800. [FAIL: remote leaf locked out past maxAge by one future-dated window: 322200 > 3600] test_P3_age365() (feed age (days): 365, honest windows refused for (s): 322200). The asserts 'clock capped (wave-3 fix holds)' and 'lastToBlock is NOT capped' passed before the failure."
   }
  },
  {
   "id": "F2",
   "severity": "low",
   "title": "P2 as framed does not hold: honestly attested pushed reads + one pushed proof put sIMD low at 0.64 x market, not within skew (5%)",
   "property": "P2",
   "claim": "C2",
   "files": [
    "src/house/Pricer.sol:75",
    "src/house/Pricer.sol:115",
    "src/house/Pricer.sol:116",
    "script/house/DeployConfig.sol:659",
    "script/house/DeployConfig.sol:480",
    "README.md:1525"
   ],
   "sequence": "Same epoch, no key: (1) the median leaf holds the market M0 (epoch anchor). (2) An honest panel attests a window of pushed pool reads at P < 0.8 M0: the leaf stores clamp(P) = 0.8 M0, attested() = P, converged() false. (3) One pushed proof puts the proven spot at P. Pricer: legs disagree, spot proven, so the twin rule runs: low = max(P, min(m, max(att, m(1-TWIN_STEP)))) = 0.8 x 0.8 M0.",
   "expected": "Sheet P2: a wrong median cannot push low below the market by more than skew (sIMD skew 0.05e18, DeployConfig:659), by any coalition of honestly attested pushed reads + one pushed proof, no key.",
   "actual": "low / market = 0.640000 for every pushed price in [1%, 64%] of M0 (fuzz, 2000 runs). The bound in code is (1 - TWIN_STEP)^2 = 0.64 at the first delivery (TWIN_STEP 0.2e18, Pricer:75; the clamped median itself moves one cap). It is documented in README:1525 ('Honest attestations of PUSHED pool reads plus one pushed proof, with no key, move `low` one allowance below the stored median at once'), a known-issue line the sheet does NOT name (it names README:1355 and :1414). So the sheet's P2 misdescribes the code: refuted. No worse than README:1525 / SwarmFeeds.sol's 'low stays >= held x (1 - c)^2'.",
   "reachableAtDeploy": true,
   "fix": "Either restate P2 as 'low >= held median x (1 - c)^2 per epoch' (what the code and README:1525 give), or, to meet skew, set TWIN_STEP = skew (the twin then leads the median by at most skew under the stored value, and by (1-c)(1-skew) under the held one).",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\nimport {Test} from \"forge-std/Test.sol\";\nimport {IFeed} from \"../src/house/interfaces/IFeed.sol\";\nimport {SwarmFeed} from \"../src/house/feeds/SwarmFeed.sol\";\nimport {SwarmPricePolicy} from \"../src/house/feeds/SwarmFeeds.sol\";\nimport {ProductFeed} from \"../src/house/feeds/ProductFeed.sol\";\nimport {ProductFeed as CoreProductFeed} from \"../src/feeds/ProductFeed.sol\";\nimport {IFeed as IFeedCore} from \"../src/interfaces/IFeed.sol\";\nimport {Pricer} from \"../src/house/Pricer.sol\";\nimport {Parameters} from \"../src/house/Parameters.sol\";\nimport {ParametersBase} from \"../src/house/ParametersBase.sol\";\n\n/// The production sIMD median leaf's policy (question, spans, 67/100, no stale widening), signed by a test attester.\ncontract TLeaf is SwarmPricePolicy {\n    constructor(address att, uint256 dataChain, uint256 maxAge_, uint256 cap_) SwarmFeed(att, address(0), dataChain, 3, maxAge_, cap_) {}\n}\n/// Chainlink-like: no traits (attester-free).\ncontract PlainFeed is IFeed {\n    uint256 public v; constructor(uint256 v_) { v = 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 view returns (bool) { return v == 0; }\n    function maxAge() external pure returns (uint256) { return 1 days; }\n}\n/// Stands for ProvenPoolPrice after ONE pushed proof (value = the pushed end-of-block price); same traits (proven() = true).\ncontract ProvenStub is PlainFeed {\n    constructor(uint256 v_) PlainFeed(v_) {}\n    function proven() external pure returns (bool) { return true; }\n}\n\ncontract ProvenFeedsTest is Test {\n    uint256 constant PK = 0xA11CE;\n    uint256 constant M0 = 4e15; // IMD/ETH wei per 1e18 IMD (the market, held by the median)\n    bytes32 constant ILK = \"SIMD\";\n    uint256 nonce;\n\n    function _att(TLeaf f, uint256 value, uint64 fromB, uint64 toB, uint64 issuedAt)\n        internal returns (SwarmFeed.OracleAttestation memory a, bytes memory sig)\n    {\n        a.requestId = bytes32(++nonce); a.chainId = f.attestationChainId(); a.questionHash = f.expectedQuestionHash(fromB, toB);\n        a.answerType = 3; a.answer = abi.encode(value); a.fromBlock = fromB; a.toBlock = toB;\n        a.panelSize = 100; a.quorum = 67; a.agreed = 100; a.issuedAt = issuedAt; a.expiresAt = issuedAt + 1 days;\n        bytes32 h = keccak256(bytes.concat(\n            abi.encode(f.ATTESTATION_TYPEHASH(), a.requestId, a.chainId, a.questionHash, a.answerType, keccak256(a.answer), a.figure, a.fromBlock),\n            abi.encode(a.toBlock, a.blockHash, a.panelJobId, a.panelSize, a.quorum, a.agreed, a.issuedAt, a.expiresAt)));\n        (uint8 v, bytes32 r, bytes32 s) = vm.sign(PK, keccak256(abi.encodePacked(\"\\x19\\x01\", f.DOMAIN_SEPARATOR(), h)));\n        sig = abi.encodePacked(r, s, v);\n    }\n    function _submit(TLeaf f, uint256 value, uint64 fromB, uint64 toB, uint64 issuedAt) internal {\n        (SwarmFeed.OracleAttestation memory a, bytes memory sig) = _att(f, value, fromB, toB, issuedAt);\n        f.submitAttestation(a, sig);\n    }\n    function _risk() internal pure returns (ParametersBase.Risk memory r) {\n        r.mat = 1.7e18; r.chop = 0.2e18; r.skew = 0.05e18; // DeployConfig _r: skew 0.05e18\n    }\n\n    // ... tests below\n}\n\n    /// P2: honest attestations of a PUSHED pool (median window) + one pushed proof, no key. Property: low >= market x (1 - skew).\n    function testFuzz_P2_lowBelowMarketBySkew(uint256 pushed) public {\n        pushed = bound(pushed, M0 / 100, M0 * 94 / 100); // the pool pushed >= 6% down (past skew)\n        vm.chainId(1); vm.roll(30_000_000); vm.warp(1_790_000_000);\n        TLeaf leaf = new TLeaf(vm.addr(PK), 1, 2 hours, 2000); // IMD_LEG_MAX_AGE-like, 2,000 bps cap (shipped)\n        PlainFeed eth = new PlainFeed(3000e18);\n        ProvenStub proven = new ProvenStub(M0);\n        ProductFeed median = new ProductFeed(IFeed(address(leaf)), eth);\n        ProductFeed spot = new ProductFeed(proven, eth);\n        Parameters p = new Parameters();\n        ParametersBase.Config memory c;\n        c.token = address(1); c.median = median; c.spot = spot;\n        p.set(ILK, c, _risk());\n        Pricer pricer = new Pricer(p);\n        // honest market value held by the median (first value, epoch anchor)\n        _submit(leaf, M0, uint64(block.number - 400), uint64(block.number - 1), uint64(block.timestamp));\n        uint256 market = M0 * 3000; // USD per 1e18 IMD (x1e18)\n        // later in the same epoch: an honest panel attests a window of PUSHED reads; one pushed proof\n        vm.roll(30_000_100); vm.warp(1_790_000_000 + 20 minutes);\n        _submit(leaf, pushed, uint64(30_000_100 - 400), uint64(30_000_099), uint64(1_790_000_000 + 20 minutes));\n        proven.set(pushed);\n        Pricer.Quote memory q = pricer.quote(ILK);\n        emit log_named_decimal_uint(\"low / market\", q.low * 1e18 / market, 18);\n        assertGe(q.low, market * 95 / 100, \"P2: low pushed below market by more than skew\");\n    }\n",
    "ran": "RAN: forge 1.8.3, solc 0.8.26 via_ir, scratch copy (see forge field), fuzz runs 2000",
    "result": "[FAIL: P2: low pushed below market by more than skew: 7680000000000000000 < 11400000000000000000; counterexample: args=[5000000000000000000000]] testFuzz_P2_lowBelowMarketBySkew(uint256); log: low / market: 0.640000000000000000"
   }
  },
  {
   "id": "F3",
   "severity": "info",
   "title": "FeedTraits.attesterFree treats 'answers no converged()' as attester-free, but the core composites src/feeds/ProductFeed.sol and src/feeds/RateFeed.sol answer no trait: a house ProductFeed over a core composite of a swarm leaf reads proven and converged",
   "property": "P1",
   "claim": "C1",
   "files": [
    "src/house/feeds/FeedTraits.sol:59",
    "src/house/feeds/ProductFeed.sol:46",
    "src/house/feeds/RateFeed.sol:116",
    "src/feeds/ProductFeed.sol:10",
    "src/feeds/RateFeed.sol:1"
   ],
   "sequence": "Graph: house ProductFeed(ProvenPoolPrice, core ProductFeed(SwarmPriceFeed, ETH/USD)). The swarm leaf is clamped (converged false). attesterFree(core ProductFeed) = !answered(converged) = true, so house ProductFeed.proven() = true and converged() = true.",
   "expected": "P1: a composite reports proven only with an attester-free other input, on every implementation. FeedTraits.sol's own note: 'every swarm leaf answers it, and so does every composite, whatever is below it'.",
   "actual": "proven() returns true with a clamped attester in the other input (W4 C5 class, here via a non-trait composite). Not reachable at deploy: the house graph builds only src/house/feeds composites (StageFeeds.sol:6-9), DeployBase._attesterFreeAtDeploy mirrors the rule, and the core is Chainlink-only on day 1 (README Day 1). It needs a Safe re-point of a house spot to such a graph; Parameters/ParametersRules do not check traits at re-point (grep proven: no hit), so only review stands between.",
   "reachableAtDeploy": false,
   "fix": "Make attester-freedom a positive trait: attesterFree(f) = proven(f) || f answers attesterFree() == true (Chainlink, LivePoolPrice, ProvenPoolPrice, the vault adapters), default NOT free; or give src/feeds composites converged()/proven() pass-throughs.",
   "test": {
    "source": "    /// P1 / C1: a composite that is not a FeedTraits implementer (the core src/feeds/ProductFeed) over a swarm leaf reads\n    /// attester-free, so the house ProductFeed reports PROVEN (and converged) with an attester (clamped) in its other input.\n    function test_P1_coreCompositeHidesAttester() public {\n        vm.chainId(1); vm.roll(30_000_000); vm.warp(1_790_000_000);\n        TLeaf leaf = new TLeaf(vm.addr(PK), 1, 2 hours, 2000);\n        _submit(leaf, 1e18, uint64(block.number - 400), uint64(block.number - 1), uint64(block.timestamp));\n        vm.roll(30_000_100); vm.warp(1_790_000_000 + 20 minutes);\n        _submit(leaf, 0.5e18, uint64(30_000_100 - 400), uint64(30_000_099), uint64(1_790_000_000 + 20 minutes)); // clamped\n        assertFalse(leaf.converged());\n        CoreProductFeed hidden = new CoreProductFeed(IFeedCore(address(leaf)), IFeedCore(address(new PlainFeed(1e18))));\n        ProductFeed composite = new ProductFeed(new ProvenStub(1e18), IFeed(address(hidden)));\n        assertFalse(composite.proven(), \"P1: proven with an attester (clamped swarm leaf) in the other input\");\n    }\n\n// harness: see F2.test.source",
    "ran": "RAN: forge 1.8.3, solc 0.8.26 via_ir, scratch copy (see forge field), fuzz runs 2000",
    "result": "[FAIL: P1: proven with an attester (clamped swarm leaf) in the other input] test_P1_coreCompositeHidesAttester() (gas: 4052797)"
   }
  }
 ],
 "claims": [
  {
   "id": "C1",
   "result": "refuted",
   "evidence": "FeedTraits users in src/: Pricer.sol (:105,:108,:115,:127), ProductFeed.sol (:37-56), RateFeed.sol (:109-126), SeatFeed.sol (SeatFeed.converged :294, SeatSpotLeg.converged :326); trait implementers: ProvenPoolPrice.proven (pure true), ProductFeed, RateFeed, SwarmFeed (attested/converged :642-650), SeatFeed/SeatSpotLeg (converged only); ImdDepth.attested (:193) is an unrelated USD getter of the same selector (ImdDepth is not an IFeed: `contract ImdDepth` at ImdDepth.sol:37). script/house/deploy/DeployBase.sol:191,213-231 mirrors proven(). ProductFeed and RateFeed meet P1 for trait-aware inputs; the core src/feeds/ProductFeed and RateFeed implement no trait and read attester-free, so P1 fails for a composite over them (F3, info, not reachable at deploy). Deployed sIMD graph: spot = RateFeed(sIMD, ProductFeed(ProvenPoolPrice, Chainlink ETH)) -> proven; median = RateFeed(sIMD, ProductFeed(SwarmPriceFeed, ETH)) -> not proven (DeployConfig.sol:480-492)."
  },
  {
   "id": "C2",
   "result": "refuted",
   "evidence": "Twin rule runs only for a spot with the proven trait (Pricer:108): sIMD only; SeatSpotLeg has no proven(), so seat legs use the median rule. On sIMD the W5 high (low = pushed price at once) is closed in the sense that low >= max(spot, 0.8 x stored median) and the median leaf has no stale widening (SwarmFeeds.sol _staleMultiple = 1), but the bound is 0.64 x held market at the first delivery, not skew: F2 (fuzz). Documented in README:1525, which the sheet does not name."
  },
  {
   "id": "C3",
   "result": "holds",
   "evidence": "SeatFeed.sol:326 `FeedTraits.converged(feed.spot()) && FeedTraits.converged(feed.ethUsd()) && feed.converged()`: feed.converged() is a direct call. SeatFeed always implements converged() (:294), so a direct call cannot read 'absent'; a revert or out-of-gas propagates (fails closed), it cannot read true. Code read; no separate test."
  },
  {
   "id": "C4",
   "result": "refuted",
   "evidence": "No day-1 house leaf reaches _tickClock: HouseConfig sets c.chain.chainId = 1 (script/house/DeployConfig.sol:1296), every leaf is built with SwarmQuestions.DATA_CHAIN = 1 (SwarmFeeds.sol:45,111), so attestationChainId == block.chainid takes the same-chain branch (SwarmFeed.sol:438); the core is Chainlink-only on 4663/Base (README Day 1). Re-checked as code with a test leaf on chain 8453: the wave-3 clock cap (:488) holds, but lastToBlock (:452) is not capped, so one future window locks honest windows out (F1), worse than README:1355."
  },
  {
   "id": "C5",
   "result": "holds",
   "evidence": "One invariant: proven(f) => every leaf in f's latestValue DAG other than the ProvenPoolPrice is POSITIVELY declared attester-free (and converged(f) is true only when every SwarmFeed leaf below has _value == _attested). Today it rests on duck typing (absence of converged() = free), which F3 breaks with the trait-less core composites. Smallest replacement: an explicit attesterFree() trait answered true only by Chainlink/LivePool/Proven/vault adapters, default false in FeedTraits, checked by Parameters at every spot re-point (not only DeployBase at deploy)."
  }
 ],
 "holds": [
  {
   "property": "P3 (storage proof)",
   "tried": "Ran the commit's own ProvenPoolPrice suites in the scratch copy: test/house/unit/ProvenPoolPrice.t.sol (12/13 pass on a real mainnet proof: another manager, another pool, block-hash mismatch, out of range, current block, dropped/extra node, swapped proofs, tampered header/account/storage proof, same-block no-op; the 13th, test_constructorRefusesNoCodeOrZeroAge, failed with InvalidConfig in my harness, which lacks the commit's isolate/no-dynamic-linking settings) and AuditW4ProveWindow.t.sol (4/4, incl. testFuzz_onlyRecentBlocksMoveThePrice and testFuzz_heldBlockStaysANoOp at 2000 runs). Code: keccak(header) == blockhash(number) (:106-107), PROVE_WINDOW 32 (:109), keys computed from immutable manager/slot0Key (:114, :120-121), only prove() writes _value/provenBlock/_provenAt."
  },
  {
   "property": "P3 (first origin)",
   "tried": "Code: a remote leaf with no block clock accepts its first value only from the deployer (SwarmFeed.sol:480); with a block clock (4663 -> 1) the first window is bounded by block.number +300 / -maxAge/12 (:442-446). Test leaf on 8453: first value by deployer accepted (F1 harness)."
  },
  {
   "property": "P1 (deployed graph)",
   "tried": "Deployed sIMD spot is proven only through ProductFeed(Proven, Chainlink) and RateFeed with the sIMD vault (no converged()); median composite reads not proven. F3 test shows the only hole is a non-trait composite, absent at deploy."
  }
 ],
 "notRun": [
  "[fork]/[data]: no fork claims in this sheet; no mainnet fork run (NOT RUN).",
  "forge --use solar and solc 0.8.38: not available (forge 1.8.3, solc 0.8.38 not installed); all tests ran on a pragma-relaxed copy with solc 0.8.26.",
  "Invariant (stateful) campaign over Pricer + leaves: not run; fuzz only."
 ]
}