Skip to content

fix(skills-sync): fail the run when a push, gh call or skill copy fails - #177

Merged
bketelsen merged 2 commits into
mainfrom
lucilla/sync-skills-fail-loud
Nov 1, 2026
Merged

bketelsen merged 2 commits into
mainfrom
lucilla/sync-skills-fail-loud

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

The skills sync reported success when a push or a gh call failed.

scripts/sync-skills.sh:31 calls skills_sync_run_repo as an if condition. Bash ignores set -e for every command inside a function in that context, also inside a subshell that sets -e again. So the ( set -e; … ) block in scripts/lib/skills-sync-repo.sh did not stop on a failure: a failed push printed == <repo>: synced and the job ended green. Production evidence: run 40313372142 (2026-10-26), snowcat-cockpit: remote: This repository was archived so it is read-only / fatal: … 403, then PR #55 already open — branch force-updated and synced. The same masking applied to mkdir/rsync/marker writes in skills_sync_sync_repo (called as if !), which could stage a partial mirror.

Changes:

  • scripts/lib/skills-sync-repo.sh: every git and gh step in the subshell checks its own status (|| exit 1); the subshell's status is read with || rc=$?, so the function behaves the same under an if caller and under a set -e caller.
  • scripts/lib/skills-sync-containment.sh: mkdir, rsync and the marker write return 1 on failure.
  • test/sync-skills.test.mjs: 4 new tests drive scripts/sync-skills.sh (the real caller), with stubbed failures of push, gh pr list, gh pr create and rsync. Each asserts exit 1, ::error::sync failed for frostyard/consumer, no consumer: synced, and (for git/gh) that a later consumer still syncs. The existing sync-skills-run-repo tests call the bare function, so they did not see the bug.

Found in the 2026-10-31 core skills audit (Odrade report 2026-10-31-core-skills, action 1).

Risk tier

Risk tier: 2 — the automation script that pushes to consumer repositories (precedent #124). No workflow, permission or token change.

Verification

  • New tests fail on main (Missing expected rejection. for push, pr list, pr create; the rsync test fails without the containment change) and pass with the fix.
  • npm run check: docs gate 1.000/1.000/1.000, bash_syntax: 6/6, 72/72 tests pass.

sync-skills.sh calls skills_sync_run_repo as an `if` condition. Bash
ignores set -e inside a function in that context, also in a subshell
that sets -e again, so a failed push or gh call printed 'synced' and the
run stayed green (run 40313372142: 403 on an archived repo, then
'synced'). The same held for mkdir/rsync in skills_sync_sync_repo.

Every git, gh, mkdir and rsync step now checks its own status. The new
tests drive scripts/sync-skills.sh, the real caller, not the bare
function.
…ution

Cross-review findings: `git diff --cached --quiet` exits >1 on an error,
which counted as a change; and an empty realpath result for the clone
root made every absolute destination look contained. Both now fail the
repository. Two more entry-point tests cover them.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 1, 2026
@bketelsen
bketelsen merged commit cb5e9ad into main Nov 1, 2026
3 checks passed
@bketelsen
bketelsen deleted the lucilla/sync-skills-fail-loud branch November 1, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants