ci(drift): make drift-live-pr head/base legs treat collector exit-2 as non-fatal#298
Merged
Conversation
commit: |
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.
The bug
The
drift-live-prjob's head leg let the drift collector's exit code 2 (critical drift found) propagate as a step failure. But exit-2 is the expected "drift present" signal that must feed the delta gate — it has to be non-fatal for the leg so the delta gate can decide block-vs-advisory by key presence.GitHub Actions runs
run:blocks underbash -e. The head-leg step'sset -uo pipefailline does not clear that-e, and there was noset +eguard around the collector call. So the instant the collector returned 2,-eaborted the step at thenpxline — beforeHEAD_EXIT=$?was even captured — and the delta gate never ran.On PR #297 the head leg logged
Exiting with code 2 (critical diffs found)then##[error]Process completed with exit code 2. The prior fix (#297) only hardened the base leg (which already wrapped the collector inset +e/set -e) and the no-keys degradation path; the keys-present head-leg live run still propagated exit-2.Makes drift-live-pr functional on drift-code PRs (was merged non-functional in #297).
The fix (scoped only to
.github/workflows/test-drift.yml)Both the base-leg and head-leg keys-present (
LIVE_LEGS_RAN=true) live-run steps now capture the collector's exit code withset +e/set -eand treat it as data:drift-report-{base,head}.jsonreport feeds the delta gate).Report filenames/paths are unchanged (
drift-report-base.json/drift-report-head.json), so the delta gate contract is untouched. The head leg was the actual #297 bug (it lacked theset +eguard); the base leg already tolerated exit-2, and gains only the explicit exit-5 classification for symmetry.Diff hunk
(The base leg gains the same explicit
exit 5classification block ahead of its existing-ne 0 && -ne 2fault check.)Red-green proof (keys-present live-run path)
The harness programmatically extracts the real base-/head-leg
run:bash from the YAML (python YAML parse — not hand-reconstructed), then drives it under GitHub's exact default shell (bash --noprofile --norc -e -o pipefail) with a fakenpxcollector on PATH that writes the expecteddrift-report-{base,head}.jsonand returns a configurable exit code.LIVE_LEGS_RAN=trueforces the keys-present branch.RED — current
mainYAML, head leg, fake collector exit 2 (reproduces #297)The step FAILS with exit 2 (the
head: collector exit ...line never prints —-ekilled the step at thenpxline). This is the #297 failure.GREEN — fixed YAML, head leg
GREEN — fixed YAML, base leg (same three)
Quality
actionlintclean on my changed steps. (The one reported SC2086 is at the pre-existing notify-job "Check previous run status" step — not part of this change.)pnpm run format:check— clean.pnpm run lint— clean.git status— only.github/workflows/test-drift.ymlmodified. Harness is a scratch tool under/tmp, not committed.🤖 Generated with Claude Code