{
 "item": "stock-oracle-s-session",
 "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40",
 "forge": "1.9.0 (6056c58), --use solar; tests compiled with --match-path test/scratch/SessionAudit.t.sol",
 "verdict": "findings",
 "findings": [
  {
   "id": "SOS-1",
   "severity": "low",
   "title": "SESSION_ROUNDS markets (CRCL, MSTR) have no heartbeat bound: after a gap past JUMP, a tape printing one round per session never prices, so liquidations wait indefinitely (F4's 'up to the 24 h heartbeat' does not hold)",
   "property": "F4 / README:809-810 (a real move past JUMP stays unpriced until a round within JUMP of it, 'liquidations wait up to the 24 h heartbeat of open-market time')",
   "claim": "F4",
   "files": [
    "src/stocks/StockOracle.sol:222",
    "src/stocks/StockOracle.sol:49-51",
    "README.md:809",
    "script/DeployConfig.sol:898-899",
    "script/DeployConfig.sol:912-913"
   ],
   "sequence": "Market with sessionRounds=true (CRCL t[6], MSTR t[7] at DeployConfig.sol:912-913). Fri close rounds 100,100. Mon 09:31 a -11% gap round (past JUMP 5%: Jump). From then the feed prints only its 24 h open-market-time heartbeat, one round per session at ~09:31 (each step -0.4%, under the 0.5% deviation threshold, so no extra round). Every price() in every session reverts NotYet because round id-1 is from the previous session (t1 < today's open, StockOracle.sol:222). The SESSION_ROUNDS-off oracle on the same feed prices on Tuesday (one heartbeat later); the SESSION_ROUNDS-on one is unpriced for all 90 sessions tested while the answer goes 100 -> 89 -> 62.05 (-30.3% after the gap, past the 1 - LLTV x LIF loss line of ~29.6% quoted for 62.5% LLTV; CRCL/MSTR LLTV is 38.5%, so their line is ~56%: the same flat-ish tape needs longer, but no bound exists).",
   "expected": "F4 as written: after a gap past JUMP, a market prices again within the 24 h heartbeat on a flat tape (the round after the gap is within JUMP of it).",
   "actual": "With SESSION_ROUNDS on, two rounds in ONE regular session are required; a tape with fewer than ~0.5% move per session prints at most one round per session, so the market stays unpriced (no borrow, no liquidation) with no time bound, while not Stale (rounds keep arriving). Borrowers past the LLTV after the gap are not liquidated while the price drifts down; with enough sessions the position crosses into bad debt for the lender (capped by the market cap / hub row). The deploy comment knows SESSION_ROUNDS prices SPY only 19.9% of the session (DeployConfig.sol:899) but the README's F4 bound and the NatSpec (StockOracle.sol:49-51) state 24 h.",
   "reachableAtDeploy": "yes: sessionRounds=true for CRCL and MSTR in StocksConfig.tickers() (a PLACEHOLDER list, but the property fails at the configured value); needs a quiet tape after a gap, unlikely on those volatile names",
   "fix": "Bound the wait: with SESSION_ROUNDS accept t1 < open when t0 is within the session and a1 printed at or after the previous regular close (or when t0 - t1 >= the heartbeat), i.e. fall back to the SESSION_ROUNDS-off rule once the latest round is a session round older than a set time; or correct F4/README:809 to say SESSION_ROUNDS markets have no heartbeat bound.",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.38;\n\nimport {StockOracleBase} from \"../utils/StockOracleBase.sol\";\nimport {StockOracle} from \"../../src/stocks/StockOracle.sol\";\nimport {Pulse} from \"../../src/Pulse.sol\";\n\ncontract SessionAudit is StockOracleBase {\n    Pulse internal pulse;\n    StockOracle internal oP; // SESSION_ROUNDS off, with the 4663 Pulse (gap 15 min, grace 1 h: DeployConfig.sol:597)\n\n    function setUp() public {\n        _deploy();\n        pulse = new Pulse(15 minutes, 1 hours);\n        StockOracle.Config memory c = _cfg(false);\n        c.pulse = address(pulse);\n        oP = new StockOracle(c);\n    }\n\n    function _open(uint256 day) internal view returns (uint256 op, uint256 cl) {\n        (, uint64 a, uint64 b,) = cal.windowOf(day);\n        return (a, b);\n    }\n\n    // ---- F4 worse than written: SESSION_ROUNDS on + a gap + a slow tape never prices (no 24 h bound)\n    function test_F4_sessionRoundsGapNeverPrices() public {\n        _print(friClose - 2 minutes, P);\n        _print(friClose - 1 minutes, P);\n        int256 a = 89e8; // a -11% gap at Monday's open: past JUMP\n        uint256 day = FRI + 3;\n        uint256 firstO;\n        bool sPriced;\n        uint256 rounds;\n        for (; rounds < 90; ++day) {\n            if (!cal.isTradingDay(day)) continue;\n            (uint256 op, uint256 cl) = _open(day);\n            _print(op + 1 minutes, a); // one round per session: the 24 h heartbeat (each step < 0.5%: no deviation round)\n            for (uint256 k; k < 3; ++k) {\n                _at(op + 2 hours + k * 1 hours);\n                (bool okO,,) = _try(o);\n                if (okO && firstO == 0) firstO = day;\n                (bool okS,,) = _try(oS);\n                if (okS) sPriced = true;\n            }\n            _at(cl - 1);\n            a = a * 996 / 1000;\n            ++rounds;\n        }\n        emit log_named_uint(\"o (SESSION_ROUNDS off) first priced day offset\", firstO - FRI);\n        emit log_named_uint(\"last answer (1e8), was 100e8 pre-gap\", uint256(a));\n        assertTrue(firstO != 0, \"o prices after one heartbeat\");\n        assertTrue(sPriced, \"F4: oS (SESSION_ROUNDS on) unpriced for 90 sessions while the answer fell 30% past the gap\");\n    }\n}\n",
    "ran": "forge 1.9.0 test --use solar --match-path test/scratch/SessionAudit.t.sol --match-test test_F4_sessionRoundsGapNeverPrices -vv",
    "result": "[FAIL: F4: oS (SESSION_ROUNDS on) unpriced for 90 sessions while the answer fell 30% past the gap] test_F4_sessionRoundsGapNeverPrices() (gas: 41086395). Logs: o (SESSION_ROUNDS off) first priced day offset: 4 (Tue); last answer (1e8), was 100e8 pre-gap: 6204838213"
   }
  }
 ],
 "claims": [
  {
   "id": "F3",
   "result": "holds",
   "evidence": "testFuzz_F3_premarketBound (3000 runs, PASS): Fri close rounds P,P; one Monday pre-market round a0 = P x (1 - drop), drop 0..10%; at any instant of Monday's session the SESSION_ROUNDS-off oracle prices exactly a0 when drop <= JUMP, so the opening price is bounded to [a1 x (1 - JUMP), a1] (a1 = the round before it); drop > JUMP is unpriced (Jump). The SESSION_ROUNDS-on oracle reverts NotYet throughout. A chain of several pre-market rounds each within JUMP moves the level further: that is F7 (README:814), not a wider F3 bound. The lender is covered by LLTV x LIF / (1 - JUMP) < 1 (README:804-805)."
  },
  {
   "id": "F4",
   "result": "refuted",
   "evidence": "Holds for SESSION_ROUNDS off (test_F4: the off-oracle prices one heartbeat after an -11% gap). Refuted for SESSION_ROUNDS on: finding SOS-1 (no heartbeat bound). The loss itself past the line on a single gap is market gap risk, see C2."
  },
  {
   "id": "F5",
   "result": "holds",
   "evidence": "test_F5_phaseAndBounds (PASS): new proxy phase first round -> NoPrevious (StockOracle.sol:217); answer MIN_ANSWER-1 and MAX_ANSWER+1 -> BadAnswer (:309); reverting feed -> BadRound (:306). testFuzz_P2_issuer covers issuer action; testFuzz_C1_deadOverHoliday covers the dead feed."
  },
  {
   "id": "F8",
   "result": "holds",
   "evidence": "testFuzz_P4_grace (3000 runs, PASS): real Pulse(15 min, 1 h) as in DeployConfig.sol:597; halts 0-3 h with no poke, a pre-halt round and a late round reading fresh at resume, 0-3 pokes (several in one block and in later blocks), checks before each poke and at a random later time: price() succeeds iff !pulse.inGrace(), and never before resume + 1 h after a silence > 15 min (pending silence before any poke reverts Grace, StockOracle.sol:212 / Pulse.sol:58). Could not make one price inside the grace."
  },
  {
   "id": "C1",
   "result": "holds",
   "evidence": "testFuzz_C1_deadOverHoliday (3000 runs, PASS): last rounds Wed 2026-11-25 15:58-15:59 ET, then dead over Thanksgiving (11-26 closed, 11-27 early close) and up to 20 days: whenever price() succeeds, openTime(t0, now) <= 49 h. openTime returns uint256.max past MAX_SPAN 14 days (MarketCalendar2.sol:138). By design a dead feed still prices for up to 49 h of open-market time (~2 sessions) after its last round (README:811); offset-table steps between adjacent trading days can make openTime count 1 h less (4 h -> 5 h step), a 1 h longer stale window, governance-only and minor."
  },
  {
   "id": "C2",
   "result": "not-checked",
   "evidence": "[data] NOT RUN: no Chainlink round history read in this item; the sheet's figures (27,000 rounds, NVDA -13.1%) are the requester's and are not re-derived. The code places no bound on a single real gap (any oracle shares this); SOS-1 shows the wait is unbounded on SESSION_ROUNDS markets."
  },
  {
   "id": "FILES-StageChain",
   "result": "refuted",
   "evidence": "script/deploy/StageChain.sol:63 passes pulse: address(d.pulse) to every StockOracle, but _stageStocks (StageChain.sol:40) has no caller in script/ at this commit: Deploy._deploy (script/Deploy.s.sol:54-62) never calls it and script/launch/Plan.s.sol, which StageChain.sol:20 and LaunchBase.sol:17 name as the caller, is not in the tree. So 'the pulse each 4663 oracle gets' cannot be checked end to end: d.pulse is set by StageCore.sol:47-49 when cfg.chain.pulse (true for 4663, DeployConfig.sol:597) only if that stage ran first in the absent plan. MorphoLender APPROVE does not check an oracle's pulse (README.md:834), so a pulse-less oracle is only stopped by the Safe (accepted)."
  }
 ],
 "holds": [
  {
   "property": "P1",
   "tried": "testFuzz_P1_pricedOnlyInSession (3000 runs): 2-7 random rounds 1 s-30 h apart from two days before Fri 2026-10-16, random proxy phase changes, read at a random instant up to 6 days later (weekend, pre/post-market, consecutive sessions): whenever priced, session kind == REGULAR, uint64(id) >= 2, 0 < t1 <= t0, fresh (wall <= 49 h or openTime <= 49 h), |a0-a1| <= a1 x JUMP, value == min(a0,a1), and with SESSION_ROUNDS t1 >= open. testFuzz_P1_earlyClose (3000 runs): Fri 2026-11-27 (early close, EST) priced iff before 13:00 New York. F5 test: phase first round and broken feed unpriced. Code: undated/after-t0/unreadable id-1 -> BadRound (StockOracle.sol:219)."
  },
  {
   "property": "P2",
   "tried": "testFuzz_P2_issuer (3000 runs): every non-empty combination of token paused, token oraclePaused, registry paused, registry isBlocked(morpho), and a reverting isBlocked read: both oracles revert Frozen. _flag treats revert or short return as set (StockOracle.sol:331-334). Not covered: a token that changes its ACCESS_CONTROLLED_REGISTRY after deploy (read once, immutable at :190) needs an upgrade, outside 'pause, blocklist, freeze'."
  },
  {
   "property": "P3",
   "tried": "grep src/ and script/: no contract of the system calls price() (only Morpho does); Morpho Blue's _isHealthy returns true before reading the oracle when borrowShares == 0 and repay/supply/supplyCollateral do not call _isHealthy (morpho-blue src/Morpho.sol). No Morpho test run in this item (Morpho is not vendored as code here)."
  },
  {
   "property": "P4",
   "tried": "testFuzz_P4_grace (above) and code: price() reads pulse.inGrace() before any feed read (StockOracle.sol:212); inGrace counts a pending silence (Pulse.sol:58) so a view or a direct Morpho.liquidate in the first block after a halt reverts before anyone pokes; poke() only lengthens graceUntil (Pulse.sol:49). Writers of Pulse state: Pulse.poke (anyone; LedgerBase.sol:260, Liquidator.sol:223, house mirrors); readers: StockOracle.sol:212, Redeemer.sol:112, LedgerBase.sol:240, Liquidator.sol:224, StockJoin.sol:155. Limitation (not a property breach): a 4663 sequencer that keeps poking while censoring borrowers never opens a grace, and a halt of <= 15 min opens none; both are the Pulse design."
  }
 ],
 "notRun": [
  "C2 [data]: NOT RUN (no Chainlink history read)",
  "[fork]: NOT RUN (no fork test in this item)",
  "Morpho Blue integration for P3: code reading only"
 ]
}