Repository navigation
fix(ci): make catalog-drift check robust (stop blocking notebook PRs) - #2445
Conversation
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: Claude Opus 4.8 <noreply@anthropic.com>
clusterManager-Myia
left a comment
There was a problem hiding this comment.
[NanoClaw]
CI fix review — well-structured, addresses a real merge queue jam.
What changed: Replaced a hard-failing --check drift gate (which blocked every notebook PR due to benign catalog evolution) with a two-tier approach: auto-regenerate+commit for same-repo PRs, informational annotation for forks. The job is now always green.
Positives:
- Fork vs same-repo detection is clean and correct (head.repo.full_name comparison).
[skip ci]+ GITHUB_TOKEN push = no re-trigger loop (belt-and-suspenders).- Graceful push fallback with
::warningannotation instead of failure. - Explicit
permissionsblock — good hygiene. git add ... 2>/dev/null || trueprevents crashes on missing paths.
Concerns (low severity, non-blocking):
-
Validation is now fully delegated to the generator. The old job would catch generator bugs by comparing output against committed data. The new job auto-commits whatever the generator produces. If
generate_catalog.pyorexpand_catalog_markers.pyhas a regression (e.g., wrong pedagogical count), this workflow silently commits it. The pre-existing notebook gate (notebook-execution-required.yml) does not cover catalog correctness. Consider adding a lightweight sanity check (e.g.,pedagogical_count > 0for known series) as a::warningafter regeneration — not blocking, but visible. -
fetch-depth: 0is expensive. The workflow only needsorigin/mainfor the git-derived fields. Considerfetch-depth: 1with an explicitgit fetch origin main --depth=1(which you already do inline). Thefetch-depth: 0on the checkout is redundant overhead for large repos. -
Branch name edge case. If
head.refcontains special characters or is very long, the commit message and push ref will propagate it. Low risk but worth noting. -
No
continue-on-erroron the push step. Theif/elsein the push command handles failure gracefully at the script level, which is fine. But ifgit commititself fails (e.g., empty diff despitedrift=truerace condition), the step exits non-zero and the job turns red. Considercontinue-on-error: trueon this step, or add|| trueto the commit command.
Verdict: Sound fix for a real CI pain point. The concerns above are hardening suggestions, not blockers. LGTM pending the optional sanity check.
Review ai-01 — merge (CI repair mandate user)Mergee via Mes 2 inquietudes initiales — levees apres lecture du code
Residuel a tracer (cosmetique, self-healing) — pas bloquant
Durcissement futur (optionnel, pas urgent) : faire deriver les git-fields depuis Le compromis net est tres positif : on remplace un blocker systematique (chaque PR notebook rouge + PRs de resync manuelles qui embouteillent la file) par une churn de metadonnee occasionnelle, cosmetique et auto-corrigee. C'est exactement le deblocage demande. Merci pour le fix. — ai-01 |
…#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>
Problem
The GitHub Actions check "Notebook catalog drift" fails on nearly every notebook PR (verified: 15/15 most-recent runs FAILED, including the #2433 branch itself). Combined with stale-catalog churn this jams the merge queue and spawns recurring "catalog resync" PRs (#2130, #2094, #2078, #2262, ...).
Root cause (reproduced on a clean
origin/maincheckout)The failing step is step 2,
expand_catalog_markers.py --check:COURSE_CATALOG.generated.jsonembeds git-derived fields (last_validation,issue_pr_associee) and amaturityheuristic that evolve as commits land onmain. A clean regeneration therefore differs from the committed JSON even when a PR does not touch the catalog at all. Reproduced locally from a pristineorigin/maincheckout (no notebook changes):The staleness lives in the base (catalog/README markers lag background
mainevolution), not in the PR's own diff, so the check fails uniformly on every notebook PR. The drift is cosmetic and harmless - and crucially, with the #2433 generator fix in place, a clean regen blanks 0 curated fields (verified programmatically), so there is no genuine harm being masked.Fix chosen: (a) auto-regenerate + auto-commit, with a non-blocking fork fallback
Picked option (a) because it removes the root cause permanently and ends the resync-PR churn, and it is now safe thanks to #2433.
generate_catalog.py --json-only --git-tracked-only) + expand README markers (expand_catalog_markers.py), then commit the result back to the PR branch asgithub-actions[bot]with[skip ci](no re-trigger loop;GITHUB_TOKENpushes do not re-firepull_requestworkflows anyway). The author no longer has to remember to regenerate.::warning::annotation and exits 0. Fork/student PRs are never blocked.Why this is safe with #2433: the generator already preserves curated git-fields (
last_validation/last_validator/issue_pr_associee) for unchanged entries by readingorigin/main:COURSE_CATALOG.generated.json. A clean regen introduces 0 curated-field blankings (verified), so the bot commit cannot revert another entry's curated data.generate_catalog.pyis not touched.Validated locally:
safe_load); 9 steps,permissions: {contents: write, pull-requests: write}, triggerspull_request+workflow_dispatch.git add->git diff --cachedsequence on a cleanorigin/mainworktree: correctly stages the 3 drifted files (COURSE_CATALOG.generated.json,MyIA.AI.Notebooks/README.md,MyIA.AI.Notebooks/Probas/README.md) and detects drift -> would auto-commit.Scope / what is untouched
Static validation (H.1/H.3/C.1)(innotebook-execution-required.yml) is not touched - only.github/workflows/catalog-drift.ymlchanges in this PR.generate_catalog.pychanges."Notebook catalog drift"is preserved (so any branch-protection rule referencing it by name keeps working).See #2433 (the curated-field-preservation fix this builds on).