Skip to content

fix(sync): a --only skills install warns 'N file(s) differ' forever, and the suggested sync --force overwrites the repo's constitution #1409

Closed

Description

@admarble

Epic: graph-2026-10-freeze-b Tier: judgment Execution: sequant_run (after the owner rules on OQ-1)

Problem

A repo adopted with sequant init --manifest-only + sequant sync --only skills (the existing-repo path from #1209) gets a content-drift warning that never clears. Both commands the warning suggests install files the adopter deliberately left out, and the first one also overwrites the repo's own constitution.

Field case (2026-10-12): a Python repo with a repo-owned .claude/memory/constitution.md, adopted this way, runs through MCP sequant_run on npm 2.19.0. The behaviour below is the same on main.

  1. sync --only skills --dry-run reports "Skills are already up to date", exit 0.
  2. Every status / serve / run start still warns Version current, but 12 file(s) differ from bundled content.
  3. sync --force --dry-run lists those 12 as new files the skills-only install never wrote: .claude/agents/sequant-{implementer,qa-checker,testgen}.md, .claude/hooks/{capture-tokens,parallel-marker,post-tool,pre-tool,relay-check}.sh, scripts/dev/{cleanup-worktree,list-worktrees,new-feature}.sh and .claude/settings.json. It also lists Local overrides (will be overwritten): .claude/memory/constitution.md.

Where it comes from (main)

  • computeContentDrift (src/commands/sync.ts:228) counts template changes with status new or modified, over the whole template set. A file that was never installed counts as drift, so a partial install drifts permanently.
  • The remedy lines (sync.ts:883-887 and formatSkillsInstallWarning in src/commands/version-preflight.ts:160) say Run: sequant sync --force (or sequant update):
  • .sequant-manifest.json keeps "files": {} after sync --only skills; only updatedAt changes. The manifest never records which groups were installed, so the drift check has nothing to scope against.

Why it matters

--only skills is the documented way to adopt sequant in an existing repo. Every such adopter gets a permanent warning, and the first fix it suggests deletes a repo-owned file. A user or agent that follows it either loses the constitution or ends up with hooks and settings they chose not to install. Here, the agent running the repo stopped only because its own rules ban overwriting the constitution.

Owner decision (graph doc OQ-1, before exec)

Does the install record its scope in .sequant-manifest.json, or is scope worked out from what exists on disk? Recommended: record it (for example, a groups field that init and sync --only write). Inference from disk can't tell "deliberately skipped" from "deleted by accident". The owner's ruling is written into AC-4's text before exec (an AC prescription is changed by editing the AC, not by a comment).

Acceptance Criteria

  • AC-1: After init --manifest-only + sync --only skills in a fixture repo, the drift count printed by status is 0. Evidence: a test that sets up a skills-only fixture and asserts the count, mutation-verified by restoring the whole-template-set count in computeContentDrift.
  • AC-2: A skills-only fixture with one modified SKILL.md reports drift of 1, and the remedy line names a command that, when run, rewrites only .claude/skills/**: no constitution, hooks, agents or settings.json. Evidence: a test that runs the printed remedy on the fixture and diffs the tree, mutation-verified by restoring the sync --force remedy text.
  • AC-3: A full install (init without --manifest-only) still reports new and modified files as drift, as today. Evidence: the existing drift tests pass unchanged.
  • AC-4: The install's scope is recorded in .sequant-manifest.json by init and sync --only, and computeContentDrift reads it through src/lib/manifest.ts; a manifest without the field reads as a full install. Evidence: a test that writes a skills-only manifest and asserts the recorded scope, plus a test that a pre-existing manifest with no scope field still reports full-install drift.

Prior fixes / producers

May touch

src/commands/sync.ts, src/commands/version-preflight.ts, src/commands/init.ts, src/lib/manifest.ts, their tests, CHANGELOG.md.

Non-Goals

Activity

  1. added
    graph-2026-10-freeze-b
    on Oct 16, 2026
  2. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Runner context (graph-2026-10-freeze-b, tracker #1452), for the exec and qa phases:

    • exec and qa: do not run the full suite (npm test / npx vitest run with no file filter). Six phase agents run at once and the MCP phase wall is 30 minutes (graph doc I-5). Full-suite evidence comes from CI. Run only the targeted test files, in the foreground, under timeout 600, after a WIP commit. Do not use run_in_background or Monitor.
    • No edit under plugin/, .claude/skills/ or templates/skills/ (plugin freeze, I-1).
    • Gate-test ACs need the mutation record in the PR body (CLAUDE.md, Testing).
    • OQ-1 is ruled (owner, 2026-10-16): record the install scope in .sequant-manifest.json (AC-4 as filed). src/lib/manifest.ts owns the format, and other modules read it through getManifest (graph doc §9).
  3. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (4 ACs, 2 directories: src/commands/, src/lib/)

    AC Quality Check

    • AC-1, AC-2, AC-4: concrete, one line each, Evidence: names a test and a mutation. All three fail on main today: the skills-only drift is 12, the remedy is sync --force, and there is no scope field.
    • ⚠️ AC-3 is vacuous as a gate. "Existing drift tests pass unchanged" already passes on main. That is fine for a regression guard, but it gates nothing on its own. AC-4's second test (a manifest with no scope field reports full-install drift) is the real gate for the full-install path.
    • AC-2: "a command that, when run, rewrites only .claude/skills/**". At a matching version, plain sync --only skills only reports and writes nothing (fast path, sync.ts:478). The remedy that does the rewrite has to be sync --only skills --force. Skills paths are sequant-owned (ownershipPolicy, templates.ts:367), so --force widens nothing inside that tree.

    Scope Assessment

    Non-Goals: present (no update --only, no change to full-install --force (#814), no edits under plugin/ or the skill dirs).

    Metric Value Status
    Feature count 1 ✅
    AC items 4 ✅
    Directory spread 2 (+ CHANGELOG) ✅

    Verdict: ✅ SCOPE_OK

    Acceptance Criteria

    AC-1: skills-only install → status drift 0

    Verification: Integration Test (real temp-dir fixture)
    Scenario: Given init --manifest-only + sync --only skills in a temp repo → When the status pre-flight runs (areSkillsOutdated, via runVersionPreflight) → Then contentDrift === 0 and no "differ" warning is printed.
    Assumptions: The fixture runs the real templates/ tree. Hooks, agents, scripts/dev and settings.json are absent on disk. Mutation: make computeContentDrift count the whole template set again.

    AC-2: one modified SKILL.md → drift 1, and the remedy touches only skills

    Verification: Integration Test
    Scenario: Given the AC-1 fixture plus a repo-owned .claude/memory/constitution.md, and one edited .claude/skills/*/SKILL.md → When the pre-flight warns → Then the count is 1 and the remedy line is <cli> sync --only skills --force. When the test runs that remedy, a before/after tree diff shows changes only under .claude/skills/** (plus .sequant-manifest.json and .claude/.sequant/ cache files). No constitution, hooks, agents or settings.json appear.
    Assumptions: The test parses the printed remedy and maps it to syncCommand({ only: "skills", force: true }), or spawns the CLI as sync-source-invocation.integration.test.ts does. The allowed-diff list must be explicit. Mutation: restore the sync --force (or update) remedy text.

    AC-3: a full install still reports new and modified files as drift

    Verification: Unit Test (existing sync.test.ts "areSkillsOutdated content-drift" block and version-preflight.test.ts, unchanged)
    Scenario: Given a manifest with no scope field → When the drift is computed → Then the result matches today's new + modified count over the whole set.

    AC-4: the scope is recorded in the manifest and read through manifest.ts

    Verification: Unit Test
    Scenario: (a) After init --manifest-only + sync --only skills, the manifest on disk records the skills scope. (b) A pre-existing manifest with no field → getInstallScope returns full → the drift count includes new files outside .claude/skills/.
    Assumptions: No consumer parses the field itself. Every read goes through getManifest and a helper in manifest.ts.

    Implementation Plan

    Phase 1: Manifest format (src/lib/manifest.ts)

    1. Add groups?: InstallGroup[] to Manifest, with type InstallGroup = "skills" (the SYNC_ONLY_GROUPS vocabulary). Absent means a full install. Add getInstallScope(manifest): { kind: "full" } | { kind: "partial"; groups: InstallGroup[] }.
    2. createManifest(stack, pm, { groups? }): init --manifest-only passes groups: [], and full init passes nothing.
    3. updateManifest({ addGroup? }): sync --only skills unions "skills" into an existing groups array. It never adds a field to a manifest that has none, so a later --only cannot narrow a full install. All of this stays in manifest.ts.

    Phase 2: Scoped drift (src/commands/sync.ts)

    1. computeContentDrift: filter changes through a single filterToInstallScope(changes, scope) (full means no filter; skills reuses filterToSkillsOnly). The drift fingerprint already stats the manifest, so a scope change invalidates the cache with no further work.
    2. In syncCommand, the apply path calls updateManifest({ addGroup: "skills" }) when skillsOnly. The fast-path report (line ~523) names the scoped remedy when skillsOnly.

    Phase 3: One remedy producer (sync.ts + version-preflight.ts)

    1. Add driftRemedy(scope, cli): a partial scope returns ${cli} sync --only skills --force, and a full scope returns today's string. checkAndWarnSkillsOutdated (sync.ts:883-887) and getSkillsInstallStatus's remediation (version-preflight.ts:136, which feeds formatSkillsInstallWarning and sequant://install) both read it. That gives one producer instead of two diverging strings.
    2. Tests: a new src/commands/sync.install-scope.integration.test.ts (temp dir, real templates; AC-1/AC-2/AC-4a), unit cases in src/lib/manifest tests (AC-4 a/b), and a version-preflight.test.ts case for the scoped remediation. Add a CHANGELOG entry under Unreleased.

    Design Review

    1. Where does this logic belong? The format and its default belong in src/lib/manifest.ts (owner of the format, per the graph doc §9). Filtering by scope and the remedy belong in sync.ts next to filterToSkillsOnly, which is the only place that knows the groups' write-sets.
    2. Simplest correct approach? An optional groups field, absent meaning full. Rejected: inferring the scope from disk (owner ruling OQ-1: it can't tell "skipped" from "deleted"). Also rejected: a required field with a migration (it breaks pre-existing manifests and run's documented minimal manifest shape from feat(adopt): init --manifest-only and sync --only skills — cheap, documented adoption; the manifest stays the single installed marker #1209).
    3. Pattern / re-patch count. It reuses the feat(adopt): init --manifest-only and sync --only skills — cheap, documented adoption; the manifest stays the single installed marker #1209 --only skills filter (filterToSkillsOnly). git log -S computeContentDrift: fix(sync): areSkillsOutdated/checkAndWarnSkillsOutdated pre-flight is version-only — misses content drift (sibling of #708) #713 (PR fix(#713): make pre-flight skill check content-aware, not version-only #717) only. Related, but a different class: fix(update/sync): sync reports 'up to date' on content drift; update overwrites in-place customizations (constitution) #708/fix(#708): content-truth for update/sync; protect in-place customizations #710 (one content diff) and fix(sync): plain sync overwrites CUSTOMIZABLE_FILES (constitution) — copyDir ignores force and never consults isCustomizableFile #814 (--force by design). This is the first fix to the drift scope, so it is not a recurring class.
    4. What would a reviewer challenge? (a) "Why not make bare update the remedy?" Because it installs all newFiles (update.ts:213,252), including hooks and settings.json. (b) "Why can't sync --only narrow a full install?" A narrowing would hide real drift on files the user has. (c) "The version-mismatch remedies still say bare sync/update." See OQ-1.
    5. Producers and consumers of the manifest (whole-repo grep, excluding tests): writers: createManifest (init.ts:650 manifest-only, init.ts:1172 full) and updateManifest (sync.ts:766, update.ts:373). Readers: sync.ts (227, 419), version-preflight.ts (77, 128), status.ts:370, doctor.ts:595, run.ts:57, update.ts:80, init.ts:639, the run-manifest shape and the src/index.ts export. The two writers go through manifest.ts, so no parity test is needed. Remedy string producers: 3 (sync.ts:523, sync.ts:887, version-preflight.ts:136), collapsed into driftRemedy by step 6.

    ADR required: the plan picks a recorded scope over disk inference, and an optional field over a required one. The exec PR adds docs/adr/0014-install-scope-recorded-in-manifest.md (shape per docs/adr/README.md). That is a docs path outside the plugin freeze.

    Feature Quality Planning

    • Backward compatibility: old manifests have no field and read as full (AC-4b). Old CLIs reading a new manifest ignore the extra key, since it is plain JSON.
    • Cache: the manifest mtime is already in computeDriftFingerprint, so a scope change invalidates the cache. A test should still show that the cached pre-flight (cache: true) returns 0 after sync --only skills. This guards against a stale cached 12.
    • Fixture hygiene: use a temp dir and avoid process.cwd spies (they leak across forks). Use chdir in a dedicated integration file or spawn the CLI. A name without .integration. gets the 5 s timeout.

    Open Questions

    1. Version-mismatch remedies on a skills-only install (sibling sites, same file). checkAndWarnSkillsOutdated says Run: sync (sync.ts:875), doctor.ts:649 says sync, and getSkillsInstallStatus says update. After an npm upgrade, all three steer a skills-only adopter into a full install. Recommendation: route them through the same driftRemedy/scope helper (a skills scope gives sync --only skills). This is trivially co-located and the same root cause. Impact if skipped: the same defect reappears on every version bump. doctor.ts is outside "May touch"; the owner decides.
    2. Plain sync (no --only) on a skills-scoped install. Today it diffs the whole set and exits 1 forever at a matching version. Recommendation: the effective only = options.only ?? manifest scope, and widening happens only through a full init. Impact if not: the report-only fast path still shows the 12-file drift with exit 1.
    3. update on a scoped install installs every newFiles entry but would leave groups: ["skills"]. The drift stays correctly scoped, but the manifest understates what is on disk. Recommendation: leave it, because update --only is a Non-Goal. Record it as a follow-up issue rather than widen this one.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: A bounded fix in two modules with declared test evidence. The ACs name their own tests and mutations, so testgen stubs add little. The graph run rules apply: targeted test files only, no full suite, and the mutation records go in the PR body.

    Label Review

    Current: graph-2026-10-freeze-b
    Recommended: + bug, + planned
    Reason: A user-facing defect (a permanent warning, and a remedy that deletes a repo-owned file).

  4. added
    planned
    bug
    on Oct 16, 2026
  5. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 4/4 met

    Gaps:

    • Gate-test ACs AC-2 and AC-4 lack parseable SEQUANT_MUTATION markers; add them to exec's final ## Summary
    • Repos adopted before fix(sync): a --only skills install warns 'N file(s) differ' forever, and the suggested sync --force overwrites the repo's constitution #1409, including the issue's field case, keep the permanent warning and the constitution-overwriting remedy, with no in-product recovery path
    • Spec OQ-1: doctor's version-mismatch remedy still steers a skills-only install to a full sync — unresolved
    • Spec OQ-2: plain sync on a skills-scoped install reports whole-set drift and exits 1 — unresolved
    • Spec OQ-3: update installs every group but leaves groups as it was; exec PR body says it needs a follow-up issue, none filed — unresolved
    • Upgrade gap, reproduced: the motivating repo (adopted on npm 2.19.0) is not fixed by this change.
    • Its manifest has no groups field, so it reads as a full install.
    • init --manifest-only refuses to touch an existing manifest (init.ts:640).
    • sync --only skills never adds the field.
    • Reproduction: I ran the built CLI in a temp repo with a legacy manifest, then ran sync --only skills and init --manifest-only. status still prints 13 file(s) differ … Run: sequant sync --force (or sequant update), which is the constitution-overwriting remedy.
    • AC-4 explicitly requires "absent reads as full", so the ACs are met. But the CHANGELOG says "existing installs are unchanged" and gives no recovery step, and the issue's field case keeps the behaviour it reported.
    • This needs an owner decision: a documented manual step, or a migration such as sync --only skills claiming the scope when files is {}.
    • PR body mutation markers are truncated: only the AC-1 SEQUANT_MUTATION marker parses. The AC-2 marker is cut off at {"ac":"AC-2","mutat, and the two AC-4 markers are missing. The prose records exist, but the machine-readable record is incomplete.

    Suggestions:

    • Spec OQ-2 is not done. A plain sync with no --only on a skills-scoped install, at a matching version, still reports drift over the whole template set and exits 1, with the update / sync --force remedy.
  6. added a commit that references this issue on Oct 16, 2026
  7. added 2 commits that reference this issue on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggraph-2026-10-freeze-bplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions