Skip to content

fix(#713): make pre-flight skill check content-aware, not version-only - #717

Merged
admarble merged 3 commits into
mainfrom
feature/713-fix-sync-areskillsoutdated-checkandwarnskillsoutda
Jun 4, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/713-fix-sync-areskillsoutdated-checkandwarnskillsoutda

Conversation

@admarble

@admarble admarble commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up from #708 (PR #710). The content-truth fix corrected sync's own up-to-date decision, but the sibling pre-flight path other commands rely on (areSkillsOutdated / checkAndWarnSkillsOutdated, invoked from the preAction hook in bin/cli.ts) was still version-only and under-reported real content drift. A tree at the matching version but with drifted bundled content (the #708 scenario) reported outdated: false, so no warning surfaced and the drift sequant sync now flags stayed invisible to every other command.

Changes

Acceptance Criteria

AC Description Status
AC-1 areSkillsOutdated content-aware (reflects content drift, not just version) ✅ contentDrift from computeTemplateChanges, excludes local-override/unchanged
AC-2 preAction warns on content drift at matching version ✅ Warn-only, no exitCode change, command exits normally
AC-3 Decide + document auto-sync behavior on content-only drift ✅ Auto-sync gated on version bumps only; content drift → warn. Documented in plugin-updates.md + hook comment
AC-4 Reuse computeTemplateChanges (no parallel comparison) ✅ No re-implemented diff loop
AC-5 Performance: content comparison cheap enough for every invocation ✅ Diff gated behind version match; status reused in hook (single scan)

Test plan

  • npm run build — passes
  • npm run lint — passes (0 warnings)
  • npm test (sync, doctor, cli.integration) — 65 tests pass
  • New unit tests: contentDrift on new/modified, exclusion of local-override/unchanged, version-mismatch fast-path skip, diff-failure tolerance, and checkAndWarnSkillsOutdated warn-only/exit-0 behavior.

Coordination

Closes #713

areSkillsOutdated/checkAndWarnSkillsOutdated (used by the preAction hook in
bin/cli.ts before most commands) compared only the .sequant-version marker, so a
tree at the matching version with drifted bundled content (the #708 scenario)
reported outdated:false — no warning, drift invisible to every other command.

- areSkillsOutdated now returns a contentDrift count: on a version match it runs
  the same computeTemplateChanges diff sync uses (#708/#710 source of truth),
  counting new+modified and excluding local-override/unchanged so customized
  files (#711) don't warn on every command. Version mismatch skips the diff
  (already stale → copy path) to keep the per-command pre-flight cheap (AC-5).
- checkAndWarnSkillsOutdated warns on content drift; warn-only — never copies,
  never sets process.exitCode. Accepts a pre-computed status to avoid a double
  scan on the hook hot path.
- preAction hook: version mismatch → auto-sync (copy) as before; version match +
  drift → warn only. Auto-sync stays gated on version bumps so in-place
  customizations aren't clobbered (AC-3).
- Docs (plugin-updates.md) + CHANGELOG document the decision; unit tests cover
  contentDrift detection, exclusions, fast-path skip, and warn-only/exit-0.

Closes #713

Entire-Checkpoint: d954cbdb7aec
admarble added 2 commits June 3, 2026 23:11
…t fix it

The pre-flight content-drift warning recommended bare 'sequant sync', but at a
matching version sync is report-only (reports drift and exits non-zero, does not
copy). Point users at the commands that actually resolve in-place drift —
'sync --force' or 'update' — mirroring syncCommand's own drift message and
satisfying AC-2's 'consistent with sync's own drift message'. Drop the 'skill'
qualifier since computeTemplateChanges covers all bundled templates, not just
skills.

Entire-Checkpoint: 38bd202180af
Address the two QA gaps on the content-drift pre-flight:

1. Performance (AC-5): the full read+render+diff template scan (~15ms) ran on
   every command for up-to-date installs, since the existing gate only skipped
   on a version *mismatch* (the common case is a match). Add an opt-in stat-only
   fingerprint cache: a SHA-1 over the package version plus the mtime/absence of
   each bundled template, its installed counterpart, any `.claude/.local/`
   override, and the config/manifest. On a fingerprint match the cached drift
   count is returned without scanning (~4ms vs ~15ms, measured ~5x faster). A
   per-file hash (not max-mtime) ensures editing an older file still invalidates,
   so a real drift is never missed; `sync`/`update` rewrites bump mtimes so the
   cache self-invalidates. Opt-in via `areSkillsOutdated({ cache: true })` from
   the hot preAction path only — `doctor`/`sync` stay uncached for fresh truth.
   Degrades gracefully: any fingerprint/cache error falls back to a fresh scan.

2. UX: exclude `update` from the preAction pre-flight (alongside `init`/`sync`).
   `update` is itself the command that resolves drift, so the warn-only
   "run sync/update" message was a circular nag right before it ran.

Adds 4 cache tests (hit/miss/default-uncached/graceful-fallback) and updates the
plugin-updates doc + CHANGELOG. Build + lint + 57 sync/doctor tests green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sync): areSkillsOutdated/checkAndWarnSkillsOutdated pre-flight is version-only — misses content drift (sibling of #708)

1 participant