Add thv skill sync: restore project skills from the lock file#5895
Open
samuv wants to merge 3 commits into
Open
Add thv skill sync: restore project skills from the lock file#5895samuv wants to merge 3 commits into
samuv wants to merge 3 commits into
Conversation
samuv
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
aponcedeleonch,
jhrozek,
rdimitrov and
reyortiz3
as code owners
July 21, 2026 14:48
This was referenced Jul 21, 2026
samuv
force-pushed
the
skills-lock/04-sync
branch
from
July 21, 2026 15:31
784a7ce to
9c2d5f5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## skills-lock/03-install-hooks #5895 +/- ##
================================================================
- Coverage 71.64% 71.61% -0.04%
================================================================
Files 704 706 +2
Lines 71919 72103 +184
================================================================
+ Hits 51528 51633 +105
- Misses 16678 16744 +66
- Partials 3713 3726 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
samuv
force-pushed
the
skills-lock/03-install-hooks
branch
from
July 21, 2026 16:58
7824f3f to
1514a9d
Compare
samuv
force-pushed
the
skills-lock/04-sync
branch
from
July 21, 2026 16:58
9c2d5f5 to
06a66f8
Compare
samuv
force-pushed
the
skills-lock/03-install-hooks
branch
from
July 21, 2026 17:08
1514a9d to
3dd34f4
Compare
samuv
force-pushed
the
skills-lock/04-sync
branch
from
July 21, 2026 17:08
06a66f8 to
42a03de
Compare
samuv
force-pushed
the
skills-lock/04-sync
branch
from
July 21, 2026 17:14
42a03de to
4604083
Compare
15 tasks
Contributor
Author
|
Tracked in #5899 (RFC THV-0080 stack). |
RFC THV-0080 needs a way to restore a project's pinned skill set on any machine (a fresh clone, CI, a teammate's laptop) and to verify on-disk content still matches the lock file without installing anything. This adds the full sync vertical slice: service logic, HTTP endpoint, client, and CLI command. - Sync reconciles installed skills against toolhive.lock.yaml: missing/drifted entries reinstall at the pinned reference (never re-resolving source, see buildPinnedReference), --check reports drift read-only, --adopt/--prune handle unlocked installs - Fixes a real bug this surfaced: reinstalling at an unchanged pinned digest hit both the OCI and git install paths' "same digest means content is already correct" fast path, silently skipping re-extraction — exactly the drift sync exists to repair. A new internal SyncRestore option bypasses that fast path. - POST /api/v1beta/skills/sync via a narrow skillSyncer interface (pkg/api/v1), so this PR doesn't need to ship an Upgrade stub - `thv skill sync` CLI (--check/--adopt/--prune/--clients/ --project-root, auto-detected via .git when omitted) Part of the production stack for #5715 (RFC THV-0080). Stack: 4/6.
reinstallPinned reinstalls at a pinned reference derived from the lock entry, and that pinned string was flowing straight into ResolvedReference via the install path — a drift repair overwrote it with an internal restore form instead of preserving what Source had actually resolved to, which later corrupts upgrade's ref-change detection. Add a LockResolvedReference override on InstallOptions, mirroring the existing LockSource one.
Picks up the AlreadyCurrent JSON tag rename and Drifted doc comment fix from the PR2 review pass.
samuv
force-pushed
the
skills-lock/03-install-hooks
branch
from
July 22, 2026 20:13
bdf19aa to
176f367
Compare
samuv
force-pushed
the
skills-lock/04-sync
branch
from
July 22, 2026 20:13
d94ef78 to
e4b12ca
Compare
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
syncvertical slice in one PR since the CLI command can't exist without its API endpoint.Syncreconciles installed skills againsttoolhive.lock.yaml: missing/drifted entries reinstall at the pinned reference (never re-resolvingsource— seebuildPinnedReference),--checkreports drift read-only,--adoptrecords lock entries for unmanaged installs,--pruneremoves installs no longer in the lock.syncexists to repair (a tampered file doesn't change the pinned commit/digest). A new internalSyncRestoreoption onInstallOptionsbypasses that fast path in bothinstall_extraction.goandinstall_git.go.POST /api/v1beta/skills/sync, wired through a narrowskillSyncerinterface inpkg/api/v1so this PR doesn't need to ship anUpgradestub (widens toskills.SkillLockServicein PR5).thv skill syncCLI:--check,--adopt,--prune,--clients,--project-root(auto-detected by walking up for.gitwhen omitted).Part of the production stack for #5715 (RFC THV-0080). Stack: 4/6 — lockfile → lock-service → install-hooks → sync → upgrade → cli-exitcodes. Based on #5894 (PR3).
Type of change
Test plan
task test)task test-e2e, scoped:ginkgo --label-filter=skills-lock)task lint-fix)Table-driven drift-matrix tests cover up-to-date / drifted-and-reinstalled / missing-and-restored / check-mode-no-write / adopt / prune / feature-disabled-403; golden tests for
buildPinnedReference(OCI digest-pin, git commit-pin with and without a subdir path) andisImmutableSource; API handler tests including the 501 "not supported" path when the underlying service lacksSync. New E2E spec: install → delete files on disk →sync --checkreports drift without touching anything →syncrestores the files.Does this introduce a user-facing change?
Not yet — same
TOOLHIVE_SKILLS_LOCK_ENABLEDgate as the rest of the stack (see PR3). Once the full stack lands:thv skill syncrestores a project's skills to match its committed lock file.Special notes for reviewers
SyncRestorefix (install_extraction.go,install_git.go) is the part I'd like the most scrutiny on — it's a small diff but changes behavior on the existing install fast paths, gated entirely behind an internal-only option onlySyncsets.pkg/skills/client.ClientgainsSyncbut does not yet assertskills.SkillLockServiceconformance — that lands in PR5 onceUpgradeexists too.🤖 Generated with Claude Code