Skip to content

feat(ci): systematic markdown-rendering guard (frontmatter/setext + plural hint fix) - #8352

Merged
jsboige merged 1 commit into
mainfrom
feature/markdown-rendering-guard
Jul 24, 2026
Merged

jsboige merged 1 commit into
mainfrom
feature/markdown-rendering-guard

Conversation

@jsboige

@jsboige jsboige commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Systematic CI guard for markdown-rendering defects

Agents reviewing or creating notebooks cannot render markdown in their heads, so a whole class of rendering regressions ships to main unseen: they look fine in a source diff but render as ugly, title-sized unformatted text blocks on the very first open. Two families have repeatedly slipped through:

  1. Cost / YAML frontmatter dumped into a rendered markdown cell (---\ntitle:...\ncost:\n api_usd_est: 0.00\n---). markdown-it (VSCode / JupyterLab / nbviewer) treats the leading --- as <hr>, joins every key: value line into one run-on paragraph, and — because the closing --- directly follows a text line with no blank line — parses it as a setext H2, promoting the entire YAML block to one oversized heading. Exemplar: the cell-header pattern of epic [#4208] Matrice coût/ressource par notebook (API $ / CPU / GPU / VRAM / compte externe / alternative gratuite) #8056 (PR refactor(infer,#8056): convert Infer-3/4 cost frontmatter to metadata.cost (canonical form, #8323 exemplar of #8056) #8323).
  2. Oversized hints/asides: Indice / Astuce / Conseil / Piste written as an #/##/### heading, rendering larger than the notebook title — the same defect the [EPIC] Mise en forme visuelle des notebooks — verification de rendu + directives #3966/[mise-en-forme] Hierarchie typographique: indices/objectifs en grande police -> normaliser (261 notebooks) #3968 campaign targeted.

This PR builds the systematic comb the user mandated ("un script pour passer au peigne fin tous ces pbs de formatting sans attendre qu'un agent finisse par lire chacun des 800+ notebooks"), so we stop bailing the sea with a spoon.

What's in it

scripts/notebook_tools/detect_markdown_rendering.py (new) — the hard gate. Deterministically scans all ~960 notebooks for:

  • frontmatter_supersize (ERROR) — YAML frontmatter promoted to a setext-H2 supersize block;
  • frontmatter_rawyaml (ERROR) — frontmatter dumped as raw unformatted text;
  • setext_oversized (ERROR) — prose paragraph accidentally underlined by ---/===;
  • oversized_hint (WARN) — hint keyword as a heading.

Baselined exactly like gitleaks / pip-leak-guard: the corpus already carries 482 pre-existing violations, so --check --baseline fails a PR only on NEW error-level ones (hashes are content-stable across cell reordering). Burn the baseline down with --update-baseline after each remediation batch.

scripts/notebook_tools/scan_md_hierarchy.py (fix) — the existing typographic-hierarchy tool had a plural-blind regex: indice\b cannot match Indices (the s is inside the word, no boundary), and every stem had the same bug. Result: it reported 0 hint-headings while 218 plural-form hint headings across 127 notebooks survived uncaught — which is why the #3968 "scanner reports 0" acceptance criterion was vacuously satisfied and the user still saw broken notebooks after the campaign "closed". Fixed by making every stem optionally-plural (indices?, astuces?, conseils?, pistes?, …) and pluralising the matching RAPPEL_REFERENCE_RE exclusion in parallel. All existing FP-exclusions (titled steps, hyphenated compounds, rappel-references) verified intact by unit test.

.github/workflows/markdown-rendering-guard.yml (new) — runs the detector as a blocking gate on new frontmatter/setext ERRORs + scan_md_hierarchy.py as an informational hint/collapsed/H1 census.

.pre-commit-config.yaml (hook) — same detect_markdown_rendering.py --check --baseline gate locally, whole-tree scan when any notebook is staged.

Verification (firsthand)

  • Detector --check --baseline on current main: OK, 0 new ERROR.
  • Detector on the refactor(infer,#8056): convert Infer-3/4 cost frontmatter to metadata.cost (canonical form, #8323 exemplar of #8056) #8323 branch's Infer-3-Factor-Graphs.ipynb: FAIL — 1 new frontmatter_supersize at cell#1 (title: "Infer-3 : Graphes de Facteurs..."). The guard would have blocked exactly the cell the user flagged.
  • scan_md_hierarchy.py after fix: 0 → 218 HINT-AS-HEADING lines, 127/960 notebooks; exclusion unit test passes (Indices/Astuces/Conseils/Pistes flagged; Étape 3 : Installation, Aide-mémoire, Step recursif, Rappel/Rappels ICT-10, Objectifs pédagogiques NOT flagged).

Scope / follow-up

See #8056, #3966.

🤖 Generated with Claude Code

…rsize + plural hint fix)

Agents cannot render markdown in their heads, so cost-frontmatter blocks
(#8323, epic #8056) and oversized exercise hints (#3966) ship to main
unseen -- fine in a source diff, ugly title-sized text on first open.

- detect_markdown_rendering.py (new): baselined hard gate for YAML
  frontmatter dumped into a rendered cell (setext-H2 supersize) + accidental
  setext-oversized prose. --check --baseline fails only on NEW error-level
  violations (content-stable hashes); baseline = 482 pre-existing.
- scan_md_hierarchy.py (fix): plural-blind regex ("indice\b" cannot match
  "Indices") made it report 0 hint-headings while 218 lines / 127 notebooks
  survived -- the vacuous #3968 "scanner reports 0" closure. Every stem now
  optionally-plural; RAPPEL_REFERENCE_RE pluralised in parallel; exclusions
  (titled-step, compound, rappel-ref) verified intact.
- markdown-rendering-guard.yml (new): detector as blocking gate + hierarchy
  census (report-only).
- pre-commit hook: same --check --baseline gate locally.

Verified: detector OK/0-new on main; FAILs #8323 Infer-3 cell#1
(frontmatter_supersize); scanner 0->218 hints; exclusion unit test green.

See #8056, #3966.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@clusterManager-Myia clusterManager-Myia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NanoClaw] structural review (glm-5.2, COMMENT-only per self-review cap)

PR #8352 — feat(ci): systematic markdown-rendering guard (frontmatter/setext + plural hint fix)
head 883fe89004 · base d4bc196c · +958/-6 · 5 files (1 new workflow + 1 new detector + 1 baseline JSON + 1 detector-fix in scan_md_hierarchy + 1 pre-commit hook) · author jsboige (≠ my identity → 0 self-review conflict)

This is exactly the systematic comb the user mandated — catches the rendering-regression class that source-diff review is blind to (frontmatter/setext cells look fine in a diff but render as title-sized text on open). Closes the root cause of defects I've flagged manually (#8323 cell-header, the #3966/#8056 hint-heading campaigns).

1. The load-bearing bug fix is REAL and CORRECT (scan_md_hierarchy.py plural-blind regex) — verified firsthand at L38-40 / L62-63 : the old \bindice\b FAILED to match Indices (the trailing \b breaks after the singular stem when an s follows → word-boundary mismatch), so the scanner reported 0 hint-headings while 218 across 127 notebooks survived uncaught. This is why #3968's "scanner reports 0" acceptance criterion was vacuously satisfied and the user still saw broken notebooks after the campaign "closed". Fix = every stem optionally-plural (indices?|astuces?|conseils?|pistes?|hints?|tips?|...), applied identically to the COMPOUND_HINT_RE. In-code comment L31-37 documents the WHY precisely. Genuine root-cause fix.

2. Detector logic is sound (detect_markdown_rendering.py), CommonMark-correct :

  • _frontmatter_supersizes requires the setext underline's immediately-preceding line to be non-blank text (a blank line → thematic break, renders fine) — matches CommonMark setext spec ✓
  • _cell_hash = sha1(rule\0normalized-source) → content-stable across cell reordering ✓ (so the baseline survives notebook re-runs that renumber cells)
  • Exit logic correct : --check fails only on NEW (hash ∉ baseline) ERROR-severity findings ; oversized_hint is WARN-only → never blocks, informational ✓
  • Setext paragraph-gather has correct bounds (p-1 >= 0) ✓ ; frontmatter returns early to avoid double-reporting ✓

3. Baseline is well-formed (markdown_rendering_baseline.json, 11812B) : 482 hashes, count field matches hashes.length, all 482 are 16-char hex matching _cell_hash output, "burn down, do not grow" comment + regenerate command. Internally consistent, not fabricated.

4. PR body verification is credible (spot-checkable claims) : detector blocked exactly the #8323 cell the user flagged (frontmatter_supersize at cell#1 Infer-3) ; post-fix scan_md_hierarchy reports the 218 it previously missed. These are reproducible firsthand.

Scan : 0 secret (sk-/ghp_/AKIA). The 2 C:\Users\<user> hits in .pre-commit-config.yaml (L39/L55) are placeholders (<user> literal) in a leak-scrubbing hook's documentation text — benign, not real paths. 0 CJK (HARD RULE respectée).

△ Nits (non-bloquants) :

  1. Docstring/body count drift : detector docstring says "~520 pre-existing frontmatter violations" while the committed baseline is 482 (the 482 = all rules incl. WARN oversized_hint, the ~520 was a frontmatter-only estimate). Minor — recommend aligning the docstring to the real count field (482) to avoid future confusion.
  2. Detector vs scan_md keyword-set divergence is intentional but undocumented in the detector : the detector's _HINT_RE is deliberately narrow (6 stems) while scan_md_hierarchy.py's HINT_RE is broad (15+ stems incl. conseils/pistes/notes). The body documents the narrow detector choice ("Deliberately NOT note/remarque"), but a one-line cross-reference in the detector would help maintainers understand why the two tools report different WARN counts.

Conclusion : LGTM deep. Substantive CI hardening that closes a real vacuous-acceptance gap (the #3968 scanner-blind-spot) and prevents a whole class of rendering defects from shipping unseen. The plural-regex fix alone (catching 218 previously-hidden violations) justifies the PR. Baseline discipline mirrors gitleaks correctly. The two nits are cosmetic (docstring count + cross-reference).

— NanoClaw (myia-ai-01) [structural review]

@jsboige
jsboige merged commit 5657edb into main Jul 24, 2026
11 checks passed
myia-po-2023 pushed a commit that referenced this pull request Jul 24, 2026
…ost JSON (#8323 exemplar)

Per ai-01 design-gate #8056 (DM msg-20260724T145315): the canonical machine-readable
cost matrix lives in nb.metadata['cost'] (JSON, invisible), NOT as a rendered `---`-YAML
markdown cell. The previous costfm-frontmatter cell (`---\ntitle:...\ncost:\n...\n---`)
renders as a setext-H2 supersize block in markdown-it (guard #8352 ERROR). Moving cost
to metadata.cost makes it invisible to any markdown renderer -> guard-clean by construction.

This makes Infer-3 / Infer-4 the REFERENCE EXEMPLAR of the new canonical form. PR A
(parser check_cost_metadata.py reads metadata.cost first, cell-fallback backward-compat)
lands from po-2025; PR C (mass migration by family tranches) follows. The order is not
blocking: metadata.cost is already valid JSON, so a cell-fallback parser still finds it.

Reformat (per notebook, byte-stable):
1. Parsed the costfm-frontmatter cell source as YAML -> extracted cost dict + notes.
   (PyYAML coerces `last_validated: 2026-07-24` to a date -> written back as ISO string.)
2. Removed the costfm-frontmatter markdown cell.
3. Added nb.metadata['cost'] = cost dict (15 fields; notes preserved w/ reproducibility
   timing; title dropped as redundant w/ the H1 cell heading).
4. Serialized via json.dumps(indent=1, ensure_ascii=False) + trailing newline -- VERIFIED
   byte-identical round-trip for BOTH notebooks before applying (so the ONLY bytes that
   change are the cell removal + metadata.cost addition).

Pure metadata reformat: zero code-cell source or output touched (C.2 markdown-exception;
the script's cell-by-cell byte-identity assertion confirms every remaining cell is
unchanged). No re-execution needed -- execution_count + outputs of all 35 code cells are
byte-identical to origin.

Validation (proven 4 ways):
- H.3 validate_pr_notebooks.py vs origin/main: PASS 2/2 (Infer-3 15 cells, Infer-4 20
  code cells, .net-csharp). All 35 code cells carry execution_count != null + outputs.
- nbformat VALID (nbformat.validate, errors=None): Infer-3 53 cells, Infer-4 66 cells.
- Leak scanner (audit_solution_leaks.py, 942 NBs): Infer-3 and Infer-4 NOT in the 226
  flagged notebooks -- clean.
- No `---`-frontmatter markdown cell remains (the guard target is gone). The 9 markdown
  cells starting with `---` are pre-existing horizontal-rule separators (`---` + blank
  line + heading = <hr>), not setext-H2 traps, and are byte-identical to origin.

Diff: -57/+34 (net negative: verbose YAML cell -> compact JSON metadata block).

See #8056 (cost-matrix design-gate), #8352 (markdown-rendering guard), #8323 (this PR).
See #8081 (audit fidelite Probas/Infer.NET) -- these notebooks are FIDELE (Infer-3 factor
graphs + Infer-4 bayesian nets demonstrated on real Infer.NET EP).

Co-Authored-By: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
….cost (canonical form, #8323 exemplar of #8056) (#8323)

* feat(probas,#8056): cost frontmatter on Infer-3/4 (Infer.NET local profile)

Add cost/resource YAML frontmatter to Infer-3-Factor-Graphs and
Infer-4-Bayesian-Networks (.NET Infer.NET, standalone non-twin notebooks;
Infer.NET series is outside twin_pairs.yaml -- no parity risk).

Cost profile firsthand-derived + measured: local CPU (Infer.NET EP/VMP),
api_usd_est=0.00, gpu_required=false, vram_tier=NONE, reproducibility=HIGH
(deterministic EP/VMP on hardcoded data). Re-exec papermill 2026-07-24:
Infer-3 16s, Infer-4 24s, both EXIT=0 clean -- last_validated reflects this.

Markdown-only (C.2 exception): frontmatter cell at index 1 via raw-byte
splice (byte-stable, 0 churn on existing cells/outputs).

Infer-2-Gaussian-Mixtures excluded: pre-existing nbformat id=None on
cell[84] (origin/main) makes batch H.3 validator skip it -- separate
concern, signaled for dedicated cleanup.

See #8056 (partial: 2 notebooks toward Probas/Infer cost matrix)
See #4208 (publication open-courseware)
variation-protocol: LIGHT (metadata), 1/lane/jour cap respected

Co-Authored-By: Claude-Code <noreply@anthropic.com>

* refactor(infer,#8056): convert Infer-3/4 cost YAML cell -> metadata.cost JSON (#8323 exemplar)

Per ai-01 design-gate #8056 (DM msg-20260724T145315): the canonical machine-readable
cost matrix lives in nb.metadata['cost'] (JSON, invisible), NOT as a rendered `---`-YAML
markdown cell. The previous costfm-frontmatter cell (`---\ntitle:...\ncost:\n...\n---`)
renders as a setext-H2 supersize block in markdown-it (guard #8352 ERROR). Moving cost
to metadata.cost makes it invisible to any markdown renderer -> guard-clean by construction.

This makes Infer-3 / Infer-4 the REFERENCE EXEMPLAR of the new canonical form. PR A
(parser check_cost_metadata.py reads metadata.cost first, cell-fallback backward-compat)
lands from po-2025; PR C (mass migration by family tranches) follows. The order is not
blocking: metadata.cost is already valid JSON, so a cell-fallback parser still finds it.

Reformat (per notebook, byte-stable):
1. Parsed the costfm-frontmatter cell source as YAML -> extracted cost dict + notes.
   (PyYAML coerces `last_validated: 2026-07-24` to a date -> written back as ISO string.)
2. Removed the costfm-frontmatter markdown cell.
3. Added nb.metadata['cost'] = cost dict (15 fields; notes preserved w/ reproducibility
   timing; title dropped as redundant w/ the H1 cell heading).
4. Serialized via json.dumps(indent=1, ensure_ascii=False) + trailing newline -- VERIFIED
   byte-identical round-trip for BOTH notebooks before applying (so the ONLY bytes that
   change are the cell removal + metadata.cost addition).

Pure metadata reformat: zero code-cell source or output touched (C.2 markdown-exception;
the script's cell-by-cell byte-identity assertion confirms every remaining cell is
unchanged). No re-execution needed -- execution_count + outputs of all 35 code cells are
byte-identical to origin.

Validation (proven 4 ways):
- H.3 validate_pr_notebooks.py vs origin/main: PASS 2/2 (Infer-3 15 cells, Infer-4 20
  code cells, .net-csharp). All 35 code cells carry execution_count != null + outputs.
- nbformat VALID (nbformat.validate, errors=None): Infer-3 53 cells, Infer-4 66 cells.
- Leak scanner (audit_solution_leaks.py, 942 NBs): Infer-3 and Infer-4 NOT in the 226
  flagged notebooks -- clean.
- No `---`-frontmatter markdown cell remains (the guard target is gone). The 9 markdown
  cells starting with `---` are pre-existing horizontal-rule separators (`---` + blank
  line + heading = <hr>), not setext-H2 traps, and are byte-identical to origin.

Diff: -57/+34 (net negative: verbose YAML cell -> compact JSON metadata block).

See #8056 (cost-matrix design-gate), #8352 (markdown-rendering guard), #8323 (this PR).
See #8081 (audit fidelite Probas/Infer.NET) -- these notebooks are FIDELE (Infer-3 factor
graphs + Infer-4 bayesian nets demonstrated on real Infer.NET EP).

Co-Authored-By: Claude-Code <noreply@anthropic.com>

---------

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…anonical) + doc PR A (#8376)

* feat(tooling,#8056): check_cost_metadata reads metadata.cost first (canonical), fallback cell-scan (legacy)

* docs(cost-matrix,#8056): designate metadata.cost JSON canonical, retire ---YAML cell from mandate

Rewrites docs/notebook-metadata/cost-matrix.md per #8056 design-gate c.866:
- Schema section: canonical = nb.metadata['cost'] (JSON, invisible to markdown
  render); the ---YAML markdown cell is RETIRED from the mandate (markdown-it
  promotes it to setext-H2 supersize, guard #8352 blocks ERROR).
- Drop redundant title field (H1 of notebook suffices) from mandatory table.
- Pilot examples: clarifying note — YAML used only for inline-comment readability
  (JSON is comment-free); field VALUES identical, storage = metadata['cost'].
- Student-facing cost disclosure = OPTIONAL (md badge, never raw YAML).
- Update #8052 litmus + acceptance criterion 1 + sortie-attendue references.

Pairs with the validator change (900f5fb27) which reads metadata.cost first,
falls back to cell-scan. Exemplar #8323 (Infer-3/4). See #8056.

Co-Authored-By: Claude-Code <noreply@anthropic.com>

---------

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
myia-po-2023 pushed a commit that referenced this pull request Jul 24, 2026
…nonical), fixes #8352 guard

Resolves the markdown-rendering guard (#8352) failure on #8378. cell#0 carried a
`---`-YAML frontmatter (title + cost + notes) that markdown-it promotes to
setext-H2 supersize = ERROR-level guard violation. The frontmatter was pre-existing
legacy; the #8378 notes edit triggered the guard to re-evaluate cell#0.

Fix per merged #8376 design-gate (canonical = nb.metadata['cost']):
- Migrate `cost:` -> nb.metadata['cost'] (invisible JSON, all values preserved).
- Drop redundant `title` (H1 `# 10. Hébergement Local...` already exists in cell#0).
- Merge top-level `notes` into cost.notes (canonical placement per #8323/#8376).
- Remove the entire `---...---` block from cell#0 source.

Validation: detect_markdown_rendering.py --check --baseline = OK (exit 0, no new
ERROR-level violations). Cross-tool: check_cost_metadata.py reads cost_source:
'metadata'. 0 code cells modified -> no re-exec (C.2 N/A; metadata + markdown-only).
byte-delta -737 (verbose YAML w/ comments -> compact JSON).

See #8369 · See #8056 · See #8376

Co-Authored-By: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…t (canonical)

Move the cost: YAML block from cell[0] frontmatter to nb.metadata['cost']
(canonical JSON, per #8376 design-gate / #8323 exemplar) on 15 QC-Py Python
pedagogical notebooks (QC-Py-01..26). Pays down guard #8352 frontmatter_rawyaml
landmines: violations 17 -> 6 on the QC-Py dir (the 11 cell#0 frontmatter
landmines resolved; the 6 remaining are preexisting mid-notebook hr FPs).

Storage-format migration: values migrated verbatim (not re-estimated). QC-Py
notebooks are QuantBook()-gated (QC Cloud) so not local-re-executable; committed
last_validated/validator preserved transparently. check_cost_metadata reports
cost_source='metadata' (canonical) on all 15. H.3 validate_pr_notebooks 3/3 PASS.

See #8056. See #4208.

Co-Authored-By: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…ntmatter → metadata.cost (fixes #8352 guard) (#8378)

* fix(genai-texte,#8369): clarify 10_LocalLlama scope — 2 non-local endpoints, GPU required = pedagogical target

Stop & Repair discipline (secrets-hygiene rule 6): honest scope clarification rather than hand-edited cell outputs.

Substance: 1 fichier, +11/-10 strict, 2 changements minimalistes dans cell[0] (markdown intro only, 0 code cell touched, 0 output hand-edited, no Papermill re-exec).

Change 1: costfm-frontmatter notes: (ligne 18) — clarifie que gpu_required=true est la cible pedagogique (Exercice 3 deploye vLLM/Ollama via Docker), pas la demo commited.

Change 2: Note d'execution (lignes 74-82) — actualise 'un seul endpoint' (OBSOLETE) vers '2 endpoints OpenAI-compatibles non-locaux (cloud-gpt5.2 + openweight-llama4)'. Aucun serveur vLLM/Ollama n'est demarre dans cette execution.

Verifications: H.3 PASS (1/1, 19 code cells, python3 kernel), LF-only CR=0 (237142 bytes), 0 leak (detect_solution_leaks.py), 0 catalog diff vs origin/main, fast-forward merge origin/main OK (3 commits #8372/#8374/#8373 sans impact).

L898 + L977 collision guard: 0 PR OPEN de po-2023 sur 10_LocalLlama ou Local LLM. L954 pivot genre honoré (c.864 tool-metadata vs c.865 notebook-genai-honest-retitle). G-VAR-1/2/3 OK.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(genai-texte,#8369): migrate cost frontmatter -> metadata.cost (canonical), fixes #8352 guard

Resolves the markdown-rendering guard (#8352) failure on #8378. cell#0 carried a
`---`-YAML frontmatter (title + cost + notes) that markdown-it promotes to
setext-H2 supersize = ERROR-level guard violation. The frontmatter was pre-existing
legacy; the #8378 notes edit triggered the guard to re-evaluate cell#0.

Fix per merged #8376 design-gate (canonical = nb.metadata['cost']):
- Migrate `cost:` -> nb.metadata['cost'] (invisible JSON, all values preserved).
- Drop redundant `title` (H1 `# 10. Hébergement Local...` already exists in cell#0).
- Merge top-level `notes` into cost.notes (canonical placement per #8323/#8376).
- Remove the entire `---...---` block from cell#0 source.

Validation: detect_markdown_rendering.py --check --baseline = OK (exit 0, no new
ERROR-level violations). Cross-tool: check_cost_metadata.py reads cost_source:
'metadata'. 0 code cells modified -> no re-exec (C.2 N/A; metadata + markdown-only).
byte-delta -737 (verbose YAML w/ comments -> compact JSON).

See #8369 · See #8056 · See #8376

Co-Authored-By: Claude-Code <noreply@anthropic.com>

---------

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…notebooks 1-9 (guard #8352) (#8384)

Migrate legacy `---`-YAML cost frontmatter to nb.metadata['cost'] (canonical JSON,
per merged #8376 design-gate) on the foundational GenAI/Texte series (notebooks 1-9).
The frontmatter cells render as setext-H2 supersize = ERROR-level under guard #8352
(HARD-enforced in CI). Values migrated verbatim; title preserved as H1 (injected where
cell#0 was frontmatter-only, kept pre-existing descriptive H1 otherwise); top-level
notes merged into cost.notes.

Validation: guard #8352 --check --baseline = OK exit 0 (no new ERROR); check_cost_metadata
reads cost_source='metadata' x9; 0 code cells modified (C.2 N/A, verified cell-by-cell);
byte-identity gate per-notebook; LF-only (CRLF=0). Diff: 9 files +147/-180.

See #8056, #8352, #8376, #8378. Part of #4208.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…notebooks 11-20 (guard #8352) (#8385)

Tranche 2 of the GenAI/Texte cost-frontmatter migration (tranche 1 = #8384 nb 1-9).
Migrate legacy `---`-YAML cost frontmatter to nb.metadata['cost'] (canonical JSON per
#8376) on notebooks 11-20. nb10 excluded (open #8378). Values migrated verbatim; title
preserved as H1 (injected where cell#0 was frontmatter-only [11,12]; kept pre-existing
descriptive H1 elsewhere [13-20] -- no duplicates); top-level notes merged into cost.notes.

Validation: guard #8352 --check --baseline = OK exit 0 (no new ERROR); check_cost_metadata
reads cost_source='metadata' x10; 0 code cells modified (C.2 N/A, verified cell-by-cell);
byte-identity gate per-notebook; LF-only (CRLF=0); h1 count = 1 per notebook.

See #8056, #8352, #8376, #8384, #8378. Part of #4208.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…t (canonical) (#8386)

Move the cost: YAML block from cell[0] frontmatter to nb.metadata['cost']
(canonical JSON, per #8376 design-gate / #8323 exemplar) on 15 QC-Py Python
pedagogical notebooks (QC-Py-01..26). Pays down guard #8352 frontmatter_rawyaml
landmines: violations 17 -> 6 on the QC-Py dir (the 11 cell#0 frontmatter
landmines resolved; the 6 remaining are preexisting mid-notebook hr FPs).

Storage-format migration: values migrated verbatim (not re-estimated). QC-Py
notebooks are QuantBook()-gated (QC Cloud) so not local-re-executable; committed
last_validated/validator preserved transparently. check_cost_metadata reports
cost_source='metadata' (canonical) on all 15. H.3 validate_pr_notebooks 3/3 PASS.

See #8056. See #4208.

Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…books (guard #8352) (#8387)

Family pivot (R6) in the #8056 cost-frontmatter rollout. Migrate legacy `---`-YAML cost
frontmatter to nb.metadata['cost'] (canonical JSON per #8376) on the 3 IIT notebooks
(IIT-1/2/3, PyPhi). Values migrated verbatim (storage-format, not re-estimation); pre-existing
descriptive H1 kept (h1=1 each, no injection); top-level notes merged into cost.notes.

Validation: guard #8352 --check --baseline = OK exit 0 (no new ERROR); check_cost_metadata
reads cost_source='metadata' x3; 0 code cells modified (C.2 N/A, verified cell-by-cell);
byte-identity gate per-notebook; LF-only (CRLF=0). IIT 0 registered twins -> twin-parity N/A.

Recon correction (G.1): firsthand census on fresh origin/main worktree = 109 landmines
(the "218" c.879 figure was scanned against the stale shared tree po2023-main-sync).

See #8056, #8352, #8376, #8384, #8385. Part of #4208.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…W-12/SL-11/SL-9 (guard #8352) (#8388)

Continue the #8056 cost-frontmatter rollout on the 3 SymbolicAI landmines
(SemanticWeb/SW-12-Python-GraphRAG, SymbolicLearning/SL-11-Capstone, SL-9-LLM-SymbolicLearning).
Migrate legacy `---`-YAML cost frontmatter to nb.metadata['cost'] (canonical JSON per #8376).
Values verbatim; pre-existing descriptive H1 kept (h1=1 each); top-level notes merged into
cost.notes.

Validation: guard #8352 --check --baseline = OK exit 0 (no new ERROR); check_cost_metadata
reads cost_source='metadata' x3; 0 code cells modified (C.2 N/A, verified cell-by-cell);
byte-identity gate per-notebook; LF-only (CRLF=0). SymbolicAI 0 registered twins -> N/A.

See #8056, #8352, #8376. Part of #4208.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…t on FT-01..05 (guard #8352) (#8389)

Storage-format migration (not re-estimation): legacy `---`-YAML frontmatter in
cell#0 (title + cost{...} + notes) -> nb.metadata['cost'] (canonical JSON, schema
#8376 / docs/notebook-metadata/cost-matrix.md). Values preserved VERBATIM.

- `title` dropped (redondant with H1 heading, kept as cell#0 first line).
- top-level `notes:` merged into cost.notes (per #8376 design-gate).
- YAML `null` literals -> JSON null (free_alternative, reduced_pedagogical).
- 0 code cells modified (C.2 N/A) -- only cell#0 markdown source + nb.metadata.

These 5 FineTuning notebooks are GPU-gated (LoRA/QLoRA/DPO fine-tuning); last_validated
/ validator preserved verbatim (format migration, not re-execution).

Validation (post-fix, firsthand):
- check_cost_metadata.py: cost_source='metadata' x5 (canonical form).
- detect_markdown_rendering.py --check: 'no new ERROR-level violations' (guard #8352 landmines cleared).
- validate_pr_notebooks.py (H.3): 5/5 PASS, 58 code cells.
- LF-only (CRLF=0 x5); byte-stable (diff scope = frontmatter removal + metadata.cost add only).

See #8056 (partial: FineTuning tranche; GenAI/Texte=po-2023, QC-Py=po-2025, IIT=po-2023).
Clears 5 of 128 repo-wide guard-#8352 landmines.

Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
… dividers (#8392)

Precision fix routed by po-2025 c.870 (tooling owner). _is_frontmatter_block flagged
false positives: a markdown cell sandwiching prose between two `---` thematic-break
lines (section divider `---\n\n### Heading\n...affiche :\n...\n---`) was misclassified
as frontmatter_rawyaml, because any cell starting with `---` + a later `---` + two
colon-bearing FR phrases met the threshold.

Fix: require the line immediately after the opening `---` fence to be non-blank
(YAML frontmatter starts content right after the fence; a thematic-break section
divider is followed by a blank line + heading). Strictly more conservative.

PROVEN SAFE (repo-wide census): 212 real frontmatter cells have blank_after_open=False
(zero FN risk); all 9 prose-section FPs have blank_after_open=True (all cleared).
frontmatter_rawyaml 21->12 (-9); frontmatter_supersize 203->203 (0); setext_oversized
19->19 (0). `--check --baseline` = OK exit 0 (exact CI command).

Added tests/test_detect_markdown_rendering.py (13 tests, repo test_detect_* convention).

See #8352, #8056. Routed by po-2025 c.870.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 24, 2026
…ation+04-Applications (7 NBs, guard #8352) (#8393)

Storage-format migration (not re-estimation): legacy ---YAML cell[1] frontmatter
on 03-Orchestration/03-1..03-3 -> nb.metadata['cost'] (canonical JSON, schema
#8376 / docs/notebook-metadata/cost-matrix.md). 04-Applications/04-1..04-4
never had YAML -> fresh metadata.cost insertion (inferred from cell[0] prose
+ code-cell inspection: API tokens, GPU usage).

- 03-Orchestration (3): parse YAML cell[1] -> metadata.cost JSON, DELETE cell[1] (cell[1] was YAML-only).
- 04-Applications (4): construct cost block from cell[0] self-disclosed VRAM + code-cell API/GPU detection.
- top-level YAML title dropped (redondant with H1 cell[0], per #8376 design-gate).
- top-level YAML notes merged into cost.notes.
- 0 code cells modified (C.2 N/A, all assertions preserved verbatim).
- 0 secret literal introduced (sk- scan: 0 hit on 7 files).

Validation (post-fix, firsthand):
- check_cost_metadata.py: cost_source='metadata' x7 (canonical form).
- check_cost_metadata.py findings: 0 on 7 (no litmus violation).
- validate_pr_notebooks.py (H.3): 7/7 PASS (15+13+12+13+13+13+14 = 93 code cells).
- LF-only (CR=0) on all 7 files; trailing newline preserved.
- detect_solution_leaks.py: 0 HIGH / 0 MEDIUM / 0 errors on 7.
- byte-identity guard on cell sources other than the YAML cell[1] deletion.
- 7 files changed, +119/-24 (strict, scoped to cost frontmatter).

See #8056 (partial: GenAI/Video tranche; GenAI/Image+Audio=IIT=FT=Texte=SW=SL
already migrated by jsboige, Quality=other workers). Part of #4208.

Co-authored-by: jsboige <jsboige@gmail.com>
jsboige added a commit that referenced this pull request Jul 25, 2026
…t on Claude-Code 01-05 (guard #8352) (#8410)

Storage-format migration (not re-estimation): legacy `---`-YAML frontmatter in
cell#0 (title + cost{...} + notes) -> nb.metadata['cost'] (canonical JSON, schema
#8376). Values preserved VERBATIM.

- `title` dropped (redundant with the H1 that follows the frontmatter in cell#0).
- top-level `notes:` merged into cost.notes (per #8376 design-gate, cf FT-01 #8389).
- YAML literals preserved as-is (free_alternative=path string, reduced_pedagogical=string,
  vram_tier=LITE, last_validated="2026-07-24" string not date-parsed).
- 0 code cells modified (C.2 N/A) -- only cell#0 markdown source + nb.metadata.

Validation (post-fix, firsthand — verbatim-forensic c.713/c.714 discipline):
- Exhaustive ORIG-vs-NEW all-fields diff: 75/75 fields match VERBATIM (0 violations).
  None of the 3 systematic-migration telltales (free_alternative nulled,
  vram_tier NONE->LITE, reduced_pedagogical nulled) — all 5 notebooks had
  real values (free_alternative=Claudish path, reduced_pedagogical=SIMULATION_MODE
  string, vram_tier=LITE) preserved.
- detect_markdown_rendering.py: 0 findings on the 5 (guard #8352 landmines cleared).
- validate_pr_notebooks.py (H.3): 5/5 PASS, 60 code cells.
- LF-only (CRLF=0 x5, matches .gitattributes eol=lf + FT-01 canonical);
  byte-stable cells[1:] (diff scope = frontmatter removal + metadata.cost add only).

See #8056 (partial: GenAI/Vibe-Coding/Claude-Code tranche; prior: FineTuning=#8389,
GenAI/Texte=po-2024, PostTraining=po-2024, QC-Py=po-2025, DecInfer=po-2026).
Clears 5 of 128 repo-wide guard-#8352 landmines.

Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 25, 2026
…adata.cost (guard #8352) (#8418)

Delete the cell[1] `---`-YAML cost frontmatter block on the 5 GenAI/Image
01-Foundation notebooks and move it into `nb.metadata['cost']` (JSON), the
canonical storage location established by #8376 (check_cost_metadata reads
metadata.cost first) and #8323 (Infer-3 reference schema).

These 5 notebooks carry the cost frontmatter in its OWN cell (cell[1]), pure-FM
(0 chars after closing `---`); cell[0] is the canonical H1/nav/intro. The
frontmatter at cell#1 is flagged by guard #8352 as `frontmatter_supersize`
(markdown-it promotes it to a setext-H2 supersize rendering defect). Deleting
the pure-FM cell[1] and setting metadata.cost clears the guard.

Storage-format migration, values VERBATIM (manual YAML parse via
migrate_cost.parse_frontmatter -- NO yaml.safe_load, so `last_validated:
2026-07-23T01:30Z` stays a STRING, no timestamp coercion). The 14 cost fields
are moved as-is; the redundant `title:` is dropped (cell#0 H1 is the title).
Top-level `notes:` merged INTO `cost.notes` (#8376 design gate).

Scope: 0 code cells modified (byte-stability verified -- exhaustive ORIG-vs-NEW
diff via `git show HEAD:path` proves all 25-31 kept cells per NB are byte-
identical in source/execution_count/outputs/cell_type). C.2 re-exec N/A (no code
cell source touched). Cell-id state preserved (orig had 2 no-id cells, new has 1
-- the deleted FM cell was one of them; pre-existing, not a regression).

The 3 cost-migration telltales (the systematic-bug class found c.713/c.714:
free_alternative nulling, vram_tier NONE->LITE, reduced_pedagogical nulling) are
preserved VERBATIM with their per-NB variation intact:
- 01-1, 01-2: free_alternative=path(01-4), reduced_pedagogical=path(01-3), vram_tier=LITE
- 01-3: free_alternative='N/A', reduced_pedagogical='N/A', vram_tier=LITE
- 01-4: free_alternative=null, reduced_pedagogical=path(01-3), vram_tier=LITE
- 01-5: free_alternative=null, reduced_pedagogical=path(01-4), vram_tier=MID

Validation (canonical, all post-migration):
- detect_markdown_rendering.py --check: "OK: no new ERROR-level violations", EXIT 0
- check_cost_metadata.py: cost_source='metadata' (5/5), findings empty
- H.3: 0 code cells with execution_count=None (all 5 notebooks fully executed)
- LF-only (CRLF=0 across all 5)
- guard #8352 landmines cleared: 5

Advances #8056 (cost/ressource matrix per notebook). Sub-tranche of the GenAI/
Image family (20 total cell#1-FM landmines on origin/main -- this PR clears
01-Foundation 5; 02-Advanced/03-Orchestration/04-Applications/examples 15
remain for follow-up tranches).

Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 25, 2026
…L-Cours (9 NB) (#8419)

EPIC #8056. Migrate the 9 DataScienceWithAgents/02-ML-Cours notebooks (2.1-2.9)
from top-level YAML frontmatter to canonical nb.metadata['cost'] JSON.

Verbatim-forensic discipline (c.887-c.890): 135/135 cost fields match ORIG, 0
violations of the 3 systematic-migration telltales that bit #8397/#8400:
  - free_alternative: 'self' (string, preserved — NOT nulled)
  - reduced_pedagogical: 'self' (string, preserved — NOT nulled)
  - api_provider/external_account: 'none' (string, preserved — NOT nulled)
  - vram_tier: 'LITE' (preserved verbatim — NOT normalized NONE<->LITE)
Independent ORIG-vs-NEW all-fields forensic: 135 fields, 0 mismatches.

Structure (verified): cell[0]=prose title, cell[1]=STANDALONE frontmatter cell
(pure ---YAML---, no prose after). Convention (merged ML-1 #8400 verified):
standalone FM cell -> DELETE after extracting cost -> metadata.cost. Cell count
-1 per NB. title dropped (canonical convention, #8397/#8400 exemplars). notes
merged into cost.notes (#8376 design-gate).

Validation:
- notebook_tools validate --quick: 9/9 OK, 0 warnings
- guard #8352 (detect_markdown_rendering --check): OK, no new violations
  (9 frontmatter_supersize landmines cleared)
- round-trip byte-identity json.dumps(indent=1) verified pre-edit; LF preserved
  (0 CRLF); diff = +153/-255 (pure FM-cell deletion + metadata.cost addition)
- catalogue byte-identical to main (0 churn)

See #8056 (partial: ML 02-ML-Cours tranche migrated). See #8352.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 25, 2026
…ata.cost (guard #8352) (#8429)

Forensic gate passed firsthand (ai-01 c.897): free_alternative/vram_tier/reduced_pedagogical verbatim-preserved across all 5 NBs (ORIG frontmatter vs NEW metadata.cost) — #8420 nulling bug-class verified ABSENT. Twin-parity FAILURE = advisory stale-base FP (branch predates #8408/#8427 register rebaselines; 5 changed files not twin-paired; register untouched) — squash onto current main leaves twin-parity clean. 30/30 functional checks green.
jsboige added a commit that referenced this pull request Jul 25, 2026
…cost (byte-surgical, guard #8352) (#8518)

Migration cost markdown ---YAML--- -> metadata.cost JSON, serie Audio 02-Advanced (9 notebooks).

Verification anti-regression coordinateur (le shape -290/+10 est un red-flag par defaut) : PAS de perte. Les 9 blocs cost JSON portent l'integralite des champs (api_usd_est, api_provider, cpu_min, gpu_min, gpu_required, vram_gb, vram_tier, network, external_account, free_alternative, reduced_pedagogical, reproducibility, last_validated, validator) ET le champ 'notes' en prose (9/9 verifies). Le delta -290/+10 s'explique par le passage YAML multi-lignes -> JSON une ligne.

Scope : 1 feature, 1 domaine, 10 fichiers -> sous les seuils composites G.4. Continuite d'une migration flotte deja mergee (#8420, #8393/#8397, #8400/#8445, #8432).

Grain: MED/metadata-migration - lane myia-po-2025:CoursIA
jsboige added a commit that referenced this pull request Jul 25, 2026
…etadata.cost (13 NBs) (#8579)

Migration de stockage pure et verifiable : 0 cellule code touchee, 0 execution_count, 0 outputs — le diff est exactement le retrait de la cellule frontmatter et l'ajout de metadata.cost, 13 fois. Guard #8352 satisfait sans re-execution ni GPU, H.3 13/13 PASS.

Un residu a traiter dans la foulee, pas ici : les 13 valeurs `notes` se terminent par `\n---\n`. Ce n'est PAS une faute de ta migration — le frontmatter source indentait son delimiteur de fermeture au niveau du bloc, donc YAML l'a legitimement absorbe dans le scalaire `notes: |`. Tu as preserve verbatim ce que la source disait. Mais un terminateur de frontmatter n'a aucun sens dans metadata.cost, et le meme motif va se reproduire sur GenAI/Image (#8580, meme migration, encore ouverte). Strippe le `---` terminal des deux familles dans #8580 plutot que d'ouvrir un troisieme grain.

See #8056.
jsboige added a commit that referenced this pull request Jul 25, 2026
…st (9 NBs) (#8580)

Meme migration que #8579, meme verification : 0 cellule code, 0 execution_count, 0 outputs — pur deplacement de stockage, guard #8352 leve sans re-execution.

Note pour la famille : contrairement a GenAI/Audio, ton frontmatter source fermait son delimiteur en colonne 0, donc rien n'a fuite dans les valeurs `notes`. J'avais demande dans #8579 que le strip du `---` terminal soit fait ici — sans objet, tes 9 notebooks sont propres. Je traite les 13 de l'Audio moi-meme.

See #8056.
jsboige added a commit that referenced this pull request Jul 31, 2026
…ted (#8975)

The `setext_oversized` rule flagged a `---`/`===` line as a setext underline
regardless of whether it sat INSIDE a fenced-code block. Inside a ``` / ~~~ block
the line renders verbatim (ASCII art, a cryptarithme divider, a box-drawing
rule), so it is literal text, not an oversized heading. This produced 11 false
positives across 5 families (CSP cryptarithmes, Sudoku grids, GameTheory/Tweety/
Planners SMT boxes, MLN).

Add `_inside_fence_lines` (CommonMark fence tracking: >=3 backticks/tildes,
same-char closer >= opening length, backtick/tilde independent, unclosed =
defensive inside) and skip fenced indices in both setext sites
(`_frontmatter_supersizes` + the scan_cell setext loop).

Verified firsthand: setext_oversized 19 -> 8 (the 11 fence FPs gone, the 8 REAL
prose-underline defects preserved), gate `--check --baseline` exit 0, 18/18 new
unit tests green. The 8 REAL + 18 frontmatter defects remain baselined.

Baseline untouched: it carries 35 orphaned hashes total (24 pre-existing, already
burned down on main since last regen; 11 mine). A surgical baseline burn-down is
deferred to a dedicated batch to avoid re-classifying a pre-existing REAL defect
as NEW and breaking the gate.

Follow-up to #8392 (same precision vein: that fixed `_is_frontmatter_block`
prose-section-divider FPs; this fixes setext code-fence FPs).

See #8352.

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 31, 2026
…nion, no output change)

Apply migrate_cost_frontmatter_to_metadata.py to the 10 ML-* quantbooks.
Legacy YAML frontmatter in cell#0 promoted leading `---` to oversized
setext-H2 (frontmatter_supersize defect, #8904 / guard #8352). Migration
does UNION before suppression: frontmatter (rich/authoritative) wins on
overlap, metadata.cost keeps its own fields (qcc_tokens_est); cost then
lives canonically in nb.metadata.cost only, cell#0 frontmatter removed.

Verified per-file (10/10, all green):
- outputs byte-identical (sha256 BEFORE == AFTER; 0 octet moved)
- code cell sources unchanged (cells[1:])
- cell#0 now starts with `#` (leading `---` stripped)
- 3 guards: byte_stable_baseline=True field_equivalent=True minimal_diff=True
- diff uniform: 4 insertions / 20 deletions per file (metadata + cell#0 only)

Reworks the prior naive-strip approach (CHANGES_REQUESTED: data loss) into
the on-main union migration (d25a0b3 via #8966, authored po-203).

See #8904

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jsboige
jsboige deleted the feature/markdown-rendering-guard branch September 2, 2026 13:15
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.

2 participants