Add typed exit codes and confirmation gate to skill sync/upgrade#5897
Open
samuv wants to merge 2 commits into
Open
Add typed exit codes and confirmation gate to skill sync/upgrade#5897samuv wants to merge 2 commits into
samuv wants to merge 2 commits into
Conversation
samuv
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
aponcedeleonch,
jhrozek,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
July 21, 2026 15:19
This was referenced Jul 21, 2026
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 15:31
dd81407 to
a7e9269
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 15:31
726ce33 to
9efdc60
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## skills-lock/05-upgrade #5897 +/- ##
=========================================================
Coverage ? 71.64%
=========================================================
Files ? 707
Lines ? 72271
Branches ? 0
=========================================================
Hits ? 51777
Misses ? 16739
Partials ? 3755 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 16:58
a7e9269 to
9deff64
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 16:58
9efdc60 to
0e58495
Compare
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 17:08
9deff64 to
3e750f4
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 17:08
0e58495 to
58e1107
Compare
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 17:14
3e750f4 to
cf3c890
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 17:14
58e1107 to
80ae30f
Compare
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 17:17
cf3c890 to
aecb406
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 17:18
80ae30f to
5f504ce
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 17:25
5f504ce to
02ef32f
Compare
RFC THV-0080 gives CI a scriptable contract for sync/upgrade: exit 2 for check/freshness failures, 3 for partial failures, 4 for policy rejections, distinct from the generic 1 cobra already uses. It also requires a pre-install confirmation gate — skill content is a set of AI-followed instructions, so a non-interactive run must refuse outright without --yes rather than silently proceeding. - cmd/thv/app/exitcode.go: exitCodeError carries a specific exit code through a RunE return; main.go maps it via ExitCodeFromError instead of a hardcoded os.Exit(1) - cmd/thv/app/skill_confirm.go: requireConfirmation prompts on a TTY, refuses with ExitCodePolicyRejection off one - sync/upgrade gain --yes, skipped automatically by --check/ --preview (which never install anything); their exit-code mapping prioritizes partial failure over drift/ref-change-blocked - docs/arch/12-skills-system.md: new Project Lock File section covering rollout gating, schema, install/uninstall hooks, sync, upgrade, and the exit-code contract - CLI E2E coverage for all four exit codes (0/2/4, plus --yes) This is the last PR of Stack 1 (lock file + sync + upgrade) for RFC THV-0080. Stack 2 (Sigstore signing/verification) builds on top once this stack is fully merged; TOOLHIVE_SKILLS_LOCK_ENABLED stays off by default until that full v1 lands. Part of the production stack for #5715 (RFC THV-0080). Stack: 6/6.
upgradeExitError mapped a ref-change-blocked outcome to exit 4 unconditionally, even during --preview — where nothing was actually blocked, only reported. Thread preview through, mirroring how syncExitError already gates Drifted behind --check. Also reconcile a docs contradiction about --preview's side effects, drop a stale signer-change reference in the exit-code doc comment (that guard doesn't exist until Stack 2), and add upgrade exit-code E2E coverage.
samuv
force-pushed
the
skills-lock/05-upgrade
branch
from
July 21, 2026 17:34
664f512 to
7aa5c69
Compare
samuv
force-pushed
the
skills-lock/06-cli-exitcodes
branch
from
July 21, 2026 17:34
f0d9cc9 to
840b9d4
Compare
15 tasks
Contributor
Author
|
Tracked in #5899 (RFC THV-0080 stack). |
JAORMX
approved these changes
Jul 21, 2026
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.
Summary
sync/upgrade: exit2for check/freshness failures,3for partial failures,4for policy rejections — distinct from the generic1cobra already uses everywhere else. It also requires a pre-install confirmation gate: skill content is a set of AI-followed instructions, so a non-interactive run must refuse outright without--yesrather than silently proceeding. This is the last PR of Stack 1.cmd/thv/app/exitcode.go:exitCodeErrorlets aRunEcarry a specific exit code back through cobra;main.gomaps it viaExitCodeFromErrorinstead of a hardcodedos.Exit(1).cmd/thv/app/skill_confirm.go:requireConfirmationprompts on a TTY, refuses withExitCodePolicyRejectionoff one (matching the RFC's stated rationale, not the workload-upgrade command's precedent of silently skipping the prompt when non-interactive — skill content is higher-stakes).sync/upgradegain--yes, skipped automatically by--check/--preview(which never install anything). Exit-code mapping prioritizes partial failure over drift/ref-change-blocked (a real operational failure is a stronger signal than a guard doing its job).docs/arch/12-skills-system.md: new "Project Lock File" section covering the rollout gate, schema, install/uninstall hooks, sync, upgrade, and the exit-code contract — plus updates to the existing storage/API/CLI tables.--checkclean/drifted, non-interactive refusal,--yesbypass).Part of the production stack for #5715 (RFC THV-0080). Stack: 6/6 (final PR of Stack 1) — lockfile → lock-service → install-hooks → sync → upgrade → cli-exitcodes. Based on #5896 (PR5).
Type of change
Test plan
task test)task test-e2e, scoped:ginkgo --label-filter=skills-lock)task lint-fix)Unit tests for
ExitCodeFromError/withExitCode(including error wrapping),syncExitError/upgradeExitErrorprecedence rules,requireConfirmation's--yesand non-interactive-refusal paths (the interactive TTY-prompt branch is untestable in a normalgo testprocess and is left uncovered, matching the existingconfirmUpgradehelper for workload upgrades — this codebase's established precedent for interactive-only code). New CLI E2E spec file drives the realthvbinary against a real server process and asserts actual process exit codes via*exec.ExitError.Also verified against a clean
origin/mainworktree that a batch of 24 unrelated skills E2E failures on this dev machine (extracting skill: target path validation: symlink found at "/var") are a pre-existing macOS-local environment quirk (/var→/private/var), not something this stack introduced.Does this introduce a user-facing change?
Not yet — same
TOOLHIVE_SKILLS_LOCK_ENABLEDgate as the rest of the stack. Once the full RFC v1 (this stack + the later Sigstore stack) lands:thv skill sync/upgradewill prompt for confirmation before installing and use the documented exit codes for scripting.Special notes for reviewers
TOOLHIVE_SKILLS_LOCK_ENABLEDdefault — per the plan agreed for this stack, the feature stays gated until the Sigstore stack (built on top of this one) also lands, since the RFC frames "v1" as lock-file and signing together.🤖 Generated with Claude Code