Repository navigation
fix(notebook-tools,#8057): registry rebaseline writes LF, not os.linesep - #8716
Merged
Merged
Conversation
`Path.write_text(..., encoding="utf-8")` opens with `newline=None`, which translates every `\n` to `os.linesep` -- CRLF on Windows. Half the fleet runs on Windows, so a single-pair rebaseline silently rewrote every line of the pair file, including the ones `surgical_rebaseline` had just left untouched. The surgical guarantee was tested at the string level and unenforced at the I/O level: `test_diff_limited_to_target_block` passes on every platform even when the file written to disk is entirely rewritten. Two layers: - `write_registry_text()` opens with `newline=""` (no translation) and is used at both write sites; - `.gitattributes` pins `twin_pairs.d/*.yaml` to `eol=lf`, so the invariant holds for any writer, not just this one. Plus two regression tests: one on the writer, one asserting no registry blob is CRLF in the index (`git ls-files --eol`, not the working tree -- with `core.autocrlf=true` a CRLF working tree is correct and a byte test on disk would fail on healthy Windows checkouts). Observed on #8709 (+23/-16) and #8713 (+24/-16), both single-pair rebaselines whose real change was two lines. See #8057 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 28, 2026
This was referenced Jul 28, 2026
jsboige
added a commit
that referenced
this pull request
Jul 28, 2026
check_twin_parity.py --update wrote CRLF line endings (Path.write_text translates \n to os.linesep on Windows), which made the registry YAML diffs show as full-file churn (+24/-16) instead of the real 8-line change. Fixed at source by #8716; this branch predates that fix. git --renormalize applies the .gitattributes LF rule to the tracked YAML without hand-conversion. Co-Authored-By: Claude <noreply@anthropic.com>
jsboige
added a commit
that referenced
this pull request
Jul 28, 2026
…riance factor Formula verified firsthand against Herbrich-Minka-Graepel 2007, and the committed output re-derived independently: c = 13.1762 V(0) = 0.79788 W(0) = 0.63662 sigma' = sqrt(s^2 (1 - (s^2/c^2) W)) = 7.1945 <- committed output, and the Infer.NET posterior of cell 16 without the s^2/c^2 factor = 5.0234 <- what #8709 had The sigma^2/c^2 factor is present in both the LaTeX and the C# cell. The .NET cell carries execution_count=21 (real local execution), its output reproduces the engine's own N(29.21, 7.19) from section 3, and the notebook is therefore self-consistent rather than merely plausible. No escape corruption introduced (13 literal \n, all legitimate C# Console.WriteLine, identical count on main). No output leak, no null execution_count. Twin registry YAML is LF post-#8716. Credit where due: po-2026 caught this by refusing to stand aside on claim priority when the substance was wrong. That is the behaviour the review rules are for. Closes #8704.
jsboige
added a commit
that referenced
this pull request
Jul 28, 2026
…) (#8713) Renormalisation faite avec le bon outil : `git add --renormalize` sur le repertoire du registre, pas de reecriture manuelle. Le diff affiche desormais le vrai changement (+8 lignes) au lieu du churn CRLF pleine-page — les blobs CRLF dataient d'avant #8716, ils ne venaient pas de cette PR. Rattachement PyMC-7 / PyMC-13 au chapitre MBML : l'asymetrie relevee dans #8711 est reelle et la correction s'aligne sur le traitement deja applique aux autres entrees du chapitre. See #8711, #8081.
jsboige
added a commit
that referenced
this pull request
Jul 28, 2026
…gma^2/c^2 factor (#8720) * fix(probas,#8718): PyMC-8 TrueSkill variance closed-form — restore sigma^2/c^2 factor Cell 29 (executed) and cell 28 (LaTeX prose) of the "7 bis" closed-form EP section contracted the posterior variance by W(t) alone, instead of the canonical (sigma_w^2 / c^2) * W(t) factor (Herbrich, Minka & Graepel 2007). Consequence: the cell printed sigma 8.33 -> 5.02, while the C# twin Infer-8 cell 16 (the real Infer.NET EP engine on the same config) prints N(29.21, 7.19). A twin pair thus displayed two different std-devs for the same update, and the Python side deviated from the reference engine. Fix: - cell 29 code: sig_new = sqrt(sig**2 * (1 - (sig**2/c**2)*W)) (both w and l) - cell 28 LaTeX: variance update now shows the sigma^2/c^2 ratio + a callout - Re-executed cell 29 (Stop & Repair): real captured output sigma -> 7.19 on both sides, matching Infer-8 cell 16. Cell is self-contained (scipy + math, hardcoded params, no kernel-state deps), so standalone exec reproduces the kernel stdout exactly. This is the Python source of the error propagated into my closed #8709 (Infer-8 C#, superseded by po-2026 #8715 which carries the canonical form + executed proof). Fixing the root on the PyMC twin. See #8718 See #8081 See #8704 Co-Authored-By: Claude <noreply@anthropic.com> * chore(twin-parity,#8718): rebaseline Probas-8 TrueSkill python_sha after variance fix Records the PyMC-8 cell 28+29 closed-form variance correction (sigma^2/c^2 factor restored) on the Python twin. python_sha rebaselined to the committed fix; csharp_sha unchanged (Infer-8 carries its own correction in #8715). known_differences documents the fix provenance (#8718, root of the error propagated into the closed #8709). Twin parity: OK=136 DRIFT=0. See #8718 Co-Authored-By: Claude <noreply@anthropic.com> * fix(probas,#8718): address review — cell30 consistency + callout rendering + LaTeX Addresses ai-01's CHANGES_REQUESTED on #8720 (maths correct, 3 rendering/consistency defects). Markdown-only, no re-exec. 1. cell 30 (interpretation of cell 29) still cited the OLD contraction: "sigma: 8,33 -> 5,02, soit -40%" — contradicting cell 29 which now prints 7.19. Fixed to "8,33 -> 7,19, soit -13,7%" (matches the executed output). "forte contraction" softened to "contraction" since the callout itself establishes that sigma^2/c^2 bounds the contraction. ±4.2 points on the skill left intact (25 -> 29.21 is still correct). 2. cell 28 callout ("Detail subtil") was double-escaped: a raw-string insertion left literal \n and \u00e9/\u2014 in the source, rendering as "\n> **D\u00e9tail subtil**" instead of a blockquote. Rewritten with real unicode chars + real newline + doubled LaTeX backslashes. Renders as a proper blockquote now. 3. Pre-existing LaTeX corruption in cell 30 (same class as #8709): BEL+pprox (\approx mangled) and TAB+o (\to mangled) — a write layer interpreted \a and \t before JSON serialization. Restored to \approx and \to. Verified: 0 control characters remain anywhere in the notebook; byte-stable round-trip; cell 29 (executed, the actual fix) unchanged. See #8718 Co-Authored-By: Claude <noreply@anthropic.com> * chore(twin-parity,#8718): re-rebaseline Probas-8 python_sha after review fixes Re-baseline after the cell 28/30 markdown fixes (callout rendering, cell-30 consistency, LaTeX restoration). python_sha -> 0994697; csharp_sha unchanged. Twin parity OK=136 DRIFT=0. Registry written in LF (post-#8716). See #8718 Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Grain: MED/tooling — lane myia-ai-01:CoursIA — prev: MED/docs (#8710)
check_twin_parity.py --updatepromet un diff chirurgical. Il tient cette promesse pendant le calcul et la perd a l'ecriture, sur toutes les machines Windows.Le defaut
Path.write_textouvre avecnewline=None, ce qui traduit chaque\nenos.linesep— donc en\r\nsous Windows. Le fichier entier est reecrit en CRLF, y compris les lignes quesurgical_rebaselinevenait deliberement de laisser intactes.La docstring de cette fonction dit, mesure a l'appui, pourquoi elle existe :
C'est exactement ce qui se reproduisait, a une echelle plus petite et par un autre chemin. Constate aujourd'hui sur deux PRs, toutes deux des rebaselines d'une seule paire :
+23/-16known_differences+24/-16sur deux fichiersLes
-16sont les lignes inchangees, supprimees puis reajoutees en CRLF. La ligne qu'un relecteur doit reellement examiner — le SHA rebaseline — se retrouve noyee au milieu.Pourquoi ca n'avait jamais ete vu
Le defaut est invisible la ou
core.autocrlf=true(ma machine, entre autres) : git renormalise en LF a l'ajout, le blob reste propre. Il n'apparait que la ouautocrlfest inactif, ou le CRLF part directement dans le blob. Un defaut qui ne se manifeste que sur une partie de la flotte voyage longtemps.Et la suite de tests ne pouvait pas l'attraper :
test_diff_limited_to_target_blockettest_noop_is_byte_identicaltestentsurgical_rebaseline, la fonction pure, sur des chaines. Elles passent sur toutes les plateformes meme quand le fichier ecrit sur disque est integralement reecrit. La garantie etait testee la ou elle tient et non appliquee la ou elle casse.Le correctif, en deux couches
1. L'ecrivain.
write_registry_text(path, text)ouvre avecnewline=""— aucune traduction, le texte part tel quel. Utilise aux deux sites d'ecriture (file-per-entry et mono-fichier legacy).2.
.gitattributes.scripts/notebook_tools/twin_pairs.d/*.yaml text eol=lf. La premiere couche corrige cet outil ; la seconde tient l'invariant pour n'importe quel ecrivain — unEditsous Windows, un script ad-hoc, un futur outil. Le fichier documente deja ce motif sous le nom « L268 » (« the Edit tool on Windows flips LF->CRLF intermittently when no explicit eol rule is set »), avec cinq occurrences constatees ; le registre en est la sixieme, et le bloc de commentaire du registre existait deja pour l'accueillir.Tests
test_write_preserves_lf_on_every_platform— ecrit viawrite_registry_text, relit en octets, exige l'absence de\r\n.test_registry_blobs_are_lf_only— backstop : aucun blob du registre n'est en CRLF.Ce second test interroge l'index (
git ls-files --eol, colonnei/), pas le working tree. C'est le detail qui compte : ma premiere version testait les octets sur disque et echouait sur 130 fichiers parfaitement sains — aveccore.autocrlf=true, un working tree en CRLF est correct, seul le blob doit etre en LF. Un test sur le disque aurait echoue sur toute machine Windows normalement configuree, pour un registre irreprochable. C'est la meme confusion de surface qui rend ce defaut difficile a voir.Effet sur les deux PRs en cours
Une fois cette PR sur
main, #8709 et #8713 rebasees verront leurs YAML renormalises en LF au prochaingit add— leur diff retombera aux deux lignes reelles sans effort de leur auteur. Je l'ai signale sur les deux.Perimetre
3 fichiers, +85/-2. Aucun notebook, aucun fichier de registre, catalogue byte-identique a
main. Le comportement desurgical_rebaselineest inchange : cette PR corrige ce qu'on fait de son resultat.See #8057