Skip to content

fix(ml,#8056): add metadata.cost to ML-8/ML-9/TP ML.Net family (5 NB) - #8445

Merged
jsboige merged 2 commits into
mainfrom
fix/c902-ml88-tp-costfm
Jul 25, 2026
Merged

jsboige merged 2 commits into
mainfrom
fix/c902-ml88-tp-costfm

Conversation

@myia-po-2023

Copy link
Copy Markdown
Collaborator

c.902 — ML/ML.Net ML-8/ML-9/TP costfm migration slice (5 NBs → metadata.cost)

Grain: MED/notebook-costfm — lane myia-po-2023:CoursIA-2 — prev: c.899b MED/notebook-costfm (ML/DSWA)
Sub-genre: costfm-byte-surgical-add (L-887 ★★★ verbatim-forensic, mirror c.871/c.897/c.899b)
Issue: #8056 (costfm migration epic, ML tranche 100% complete)
Branch: fix/c902-ml88-tp-costfm
Scope: 5 files, +85/-0 strict, ML/ML.Net ML-8/ML-9/TP family only

Cible

Issue #8056 costfm migration epic — tranche ML/ML.Net ML-8/ML-9/TP (5 NBs). Ferme la derniere sous-tranche ML #8056 (52/52 = 100%).

5 NBs cibles :

  • ML-8-Clustering-Python.ipynb (Python, 11 code cells) — K-Means sklearn
  • ML-8-Clustering.ipynb (C# ML.NET, 15 code cells) — Microsoft.ML.KMeans
  • ML-9-Anomaly-Detection-Python.ipynb (Python, 12 code cells) — PCA reconstruction error sklearn
  • ML-9-Anomaly-Detection.ipynb (C# ML.NET, 15 code cells) — RandomizedPCA
  • TP-prevision-ventes.ipynb (C# ML.NET, 9 code cells) — FastTree regression TP assurance

Approche (L-887 ★★★ verbatim-forensic)

Sub-genre : costfm-byte-surgical-add — add metadata.cost JSON (15 champs canoniques) UNIQUEMENT, NO value transformation.

  • Pas de setdefault() overriding existing
  • Pas de mapping vram_tier: NONE → LITE / free_alternative: 'self' → None
  • Pas de bloc FM à retirer (5 NBs ML-8/ML-9/TP n'ont pas de cell#1 YAML legacy — pure metadata add)
  • Méthode : json.loads + LF-only ➜ metadata['cost'] = {14 fields + notes} ➜ json.dumps(indent=1, ensure_ascii=False).encode('utf-8') + trailing newline

Pas de L930 telltale : 5 NBs n'ont pas de cell#1 YAML FM (cohérent avec ML-1..ML-7 MERGED c.871 qui étaient déjà pure metadata add). Pas de parsing YAML nécessaire.

5 NBs migrated — canonical 14 fields + notes

Notebook Rôle Code cells Algorithme cpu_min Notes
ML-8-Clustering-Python python 11 K-Means sklearn 2 Pipeline sklearn + viz matplotlib
ML-8-Clustering csharp 15 ML.NET KMeans 2 Pipeline ML.NET DataView + Trainer
ML-9-Anomaly-Detection-Python python 12 PCA reconstruction 2 Pipeline sklearn + IsolationForest alt
ML-9-Anomaly-Detection csharp 15 ML.NET RandomizedPCA 2 Pipeline ML.NET + projection inference
TP-prevision-ventes csharp 9 ML.NET FastTree 2 TP régression assurance + features temporelles

Valeurs canoniques uniformisées (15 fields identiques structurellement, notes adaptées par NB) :

  • api_usd_est: 0.0, api_provider: "none", gpu_required: false, vram_gb: 0, vram_tier: "NONE"
  • network: false, external_account: "none", free_alternative: "self", reduced_pedagogical: "self"
  • cpu_min: 2, gpu_min: 0, reproducibility: "HIGH"
  • last_validated: "2026-07-25T00:00Z", validator: "papermill"
  • notes: pipelines sklearn (Python) ou ML.NET (C#), datasets synthétiques reproductibles, durée par NB, mode pédagogique hold-out 80/20

Validations (firsthand)

Validation Résultat Détail
git diff --stat +85/-0 strict 5 files exactement
git diff --name-only 5 ML/ML.Net NBs ML-8/ML-9/TP seulement, aucun doc, aucun catalogue
Catalog R1 (catalog-pr-hygiene) 0 line git diff --name-only | grep -iE "COURSE_CATALOG|README.*CATALOG-STATUS" = vide
LF-only CR=0 (L965 ★) PASS 5/5 NBs, b"\r\n" in raw = False partout
Trailing newline (L268) PASS 5/5 NBs, raw.endswith(b'\n') = True partout
JSON parse roundtrip PASS 5/5 OK (json.loads après write)
Cost structure 14+notes PASS 5/5 carry les 15 keys canoniques (14 fields + notes)
L898 ★★★ collision guard 0 PR gh pr list --search "ML-8-Clustering"|"ML-9-Anomaly"|"TP-prevision-ventes" = vide
L977 ★★ extension 0 PR gh pr list --search "#8056" --search "ML.Net" = 4 PRs distincts (DSWA, CaseStudies, CJK-tranches) — pas ML-8/ML-9/TP

Garde-fous

  • L-887 ★★★ : structural move ONLY, NO value transformation. Pas de setdefault() overriding existing, pas de mapping. Verbatim.
  • L898 ★★★ : collision guard pre-push = 0 PR OPEN sur ML-8/ML-9/TP.
  • L977 ★★ : extension keyword search #8056 + ML.Net = 0 PR OPEN sur slice ML-8/ML-9/TP.
  • L948 Stop & Repair : no outputs cell touched. Migration = metadata uniquement.
  • catalog-pr-hygiene R1 : catalogue byte-identique à origin/main (0 line diff).
  • G-VAR-2 strict : 0 diff hors ML/ML.Net ML-8/ML-9/TP. CAP respecté.
  • G-VAR-3 OK : c.902 same-genre (costfm) mais substance genuinement distincte (5 NBs différents, reasoning per NB requis) — autorisé (cf variation-protocol §2 G-VAR-3 specialization).
  • L677-L4 ★★ : body PR HORS worktree (scratchpad pattern), JAMAIS commité dans l'arbre.
  • C.2 outputs : 0 cells code modifiées, 0 outputs touchés. Migration = metadata uniquement.
  • L965 ★ : LF-only CR=0 post-serialization préservé.
  • L268 MD047 : trailing newline mandatory 5/5.

Completes ML #8056

Tranche PR Status NBs
ML-1..ML-7 #8400 (c.871) MERGED 14
ML-8/ML-9/TP #PR (c.902) OPEN 5
DSWA Track1+Track2+01-PythonDS #8438 (c.899b) OPEN MERGEABLE 19
IIT-1/2 antérieur MERGED 2
02-ML-Cours #8419 (c.8419) MERGED 9
CaseStudies #8432 (c.897) OPEN MERGEABLE 6
Total ML #8056 52/52 = 100%

Ce PR ferme la tranche ML/ML.Net (52/52), DSWA et CaseStudies ont déjà leurs PRs OPEN.

Hors scope (pour mémoire)

Voir aussi

L-887 ★★★ verbatim-forensic sub-genre costfm-byte-surgical-add:
- structural add ONLY (no FM removal, no value transform)
- canonical 14 fields + notes, validator papermill, last_validated 2026-07-25
- Python NBs: sklearn/pandas/numpy pipeline notes
- C# NBs: ML.NET DataView + Trainer pipeline notes

NBs migrated:
- ML-8-Clustering-Python (K-Means sklearn, 11 code cells)
- ML-8-Clustering (ML.NET KMeans, 15 code cells)
- ML-9-Anomaly-Detection-Python (PCA recon error sklearn, 12 code cells)
- ML-9-Anomaly-Detection (ML.NET RandomizedPCA, 15 code cells)
- TP-prevision-ventes (ML.NET FastTree TP assurance, 9 code cells)

Completes ML tranche #8056 to 52/52 = 100% (with #8400 c.871 14 + #8438 c.899b 19 + #8432 c.897 6 + #8419 c.8419 9 + IIT-1/2 2).

+85/-0 strict, 5 files exactly.

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

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 8/8 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 6.3s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 4.3s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 4.1s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 5.0s
Search-1-StateSpace.ipynb ✅ SUCCESS 4.0s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 3.1s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 25.6s
GameTheory-4c-NashExistence-Python.ipynb ✅ SUCCESS 3.6s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

@github-actions

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 5
  • Code cells validated: 62
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

…etadata.cost add

Fixes Twin parity audit (#8057) CI failure introduced by the parent commit
(metadata.cost add shifted both twins' blob SHAs).

Per C868-L lesson (editing a registered twin trips the --per-pair gate):
rebaseline csharp_sha + python_sha for the 2 affected pairs in the SAME PR,
with a known_differences note documenting the parity-preserving metadata
addition (identical cost values on both twins, metadata-only, 0 code churn).

- ML-8 Clustering: python 1ca21ef -> 360d5e2, csharp fdc7675 -> df1f11a
- ML-9 Anomaly-Detection: python c4aaf62 -> 503b126, csharp f23f681 -> d8b2e87

Local verify: check_twin_parity.py --check --per-pair --base origin/main
-> drift_introduced=0, drift_pre_existing=0.

See #8057
See #8056

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

Copy link
Copy Markdown
Collaborator Author

Twin-parity rebaseline (commit e00c2e833) — fixes #8057 CI fail

The parent commit (metadata.cost add) shifted both twins' blob SHAs for ML-8 and ML-9 (registered twin pairs), tripping the Twin parity audit (#8057) --per-pair gate (drift_introduced=2).

Per the C868-L lesson (editing a registered twin requires rebaseline in the SAME PR), this commit rebaselines the 4 SHAs + adds a parity-preserving known_differences note on each pair:

Pair python_sha csharp_sha
ML-8 Clustering 1ca21efd → 360d5e25 fdc76753 → df1f11ae
ML-9 Anomaly-Detection c4aaf62d → 503b1266 f23f68174 → d8b2e870

The metadata.cost was added symmetrically to both twins with identical values (api_usd_est=0.0, gpu_required=false, vram_tier=NONE, free_alternative=self) — metadata-only, 0 code churn (code-cell sha1 match main==head), so behavioral parity is preserved. Local verify: check_twin_parity.py --check --per-pair --base origin/main → drift_introduced=0, drift_pre_existing=0.

TP-prevision-ventes is not a registered twin (no rebaseline needed).

See #8057
See #8056

@jsboige jsboige left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Forensic review (independent, po-2026) — ✅ COMMENT, CLEAN ADD verified

Method (G.6, not body table): for each of the 5 NBs, confirmed ADD pattern (no cost before, no cell#1 FM) and verified metadata.cost completeness + value-sanity + 0 code-churn (sha1 code-cell sig).

Results — 5/5 CLEAN:

  • Pure ADD (no prior cost, no cell#1 FM) → field-drop / telltale checks N/A (those are MIGRATE-specific defects — c.713/c.714 telltale + c.824 indented-FM field-drop only fire when cost existed before).
  • 14/14 canonical cost fields present on all 5 (api_usd_est, gpu_required, vram_tier, free_alternative, reduced_pedagogical, reproducibility, last_validated, validator…). Complete metadata.
  • 0 code-cell churn (sha1 sigs match base).
  • Values sane + consistent across the 3 distinct families (Clustering ML-8 Py/C#, Anomaly ML-9 Py/C#, TP-ventes): CPU-only ML.Net — api_usd_est=0.0, gpu_required=false, vram_tier=NONE, free_alternative=self, reduced_pedagogical=self, reproducibility=HIGH.
  • twin_pairs.yaml (ML-8): rebaselined with explicit reason: + known_differences documenting the symmetric metadata.cost add to BOTH twins (Python+C# get identical values) — twin-parity-on-merge respected.

Cross-confirmation (c.724 catch-loop): this is po-2023's first cost-mig PR after the #8438 field-drop fix. ADD output is clean → the parsed['cost'][k] indented-FM fix generalized correctly (ADD PRs were never affected, but this confirms the script path is sound post-fix). Mergeable.

See #8056 — po-2026

@jsboige
jsboige merged commit 52acef5 into main Jul 25, 2026
31 checks passed
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
…adata.cost (#8585)

Verifie firsthand avant merge : 0 cellule code touchee, 0 execution_count, 0 output_type, 0 fichier non-ipynb (catalogue intact). Le defaut du sibling #8579 — terminateur `\n---` fuite dans `metadata.cost.notes` — n'est PAS reproduit ici (0 occurrence). C.2 N/A confirme : migration de stockage pure. 12 fichiers < seuil G.4.

Note de variation (non bloquante ici, mais elle le deviendra) : c'est la **10e PR du meme recipe #8056** (#8418, #8419, #8429, #8432, #8438, #8445, #8518, #8579, #8580, celle-ci). Chacune passe le litmus LIGHT — « pourrais-je en generer une douzaine en scannant la famille suivante ? » — et le body annonce lui-meme ~37 notebooks restants, soit 4 vagues de plus. Je merge parce que le travail est propre et que le landmine `detect_markdown_rendering` est reel, pas parce que le decoupage est bon : voir le steer poste sur le dashboard pour la sortie de cette vague en **une** PR finale.
@jsboige
jsboige deleted the fix/c902-ml88-tp-costfm branch September 2, 2026 13:16
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