Repository navigation
fix(#1159): diff scripts/dev against the install target, not the running bundle - #1161
Merged
admarble merged 6 commits intoSep 25, 2026
Conversation
…ing bundle computeTemplateChanges walked the running CLI's bundle for every destination, but copyTemplates installs scripts/dev from resolveScriptsSymlinkTarget() — node_modules/sequant/templates/scripts when a real install is there (#991). With an older sequant installed the two never agreed: sync exited 1 with 'N file(s) differ from bundled content' on every run and --dry-run predicted an overwrite the apply never made. Entire-Checkpoint: d2262d667299
Entire-Checkpoint: 58b292a71ac3
… update non-convergence loop
…-scripts-dev-never-converges-when-node-mod
…pts/dev untouched
admarble
deleted the
feature/1159-fix-sync-scripts-dev-never-converges-when-node-mod
branch
September 25, 2026 14:15
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
computeTemplateChangesdiffed every destination against the running CLI's bundled template — includingscripts/dev/*.sh, whichcopyTemplatesdoes not install from the bundle. Since #991 the writers link (or copy)scripts/devfromresolveScriptsSymlinkTarget().scriptsDir, which prefers<project>/node_modules/sequant/templates/scripts. With an oldersequantinstalled there, the diff and the apply read different files and never agreed:syncexited 1 withVersion current, but N file(s) differ from bundled content, andsync --forcecould not clear it;sync --dry-runprintedoverwrite: scripts/dev/<name>.shfor a write the apply never made.It stayed invisible because
templates/scripts/*.shhad not changed since 2.16.0. #1145 / PR #1156 is the first PR to change one, and it turns the requiredcanarycheck red.Per the owner decision on the issue (option 1), the #991 targeting is untouched. Only the comparison moves:
scripts/devis now diffed against the target it is actually installed from.symlinkDirwould write. Content cannot tell a correct link from a stale one (a link into an evicted npx cache resolves to identical bytes, fix(sync): copy-mode sync leaves existing machine-specific scripts/dev symlinks in place, and doctor's hint loops back to sync #1053), andsymlinkDirrelinks any target that differs, so the target string is the only signal that keeps preview and apply in step.--no-symlinks/ an unlinkable target) — compare the target file's bytes, rendered with the project's variables.sync --forcecould clear either.One edit fixes all four consumers of the count:
sync's version-current fast path,sync --dry-run,checkAndWarnSkillsOutdatedandgetSkillsInstallStatus.resolveScriptsSymlinkTarget,copyTemplates,previewScriptsSymlinkTargets,sync.tsandversion-preflight.tsare unchanged.One deliberate departure from the plan
The spec's step 3 said to drop
processTemplateon thescripts/devbranch because "neithersymlinkDirnorcopyDirrenders scripts". That holds forsymlinkDir, butcopyDirdoes render every file it copies (templates.ts, inside the file branch), scripts included. Following the letter would have re-created this exact non-converging loop the moment a.shtemplate grew a{{TOKEN}}: the apply would write rendered bytes while the diff compared raw ones. So the symlink arm does not render (it compares link targets, not content) and the copy arm does — each matching its writer. The spec's underlying concern is satisfied; only its premise aboutcopyDirwas inaccurate.AC verification
syncexits 0 with nodiffer from bundled contentlinesync --dry-runlistsscripts/dev/<name>.shonly when the apply changes itdry-run equals applypasses; it failed on the same tree without the fixresolveScriptsSymlinkTargetstill prefersnode_modules/sequant/templates/scriptsgit diffshows no edit); asserted on disk by the newconverges:casesrc/lib/templates.test.ts,converges:anddoes not report a bundled script the installed copy lacksscripts/devsymlink pointing anywhere else is still reported as driftsrc/lib/templates.test.ts,still reports a link pointing anywhere else as modifiedupdateconverges on a symlink-modescripts/deventry: a second run reports nothing to dosrc/commands/update.integration.test.ts1159:case; writer matrix re-pinned (update columnsT→=on the link route)Canary A/B (AC-1, AC-2)
Both runs in this worktree, same machine, minutes apart. #1156 (
f2f9dbf4) merged in each time, since it is the branch that changes a script template.Before —
origin/main+ #1156,npx vitest run --project canary:with
syncprinting, verbatim:dry-run equals applyfailed onscripts/dev/new-feature.shbeing predicted but not changed;customizations survive sync, init --agent codex --yes and updatefailed on that exit 1.After — this branch + #1156, same command:
Mutation record
Each mutation applied alone, on a clean tree, then reverted. Named test ran via
npx vitest run src/lib/templates.test.ts.node_modules/sequant/templates/scriptspreference fromresolveScriptsSymlinkTargetconverges:case plus the three existing #990 casesSCRIPTS_TEMPLATE_PREFIXat a prefix no template matches, soscripts/devfell back to the bundle diffupdate'slinkTargetfilter a no-op (… || true)1159:update case (npx vitest run src/commands/update.integration.test.ts)Two further arms were mutation-checked the same way, each failing exactly one case: returning
newinstead ofunchangedwhen the install target lacks the script (does not report a bundled script the installed copy lacks), and deleting the copy-mode symlink arm (reports a symlink as modified in copy mode).Mutation-verified: AC-6 — made update.ts's linkTarget filter a no-op; src/commands/update.integration.test.ts 1159 case failed (1 failed | 7 passed); restored.
Runner fixes after QA round 1 (AC_NOT_MET)
QA found that the shared
computeTemplateChangeschange madesequant updateloop.updatewrotescripts/devas a regular file, and the symlink-mode comparison never classifies a regular file asunchanged, so every run reportedUpdated 1 files. Fixed inc8c3732aandb3777a63:scripts/deventries carrylinkTarget, includingnewones, andupdatedrops them. This matches its own dry-run note ("update does not manage … scripts/dev link targets"). Copy mode is unchanged.symlinkDirunconditionally replaces a regular file is corrected: that holds only underforce, whichsyncpasses.update/update --forceon the link route go fromTto=, and their printed decision fromoto-.[email protected]+init, bundlednew-feature.shchanged):update --yestwice →Modified: 6, thenModified: 0.synctwice → exit 0 both times, nodifferlines. The link still points intonode_modules/sequant.Test plan
npx vitest run src/lib/templates.test.ts— 68 passed (64 before, 4 new)npx vitest run --project canaryon a scratch merge with fix(#1145): new-feature.sh derives the branch name with the slugify() rule #1156 — 4 passed (2 failed | 2 passed without the fix)npm run build,npm run lint— cleannpm test— 337 files, 8397 passed | 1 expected fail | 3 skipped, 0 failures (564s). No pre-existing failures to settle.Closes #1159
🤖 Generated with Claude Code