Repository navigation
Conversation
…ions sync reported "up to date" purely from the version marker, hiding real content drift on the automation-recommended path. update compared installed files against the raw (unrendered) template, so an unmodified constitution always read as "modified" and an in-place-customized constitution was overwritten on the default Y prompt — silent data loss. Extract a single source of truth in src/lib/templates.ts (buildTemplateVariables + computeTemplateChanges, shared with copyTemplates): - render template tokens before diffing (AC-3) - classify in-place-diverged customizable files (constitution) as local-override: skip-by-default, --force overwrites (AC-4, AC-5) - sync verifies actual content on version match and reports drift instead of a false no-op (AC-1, AC-2) Add SEQUANT_TEMPLATES_DIR override to getTemplatesDir for hermetic tests. Entire-Checkpoint: 95e7fd3f430e
5 tasks
…ble-file match QA second-look gaps: - sync's drift path returned exit 0 (and was silent under --quiet), so the CI/automation path #708 is about could still treat a drifted tree as success. Set process.exitCode=1 on drift — fires even under --quiet, since the exit code is the machine signal the suppressible message is not. The preAction auto-sync hook only runs on version mismatch (copy path), so it never hits this branch. - isCustomizableFile/computeTemplateChanges matched forward-slash paths only; on Windows listTemplateFiles yields backslashes, so the constitution protection would silently fail and revert to overwrite-on-default. Normalize separators before the allow-list and .local/ checks. - Tests: assert exit code on drift (incl. --quiet), separator normalization, and reset process.exitCode in afterEach so it can't leak. Entire-Checkpoint: 73d0d8a9f37d
admarble
added a commit
that referenced
this pull request
Jun 4, 2026
#717) * fix(#713): make pre-flight skill check content-aware, not version-only 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 * fix(#713): point content-drift pre-flight warning at the commands that 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 * fix(#713): cache the pre-flight drift scan + skip it on `update` 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.
This was referenced Oct 16, 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
Fixes two correctness bugs in the
update/syncflow (#708), both stemming from incomplete/divergent template content-comparison:syncfalse "up to date": it decided status purely from the version marker, so real content drift on the automation-recommended path was reported as a success no-op. It now verifies actual content on a version match and reports drift instead.updateoverwrote in-place customizations: it compared installed files against the raw (unrendered) template, so an unmodifiedconstitution.mdalways read asmodified, and a user-edited constitution was silently overwritten on the defaultApply updates? (Y)prompt.Root cause fixed by extracting a single source of truth in
src/lib/templates.ts—buildTemplateVariables+computeTemplateChanges, now also used bycopyTemplatesso the write path and the diff path can't drift again.Key decisions (from /spec)
syncis report-only on the equal-version drift path (no auto-apply) so the fast path can't silently clobber an in-place-customized constitution.--forceincludeslocal-overridefiles in the apply set (matches AC-4 wording).constitution.mdonly for now (CUSTOMIZABLE_FILES).Pre-PR AC Verification
syncreports drift (not "up to date") when content differs at equal versionsync.tsversion-equal branch;sync.test.ts"reports drift…"sync.ts;sync.test.ts"skips sync when versions match and content is identical"unchangedcomputeTemplateChangesrenders viabuildTemplateVariables;templates.test.tsAC-3local-override(skip default,--forceoverwrites)isCustomizableFile+ classification;templates.test.tsAC-4,update.integration.test.ts--forceYpath never overwrites a customized constitutionupdate.integration.test.ts"does not overwrite … on the default (Y) path"Test plan
npm run build— passesnpm run lint— passes (0 warnings)npx vitest runonsync.test.ts,templates.test.ts,update.integration.test.ts— 32 passedinit.test.ts,stacks.test.ts,project-name.test.ts,agents-md.test.ts— 192 passed (verifiescopyTemplatesrefactor)Follow-up (out of scope, per /spec)
checkAndWarnSkillsOutdated/areSkillsOutdated(sync.ts) are also version-only and will under-report content drift to other commands' pre-flight warnings — same root cause. Recommend a separate issue rather than expanding this PR (changing pre-flight warning behavior is outside these ACs).Closes #708
🤖 Generated with Claude Code