Repository navigation
Description
Summary
Across .github/workflows/shepherd-board.yml, .github/workflows/shepherd-dup.yml, and .github/workflows/shepherd-rebase.yml, the final W7 session log step runs under if: always() and invokes python3 tools/shepherd.py log with hardcoded completion arguments (--verdict "ok" --note "board + labels refreshed", --note "phase A/B pass complete", --note "rebase shepherd tick") without binding ${{ job.status }}.
When an earlier workflow step fails or is cancelled, if: always() still executes W7 session log and appends a false completion record (verdict: "ok" / completion note) to logs/SESSION.jsonl on automation/session-log even though the scan, rewrite, sync, duplicate pass, or rebase pass never ran.
Live Production Evidence (main @ b1627e8)
Observed in workflow run 43752174585 (shepherd-board, commit b1627e83b437bfc948292f17a8ce4183cef23130):
- Step 4 (
Scan) crashed with exit code1(urllib.error.HTTPError: HTTP Error 403: rate limit exceededon/repos/limitlessprojects/Go-Hybrid/pulls?state=open&per_page=100&page=3). - Step 5 (
Rewrite board) and Step 6 (Sync tier labels) were skipped (conclusion: skipped). - Step 7 (
W7 session log) ran viaif: always()and executed:recording a falsifiedpython3 tools/shepherd.py --token-env GITHUB_TOKEN log --event board-refresh --verdict "ok" --note "board + labels refreshed"
verdict: "ok"and"board + labels refreshed"audit entry for a failed run where neither the board nor labels were touched.
The same structural defect exists in:
.github/workflows/shepherd-board.yml(--event board-refresh --verdict "ok" --note "board + labels refreshed").github/workflows/shepherd-dup.yml(--event dup-pass --note "phase A/B pass complete").github/workflows/shepherd-rebase.yml(--event rebase-tick --note "rebase shepherd tick")
Root Cause
tools/shepherd.py (cmd_log) has no --job-status binding, and the three if: always() workflow steps pass static completion strings rather than forwarding GitHub Actions ${{ job.status }}. Because if: always() runs after step failures and cancellations, static --verdict "ok" / completion --note arguments turn failed automation runs into false-positive audit records in logs/SESSION.jsonl.
Reproduction
python3 -m unittest discover -s tools -p test_shepherd_gate.py -vBefore the fix:
shepherd.py log --event board-refresh --verdict ok --note "board + labels refreshed" --job-status failureis unsupported, andshepherd-{board,dup,rebase}.ymlhardcode static completion notes/verdicts underif: always().
Expected Fix
- Add
resolve_log_outcome(verdict, note, job_status=None)and--job-statustotools/shepherd.py(cmd_log):- Direct CLI calls without
--job-statuspreserve callerverdictandnoteunchanged. - When
--job-statusis"success", preserveverdict(defaultingNoneto"ok") andnote. - When
--job-statusis non-"success"(e.g."failure"or"cancelled"), override optimistic verdicts with the normalized job status and rewritenoteto"job <status> before completion (intended: <note>)".
- Direct CLI calls without
- Pass
--verdict "ok"and--job-status "${{ job.status }}"in allif: always()W7 session logsteps acrossshepherd-board.yml,shepherd-dup.yml, andshepherd-rebase.yml. - Pin both
resolve_log_outcomebehavior and allif: always()workflowshepherd.py ... loginvocations intools/test_shepherd_gate.py.
Activity