Skip to content

fix(drift): pass --report to Auto-fix step so it reads the pinned report#314

Merged
jpr5 merged 1 commit into
mainfrom
fix/drift-report-path
Jul 18, 2026
Merged

fix(drift): pass --report to Auto-fix step so it reads the pinned report#314
jpr5 merged 1 commit into
mainfrom
fix/drift-report-path

Conversation

@jpr5

@jpr5 jpr5 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Root cause

The Auto-fix drift step in .github/workflows/fix-drift.yml ran npx tsx scripts/fix-drift.ts with no --report flag, so fix-drift.ts defaulted reportPath to the repo-root drift-report.json. But FIX #F3 moved the collector's report to $RUNNER_TEMP (outside the repo checkout) and pinned a copy to $RUNNER_TEMP/drift-report.pinned.json. Nothing writes the repo-root file anymore, so readDriftReport threw and the job died with exit 3 before the fixer ran.

This is the recurring drift-job failure — e.g. run 29634448013:

Fatal error: Error: Drift report not found at /home/runner/work/aimock/aimock/drift-report.json
    at readDriftReport (scripts/fix-drift.ts:199:11)
    at main (scripts/fix-drift.ts:1167:18)   → exit code 3

The earlier steps succeeded because none of them read the repo-root file: Collect wrote to $RUNNER_TEMP, Check for critical diffs read only steps.detect.outputs.exit_code, and Pin cp'd within $RUNNER_TEMP. The Assert and Create PR steps already read --report "${PINNED_REPORT}"; only the Auto-fix step was missed when FIX #F3 relocated the report.

The prompt's mv-vs-cp hypothesis was ruled out — the pin uses cp, and both its src/dest are in $RUNNER_TEMP. The real gap was the missing --report on the Auto-fix invocation.

The fix

Pass --report "${PINNED_REPORT}" to the Auto-fix step (with PINNED_REPORT in its env), matching the Assert and Create-PR steps. The fixer now reads the same out-of-repo pinned report the integrity gate uses — lightest correct change, consistent with the existing design.

Red-green proof (real failure surface)

Replicated the workflow's exact sequence locally: collector report written to a simulated $RUNNER_TEMP, pinned via cp, repo-root drift-report.json absent, then ran the real scripts/fix-drift.ts.

RED (pre-fix invocation, bare fix-drift.ts, no --report):

Fatal error: Error: Drift report not found at .../drift-report-path/drift-report.json
    at readDriftReport (scripts/fix-drift.ts:199:11)
    at main (scripts/fix-drift.ts:1167:18)
RED exit code = 3

Same error, same stack frames, same exit code as CI.

GREEN (fixed invocation, fix-drift.ts --report "$PINNED_REPORT"):

Loaded drift report: 1 entries from 2026-07-18T00:00:00Z
Invoking Claude Code CLI...

The report is read (past readDriftReport:199 / main:1167) and the fixer proceeds to invoke Claude Code. No "not found", no fatal error.

Unit-level red-green (src/__tests__/fix-drift-workflow.test.ts): 3 new text-shape tests assert the Auto-fix step carries --report "${PINNED_REPORT}" and the PINNED_REPORT env, and that no bare fix-drift.ts invocation remains. All 3 FAIL against the pre-fix workflow (stashed) and PASS against the fix.

Verification

  • pnpm run format:check clean
  • pnpm run lint clean
  • pnpm run test — 4625 passed, 44 skipped, 0 failed
  • pnpm run build (tsdown) clean
  • commitlint --from origin/main --to HEAD exit 0
  • No version bump. Only .github/workflows/fix-drift.yml and the test file changed.

🤖 Generated with Claude Code

FIX #F3 moved the collector's drift report to $RUNNER_TEMP (outside the repo
checkout) and pointed the Assert and Create-PR steps at the pinned copy, but the
Auto-fix step still ran fix-drift.ts with no --report. It fell back to the
repo-root drift-report.json that FIX #F3 no longer writes, so readDriftReport
threw "Drift report not found" and the fixer died with exit 3 before running —
the recurring drift-job failure (e.g. run 29634448013).

Pass --report "${PINNED_REPORT}" to the Auto-fix step, matching the Assert and
Create-PR steps, so the fixer reads the same out-of-repo pinned report the
integrity gate uses. Add regression tests locking the wiring.
@pkg-pr-new

pkg-pr-new Bot commented Jul 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@314

commit: 1558553

@jpr5
jpr5 marked this pull request as ready for review July 18, 2026 17:22
@jpr5
jpr5 merged commit adf2f13 into main Jul 18, 2026
30 checks passed
@jpr5
jpr5 deleted the fix/drift-report-path branch July 18, 2026 17:23
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