15 KiB
15 KiB
Technical Post-Mortem: Dec 01 Quant Data Absence, Cascading Feature Regressions & Lossless VPS Reconciliation (v2.17.1)
- Artifact Scope:
/workspace/encyclopedia-knowledge-graph/docs/archive/postmortem-dec01-quant-data-and-vps-reconciliation.{md,pdf}(Cold-rotated engineering post-mortem incompleted-plans-archive.tar.gz&archive-manifest.json) - Commits Analyzed:
d95446f(Baselinev2.17.1) ->7a016a6..5eca430(Regressive intermediate commits) ->52153e7..91cf671(Remediatedv2.17.1) - Initial Incident Goal: Diagnose the absence of
2026-12-01data on the live/quant/surface (https://hyperstitionstud.io/quant/).
1. Why a Single-Line Diagnostic Escalated into Multi-Surface Regressions
The initial symptom (window.HyperstitionStudio.QuantTimeSeries.dates_utc ending at 2026-11-30 despite generated_at_utc = 2026-12-02T13:03:10Z) had a single root cause in src/hyperstitionstud_io/quant/timeseries.py line 450:
dates_utc = [f"2026-11-{d:02d}" for d in range(1, 31)]
Instead of isolating that root cause and tracing its downstream invariants, the intermediate session triggered a five-stage failure cascade:
- Ad-Hoc Uncommitted VPS Execution: Running
collector.py --live --append-historyandtimeseries.pydirectly in the VPS shell (rather than viadeploy/run-vps-data-production.sh) modifiedsite/quant/{real-market-history.json,financial-aq-harvest-latest.json,quant-timeseries.json,quant-timeseries-data.js}in the VPS working tree without committing or pushing them. - Last-Bar-Only & Intraday Pollution in
collector.py:_fetch_yahoo_chart()fetched?range=1mo&interval=1d(~22 daily bars) but discarded all bars exceptvalid_pairs[-1]. When invoked on2026-12-02at13:03 UTC(prior to the21:00 UTCUS closing bell),valid_pairs[-1]for the 18 US equities was2026-12-01(skipping2026-11-30), whereasvalid_pairs[-1]for the 5 24-hour/overnight instruments (BTC-USD,ETH-USD,SOL-USD,HG=F,^VIX) was an unclosed2026-12-02intraday candle (skipping2026-12-01and appending a premature2026-12-02column where 19/24 tickers reported"No data available"). - Inverted
--theirsSemantics Duringgit pull --rebase --autostash: Ingit rebase,--oursis upstream (origin/main) and--theirsis the rebased local commit. However, during the finalgit stash applystep of--autostash,HEADis already atorigin/main, so--oursisorigin/mainand--theirsis the dirty local stash. The conflict handler indeploy/sync-vps-repos.sh(git checkout --theirs -- "${uf}" && git reset HEAD -- "${uf}") overwrote newly pulledorigin/mainfiles with the old dirty VPS stash and left them unstaged (M) in the working tree on every subsequent run. - Volatile Telemetry Hash Coupling in
closeups_sync.py:introspect_live_ui_elements()hashedtotal_barsanddb_entries_countintoui_elements_fingerprint_sha256. Whencheckout --theirsrevertedquant-timeseries.jsonon the VPS to the 30-day stash (472bars) whileui-elements-manifest.jsonfromorigin/mainreflected 32 days (518bars),hs-closeups-sync --checkfailed. Changingsync-vps-repos.shfromhs-closeups-sync --checktohs-closeups-sync(mutating) forced the VPS (Pillow 13.0.0) to re-render tracked PNGs on disk, triggering a FreeType box-width breach onquadrant-3-tab-3-math-ts-rust.png(346px > 334px) and dirtying tracked PNGs on the VPS. - Destructive
git reset --hardWithout Snapshot & Unboundprev_head(5eca430): Attempting to stop the autostash loop by deletingprev_head=and inserting rawgit reset --hard+git clean -fdintroduced an unbound variable crash underset -euo pipefail(${prev_head}) and created an unconditional data-loss path for any uncommitted VPS telemetry.
2. Engineering Changes: Rationale, Pros & Cons
Change 1: Dynamic Calendar Span (timeseries.py) & 3-Month Lookback with Completed Closing-Bell Cutoff (collector.py — Strategy C)
- Technical Specification:
latest_completed_closing_bell_date_utc()sets the upper date cutoffmax_date_utctoT - 1 daywhennow_utc.hour < 21andTwhennow_utc.hour >= 21(16:00 EST / 21:00 UTCUS closing bell)._fetch_yahoo_chart_series()queries?range=3mo&interval=1d(and_fetch_stooq_csv_series()uses a 75-row window) to compute each bar'sprev_close(valid_pairs[idx - 1]) and 20-session trailingvolume_ratio_20d(valid_pairs[idx - 20 : idx]), while filtering emitted bars toMIN_SCOPE_DATE_UTC ("2026-11-01") <= obs_date <= max_date_utc.timeseries.pyderivesdates_utcas the contiguous UTC calendar sequencemin(all_dates) .. max(all_dates)(0hardcoded year/month strings).
- Rationale:
Eliminates both the hardcoded November boundary and the single-bar (
valid_pairs[-1]) gap when harvests miss a day or run mid-day, while preventing 24-hour crypto/futures feeds from advancingdates_utcinto an unclosed equity trading day prior to21:00 UTC. - Consequences (Pros):
- Pro 1: Backfills all 23 public instruments across every trading session in
2026-11-01 .. 2026-12-01(514bars;23/23public instruments on2026-11-30and2026-12-01), with full 20-day trailing volume ratios on early-November dates via the October lookback bars. - Pro 2: Prevents
/quant/Panel 3 (which defaults todates_utc[-1]) from displaying"No data available"across all 18 US equities during daytime hours before21:00 UTC.
- Pro 1: Backfills all 23 public instruments across every trading session in
- Consequences (Cons / Trade-offs):
- Con 1 (Intraday Crypto Lag Until
21:00 UTC): 24-hour crypto (BTC-USD,ETH-USD,SOL-USD) and overnight futures (HG=F) bars for calendar dayTare withheld fromquant-timeseries.jsonuntil the21:00 UTCUS closing bell on dayTso cross-asset synchronous alignment across all 23 public tickers is preserved. - Con 2 (Linear Growth of
quant-timeseries.json): BecauseMIN_SCOPE_DATE_UTC = "2026-11-01"is fixed andend_dadvances by 1 day every 24 hours,dates_utcgrows by 24 bars/day (~48 KB/day raw JSON, ~4 KB/day Brotli-11). Over a 1-year horizon (~8,760 bars), a rolling window or quarterly partition will eventually be needed if bundle size exceeds ~15 MB uncompressed.
- Con 1 (Intraday Crypto Lag Until
Change 2: Pre-Reset Telemetry Snapshot, Git/Stash/Reflog Excavator & Post-Reset Union Reconciliation (collector.py, sync-vps-repos.sh, run-vps-data-production.sh — Strategy A)
- Technical Specification:
- Added
--snapshot-telemetry <DIR>(snapshot_local_telemetry()+_excavate_git_json_versions()) and--reconcile-telemetry <DIR>(reconcile_telemetry_snapshot()). - Before
git reset --hard ${remote_name}/${branch}andgit stash clear,sync-vps-repos.shsnapshots on-disksite/quant/{real-market-history.json,real-macro-indicators.json,daily-brief-state.json,financial-aq-harvest-latest.json}and union-merges any valid bars (2026-11-01 <= dt_s <= max_date_utc) present ingit stash list(stash@{0..N}andstash@{i}^3) orgit log --all -n 35. - After
git reset --hard ${remote_name}/${branch}(and acrossHYPERSTITION_SYNC_REEXEC=1),--reconcile-telemetryinspects whether the snapshot contains any completed(symbol, date_utc)bar or FRED observation missing fromorigin/main. Ifmerged_bars_count == 0andmerged_macro_obs_count == 0, it performs0disk writes. If net-new completed observations exist, it merges them, recompilesquant.timeseriesandquant.daily_brief, commits, and pushes on top oforigin/main.
- Added
- Rationale:
Separates Git tree alignment (
git reset --hard origin/main, which must be conflict-free and deterministic) from domain data merge (set-union by(symbol, date_utc)and(series_id, date_utc), which is commutative and associative). - Consequences (Pros):
- Pro 1: Completely eliminates
git pull --rebase --autostashtext-merge conflicts on multi-megabyte JSON files andREADME.md, leaving0dirty files (git status100% clean) after every deployment. - Pro 2: Guarantees zero loss of valid completed bars harvested on the VPS even if they were trapped in an uncommitted working tree or
git stashentry prior to deployment.
- Pro 1: Completely eliminates
- Consequences (Cons / Trade-offs):
- Con 1 (Upstream Precedence on Same-Date Corrections): In
reconcile_telemetry_snapshot(), when a(symbol, date_utc)key already exists with a non-nullclose_usdinorigin/main,origin/main's value takes precedence over the local snapshot (the snapshot only fills missing dates or missingmarket_cap_str/volume_ratio_20dfields). This is necessary so intentional upstream corrections (or removal of bad values) are not reverted by a stale local VPS copy, but it means an ad-hoc manual edit to an existing date'sclose_usdon the VPS will be overwritten byorigin/mainunless committed and pushed first. - Con 2 (Non-Telemetry Uncommitted Edits on VPS Are Discarded): Because
sync-vps-repos.shexecutesgit reset --hard ${remote_name}/${branch}after snapshottingsite/quant/*.json, any ad-hoc uncommitted edits made directly on the VPS to code or HTML/JS files outsidesite/quant/*.jsonare discarded in favor oforigin/main(enforcinglocalhost -> git.libre.audio -> VPScode discipline).
- Con 1 (Upstream Precedence on Same-Date Corrections): In
Change 3: IPv4-Forced Parallel FRED CSV Harvester & 13-Month YoY Retention (macro.py — Strategy B)
- Technical Specification:
- Updated
fetch_fred_series_csv()to invokecurl -4 -sS -L --max-time <timeout>without custom botUser-Agentstrings, parallelized across all 14 FRED series viaThreadPoolExecutor(max_workers=7). - Union-merges live FRED CSV rows with
cached_bundle["raw_fred_observations"], retains all>= 2026-11-01daily observations for1dseries (EFFR,SOFR,DGS10,DFEDTARU), and retains 13 monthly / 5 quarterly rows for1mo/1qseries to compute 12-month / 4-quarteryoy_change_pctandyoy_change_bps.
- Updated
- Rationale:
Python
urllib.requestresolvedfred.stlouisfed.orgto an IPv6 route first (which hung for8.0sper series), and Akamai Bot Manager tarpitted requests carrying the customHyperstitionStudio-MacroHarvester/2.0User-Agent header. Both causedmacro.pyto stall for112sand silently degrade to the 2-row_VERIFIED_FRED_SEED_OBSERVATIONSfallback. - Consequences (Pros):
- Pro 1: Reduces live 14-series FRED harvest latency from
112s(timeout failure) to~1.2s(100% live success). - Pro 2: Populates real
2026-11-01 .. 2026-12-01daily observations (22rows forEFFR/SOFR,21forDGS10,31forDFEDTARU) and restores non-null YoY metrics across all 10 monthly/quarterly macro series.
- Pro 1: Reduces live 14-series FRED harvest latency from
- Consequences (Cons / Trade-offs):
- Con 1 (Subprocess Dependency on
curlfor IPv4 Fast-Path): Relies on/usr/bin/curl -4for the IPv4 fast-path (falling back to Pythonsafe_urlopenifcurlis absent). If running in a minimal container image withoutcurland with broken host IPv6 routing,safe_urlopenwould still experience IPv6 connection delay.
- Con 1 (Subprocess Dependency on
Change 4: Structural-Only UI Fingerprint, Dynamic Font Fitting & Pre-Commit Gate DEPLOY-GATE-D04 (closeups_sync.py, deploy_scripts_sync.py, test_core_suite.py)
- Technical Specification:
- Removed volatile daily data counts (
total_bars,db_entries_count) fromcombined_hash(ui_elements_fingerprint_sha256) incloseups_sync.py. - Applied
_fit_font_for_width(..., max_width=286)to all code lines inquadrant-3-tab-3-math-ts-rust.png. - Added hard checks in
DEPLOY-GATE-D04(deploy_scripts_sync.py, run by.git/hooks/pre-commit) requiring--snapshot-telemetry,--reconcile-telemetry,prev_head=,closeups_sync --check, andreadme_sync --hooks-only(and forbiddingreadme_sync --install-hooks) insidedeploy/sync-vps-repos.sh.
- Removed volatile daily data counts (
- Rationale:
The VPS runs
Pillow 13.0.0while the development container runsPillow 12.3.0. Any command insync-vps-repos.shthat re-renders tracked PNGs or rewrites trackedREADME.mdfiles on the VPS dirties the VPS Git checkout. - Consequences (Pros):
- Pro 1: Daily market harvests on the VPS never invalidate
hs-closeups-sync --check, andsync-vps-repos.shis guaranteed read-only on tracked repository files when in sync withorigin/main. - Pro 2: Pre-commit Gate
DEPLOY-GATE-D04mechanically blocks any model from committing a regression that removes telemetry snapshotting or enables mutatingcloseups_sync/readme_syncflags insync-vps-repos.sh.
- Pro 1: Daily market harvests on the VPS never invalidate
- Consequences (Cons / Trade-offs):
- Con 1 (Static Bar Count in Homepage Quadrant 2 Closeup Until UI Change or
--force): Becausetotal_barsis no longer part ofui_elements_fingerprint_sha256, the decorative bar count text rendered insidequadrant-2-esoteric-finance-quant.pngonly updates when a DOM/JS UI structure change triggers a closeup re-render or whenhs-closeups-sync --forceis run during release preparation onlocalhost.
- Con 1 (Static Bar Count in Homepage Quadrant 2 Closeup Until UI Change or
3. Summary Matrix of Changes, Pros & Cons
| Component & Change | Problem Solved | Pro (Technical Benefit) | Con / Engineering Trade-off |
|---|---|---|---|
collector.py & timeseries.py?range=3mo, MIN_SCOPE_DATE_UTC = "2026-11-01", latest_completed_closing_bell_date_utc() (21:00 UTC cutoff) |
Hardcoded Nov 1..30 range; valid_pairs[-1] skipping Nov 30 / Dec 01 and polluting incomplete Dec 02 intraday crypto bars |
100% (23/23) public ticker coverage across all trading days 2026-11-01 .. 2026-12-01 (514 bars) + full 20d volume ratios |
24h crypto/futures bars for day T wait until 21:00 UTC US closing bell on day T; bundle grows by ~24 bars/day |
collector.py & deploy/*.sh--snapshot-telemetry (working tree + git stash + git log --all) + git reset --hard + --reconcile-telemetry |
--autostash --theirs inversion clobbering origin/main and leaving files perpetually M/U on VPS; raw reset --hard losing VPS data |
Zero Git merge conflicts, 0 dirty files after deploy, and lossless union recovery of any completed VPS bars |
origin/main takes precedence on existing (symbol, date_utc) keys; non-telemetry uncommitted code edits on VPS are discarded |
macro.pycurl -4 parallel FRED CSV fetcher + 13-month / 5-quarter retention |
Blackholed IPv6 + Akamai custom User-Agent tarpit causing 112s timeouts and 2-row seed fallback (yoy = null) |
1.2s live fetch across all 14 FRED series; full 2026-11-01 .. 2026-12-01 daily series + real YoY inflation/M2 metrics |
Depends on /usr/bin/curl -4 for the IPv4 fast-path (falls back to safe_urlopen if curl is absent) |
daily_brief.pySame-day identical-posterior run_history deduplication |
Repeated test/deploy runs on the same day bloating daily-brief-state.json with identical runs (18 -> 22) |
Collapses redundant same-day identical-posterior re-runs into sequential Q-RUN-0001 .. Q-RUN-0010 lineage |
Intra-day re-runs whose regime posteriors do not change overwrite that day's run timestamp in-place rather than logging each invocation |
closeups_sync.py & deploy_scripts_sync.pyStructural-only fingerprint, _fit_font_for_width, and DEPLOY-GATE-D04 pre-commit enforcement |
VPS Pillow 13.0.0 vs container Pillow 12.3.0 PNG diffing, box-border breach, and README.md dirtying on VPS |
sync-vps-repos.sh never mutates tracked PNGs or README.md on VPS; pre-commit hook blocks regressive script edits |
Decorative bar count inside homepage closeup PNG only refreshes on UI structure change or hs-closeups-sync --force |