Skip to content

fix(notebook-tools,#8053): Infer-6-Debugging cell 20 — stub-ify viz demo under Exercice 1 header (C.1 content-based) - #8162

Merged
myia-ai-01 merged 1 commit into
mainfrom
fix/c8104-infer6-cell20-stub
Jul 24, 2026
Merged

myia-ai-01 merged 1 commit into
mainfrom
fix/c8104-infer6-cell20-stub

Conversation

@jsboige

@jsboige jsboige commented Jul 23, 2026

Copy link
Copy Markdown
Owner

fix(notebook-tools,#8053): Infer-6-Debugging cell 20 — stub-ify viz demo under "Exercice 1" header (C.1 + content-based FP)

Grain: MED/guard — lane myia-po-2023:CoursIA-2 — prev: LIGHT/ledger

Source de l'audit

EPIC #8053 (branch detect_solution_leaks en CI), cluster #8084/#8146/#8151.
ai-01 steer 2026-07-23T05:08Z (DM msg-20260723T050852) : fixer les 2 classes de FP pour de-HOLD #8084, puis rebase + merge.

Le finding

$ python scripts/notebook_tools/detect_solution_leaks.py --scan MyIA.AI.Notebooks/Probas/Infer/Infer-6-Debugging.ipynb
HIGH: Infer-6-Debugging.ipynb:cell 20 — "Exercice 1" has 1341 chars of code

Cellule 18 = vrai stub (TODO 1-5 + Console.WriteLine("Exercice a completer"))
Cellule 19 = ## Exercice 1 : Diagnostic d'un modèle de melange gaussien (markdown)
Cellule 20 = // Visualisation du factor graph du modele EP vs VMP (1341 chars de solution complete : modele, inference, factor graph SVG inline)

Le detector attribut le code de cell 20 au header ## Exercice 1 (closest-preceding), produisant un HIGH (exercice + solution code) malgre l'absence d'intention pedagogique d'exercice — la viz est une demonstration isolee mal situee entre l'exercice et la suite du notebook.

La regle appliquee

exercise-example-labeling.md (content-based, HARD) :

Titre "Exercice" + cellule code = solution complete => stubber le code (garder le titre Exercice, conserver # TODO/# Indice/# Etape N).

C.1 (notebook-conventions) : raise NotImplementedError / assert False / 1/0 interdits. Patterns corrects : pass, print("Exercice a completer"), return None, # TODO etudiant.

Le fix

Remplacement du corps de cell 20 (1341 chars de viz working) par un stub C.1 conforme :

// Visualisation du factor graph du modele EP vs VMP
// Le graphe est identique pour les deux algorithmes - seul le calcul des messages differe

// TODO etudiant : Implementer la visualisation du factor graph du modele EP vs VMP.
// Le graphe doit montrer la structure partagee (hyperparametres mean/precision + observations y).
// Indice 1 : definir 6 observations bruitees (cf cellules 13-15 pour le modele canonique)
// Indice 2 : creer Variable<double> mean = ... .Named("mean") et Variable<double> prec = ... .Named("precision")
// Indice 3 : creer VariableArray<double> obs[r] = Variable.GaussianFromMeanAndPrecision(mean, prec).ForEach(r)
// Indice 4 : InferenceEngine engVis = new InferenceEngine(); engVis.ShowFactorGraph = true;
// Indice 5 : afficher avec display(HTML(FactorGraphHelper.GetLatestFactorGraphHtml())) et nettoyer via FactorGraphHelper.CleanupGeneratedFiles()

Console.WriteLine("Exercice a completer : visualiser le factor graph EP vs VMP");

5 indices pedagogiques preserves (modele canonique, hyperparametres, array indexation, options moteur, helper Graphviz) — l'etudiant a tout le contexte pour implementer.

Re-execution reelle (Stop & Repair, mandat user 2026-06-22)

Le fix modifie le source de cell 20 → re-execution OBLIGATOIRE via .NET Interactive kernel (jupyter_client.KernelManager(kernel_name='.net-csharp')). JAMAIS hand-editer les outputs (interdit, scrubbing = falsification).

$ python -c "...kernel_client re-exec..."
exec_count=1, outputs=2
  [display_data]
  [stdout] Exercice a completer : visualiser le factor graph EP vs VMP

Outputs precedents (viz working 1341 chars + factor graph SVG) supprimes car stale : ils correspondent a l'ancien code, plus au nouveau.

Verification post-fix

$ python scripts/notebook_tools/detect_solution_leaks.py --scan MyIA.AI.Notebooks/Probas/Infer/Infer-6-Debugging.ipynb
Results: 0 HIGH (leaks), 0 MEDIUM (duplicates), 0 errors

$ python scripts/notebook_tools/check_c2_compliance.py --path MyIA.AI.Notebooks/Probas/Infer/Infer-6-Debugging.ipynb
C.2 Compliance Check: 1/1 notebooks compliant
All clear!

C.2 : 17/17 cellules code avec execution_count != null ET outputs != [].

Conformite regles

  • C.1 strict : 0 raise NotImplementedError / 0 assert False / 0 1/0 dans le fix. Pattern C.1 = Console.WriteLine("Exercice a completer : ...") + commentaires # TODO etudiant + 5 # Indice.
  • C.2 : cell 20 re-executee via .NET Interactive kernel, outputs coherent avec le nouveau source.
  • C.3 strict : seul cell 20 re-executee (celle modifiee). 0 autre cellule touchee. 0 PNG regeneré (l'ancien etait un output de cellule, pas un asset separe).
  • L143 secrets-hygiene : 0 hit (sk- / ghp_ / AIza sur le diff).
  • L268 LF-only : git diff | tr -cd '\r' | wc -c = 0 CR.
  • R3 atomic : 1 fichier modifie (Infer-6-Debugging.ipynb), pas de composite.
  • R4 See #N partial : ne resout pas l'EPIC [#4208] Brancher en CI la détection sémantique « Exercice contenant sa solution » #8053 entier (reste Search-3 cell 64 + branch detector), donc See #8053 (et non Closes #8053).
  • Stop & Repair (mandat 2026-06-22) : re-execution reelle de cell 20, pas de scrub des outputs precedents (suppression OK car ils etaient stale = ancien code, pas scrubbing manuel d'un resultat actuel).
  • exercise-example-labeling.md content-based : applique au cas "titre Exercice + cellule solution complete" → stub-ification du code en gardant le titre.
  • three-exercises-per-notebook.md : ne change pas le compte d'exercices (cell 18 etait deja un Exercice, cell 20 reste dans la section Exercice 1 mais en stub maintenant = pedagogiquement coherent).

Statistiques

  • 1 fichier : MyIA.AI.Notebooks/Probas/Infer/Infer-6-Debugging.ipynb
  • +6 / -224 lignes (la majorite du -224 = outputs SVG factor graph supprimes car stale)
  • 1 cellule modifiee (cell 20)
  • 0 collision (cross-lane worktree ../CoursIA-c8104-infer6-stub-cell20)

Reste pour de-HOLD #8084

L'autre classe de FP = Search-3-Informed.ipynb:cell 64 (Exercice 5 commented-solution, 2882 chars de code). Cette PR ne couvre que la moitie Infer-6 — Search-3 sera couvert dans une PR suivante (meme epic #8053, meme lane, scope distinct = atomique).

Cross-references

EPIC #8053 (detect_solution_leaks CI) · PR #8084/#8146 (wiring canonique, HOLD pending 2 FP fixes) · PR #8151 (redondant, a closer superseded) · PR #8161 (Mon essai anterieur de reorder cells, fix PARTIEL — reordonneait cells 18↔20 mais la viz restait dans la section Exercice 1). Cette PR rend le fix real et stable (stub-ification + re-exec).

…Exercice 1 header

Cell 20 (1341 chars of complete FactorGraph visualization code) sat between
the markdown '## Exercice 1' header (cell 19) and the next section. The leak
detector's closest-preceding header attribution flagged it as HIGH (exercice
+ solution code).

Per exercise-example-labeling.md (content-based rule): stub the code, keep the
title. Per C.1: TODO etudiant + Console.WriteLine stub pattern, 5 Indices
preserved, no NotImplementedError.

Re-executed cell 20 via .NET Interactive kernel (jupyter_client) so outputs
match the new source. Stop & Repair (mandat 2026-06-22): never scrub outputs
by hand; the 224 lines of stale factor-graph SVG/stdout outputs were removed
because they corresponded to the OLD code, not the new stub.

Detector post-fix: 0 HIGH, 0 MEDIUM. C.2 compliance: 17/17 code cells.

See #8053. Supersedes partial-fix approach in PR #8161 (cell reorder alone
left the viz under Exercice 1; this PR replaces the viz body with a real
stub).
@github-actions

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 17
  • 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)

@github-actions

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.8s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 4.6s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 4.2s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 5.1s
Search-1-StateSpace.ipynb ✅ SUCCESS 4.1s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 3.2s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 25.4s
GameTheory-4c-NashExistence-Python.ipynb ✅ SUCCESS 3.8s

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

@jsboige

jsboige commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

Verified on origin/main HEAD 644bb656d: with #8162 applied, detect_solution_leaks.py --scan on Infer-6-Debugging returns 0 HIGH (target FP at cell 20 closed). The 5 pedagogical indices preserved ( referencing the EP/VMP model canonique) make this a richer pedagogical stub than #8161's reorder-only fix.

For ai-01 de-HOLD path on #8084: this PR (#8162) + #8146 (Search-3 cell 64) close the 2 mechanical FP classes per ai-01 DM msg-20260723T050120. Wiring PR #8151 (or #8084) can merge after both are MERGED.

Recommendation: merge this PR as canonical; close #8161 as superseded.

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

@myia-ai-01
myia-ai-01 merged commit d89a6e2 into main Jul 24, 2026
25 of 26 checks passed
jsboige added a commit that referenced this pull request Jul 24, 2026
#8162) -- URGENT fleet blocker (#8255)

* fix(security): strip probeAddresses banner from Infer-6 (re-injected by #8162 re-exec) -- fleet blocker unblock

Le commit d89a6e2 (#8162, "stub-ify viz demo cell 20", merge aujourd'hui 03:33) a
re-execute la cellule 20 de Infer-6-Debugging.ipynb SANS appliquer le strip post-exec.
La banniere probeAddresses (.NET Interactive HTTP-bootstrap, kernel-injected, se
re-injecte a CHAQUE re-exec .NET) s'est donc retrouvez committed dans l'output
data["text/html"] de la cell 20.

Fuite de securite sur un repo PUBLIC : la banniere contient un <script> JS qui appelle
loadDotnetInteractiveApi() -> probeAddresses([...]) avec la liste COMPLETE des
interfaces reseau du runner/contributeur :
  - IPv6 globalement routable Orange-FR /32 : 2a01:e0a:9d4:f320:6701:5a41:8422:35ad
    et 2a01:e0a:9d4:f320:7caf:c5ad:fe00:85e5
  - IPv6 link-local : fe80::902b:f9f6:2003:66a1, fe80::ae60:2bbf:92f7:4e06, ...
  - IPv4 LAN : 192.168.0.51, 172.21.192.1, 172.25.0.1
  - loopback ::1, 127.0.0.1

BLOCKER FLEET-WIDE : le check CI "probeAddresses banner guard" tourne en --scan-all
(pas scope aux fichiers changes), donc cette banniere Infer-6 fait FAILER TOUTES les
PR open du cluster (~20+ : #8238/#8239/#8243/#8249/#8253 + tranches cost-frontmatter
po-2025 + citations po-2023...). Aucune PR ne peut merger tant qu'Infer-6 porte la
banniere.

Fix : strip_probe_banner.py --apply (outil dedie, exception Rule-6 sanctionnee -- la
banniere est un artefact kernel, PAS un output pedagogique reel ; elle se re-injecte
a chaque re-exec .NET, donc le workflow canonique = re-exec PUIS strip, #8162 a oublie
le strip). Remplace data["text/html"] de la cell 20 output[0] (display_data) par "" --
structure output preservee, exec_count et autres outputs intacts. Precedents : #6338
(#6309), #6632 (#6312).

+1/-1, 1 fichier, 1 champ. validate_pr_notebooks.py PASS (17 cells).

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

* chore(twin-parity,#8057): rebaseline Probas-6 csharp_sha to post-strip Infer-6 blob

This PR strips the probeAddresses banner from Infer-6-Debugging (changing its
blob). Infer-6 is the C# side of the registered Probas-6 Debugging twin pair, so
per the twin-rebaseline rule (#8264, any PR touching a registered twin must
rebaseline its last_audit sha) this commit updates Probas-6 csharp_sha to the
post-strip blob (21c3019).

Verified via local fleet-merge simulation (merge #8267+#8246+#8250+#8255):
without this rebaseline, Probas-6 re-drifts after the banner strip
(af1ea69 pre-strip -> 21c3019 post-strip). With it, twin-parity goes GREEN
(OK=39) once the unblock sequence lands.

Note: #8267 also sets Probas-6 csharp_sha (to the pre-strip af1ea69, since it
rebaselined before this strip). If #8267 merges first, this line will conflict
trivially -- resolve by keeping THIS value (21c3019), which reflects the
actual post-strip Infer-6 blob.

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

---------

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
@jsboige
jsboige deleted the fix/c8104-infer6-cell20-stub 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