Skip to content

fix(catalog): preserve curated git fields on regen-from-stale-branch - #2433

Merged
jsboige merged 1 commit into
mainfrom
fix/catalog-stale-branch-curated-fields
Jun 5, 2026
Merged

jsboige merged 1 commit into
mainfrom
fix/catalog-stale-branch-curated-fields

Conversation

@jsboige

@jsboige jsboige commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

When generate_catalog.py runs on a branch behind main, git log misses recent commits, causing last_validation, last_validator, and issue_pr_associee to be silently blanked for entries not touched on the current branch. This is the root cause of the COURSE_CATALOG.generated.json treadmill.

Root cause

Full overwrite via write_text() with no preservation logic. The catalog is regenerated from scratch each time, but git-derived fields come only from the current branch history.

Fix

  • _load_main_catalog(): loads the catalog from origin/main via git show before writing
  • _merge_curated_fields(): for each entry, if a curated git field is empty but has a value in the main catalog, it is preserved
  • Integration in main(): called between scan_all_notebooks() and the write step

Test evidence

147 passed in 0.27s

7 new regression tests in TestMergeCuratedFields:

  • empty fields merged from main
  • non-empty values preserved as-is
  • no matching main entry (graceful fallback)
  • empty main catalog (no crash)
  • mixed entries (some need merge, some don't)
  • partial field merge (only empty fields filled)
  • CURATED_GIT_FIELDS constant validation

Files changed

File Change
scripts/notebook_tools/generate_catalog.py +2 functions (_load_main_catalog, _merge_curated_fields) + integration in main()
scripts/notebook_tools/tests/test_generate_catalog.py +7 regression tests (TestMergeCuratedFields)

See #2149

When generate_catalog.py runs on a branch behind main, git log misses
recent commits, causing last_validation/last_validator/issue_pr_associee
to be silently blanked for entries not touched on the current branch.

Root cause: full overwrite via write_text() with no preservation logic.

Fix: load catalog from origin/main via git show before writing, then
merge curated git fields for entries where current values are empty.

New functions:
- _load_main_catalog(): git show origin/main:COURSE_CATALOG.generated.json
- _merge_curated_fields(): preserve curated fields from main for
  entries with empty values

Regression tests: 7 tests in TestMergeCuratedFields covering empty
field merge, non-empty preservation, no-match fallback, partial merge,
and mixed entry scenarios.

See #2149

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

@jsboige jsboige left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[NanoClaw]

Solid fix for a real catalog regression. When generate_catalog.py runs on a branch behind main, git log misses recent commits and curated fields (last_validation, last_validator, issue_pr_associee) get blanked for untouched entries.

Logic review:

  • _load_main_catalog() uses git show origin/main:COURSE_CATALOG.generated.json — correct approach, avoids checking out or merging.
  • Timeout of 15s is reasonable for a subprocess call. Catches TimeoutExpired, FileNotFoundError, and ValueError — good defensive coverage.
  • _merge_curated_fields() only fills empty fields from main, never overwrites non-empty current values. This is the right semantic: trust current branch data when available, fall back to main otherwise.
  • The two-pass check (first scan for needs_merge, then apply) is slightly redundant — could merge in one pass — but it's clearer this way and the perf impact is nil for catalog-sized data.

Test coverage (7 new tests in TestMergeCuratedFields):

  • Covers: empty→filled, non-empty→preserved, no match, empty main, mixed entries, partial field merge, constant validation.
  • The partial field merge test is the most important edge case and it's covered correctly.
  • No test for the _load_main_catalog() function itself (subprocess dependency) — acceptable since it's a thin wrapper, but worth noting.

One concern:

  • If origin/main doesn't exist (e.g. shallow clone, or remote named differently), the function silently returns empty dict and no merge happens. This is safe but could mask configuration issues. A log line at debug level (e.g. "origin/main not found, skipping merge") would help operators.

No correctness issues. The fix addresses the exact regression described.

@jsboige
jsboige merged commit 77fe8a3 into main Jun 5, 2026
2 of 3 checks passed
@jsboige
jsboige deleted the fix/catalog-stale-branch-curated-fields branch June 5, 2026 07:18
jsboige pushed a commit that referenced this pull request Jun 5, 2026
jsboige pushed a commit that referenced this pull request Jun 5, 2026
jsboige added a commit that referenced this pull request Jun 5, 2026
* fix(tweety-6,linq2z3): re-exec notebooks to resolve H.3 gaps

- Tweety-6: 10/10 code cells, 0 errors (was 1 null-exec in ASPIC+ exercise)
- Linq2Z3: 9/9 code cells, 0 errors (was 2 null-exec)
- Papermill python3 + .net-csharp kernels

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

* fix(catalog): regenerate to prevent CI drift

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

* chore(catalog): keep main's curated catalog+count-markers, avoid lossy regen (See #2433)

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jun 5, 2026
…See #2161) (#2435)

* enrich(Infer-14): relabel section 8 as Exercice 3 for >=3 exercises (See #2161)

Section 8 'Exemple guide: Comparer Deux Fonctions d'Utilite' had a stub
code cell with TODOs (not a complete solution), making it an exercise
by content-based classification. Relabeled as Exercice 3.

Before: 2 exercises (independence axiom + sequential medical test)
After:  3 exercises (independence axiom + sequential test + CARA/CRRA risk premiums)

* fix(Infer-14): re-exec full notebook to resolve H.3 blocker (See #2161)

- Papermill .net-csharp kernel from Infer/ CWD (FactorGraphHelper.cs load)
- 16/16 code cells now have execution_count + outputs (was 2/16)
- 0 errors, cell 2a15f646 (Exercice 3) now properly executed
- Resolves ai-01 bounce: cell had execution_count:null + outputs:[]

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

* chore(catalog): regenerate after Infer-14 split

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

* chore(catalog): keep main's curated catalog+count-markers, avoid lossy regen (See #2433)

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jsboige pushed a commit that referenced this pull request Jun 5, 2026
jsboige added a commit that referenced this pull request Jun 5, 2026
* enrich(RL): add PPO from scratch notebook rl_5c_ppo_from_scratch.ipynb (See #295, #1454)

- 26 cells (10 code, 16 markdown), 3 exercises, Papermill SUCCESS (70s)
- H.3 PASS: 10/10 exec_count, 0 errors
- Covers: clipped surrogate objective, PPO agent with mini-batch updates,
  GAE (lambda=0.95), PPO vs A2C comparison
- Exercises: (1) clipped surrogate implementation, (2) GAE ablation,
  (3) PPO vs A2C training comparison
- README RL updated: 8->9 notebooks, parcours, algorithmes, environnements
- Catalog: 512->513 entries

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

* chore(catalog): regen after rebase on main — preserve curated fields

Rebase on origin/main includes merges #2389, #2392-2394, #2400, #2401.
Catalog regen preserves curated fields (last_validation, issue_pr_associee)
that were updated on main since branch creation.

See #2385

* chore(catalog): keep main's curated catalog+count-markers, avoid lossy regen (See #2433)

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jsboige pushed a commit that referenced this pull request Jun 5, 2026
jsboige added a commit that referenced this pull request Jun 5, 2026
…#2445)

The "Notebook catalog drift" job ran `expand_catalog_markers.py --check`
against a freshly regenerated catalog and exited 1 on any difference.
Because COURSE_CATALOG.generated.json embeds git-derived fields
(last_validation, issue_pr_associee) and a maturity heuristic that evolve
as commits land on main, a clean regeneration differs from the committed
JSON even when a PR does not touch the catalog. Result: every notebook PR
failed this check regardless of its content, jamming the merge queue and
spawning recurring "catalog resync" PRs.

Fix: for same-repo PRs (CI has write access) auto-regenerate the catalog +
README markers and commit them back to the PR branch with a bot commit
([skip ci] to avoid a re-trigger loop). Authors no longer need to remember
to regenerate. The #2433 generator already preserves curated git-fields for
unchanged entries, so this auto-commit cannot blank another entry's curated
data (verified: 0 blankings on a clean regen). For fork/external PRs (no
write token) the job degrades to a non-blocking informational annotation
and always exits 0, so fork/student PRs are never blocked.

The job is now intentionally non-blocking. The REQUIRED notebook gate
"Static validation (H.1/H.3/C.1)" in notebook-execution-required.yml is
untouched. The check name "Notebook catalog drift" is preserved.

See #2433

Co-authored-by: myia-ai-01 <noreply@anthropic.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jsboige added a commit that referenced this pull request Jun 5, 2026
) (#2447)

* docs(GenAI-Texte): add FAQ section with 6 pedagogical entries (See #2161)

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore(2447): reset catalog + count-marker READMEs to main (docs-only FAQ keeps only GenAI/Texte/README)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: myia-ai-01 <myia-ai-01@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jsboige added a commit that referenced this pull request Jun 5, 2026
…#2161) (#2413)

* enrich(Infer): add Lean Gittins companion notebook + Lake project (See #2161)

- Infer-20b-Lean-Gittins.ipynb: 10 code cells, 10 sorry, lean4-wsl kernel
  - BanditArm, BanditInstance, Policy, RewardHistory definitions
  - Geometric discount (numerical + sorry proof)
  - Greedy/epsilon-greedy/UCB1 policies (Array.foldlIdx)
  - Gittins index definition + Bernoulli approximation
  - Gittins optimality theorem (sorry, INTRACTABLE)
  - Numerical examples with Beta posteriors
- gittins_lean/ Lake project with Mathlib v4.30.0-rc2:
  - Basic.lean: types (0 sorry)
  - Discount.lean: geometric convergence (1 proved + 2 sorry)
  - GittinsTheorem.lean: optimality + properties (5 sorry)

Note: 'instance' is Lean 4 keyword, renamed to 'inst' in notebook.
      List.argmax? absent from core, replaced with Array.foldlIdx.

* fix(Infer-16): add Plotly.NET core package pin for clean re-execution

- Add #r "nuget: Plotly.NET, 5.0.0" before Interactive ref (CS0103 fix)
- Sensitivity analysis uses reliable Console output (Plotly.NET C# API
  unstable on fresh kernel)
- Re-executed: 23/23 cells OK, 0 errors

* fix(gittins-lean): repair imports, broken proofs, reserved-keyword + renamed API; revert out-of-scope Infer-16 hollow

- Discount.lean: dead import Pow.Order -> SpecificLimits.Basic; fix geometric_series_converges (one_div); PROVE present_value_constant (eliminates 1 sorry via tsum_mul_right + tsum_geometric_of_lt_one + ring)
- GittinsTheorem.lean: 'instance' reserved-keyword -> 'inst' (x3); Array.idxMax?/mkArray nonexistent -> Array.range+foldl argmax / Array.replicate; gittinsPolicy N vs Policy type -> fun _ => ...
- Gittins.lean: import-before-docstring ordering
- Revert Infer-16 hollow (commit f9d824a stripped 569 lines) to restore origin/main verbatim -> keeps PR to one subject (gittins_lean companion)

lake build SUCCESS (1645 jobs, Lean 4.30.0-rc2 / Mathlib v4.30.0-rc2). sorry: 7 declared -> 6 (5 decls), all in new scaffolding (gittinsIndex + optimality + 2 index lemmas + discount_monotone).

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

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: jsboigeEpita <jean-sylvain.boige@epita.fr>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jsboige added a commit that referenced this pull request Jun 5, 2026
…s (See #2161) (#2470)

* docs(GenAI-SemanticKernel): add FAQ section with 6 pedagogical entries (See #2161)

6 entries: ImportError/version, NotebookMaker empty output, SK vs LangChain comparison table, AgentGroupChat loops, Qdrant RAG connection, filter-based debugging. Markdown-only (C.2 exception), 0 catalog files touched.

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(scope): strip stale catalog/README marker churn, keep only SK FAQ

Catalog + Probas/root/RL README marker blocks reverted to origin/main
(stale regen from base 619be7a pre-#2413 churned curated fields).
Catalog kept byte-identical to main; drift -> catalog lane (po-2023).
Net deliverable: GenAI/SemanticKernel/README.md FAQ (+78/-0).

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: myia-ai-01 <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jun 5, 2026
…See H.3) (#2473)

* fix(Search): re-execute 3 Part1-Foundations notebooks via Papermill (See H.3)

Papermill execution with python3 kernel, 0 errors, 0 remaining H.3 gaps.

Fixes:
- Search-3-Informed: pip install output, exercise stub outputs (9 cells)
- Search-10-SymbolicAutomata: automata-lib + z3 pip outputs, graphviz (6 cells)
- Search-11-Metaheuristics: pip install output, exercise stub output (10 cells)

Search-5 and Search-6 had no output changes (exercise stubs with pass/return None
produce no visible output, which is correct per C.1).

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

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(scope): strip stale catalog/README marker churn, keep Search re-exec

Catalog + Probas/root/RL README marker blocks reverted to origin/main
(stale regen from base 619be7a pre-#2413 churned curated fields).
Catalog kept byte-identical to main; drift -> catalog lane (po-2023).
Net deliverable: Search-3/10/11 Papermill re-exec + Search/README.

* chore(catalog): auto-regenerate catalog + README markers [skip ci]

Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 5, 2026
Keeps COURSE_CATALOG.generated.json and CATALOG-STATUS markers in sync. See #2433.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant