Skip to content

SH-2 adapter/sizing hardening: P2 follow-ups from Astra review of #9 #12

Backlog

Description

@Pigbibi

P2 findings from the local Codex gpt-6.2-astra (high) adversarial review of #9 @ 9137a64. Per the SH-2 split policy, P2s are tracked here and not fixed in the part PR. The P1s from the same review were fixed in #9 (commit 9734174, with regression tests).

  • O5 alias conflicts. Canonical defaults collide with supplied aliases. Overlaps with fuse_adapter O5: resolve whitelist aliases and stop coercing counters #11 (whitelists, counter coercion).
  • Host-path-independent config identity. compute_code_manifest_hash() hashes explicit config paths by repo-relative path, or external/<abs path> outside the repo, so the identity depends on the host path.
  • O5 session order count. Validate and pass through as evidence rather than coercing (see fuse_adapter O5: resolve whitelist aliases and stop coercing counters #11).
  • Decimal precision pinning. Pin a decimal context (precision and rounding) for sizing and adapter arithmetic, so results do not depend on the ambient context.
  • BIL quote evidence. BIL is whitelisted for O5 but has no quote or eligibility evidence path.
  • Frozen-holding exact share target (sizing.py:684). The target share count for frozen holdings should equal the held quantity exactly.
  • Numeric overflow. Bound float conversions of very large Decimal inputs (exposure, notional) so they cannot overflow to inf.
  • Fund-level pending orders for O4. Accept and validate per-fund pending_orders evidence, not only the account-level map.
  • Decimal-bound failures in sizing validation. Make sure out-of-bound decimals (canonical_decimal_str bounds) raise SizingInputError and fail closed consistently.
  • Valid bytecode cache through evaluator init. Add a test that loads VendoredFuseEvaluator with a legitimate __pycache__ present, covering the full init path, not only verify_vendored_engine_bundle().

Acceptance: each item gets a regression test, and the full suite plus python -m shadow.sh2_acceptance stay green.

Activity

  1. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    More P2s from the Astra review of #9, rounds 2 and 3. These are tracked here under the SH-2 split policy; round-3 P1s were fixed in #9.

    • Whitelist alias defaults and conflicts (see also fuse_adapter O5: resolve whitelist aliases and stop coercing counters #11).
    • Check read-only mode on every metadata file, not only the engine sources.
    • Parse entry-gate metadata from the verified bytes, not by re-reading the file.
    • O5 counter coercion: pass counters through and let alias validation reject them (see fuse_adapter O5: resolve whitelist aliases and stop coercing counters #11).
    • Pin the Decimal context (precision and rounding).
    • O5 should use exact settled cash: decimal, no float round-trip.
    • Control mappings for unknown funds and tiers should fail closed.
    • Out-of-bounds sizing decimals should be reported through O1 instead of raising.
    • Require the calendar digest before accepting a market record when the calendar session lacks a digest.
    • Clear the previous tier's joint cap on every tier change.
    • Default proposed_exposure to the effective exposure. The L0 two-pass check against the real proposal is in O7: ledger supplies last_heartbeat from previous committed record #13's part-4 scope.
    • Reject ambiguous duplicate market records for the same instrument.
    • Require eligible is True (strictly) and a finite market value.
    • Frozen-holding targets should use the held share count.

    Generated by Claude Code

  2. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    More items from the final safety-class Astra pass on #9 @ cd7a2c1. None of these block, and none fail open:

    • fuse_adapter._compute_return_ratio (around :793): a nonpositive current close becomes a -100% return and latches L6 HALT. It should be reported to O1 as missing or invalid data. This fails safe (it HALTs), but it misattributes the cause.
    • Compare corporate-action amounts in one canonical numeric form (ratio and cash_per_share_usd as float vs Decimal vs str).
    • Quote evidence for proposed non-fund symbols (e.g. BIL) before O5 or sizing accept them.
    • Tracked bytecode vs local caches: decide and document whether any __pycache__ may exist under vendor/ at runtime. Loading already ignores caches.
    • Frozen-holding targets in integer shares, equal to the held quantity (repeat of an earlier item).
    • Repeats from earlier passes that are already listed here.

    Generated by Claude Code

  3. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Deferred P2 items from local Codex gpt-6.2-astra (high) review of SH-2 part 3 (feat/sh2-part3-close-isolation) per SH-2 split review policy:

    • Parse JSON numbers as Decimal before float rounding (src/shadow/feeder.py Tiingo/Yahoo/NYFed parsers): decode JSON numbers with parse_float=Decimal / parse_int=Decimal (or preserve original text) before _parse_finite_decimal, so boundary values like 1000000000.000000001 or 1e-400 are not rounded to 1000000000.0 / 0.0 before validation.
    • Calendar overnight window across adjacent trading days (src/shadow/calendar_consumer.py:345-352): classify_us_equity_session_window should determine extended_overnight_open vs closed using the target trading session (e.g., Sunday 21:00 ET opens into Monday's trading session; Friday 21:00 ET and pre-holiday evenings are closed).
    • Thread monotonic deadlines into live fetch and OTS client (src/shadow/scheduler.py / src/shadow/feeder_live.py): pass remaining budget from decision_cutoff_utc / commitment_deadline_utc as deadline_monotonic into emit_live_market_records and OpenTimestampsClient so 429 backoffs and OTS retries stop when the budget expires.
  4. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Additional deferred P2 items from Astra Round 2 on SH-2 part 3 (feat/sh2-part3-close-isolation) per SH-2 split review policy:

    • Pass calendar_session in direct adapter fetch_daily calls (src/shadow/feeder_live.py): TiingoDailyAdapter.fetch_daily() and YahooChartAdapter.fetch_daily() parse payloads without passing calendar_session, falling back to 16:00 close on half days.
    • Reject Yahoo multi-bar intraday payloads without dataGranularity (src/shadow/feeder.py:489-491 & prior-close helper): when meta.dataGranularity is absent and multiple RTH bars exist for one session, do not pick the last bar by array order.
    • Thread YahooChartAdapter(deadline_monotonic=...) into default transport (src/shadow/feeder_live.py:452-455): pass adapter's deadline_monotonic into urllib_fetch_bytes on both initial request and 429 retries.
  5. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Deferred non-blocking P2s from SH-2 Part 4 Astra Round 1 review:

    • src/shadow/scheduler.py:1791-1795: consecutive_session_scope labels clk01_forward_clock before receipt/Bitcoin creditability verification completes.
    • src/shadow/scheduler.py:2035-2038 / _summarize_committed_receipt: production mode reuses drill receipt reason label drill_mode instead of ots_pending_bitcoin_confirmation or similar mode-accurate reason.
    • src/shadow/ledger.py:3504-3508: _assert_pending_state_preserves_committed_breakers skips _by_tier check when pending_state omits _by_tier (kept compatible with single-tier ev.evaluate callers in test_sh2_pipeline.py).
  6. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Deferred non-blocking P2s from SH-2 Part 4 Astra Round 2 review:

    • src/shadow/scheduler.py:2030-2034: run_production_cycle(config=...) direct config-object path checks evaluator identity; unify pinned config fuse_engine_hash/fuse_spec_version and strict bool clk01_active validation with load_production_scheduler_config.
    • src/shadow/scheduler.py:4233-4237: include decision-time fuse_context source evidence (positions_source_record.as_of, etc.) inside compute_inputs_digest() and verify on replay.
    • tests/test_sh2_pipeline.py:503-507: inject offline OTS mock client in remaining fixture-based tests so offline runs never wait on public OTS calendars.
  7. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Deferred non-blocking P2s from ShadowResearch#15 GitHub Codex review (0ffbdca):

    • src/shadow/scheduler.py:3027: invoke recover_pending_evidence() for drill-mode retries too before reconciling completeness reports.
    • src/shadow/ledger.py:875: propagate Pass-2 proposed_exposure override into nested fuse_inputs payloads inside _apply_explicit_payload_tier.
    • (src/shadow/ledger.py:3600 missing _by_tier in pending state already tracked above in this issue.)
  8. Pigbibi commented on Nov 26, 2026

    @Pigbibi
    ContributorAuthor

    Deferred non-blocking P2s from SH-2 Part 5 Astra Round 2 review:

    • tests/test_cloudrun_job.py:103-107: inject synthetic offline OTS client in Cloud Run unit tests so fixtures_dir drill tests do not invoke default OpenTimestampsClient network calendars.
    • src/shadow/sh2_acceptance.py:152-155: catch AssertionError / CalledProcessError from run_all_demos() and emit structured overall_status: "FAILED" JSON instead of propagating traceback.
    • src/shadow/sh2_acceptance.py:308-309: verify computed production_code_version_sha and production_policy_config_hash against documented/independent pinned values rather than only echoing computed values under pinned_identities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions