Skip to content

fix(regenerate): tolerate orphaned ACC baseline SHA in module detection - #1

Merged
GeekTrainer merged 3 commits into
mainfrom
geektrainer/congenial-train
Aug 26, 2026
Merged

fix(regenerate): tolerate orphaned ACC baseline SHA in module detection#1
GeekTrainer merged 3 commits into
mainfrom
geektrainer/congenial-train

Conversation

@GeekTrainer

Copy link
Copy Markdown
Contributor

Description

The scheduled Regenerate learner branches (pull model) workflow has been failing on its daily cron. The detect step reads the last-processed ACC commit from course-build/.last-acc-sha and diffs it against the current ACC main HEAD. When the recorded baseline SHA no longer exists in the ACC repo (its history was rewritten / force-pushed, orphaning the commit), detect-affected-modules.mjs ran git diff <bad-object> and aborted with fatal: bad object ..., failing the run.

This makes detection resilient: an unreachable baseline is now treated the same as "no baseline" (a full regen) instead of crashing, so the pipeline self-heals on the next run (the regen PR advances .last-acc-sha to a valid commit on merge).

Related Issue

N/A

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🧪 Test update
  • 🔧 Refactor (no functional changes)

Affected Services

  • web (Astro SSR + React)
  • assets-svc (.NET 10)
  • workforce-svc (Java 21 / Spring Boot 3)
  • reporting-svc (Python FastAPI)
  • notifications-svc (Python FastAPI)
  • audit-svc (legacy Java 11 / Spring Boot 2.7)
  • auth-svc (legacy Java 11 / Spring Boot 2.7)
  • devcontainer / tooling / docs

Changes Made

  • Add a commitExists(cwd, rev) reachability check (via git cat-file -e <rev>^{commit}) to detect-affected-modules.mjs.
  • When the supplied --from baseline is not a reachable commit in the ACC repo, fall back to first-run semantics (full regen) instead of running git diff on a bad object. This is surfaced via a WARN log and a new baselineMissing field in the JSON output.
  • Add a temp-repo integration selftest exercising both the valid-baseline (normal diff) and orphaned-baseline (fallback, no crash) paths.

Testing

  • End-to-end (web): npm run test:e2e (Playwright) passes
  • .NET: dotnet test in services/assets-svc passes
  • Python: pytest in services/reporting-svc and/or services/notifications-svc passes
  • Modern Java: mvn test in services/workforce-svc passes
  • Currency-lagging Java: mvn test in services/audit-svc and/or services/auth-svc passes
  • Manually verified the app runs (npm run dev or docker compose up --build) and the affected flow works at http://localhost:4321

Ran node course-build/scripts/selftest.mjs (the same suite invoked by validate-branches.yml); all checks pass, including the new baseline-fallback cases.

Checklist

  • My change targets main (I have not hand-edited generated learner branches or promoted refs — see CONTRIBUTING.md)
  • My code follows the project's coding standards for the affected language/stack
  • My changes are focused on a single concern
  • I have added or updated tests where it makes sense
  • I have updated documentation (README, per-service READMEs, exercises.md) if needed
  • I have written clear commit messages explaining what and why

Additional Notes

This resilience fix lands the code path, but the .last-acc-sha currently committed on main still points at the orphaned SHA. With this change, the next scheduled run no longer errors: it performs a full regen and opens a PR that advances .last-acc-sha to a valid commit. No manual baseline edit is required, though committing a valid SHA would also work as an immediate unblock.

The scheduled "Regenerate learner branches" workflow crashed when the
recorded course-build/.last-acc-sha pointed at an ACC commit that no
longer exists (ACC history was rewritten). detect-affected-modules.mjs
ran `git diff <bad-object>` and aborted with "fatal: bad object",
failing the run.

Add a commitExists() reachability check; when the supplied --from
baseline is not a reachable commit in the ACC repo, fall back to
first-run semantics (full regen) instead of crashing, and surface it
via a WARN log and a baselineMissing output field. Add a temp-repo
integration selftest covering both the valid-baseline and
orphaned-baseline paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3750cefd-d322-4f02-9184-c8ac3eba2fff
Copilot AI lite review requested due to automatic review settings August 26, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Improves resilience of the course-build “detect affected modules” script used by the regenerate workflow by handling an invalid/orphaned baseline ACC SHA without crashing, and adds an integration selftest covering the fallback path.

Changes:

  • Add commitExists() and baselineMissing output to treat an invalid --from baseline as first-run/full-regen semantics.
  • Emit a warning when the baseline commit is missing/unresolvable instead of failing on git diff.
  • Extend selftest.mjs with a temp-repo integration test covering both valid and missing-baseline behavior.
Show a summary per file
File Description
course-build/scripts/detect-affected-modules.mjs Adds baseline-existence guard and exposes baselineMissing to prevent git diff from crashing on bad baseline SHAs.
course-build/scripts/selftest.mjs Adds an integration selftest that creates a temp git repo and verifies both normal diff and missing-baseline fallback behavior.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Suppressed comments (1)

course-build/scripts/detect-affected-modules.mjs:88

  • baselineMissing is computed using args.from.trim(), but git diff is run with the untrimmed args.from/args.to. If either value contains whitespace/newlines (e.g. read from a file), the baseline check can pass while git diff still fails with a bad revision. Consider normalizing from/to once and using those values for both the existence check and the diff.
  let files = [];
  if (!firstRun) {
    const out = git(args.acc, 'diff', '--name-only', `${args.from}`, `${args.to}`);
    files = out.split('\n').map(s => s.trim()).filter(Boolean);
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread course-build/scripts/detect-affected-modules.mjs
Comment thread course-build/scripts/selftest.mjs Outdated
GeekTrainer and others added 2 commits August 26, 2026 09:34
…ftest

Address review feedback:
- commitExists now uses `git rev-parse --verify --quiet <rev>^{commit}` and
  only treats exit status 1 (well-formed but unknown/unreachable revision) as
  "missing". Any other failure (bad --acc path, not a git repo, git missing)
  is rethrown so real configuration/runtime errors fail fast instead of
  silently masquerading as a missing baseline and triggering a full regen.
- selftest invokes the detector via process.execPath instead of "node" so it
  works when node isn't on PATH or under a different runtime, and adds a case
  asserting commitExists rethrows on a non-git directory.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3750cefd-d322-4f02-9184-c8ac3eba2fff
Address suppressed review note: baselineMissing was computed from a
trimmed --from while `git diff` used the raw --from/--to, so a value with
stray whitespace/newlines (e.g. read from a file) could pass the existence
check yet still abort the diff on a bad revision. Trim both revisions once
and use the normalized values for the existence check and the diff. Add a
selftest asserting a whitespace-padded baseline is normalized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3750cefd-d322-4f02-9184-c8ac3eba2fff
@GeekTrainer
GeekTrainer merged commit 14030c3 into main Aug 26, 2026
6 checks passed
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