Repository navigation
fix(cost,#8955): migrate hmm_alpha cost frontmatter->metadata (malformed frontmatter, one-shot) - #8973
Conversation
…strip Residual of #8955: the 34th cost-divergent notebook (the only non-QC one), hmm_alpha_research.ipynb (ML-Training). My #8966 migration script SKIPPED it (parse_frontmatter returned None) because its cell#0 frontmatter is MALFORMED -- it opens with '---' but is NEVER closed by a '---' (a blank line then the H1 follow directly), so the regex over-matches into the prose and yaml.safe_load fails. Migrated one-shot (extending the parser for malformed YAML would be disproportionate for 1 notebook). Defect (firsthand on origin/main 2d0858f): the curated cell#0 frontmatter cost (dated 2026-07-23) carried cpu_min=90, reproducibility=MEDIUM, free_alternative=null -- the real measured values for a 27-cell research notebook. The metadata.cost scan-skeleton (dated 2026-07-29, 6 days LATER) flattened them to cpu_min=8, reproducibility=HIGH, free_alternative='self'. Same regression class as the 23 QC quantbooks fixed by #8966: the skeleton shadowed the curated values. _cost_equivalent flagged [cpu_min, reproducibility]. Fix: merged = {**metadata_cost, **frontmatter_cost} (frontmatter wins on overlap; metadata keeps notes + qcc_tokens_est + vram_*), then strip the malformed frontmatter block (lines 1-14 + trailing blank), leaving the H1 to start cell#0. metadata_written refreshed to the curated 2026-07-23T01:30Z. Verification (firsthand, all canonical tools post-apply): - byte_stable_baseline=True, field_equivalent=True, minimal_diff=True. - detect_markdown_rendering: 0 violations (frontmatter_rawyaml resolved). - check_cost_metadata: 0 findings, cost_source=metadata canonical, notes preserved. - _cost_equivalent: cell#0 no longer has a frontmatter -> no divergence. - notebook_tools validate: 0 errors (1 warning PRE-EXISTING on origin/main, unchanged by this edit -- markdown-only cell#0 + metadata.cost touched). - nbformat 4.5, 65 cells unchanged, cell#0 source list format preserved. - Diff +4/-19, 1 file; catalogue byte-identical to main. NOT Closes #8955 (G.9): firsthand measure on this branch finds 10 ML-* quantbooks (ML-Classification, ML-DeepLearning, ML-EnhancedPairs, ...) STILL cost-divergent -- #8908 (po-2026) appears to have stripped frontmatter without migrating the cost (same regression class as my reverted #8959/#8963). They are reusable via 'migrate_cost_frontmatter_to_metadata.py --project ML-*' (#8966 script) once the turf is clear. Signaled for the coordinator. See #8955, #8904, #8056, #8966. Co-Authored-By: Claude-Code <noreply@anthropic.com>
Golden-Set Execution (H.7 P3)✅ 8/8 notebooks passed (certified reproducible)
Pinned lockfile: |
Notebook PR Validation: PASS
Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns) |
jsboige
left a comment
There was a problem hiding this comment.
[Hermes] Metadata migration reviewed: frontmatter values → notebook metadata verified field-by-field. All 11 fields preserve their source values (cpu_min 90, reproducibility MEDIUM, free_alternative null, metadata_written 2026-07-23T01:30Z). No data loss. free_alternative: "self" → null is correct for a zero-cost notebook (redundant self-reference). Golden-set 8/8 passed. LGTM.
Resolve conflict with #8973 (cost frontmatter->metadata migration merged on main after this branch's base). The re-exec in f9e3108 regenerated cell#0 with the old YAML frontmatter that #8973 had stripped; this merge takes main's stripped cell#0 + enriched metadata.cost (cpu_min 90, reproducibility MEDIUM) and preserves the §D.5 markdown alignment (md#20 log-likelihood -5447.51, md#28 Sharpe 0.697 / B&H 0.735 / return 167.7%). Re-executed end-to-end on the merged base (papermill, kernel python3, hmmlearn, 65/65 cells, exit 0) to confirm determinism on the new base: log-likelihood -5447.51, Sharpe 0.697, B&H 0.735, return 167.7% -- identical to the prior run (random_state=42 on every GaussianHMM + np.random.seed(42)), confirming the markdown is sourced by the deterministic outputs. C.1/C.2: 27 code cells, 0 execution_count=None, 0 errors, 0 forbidden. Catalogue byte-identical to main. Co-Authored-By: Claude-Code <noreply@anthropic.com>
Grain: MED/data — lane myia-po-2023:CoursIA — prev: MED/tooling #8972 (CLEAN/MERGEABLE) · MED/qc #8966 (MERGED)
Residual of #8955: the 34th cost-divergent notebook — the only non-QC
one —
hmm_alpha_research.ipynb(ML-Training). This is my own flaggedresidual from #8966 (I excluded it rather than risk a regression on
ML-Training turf).
The defect (#8955, firsthand on origin/main
2d0858f1d)Same regression class as the 23 QC quantbooks fixed by #8966: the
metadata.costscan-skeleton (dated 2026-07-29) flattened the curated cell#0 frontmatter
cost (dated 2026-07-23, 6 days earlier):
cpu_minreproducibilityfree_alternativemetadata_written_cost_equivalentflagged[cpu_min, reproducibility].Why #8966's script skipped it (the malformed frontmatter)
migrate_cost_frontmatter_to_metadata.pyreturnedskip-already-migratedbecause
parse_frontmatterreturnedNone: the cell#0 frontmatter ismalformed — it opens with
---but is never closed by a---(a blankline then the
# H1follow directly). The_FRONTMATTER_REregex over-matchesinto the prose (up to the first section
---divider),yaml.safe_loadfailson the mixed YAML+markdown, and the parser bails. Migrated one-shot
(extending the parser for malformed YAML would be disproportionate for 1
notebook; documented here for recurrence).
The fix
merged = {**metadata_cost, **frontmatter_cost}(frontmatter wins on overlap;metadata keeps
notes,qcc_tokens_est,vram_*,gpu_min), then strip themalformed frontmatter block (lines 1–14 + trailing blank), leaving the H1 to
start cell#0.
metadata.costcarries the curated values;metadata_writtenrefreshes to the curated timestamp.
Verification (firsthand, all canonical tools post-apply)
(only cell#0 source + metadata.cost differ; the rest is structurally identical).
detect_markdown_rendering: 0 violations (frontmatter_rawyamlresolved).check_cost_metadata: 0 findings,cost_source=metadatacanonical,notespreserved._cost_equivalent: cell#0 no longer has a frontmatter → no divergence.notebook_tools validate: 0 errors (1 warning PRE-EXISTING onorigin/main, unchanged by this edit — markdown-only cell#0 + metadata.costtouched, no code cell affected).
sourcelist format preserved.NOT
Closes #8955(G.9 — would close an issue still open)Firsthand measure on this branch (
_cost_equivalentover all notebooks) finds10 ML- quantbooks STILL cost-divergent* —
ML-Classification,ML-DeepLearning,ML-EnhancedPairs,ML-Ensemble,ML-FeatureEngineering,ML-RandomForest,ML-Regression,ML-SVM,ML-TextClassification,ML-XGBoost(all[cpu_min, reduced_pedagogical, reproducibility]).These are the turf of #8908 (jsboige, OPEN, CHANGES_REQUESTED) — ai-01 AND
the author himself have already identified the strip-only defect there
(
No markdown content lossFAILURE per notebook: stripping the frontmatterloses the curated cost values, the SAME regression class as my reverted
#8959/#8963 and the subject of issue #8955 itself). The author has designated
#8908 the consolidation vehicle for the 33 QC notebooks. They are reusable
via
migrate_cost_frontmatter_to_metadata.py --project ML-*(#8966 script)should the migration be folded into #8908. This PR resolves hmm_alpha (the 1
non-QC divergent) only — it does not touch the ML-* (active turf, #8908).
See #8955, #8904, #8056, #8966.
Co-Authored-By: Claude-Code noreply@anthropic.com