Skip to content

fix(infer-11,#6927): Plotly CDN-script -> 3x SvgChartHelper.Bar (topic distributions) - #6986

Merged
myia-ai-01 merged 1 commit into
mainfrom
feature/c546-infer11-svg-inline-6927
Jul 17, 2026
Merged

myia-ai-01 merged 1 commit into
mainfrom
feature/c546-infer11-svg-inline-6927

Conversation

@jsboige

@jsboige jsboige commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Substance pivot for #6927 Plotly-CDN → SVG migration (Infer series). Infer-11 cell[32] (id=0e5bd4a3) visualized a 3-topic × 9-word distribution matrix (phiSimule) using Plotly-CDN heatmap. Plotly-CDN renders BLANC on static GitHub sandbox (<script src=cdn.plot.ly> blocked). Replaces Plotly heatmap with 3 inline SvgChartHelper.Bar(...) calls (canon C548-L2, helper #6942 MERGED, Overlay API #6958 MERGED but reserved for numeric shared X).

Per investigation ai-01 issuecomment-4997257737, scope correct = Infer-11/12/18 (Infer-17 MERGED via #6946, Infer-19 OPEN via #6983 po-2024). c.546 = Infer-11 atomic sequentiel strict per R6 anti-monotonie L540-L1 ★.

Root cause

The Plotly-CDN call new PlotlyHtml(markup) (last expression) registers a record PlotlyHtml type with Formatter.Register(typeof(PlotlyHtml), ..., "text/html") and injects <script src="https://cdn.plot.ly/plotly-2.x.x.min.js"> into the markup. GitHub's static HTML rendering sandbox strips <script> tags from <text/html> MIME blocks → JS never executes → no heatmap drawn → BLANC output on https://github.com/.../blob/main/Infer-11-Topic-Models.ipynb.

Detectors (check_plotly_static_risk.py) DO catch this pre-commit (source-level cdn.plot.ly keyword + Formatter.Register(typeof(PlotlyHtml)...) pattern), but the fix must substitute the visualization entirely, not strip the script tag (which would leave broken Plotly markup).

Fix

  1. Stripped using Microsoft.DotNet.Interactive.Formatting; using System.IO; using System.Text.Json; record PlotlyHtml(...); Formatter.Register(typeof(PlotlyHtml)...); block — SvgChartHelper registers its own Formatter type registration via static ctor, so the PlotlyHtml machinery is no longer needed.
  2. Prepended bare #load "SvgChartHelper.cs" at top of cell (canon L542b-L1 ★ + L543-L1 ★ for kernel-cwd siblings in Infer notebooks — same pattern as DecInfer-7 cell 2's FactorGraphHelper.cs).
  3. Replaced the entire Plotly heatmap block (z list construction + trace/layout JSON-serialization + markup assembly + last expression new PlotlyHtml(markup)) with 3 separate SvgChartHelper.Bar(...) calls, one per topic (Sport, Politique, Musique). Each chart shows the distribution P(mot | topic) across the 9 vocabulary words, with the 3 dominant words at 0.30 visible as the highest bars.
  4. Preserved the LDA model logic INTACT (phiSimule matrix definition, topicNames, top-3 Console.WriteLine loop). The pedagogical message (block-diagonal structure of phi, 3 topics each owning 3 words) is preserved by the 3 separate charts + Console.WriteLine legends.

Why 3× Bar() and not Overlay() : SvgChartHelper.Overlay requires a shared numeric X axis. The categorical/temporal X (9 vocabulary words as string labels) is best visualized as N separate Bar() charts with legends explaining each topic's distribution. This avoids misusing Overlay() with a categorical X axis that doesn't fit its contract.

Verification (3 SVG charts in 1 target cell)

Item Value
Cell 32 (id=0e5bd4a3)
execution_count 11
n_out 23
SVG output 1 (Sport) text/html, 2525 chars, contains <svg xmlns='http://www.w3.org/2000/svg' ...
SVG output 2 (Politique) text/html, 2529 chars, contains <svg xmlns='http://www.w3.org/2000/svg' ...
SVG output 3 (Musique) text/html, 2527 chars, contains <svg xmlns='http://www.w3.org/2000/svg' ...
stdout legends 3× " [Topic] ... " explanations
Code cells executed 17/17
Errors 0
validate_pr_notebooks.py 17/17 PASS
detect_svg_decimal_commas.py 0 defects
detect_svg_empty_display.py 0 defects
check_plotly_static_risk.py Infer-11 clean (exit la liste 15 risky notebooks)

Plotly references remaining: 1 in cell[32] — historical comment documenting the migration rationale (NOT active code): "// La heatmap Plotly-CDN precedente rendait BLANC en static (GitHub sandbox les <script src=cdn.plot.ly>)."

Files changed

  • MyIA.AI.Notebooks/Probas/Infer/Infer-11-Topic-Models.ipynb — +73/-48 lines (cell[32] rewritten multi-line, SvgChartHelper.Bar substituted for Plotly heatmap block)

See also

…c distributions)

Migration cellule cell[32] (id=0e5bd4a3) du canon Plotly-CDN heatmap vers le helper canon SvgChartHelper.cs (#6942 MERGED, #6958 Overlay MERGED) charge via bare #load.

Le rendu Plotly CDN rendait BLANC en consultation statique (GitHub sandbox les <script src=cdn.plot.ly>). Le helper genere un <svg> inline zero-dep qui rend sur GitHub/nbviewer/offline.

Substance pivot :
- Bare #load "SvgChartHelper.cs" canonique (L542b-L1 ★, L543-L1 ★ DecInfer kernel-cwd-relative)
- Strip using/record/Formatter PlotlyHtml machinery
- Heatmap 3x9 (Plotly Viridis) -> 3 Bar() distincts (1 par topic : Sport/Politique/Musique)
- Bloc-diagonal structure preservee (3 mots a 0.30 par topic visible par Bar + legende textuelle)
- Console.WriteLine legends explicatives pour chaque topic

Canon respecté :
- Helper unique SvgChartHelper.cs #6942 (R3-deconfliction L623-L1 ★)
- MIME text/html (canon C548-L2 confirme)
- Model = c.545 DecInfer-8 (3 Bar() x N series, meme pattern canonique)
- execution_count != null (H.4 regle, preuve locale dotnet-interactive)
- Cellule source multi-ligne preservee (L544-L1 ★★★ anti silent-failure)

Verification firsthand (cell[32] execution_count=11, n_out=23) :
- SVG #1 P(Sport) : 2525 chars text/html <svg>
- SVG #2 P(Politique) : 2529 chars text/html <svg>
- SVG #3 P(Musique) : 2527 chars text/html <svg>
- 3 stdout Console.WriteLine legends explicatives
- 0 erreur kernel

Gates :
- validate_pr_notebooks.py : 17/17 PASS
- detect_svg_decimal_commas : 0 defects
- detect_svg_empty_display : 0 defects
- check_plotly_static_risk : Infer-11 clean (sortie de la liste 15 risky notebooks)

Refs #6927, refs #3801, refs #6942, refs #6958
@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 5.7s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 4.5s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 4.1s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 5.2s
Search-1-StateSpace.ipynb ✅ SUCCESS 4.2s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 3.1s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 27.3s
GameTheory-4c-NashExistence-Python.ipynb ✅ SUCCESS 3.8s

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: 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)

@jsboige

jsboige commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Forensic §H.4 + vision QA (po-2024, lane Opus vision-capable — backstop périodique #6927 canon pipeline)

Vérifié firsthand sur PR head a6fe53e5 (re-fetch pull/6986/head). cell[32] (id 0e5bd4a3, exec_count=11) : 3 SvgChartHelper.Bar(...) → 3 vrais <svg> committés dans l'output (out[17]/out[19]/out[21], ~2525 chars chacun, text/html).

Canon §4 (corrigé) — EXEC_PROVED : helper chargé, chaque display(Bar(...)) rend son SVG. Pas de white-figure (out_len > 0, 3/3).

Vision QA (render Playwright → screenshot, capability GLM-invisible) — les 3 charts sont géométriquement corrects et pédagogiquement sensés, non dégénérés :

  • Axe Y linéaire 0 / 0.081 / 0.162 / 0.243 / 0.324 (échelle de probabilité), 9 labels X (sport/équipe/match/politique/élection/vote/musique/concert/artiste), titre P(mot | Topic=<T>) - 3 mots dominants a 0.30.
  • Rotation correcte du topic dominant : out[17]=Sport (sport/équipe/match en barres hautes ~0.30), out[19]=Politique (politique/élection/vote), out[21]=Musique (musique/concert/artiste) — les 6 autres mots en barres minuscules (~0.02-0.04) à chaque fois. Signal LDA textbook.
  • Couleur #4C72B0, axes/lignes présents.
  • 0 comma-coords dans les 3 SVGs → detect_svg_decimal_commas.py (feat(notebook-tools,#3801): detect_svg_decimal_commas.py — flag SVG broken by French decimal commas #6959) passerait (canon décimal-virgule respecté : points, pas fr-FR).

Verdict : SOTA-OK + EXEC_PROVED + VISION-OK. Rendu correct, prêt pour merge. Pas de CHANGES_REQUESTED de ma part (PR étudiante/contributeur interne — gates déterministes verts + rendu visuel validé). Ce comment est un backstop vision factuel, pas un formal review state (compte shared jsboige → gh pr review --approve échoue ; evidence-cited comment only).

myia-ai-01 pushed a commit that referenced this pull request Jul 17, 2026
…ies) (#6989)

Substance pivot for #6927 Plotly-CDN -> SVG migration (Infer series). Infer-12
cell[9] (id=c30c821e) visualized a hierarchical shrinkage comparison (vrai /
no-pool / hierarchique) across 8 classes via Plotly grouped-bars CDN. Plotly-CDN
renders BLANC on static GitHub sandbox (<script src=cdn.plot.ly> blocked).
Replaces the grouped-bars with 3 separate SvgChartHelper.Bar() calls (one per
series), each showing the 8-class distribution.

SvgChartHelper.Overlay (#6958 MERGED) requires a SHARED NUMERIC X axis --
categorical class labels (cl.0..cl.7) don't fit, so 3 distinct Bar() charts +
Console.WriteLine legends (mirrors c.545 DecInfer-8 canonical pattern).

Pattern canonique L542b-L1 + L543-L1 + L544-L1 validated 5x (c.542 #6963,
c.543 #6967, c.545 #6977, c.546 #6986, c.547 #this). NB: this cell uses
`display(new PlotlyHtml(markup))` as last expression, so we use
`display(SvgChartHelper.Bar(...))` per DecInfer-7 canon (proven to produce
text/html MIME with <svg>, validate_pr_notebooks EXEC_PROVED).

Cell structure (60 lines):
- L000-L002: using directives (Microsoft.DotNet.Interactive.Formatting, System.IO, System.Collections.Generic)
- L003-L005: record PlotlyHtml + Formatter.Register block
- L006: blank
- L007-L008: Console.WriteLine header (Classe | n | ...)
- L009-L027: loop + MSE calculation (vraiArr, noPoolArr, hierArr populated)
- L028: blank
- L029-L033: Plotly comment header (Bar chart Plotly groupe)
- L034-L058: Plotly block (xs, tVrai, tNoPool, tHier, layout, markup, display)
- L059: closing } of outer Plotly block

Replacement strategy:
1. Strip using directives (L000-L002) -- SvgChartHelper registers Formatter
2. Strip record PlotlyHtml + Formatter.Register block (L003-L005)
3. Replace Plotly block (L029-L058) with 3 SvgChartHelper.Bar() calls
4. Prepend bare #load "SvgChartHelper.cs" canon

Preserves INTACT: Console.WriteLine header (L007-L008), MSE loop + calculations
(L009-L027), the pedagogical message (3 series showing shrinkage toward mu).

After pattern nbformat.write churn (L619-L2, L595-L2 canon), applied minimal-diff
JSON-level surgical swap preserving cell[9] only -- markdown cells 4663e998,
factor-graph structure byte-identical to main.
@myia-ai-01
myia-ai-01 merged commit 7a49d5b into main Jul 17, 2026
21 checks passed
jsboige added a commit that referenced this pull request Aug 15, 2026
… flag (+9 regression tests) (#11084)

* feat(guard,#11044): recalibrate FP organ — cited verdicts no longer flag as concerns

Measured defect (triage po-2024:CoursIA-2, window 07-14..07-20): 11/64 flagged
signals were positive reviews quoting a verdict they did not emit ("No
CHANGES_REQUESTED", "Verdict : COMMENT_WITHOUT_CONCERNS", "the CHANGES_REQUESTED
reflects a pre-fix state"). An organ crying wolf 17% of the time is an organ
that gets ignored — the exact mechanism by which the 42 real nits slipped
through.

Four calibrated layers, each anchored to named PRs:
- CITERS (occurrence-level citation guard): negation ("No", "Pas de",
  "without"), definite-article narration ("the"), hypothetical modals
  ("would") in the 30 chars before a marker kill that occurrence.
- VERDICT_POSITIVE ("COMMENT_WITHOUT_CONCERNS"): formal verdict overrides
  prose concern counts (#7583/#7593 resolution narrations).
- POSITIVE_MARKERS (soft: "SAFE/Safe to merge", "Verdict : OK"): rescue only
  bodies with no live concern — mixed Hermes reviews keep flagging.
- New CONCERN_MARKERS "SCOPE FLAG"/"scope mismatch": #7298 was caught only by
  accident; the class was invisible. Recovered 7 true positives on 07-18 alone.

Acceptance (falsifiable, per ai-01 Phase 2): the 11 named FPs (#6291 #6699
#6986 #7233 #7243 #7248 #7252 #7284 #7286 #7583 #7593) no longer flag; the 42
NON-LEVE still flag (40 distinct PRs replayed, all >=1 signal kept); founder
#10761 still flags (2 signals). End-to-end audit 07-14..07-20 (saturated 400,
07-18->07-20): 26 -> 25 flagged, -8 FP, +7 genuine SCOPE FLAGs.

Tests: 13 -> 22 (FP classes, mixed-review and emitted-verdict guards).

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

* fix(#11045): cover English 'before merge' demand phrasing (2 measured FNs #594/#590)

Window 04-23..04-30 triage (Epic #11044) exposed 2 false negatives: PRs
merged with zero lift while reviews demanded 'issues that should be
addressed before merge' (#594) and 'CRITICAL - Must fix before merge'
(#590). 'avant merge' was already a marker; its English mirror was not.
One marker covers both FNs. Acceptance re-run: 11 FP unflagged, 40
NON-LEVE still flagged, both FN PRs now flag, 24/24 tests.

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

* fix(#11045): treat 'previous' as citation word (narrated retraction FP #748)

Window 05-01..05-07 triage (Epic #11044): PR #748's flagged signals were
the retraction itself - 'CORRECTION - Previous CHANGES_REQUESTED was
incorrect... Revised verdict: APPROVE' plus the bot's 'APPROVE -
previous CHANGES_REQUESTED retracted'. 'previous' can only narrate a
past demand, never issue one. Acceptance re-run: 11 FP unflagged, 40
NON-LEVE still flagged, #748 unflagged, FN corpus #594/#590 and the 5
FLAG-OK of the window still flagged, 25/25 tests.

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

* feat(nits,#11044): 3 narration citers from window 05-08..05-14 (pas/stale/needs rebase)

18 flags / 249 PRs triaged on #11044. 11 FLAG-OK (0 DEFECT-ALIVE on main),
7 FLAG-FP of which 3 mechanized as CITERS:

- "pas": FP #860 « **COMMENTED** (pas CHANGES_REQUESTED) » — French
  negation without « de » (bare form not covered by "pas de").
- "stale": FP #977 « pending dismissal of stale CHANGES_REQUESTED » —
  re-review request narrating a past reserve.
- "needs rebase": FP #887 « CONFLICTING — needs rebase before merge » —
  procedural demand satisfied by the merge itself (recidive of #729,
  window 05-01..05-07, retroactively covered).

Acceptance: 28 tests pass; harness replays 51 corpus PRs — 11 FP
unflagged, 40 NON-LEVE still flagged.

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

* feat(nits,#11044): arrow-citer for conditional verdicts from window 05-15..05-21

8 flags / 194 PRs triaged on #11044. 6 FLAG-OK (1 DEFECT-UNMEASURED
visual QA #1253, rest DEFECT-NONE), 2 FLAG-FP:

- #1247 « Si Static validation rouge → CHANGES_REQUESTED » : conditional
  future verdict. An arrow immediately before a marker is a derivation,
  never an emission — handled in _is_cited (not CITERS) since the arrow
  is not a word.
- #1138 « Awaiting ... review before merge » : procedural note, accepted
  as residual FP (the awaited review flags on its own concerns).

Acceptance: 30 tests pass; harness replays 51 corpus PRs — 11 FP
unflagged, 40 NON-LEVE still flagged.

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

---------

Co-authored-by: jsboige <jsboige@gmail.com>
Co-authored-by: Claude-Code <noreply@anthropic.com>
@jsboige
jsboige deleted the feature/c546-infer11-svg-inline-6927 branch September 2, 2026 13:14
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