Skip to content

feat(close): add US 23/5 close isolation, feeder limits, and OTS (SH-2 3/5) - #14

Merged
Pigbibi merged 30 commits into
mainfrom
feat/sh2-part3-close-isolation
Nov 26, 2026
Merged

Pigbibi merged 30 commits into
mainfrom
feat/sh2-part3-close-isolation

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

AI assistance

Gemini and local Codex gpt-6.2-astra (high) adversarial review (2 rounds).

What changed

SH-2 split part 3/5 (feat/sh2-part3-close-isolation): US 23/5 16:00 ET Official Close isolation, bounded HTTP response/error reads with monotonic deadlines, and OpenTimestamps redirect/deadline hardening.

  • src/shadow/calendar_consumer.py: add classify_us_equity_session_window for RTH vs US 23/5 extended/overnight windows and core_session_open support.
  • src/shadow/feeder.py: enforce RTH Official Close validation on Tiingo/Yahoo payloads, reject next_trade_date_window / closed / extended markers, reject post-cutoff or post-retrieval publicationTimestamp at eligibility time, enforce effective_session == trade_date, and accept calendar_session in verify_market_record_raw_integrity.
  • src/shadow/feeder_live.py, src/shadow/http_limits.py, src/shadow/ots.py: add bounded HTTP body/error readers, monotonic connection deadlines, cross-host credential redirect blocking, and bounded redirect body closing (_CloseOnUnboundedRedirectRead).
  • src/shadow/scheduler.py, src/shadow/replay.py: pass resolved calendar_session=cal into verify_market_record_raw_integrity.
  • src/shadow/manifest.py: register src/shadow/http_limits.py in RUNTIME_MODULE_FILES.
  • Tests (tests/test_calendar.py, tests/test_feeder.py, tests/test_feeder_live.py, tests/test_ots.py, tests/test_scheduler.py): coverage for close isolation, redirect bounds, publication timestamp eligibility, and half-day integrity verification.
  • Non-blocking Astra P2 items tracked in SH-2 adapter/sizing hardening: P2 follow-ups from Astra review of #9 #12.

How verified

Why

Completes part 3 of 5 in the #7 SH-2 PR split so each slice stays reviewable ahead of the 2026-12-06 US 23/5 boundary.

Risk

High-risk repository (ShadowResearch), offline/read-only feeder and verification layer only (production_chain_locked: true, clk01_active: false, live=OFF, kelly=OFF, zero broker connections or secrets).

Pigbibi and others added 30 commits November 25, 2026 23:47
Add VendoredFuseEvaluator, which re-verifies the vendored engine digests
before each evaluate() call, plus FUSE input translation, NO-NEW-RISK
clamping and per-tier sizing controls. Register fuse_adapter in the code
manifest, hash explicit scheduler config paths by their relative path,
and record the SH-2 entry gates. Part 2 of the SH-2 split of #7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Consume the csa22-v2 calendar to classify core RTH vs extended and
overnight windows, reject non-official-close and T+1 bars, resolve the
immediately preceding trading date, and bound decimal inputs. Add
http_limits with streaming byte caps and monotonic total deadlines for
market and OTS fetches. Part 3 of the SH-2 split of #7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Resolve o5_settled_cash before defaulting settled_cash to the bankroll,
keep a missing V7 session_time as missing instead of asserting a
regular session, and compile vendored source with dont_inherit=True so
legitimately compiled __pycache__ bytecode verifies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Default the canonical O5 session counters only when no alias carries
evidence, forward H so O9 can match authorized H change descriptors,
and stop substituting one_session_loss (a return fraction) for the
cumulative dollar loss L when re-tiering explicit FUSE payloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Stage N has no broker evidence in any mode, so absent broker_*
observations are substituted with modelled values and O3 is a model
self-reconciliation, not reconciliation evidence. Comment only; no
change to validated inputs or record hashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Default session_order_count and session_turnover only when the key is
omitted; an explicitly null counter is unknown evidence and is passed
through as None so evaluate_O5() fails closed on turnover/order limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Compare cached vendored bytecode by code-object equality instead of
marshal encoding, which differs between py_compile and compile() on
CPython 3.11/3.12, while still rejecting altered constants. Preserve an
explicitly null settled_cash or o5_settled_cash as unknown evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Validate every market record (including optional SPX) for eligibility,
calendar digest and effective session, apply corporate actions to V1
returns only when the ex-date is the decision session, pass explicit
null policy hashes and heartbeats through uncoerced, leave absent
settled cash unknown, pin the complete metadata digest set in code, and
execute only verified engine source bytes via a dedicated finder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Record heartbeat_source="adapter_self" when the adapter defaults the
O7 heartbeat to as_of, and "caller" when session inputs supply it, so a
self-attested heartbeat is never mistaken for liveness evidence. The
ledger-supplied heartbeat follows in part 4 (#13).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
SH-2 decisions are end-of-day, so every trading day, half days
included, maps to `open`; FuseControl's half_day_cutoff is a pre-trade
rule. Pin that the 2026-11-27 14:30 ET half-day decision maps to open
with O2 clear, and that late runs are the scheduler cutoff's job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Apply the feeder's exact rate freshness rule, reject records retrieved
after the decision instant, reject the ineffective kill_switch_tripped
flag, fail closed on conflicting corporate actions and on caller closes
that disagree with the validated market close, and pass explicit nulls
(broker, cash, exposures, tolerance, proposal) through as missing.
Unknown tiers and missing high-water marks no longer fall back to
balanced or bankroll defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
The close-mismatch guard must compare values, not the strict sizing
parser (which rejects floats by design), so a float and a canonical
decimal string for the same close are treated as equal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Reject conflicting corporate actions before any successor state,
never let current_index_closes override a validated record, propagate
unknown held-position values into reconciliation and aggregates,
reject kill_switch_tripped on the effective payload at the evaluator
boundary, drop source records dated after the decision instant, and
compare timestamps as aware instants rather than strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Drop source records dated after the decision instant at the evaluator
boundary so nested fuse_inputs and direct payloads are covered, and
pass an unknown ledger quantity as share_count None (0 only for an
explicitly flat position) so O3/V2 cannot clear on an invented zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
…isolation

# Conflicts:
#	src/shadow/manifest.py
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T16:31:47.124368Z 525581c PR opened
🔒 Security Review ✅ Completed 2026-11-26T16:34:55.827719Z 525581c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Pigbibi Pigbibi added the agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation label Nov 26, 2026
@Pigbibi
Pigbibi merged commit bbdddcb into main Nov 26, 2026
12 of 13 checks passed
@Pigbibi
Pigbibi deleted the feat/sh2-part3-close-isolation branch November 26, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant