Skip to content

feat(qt): D1 end-of-stage panel freeze — 14-factor raw baseline + manifest - #87

Merged
StackOverFlow11 merged 2 commits into
mainfrom
feat/factor-refactor-d1-panel-freeze
Jul 24, 2026
Merged

feat(qt): D1 end-of-stage panel freeze — 14-factor raw baseline + manifest#87
StackOverFlow11 merged 2 commits into
mainfrom
feat/factor-refactor-d1-panel-freeze

Conversation

@StackOverFlow11

Copy link
Copy Markdown
Owner

Closes out step D1 of the factor-layer refactor (v3.2 §五 leg-4 / R11): freeze the 14 closing-set factors' raw value panels while factor math is still bit-identical to pre-refactor main — the sole cell-level baseline for D5 reconciliation once D2 rewrites the math.

What (+1207, 3 new files, zero existing files touched)

  • qt/panel_freeze.py — freeze tool, reused at D5. Zero formula re-implementation: every minute factor calls its eval runner's own _load_*_panel with constants referenced off the runner module object; book factors go through qt.eval_jump_amount_corr._build_book_factors (verified identical across all 11 runners). Canonical content hash (sha256 over sorted index serialization + float64 raw bytes; NaN payloads collapsed to one bit pattern, signed zeros kept distinct), atomic writes, strict --resume (panels read back from file are re-processed, re-reconciled and re-hashed — never trusted).
  • tests/test_panel_freeze.py — 23 network-free tests incl. NaN-payload mutation evidence (asserts payload bytes differ before asserting hash equality) and a real mid-write-failure atomicity test.
  • docs/factors/d1_panel_freeze_manifest.md — 14-row manifest: rows/date-range/symbols/NaN/mean/std + canonical & file sha256 per factor; producing SHA pinned to 3669c90 (run executed before commit so the tracked tree bit-equalled main); provenance rule verbatim (baseline regeneration only from the pinned pre-D2 SHA — the structural guard against the compare_postmerge.py vacuous-reconciliation failure mode); honest disclosure of the two-segment run (session-limit kill at ~60min → --resume) and of the first segment's log loss (_make_logger truncate mode — deliberately not fixed here, existing-file edits forbidden).

Run evidence (panels live in gitignored artifacts/refactor_baseline/)

  • 14/14 panels frozen; grid 1,158,912 (book) / 1,159,263 (minute) rows over CSI500 000905.SH 2021-07-01→2026-06-30, 996 symbols, 1210 trading days; 279M raw 1min rows read; stk_mins_live_calls=0 (raise-on-nonzero per factor), 10 daily endpoints gap-fetch all 0.
  • Reconciliation 11/11 against the frozen eval JSONs (panel_rows / evaluation_periods / symbols / dropped / nan_rate), executed before any panel is written — mismatch raises, nothing lands. Book factors have no coverage payload to reconcile against; disclosed honestly, evidenced instead by cross-process determinism + cross-run identical hashes + full-grid row identity.
  • Determinism double-run 3/3 (cross-process: fresh rebuild vs first-segment file contents).

Acceptance

  • Adversarial review: APPROVE — zero findings incl. LOW (first in this series). Reviewer independently: mirrored the recipe call sites parameter-by-parameter against the runners; traced the resume path for skip-verification gaps (none); programmatically compared all 14 manifest rows doc↔json; re-hashed 3 panels from disk; independent secret scan over 17 run files (0 hits).
  • Lead-independent: pytest 1902 passed (1879+23), ruff clean, phase0 anchor verbatim, 31/31 configs, branch purity verified, value_ep canonical hash recomputed from disk = manifest.

With this, step D1 is closed. Next: D2 (primitives + ops + factor migration — first math-touching step; provisional anchor freezes there after hand anchors pass).

qt/panel_freeze.py freezes the closing 14 factors' RAW daily panels (11
minute factors + the 3 book factors) on the eleven-factor evaluation data
plane (CSI500 000905.SH, 2021-07-01..2026-06-30, cache-only) as the pre-D2
baseline for the D5 cell-by-cell reconciliation. No factor math is
reimplemented: every panel is produced by calling the qt/eval_*.py runners'
own loader chains with the runners' own constants, imported from the runner
modules themselves; book factors go through _build_book_factors +
factor.compute on the enriched panel. The frozen value is raw
(pre-_process_factors).

The authoritative fingerprint is a canonical content hash (sha256 over the
sorted (date, symbol) index serialization + float64 raw bytes, NaN payloads
collapsed, +/-0.0 kept distinct) because parquet file bytes depend on writer
metadata; the file sha256 is recorded as a convenience only. Panels are
written atomically (tmp + os.replace). Built-in verification: per-factor
reconciliation of the processed boundary against the shipped
eval_*_no_book.json data_coverage payloads (mismatch raises, the panel is
never frozen), a determinism double-run (2 minute + 1 book subjects), a
zero-live-call assertion on every minute loader, and a --resume mode that
re-verifies existing panel files through the same processing +
reconciliation instead of trusting them.

Runs via python -m qt.panel_freeze (deliberately not registered in qt/cli).
tests/test_panel_freeze.py (23 network-free tests) pins the hash semantics
(value/index sensitivity paired with order/NaN-payload invariance), the
atomic-write failure paths, manifest field completeness, and the
reconciliation mismatch discipline.
…baseline

docs/factors/d1_panel_freeze_manifest.md is the git-tracked authority for
the frozen baseline: producing SHA 3669c90 (HEAD during both run segments;
the freeze tool ran as untracked files, so the tracked tree was
bit-identical to main), the data plane (CSI500 000905.SH,
2021-07-01..2026-06-30, cache-only, 10 daily endpoints at zero gap-fetches,
stk_mins_live_calls=0), the provenance rule (baseline regeneration only
from the pinned pre-D2 SHA, never from current code), the canonical-hash
definition pointer, the two-segment run record (first segment killed by the
session harness at ~60min after 12/14 panels; the resume segment re-verified
those panels from file content through processing + reconciliation), the
verification results (determinism double-run 3/3 across processes,
eval-artifact reconciliation 6 fields x 11 factors all equal, book factors
disclosed as having no coverage fields to reconcile, secret scan 0 hits),
and the full 14-row table with per-factor stats and both hashes.
@StackOverFlow11
StackOverFlow11 merged commit 1e6f408 into main Jul 24, 2026
StackOverFlow11 added a commit that referenced this pull request Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant