{
 "item": "house-seats",
 "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40",
 "forge": "forge 1.8.3 (cae51ad, 2026-09-15): --use solar NOT available; compiled with solc 0.8.38 (official binary) via --use, via_ir per foundry.toml",
 "verdict": "findings",
 "findings": [
  {
   "id": "HS-1",
   "severity": "low",
   "title": "Auction clock counts a SeatFeed==0 stretch that starts and ends between two ticks inside the old median window as priced time: the sale reaches its 70% floor while no take could settle",
   "property": "P2",
   "claim": "P2 (README:1313 'also stopped while SeatFeed reads 0')",
   "files": [
    "src/house/seats/SeatJoin.sol:496",
    "src/house/seats/SeatJoin.sol:501",
    "src/house/seats/SeatJoin.sol:512",
    "src/house/seats/SeatJoin.sol:526",
    "src/house/feeds/SeatFeed.sol:144",
    "src/house/feeds/SeatFeed.sol:285"
   ],
   "sequence": "Auction opens at T0 (figure 1). T0+1h: a median attestation with figure 0 lands and is poked (1->0 passes the 20% cap): SeatFeed reads 0, Pricer.priced=false, Liquidator.settle reverts NotPriced. Nobody ticks. T0+6h: an attestation with figure 1 (0->1 passes the +25%+1 cap) lands. _elapsed: v!=0 now, zeroAtTick false, opened(T0+6h) <= attestedAt+26h, so [lastTick, now) is counted whole. A taker relays/waits for the lifting attestation and takes at the floor in the same block.",
   "expected": "elapsed <= priced seconds (3600 s); price > 0.7 x start",
   "actual": "elapsed 21600 s; price 2100e18 = 70% floor of 3000e18 after only 1 h in which a take could settle",
   "reachableAtDeploy": true,
   "fix": "Slow-never-fast for zeros: when a newer median attestation landed since lastTick (newAt != a.attestedAt), count priced time only from `opened` (the newest arrival) on, not from lastTick through the old window; or have the median leaf's accept path call a SeatFeed/SeatJoin checkpoint so every 0/non-0 transition is recorded on chain. README:1313 should state the residual (today only the SeatJoin NatSpec at :494 does, conditional on the keeper ticking).",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {SeatJoin} from \"src/house/seats/SeatJoin.sol\";\nimport {IImdAgentAdapter} from \"src/house/seats/SeatAccount.sol\";\nimport {SeatFeed} from \"src/house/feeds/SeatFeed.sol\";\nimport {IFeed} from \"src/house/interfaces/IFeed.sol\";\nimport {Leaf, P, L} from \"test/house/unit/AuditW3SeatClockUnpriced.t.sol\";\n\n/// P2: the clock runs only while a take can settle (SeatFeed != 0, legs fresh). A zero stretch that starts and ends\n/// between two ticks, inside the old attestation's life, is counted as priced time (nobody ticks: no keeper).\ncontract HouseSeatsClockZero is Test {\n    uint256 constant T0 = 1_800_000_000;\n    Leaf median;\n    Leaf spot;\n    Leaf eth;\n    SeatFeed feed;\n    SeatJoin join;\n\n    function setUp() public {\n        vm.etch(address(0x44), hex\"600160005260206000f3\");\n        vm.warp(T0);\n        median = new Leaf(26 hours, 1);\n        spot = new Leaf(26 hours, 1);\n        eth = new Leaf(1 hours + 10 minutes, 0);\n        median.set(1e18, uint64(T0), 1);\n        spot.set(1e18, uint64(T0), 1);\n        eth.set(3000e18, uint64(T0), 0);\n        feed = new SeatFeed(median, spot, eth);\n        P p = new P();\n        p.setMedian(IFeed(address(feed)));\n        join = new SeatJoin(\"SEAT\", IERC721(address(0x55)), IImdAgentAdapter(address(0x66)), address(this), 25, 3);\n        join.wire(address(new L(address(p))));\n        vm.prank(address(0x11));\n        join.open(1, address(0x22));\n    }\n\nfunction testFuzz_zeroStretchBetweenTicksCounted(uint256 zeroAt, uint256 zeroLen) public {\n        zeroAt = bound(zeroAt, 1, 12);\n        zeroLen = bound(zeroLen, 1, 12);\n        uint256 priced;\n        for (uint256 h = 1; h <= zeroAt + zeroLen; ++h) {\n            uint256 t = T0 + h * 1 hours;\n            vm.warp(t);\n            eth.set(3000e18, uint64(t), 0);\n            (uint256 before,) = feed.latestValue();\n            if (before != 0) priced += 1 hours; // the hour that just ended was priced\n            if (h == zeroAt) median.set(1e18, uint64(t), 0);\n            if (h == zeroAt + zeroLen) median.set(1e18, uint64(t), 1);\n            feed.poke();\n        }\n        (uint256 v,) = feed.latestValue();\n        assertGt(v, 0, \"priced again\");\n        emit log_named_uint(\"priced seconds (truth)\", priced);\n        emit log_named_uint(\"elapsed counted\", join.elapsed(1));\n        emit log_named_uint(\"price (start 3000e18)\", join.price(1));\n        assertLe(join.elapsed(1), priced, \"the clock counted the zero stretch as priced time\");\n    }\n}",
    "ran": "forge 1.8.3 (cae51ad), solc 0.8.38 binary (binaries.soliditylang.org) via --use; forge test --use solc-0.8.38 --match-path test/scratch/<file> --match-contract HouseSeats --fuzz-runs 512",
    "result": "[FAIL: the clock counted the zero stretch as priced time: 21600 > 3600; args=[zeroAt->1, zeroLen->5]] testFuzz_zeroStretchBetweenTicksCounted. Logs: priced seconds (truth): 3600; elapsed counted: 21600; price (start 3000e18): 2100000000000000000000"
   }
  },
  {
   "id": "HS-2",
   "severity": "low",
   "title": "SeatFeed fall cap is bypassed after an unpoked rise: the next attestation is capped against the older recorded value, so the accepted median can fall 50% (bounded only by the leaf's own cap) in one new attestation",
   "property": "C3",
   "claim": "C3; SeatFeed NatSpec :57-58 'so an unpoked fall is capped harder (the leg falls slower), never looser'",
   "files": [
    "src/house/feeds/SeatFeed.sol:134",
    "src/house/feeds/SeatFeed.sol:138",
    "src/house/feeds/SeatFeed.sol:179",
    "src/house/seats/SeatJoin.sol:410"
   ],
   "sequence": "Recorded state raw=base=1e18. Block n: attestation A1=2e18 (honest rally or wash pump within the leaf cap) is relayed; acceptedMedian=2e18 (rises pass 1:1), positions are valued/opened at it. Block n+1, ordered by a builder ahead of the keeper's poke: A2=1e18 relayed. acceptedMedian = _capped(A2, _capped(c.raw=1e18, c.base)) = 1e18.",
   "expected": ">= 0.8 x 2e18 = 1.6e18 (20% per new attestation)",
   "actual": "1e18 (-50% in one new attestation); liquidations and the auction start (medianUsd) read it",
   "reachableAtDeploy": true,
   "fix": "Record every attestation atomically: the seat median leaf's accept path calls SeatFeed.poke() (or SeatFeed stores the live accepted value whenever it is read in a state-changing path: Liquidator/Ledger/SeatJoin.open), or cap against max(capped(c.raw,c.base), the live accepted value at the time the newer attestation replaced it) by having the leaf expose the previous value.",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {Test} from \"forge-std/Test.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {SeatJoin} from \"src/house/seats/SeatJoin.sol\";\nimport {IImdAgentAdapter} from \"src/house/seats/SeatAccount.sol\";\nimport {SeatFeed} from \"src/house/feeds/SeatFeed.sol\";\nimport {IFeed} from \"src/house/interfaces/IFeed.sol\";\nimport {Leaf, P, L} from \"test/house/unit/AuditW3SeatClockUnpriced.t.sol\";\n\n/// P2: the clock runs only while a take can settle (SeatFeed != 0, legs fresh). A zero stretch that starts and ends\n/// between two ticks, inside the old attestation's life, is counted as priced time (nobody ticks: no keeper).\ncontract HouseSeatsFeedCap is Test {\n    uint256 constant T0 = 1_800_000_000;\n    Leaf median;\n    Leaf spot;\n    Leaf eth;\n    SeatFeed feed;\n\n    function setUp() public {\n        vm.warp(T0);\n        median = new Leaf(26 hours, 100);\n        spot = new Leaf(26 hours, 100);\n        eth = new Leaf(1 hours + 10 minutes, 0);\n        median.set(1e18, uint64(T0), 100);\n        spot.set(1e18, uint64(T0), 100);\n        eth.set(3000e18, uint64(T0), 0);\n        feed = new SeatFeed(median, spot, eth);\n    }\n\nfunction test_unpokedRiseThenFallBypassesCap() public {\n        vm.warp(T0 + 1);\n        median.set(2e18, uint64(T0 + 1), 100); // honest rally (or wash pump within the leaf cap), not yet poked\n        uint256 a1 = feed.acceptedMedian();\n        assertEq(a1, 2e18);\n        vm.warp(T0 + 2); // next block, builder orders it ahead of the keeper's poke\n        median.set(1e18, uint64(T0 + 2), 100);\n        uint256 a2 = feed.acceptedMedian();\n        emit log_named_uint(\"accepted after A1\", a1);\n        emit log_named_uint(\"accepted after A2\", a2);\n        assertGe(a2, a1 * 8000 / 10_000, \"accepted median fell more than 20% in one new attestation\");\n    }\n}",
    "ran": "forge 1.8.3 (cae51ad), solc 0.8.38 binary (binaries.soliditylang.org) via --use; forge test --use solc-0.8.38 --match-path test/scratch/<file> --match-contract HouseSeats --fuzz-runs 512",
    "result": "[FAIL: accepted median fell more than 20% in one new attestation: 1000000000000000000 < 1600000000000000000] test_unpokedRiseThenFallBypassesCap() (gas: 124983). Logs: accepted after A1: 2e18; accepted after A2: 1e18"
   }
  },
  {
   "id": "HS-3",
   "severity": "low",
   "title": "A reward the seat's account earned under the borrower but not yet claimed reaches the auction buyer: take, re-deposit the same tokenId (same deterministic account), claim; credited to the buyer",
   "property": "C4/P3",
   "claim": "C4",
   "files": [
    "src/house/seats/SeatJoin.sol:566",
    "src/house/seats/SeatJoin.sol:288",
    "src/house/seats/SeatJoin.sol:313",
    "src/house/seats/SeatJoin.sol:689",
    "src/house/seats/SeatAccount.sol:186"
   ],
   "sequence": "Claim rule for the distributor set (SET_SEAT_CLAIM). alice pledges seat 1; the distributor owes 100 IMD to accountOf(1). Position unhealthy, liquidate opens the auction. bob in one bundle: take (NFT to bob, holderOf deleted, lastHolder=alice), deposit(1) (same Clones address, holderOf=bob), SeatAccount.claim(dist, claim(acct,IMD,100), [IMD]) -> onRewards credits holderOf=bob. Same with takeFloor (Treasury becomes holder) and the Treasury's later transfer.",
   "expected": "owed[1][IMD][alice] == 100e18 (earned during her tenure)",
   "actual": "owed[1][IMD][alice] == 0; owed[1][IMD][bob] == 100e18",
   "reachableAtDeploy": false,
   "fix": "Make the buyer unable to inherit pre-sale arrivals: on deposit of a tokenId whose account already exists, keep crediting lastHolder for a claim window (e.g. arrivals reported before the new holder's first `sync` after `depositedAt + window`), or key accounts by (tokenId, custody epoch) so a re-deposit gets a fresh account; and document it in README Known issues (today only the SeatJoin NatSpec :687-688 says credit follows the reporter's moment). Not reachable until governance sets a claim rule (none at genesis).",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SeatsTest} from \"test/house/unit/Seats.t.sol\";\nimport {MockDistributor} from \"test/house/utils/SeatMocks.sol\";\nimport {SeatAccount} from \"src/house/seats/SeatAccount.sol\";\nimport {SeatJoin} from \"src/house/seats/SeatJoin.sol\";\nimport {Adjust} from \"src/house/interfaces/IPositions.sol\";\nimport {_pid} from \"test/house/utils/Pid.sol\";\n\ncontract HouseSeatsRoutes is SeatsTest {\nfunction test_C4_pendingClaimReachesBuyer() public {\n        _allow(address(dist), MockDistributor.claim.selector, 1);\n        _pledge(alice, 1, 1_500e18);\n        address acct = seatJoin.accountOf(1);\n        // 100 IMD accrue to the account during alice's tenure (the distributor owes the account; nobody claimed yet).\n        _crash();\n        liquidator.liquidate(_pid(SEAT, alice));\n        _cash(bob, 5_000e18);\n        vm.startPrank(bob);\n        usd.approve(address(seatJoin), type(uint256).max);\n        seatJoin.take(_pid(SEAT, alice), type(uint256).max); // one bundle: take, deposit, claim\n        seatJoin.deposit(1);\n        address[] memory toks = new address[](1);\n        toks[0] = address(reward);\n        SeatAccount(acct).claim(address(dist), abi.encodeCall(MockDistributor.claim, (acct, address(reward), 100e18)), toks, address(0), 0);\n        vm.stopPrank();\n        emit log_named_uint(\"owed to bob (buyer)\", seatJoin.owed(1, address(reward), bob));\n        emit log_named_uint(\"owed to alice (earner)\", seatJoin.owed(1, address(reward), alice));\n        assertEq(seatJoin.owed(1, address(reward), alice), 100e18, \"the pending claim reached the buyer\");\n    }\n}",
    "ran": "forge 1.8.3 (cae51ad), solc 0.8.38 binary (binaries.soliditylang.org) via --use; forge test --use solc-0.8.38 --match-path test/scratch/<file> --match-contract HouseSeats --fuzz-runs 512",
    "result": "[FAIL: the pending claim reached the buyer: 0 != 100000000000000000000] test_C4_pendingClaimReachesBuyer() (gas: 4378130). Logs: owed to bob (buyer): 100e18; owed to alice (earner): 0"
   }
  }
 ],
 "claims": [
  {
   "id": "C1",
   "result": "holds",
   "evidence": "Read line by line: SeatJoin.claimAllowed :680-684 (RULE_DIRECT exact target+selector; RULE_FACTORY only via factory with rule 2 and distributorOf(uint64(hint))==target!=0); setClaimRule :210 onlyParams; ParametersRules :151-156 (join wired to this Ledger, rule<=MAX_CLAIM_RULE, rule!=0 needs code at target and selector not in the 41-entry MOVES_TOKENS list, :271), apply :385-389; SeatAccount.claim :186-196 refuses nft/join targets. Existing fuzz testFuzz_W3_claimRuleRefusedIffSelectorIsListed and test_W3/G4/panelG4 pass at this commit (512 runs). Incompleteness of the denylist (a selector whose code moves tokens or takes a recipient argument) is README:588 and README:1353, as written. Revocation (rule 0) always passes."
  },
  {
   "id": "C2",
   "result": "holds",
   "evidence": "testFuzz_C2_swapNeverShrinksDelivery (512 runs, PASS): position of 1 seat + 2 unpledged seats; in the auction block alice withdraws any seat incl. the pledged one, then a second; a third refuses NoUnits; take always delivers exactly n=1 NFT, holder units == seats, pool == collateral. Units (wallet + Ledger) >= list length at all times, so take cannot deliver fewer or none; the swap of WHICH seat is README:1260 as written."
  },
  {
   "id": "C3",
   "result": "refuted",
   "evidence": "Holds when every attestation is poked (testFuzz_fallCapPokedEachAttestation, 512 runs, values 1..3e18, figures 0..399, equal-time replacements, 1-3 s spacing: PASS). Refuted when a rise is not poked before the next attestation: HS-2 (-50% in one attestation)."
  },
  {
   "id": "C4",
   "result": "refuted",
   "evidence": "HS-3: take + re-deposit + claim credits the buyer. Without a re-deposit, an arrival reported after take credits lastHolder (the borrower), as intended."
  },
  {
   "id": "C5",
   "result": "holds",
   "evidence": "ONE invariant: for every id with auctions[id].startAt!=0, elapsed(id) <= the seconds since startAt in which Pricer.quote(SEAT).priced && !Pulse.inGrace held (the condition Liquidator.settle :232-233 needs), and auctions[id] is written only by SeatJoin.open (Liquidator.bite :153), reopen :623, tick :447, cancel :610 (also Ledger.sol:331 try-cancel) and _settle :658 (take :566, takeFloor :588). HS-1 breaks it. Smallest replacement: a push clock: the median leaf's accept (and SeatFeed.poke) checkpoint a per-type cumulative priced-seconds counter, so every 0/non-0 and fresh/stale transition is on chain and the auction reads counter(now)-counter(open) instead of reconstructing windows; Pulse is address(0) for the house (StageHouse.sol:83) so the grace term is 0 at deploy."
  }
 ],
 "holds": [
  {
   "property": "P1",
   "tried": "test_P1_strangerRoutesRefused (PASS): stranger withdraw NotHolder, take without auction reverts, governor rescue of the held seat NotStray, take after the price heals reverts (settle -> Healthy). Writers of holderOf/_seats/NFT custody grepped in src/ and script/: deposit, withdraw, take, takeFloor(_assign), transfer (Treasury only), onPositionTransfer (Ledger only, Ledger.sol:197), rescue (strays only, :384), SeatAccount.release/rescue onlyJoin; SeatAccount.claim cannot target the NFT. writeOff (LedgerSettlement.sol:193) needs IStockCustody.worthless(), which SeatJoin lacks (reverts), harvest (LedgerBase.sol:439) needs a yieldRate the auction type refuses (test_auctionTypeRejectsYieldRate). Deployer: wire() one-shot (AlreadyWired)."
  },
  {
   "property": "P2",
   "tried": "Finding HS-1. Otherwise existing AuditW1/W2/W3 clock property fuzzers pass; Pricer.priced == SeatFeed!=0 && !SeatFeed.isStale (Pricer.sol:87) matches the reconstruction's two legs; the house Ledger has no Pulse (StageHouse.sol:78,83) so settle's SequencerGrace cannot hold a take while the clock runs at deploy."
  },
  {
   "property": "P3",
   "tried": "Holds against a hostile/denylisted caller for credit routing: collect(tokenId, token, who) pays only owed[..][who] to who (fee to Treasury); a blocklisted holder's credit waits (revert keeps it). Claim calldata is caller-chosen for an allowlisted selector: a target that takes a recipient is the governance review duty of README:588. Redirection via custody change is HS-3."
  },
  {
   "property": "P4",
   "tried": "testFuzz_P4_starvedCollectKeepsCredit (512 runs, gas 20k..1.2M, PASS): either both legs paid (90/10) or the whole collect reverts with owed, account balance and reported intact; send reverts SendFailed on OOG inside SEND_GAS (63/64 rule), so a starved send cannot lose the claim. test_collectFitsAnExpensiveTransfer passes; 1,000,000 > the 110,020 Glamsterdam first-slot figure the code cites (SeatAccount.sol:72-76)."
  }
 ],
 "notRun": [
  "No [fork]/[data] claims in this sheet: none run (NOT RUN, no RPC used).",
  "Live-config values (median leaf maxAge, relay cadence, the keeper's tick schedule) not read on chain; tests use the beta values in the existing suite (26 h leaf life, 1h10m ETH/USD)."
 ]
}