{"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":"b19b5e0c-704e-4104-a012-f4a8bfc22b72","kind":"audit","nodes":[{"acceptedSubmissionHash":"6e8c36bfbe52ab09088d5b5b2a467d3c386a8ede6c96f8b9fcff08e9eaa51c86","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":"e394b5db754319527db4e5c7acadf836296eaa20ae0b6d3091883c815bd83950","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":"b7e6550fa9b91e2895f7f60212f08800c5e6379becb5a2d2cc9927bc797515fb","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":"3f45e819b447ec889923496400e50d3739530ec3ecea9e56e0d896dabae2387c","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":"df6edb4264f2cf0349da2899847442b53e7cb637d09ed7b1ebc62ba015fa72b8","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":"RE-CHECK the wave-2 fixes in src/Parameters.sol, src/ParametersRules.sol, src/feeds/ImdDepth.sol, script/deploy/ (StageGenesis, StageFeeds, DeployBase), and REVIEW the beta as deployed and run: script/DeployConfig.sol BetaConfig, the size margins, the keeper's recurring gas, at the pinned commit, for a capped mainnet beta.\n\nimdUSD v2 is a multi-collateral CDP stablecoin; this is its capped mainnet beta on Ethereum. Positions are NFT ids; borrowers set their own rate and redemptions take from the lowest rates first; liquidation is mark then bite, with a standing bid from Backstop sleeves; prices come from Chainlink and swarm-attested feeds. README.md gives scope, invariants, trust model and known issues: read it first. Commit 1 (2875ffb) was audited in wave 1, commit 2 (5de80a6) in wave 2; this third commit is the whole delta since (README 'What changed since the second public audit').\n\nBUILD AND TEST (required; Foundry, solc 0.8.26 via_ir per foundry.toml). Never build or test the whole project with solc: it needs about 49 GB. Run only this panel's tests: `forge test --match-path 'test/unit/{AuditW2{ProposeAtApply,LowerOtherImd,ResumeSamplers},AuditW1{BatchItems,OtherImdLines},DepthRule,PanelParams,CapAndSlots}.t.sol'`. With Foundry 1.9+, `forge test --use solar --no-match-path 'test/fork/*'` builds everything and runs all 1,297 tests in seconds under 1 GB (confirm a proof and a gas figure with solc). Write each proof as test/unit/Proof<Name>.t.sol, add it to the glob, run it, paste it with its output, then delete it: leave the tree unchanged.\n\nWave 2's findings and proofs are public: GET https://api.imd.fun/jobs/<id>/submissions for jobs 5fcd4063 (money), 5a8d427d (prices), 62b92eb1 (running); each fix has a test named AuditW2*. For questions 1-3, re-run each original proof for these files against this commit and say whether it still fails, and why.\n\nQuestions 4-5: For each: measure, do not estimate (forge test --gas-report or gasleft() in a test), rank the options given and any better one, and say what you would build, with its cost. A change that saves gas but weakens a check, a bound or a README invariant is a finding, not a saving. Constraints: beta on 2026-12-07; Glamsterdam (EIP-8037/8038, not final) would price a new storage slot 110,020 gas and an update 12,100. Report concrete defects as findings in the usual form.\n\nAnswer each numbered question:\n1. A BATCH is dry-run at propose (Parameters.checkBatch / dryRun, a self-call that always reverts) and refused when an item fails only because of an earlier one. Can the dry run change state, be re-entered, be made to pass while the apply fails (or the reverse), or price a legitimate batch out of a block? Is an item waiting on state still accepted?\n2. ADD_DEPTH_SAMPLER asks ImdDepth.canAdd at propose, SET_DEPTH_LEG needs code on both, lowerOtherImdLines is removed, a resumed stage 4 stops when ImdDepth lists other samplers. What still passes propose and fails at apply, or what can a resume still adopt?\n3. The new PROVEN_POOL feed kind is deployed empty and verified by Check/DeployBase. Can a deploy or a resume adopt a wrong ProvenPoolPrice (manager, pool, base side, max age), and does anything at genesis read it before its first proof?\n4. SIZE AND ROOM. Measured under solc: Parameters init code 762 bytes under EIP-3860, ParametersRules 165 bytes, Ledger 1,778, Allocator 1,767. Per-contract optimizer runs failed because the deploy scripts compile every contract in one job (Ledger went over EIP-170). What should change before mainnet: deploying hot contracts from separately compiled artifacts, splitting ParametersRules off GovernedByKind, or else?\n5. GAS OVERALL. Name the three largest gas items of the protocol's own recurring bill (keeper) and of a borrower's first month, each with the change that removes most of it, measured. Include what Glamsterdam pricing does to each.\n\nNot findings: README.md 'Known issues and accepted risks' (say so if you find one worse than written); src/bridge, src/dex, src/earn/LoopVault.sol, src/stocks (after the beta) unless a question names them; test/ and mocks.\n\nFor every finding: severity by impact; file, line and the lines copied; the call sequence; a concrete failing state with expected against actual; whether it is reachable with script/DeployConfig.sol BetaConfig; the smallest fix; and a Foundry test that fails on this commit, RUN as BUILD says and pasted in full with its output (the judge reruns it). Answer every numbered question, including those where nothing is wrong.","parentJobId":null,"planHash":"36afc04b689eaa39ad4990961fc6162b591b0625735a22b0b21bbcf3975e6c7e","previousHash":"0000000000000000000000000000000000000000000000000000000000000000","projectId":"b19b5e0c-704e-4104-a012-f4a8bfc22b72","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":"51053","feedbackHash":"d8db8a8e87d4c3adbb694845653c37bde3b3777289c2747441cb47be7912a460","nodeKey":"audit_economics","submissionHash":"6e8c36bfbe52ab09088d5b5b2a467d3c386a8ede6c96f8b9fcff08e9eaa51c86","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"50961","feedbackHash":"922608c1d6e5712a3ab374b755d681c4cf1a4fd68e4739ea4ecd7dbe6f353197","nodeKey":"audit_flow","submissionHash":"e394b5db754319527db4e5c7acadf836296eaa20ae0b6d3091883c815bd83950","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"52176","feedbackHash":"2ddbfc6f94b4fde61033c82292ffe38d454ff0022d8e844fcd1299d792d7736c","nodeKey":"audit_judge","submissionHash":"b7e6550fa9b91e2895f7f60212f08800c5e6379becb5a2d2cc9927bc797515fb","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"51450","feedbackHash":"abe3730598400f6e419da3c4f7793eb717a273647b5e928f325aa396cb0f1a23","nodeKey":"audit_math","submissionHash":"3f45e819b447ec889923496400e50d3739530ec3ecea9e56e0d896dabae2387c","tag1":"review:submission","tag2":"acceptance-v2","value":1},{"agentId":"50989","feedbackHash":"a9aaeb7a505cb7fd44e2e0a30cddc8006cac487b4669c3a19bbcfc2b25ade486","nodeKey":"audit_permissions","submissionHash":"df6edb4264f2cf0349da2899847442b53e7cb637d09ed7b1ebc62ba015fa72b8","tag1":"review:submission","tag2":"acceptance-v2","value":1}],"site":null,"snapshotHash":"6ff95d6bfff06d18acc33b324424a01fc5a9cc59f3814a18192a26fde3773398","state":"completed","submissions":[{"artifacts":[],"attempt":1,"bundleHash":null,"device":"f2101c240e0b52a9","findings":[{"citation":"resolved","description":"Parameters.checkBatch (wave-2 fix) first dry-runs the whole batch; when any item fails it dry-runs prefixes [0,1), [0,2), ... until one fails, then the failing item alone. For a batch of n items whose LAST item only waits on state (README 'Known issues added after the second public audit': such an item 'is still accepted'), that is 1 + n(n+1)/2 item executions, each paying cold storage again because every dry run is a reverted frame (EIP-2929 access sets are rolled back). Measured under solc 0.8.26 via_ir: 7 ADD_ILK items plus a SET_RISK raising the depth-gated sIMD line before depth is measured costs 17,871,602 gas at propose; the same items with the waiting item first cost 4,105,299; 8 passing ADD_ILK items cost 6,651,366 at propose and 6,444,967 at apply (applyPending re-validates, so the dry run runs again before the real apply). Mainnet has run EIP-7825 (16,777,216 gas per transaction) since Fusaka, so the Safe cannot send the first batch at all, and any accepted batch pays O(n^2) at propose and about 2x at apply. The order of the items, not their content, decides whether a batch is proposable. Reachable with BetaConfig: the Parameters code is the same, MAX_BATCH is 8, and listing several types with an sIMD line raise is an ordinary Safe batch. No funds at risk; governance liveness and cost only. Smallest fix: make one dry run report the first failing index (dryRun catches each item's failure and reverts with DryRunFailed(i), checkBatch then dry-runs item i alone): 2 dry runs instead of up to n+2; and skip the dry run at applyPending (the apply itself re-validates each item in order). Note: because _dry treats an out-of-gas inner call as a plain failure, a propose that is short of gas skips the check instead of reverting; with MAX_BATCH 8 the gas retained by the 63/64 rule never covers storing the payload, so this cannot be reached today, but the fix should revert when the dry run did not complete.","line":417,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {ImdDepth} from \"src/feeds/ImdDepth.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract BgStub {}\n\ncontract BgJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\ncontract BgSampler {\n    address public manager;\n    bytes32 public poolId;\n\n    constructor(address m, bytes32 id) {\n        (manager, poolId) = (m, id);\n    }\n}\n\n/// Parameters.checkBatch re-runs the dry run over every prefix when an item fails: a batch whose LAST item is only\n/// waiting on state (README: accepted) costs O(n^2) item executions at propose. With 7 ADD_ILK items and one depth-gated\n/// line raise waiting on depth, the propose transaction needs more gas than EIP-7825's 16,777,216 per-transaction cap\n/// (Fusaka, live on mainnet since 2025-12), so the Safe cannot send it at all.\ncontract ProofBatchDryRunGasTest is Test {\n    uint256 constant TX_GAS_CAP = 16_777_216; // EIP-7825\n\n    Parameters params;\n    ImdDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant ETH = \"ETH\";\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new BgStub());\n        params.wire(ledger, address(new BgStub()));\n        params.addGenesisIlk(ETH, _cfg(), _risk(1_000_000e18));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new ImdDepth(address(params));\n        address[] memory list = new address[](1);\n        list[0] = address(new BgSampler(address(0xBEEF), bytes32(uint256(1))));\n        params.setGenesisImdDepth(address(depth), list);\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new BgStub());\n        c.join = address(new BgJoin(c.token, ledger));\n        c.median = IFeed(address(new BgStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function _addItems(uint256 n) internal returns (bytes[] memory items) {\n        items = new bytes[](n);\n        for (uint256 i; i < n; ++i) {\n            items[i] = abi.encode(params.ADD_ILK(), bytes32(bytes1(uint8(0x41 + i))), _cfg(), _risk(1_000e18));\n        }\n    }\n\n    /// The sIMD line raise: valid alone, fails at apply until depth is measured (DepthRuleFails). README: accepted.\n    function _waiting() internal view returns (bytes memory) {\n        return abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n    }\n\n    function _propose(bytes memory p) internal returns (uint256 used) {\n        vm.prank(gov);\n        used = gasleft();\n        params.propose(p);\n        used -= gasleft();\n    }\n\n    function test_waitingItemLastCostsMoreThanTheTxGasCap() public {\n        uint8 b = params.BATCH();\n        bytes[] memory adds = _addItems(7);\n        bytes[] memory items = new bytes[](8);\n        for (uint256 i; i < 7; ++i) items[i] = adds[i];\n        items[7] = _waiting();\n        uint256 last = _propose(abi.encode(b, items));\n        emit log_named_uint(\"propose gas, waiting item LAST (7 ADD_ILK + SET_RISK)\", last);\n        vm.prank(gov);\n        params.cancel(b);\n\n        // The same items with the waiting one first: accepted after two one-item dry runs.\n        items[0] = _waiting();\n        for (uint256 i; i < 7; ++i) items[i + 1] = adds[i];\n        uint256 first = _propose(abi.encode(b, items));\n        emit log_named_uint(\"propose gas, waiting item FIRST\", first);\n        vm.prank(gov);\n        params.cancel(b);\n\n        // Eight items that all apply: one dry run.\n        bytes[] memory eight = _addItems(8);\n        uint256 clean = _propose(abi.encode(b, eight));\n        emit log_named_uint(\"propose gas, 8 ADD_ILK all passing\", clean);\n        vm.warp(block.timestamp + params.TIMELOCK());\n        uint256 g = gasleft();\n        params.applyPending(b);\n        g -= gasleft();\n        emit log_named_uint(\"apply gas, 8 ADD_ILK (dry run again + apply)\", g);\n\n        assertLt(last, TX_GAS_CAP, \"an accepted batch must be sendable under EIP-7825\");\n    }\n}","reproduction":"State: Parameters sealed with ETH and SIMD registered, SIMD the depth-gated type with ImdDepth reading 0 depth (as the beta on day 1-6). Input: propose(abi.encode(BATCH, [ADD_ILK A..G (7 distinct new types), SET_RISK(SIMD, line 1000e18)])). Expected: propose succeeds within a sendable transaction (<= 16,777,216 gas, as the README says a state-waiting item is accepted). Actual: propose succeeds only with 17,871,602 gas, more than a mainnet transaction may carry; with the SET_RISK item first the same batch costs 4,105,299. Run: forge test --match-path test/scratch/ProofBatchDryRunGas.t.sol -vv","severity":"low","snippet":"        uint256 n = 1;\n        while (_dry(items, 0, n)) ++n;\n        if (_dry(items, n - 1, n)) revert BadConfig();","title":"BATCH dry run re-runs every prefix: an accepted batch (a state-waiting item last) costs 17.9M gas to propose, over EIP-7825's 16.78M per-transaction cap"},{"citation":"resolved","description":"StageFeeds keeps a recorded feed when DeployBase._feedIs says it is the config's node. The LIVE_POOL branch reads manager(), poolId() and baseIsToken0(), and ProvenPoolPrice (the new PROVEN_POOL kind, wave 3) exposes the same three with the same values for the same pool. So a resumed stage 2 whose record holds a ProvenPoolPrice at a LIVE_POOL node's index (BetaConfig: node 17 F_IMD_LIVE, the base of F_IMD_USD_LIVE and of sIMD's liveSpot leg F_SIMD_LIVE) adopts it silently instead of stopping with Mismatch, as every other kept piece does since wave 1. The sIMD live leg would then be a price proven at most 6 hours ago rather than the pool's price now: the redemption payout and the two-leg agree check (README invariant 2) follow a lagging value until it reads stale. The reverse direction fails closed (LivePoolPrice has no maxAge(), so the PROVEN_POOL branch reverts). Reaching it needs a deployment record whose feed array is misaligned with the config (a node inserted or the record edited between runs), so it is an operator-error path, not an attacker's; the resume logic exists for exactly that situation. Smallest fix: in the LIVE_POOL branch also require that f does not answer provenBlock() (or compare the kind recorded with each feed), so a feed of another kind stops the run.","line":178,"path":"script/deploy/DeployBase.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {DeployTypes} from \"script/DeployConfig.sol\";\nimport {StageFeeds} from \"script/deploy/StageFeeds.sol\";\nimport {ProvenPoolPrice} from \"src/feeds/ProvenPoolPrice.sol\";\nimport {LivePoolPrice} from \"src/feeds/LivePoolPrice.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\n/// A pool manager whose every pool reads as initialised at price 1 (StateLibrary.getSlot0 reads extsload).\ncontract FsMgr {\n    function extsload(bytes32) external pure returns (bytes32) {\n        return bytes32(uint256(1 << 96));\n    }\n}\n\ncontract FsStage is StageFeeds {\n    function stage(DeployTypes.Config memory cfg, Deployed memory d) external returns (Deployed memory) {\n        _stageFeeds(cfg, d);\n        return d;\n    }\n}\n\n/// DeployBase._feedIs's LIVE_POOL branch reads manager(), poolId() and baseIsToken0(): a recorded ProvenPoolPrice on the\n/// same pool answers all three, so a resumed stage 2 keeps it as the LIVE_POOL node (the sIMD live leg's base) instead of\n/// stopping with Mismatch or deploying a LivePoolPrice. (The reverse, a LivePoolPrice recorded where PROVEN_POOL is wanted,\n/// fails closed: LivePoolPrice has no maxAge().)\ncontract ProofResumeAdoptsProvenAsLiveTest is Test {\n    function test_resumeKeepsAProvenPoolPriceAsTheLivePoolNode() public {\n        FsStage h = new FsStage();\n        address mgr = address(new FsMgr());\n        bytes32 id = keccak256(\"pool\");\n        ProvenPoolPrice proven = new ProvenPoolPrice(mgr, id, false, 6 hours);\n\n        DeployTypes.Config memory cfg;\n        cfg.feeds = new DeployTypes.FeedNode[](1);\n        cfg.feeds[0].kind = DeployTypes.LIVE_POOL;\n        cfg.feeds[0].source = mgr;\n        cfg.feeds[0].poolId = id;\n        cfg.feeds[0].passOneE18 = false;\n\n        FsStage.Deployed memory d;\n        d.feeds = new IFeed[](1);\n        d.feeds[0] = IFeed(address(proven)); // the record holds a PROVEN_POOL feed at a LIVE_POOL node's index\n\n        d = h.stage(cfg, d);\n        assertTrue(address(d.feeds[0]) != address(proven), \"a ProvenPoolPrice must not be kept as a LIVE_POOL node\");\n    }\n}","reproduction":"Record d.feeds[i] = ProvenPoolPrice(manager M, pool P, baseIsToken0 false, 6h) where cfg.feeds[i] = {kind: LIVE_POOL, source: M, poolId: P, passOneE18: false}; run _stageFeeds. Expected: Mismatch(\"feed\") or a new LivePoolPrice at d.feeds[i]. Actual: d.feeds[i] stays the ProvenPoolPrice. Run: forge test --match-path test/scratch/ProofResumeAdoptsProvenAsLive.t.sol (fails on this commit: 'a ProvenPoolPrice must not be kept as a LIVE_POOL node').","severity":"low","snippet":"        if (n.kind == DeployTypes.LIVE_POOL) {\n            return address(LivePoolPrice(f).manager()) == n.source && PoolId.unwrap(LivePoolPrice(f).poolId()) == n.poolId\n                && LivePoolPrice(f).baseIsToken0() == n.passOneE18;\n        }","title":"Deploy resume keeps a ProvenPoolPrice recorded at a LIVE_POOL node: _feedIs's LIVE_POOL branch cannot tell the two feed kinds apart"}],"hash":"3f45e819b447ec889923496400e50d3739530ec3ecea9e56e0d896dabae2387c","nodeId":"506c4525-c200-4326-a3e1-31bf7aeb4604","outcome":"completed","summary":"The review is complete. Two low findings are recorded in `.imd-findings.json`, each with a Foundry proof that fails on this commit. The scratch tests were removed, so the tree is unchanged apart from the findings file.\n\n## Build and test\n\nThe required panel ran under solc 0.8.26 via_ir on this machine (Foundry 1.8.3, 7 GB RAM) in about 2 minutes after a 4-minute first compile. All tests passed:\n\n| Suite | Result |\n|---|---|\n| AuditW2ProposeAtApply, AuditW2LowerOtherImd, AuditW2ResumeSamplers | 4 passed |\n| AuditW1BatchItems, AuditW1OtherImdLines | 4 passed |\n| DepthRule, PanelParams, CapAndSlots | 36 passed |\n| GasSlots, DepthSampler, ProvenPoolPrice (for measurements) | 39 passed |\n\n`--use solar` does not work with Foundry 1.8.3 on this machine, so everything was measured with solc. The wave-2 submissions endpoint answered `invalid_job_id` for all three short ids, so the re-checks below use the repository's AuditW2 tests as the record of each proof.\n\n## Findings\n\n**1. Low. BATCH dry run re-runs every prefix.** `src/Parameters.sol:417`. When any item fails, checkBatch dry-runs prefixes of growing length, then the failing item alone. A batch whose last item only waits on state, which the README says is accepted, pays O(n²) item executions, each cold again because every dry run is a reverted frame. Measured: 7 ADD_ILK plus an sIMD line raise before depth exists costs 17,871,602 gas to propose. That is over the EIP-7825 per-transaction cap of 16,777,216, so the Safe cannot send it. The same items with the waiting item first cost 4,105,299. Eight passing ADD_ILK cost 6,651,366 at propose and 6,444,967 at apply, because applyPending re-validates and so dry-runs again. Fix: one dry run that reverts with the first failing index, then that item alone, and no dry run inside applyPending.\n\n**2. Low. Resume keeps a ProvenPoolPrice at a LIVE_POOL node.** `script/deploy/DeployBase.sol:178`. The LIVE_POOL branch of `_feedIs` reads manager, poolId and baseIsToken0, which ProvenPoolPrice also answers. A record holding a ProvenPoolPrice at F_IMD_LIVE's index is adopted as sIMD's live leg instead of stopping with Mismatch. Operator-error path only. The reverse fails closed because LivePoolPrice has no maxAge.\n\n## Answers\n\n**Q1.** The dry run cannot persist state: dryRun always reverts, and both entry points accept only self-calls. Re-entry from an external contract during a dry run only changes the dry run's own result, which is discarded. An item broken by an earlier one is refused, and a state-waiting item is still accepted. Two gaps: the cost above, and `_dry` treating an out-of-gas inner call as a plain failure, so an under-gassed propose would skip the check rather than revert. With MAX_BATCH 8 the 1/64 retained gas never covers storing the payload, so that regime is unreachable today, but the fix should revert when the dry run did not complete.\n\n**Q2.** Nothing new passes propose and fails at apply for ADD_DEPTH_SAMPLER or SET_DEPTH_LEG: canAdd mirrors addSampler exactly, the kind lock prevents a competing listing, and sampler identity is immutable. What still fails at apply is by design: SET_RISK on the depth type, SET_CAP against the live low, savings and dust steps, edge room, and the known 3-word retire. Note that removeDepthSampler cancels any pending unrelated ADD_DEPTH_SAMPLER. A resume can still re-point Parameters at a fresh ImdDepth before the seal when the record lost the old one, since setGenesisImdDepth has no already-set check. That is harmless pre-seal.\n\n**Q3.** The proven feed is compared on all four constructor values and the product node on both operands. Nothing at genesis reads it: the sampler constructor reads only slot0, and Deploy.t.sol lists both proven nodes as empty at deploy. A sampler reading a stale proven leg reverts StaleFeed, so it fails closed. The one gap is finding 2.\n\n**Q4.** Measured margins under EIP-170: ParametersRules 165 bytes, Parameters 1,420, Allocator 1,767, Ledger 1,778. Parameters' init code","treeHash":null,"usage":{"cachedInputTokens":1933892,"cost":{"source":"runtime","usdMicros":6598530},"inputTokens":450,"model":"claude-fable-5-1","outputTokens":49652,"runtime":"claude","turns":36,"wallClockMs":1376417}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"3d4af5c47a8f7374","findings":[{"citation":"resolved","description":"Parameters.checkBatch (wave-2 fix, 'an item that fails only because of an earlier item in the same batch is refused at propose') finds the first prefix 0..n that fails in order and asks only whether item n-1 fails alone. If that item is a legitimate 'waiting on state' item (allowed by design: a sIMD line raise before depth, a retire before its feed stops), the check returns without ever dry-running the items BEHIND it against the items before it. A batch [ADD_ILK X, SET_RISK sIMD line (waits on depth), ADD_ILK X] is accepted at propose, locks ADD_ILK and SET_RISK for 48 h, and can never apply: once depth arrives, the same dry run re-run at apply reaches item 3, finds it passes alone, and reverts BadConfig; the slot holds until the Safe cancels. This is exactly the class the wave-2 fix set out to refuse (two ADD_ILK of one type), reopened whenever a waiting item sits between them. Reachable with BetaConfig: the beta's day-7 batch carries a sIMD line item that waits on measured depth by design, and governance may add further items to it (MAX_BATCH = 8). Impact is limited to governance liveness (a 48 h slot and the kinds it locks are wasted; the Safe must cancel and re-propose), the same impact as the wave-2 low. Smallest fix: make the dry run one pass that, when item i fails in order, re-tries item i alone in a nested self-call against the pre-batch state; if it passes alone revert BadConfig, otherwise mark it waiting, skip it and continue applying the remaining items on the accumulated state (so every item is checked against the items before it, and the check is linear in the batch size, which also fixes the gas finding on line 418).","line":419,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract PbStub {}\n\ncontract PbJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\n/// The measured depth, moved by the test (on chain: DepthSampler + ImdDepth.poke).\ncontract PbDepth {\n    address public params;\n    uint256 public depth;\n\n    constructor(address p) {\n        params = p;\n    }\n\n    function set(uint256 d) external {\n        depth = d;\n    }\n\n    function addSampler(address) external {}\n}\n\n/// Parameters.checkBatch stops at the FIRST item that fails in order and only asks whether THAT item fails alone. An\n/// item behind it that fails only because of an earlier item (the wave-2 case: two ADD_ILK of one type) is never dry-run\n/// against the items before it. The batch passes propose, locks ADD_ILK and SET_RISK for 48 h, and can never apply:\n/// once the waiting item's state arrives (depth), apply reaches the third item and reverts IlkExists.\ncontract ProofBatchAfterWaitingItemTest is Test {\n    Parameters params;\n    PbDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new PbStub());\n        params.wire(ledger, address(new PbStub()));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new PbDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new PbStub());\n        c.join = address(new PbJoin(c.token, ledger));\n        c.median = IFeed(address(new PbStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function test_itemBrokenByAnEarlierItemBehindAWaitingItemIsRefusedAtPropose() public {\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        // Fails alone today (measured depth 0: DepthRuleFails) and is meant to wait for depth, as a single proposal may.\n        bytes memory line = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n        bytes[] memory items = new bytes[](3);\n        (items[0], items[1], items[2]) = (add, line, add);\n        uint8 b = params.BATCH();\n        bytes memory batch = abi.encode(b, items);\n\n        vm.prank(gov);\n        (bool accepted,) = address(params).call(abi.encodeCall(params.propose, (batch)));\n        if (accepted) {\n            // The depth arrives, the delay runs: the batch still cannot apply, ever. The SAME dry run, re-run at apply with\n            // the depth present, now reaches item 3, finds it passes alone, and refuses the batch (BadConfig).\n            depth.set(10_000e18);\n            vm.warp(block.timestamp + params.TIMELOCK());\n            vm.expectRevert(ParametersBase.BadConfig.selector);\n            params.applyPending(b);\n            assertTrue(params.locked() & (1 << params.ADD_ILK()) != 0, \"ADD_ILK stays locked until the Safe cancels\");\n        }\n        assertFalse(accepted, \"a batch whose third item fails only because of its first was accepted at propose\");\n    }\n}","reproduction":"Setup: Parameters with a genesis type SIMD (line 0), setGenesisDepthRule(SIMD, k=1e18, 0, 0, 0), an ImdDepth stand-in reading depth 0, sealed. Input: propose(abi.encode(BATCH, [ADD_ILK WSTETH, SET_RISK SIMD line 1,000, ADD_ILK WSTETH])). Expected (README wave-2): propose reverts BadConfig because the third item fails only because of the first. Actual: propose succeeds (dry(0,3) fails at item 2 on DepthRuleFails; dry(0,1) ok; dry(0,2) fails; dry(1,2) fails alone => accepted). Then set depth to 10,000e18, warp 48 h, applyPending(BATCH): reverts BadConfig (the apply-time dry run now reaches item 3); locked still has the ADD_ILK bit set. Test: test/scratch/ProofBatchAfterWaitingItem.t.sol, run with `forge test --match-path test/scratch/ProofBatchAfterWaitingItem.t.sol`: [FAIL: a batch whose third item fails only because of its first was accepted at propose] on this commit.","severity":"low","snippet":"        while (_dry(items, 0, n)) ++n;\n        if (_dry(items, n - 1, n)) revert BadConfig();","title":"BATCH dry run stops at the first item that waits on state, so a later item broken by an earlier one still passes propose and can never apply"},{"citation":"resolved","description":"checkBatch first dry-runs the whole batch, then re-runs the prefix 0..n for n = 1, 2, ... up to the first failing prefix, then the failing item alone: with the first failure at item k that is k(k+1)/2 + k + 1 item applications (45 for k = 8). Every dry run is a reverting self-call, so its SSTOREs and external calls are paid in full and refunded nothing. Measured with solc 0.8.26 via_ir on this commit (gasleft() around propose, isolate = true): the beta's day-7 batch (SET_DEPTH, SET_RISK sIMD, SET_KEEPER_CAP) costs 874,171 when the depth is present (one dry run) and 1,034,841 while the line waits on depth (four dry runs), against 767,554 for the three items proposed one by one, and apply costs 457,663 (the dry run runs again at apply). A full batch (MAX_BATCH = 8) of seven ADD_ILK plus one item that waits on state (the sIMD line before depth: allowed in a batch by the README) costs 17,854,743 at propose, above EIP-7825's per-transaction cap of 16,777,216 that is in force on mainnet since Fusaka and will be on 2026-12-07; the same eight items with none waiting cost 6,650,702 (apply: 6,444,921). So a legitimate batch the design allows cannot be proposed in one transaction, and the Safe must split it, losing the atomicity a BATCH exists for ('acts that must land together'). Reachable with BetaConfig (the batch is a governance payload; no special state). Impact: governance liveness only, and only for large batches that carry a waiting item; small batches cost about 1.3x their items. Smallest fix: have dryRun revert with the index of the first failing item (e.g. DryRunFailed(i)) instead of being re-run per prefix, so checkBatch does one in-order run plus one run of that item alone (two self-calls, linear), or the single-pass check described in the previous finding, which also closes its gap.","line":418,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract GcStub {}\n\ncontract GcJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\ncontract GcDepth {\n    address public params;\n    uint256 public depth;\n\n    constructor(address p) {\n        params = p;\n    }\n\n    function set(uint256 d) external {\n        depth = d;\n    }\n\n    function addSampler(address) external {}\n}\n\n/// Parameters.checkBatch re-runs the prefix 0..n for every n up to the first failing item (n(n+1)/2 item runs), then the\n/// item alone. A full batch (MAX_BATCH = 8) of seven ADD_ILK and one item that waits on state (the sIMD line before depth,\n/// which the README says a batch may carry) costs more at propose than EIP-7825's transaction gas cap (16,777,216, in force\n/// on mainnet since Fusaka): the Safe cannot propose it at all. The same eight items with none waiting cost 6.65M.\ncontract ProofBatchGasCapTest is Test {\n    uint256 constant EIP_7825_TX_GAS_CAP = 16_777_216;\n\n    Parameters params;\n    GcDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new GcStub());\n        params.wire(ledger, address(new GcStub()));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new GcDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new GcStub());\n        c.join = address(new GcJoin(c.token, ledger));\n        c.median = IFeed(address(new GcStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function test_fullBatchWithOneWaitingItemFitsInATransaction() public {\n        bytes[] memory items = new bytes[](8);\n        for (uint256 i; i < 7; ++i) {\n            items[i] = abi.encode(params.ADD_ILK(), bytes32(uint256(i + 1)), _cfg(), _risk(1_000e18));\n        }\n        // Passes validation, fails at apply alone until depth arrives (DepthRuleFails): allowed in a batch by design.\n        items[7] = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n        bytes memory batch = abi.encode(params.BATCH(), items);\n        vm.prank(gov);\n        uint256 g = gasleft();\n        params.propose(batch);\n        uint256 used = g - gasleft();\n        emit log_named_uint(\"gas propose (7 ADD_ILK + 1 waiting item)\", used);\n        assertLe(used, EIP_7825_TX_GAS_CAP, \"a legitimate full batch cannot be proposed in one transaction\");\n    }\n}","reproduction":"Setup as in the previous finding (SIMD at line 0, depth 0, sealed). Input: propose(abi.encode(BATCH, [ADD_ILK t1..t7 (seven fresh types, line 1,000 each), SET_RISK SIMD line 1,000])). Expected: the propose fits in a mainnet transaction (<= 16,777,216 gas). Actual: 17,854,743 gas measured around the call ([FAIL: a legitimate full batch cannot be proposed in one transaction: 17854743 > 16777216]). Control: the same batch with an eighth ADD_ILK instead of the waiting item: 6,650,702. Test: test/scratch/ProofBatchGasCap.t.sol, `forge test --match-path test/scratch/ProofBatchGasCap.t.sol -vv`.","severity":"low","snippet":"        while (_dry(items, 0, n)) ++n;","title":"BATCH dry run is quadratic in the batch length: a full batch with one waiting item costs 17.85M gas at propose, over EIP-7825's 16,777,216 transaction cap"}],"hash":"6e8c36bfbe52ab09088d5b5b2a467d3c386a8ede6c96f8b9fcff08e9eaa51c86","nodeId":"58ed544b-d8e0-4c0d-bbd9-ecd851e75856","outcome":"completed","summary":"Review complete. The findings file holds two substantiated defects, each with a Foundry proof that fails on this commit; the scratch tests were deleted and the tree is unchanged.\n\n## What was run\n\nBuild and tests used solc 0.8.26 via_ir through Foundry 1.9.0's sparse compilation (only the matched files and their imports), which took under a minute per run and never approached the memory limit. Solar is not installed on this machine, so every figure below is solc. The whole panel glob passed under solc: 44 tests across the eight files, including the three `AuditW2*` proofs and the two `AuditW1*` proofs. The wave-2 submissions API answered `invalid_job_id` for all three ids, so the original proofs re-run are the in-repo `AuditW2*` tests the README describes as the auditors' proofs adapted. The fork gas suite needs an RPC and was not run; keeper figures come from the unit suites' mock pools.\n\n## Findings\n\nBoth are low and both sit in `Parameters.checkBatch`, the wave-2 batch dry run.\n\n- **Dry run stops at the first waiting item.** After finding the first prefix that fails, the check asks only whether that item fails alone. If it does (a sIMD line raise before depth, which the README allows in a batch), the items behind it are never checked against the items before them. The batch `[ADD_ILK X, SET_RISK sIMD, ADD_ILK X]` passes propose, locks two kinds for 48 hours, and can never apply: once depth arrives, the same check re-run at apply refuses it with `BadConfig`. Proof: `ProofBatchAfterWaitingItem`, fails on this commit.\n- **Dry run is quadratic.** The prefix loop re-applies items 0..n for every n up to the first failure, each in a reverting self-call whose SSTOREs are paid in full. A full batch of seven ADD_ILK plus one waiting item costs more at propose than the EIP-7825 transaction cap that is live on mainnet, so the Safe cannot propose it in one transaction and must split it. Proof: `ProofBatchGasCap`, fails on this commit.\n\n| Batch proposed | Gas |\n|---|---|\n| Day-7 batch, depth present (1 dry run) | 874,171 |\n| Day-7 batch, line waiting on depth (4 dry runs) | 1,034,841 |\n| Same three items proposed singly, total | 767,554 |\n| Apply of the day-7 batch (dry run again, then apply) | 457,663 |\n| 8 ADD_ILK, all pass (8 item runs) | 6,650,702 |\n| 7 ADD_ILK + 1 waiting item (45 item runs) | 17,854,743 |\n| EIP-7825 cap | 16,777,216 |\n\nOne fix closes both: a single in-order pass that, when item i fails, re-tries it alone in a nested self-call, refuses if it passes alone, otherwise skips it and continues on the accumulated state.\n\n## Answers\n\n**1. Batch dry run.** It cannot change state: `dryRun` always reverts, every external call it makes (ImdDepth, the sleeves, the token, FeeNotes, SeatJoin) sits inside that frame, and `propose` only writes the slot afterwards. It cannot be re-entered: both `checkBatch` and `dryRun` accept only the contract itself, Parameters never calls an address it does not control, and a protocol contract that called `applyPending` from inside the dry run would be rolled back with it. The apply-time dry run is the same code on the same state as the real apply, and nothing in validate or apply reads `msg.sender`, so pass-at-propose-fail-at-apply arises only through state: the design-allowed waiting items, and finding 1. The reverse exists by design and is conservative: a batch refused because a later item collides with an earlier one (two new sleeve tokens past the limit, a seventh sampler) is refused even if an instant act before apply would have made room. A waiting item is still accepted, and that acceptance is what opens finding 1. Gas: a dry run that runs out of gas returns false and the check is skipped, but the retained 1/64 then cannot pay for storing the slot, so no realistic gas limit turns a refusal into an acceptance. Finding 2 covers the pricing-out.\n\n**2. Propose against apply.** `ImdDepth.canAdd` is the exact predicate of `addSampler`, nothing but ADD_DEPTH_SAMPLER can add one, and `removeDepthS","treeHash":null,"usage":{"cachedInputTokens":2472053,"cost":{"source":"runtime","usdMicros":7903656},"inputTokens":484,"model":"claude-fable-5-1","outputTokens":66953,"runtime":"claude","turns":46,"wallClockMs":2826180}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"ee2cc12e7dfe571a","findings":[{"citation":"resolved","description":"Merged from three specialists (permissions, flow, economics), all reproduced. README ('BATCH proposals are dry-run at propose'): an item that fails only because of an earlier item in the same batch is refused at propose. Parameters.checkBatch (lines 414-420) dry-runs the whole batch, then walks prefixes [0,n) to the FIRST failing one and asks only whether item n-1 fails alone. When that item legitimately waits on state (BetaConfig: the sIMD line raise before the measured depth exists, line 0 and depth 0 until day 7; also a RETIRE before its feed stops), checkBatch returns and no item after it is ever dry-run in order. So BATCH [SET_RISK(SIMD, line up), ADD_ILK X, ADD_ILK X] (or [ADD_ILK X, SET_RISK SIMD, ADD_ILK X]) passes propose, exactly the wave-2 case (two ADD_ILK of one type, two SET_KEEPER, two sleeve listings) hidden behind a waiting item. Call sequence: governor propose(BATCH) -> _validate -> ParametersRules.validateKind(BATCH) -> IBatchCheck(this).checkBatch -> _dry(0,3) false (DepthRuleFails at item 0) -> _dry(0,1) false -> _dry(0,1) alone false -> return (accepted). The batch locks BATCH, SET_RISK and ADD_ILK for 48 h plus the slot's life, and applyPending(BATCH) reverts whatever the depth: with depth present the apply-time re-validation runs checkBatch again, now reaches item 2 and reverts BadConfig; with no depth it reverts DepthRuleFails. The Safe must cancel and re-propose (another 48 h). Impact: governance liveness only, no funds (same class as the wave-2 low). Reachable with BetaConfig: the day-7 batch carries the sIMD line item that waits on depth by design, MAX_BATCH is 8. Smallest fix: one in-order pass that, when item i fails, dry-runs item i alone against the pre-batch state: passes alone -> revert BadConfig; fails alone -> mark it waiting, skip it, and continue applying the remaining items on the accumulated state (have dryRun take a skip mask and revert with the index of the first failure). Every item is then checked against the items before it, and the check is linear, which also fixes the quadratic-gas finding on line 418.","line":419,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract PbStub {}\n\ncontract PbJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\n/// The measured depth, moved by the test (on chain: DepthSampler + ImdDepth.poke).\ncontract PbDepth {\n    address public params;\n    uint256 public depth;\n\n    constructor(address p) {\n        params = p;\n    }\n\n    function set(uint256 d) external {\n        depth = d;\n    }\n\n    function addSampler(address) external {}\n}\n\n/// Parameters.checkBatch stops at the FIRST item that fails in order and only asks whether THAT item fails alone. An\n/// item behind it that fails only because of an earlier item (the wave-2 case: two ADD_ILK of one type) is never dry-run\n/// against the items before it. The batch passes propose, locks ADD_ILK and SET_RISK for 48 h, and can never apply:\n/// once the waiting item's state arrives (depth), apply reaches the third item and reverts IlkExists.\ncontract ProofBatchAfterWaitingItemTest is Test {\n    Parameters params;\n    PbDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new PbStub());\n        params.wire(ledger, address(new PbStub()));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new PbDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new PbStub());\n        c.join = address(new PbJoin(c.token, ledger));\n        c.median = IFeed(address(new PbStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function test_itemBrokenByAnEarlierItemBehindAWaitingItemIsRefusedAtPropose() public {\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        // Fails alone today (measured depth 0: DepthRuleFails) and is meant to wait for depth, as a single proposal may.\n        bytes memory line = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n        bytes[] memory items = new bytes[](3);\n        (items[0], items[1], items[2]) = (add, line, add);\n        uint8 b = params.BATCH();\n        bytes memory batch = abi.encode(b, items);\n\n        vm.prank(gov);\n        (bool accepted,) = address(params).call(abi.encodeCall(params.propose, (batch)));\n        if (accepted) {\n            // The depth arrives, the delay runs: the batch still cannot apply, ever. The SAME dry run, re-run at apply with\n            // the depth present, now reaches item 3, finds it passes alone, and refuses the batch (BadConfig).\n            depth.set(10_000e18);\n            vm.warp(block.timestamp + params.TIMELOCK());\n            vm.expectRevert(ParametersBase.BadConfig.selector);\n            params.applyPending(b);\n            assertTrue(params.locked() & (1 << params.ADD_ILK()) != 0, \"ADD_ILK stays locked until the Safe cancels\");\n        }\n        assertFalse(accepted, \"a batch whose third item fails only because of its first was accepted at propose\");\n    }\n}","reproduction":"State: Parameters sealed, SIMD registered with line 0, setGenesisDepthRule(SIMD, 1e18, 0, 0, 0), ImdDepth stand-in reading depth 0 (the beta before day 7). Input: governor propose(abi.encode(BATCH, [ADD_ILK WSTETH, SET_RISK(SIMD, line 1,000e18), ADD_ILK WSTETH])). Expected: revert BadConfig (as AuditW2ProposeAtApply.test_batchDuplicateAddIlkRefusedAtPropose shows for the two ADD_ILK without the waiting item). Actual: propose succeeds; then with depth set to 10,000e18 and 48 h later applyPending(BATCH) reverts BadConfig and the ADD_ILK lock stays set. Run on c64ecee: forge test --match-path 'test/scratch/Proof_59301b228fbd.t.sol' -> [FAIL: a batch whose third item fails only because of its first was accepted at propose] test_itemBrokenByAnEarlierItemBehindAWaitingItemIsRefusedAtPropose() (gas: 5410814). The two other specialists' proofs fail the same way ([FAIL: next call did not revert as expected] test_duplicateAddIlkBehindAWaitingItemIsRefusedAtPropose, test_brokenPairBehindWaitingItemIsNotRefused; [FAIL: BadConfig()] test_acceptedBatchNeverApplies).","severity":"low","snippet":"        if (_dry(items, n - 1, n)) revert BadConfig();","title":"BATCH dry run stops at the first item that waits on state: a later item broken by an earlier one still passes propose and can never apply"},{"citation":"resolved","description":"Merged from two specialists (economics, math), reproduced and extended. checkBatch dry-runs the whole batch, then prefixes [0,1), [0,2), ... up to the first failing one, then that item alone: with the first failure at item k that is 1 + k(k+1)/2 + 1 item applications (45 for k = 8). Each dry run is a reverting self-call, so its SSTOREs (ADD_ILK creates about 13 slots) and cold accesses are paid in full every time and refunded nothing. Measured (solc 0.8.26 via_ir, isolate, gasleft() around propose): 7 ADD_ILK + SET_RISK(SIMD line raise before depth, allowed in a batch by the README) = 17,854,743; the same eight items with none waiting = 6,650,702; with k ADD_ILK + the waiting item last: 1 -> 2,212,901; 2 -> 4,001,549; 3 -> 6,117,481; 4 -> 8,561,012; 5 -> 11,332,384; 6 -> 14,431,965; k+1 ADD_ILK none waiting: 1,833,490 / 2,636,127 / 3,439,173 / 4,242,699 / 5,046,690 / 5,851,301. Sent at exactly 16,777,216 gas the 7+1 propose reverts (no pending batch, the check is not silently skipped: the 63/64 rule leaves too little to store the payload). Mainnet has run EIP-7825 since Fusaka and will on 2026-12-07, so a legitimate batch the design allows cannot be proposed in one transaction, and the item ORDER (waiting item first: ~4.1M; last: 17.9M) decides whether a batch is proposable. applyPending re-validates, so an accepted batch pays the dry run again at apply (8 ADD_ILK: 6,444,921). Under the Glamsterdam figures given (new slot 110,020, update 12,100) each ADD_ILK dry application rises by about 13 x 87,920 = 1.14M, so even 3 ADD_ILK + a waiting item (10 dry applications of ADD_ILK) would add about 11M and exceed the cap. Reachable with BetaConfig (a governance payload, no special state). Impact: governance liveness and cost only. Smallest fix: the linear single-pass check of the previous finding (dryRun reverts with the index of the first failing item and takes a skip mask: two self-calls per waiting item instead of up to n+2 prefix runs), and skipping the dry run at applyPending, where the real apply already fails in order.","line":418,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract GcStub {}\n\ncontract GcJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\ncontract GcDepth {\n    address public params;\n    uint256 public depth;\n\n    constructor(address p) {\n        params = p;\n    }\n\n    function set(uint256 d) external {\n        depth = d;\n    }\n\n    function addSampler(address) external {}\n}\n\n/// Parameters.checkBatch re-runs the prefix 0..n for every n up to the first failing item (n(n+1)/2 item runs), then the\n/// item alone. A full batch (MAX_BATCH = 8) of seven ADD_ILK and one item that waits on state (the sIMD line before depth,\n/// which the README says a batch may carry) costs more at propose than EIP-7825's transaction gas cap (16,777,216, in force\n/// on mainnet since Fusaka): the Safe cannot propose it at all. The same eight items with none waiting cost 6.65M.\ncontract ProofBatchGasCapTest is Test {\n    uint256 constant EIP_7825_TX_GAS_CAP = 16_777_216;\n\n    Parameters params;\n    GcDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new GcStub());\n        params.wire(ledger, address(new GcStub()));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new GcDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new GcStub());\n        c.join = address(new GcJoin(c.token, ledger));\n        c.median = IFeed(address(new GcStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function test_fullBatchWithOneWaitingItemFitsInATransaction() public {\n        bytes[] memory items = new bytes[](8);\n        for (uint256 i; i < 7; ++i) {\n            items[i] = abi.encode(params.ADD_ILK(), bytes32(uint256(i + 1)), _cfg(), _risk(1_000e18));\n        }\n        // Passes validation, fails at apply alone until depth arrives (DepthRuleFails): allowed in a batch by design.\n        items[7] = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n        bytes memory batch = abi.encode(params.BATCH(), items);\n        vm.prank(gov);\n        uint256 g = gasleft();\n        params.propose(batch);\n        uint256 used = g - gasleft();\n        emit log_named_uint(\"gas propose (7 ADD_ILK + 1 waiting item)\", used);\n        assertLe(used, EIP_7825_TX_GAS_CAP, \"a legitimate full batch cannot be proposed in one transaction\");\n    }\n}","reproduction":"Setup as the previous finding (SIMD at line 0, depth 0, sealed). Input: propose(abi.encode(BATCH, [ADD_ILK t1..t7 (seven fresh types, line 1,000e18 each), SET_RISK(SIMD, line 1,000e18)])). Expected: fits in a mainnet transaction (<= 16,777,216 gas). Actual: 17,854,743 gas. Run on c64ecee: forge test --match-path 'test/scratch/Proof_1b1425d8e050.t.sol' -vv -> [FAIL: a legitimate full batch cannot be proposed in one transaction: 17854743 > 16777216] test_fullBatchWithOneWaitingItemFitsInATransaction() (gas: 20352161), Logs: gas propose (7 ADD_ILK + 1 waiting item): 17854743. Control (scratch GasCapBehaviour.t.sol): propose(7 ADD_ILK + waiting) at 16,777,216 gas ok? false; the k-item series above.","severity":"low","snippet":"        while (_dry(items, 0, n)) ++n;","title":"BATCH dry run is quadratic in the batch length: a full batch with one waiting item costs 17.85M gas at propose, over EIP-7825's 16,777,216 transaction cap"},{"citation":"resolved","description":"From the permissions specialist (who could not compile it); reproduced here through a StageGenesis harness. DeployBase's resume rule is that a recorded piece with code but other wiring stops the run (Mismatch), as the sleeves do ('Parameters points at other sleeves', StageGenesis.sol:231). The depth step does not: when Parameters already points at ImdDepth A (a first run that stopped later in stage 4, before the seal) and the resumed record carries no ImdDepth, or another one with params() == Parameters, the step deploys/keeps B and, because params.imdDepth() != B, calls setGenesisImdDepth(B, list) again. Parameters.setGenesisImdDepth (src/Parameters.sol:116-123) checks only code and params(), never that the slot is empty, so it overwrites `imdDepth` and lists the config's samplers on B. A, with every hourly low the keeper may already have poked into it, is orphaned with no Mismatch, the 'ImdDepth samplers' comparison of the wave-2 fix is skipped (it sits in the else branch), and the depth rule restarts from 0 for 6 days (ImdDepth.depth() reads 0 until the window has lows), delaying the beta's day-7 sIMD line. Deployer-only and pre-seal, so no funds: an operational defect in the wave-2 resume fix. Not reachable from a clean single-run BetaConfig deploy; reachable on any resume whose Deployed record disagrees with the chain (a lost or edited record, a resume from an older record). Smallest fix: in Parameters.setGenesisImdDepth add `if (address(imdDepth) != address(0)) revert BadConfig();` (as setGenesisBackstops does), and in _stageDepth add `else if (address(d.params.imdDepth()) != address(0)) revert Mismatch(\"Parameters points at another ImdDepth\");` before the setGenesisImdDepth branch.","line":305,"path":"script/deploy/StageGenesis.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {DeployTypes} from \"script/DeployConfig.sol\";\nimport {StageGenesis} from \"script/deploy/StageGenesis.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ImdDepth} from \"src/feeds/ImdDepth.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\n/// A pool manager whose every pool reads as initialised at price 1 (StateLibrary.getSlot0 reads extsload).\ncontract RpCode {\n    function extsload(bytes32) external pure returns (bytes32) {\n        return bytes32(uint256(1 << 96));\n    }\n}\n\ncontract RpToken {\n    function decimals() external pure returns (uint8) {\n        return 18;\n    }\n}\n\n/// Stage 4's depth step exactly as the launch runs it, on a deployment record `d`.\ncontract RpStage is StageGenesis {\n    function depthStep(DeployTypes.Config memory cfg, Deployed memory d) external returns (Deployed memory) {\n        _stageDepth(cfg, d);\n        return d;\n    }\n}\n\n/// DeployBase's resume rule: a recorded piece with code but other wiring stops the run (Mismatch) for a person to decide.\n/// The depth step breaks it: when Parameters already points at ImdDepth A (run 1) and the resumed record carries no (or\n/// another) ImdDepth, `_stageDepth` deploys B and calls `setGenesisImdDepth(B)` again, which has no already-set guard\n/// (Parameters.sol:116-123). A is orphaned with every low the keeper poked into it, and the depth rule restarts at 0.\ncontract ProofResumeRepointsImdDepthTest is Test {\n    RpStage h;\n    address manager;\n    address tokenA;\n    address tokenB;\n\n    function setUp() public {\n        h = new RpStage();\n        manager = address(new RpCode());\n        (tokenA, tokenB) = (address(new RpToken()), address(new RpToken()));\n        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\n    }\n\n    function _cfg() internal view returns (DeployTypes.Config memory cfg) {\n        cfg.poolManager = manager;\n        cfg.depth.enabled = true;\n        cfg.depth.samplers = new DeployTypes.SamplerSpec[](1);\n        DeployTypes.SamplerSpec memory sp = cfg.depth.samplers[0];\n        (sp.currency0, sp.currency1, sp.fee, sp.tickSpacing, sp.hooks) = (tokenA, tokenB, 10_000, 200, address(0));\n        sp.poolId = keccak256(abi.encode(tokenA, tokenB, uint24(10_000), int24(200), address(0)));\n        (sp.feed0, sp.feed1) = (DeployTypes.NO_FEED, DeployTypes.NO_FEED);\n        (sp.bandBps, sp.maxDeviationTicks, sp.maxSteps, sp.soldIsToken0) = (1_500, 200, 64, true);\n    }\n\n    function test_resumeWithoutTheRecordedImdDepthStopsInsteadOfRepointingParameters() public {\n        RpStage.Deployed memory d;\n        d.params = new Parameters(makeAddr(\"gov\"), address(h));\n        d.feeds = new IFeed[](0);\n        // Run 1: ImdDepth A deployed, its sampler listed, Parameters wired to A. The run stops later in stage 4.\n        d = h.depthStep(_cfg(), d);\n        ImdDepth a = d.imdDepth;\n        assertEq(address(d.params.imdDepth()), address(a));\n\n        // Resume on a record that lost the ImdDepth entry (the samplers are still recorded).\n        RpStage.Deployed memory d2 = d;\n        d2.imdDepth = ImdDepth(address(0));\n        // Expected (DeployBase's rule, as the sleeves do: \"Parameters points at other sleeves\"): revert Mismatch.\n        vm.expectRevert();\n        h.depthStep(_cfg(), d2);\n    }\n\n    function test_setGenesisImdDepthCanBeCalledTwice() public {\n        Parameters p = new Parameters(makeAddr(\"gov\"), address(this));\n        ImdDepth a = new ImdDepth(address(p));\n        ImdDepth b = new ImdDepth(address(p));\n        p.setGenesisImdDepth(address(a), new address[](0));\n        // Expected: a second wiring is refused (BadConfig), as setGenesisBackstops refuses a second call.\n        vm.expectRevert();\n        p.setGenesisImdDepth(address(b), new address[](0));\n    }\n}","reproduction":"Run 1: _stageDepth(cfg, d) with one sampler spec deploys ImdDepth A and its sampler and calls params.setGenesisImdDepth(A, [sampler]); params.imdDepth() == A. Resume with the same record but d.imdDepth = ImdDepth(address(0)): expected revert Mismatch (Parameters is wired to A); actual: a new ImdDepth B is deployed, setGenesisImdDepth(B, list) succeeds, params.imdDepth() == B, A is orphaned. Root cause check: setGenesisImdDepth(a) then setGenesisImdDepth(b) on a fresh Parameters both succeed. Run on c64ecee: forge test --match-path 'test/scratch/ProofResumeRepointsImdDepth.t.sol' -> [FAIL: next call did not revert as expected] test_resumeWithoutTheRecordedImdDepthStopsInsteadOfRepointingParameters() (gas: 4622087); [FAIL: next call did not revert as expected] test_setGenesisImdDepthCanBeCalledTwice() (gas: 95067).","severity":"low","snippet":"        if (address(d.params.imdDepth()) != address(d.imdDepth)) {\n            g = gasleft();\n            d.params.setGenesisImdDepth(address(d.imdDepth), list);","title":"Resumed stage 4 re-points Parameters at a different ImdDepth instead of stopping with Mismatch: setGenesisImdDepth has no already-set guard and the depth step never compares params.imdDepth with the r"},{"citation":"resolved","description":"From the math specialist; reproduced here through a StageFeeds harness. StageFeeds keeps a recorded feed when _feedIs says it is the config's node. The LIVE_POOL branch reads manager(), poolId() and baseIsToken0(); the new PROVEN_POOL kind (ProvenPoolPrice, wave 3) exposes the same three getters with the same values for the same pool (BetaConfig: F_IMD_LIVE node 17 and F_IMD_PROVEN node 23 are both pool 0xb07d on the v4 PoolManager with base = token1). So a resumed stage 2 whose record holds a ProvenPoolPrice at a LIVE_POOL node's index (a record misaligned with the config: a node inserted, or the record edited between a stopped run and its resume) adopts it silently instead of stopping with Mismatch(\"feed\"), against the wave-1 rule that a resume compares every kept piece with the config. F_IMD_LIVE is the base of F_IMD_USD_LIVE and of sIMD's liveSpot leg (F_SIMD_LIVE), so the sIMD redemption payout and the two-leg agree check (README invariant 2) would follow a price proven up to 6 hours earlier instead of the pool's price now, until it reads stale. The reverse direction fails closed (a LivePoolPrice at a PROVEN_POOL node is refused: control test passes). Operator-error path, deployer-only, pre-seal: no funds; low. Smallest fix: in the LIVE_POOL branch also require that f has no provenBlock()/maxAge() answer matching ProvenPoolPrice (a staticcall to provenBlock() must fail), or record each feed's kind in the Deployed record and compare it.","line":178,"path":"script/deploy/DeployBase.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {DeployTypes} from \"script/DeployConfig.sol\";\nimport {StageFeeds} from \"script/deploy/StageFeeds.sol\";\nimport {ProvenPoolPrice} from \"src/feeds/ProvenPoolPrice.sol\";\nimport {LivePoolPrice} from \"src/feeds/LivePoolPrice.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\nimport {IPoolManager} from \"v4-core/src/interfaces/IPoolManager.sol\";\n\ncontract PaCode {\n    function extsload(bytes32) external pure returns (bytes32) {\n        return bytes32(uint256(1 << 96));\n    }\n}\n\n/// Stage 2 exactly as the launch runs it, on a deployment record `d`.\ncontract PaStage is StageFeeds {\n    function feedsStep(DeployTypes.Config memory cfg, Deployed memory d) external returns (Deployed memory) {\n        _stageFeeds(cfg, d);\n        return d;\n    }\n}\n\n/// DeployBase._feedIs's LIVE_POOL branch reads manager(), poolId() and baseIsToken0(): a ProvenPoolPrice (wave 3's\n/// PROVEN_POOL kind) answers all three with the same values for the same pool, so a resumed stage 2 whose record holds a\n/// ProvenPoolPrice at a LIVE_POOL node's index keeps it instead of stopping with Mismatch(\"feed\").\ncontract ProofResumeAdoptsProvenAsLiveTest is Test {\n    bytes32 constant POOL = keccak256(\"pool\");\n\n    function test_provenPoolPriceRecordedAtALivePoolNodeIsNotKept() public {\n        PaStage h = new PaStage();\n        address manager = address(new PaCode());\n        DeployTypes.Config memory cfg;\n        cfg.feeds = new DeployTypes.FeedNode[](1);\n        cfg.feeds[0].kind = DeployTypes.LIVE_POOL;\n        cfg.feeds[0].source = manager;\n        cfg.feeds[0].poolId = POOL;\n        cfg.feeds[0].passOneE18 = false; // base is token1, as BetaConfig's F_IMD_LIVE\n\n        PaStage.Deployed memory d;\n        d.feeds = new IFeed[](1);\n        d.feeds[0] = IFeed(address(new ProvenPoolPrice(manager, POOL, false, 6 hours)));\n\n        // Expected: the kept piece is compared with the config and the run stops (Mismatch) or a LivePoolPrice is built.\n        // Actual: the ProvenPoolPrice is kept as the LIVE_POOL node.\n        PaStage.Deployed memory out = h.feedsStep(cfg, d);\n        assertTrue(address(out.feeds[0]) != address(d.feeds[0]), \"a ProvenPoolPrice must not be kept as a LIVE_POOL node\");\n    }\n\n    function test_control_livePoolPriceAtAProvenNodeIsRefused() public {\n        PaStage h = new PaStage();\n        address manager = address(new PaCode());\n        DeployTypes.Config memory cfg;\n        cfg.feeds = new DeployTypes.FeedNode[](1);\n        cfg.feeds[0].kind = DeployTypes.PROVEN_POOL;\n        cfg.feeds[0].source = manager;\n        cfg.feeds[0].poolId = POOL;\n        cfg.feeds[0].maxAge = 6 hours;\n        PaStage.Deployed memory d;\n        d.feeds = new IFeed[](1);\n        d.feeds[0] = IFeed(address(new LivePoolPrice(IPoolManager(manager), POOL, false)));\n        vm.expectRevert();\n        h.feedsStep(cfg, d);\n    }\n}","reproduction":"cfg.feeds = [ {kind: LIVE_POOL, source: M (a contract answering extsload), poolId: P, passOneE18: false} ]; d.feeds = [ ProvenPoolPrice(M, P, false, 6 hours) ]; run _stageFeeds(cfg, d). Expected: Mismatch(\"feed\") or a new LivePoolPrice at d.feeds[0]. Actual: d.feeds[0] stays the ProvenPoolPrice. Run on c64ecee: forge test --match-path 'test/scratch/ProofResumeAdoptsProvenAsLive.t.sol' -> [FAIL: a ProvenPoolPrice must not be kept as a LIVE_POOL node] test_provenPoolPriceRecordedAtALivePoolNodeIsNotKept() (gas: 22206455); [PASS] test_control_livePoolPriceAtAProvenNodeIsRefused().","severity":"low","snippet":"        if (n.kind == DeployTypes.LIVE_POOL) {\n            return address(LivePoolPrice(f).manager()) == n.source && PoolId.unwrap(LivePoolPrice(f).poolId()) == n.poolId\n                && LivePoolPrice(f).baseIsToken0() == n.passOneE18;","title":"Deploy resume keeps a ProvenPoolPrice recorded at a LIVE_POOL node: _feedIs's LIVE_POOL branch cannot tell the two feed kinds apart"},{"citation":"resolved","description":"From the flow specialist; verified from the artifacts of this commit's build (solc 0.8.26, via_ir, runs 200). ParametersRules runtime 24,411 bytes (margin 165), 108 external selectors of which only validateKind/applyKind are ever reached (delegatecall-only module), the rest being GovernedByKind's propose/cancel/applyPending/pending/locked and ParametersBase's getters and constants; it also receives the real governor, who can propose on the Rules contract's own storage (harmless: nothing reads it). Parameters runtime 23,156 (margin 1,420) and init code 48,390 (margin 762) because its constructor does `rules = new ParametersRules(governor_)` (src/Parameters.sol:24), so the two limits are coupled: any growth of the Rules runtime shrinks Parameters' init margin one for one. Ledger (runtime margin 1,778; init 44,886, margin 4,266, embedding LedgerSettlement the same way) and Allocator (margin 1,767) are the next tightest. Not a defect in behaviour; recorded because the two low findings above need code in checkBatch/dryRun and in ParametersRules' BATCH branch. Suggested change: deploy ParametersRules (and LedgerSettlement) separately in the deploy script and pass the address to the constructor (DeployBase checks extcodehash and the immutable self/governor as it does for every kept piece), which removes about 24.6 KB from Parameters' init code; and keep GovernedByKind out of the Rules module by splitting ParametersBase into a storage/constants base (no public getters) that both inherit and a governed layer only Parameters inherits.","line":13,"path":"src/ParametersRules.sol","reproduction":"After forge build on c64ecee: out/ParametersRules.sol/ParametersRules.json deployedBytecode 24,411 bytes, 108 methodIdentifiers including propose(bytes), cancel(uint8), applyPending(uint8), pendingOf(uint8), locked(); out/Parameters.sol/Parameters.json bytecode 48,390 bytes (49,152 - 48,390 = 762), out/Ledger.sol/Ledger.json deployedBytecode 22,798 / bytecode 44,886, out/Allocator.sol/Allocator.json deployedBytecode 22,809. Expected for a delegatecall-only module: two selectors and a runtime margin that does not bound Parameters' init code.","severity":"info","snippet":"contract ParametersRules is ParametersBase {","title":"ParametersRules is 165 bytes under EIP-170 and carries GovernedByKind's whole governance surface, while Parameters' init code embeds its creation code (762 bytes under EIP-3860): no room for the dry-r"}],"hash":"b7e6550fa9b91e2895f7f60212f08800c5e6379becb5a2d2cc9927bc797515fb","nodeId":"d71c194f-b4dc-45bc-a5d9-46abda7404d6","outcome":"completed","summary":"Done. The findings file holds five entries, four with proofs, and the scratch tests are removed so the tree is as it was.\n\n## Re-check of the wave-2 fixes (questions 1 to 3)\n\n**Q1, BATCH dry run.** The dry run cannot change state: `dryRun` is self-call only and always reverts, and `checkBatch` is self-call only, so every write inside it is rolled back. Re-entry during the dry run (an item's external call invoking the permissionless `applyPending`) is rolled back with the frame, and at propose the batch slot is not yet set. A waiting item is still accepted, as the README says. Two defects remain, both reproduced and reported as low findings:\n\n- **Passes propose, fails apply.** The prefix walk stops at the first item that fails alone and never dry-runs the items behind it in order. A duplicate ADD_ILK behind the sIMD line raise (the beta's day-7 batch shape) passes propose, locks its kinds, and reverts BadConfig at apply once depth arrives. Three specialists found this; merged into one finding.\n- **Priced out of a block.** The walk is quadratic. Measured: 7 ADD_ILK plus a waiting item costs 17,854,743 gas at propose, over the EIP-7825 cap of 16,777,216. Sent at exactly the cap it reverts, so the check is not silently skipped. Waiting item first costs about 4.1M, so item order decides proposability. Two specialists found this; merged. The reverse case (apply passes where propose fails) does not arise: apply re-runs the same check.\n\n**Q2, depth sampler, leg, lowerOtherImdLines, resume.** ADD_DEPTH_SAMPLER cannot pass propose and fail apply: `canAdd` mirrors `addSampler`, the kind lock prevents a second listing of the same pool in the window, and `removeDepthSampler` cancels the pending item. SET_DEPTH_LEG validates the zero pairing and code on both at propose, matching `setLeg`. The removed `lowerOtherImdLines` leaves no instant path that widens the sIMD line; SET_OTHER_IMD calls `_requireDepth` when the product rises. A resumed stage 4 still adopts one wrong state: with Parameters already wired to ImdDepth A and a record missing or holding another ImdDepth, the step calls `setGenesisImdDepth` again and re-points Parameters, skipping the sampler comparison and orphaning A's lows. The root cause is a missing already-set guard at `src/Parameters.sol:116`. Reported as low with a proof.\n\n**Q3, PROVEN_POOL.** A wrong ProvenPoolPrice is not adopted: the PROVEN_POOL branch of `_feedIs` compares manager, pool, base side and max age, and a LivePoolPrice at a PROVEN node is refused (control test passes). The gap is the other direction: the LIVE_POOL branch reads only manager, pool and base side, which a ProvenPoolPrice answers identically, so a misaligned record keeps a proven price as the live leg of sIMD. Reported as low with a proof. Nothing at genesis reads the proven feed before its first proof: it is only the samplers' reference through the product node, `sample` refuses a stale reference, `_emptyAtDeploy` exempts it from the priced check, and the sIMD line is 0 at genesis.\n\n## Size and gas (questions 4 and 5)\n\n**Q4, measured from this commit's artifacts.** ParametersRules runtime 24,411 bytes (165 under EIP-170), Parameters init 48,390 (762 under EIP-3860), Ledger runtime margin 1,778, Allocator 1,767. The coupling is the problem: Parameters' constructor does `new ParametersRules`, so Rules' runtime and Parameters' init share one margin. What I would build before mainnet, in order: deploy ParametersRules and LedgerSettlement separately in the script and pass their addresses to the constructors, with DeployBase checking extcodehash as for every kept piece. That frees about 24.6 KB of Parameters init and 18.8 KB of Ledger init at no runtime cost. Then split GovernedByKind and the public getters out of the Rules module, which today exposes 108 selectors for 2 used ones. Separately compiled artifacts with different optimizer runs I rank last: Foundry's runs setting is per profile, the verification story becomes two builds, and it does no","treeHash":null,"usage":{"cachedInputTokens":1614582,"cost":{"source":"runtime","usdMicros":5512834},"inputTokens":514,"model":"claude-fable-5-1","outputTokens":47236,"runtime":"claude","turns":42,"wallClockMs":1539165}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"e36579e0223ff908","findings":[{"citation":"resolved","description":"Wave 2's fix promises (Parameters.sol:409-413, README 'BATCH proposals are dry-run at propose'): 'if item i fails there but would apply alone, an earlier item broke it: refused (BadConfig)'. checkBatch only walks prefixes [0..n) until the FIRST prefix that fails and then judges item n-1 alone. When that first failing item is one that legitimately waits on state (a SIMD line raise before the measured depth, a RETIRE_SLEEVE_TOKEN before its feed stops, any SET_RISK that needs _requireDepth), the check returns without ever dry-running the items after it. A pair that fails ONLY because of an earlier item (two ADD_ILK of one type, two SET_KEEPER, two ADD_SLEEVE_ILK filling the sleeve, a SET_CAP after a SET_RISK that changes its bound) therefore passes propose exactly as before wave 2. The batch then locks BATCH plus every item's kind for 48 h and up to 14 d more, and reverts at apply even once the waiting item's state has arrived, until the Safe cancels it and re-proposes (another 48 h). Impact is operational (a governance change delayed, kinds locked), no funds; the same severity wave 2 gave the original. Reachable with BetaConfig: the day-7 batch itself opens the sIMD line (waits on depth) together with other items. Smallest fix: dry-run every item alone when the prefix fails, e.g. after the while loop, for (uint256 i = n - 1; i < items.length; ++i) if (_dry(items, i, i + 1) && !_dry(items, 0, i + 1)) revert BadConfig(); or equivalently skip waiting items and keep walking: build the prefix from the items that pass alone and refuse any item that passes alone but fails after that prefix. Cost: at most MAX_BATCH (8) extra single-item dry runs at propose and at apply.","line":417,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {ImdDepth} from \"src/feeds/ImdDepth.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract PbStub {}\n\ncontract PbJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\n/// Wave 2's BATCH dry run (Parameters.checkBatch) promises: \"if item i fails there but would apply alone, an earlier item\n/// broke it: refused (BadConfig)\". The check walks prefixes only up to the FIRST failing item and judges that one alone.\n/// When the first failing item is one that legitimately waits on state (a line raise before its depth), every later item\n/// is never checked: a pair broken by an earlier item (two ADD_ILK of one type) passes propose and the batch can only ever\n/// fail at apply, holding its slot and every kind it locks until the Safe cancels (the exact wave-2 defect).\ncontract ProofBatchCheckStopsAtFirstWaitingItemTest is Test {\n    Parameters params;\n    ImdDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant ETH = \"ETH\";\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new PbStub());\n        params.wire(ledger, address(new PbStub()));\n        _add(ETH, 1_000_000e18);\n        _add(SIMD, 0);\n        // The depth rule on SIMD with a measured depth that reads 0 (no sampler, nothing poked): a SIMD line raise waits.\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new ImdDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new PbStub());\n        c.join = address(new PbJoin(c.token, ledger));\n        c.median = IFeed(address(new PbStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function _add(bytes32 ilk, uint128 line) internal {\n        params.addGenesisIlk(ilk, _cfg(), _risk(line));\n    }\n\n    /// Control (the wave-2 test): the broken pair alone is refused at propose.\n    function test_control_brokenPairAloneIsRefused() public {\n        bytes[] memory items = new bytes[](2);\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[0], items[1]) = (add, add);\n        uint8 b = params.BATCH();\n        vm.prank(gov);\n        vm.expectRevert(ParametersBase.BadConfig.selector);\n        params.propose(abi.encode(b, items));\n    }\n\n    /// The same broken pair behind one item that waits on state passes propose, then can only fail at apply.\n    function test_brokenPairBehindWaitingItemIsNotRefused() public {\n        bytes[] memory items = new bytes[](3);\n        items[0] = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18)); // waits on depth (fails alone at apply: DepthRuleFails)\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[1], items[2]) = (add, add); // the second fails ONLY because of the first: wave 2 says refused (BadConfig)\n        uint8 b = params.BATCH();\n        bytes memory payload = abi.encode(b, items);\n        vm.prank(gov);\n        vm.expectRevert(ParametersBase.BadConfig.selector);\n        params.propose(payload);\n    }\n\n    /// What follows on this commit: the batch is queued, locks SET_RISK, ADD_ILK and BATCH for 48h + 14d, and even once the\n    /// waiting item's state arrives it reverts at apply (IlkExists) until the Safe cancels it.\n    function test_queuedBatchCanOnlyFailAtApply() public {\n        bytes[] memory items = new bytes[](3);\n        items[0] = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18));\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[1], items[2]) = (add, add);\n        uint8 b = params.BATCH();\n        bytes memory payload = abi.encode(b, items);\n        vm.prank(gov);\n        (bool ok,) = address(params).call(abi.encodeCall(params.propose, (payload)));\n        if (!ok) return; // fixed: refused at propose, nothing to show\n        (, uint256 eta) = params.pendingOf(b);\n        assertGt(eta, 0, \"queued\");\n        assertEq(params.locked(), (1 << b) | (1 << params.SET_RISK()) | (1 << params.ADD_ILK()), \"three kinds locked\");\n        vm.warp(block.timestamp + 48 hours);\n        // Whether or not item 0's depth has arrived, item 2 can never apply: the batch reverts (IlkExists after item 1).\n        vm.expectRevert();\n        params.applyPending(b);\n        (, eta) = params.pendingOf(b);\n        assertGt(eta, 0, \"the batch still holds its slot after a failed apply\");\n    }\n}","reproduction":"State: Parameters sealed with SIMD as the depth type (setGenesisDepthRule(SIMD, 1e18, 0, 0, 0)) and an ImdDepth with no samplers (measured depth 0). Governor proposes BATCH [SET_RISK(SIMD, line 1000e18), ADD_ILK(WSTETH), ADD_ILK(WSTETH)]. Expected (wave 2 contract, and the behaviour of BATCH [ADD_ILK(WSTETH), ADD_ILK(WSTETH)] which IS refused): propose reverts BadConfig because item 2 fails only because of item 1. Actual: propose succeeds (eta set, locked = BATCH|SET_RISK|ADD_ILK); 48 h later applyPending(BATCH) reverts (IlkExists on item 2) whatever the depth, and the slot stays held. Test: test_brokenPairBehindWaitingItemIsNotRefused fails on this commit ('next call did not revert as expected'); test_control_brokenPairAloneIsRefused passes; test_queuedBatchCanOnlyFailAtApply shows the stuck slot. Run (import-closure scratch project, same foundry.toml settings, solc 0.8.26 via_ir): forge test --match-path 'test/unit/ProofBatchCheckStopsAtFirstWaitingItem.t.sol' -> 2 passed, 1 failed.","severity":"low","snippet":"        uint256 n = 1;\n        while (_dry(items, 0, n)) ++n;\n        if (_dry(items, n - 1, n)) revert BadConfig();","title":"BATCH dry run (checkBatch) stops at the first item that waits on state, so a later item broken by an earlier one still passes propose and can only fail at apply"},{"citation":"resolved","description":"DeployBase's rule: 'one with code but other wiring stops the run (Mismatch) for a person to decide', and the sleeves follow it (StageGenesis.sol:231 'Parameters points at other sleeves'). The depth step does not: when the recorded d.imdDepth has code and the right params(), but Parameters already points at ANOTHER ImdDepth (a record edited or lost between a stopped run and its resume, or a run resumed from an older record), the step silently calls setGenesisImdDepth again, which overwrites `imdDepth` (Parameters.sol:116-123 checks only code and params(), never that the slot is empty) and lists the config's samplers on the new instance. The ImdDepth that was measuring (with the hourly lows the keeper may already have poked for days) is orphaned without a Mismatch, and the depth rule restarts from 0 for 6 days (ImdDepth reads 0 until 6 recorded days exist), delaying the beta's day-7 sIMD line. Pre-seal and deployer-only, so no funds: an operational defect in the wave-2 resume fix. Not reachable from a clean single-run BetaConfig deploy; reachable on any resume whose Deployed record disagrees with the chain. Smallest fix: in Parameters.setGenesisImdDepth, `if (address(imdDepth) != address(0)) revert BadConfig();` and in _stageDepth, `else if (address(d.params.imdDepth()) != address(0)) revert Mismatch(\"Parameters points at another ImdDepth\");` before the setGenesisImdDepth branch.","line":305,"path":"script/deploy/StageGenesis.sol","reproduction":"Run 1: _stageDepth(cfg, d) deploys ImdDepth A and samplers, calls params.setGenesisImdDepth(A, list); the run stops before the seal. Resume with a record whose d.imdDepth is zero (or another ImdDepth B with params()==params): the step deploys/keeps B, then since params.imdDepth() (A) != B it calls setGenesisImdDepth(B, list) and succeeds. Expected: revert Mismatch (Parameters is wired to A). Actual: params.imdDepth() == B, A and its recorded lows are orphaned, the run goes on to seal. (Could not be compiled here: StageGenesis pulls the whole deploy closure, which exceeds this machine's memory under solc via_ir; the AuditW2ResumeSamplers harness RsStage.depthStep reproduces it with d.imdDepth = ImdDepth(address(0)) on the second call.)","severity":"low","snippet":"        if (address(d.params.imdDepth()) != address(d.imdDepth)) {\n            g = gasleft();\n            d.params.setGenesisImdDepth(address(d.imdDepth), list);","title":"Resumed stage 4 re-points Parameters at a different ImdDepth instead of stopping with Mismatch (setGenesisImdDepth has no already-set guard; the depth step never compares params.imdDepth with the reco"}],"hash":"df6edb4264f2cf0349da2899847442b53e7cb637d09ed7b1ebc62ba015fa72b8","nodeId":"d51a6c3d-f2d7-4b13-90d1-f66a1561cebf","outcome":"completed","summary":"Findings file written and verified against the tree. I'm now writing the report.\n\n## Findings\n\n**1. Low. `checkBatch` stops at the first item that waits on state, so a later item broken by an earlier one still passes propose** (`src/Parameters.sol:417`).\n\n```solidity\n        uint256 n = 1;\n        while (_dry(items, 0, n)) ++n;\n        if (_dry(items, n - 1, n)) revert BadConfig();\n```\n\nThe wave-2 contract (lines 409-413, README) says an item that fails only because of an earlier item is refused. The loop walks prefixes until the first failing one and judges that item alone. If that item is a legitimate \"waiting on state\" item, nothing after it is ever dry-run. Call sequence: governor proposes BATCH [SET_RISK(SIMD, line 1000e18) with measured depth 0, ADD_ILK(WSTETH), ADD_ILK(WSTETH)]. Expected: BadConfig at propose, as the two-item batch gets. Actual: queued, locks BATCH, SET_RISK and ADD_ILK, reverts IlkExists at apply whatever the depth, slot held until the Safe cancels. Reachable with BetaConfig: the day-7 batch opens the sIMD line (waits on depth) alongside other items. Smallest fix: after the loop, dry-run each remaining item alone and refuse any that passes alone but fails after the prefix (at most 8 extra single-item runs). Proof test (fails on this commit, run below):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {ImdDepth} from \"src/feeds/ImdDepth.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract PbStub {}\n\ncontract PbJoin {\n    address public token;\n    address public ledger;\n    constructor(address t, address l) { (token, ledger) = (t, l); }\n}\n\ncontract ProofBatchCheckStopsAtFirstWaitingItemTest is Test {\n    Parameters params;\n    ImdDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant ETH = \"ETH\";\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new PbStub());\n        params.wire(ledger, address(new PbStub()));\n        _add(ETH, 1_000_000e18);\n        _add(SIMD, 0);\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new ImdDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.5e18, chop: 0.1e18, cut: 0.1e18, chip: 0.01e18, rateFloor: 0.005e18, yieldFee: 0, skew: 0.02e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 4, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new PbStub());\n        c.join = address(new PbJoin(c.token, ledger));\n        c.median = IFeed(address(new PbStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    function _add(bytes32 ilk, uint128 line) internal { params.addGenesisIlk(ilk, _cfg(), _risk(line)); }\n\n    function test_control_brokenPairAloneIsRefused() public {\n        bytes[] memory items = new bytes[](2);\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[0], items[1]) = (add, add);\n        uint8 b = params.BATCH();\n        vm.prank(gov);\n        vm.expectRevert(ParametersBase.BadConfig.selector);\n        params.propose(abi.encode(b, items));\n    }\n\n    function test_brokenPairBehindWaitingItemIsNotRefused() public {\n        bytes[] memory items = new bytes[](3);\n        items[0] = abi.encode(params.SET_RISK(), SIMD, _risk(1_000e18)); // waits on depth\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[1], items[2]) = (add, add); // the second fails ONLY because of the first\n      ","treeHash":null,"usage":{"cachedInputTokens":1716478,"cost":{"source":"runtime","usdMicros":6895985},"inputTokens":386,"model":"claude-fable-5-1","outputTokens":47409,"runtime":"claude","turns":46,"wallClockMs":1428112}},{"artifacts":[],"attempt":1,"bundleHash":null,"device":"d68ba89c0b30801c","findings":[{"citation":"resolved","description":"README ('What changed since the second public audit'): 'BATCH dry-run at propose ... an item that fails only because of an earlier item in the same batch is refused at propose'. Parameters.checkBatch finds the FIRST prefix [0,n) that fails and classifies item n-1 alone: if it fails alone it is 'waiting on state' and checkBatch returns. Nothing after item n-1 is ever dry-run in order. So a batch [SET_RISK(sIMD line raise, waits on depth), ADD_ILK X, ADD_ILK X] passes propose (the exact wave-2 case, two ADD_ILK of one type, hidden behind a waiting item), holds the BATCH slot and the locks of SET_RISK and ADD_ILK for up to 16 days, and can never apply: once depth arrives, applyPending re-validates and reverts BadConfig (the duplicate is then found), and if the batch is applied with no depth it reverts DepthRuleFails. Reachable with BetaConfig: sIMD is the depth-gated type with line 0 and measured depth 0 until the samplers fill (the day-7 batch shape). Impact: a governance act the Safe believed queued never lands and blocks every kind it locks until cancel(); no funds at risk (same severity class as the wave-2 low). Second mechanism, same function: when the full dry run fails, the prefix walk re-applies items 1..n in every prefix, O(n^2) item applications, measured under solc: BATCH of 8 ADD_ILK that passes = 6,491,104 gas at propose; 7 ADD_ILK + 1 waiting item = 17,696,111 gas (42 ADD_ILK dry applications, each creating 13 storage slots). Under the Glamsterdam figures given (new slot 110,020) that shape adds about 42 x 13 x 87,920 = 48M gas and exceeds a 60M block, so a legitimate 'waiting on state' batch of several ADD_ILK could not be proposed. Smallest fix: make dryRun report WHERE it stopped (self-call each item and revert DryRunStopped(i)) and give it a skip mask: checkBatch runs one dry run; on a stop at i it dry-runs item i alone, refuses (BadConfig) if it passes alone, otherwise marks i skipped and re-runs from the start with the mask; a batch is then applied at most (waiting items + 1) times and every item after a waiting one is still checked in order.","line":417,"path":"src/Parameters.sol","proof":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"src/Parameters.sol\";\nimport {ParametersBase} from \"src/ParametersBase.sol\";\nimport {IFeed} from \"src/interfaces/IFeed.sol\";\n\ncontract PbStub {}\n\ncontract PbJoin {\n    address public token;\n    address public ledger;\n\n    constructor(address t, address l) {\n        (token, ledger) = (t, l);\n    }\n}\n\n/// A measured depth the test moves (on chain it moves hourly: DepthSampler + ImdDepth.poke).\ncontract PbDepth {\n    address public params;\n    uint256 public depth;\n\n    constructor(address p) {\n        params = p;\n    }\n\n    function set(uint256 d) external {\n        depth = d;\n    }\n\n    function addSampler(address) external {}\n\n    function canAdd(address) external pure returns (bool) {\n        return true;\n    }\n}\n\n/// Wave 3 (README): \"BATCH proposals are dry-run at propose. An item that fails only because of an earlier item in the\n/// same batch is refused at propose.\" `Parameters.checkBatch` stops its in-order dry run at the FIRST item that fails\n/// alone (one waiting on state) and never dry-runs the items after it in sequence. So a batch whose waiting item comes\n/// before a duplicate (two ADD_ILK of one type: the wave-2 case itself) still passes propose and can never apply, not even\n/// once the state arrives: it holds the BATCH slot and the locks of every kind it carries until the Safe cancels.\ncontract ProofBatchBehindWaitingItemTest is Test {\n    Parameters params;\n    PbDepth depth;\n    address gov = makeAddr(\"gov\");\n    address ledger;\n    bytes32 constant SIMD = \"SIMD\";\n\n    function setUp() public {\n        params = new Parameters(gov, address(this));\n        ledger = address(new PbStub());\n        params.wire(ledger, address(new PbStub()));\n        params.addGenesisIlk(SIMD, _cfg(), _risk(0));\n        // The beta's rule: sIMD is the depth-gated type, line 0 at genesis, measured depth 0 until the samplers fill.\n        params.setGenesisDepthRule(SIMD, 1e18, 0, 0, 0);\n        depth = new PbDepth(address(params));\n        params.setGenesisImdDepth(address(depth), new address[](0));\n        params.seal();\n    }\n\n    function _risk(uint128 line) internal pure returns (ParametersBase.Risk memory) {\n        return ParametersBase.Risk({\n            mat: 1.7e18, chop: 0.2e18, cut: 0.04e18, chip: 0, rateFloor: 0.005e18, yieldFee: 0, skew: 0.05e18,\n            pegFloor: 0, line: line, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 2, redeemCap: 0\n        });\n    }\n\n    function _cfg() internal returns (ParametersBase.Config memory c) {\n        c.token = address(new PbStub());\n        c.join = address(new PbJoin(c.token, ledger));\n        c.median = IFeed(address(new PbStub()));\n        c.spot = c.median;\n        c.redeemable = true;\n    }\n\n    /// The day-7 shape: a line raise that waits on depth, followed by two ADD_ILK of the same new type.\n    function _batch() internal returns (bytes memory) {\n        bytes[] memory items = new bytes[](3);\n        items[0] = abi.encode(params.SET_RISK(), SIMD, _risk(10_000e18)); // fails alone now: DepthRuleFails (depth 0)\n        bytes memory add = abi.encode(params.ADD_ILK(), bytes32(\"WSTETH\"), _cfg(), _risk(1_000e18));\n        (items[1], items[2]) = (add, add); // the second fails ONLY because of the first: wave 2's own case\n        return abi.encode(params.BATCH(), items);\n    }\n\n    /// Expected (README, wave 2 fix): refused at propose with BadConfig, as the same two ADD_ILK are without the waiting\n    /// item in front (AuditW2ProposeAtApply.test_batchDuplicateAddIlkRefusedAtPropose). Actual: accepted.\n    function test_duplicateAddIlkBehindAWaitingItemIsRefusedAtPropose() public {\n        bytes memory p = _batch();\n        vm.prank(gov);\n        vm.expectRevert(ParametersBase.BadConfig.selector);\n        params.propose(p);\n    }\n\n    /// The accepted batch can never apply: once depth arrives and the waiting item passes, the duplicate reverts IlkExists,\n    /// and the BATCH slot (locking SET_RISK and ADD_ILK) stays until the Safe cancels. Passes once propose refuses it.\n    function test_acceptedBatchNeverApplies() public {\n        bytes memory p = _batch();\n        vm.prank(gov);\n        (bool ok,) = address(params).call(abi.encodeCall(params.propose, (p)));\n        if (!ok) return; // fixed: refused at propose\n        vm.warp(block.timestamp + 48 hours);\n        depth.set(1_000_000e18); // the state the first item waited on has arrived\n        params.applyPending(params.BATCH()); // expected to apply; actual: IlkExists\n    }\n}","reproduction":"State: Parameters sealed, SIMD registered with line 0, setGenesisDepthRule(SIMD, 1e18, 0, 0, 0), ImdDepth.depth() == 0 (the beta before day 7). Input: governor calls propose(abi.encode(BATCH, [abi.encode(SET_RISK, SIMD, risk with line 10_000e18), abi.encode(ADD_ILK, 'WSTETH', cfg, risk), the same ADD_ILK again])). Expected: revert BadConfig (as AuditW2ProposeAtApply.test_batchDuplicateAddIlkRefusedAtPropose shows for the two ADD_ILK without the waiting item in front). Actual: propose succeeds (pendingOf(BATCH) non-empty). Then warp 48h, set depth to 1,000,000e18 and call applyPending(BATCH): expected to apply; actual revert BadConfig. Run: forge test --match-path test/scratch/ProofBatchBehindWaitingItem.t.sol -> both tests FAIL on c64ecee ('next call did not revert as expected' and 'BadConfig()').","severity":"low","snippet":"        uint256 n = 1;\n        while (_dry(items, 0, n)) ++n;\n        if (_dry(items, n - 1, n)) revert BadConfig();","title":"BATCH dry run stops at the first item that waits on state: items after it are never checked in sequence (wave-2 duplicate case re-opens behind a waiting item), and the prefix walk is O(n^2)"},{"citation":"resolved","description":"ParametersRules is only ever delegate-called through validateKind/applyKind, yet because ParametersBase inherits GovernedByKind its runtime (24,411 bytes measured from out/ParametersRules.sol, 165 bytes under the 24,576 limit) includes propose(bytes), cancel(), cancel(uint8), applyPending(), applyPending(uint8), pending(), pendingEta(), pendingOf(uint8), locked(), pendingKinds(), governor() and every public constant and storage getter of ParametersBase (111 external selectors in the artifact; 2 are used). Its constructor also receives the real governor, so the governor can call propose/applyPending on the Rules contract's OWN storage (harmless: Parameters never reads it, token/ledger are zero there). Consequence: there is no room for any correction to validation (the dry-run fix above included) without first making room, and Parameters' init code, which embeds the Rules creation code, is 762 bytes under EIP-3860. Suggested change: move the storage layout and the shared internal helpers into a ParametersStorage base with no public getters and no GovernedByKind functions, inherit GovernedByKind only in Parameters, and deploy ParametersRules separately (constructor argument checked by DeployBase extcodehash) so the two limits are no longer coupled.","line":13,"path":"src/ParametersRules.sol","reproduction":"forge build (solc 0.8.26, via_ir, runs 200) then read out/ParametersRules.sol/ParametersRules.json: deployedBytecode 24,411 bytes (margin 165), methodIdentifiers lists propose(bytes), applyPending(uint8), cancel(uint8), pending(), pendingOf(uint8) and 57 constant getters; out/Parameters.sol/Parameters.json bytecode 48,390 bytes (margin 762 under 49,152). Expected: a delegatecall-only module exposes validateKind/applyKind only; actual: 111 selectors.","severity":"info","snippet":"contract ParametersRules is ParametersBase {","title":"ParametersRules (165 bytes under EIP-170) carries GovernedByKind's whole governance surface and 100+ getters that are unreachable through its only entry points"}],"hash":"e394b5db754319527db4e5c7acadf836296eaa20ae0b6d3091883c815bd83950","nodeId":"5459b106-6a0a-4824-828c-19e971b11059","outcome":"completed","summary":"Findings file written with two entries, scratch tests deleted, and the tree is back to the pinned state (only the ignored build directories and the findings file are new). Here is the review.\n\n## Outcome\n\nOne low finding with a failing proof, one info finding on size, and answers to the five questions with measured figures. The panel's tests all pass under solc 0.8.26 via IR on Foundry 1.8.3 (solar needs 1.9 and is not on this machine). The public wave-2 submissions could not be fetched: the API answered HTTP 400 `{\"error\":\"invalid_job_id\"}` for all three ids, so I re-ran the repository's adapted proofs and re-derived each original from its description.\n\n**Finding 1 (low): the BATCH dry run stops at the first item that waits on state.** `Parameters.checkBatch` at `src/Parameters.sol:417` finds the first failing prefix and classifies that one item alone. Items after it are never dry-run in order. A batch of the day-7 shape, a sIMD line raise that waits on depth followed by two ADD_ILK of the same type, passes propose, locks SET_RISK and ADD_ILK for up to 16 days, and never applies. Once depth arrives the apply-time re-validation reverts BadConfig. Reachable with BetaConfig, since sIMD has line 0 and depth 0 until the samplers fill. Same function, second mechanism: the prefix walk re-applies every item in every prefix. Smallest fix: let dryRun report where it stopped and take a skip mask, so one pass checks every item and the cost is linear in the number of waiting items.\n\nProof, written to test/scratch, run, pasted in the findings file, then deleted:\n\n```\nRan 2 tests for test/scratch/ProofBatchBehindWaitingItem.t.sol:ProofBatchBehindWaitingItemTest\n[FAIL: BadConfig()] test_acceptedBatchNeverApplies() (gas: 4051168)\n[FAIL: next call did not revert as expected] test_duplicateAddIlkBehindAWaitingItemIsRefusedAtPropose() (gas: 1995550)\nSuite result: FAILED. 0 passed; 2 failed; 0 skipped\n```\n\n**Finding 2 (info): ParametersRules carries dead governance surface.** Its runtime is 165 bytes under EIP-170 yet includes propose, cancel, applyPending, the pending views and 57 constant getters, 111 selectors of which 2 are reachable. Details and the suggested split are in the findings file.\n\n## Re-check of the wave-2 fixes (questions 1 to 3)\n\nPanel run, all green:\n\n```\nAuditW2LowerOtherImd 1 passed | AuditW1OtherImdLines 1 passed | AuditW1BatchItems 3 passed\nAuditW2ResumeSamplers 1 passed | AuditW2ProposeAtApply 2 passed | DepthRule 6 passed\nPanelParams 11 passed | CapAndSlots 18 + 1 passed | GasSlots 2 passed\n```\n\n- **Original proofs.** ADD_DEPTH_SAMPLER of a listed sampler now reverts OutOfBounds at propose through ImdDepth.canAdd, whose checks are exactly addSampler's. The duplicate ADD_ILK batch reverts BadConfig at propose. `lowerOtherImdLines` no longer exists, so the instant raise cannot happen. A resume with a changed sampler list reverts `Mismatch(\"ImdDepth samplers\")`. None of the three reproduces, except the variant in Finding 1.\n- **Q1, state and re-entry.** The dry run cannot change state: dryRun always reverts, so storage, transient storage and logs of its frame are discarded. checkBatch and dryRun accept only self-calls. The external calls inside a dry run go to governor-chosen protocol contracts that do not call back, and a callback could only reach applyPending, whose effects would be rolled back with the frame. Propose and apply differ only through state changes in between, by design, plus the shape in Finding 1 and the known 3-word RETIRE payload. The reverse also exists: a batch whose later item depends on an earlier one, such as ADD_ILK X then ADD_SLEEVE_ILK X, is refused because every item is also validated against the pre-batch state. A waiting item is still accepted, as the README states.\n- **Q1, gas.** Measured at propose under solc:\n\n| Shape | Gas |\n|---|---|\n| one ADD_ILK | 556,940 |\n| day-7 BATCH, 3 items (propose / apply) | 854,389 / 454,983 |\n| BATCH of 8 ADD_ILK that passes | 6,491,104 |\n| 7 ADD_ILK + 1 waiting","treeHash":null,"usage":{"cachedInputTokens":2848867,"cost":{"source":"runtime","usdMicros":8669651},"inputTokens":484,"model":"claude-fable-5-1","outputTokens":67276,"runtime":"claude","turns":47,"wallClockMs":1013171}}],"verification":[]}