Repository navigation
Description
Summary
sequant sync overwrites .claude/memory/constitution.md with the rendered template, destroying in-place customizations. No --force is required — plain sequant sync does it.
This is not a #708 regression. #708 fixed update and left sync destructive, with the divergence recorded in a code comment (src/commands/sync.ts:328-330). This issue is about closing that gap, because the reasoning that justified leaving it open no longer holds.
Root cause
isCustomizableFile has exactly one consumer, and it is on the diff path:
$ grep -rn "isCustomizableFile\|CUSTOMIZABLE_FILES" src bin | grep -v "\.test\."
src/lib/templates.ts:104:export const CUSTOMIZABLE_FILES = [".claude/memory/constitution.md"];
src/lib/templates.ts:109:export function isCustomizableFile(localPath: string): boolean {
src/lib/templates.ts:112: return CUSTOMIZABLE_FILES.includes(localPath.replace(/\\/g, "/"));
src/lib/templates.ts:234: if (hasLocalOverride || isCustomizableFile(localPath)) {templates.ts:234 is inside computeTemplateChanges. The write path never consults it. copyTemplates calls an inner copyDir that unconditionally writes every template file:
// src/lib/templates.ts:412-428
async function copyDir(srcDir: string, destDir: string): Promise<void> {
// ...
let content = await readFile(srcPath);
content = processTemplate(content, variables);
await writeFile(destPath, content);Note what is absent: copyDir never reads options.force. It is not "force overwrites customizations" — the copy overwrites unconditionally, and CopyTemplatesOptions.force only reaches the scripts symlink path (templates.ts:474-477). .claude/memory is copied at templates.ts:453 with no options argument at all.
Meanwhile sync sets force: true unconditionally on every apply, independent of the user's --force flag:
// src/commands/sync.ts:386-389
const copyOptions: CopyTemplatesOptions = {
force: true, // Always overwrite when syncing
};Why this matters more than it did at #708 time
sync is the recovery path for a missing skills install. A user whose .claude/skills/ has gone missing is told to run sequant sync — that is the correct and documented fix, and doctor points at it. So the remedy for one failure silently destroys the constitution as a side effect. Observed exactly this way in a downstream project on 2026-07-26.
sync is the automation-recommended path. #708's own text: "the path we point CI and scripts at is the one that declares success while leaving drift in place." The same path now also silently eats the one file sequant explicitly designates as user-owned.
The dry-run already knows. sync --dry-run reports Local overrides (will be overwritten by sync): N and lists them (sync.ts:344-368). The apply path prints nothing. A preview that warns and an apply that is silent is the divergence shape #722 was about.
The design question
Two distinct notions of "force" are conflated:
- "overwrite the skills tree" — what
syncalways wants, and what it setsforce: truefor - "overwrite files the user owns" — what the user asks for with an explicit
--force
They should not be one flag. The fix is to separate them, so sync's always-on tree overwrite stops implying consent to clobber CUSTOMIZABLE_FILES.
Acceptance criteria
- AC-1: Plain
sequant syncdoes not overwrite files inCUSTOMIZABLE_FILESthat exist and differ from the rendered template; the skills/agents/hooks trees are still fully refreshed. - AC-2:
copyTemplatesgains an explicit opt-in for overwriting customizable files, separate fromCopyTemplatesOptions.force, so sync's always-on tree overwrite no longer implies consent to clobber user-owned files. - AC-3: An explicit user
sequant sync --forcestill overwrites them, and says so on stdout before writing. - AC-4: When plain
syncpreserves a customizable file, it reports it (e.g.preserved: .claude/memory/constitution.md — run \sync --force` to replace), so the apply path's output matches what--dry-run` already promises. - AC-5: A missing customizable file is still created on a fresh install — preservation applies only to files that already exist.
- AC-6: A test pins the round trip: write a customized constitution, run plain
sync, assert the content survives; runsync --force, assert it is replaced. - AC-7:
docs/guides/customization.mdno longer implies in-place constitution edits are unsafe undersync, and states the actual--forcesemantics.
Note on scope
.claude/memory/constitution.md is the only current entry in CUSTOMIZABLE_FILES, but the fix should be written against the list, not the single path — the whole point of the constant is that the set can grow.
Activity
admarble commentedon Jul 26, 2026
Related: #813.
sequant syncis the documented remedy for the missing-skills failure in #813, so the two compound — recovering from #813 currently costs you your constitution. Landing #813's pre-flight will point more users atsync, which raises the priority of this one.admarble commentedon Jul 26, 2026
Plan (spec) — #814
Complexity: Standard (7 ACs, ~3 directories:
src/lib,src/commands,docs)AC Quality Check
All 7 ACs are concrete and measurable. AC-6 is itself a test requirement (good — it pins the round trip). No vague/unmeasurable/open-ended patterns. No title/body verb tension.
Scope Assessment
## Non-Goals, but a## Note on scopefixes the boundary well: write againstCUSTOMIZABLE_FILES(the list), not the single constitution path.Root cause (confirmed against source)
Two write paths implement the "protect in-place customizations" rule, and only one honors it:
update.tsis correct:computeTemplateChanges→ filtersstatus === "local-override"→ writes them only under--force(update.ts:189-206,233,279).sync.tsbypasses that: it callscopyTemplates({ force: true })unconditionally (sync.ts:388-391), andcopyTemplates' innercopyDirwrites every file with no existence/diff/customizable check (templates.ts:412-434).copyDirnever readsoptions.forceat all —forceonly reaches the scripts symlink path (templates.ts:465)..claude/memoryis copied with no options (templates.ts:453).So
isCustomizableFilehas one consumer, on the diff path (templates.ts:234); the write path never consults it. Issue's diagnosis is accurate.Acceptance Criteria + verification
syncpreserves differingCUSTOMIZABLE_FILES, trees still refresh. Integration Test. Given a customizedconstitution.md→ Whensequant sync→ Then constitution content survives and.claude/skillsis rewritten.copyTemplatesgains an opt-in separate fromCopyTemplatesOptions.force. Unit Test. GivenoverwriteCustomizableunset → When copyTemplates over a differing customizable file → Then file preserved.sync --forceoverwrites and says so on stdout before writing. Integration Test. Given customized constitution → Whensync --force→ Then stdout announces overwrite AND file replaced.syncreports each preserved file (preserved: … — run \sync --force` to replace). **Integration Test.** Assert stdout matches the--dry-run` promise.sync→ Then rendered constitution written.syncsurvives →sync --forcereplaces. Integration Test (this AC is the test).docs/guides/customization.mdstates real--forcesemantics; no longer implies in-place edits are unsafe undersync. Manual/Docs verification.Implementation Plan
Phase 1 — Write-path opt-in (
src/lib/templates.ts)overwriteCustomizable?: booleantoCopyTemplatesOptions(distinct fromforce).copyDir, beforewriteFile: ifisCustomizableFile(destPath)(normalize separators) AND the dest exists AND rendered content differs AND!overwriteCustomizable→ skip the write and record the path as preserved. Otherwise write as today (this keeps AC-5: missing file → written; identical file → harmless rewrite).copyTemplates(extend the return object, e.g.preservedCustomizable: string[]) so the caller can report authoritatively without a second diff pass.Phase 2 — Sync wiring + reporting (
src/commands/sync.ts)4. Keep
force: truefor the tree refresh; setoverwriteCustomizableonly from the user's--forceflag (options.force).5. On
--force: announce which customizable files will be overwritten before callingcopyTemplates(AC-3) — compute via the existingcomputeTemplateChangeslocal-overrideset, matching the dry-run branch.6. On plain
sync: after copy, print each preserved file from the returned set (AC-4), formatpreserved: <path> — run \sync --force` to replace`.Phase 3 — Tests + docs
7. Round-trip integration test (AC-6) + unit test for
copyTemplatesopt-in (AC-2) + fresh-install create (AC-5). Add tosrc/commands/sync.test.ts/src/lib/templates.test.ts.8. Update
docs/guides/customization.md: state that in-placeconstitution.mdedits survive plainsync/updateand are only overwritten by--force.Design Review
copyDir(the write path) — the single place that actually mutates files — mirroring howupdatefilterslocal-overridebeforewriteFile. Reporting belongs insync.ts.copyDirreusing existingisCustomizableFile+processTemplate. Rejected: routingsyncthroughupdate'scomputeTemplateChanges+per-file-write path — larger blast radius, changes sync's whole-tree copy semantics.update.ts's--force-gates-local-overridepattern. Confirmed it fits.computeTemplateChangesfor the skip too?" — because the write path is a bulkcopyDir, not a change-list; a per-file check keeps it O(1) and local. Report AC-3/AC-4 from the authoritative preserved-set, not a re-diff, to avoid drift.Open Questions
.local-twin parity.update/computeTemplateChangesprotect a managed file when it has a.claude/.local/twin or is customizable (templates.ts:234). The ACs scope only toCUSTOMIZABLE_FILES. Recommendation: implementisCustomizableFileonly (matches the ACs); note that a managed file with a.localtwin but not in the list is out of scope here. Impact if this matters later: a follow-up to unify write-path protection with the diff path. (User decides — don't silently widen.)computeTemplateChanges(as the dry-run branch already does) to guarantee "before writing"; report AC-4 preservation fromcopyTemplates' return value. Impact if wrong: minor stdout ordering.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: disabled (focused bug, SCOPE_OK)
Reasoning: ACs carry Unit + Integration verification (AC-6 is an explicit test) → testgen stubs the round-trip before exec. No UI → no
testphase. Not security-sensitive.Label Review
Current:
bug,cliRecommended: add
planned. No complexity label needed (Standard tier).Quality Loop: won't auto-enable (SCOPE_OK).
admarble commentedon Jul 26, 2026
Progress Update — /exec (PR #815)
Implemented via PR #815. All 7 ACs addressed.
AC Coverage
copyDirper-file guard (src/lib/templates.ts)copyTemplatesopt-in separate fromforceoverwriteCustomizableoption, distinct fromforcesync --forceoverwrites and says so on stdout before writingsyncCommandbeforecopyTemplatespreserved: … — run \sync --force` to replace` from the returned setpins the round tripintemplates.test.ts--forcesemanticsdocs/guides/customization.md"Edit it in place (safe)" sectionDesign
Two conflated notions of "force" separated on the write path (mirroring how
updatealready gateslocal-overridebehind--force):force→ refresh the managed skills/agents/hooks trees (unchanged, always on for sync)overwriteCustomizable→ consent to clobber user-ownedCUSTOMIZABLE_FILES(set only from the user's--force)copyDirnow skips an existing, differing customizable file unless opted in, andcopyTemplatesreturnspreservedCustomizableso the caller reports authoritatively without a second diff pass.--dry-runwas updated to mirror the preserved/overwritten split so the preview can't diverge from the apply path (#722). Scoped to theCUSTOMIZABLE_FILESlist, not the single constitution path. The.local-twin-on-a-non-customizable-managed-file case (Open Question 1) is left out of scope as recommended.Checks
npm run build✅ ·npm run lint✅npx vitest run src/lib/templates.test.ts src/commands/sync.test.ts→ 57 passed (5 new write-path tests + 4 new/updated sync tests)src/lib src/commandssweep: green except a pre-existing, unrelatedprompt-wait.test.tstimer flake (relay/inbox subsystem — verified it fails on the base branch too, no path to this change).Files changed
src/lib/templates.ts—overwriteCustomizableoption, copyDir preservation,preservedCustomizablereturnsrc/commands/sync.ts— wireoverwriteCustomizablefrom--force, force-announce (AC-3), preserved report (AC-4), force-aware dry-runsrc/lib/templates.test.ts,src/commands/sync.test.ts— new/updated testsdocs/guides/customization.md(AC-7),CHANGELOG.mdadmarble commentedon Jul 26, 2026
QA Review for Issue #814 (PR #815)
AC Coverage
copyDirskips a customizable file that exists+differs when!overwriteCustomizable(templates.ts); non-customizable files bypass the guard so skills/agents/hooks trees are still written unconditionally. Test:preserves an in-place customized constitution.copyTemplatesopt-in separate fromforceoverwriteCustomizablefield is the only gate on the skip;forcestill drives the tree/symlink refresh. Test explicitly pinsforce:truealone does NOT overwrite:overwrites … only when overwriteCustomizable is set — not force.sync --forceoverwrites + says so on stdout before writingcopyTemplates; ordering asserted via sentinel inannounces customizable overwrites on stdout before copying under --force.preserved: <path> — run \sync --force` to replaceprinted from the returnedpreservedCustomizableset. Test:reports preserved customizable files on stdout under a plain sync`.fileExists(destPath); a missing file falls through towriteFile. Test:creates a missing constitution on a fresh install.pins the round trip: plain copy preserves, opt-in replacesruns the realcopyTemplatesagainst a real fs.--forcesemantics; no longer imply in-place edits unsafedocs/guides/customization.mdadds "Edit it in place (safe)". Cross-checked theupdate/update --forceclaims againstupdate.ts— accurate (#708 protection + forced-overwrite listing before write).Coverage: 7/7 AC items fully met. No derived ACs in the spec.
CI Status
build (22.x)typechecknode-floor-guardvalidate-pluginvalidate-skillsCI Summary: 5 passed, 0 pending, 0 failed. (Diff is not markdown-only, so no relaxation applied — build genuinely green.)
Quality Metrics
any)Test Coverage Analysis
src/lib/templates.tssrc/lib/templates.test.ts(new preservation block, 5 tests, real-fs)src/commands/sync.tssrc/commands/sync.test.ts(new/updated apply + dry-run tests)Coverage: 2/2 changed source files have corresponding tests. No critical (auth/payment/security) paths.
Test Quality Review
preservedCustomizable, not internals. AC-3 test verifies announce-before-copy ordering.sync.testmocks fs/manifest/templates/config (command unit test);isCustomizableFilemock mirrors the real allow-list, andtemplates.testexercises the real function — so mock drift can't hide a regression.Anti-Pattern Detection
No
any, noeval/innerHTML, no hardcoded secrets, no SQL concatenation. Nopackage.jsonchange (dependency audit N/A). Theawaits insidecopyDir's loop are the pre-existing sequential-copy pattern, unchanged in intent.Execution Evidence
src/commands/sync.ts(CLI command logic) changed;scripts/unchanged. End-to-end behavior is exercised by the real-fs round-trip intemplates.test.ts(not mocked), plus the command-level unit tests and green CI. Status: Complete (integration test is the execution evidence).CLI Registration Verification
CopyTemplatesOptionsgainedoverwriteCustomizable, but it is internal — set programmatically from the existingoptions.force, not a new user flag.sync -f, --forceis already registered inbin/cli.ts:206. Status: N/A (no new user-facing flag required).Risk Assessment
CUSTOMIZABLE_FILESentry copied via acopyDirwhosedestPathdoesn't normalize to the exact allow-list string (e.g. an absolute destDir) would silently not be protected. Today allcopyDircall sites use relative dest dirs (.claude/memory, …), andisCustomizableFilenormalizes separators, so this holds — but it's an invariant worth keeping if the copy call sites change.copyTemplates/copyDiris the single bulk write path;symlinkDir(scripts) already has its own force/skip logic and scripts aren't customizable;update.tsalready protects overrides viacomputeTemplateChanges(fix(update/sync): sync reports 'up to date' on content drift; update overwrites in-place customizations (constitution) #708). No other file shares the "write path ignores isCustomizableFile" root cause.copyTemplates(.claude/settings.json,SKILLS_VERSION_PATH) are correct as-is: neither is inCUSTOMIZABLE_FILES(settings is customized viasettings.local.json), so they must always be rewritten.Adversarial Re-Read
Findings: No blocking gaps. (1) Verbatim motivating example (plain
sequant synceating the constitution) is pinned by the AC-6 round-trip against real fs. (2) The exec "evidence" is genuine post-fix validation (content survives plain copy), not a pre-fix repro. (3) Process state clean — only a pre-existingpackage-lock.json(−12 lines, present at session start) is uncommitted, correctly excluded from the commit. (4) Dry-run/apply parity verified by hand:computeTemplateChangesonly classifies existing+differing files aslocal-override, and the dry-run partitions that set byisCustomizableFileexactly ascopyDirdoes — so preview and apply cannot diverge (preserves #722's invariant), including the.local-twin-non-customizable case (both report "overwritten"). (5) No Non-Goal creep: scoped toCUSTOMIZABLE_FILES, and the.local-twin-write-path protection was deliberately left out per the spec's Open Question 1.Status: Clean
Verdict: AC_MET_BUT_NOT_A_PLUS
All 7 ACs are literally met, both changed source files are tested (including a real-fs round trip), local build/lint/tests and all 5 CI checks are green, and dry-run/apply parity is preserved. One recommended polish keeps this from A+:
Recommendation (non-blocking):
sync's--forcehelp text is"Sync even if versions match"(bin/cli.ts:206). Since #814,--forcealso gates overwriting user-owned customizable files (the constitution) — its most consequential effect. Consider expanding the help text, e.g."Sync even if versions match; also overwrites in-place customizations (e.g. the constitution)", so--helpreflects the now-more-destructive semantics. The runtime announce (AC-3) already prevents a silent clobber, so this is polish, not a correctness gap.Optional: add one assertion that a non-customizable tree file is (over)written in the same
copyTemplatescall that preserves the constitution, to lock AC-1's "trees still refresh" clause explicitly.Documentation
customization.md) — AC-7[Unreleased] → Fixed(fix(sync): plain sync overwrites CUSTOMIZABLE_FILES (constitution) — copyDir ignores force and never consults isCustomizableFile #814)/docs 814if admin-facing docs are generated for this repoNext Steps
sync --forcehelp text to mention customizable-file overwrite.fix(worktree): frozen installs so provisioning cannot dirty the lockf…
fix(#814): QA polish — sync --force help text names customizable over…
admarble commentedon Jul 26, 2026
QA Follow-up for Issue #814 (PR #815)
The two non-blocking gaps from the prior QA review (verdict
AC_MET_BUT_NOT_A_PLUSatac0addd) are now addressed in5ee6d66:sync --forcehelp text now names its destructive semantics:"Sync even if versions match; also overwrites in-place customizations (e.g. the constitution)"(bin/cli.ts). Verified vianpx tsx bin/cli.ts sync --help..claude/skills/exec/SKILL.mdand asserts the samecopyTemplatescall that preserves the customized constitution overwrites the tree file with the rendered template (src/lib/templates.test.ts).Additionally,
origin/mainwas merged into the branch (3179fc0) to resolve a CHANGELOG conflict — the PR had goneCONFLICTINGafter #816 landed. The conflict resolution also repairs a pre-existing CHANGELOG corruption introduced on main by e6d160e, where the #816 bullet had overwritten the #808 entry's header and absorbed its body mid-sentence; both entries are now separate, complete bullets (and #816's bullet gains its issue ref).Validation: targeted suites green post-merge (
templates.test.ts+sync.test.ts: 57 passed),tsc --noEmitclean, all 5 CI checks pass (build 22.x, typecheck, node-floor-guard, validate-plugin, validate-skills), PR isMERGEABLE.Verdict: READY_FOR_MERGE
All 7 ACs met (see prior review for the full table), the only recommended polish has landed, and no new gaps were introduced.
fix(#814): plain sync preserves CUSTOMIZABLE_FILES (constitution) (#815)
fix(#921): spec recommendation handoff — resolve via structured comme…
fix(#814): plain sync preserves CUSTOMIZABLE_FILES; separate overwrit…
fix(#814): QA polish — sync --force help text names customizable over…
fix(#1090): announce a preserved file once, and make the post-copy re…