Repository navigation
Description
Incident (2026-09-06)
A downstream project reported that a long-running npm exec sequant@latest serve process "silently re-synced the repo from 2.10.0 → 2.13.0 at 12:14, mid-test-run, and overwrote pre-tool.sh" — erasing a locally tested hook guard. Same-day inspection found the identical churn sitting uncommitted in two more local projects (pre-tool.sh +108/−17 and +228/−15, .sequant-version bumped, skills rewritten), each with a sequant@latest serve process whose cwd is that project.
Root cause — a four-link chain, every link verified in source or on disk
- The plugin ships
sequant@latest, not the Reconsider sequant@latest pinning in generated MCP config (forces npx reinstall every release; surfaces as -32000) #793 pin..claude-plugin/marketplace.jsondeclaressource: "./", so the plugin root is the repo root and the shipped MCP config is the repo-root.mcp.json—["-y","sequant@latest","serve"].scripts/prepare-marketplace.ts:153-170stamps a pinned copy intodist/marketplace/external_plugins/sequant/.mcp.json, and its validator (:234-237) rejects@latest— but that dist copy is not what the GitHub marketplace installs. Proof:~/.claude/plugins/cache/sequant/sequant/2.13.0/.mcp.jsonand2.12.0/.mcp.jsonboth carrysequant@latest. Reconsider sequant@latest pinning in generated MCP config (forces npx reinstall every release; surfaces as -32000) #793's fix is dead code on the primary distribution channel. - Claude Code starts the plugin's MCP server with cwd = the open project, in every project.
lsof -d cwdon the three runningsequant@latest serveprocesses: three different project directories. - The
preActionhook fires onserve.bin/cli.ts:882-908excludes onlyinit/sync/update. When.claude/skills/.sequant-version< package version it callssyncCommand({ quiet: true })→copyTemplates({ force: true, overwriteCustomizable: false })(sync.ts:448-450) → rewrites.claude/skills/**,.claude/agents/**,.claude/hooks/**,AGENTS.md,scripts/dev/*.sh,.sequant-manifest.json, the.mcp.jsonpin (sync.ts:310), and the version marker — with zero output (quiet). An MCP server start, which every user reasonably assumes is side-effect-free, mutates tracked files in the working tree. - The write path protects exactly one file.
CUSTOMIZABLE_FILES = [".claude/memory/constitution.md"](templates.ts:238).copyTemplates(templates.ts:618-628) checks onlyisCustomizableFile; the.claude/.local/twin that the classifier treats aslocal-override(templates.ts:333-405) is not consulted on write, andsync.ts:374-375explicitly overwrites non-customizable local-overrides even under a plain sync. A hook edited in place has no supported protection.
Repeat trigger: the condition is committed marker < package version. Until the marker bump is committed, every new Claude Code session in that project re-runs the silent sync. The downstream project's marker is still 2.10.0 at HEAD — the next session start will clobber the guard again.
Related history: docs/internal/plugin-updates.md:88-101 documents the auto-sync as intended behavior; #713 AC-3 decided content-only drift is warn-only because copying would clobber in-place customizations (#711) — the same reasoning applies with more force to a version bump arriving via a background server. #784 warned about stale plugin caches; this is the inverse failure — an eager plugin channel.
Design
D1 — auto-sync becomes warn-only; serve becomes side-effect-free.
The version-mismatch branch of the preAction hook stops calling syncCommand and instead surfaces the same warning path the content-drift branch already uses (checkAndWarnSkillsOutdated), naming the fix (sequant update). Mutation of the working tree happens only on explicit init / sync / update. serve additionally exposes the drift in the sequant://config resource and logs one stderr line at startup, so MCP users still learn about it. Rationale: #713 already established that the pre-flight must never clobber in-place customizations; a background process is the strongest case of that. The npm upgrade → skills auto-update convenience the hook was built for is preserved by the warning plus doctor.
D2 — fix the #793 regression at its actual source. Either (a) /release stamps the repo-root .mcp.json pin to the release version via the existing syncSequantMcpPin (the "tracks HEAD for contributors" comment is mistaken — @latest tracks npm, not HEAD, so contributors lose nothing), and prepare-marketplace's validator checks the root file; or (b) marketplace.json source points at the prepared dist directory. (a) is smaller and keeps source: "./".
D3 (decide, not prescribed) — align the write path with the classifier. copyTemplates skips any file with a .claude/.local/ twin unless --force, so the documented update-safe customization path (docs/guides/customization.md:165-210) is honored by the tree copy and not only by the preview. Independent of D1; D1 alone closes the incident.
Non-Goals
- No change to explicit
sequant sync/updateoverwrite semantics for managed trees (that is what those commands are for). - No per-project opt-out flag for auto-sync — with D1 there is nothing to opt out of.
- Not re-litigating Reconsider sequant@latest pinning in generated MCP config (forces npx reinstall every release; surfaces as -32000) #793's pin-vs-track trade-off; the decision stands, it just never shipped.
Acceptance Criteria
- AC-1:
bin/cli.tspreActionnever callssyncCommand; on a version-marker mismatch it warns via the existing drift-warning helper and namessequant update; a unit test drives the hook with a stale marker and asserts no template write occurred — mutation-verified (restore thesyncCommandcall → exactly that test fails). - AC-2:
sequant servewith a stale marker starts without modifying any file under.claude/,AGENTS.md,scripts/dev/,.sequant-manifest.json, or.mcp.json— integration test snapshots the tree before/after startup. - AC-3:
servesurfaces the stale-install condition on one stderr line at startup and in a dedicatedsequant://installresource that is always an object ({ installed: false }with no manifest) and carriesfilesModified: false;sequant://configstays the settings file verbatim (JSON or JSONC) with no server-computed fields; tests assert all three. - AC-4: the shipped plugin MCP config is pinned — the repo-root
.mcp.json(or whichever filemarketplace.jsonsourceresolves to) carriessequant@<package.json version>at release, andprepare-marketplace's validator checks that file; a test readsmarketplace.jsonsource, resolves.mcp.jsonfrom it, and asserts the pin — mutation-verified (set@latest→ fails). - AC-5:
docs/internal/plugin-updates.mdand thepreActionheader comment describe the warn-only behavior; content-coverage gate scoped to that section. - AC-6: CHANGELOG entry states the behavior change plainly: "sequant no longer rewrites project files on startup; run
sequant updateto apply a new version."
Human decisions required
- D2 (a) vs (b).
- Whether to take D3 in this issue or file it separately.
- Whether
sequant run(also spawned by the MCPsequant_runtool,src/mcp/tools/run.ts) should keep any auto-behavior; recommendation: no — same rule, explicit commands only.
Context
#793 (pin decision — regressed via source: "./"), #713 / #711 / #708 (drift pre-flight and the in-place-customization rule), #784 (stale plugin cache — the mirror-image failure), #814 (constitution clobber — the overwriteCustomizable split), docs/guides/customization.md (the .claude/.local/hooks/ path the incident's guard should have used).
Activity
refactor(mcp): keep sequant://config verbatim; sequant://install is t…
admarble commentedon Sep 7, 2026
AC-3 reworded (2026-09-06, during PR #989): the original text asked for install status in
sequant://config. Implementing it showed that's the wrong shape — the field only appeared when the settings file parsed as plain JSON, the file got re-serialized (formatting/key order), and a server-computed value shared a namespace with real settings.sequant://configstays the settings file verbatim; status lives in a dedicatedsequant://installresource that is always an object withfilesModified: falseas the report-only contract. Tests cover the resource shape and config-verbatim for both JSON and JSONC.fix(cli): skills pre-flight is warn-only; serve is side-effect-free; …
admarble commentedon Sep 7, 2026
Recurrence, post-merge / pre-release (2026-09-06 ~12:14 local): the plugin's
npm exec sequant@latest serve(running since 11:11 in a downstream project) re-synced 2.10.0 → 2.13.0 mid-test-run and overwrote.claude/hooks/pre-tool.sh, erasing a guard the user had just written and tested there. npmlatestis still 2.13.0, so every plugin session keeps the old preAction until 2.13.1 is published. This is the release-blocking reason to cut 2.13.1.Two file classes from the same sync that the fix here does not cover on an explicit
sequant sync, filed separately: #990 (AGENTS.mdregenerated unconditionally: 73-line pointer → 1,079-line CLAUDE.md copy) and #991 (scripts/dev/*.shsymlinks re-pointed into~/.npm/_npx/<hash>/…, which gets evicted).Downstream note for the record: a customization placed in the managed
pre-tool.shwill be clobbered again by the nextsequant updateeven after 2.13.1; the update-safe home is.claude/.local/hooks/registered viasettings.local.json(docs/guides/customization.md).admarble commentedon Sep 7, 2026
Shipped: v2.13.1 (20e2a86), npm
latest= 2.13.1, tag's root.mcp.jsonpinned to[email protected]. Downstream.mcp.jsonfiles that still say@latestnow resolve to a build with the warn-only preAction, so the silent rewrite stops without any plugin-cache refresh. Remaining explicit-syncgaps tracked in #990 / #991.fix(#1265): ship a slim plugin/ folder instead of the whole dev repo (#…