Skip to content

feat(sh2): add Cloud Run deployment spec and SH-2 acceptance pack (SH-2 5/5) - #16

Merged
Pigbibi merged 59 commits into
mainfrom
feat/sh2-part5-cloudrun-acceptance
Nov 26, 2026
Merged

Pigbibi merged 59 commits into
mainfrom
feat/sh2-part5-cloudrun-acceptance

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

AI assistance

  • Gemini (execution) + OpenAI Codex (gpt-6.2-astra, reasoning high, 2 local review rounds).

What changed

  • Add secret-free Cloud Run Jobs container definition (Dockerfile, .dockerignore, UID/GID 10001 shadowapp, no default SHADOW_DATA_DIR) and deploy/cloudrun/job-spec.example.yaml (us-east1, maxRetries: 0, Secret Manager ref, UID-matched mountOptions).
  • Add src/shadow/sh2_acceptance.py implementing SH2-A01..A14 offline acceptance checks (PASS_OFFLINE, 10/10, zero network OTS transport calls offline, concrete config/production-scheduler.json safety-lock assertions, git-tracked hygiene scan).
  • Add Cloud Run idempotency, tamper/rollback recovery, and acceptance test suites (tests/test_cloudrun_job.py, tests/test_sh2_acceptance.py) plus docs/sh2-acceptance-pack.md and docs/sh2-cloudrun-runbook.md (marking legacy Mac mini units deprecated under deploy/scheduler/).
  • Keep src/shadow/manifest.py runtime file list unchanged from SH-2 4/5 and preserve all safety locks (production_chain_locked: true, clk01_active: false, live: OFF, kelly: OFF, H: "0", B0: "50000").

How verified

Why

Risk

  • Low-Medium: adds deployment specs, docs, offline acceptance CLI, and tests without changing locked production trading/ledger runtime behavior or RUNTIME_MODULE_FILES digests.

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
Embed next_row_state_sha256 in record bodies, authenticate persisted
production history against an external trusted head and monotonic
anchor, and recover pending rejected state across multi-day rejections.
Wire FUSE into scheduler and replay, add the locked production config,
the Cloud Run job module, and the SH-2 demo used by the pipeline tests.
Part 4 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
Add the secret-free Cloud Run Job Dockerfile and example job spec, the
Cloud Run runbook, the SH-2 acceptance pack (sh2_acceptance) and its
docs, the Cloud Run job test suite, and deprecation notes for the SH-1
host templates. Part 5 of the SH-2 split of #7; the tree now matches
feat/sh2-live-engine.

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
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
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
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
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
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
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
Market records are now validated against the decision session, so the
ledger-integration and pipeline fixtures that build records by hand
carry the effective_session the feeder always sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Pigbibi and others added 25 commits November 26, 2026 11:03
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
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
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iHeYdGvqQh5k2bkN5Eiuq
Ledger and pipeline fixtures that build market records by hand now
carry a T-1 SOFR effective date, a retrieval time before the decision
instant, and per-fund closes that match the fund payload.

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
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
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
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
@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-26T18:33:22.331295Z 31e5662 PR opened
🔒 Security Review ✅ Completed 2026-11-26T18:37:19.013328Z 31e5662 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 ac8aff5 into main Nov 26, 2026
12 of 13 checks passed
@Pigbibi
Pigbibi deleted the feat/sh2-part5-cloudrun-acceptance branch November 26, 2026 18:37
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