Skip to content

Adaptive paper engine: exchange-calendars XNYS as the primary session calendar (never-rebuild), overnight-cap fail-open fixed - #735

Merged
seathatflowsinourveins merged 19 commits into
mainfrom
trading/adaptive-paper-xnys-primary-20261005
Oct 5, 2026
Merged

seathatflowsinourveins merged 19 commits into
mainfrom
trading/adaptive-paper-xnys-primary-20261005

Conversation

@seathatflowsinourveins

@seathatflowsinourveins seathatflowsinourveins commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

  • What this PR changes: the adaptive paper engine's session clock now uses exchange-calendars XNYS as its primary NYSE calendar, under the 2026-10-05 never-rebuild rule. That covers the PRE/RTH/POST/CLOSED classification, is_trading_day for ingestion, and mover X1 timing. Bounds are derived from the query year, with no frozen table. Session open and close times come from upstream, including delayed opens and early closes.
  • Base commit: f946c6d4ca988a17b6fa4392ecb488909f147883
  • Lane: lane:shared. The engine and its tests are trading-owned. The PR also changes CI workflows and pins (.github/workflows/adoption-bootstrap.yml, catalog-freshness.yml, .github/requirements-ci.txt, the new .github/requirements-calendar.txt) and the root README.md, so it needs the foundation lane's acknowledgement (docs/lanes.md).
  • Owned paths touched:
    • blueprints/us-equities/adaptive-paper/{sessions, safety, leverage, financing, mover, native_strategy, runner}.py, plus its requirements, lock and source-hashes;
    • blueprints/us-equities/data/ingest_snapshot.py;
    • receipts under adaptive-paper/receipts/xnys-primary-20261005/;
    • the tests;
    • the CI files above;
    • docs/decisions/2026-10-05-adaptive-paper-xnys-primary.md;
    • manifests/evidence.json (last commit, per the hot-file protocol).
  • Live paper lane: running series use the frozen engine dca821c (FREEZE.md per series). This change reaches live paper only through a new, separately qualified freeze, never by merge.

SOTA sources

Evidence-class table

Claim Evidence class Command / receipt
Session classification covers every 2026/2027 date, holidays, early closes, DST, bounds and provider failures local_integration (unchanged upstream library) tests.test_adaptive_paper_sessions SessionClockTests; receipts/xnys-primary-20261005/qualification.json
Engine suites green under the hash-locked engine environment local_integration coordinator, engine interpreter: safety, sessions, mover, mover_native, ingest and source-hash, 357 tests OK
CI interpreters install the calendar; a relock triggers macOS validation local_integration tests.test_workflow_hardening, 118 OK (2 skips)
The overnight gross cap no longer fails open on a calendar error (pre-existing, fixed in r3) local_integration regression with a 0.5 overnight multiple: red against r2, green after

Local commands run

$ <engine venv>/python -m unittest tests.test_adaptive_paper_safety tests.test_adaptive_paper_sessions tests.test_adaptive_paper_mover tests.test_adaptive_paper_mover_native tests.test_ingest_snapshot tests.test_adaptive_paper_source_hashes_manifest   Ran 357, OK   [coordinator]
$ python3 -m unittest tests.test_workflow_hardening   Ran 118, OK (skipped=2)   [coordinator]
$ python3 scripts/validate.py                    exit 0   [coordinator]
$ python3 scripts/evidence_manifest.py --check   exit 0   [coordinator]
$ git diff --check                               exit 0   [coordinator]

Not run locally, so this PR's CI is the evidence:

  • the full CI-equivalent suite;
  • validate-macos in full mode;
  • the macos-15 wheel tags.

One engine-suite error reproduces on main from a linked git worktree (credential_file_permissions:worktree), so it is environmental and predates this branch.

Review

Built by GPT-6.1 Sol through the packaged SDK worker (rounds t-cal-r1 to r3); committed by the coordinator.

  • Claude Opus cross-family read of r1: 3 P1 and 6 P2. r2 fixed them.
  • Delta read of r2: ACCEPT, with 4 P2. r3 fixed those.
  • Delta read of r3: ACCEPT, with 3 P2. They are recorded below as residuals.

Decision record

docs/decisions/2026-10-05-adaptive-paper-xnys-primary.md

Checklist

  • Workflow changes add only a hashed, binary-only calendar install step and a MACOS_PATTERNS entry; no new actions, permissions or secrets.
  • No secrets printed, logged or committed. No live endpoint, key or mode is touched.
  • No new paid hosting, subscription or billing surface.
  • Peer-owned untracked files and worktrees were preserved.

Recorded residuals (bounded review, 2026-10-05)

Claude Opus delta read r3 at a4f20a5d9260 returned ACCEPT with no p1. Under the bounded review rule these p2 items land as recorded residuals, each owed as a follow-up:

  • docs/decisions/2026-10-03-macos-ci-scope.md:679-689 (section 6.2 literal list) vs .github/workflows/adoption-bootstrap.yml:148-156: Before r3 the record's 6.2 literal list matched MACOS_PATTERNS entry for entry and in order (89/89).
  • README.md:199,204; blueprints/us-equities/order-throughput/README.md:171,175: The prose requires 'Python >=3.12', but both recipes run python3.12 -m venv, which needs that exact binary.
  • tests/test_adaptive_paper_safety.py:939-958 (with blueprints/us-equities/adaptive-paper/safety.py:772-775,781-784; leverage.py:61,274): Pre-existing: the test text is identical at merge base f946c6d.

🤖 Generated with Claude Code

Scout and others added 18 commits October 5, 2026 02:36
…mary NYSE calendar, with query-derived bounds and visible errors

Under the 2026-10-05 never-rebuild rule, the hand-maintained NYSE holiday table gives way to
upstream exchange-calendars 4.13.2 (gerrymanoim/exchange_calendars at dbe38b1f). The module
stays pure: it never reads the wall clock.

- sessions.py builds the XNYS calendar with explicit bounds derived from the queried date. The
  default "now + 1 year" end bound would tie the module to the run date. Provider errors
  surface instead of being swallowed, and a date outside the bounds is a hard error. The
  session policy and receipts are unchanged. The docstring cites XNYS at the pin and states the
  bounds rule.
- Why the engine env excluded exchange-calendars: git history (4ba8ac9, 7e7eefe) records only
  "the task's environment constraints". The decision record says no substantive reason was
  found.
- Qualification inside the exact engine lock, in a clean scratch venv: the 20 baseline
  distributions are unchanged, and only exchange-calendars and its four dependencies are added,
  hash-locked in requirements-linux-x86_64-py312.lock. NautilusTrader 2.0.0rc5 (LiveNode),
  alpaca-py 0.44.0 (TradingClient) and exchange-calendars import. uv pip check passes. The
  installed calendar sources match dbe38b1f.
- Tests use the real calendar. They cover holidays, 13:00 early closes, New Year observances,
  DST, weekends, visible provider errors and explicit bounds, plus parity with the previous
  table over all 730 dates of 2026 and 2027. A negative control fails when the bounds are
  removed. Totals: 145 session tests and a 320-test affected selection.
- CI gets a calendar-only dependency file, .github/requirements-calendar.txt.

Deploying the engine code and environment to the live paper host is a separate operator step,
taken outside the paper run windows.

Built by GPT-6.1 Sol through the packaged SDK worker (round t-cal-r1); committed by the
coordinator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… osv inventory (with reason)

engine-baseline.lock under receipts/xnys-primary-20261005/ is a frozen evidence copy of the
pre-change engine resolution, not an install input. The active engine lock is registered for
scanning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…evidence fixture it is

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… calendar in both CI interpreters, upstream session_open, cached bounds

P1 fixes from the Claude Opus read of r1:
- ingest_snapshot no longer imports the deleted private helper. A public is_trading_day answers through a direct XNYS is_session query, and ingestion uses it. A regression runs ingestion main with the real calendar and synthetic transport and credential fixtures.
- The engine .lock key is removed from the narrow source-hash manifest; its digest stays registered in manifests/evidence.json. A regression enforces both.
- Both CI workflows install .github/requirements-calendar.txt (hashed, binary-only) before unittest, including both macOS modes.

P2 fixes:
- The RTH opening time uses upstream session_open, with the New York conversion (gerrymanoim/exchange_calendars 4.13.2 at dbe38b1f, exchange_calendar.py:1006-1010), instead of a duplicated 09:30. A delayed-open regression covers it.
- A four-entry LRU keyed by query year replaces per-call calendar construction, and session_at reuses the first close. Regressions cover alternating years and the single close query.
- Mover X1 timing refuses non-sessions with MoverRefusal("mover_x1_non_session").
- The clock fixtures bind only the runner's time.
- The docs carry query-derived bounds and provider-error behaviour.

Built by GPT-6.1 Sol through the packaged SDK worker (rounds t-cal-r2 and t-cal-r2b); committed by the coordinator. The builder's scratch engine venv and CI venv (clean, hash-locked) ran the session, ingest, mover, native and workflow suites green. The coordinator re-ran the host-dependent suites in its own shell:
- CI interpreter: workflow policy, security and coverage, adoption-bootstrap-macos, workflow hardening, sessions, ingest and source-hash manifest. 487 tests, OK (68 skips).
- Engine interpreter: runner, native, financing and order throughput. 321 tests, 1 error: test_cli_refuses_live_base_url_from_env_file_without_network raises credential_file_permissions:worktree. The same error reproduces on main from a linked git worktree, so it is not introduced here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…open on a calendar error; macOS CI covers calendar relocks; Python >=3.12 stated

- **Risk path.** On a ValueError from the session calendar, safety.py's _effective_gross_cap returned max_gross_exposure_usd. That lets more gross exposure through than the overnight cap whenever overnight_gross_multiple is below 1, at both the entry gate and the _refresh_risk halt trigger. This predated the branch. It now returns min(max_gross_exposure_usd, overnight_gross_exposure_cap_usd()). A regression with a 0.5 multiple fails against r2 and passes now. No frozen trial parameter changes.
- **macOS CI.** .github/requirements-calendar.txt is in adoption-bootstrap.yml MACOS_PATTERNS, so a calendar relock runs validate-macos on its PR. A workflow-hardening regression covers it.
- **Docs.** The three live-engine docstrings in safety.py and leverage.py describe query-year bounds and provider-error behaviour, not the removed table. requirements-ci.txt and both README recipes state Python >=3.12.

Built by GPT-6.1 Sol through the packaged SDK worker (round t-cal-r3); committed by the coordinator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fore the final hot-file commit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (hot-file protocol: every hot-file edit in the last commit)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@seathatflowsinourveins seathatflowsinourveins added the lane:shared Touches files owned by both lanes; needs both lanes' acknowledgement label Oct 5, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T12:06:11.013053Z a4f20a5 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.

@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Foundation ACK (c5, foundation coordinator) at a4f20a5 for this PR's CI-workflow and pin edits.

Read in the diff:

  • .github/requirements-calendar.txt is generated by uv pip compile, hash-locked and constrained by the engine lock.
  • adoption-bootstrap.yml and catalog-freshness.yml install it with pip install --require-hashes --only-binary=:all:.
  • requirements-ci.txt includes it.
  • .github/osv-scanner-lockfiles.json registers the new lockfiles.
  • Upstream: exchange-calendars 4.13.2 from PyPI, the vendor package. No rebuild or wrapper.

Conditions:

  • The PR is DIRTY against main. Rebase it, put the registry last, and get CI green, including the macOS jobs, given the requirements header now reads Python >=3.12.
  • Live paper stays unaffected until a separately qualified freeze, as the body says.

…erged by entry; registry last)

Both sides added an entry at the same place in .github/osv-scanner-lockfiles.json (this branch's
adaptive-paper engine lock, main's #729 riskl-parity lock), so a line merge produced one object with two "path" keys
and the queue's line-union refresh stopped at record discovery, whose JSON reader refuses duplicate keys. The file is
merged by whole entries instead: main's lists plus this branch's three entries at their reviewed positions, so it
differs from main by exactly this branch's insertions and from the branch head by exactly main's.
.github/workflows/catalog-freshness.yml merged cleanly. manifests/evidence.json is main's registry with this branch's
rows re-registered from the merged files, plus its receipts and convergence-record additions (hot-file protocol).

Checks on the merged tree: scripts/validate.py exit 0; scripts/validate_convergence.py --all-recorded exit 0;
scripts/evidence_manifest.py --check passed (10,157 files); git diff --check against main clean. Unit tests: 410 run
with the system python3 (8 errors, all ModuleNotFoundError exchange_calendars); the 7 calendar-dependent modules
re-run in a venv from .github/requirements-calendar.txt: 591 tests OK (126 skipped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@socket-security

Copy link
Copy Markdown

Dependency limit exceeded — report not shown.

This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report.

Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard.

Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account.

@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Claude session 5f (trading custody): trading-lane ACK at d18a3af5ac039922c9267f3ac281fca4f2d03eaa, for this lane:shared PR. The command center gave the foundation ACK at the same head.

Basis:

  • The root read's three P1s are resolved, with a recorded resolution.
  • Opus delta read r2 ACCEPT; delta read r3 ACCEPT at a4f20a5d9.
  • GPT cross-family read of the coordinator merge of main cb339488e ACCEPT, no findings. It verified:
    • the lockfile inventory is merged by entry;
    • there are no duplicate keys;
    • the 3-way merge of catalog-freshness.yml is clean;
    • the 10,157 registry rows are verified.
  • Calendar-dependent tests: 591 OK (126 skipped) in a venv from .github/requirements-calendar.txt.
  • validate, convergence and evidence-manifest checks exit 0.

macOS checks are advisory, by the user's 2026-10-05 decision.

@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Claude session native-agent-stack-5f: landing at head d18a3af5ac039922c9267f3ac281fca4f2d03eaa. The command center (wsl-architecture-design) gave its ACK at this exact head; under the user's 2026-10-04 decision it owns merges that touch the hot registry. The read-only cross-family review (GPT-6.1 Sol max, the packaged Codex SDK worker) returned FINDINGS at 92a3a20effce; this head is reached from it through recorded carry edges (equal owned patch-ids, or a cross-family delta read returning ACCEPT at the edge's target), with its 3 P1 item(s) resolved in one repair round as recorded.

Observed main cb339488e3e004b04e8a4e5b4fd246442a275e3c. coordination/merge_tree_landing_check.py (sha256 a11649fcf2e5844c…) exit 0:

main cb339488e3e004b04e8a4e5b4fd246442a275e3c head d18a3af5ac039922c9267f3ac281fca4f2d03eaa base cb339488e3e004b04e8a4e5b4fd246442a275e3c merged-tree 4370aacd40dabf87916fd27884ef89dacdf07eef merge-tree-exit 0
ok   1: clean three-way merge
ok   2: merged-vs-main paths 36, outside PR-owned 0 []
ok   3: main drift 0 paths, overlap with PR-owned inputs (registry excluded) []
ok   4: registry foreign rows equal True, order preserved True, PR-owned rows 35, unowned top-level keys differing []
ok   5: merged files[] sorted by path with no duplicates: True (10157 rows)
LANDABLE
condition 5: merged files[] sorted and unique (tree 4370aacd40dabf87916fd27884ef89dacdf07eef)

Required checks at this head: 7 pass . Unresolved review threads: 0.

macOS (advisory). The user decided on 2026-10-05 that macOS checks are advisory. Ruleset 23739774 requires exactly validate, token-report, secret-scan, dependency-review, osv-scanner, verdict-review-gate and sota-sources.

The macOS full suite has carried one failure from main since #732 (4fd7106): tests.test_runtime_worker_openhands_push_gate OwnedPathGateTests.test_case_and_unicode_collisions, controls case_collision and unicode_nfc_collision.

  • Cause: the test fixture writes the colliding paths through the filesystem. macOS APFS is case- and normalization-insensitive, so each pair collapses into one path, and the gate correctly passes.
  • Scope: a test-fixture defect, not a gate defect.
  • Fix: on branch foundation/resolver-push-gate-macos-collisions-20261005.

@seathatflowsinourveins
seathatflowsinourveins merged commit 095d4fa into main Oct 5, 2026
24 of 25 checks passed
@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Claude session native-agent-stack-5f: post-merge observation. Landed as 095d4fad89c7896c7f1766fdaa9981554a19403a (parent cb339488e3e004b04e8a4e5b4fd246442a275e3c), tree 4370aacd40dabf87916fd27884ef89dacdf07eef. The landed tree equals the checked merged tree and the parent is the observed main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:shared Touches files owned by both lanes; needs both lanes' acknowledgement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant