Repository navigation
Closed
Labels
bugSomething isn't workingcliCLI commands and interfacegraph-2026-09-w2Wave 2 (2026-09): sync ownership, fresh-session QA, trust contractplannedImplementation plan approved
Description
Epic: W2 Blocked by: — Tier: mechanical Doc: W2 PLAN §4 (template sync seam), §5 I-2, §7 D1/D2/D3/D6, Lab §1
Why
Two file classes from the 2026-09-06 downstream incident that #988 (v2.13.1)
did not close, because an explicit sequant sync still does both:
AGENTS.md—src/commands/sync.ts:498-512regenerates it whenever it
exists; it is not inCUSTOMIZABLE_FILES(src/lib/templates.ts:238) and
synchas no--no-agents-md(onlyinitdoes,bin/cli.ts:189). A
deliberate 73-line pointer file was replaced with a 1,079-line copy of
CLAUDE.mdbecausegenerateAgentsMdinlinesgetPortableInstructions()
(src/lib/agents-md.ts:100).scripts/dev/*.sh— symlink target is
relative(dirname(dest), <templates dir of whichever sequant ran>)
(src/lib/templates.ts:499-507): an npx cache path (evicted → dead links), an
npm linksibling or a global prefix (machine-specific). Only a local
devDependency target survivesgit clone && npm install. The links are
tracked (GITIGNORE_ENTRIESis.sequant/only,src/commands/init.ts:101),
so every re-sync from a different runner is churn on three files.- Found in Phase 0 (Lab §1):
src/commands/doctor.ts:320-360tells the
owner of a pointer-styleAGENTS.mdto runsequant sync --force— the
command that destroys it.
One contract (PLAN §5 I-2): sequant never rewrites a tracked file the user owns,
never writes a machine-specific one, and shows every such decision before
writing.
Scope
- may touch:
src/lib/templates.ts,src/lib/agents-md.ts,
src/commands/sync.ts,src/commands/init.ts,src/commands/doctor.ts,
bin/cli.ts(one.option()line onsync),README.md(sync-section
lines),CHANGELOG.md([Unreleased], one bullet); tests:
src/lib/templates.test.ts,src/lib/agents-md.test.ts,
src/commands/sync.test.ts,src/commands/init.test.ts,
src/commands/doctor.test.ts. - not in scope: populating
Manifest.files(PLAN §10); gitignoring
scripts/dev(OQ-1); the Windows copy path (unchanged); any hook or skill
file (I-4). - real filesystem only: symlink/copy tests run in a temp project with
SEQUANT_TEMPLATES_DIR; nofsmocking (I-8).
Acceptance criteria
- AC-1: a generated
AGENTS.mdbegins with the marker line<!-- sequant:agents-md v=<package version> h=<sha1 of everything after the marker line> -->, written bygenerateAgentsMdand therefore present ininitoutput — Verify:npx vitest run src/lib/agents-md.test.ts -t "AC-1"→ first line matches^<!-- sequant:agents-md v=\S+ h=[0-9a-f]{40} -->$andhrecomputes from the body. - AC-2:
sequant syncleaves anAGENTS.mdbyte-identical when it has no marker or its body hash ≠ the marker'sh=, lists it underCustomizable (preserved), and rewrites it only with--force; a marked file whose hash matches is regenerated as today — Verify:npx vitest run src/commands/sync.test.ts -t "AC-2"→ three cases: unmarked file unchanged +preservedline; marked-and-matching regenerated;--forcerewrites both. Mutation: delete the marker/hash guard → the first case fails; restore. - AC-3:
sequant sync --no-agents-mdskipsAGENTS.mdentirely (parity withinit) — Verify:npx vitest run src/commands/sync.test.ts -t "AC-3"→generateAgentsMdnot called, file untouched;node dist/bin/cli.js sync --help | grep -c -- '--no-agents-md'→1. - AC-4: when
<project>/node_modules/sequant/templates/scripts/exists, everyscripts/dev/*.shlink targets it (relative path) regardless of which sequant binary ran the command — Verify:npx vitest run src/lib/templates.test.ts -t "AC-4"→ withSEQUANT_TEMPLATES_DIRpointing at a sibling dir and a fakenode_modules/sequant/templates/scriptspresent,readlinkof each link resolves insidenode_modules/sequant. Mutation: remove thenode_modulespreference → fails; restore. - AC-5: with no local
node_modules/sequant, a templates dir under a/_npx/path segment or outside the project tree yields copies, not links, plus exactly one stdout line that says why and names--no-symlinks— Verify:npx vitest run src/lib/templates.test.ts -t "AC-5"→ two cases (the_npxcase uses the verbatim field target../../../../.npm/_npx/38ae72183b73fa32/node_modules/sequant/templates/scripts/new-feature.sh, observed committed insequant-io/sequant-landingon 2026-09-09 — PLAN D13; the second is a sibling dir): no symlinks underscripts/dev, files present, exactly one line matching--no-symlinks. Mutation: drop the_npx/outside-tree detection → links appear; restore. - AC-6:
sequant sync --dry-runprints theAGENTS.mddecision (runner amendment 2026-09-10, W2 D16: thesequant update --dry-runclause moves to 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 —updatenever regeneratesAGENTS.mdnor re-linksscripts/dev, so printing those decisions there would 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 owns;update.tsis also outside this node's may-touch list) (regenerate|preserved|skipped (--no-agents-md)) and, for eachscripts/devlink whose target would change,old → new, and write nothing — Verify:npx vitest run src/commands/sync.test.ts -t "AC-6"→ stdout assertions; project tree hash identical before and after. - AC-7:
sequant doctor(a) warns on ascripts/dev/*.shlink whose target is missing or resolves outside bothnode_modules/sequantand the project tree, naming the fix command, and (b) reports an unmarked or hash-mismatchedAGENTS.mdasuser-owned (preserved by sync)and never recommendssync --forcefor it — Verify:npx vitest run src/commands/doctor.test.ts -t "AC-7"→ dead-link case warns with the fix text; user-owned case's message contains no--force. Mutation: restore the old--forcehint → (b) fails; restore. - AC-8: the behavior change is documented —
CHANGELOG.md[Unreleased]and the README sync section state the ownership rule, the marker, and that pre-existingAGENTS.mdfiles without a marker are treated as user-owned untilsync --forceonce — Verify:grep -c "sequant:agents-md" README.md CHANGELOG.md→ both ≥ 1. - AC-9: suite green — Verify:
npm run build && npm test→ pass.
Done when
sequant sync/update never rewrite an AGENTS.md the user owns and never
write a scripts/dev link that only works on the machine that ran the command,
and every such decision is visible in --dry-run and doctor before any
write.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingcliCLI commands and interfacegraph-2026-09-w2Wave 2 (2026-09): sync ownership, fresh-session QA, trust contractplannedImplementation plan approved
Activity
admarble commentedon Sep 7, 2026
Sibling from the same 2026-09-06 downstream sync: #991 (scripts/dev symlink targets). Both are file classes the #988 fix leaves untouched on an explicit
sequant sync.admarble commentedon Sep 8, 2026
Runner context — opencode dogfood sample (graph-2026-09 node 16, #997). This issue is being run spec→exec→qa twice as a sample for the opencode promotion gate: once with
--agent opencode(base branchdogfood/opencode-2026-09, which carries the generated.opencode/wrappers and hook shim), then once with the default claude-code driver. The resulting PRs are samples and will not be merged; the owner reads them for defects and the runner records verdict, skill-marker presence, fan-out, cost and wall time indocs/investigations/multi-backend-2026-07.md("Dogfood 2026-09"). Work the issue exactly as you would for real — same ACs, same PR body discipline, mutation records for gate tests — but do not file any issue and do not merge. Commit a WIP within 5 minutes and every ~10 minutes; targeted tests in the foreground only; a phase silent for 30 minutes is killed. Cost cap for the opencode arm across all three sample issues: $30.[-]fix(sync): AGENTS.md is regenerated unconditionally — a hand-maintained file is silently replaced with a CLAUDE.md copy (no opt-out, not a customizable file)[/-][+]fix(sync): never rewrite a user-owned AGENTS.md or write a machine-specific scripts/dev symlink (absorbs #991)[/+]docs(graph): wave 2 plan — sync ownership, fresh-session QA, trust co…
admarble commentedon Sep 10, 2026
Runner context — W2 wave 1 launch (2026-09-10). This supersedes the 2026-09-08 "opencode dogfood sample" comment above: the #997 gate was deferred and this issue was re-scoped as wave-2 node 01. This is a real run on the default claude-code driver; the PR is for the owner's merge review (stop-at-PR — do not merge). Work the ACs and verify commands in the body exactly.
mainat 988559f (v2.14.0). feat(run): fresh-session QA — never resume the exec session into qa; expose run.fullQa (setting + --full-qa + MCP param) #982 and docs+ci(trust): public threat model with OWASP agentic mapping, SECURITY.md, recurring injection eval, and supply-chain trust signals #980 run in parallel; each adds one.option()line tobin/cli.ts, one README region and one append-only CHANGELOG bullet (PLAN §8) — keep to yours.templates/opencode/** → .claude/opencode/**drift. Do not fix it here.Mutation-verified:records in the PR body (CLAUDE.md).admarble commentedon Sep 10, 2026
Complexity: Complex (9 ACs, 4 directories)
AC Quality Check
9/9 pass the standard lint (no vague/unmeasurable/incomplete/open-ended/title-body-tension flags). Two non-blocking format notes:
— Verify: <command>rather than the constitution'sEvidence:clause format.extractAcceptanceCriteriaonly recognizes a literalEvidence:clause (feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938) for declared-evidence verification-method inference, so all 9 ACs resolved toverificationMethod: "manual"programmatically even though each names an exactvitest run ... -t "AC-N"command. Doesn't block planning (methods assigned manually below from the Verify text), but worth knowing before trusting/spec's auto-inference on this issue.## Non-Goalsheading and reports it missing; the issue's## Scope→not in scope:bullets serve the same purpose in different words. Treated as present for the assessment below.Scope Assessment
Non-Goals (from
## Scope→ not in scope): populatingManifest.files(PLAN §10); gitignoringscripts/dev(OQ-1); the Windows copy path (unchanged); any hook or skill file (I-4).src,bin,scripts, tests)Verdict: ❌ SCOPE_SPLIT_RECOMMENDED (programmatic)
Assessment: the keyword clustering doesn't track a real feature seam here — AC-1/2/3 (AGENTS.md ownership marker) and AC-4/5 (symlink target ownership) are the two halves of one contract ("never rewrite a tracked file the user owns, never write a machine-specific one"), and AC-6/7/8/9 (visibility, docs, tests) apply to both halves together. Recommend proceeding as one issue, as already scoped by the issue author (explicit file list, absorbed sibling #991, single PLAN §5 I-2 citation) — see Open Questions.
Acceptance Criteria
AC-1: Generated
AGENTS.mdbegins with a versioned, self-verifying marker lineVerification: Unit Test
Scenario: Given
generateAgentsMd(config)→ When called → Then output's first line matches^<!-- sequant:agents-md v=\S+ h=[0-9a-f]{40} -->$, andhis the sha1 of everything after that line.Assumptions: The hash must cover the exact bytes written to disk (including the trailing newline
generateAgentsMdappends at agents-md.ts:116), not a re-trimmed copy — see Open Question 3.AC-2:
sequant syncnever rewrites an AGENTS.md it doesn't recognize as its ownVerification: Integration Test
Scenario: Given an
AGENTS.mdwith no marker, or a marker whoseh=doesn't match the recomputed body hash → Whensequant syncruns (no--force) → Then the file is byte-identical and reported under "Customizable (preserved)"; given a marked file whose hash matches → Then it regenerates as today; given--force→ Then both cases rewrite.Assumptions: Reuses the existing
preservedCustomizablereporting pattern (sync.ts:478-492) built forCUSTOMIZABLE_FILES/constitution.md (#814) rather than inventing a second mechanism.AC-3:
sequant sync --no-agents-mdskips AGENTS.md entirelyVerification: Integration Test
Scenario: Given
--no-agents-md→ Whensequant syncruns → ThengenerateAgentsMdis never called and the file is untouched;node dist/bin/cli.js sync --helpcontains--no-agents-mdexactly once.Assumptions: Mirrors
init's existing--no-agents-md(bin/cli.ts:189, init.ts:88/643/808) — same flag semantics, new command.AC-4: A local
node_modules/sequant/templates/scripts/always wins as the symlink targetVerification: Integration Test
Scenario: Given
node_modules/sequant/templates/scriptsexists in the project → Whenscripts/dev/*.shlinks are (re)created, regardless of whichgetTemplatesDir()value produced the copy → Then every link'sreadlinkresolves insidenode_modules/sequant.Assumptions: New preference check sits beside
getTemplatesDir()(templates.ts:122-140) and feedssymlinkDir's call site incopyTemplates(templates.ts:662-682), which today always targets whatevertemplatesDirresolved to.AC-5: A
_npxor outside-project-tree templates dir produces copies, not linksVerification: Integration Test
Scenario: Given no local
node_modules/sequantand a templates dir under/_npx/(using the verbatim PLAN D13 fixture path) or outsideprocess.cwd()→ When scripts/dev is populated → Then no symlinks are created, files are present, and exactly one stdout line names--no-symlinks.Assumptions: Extends the existing
useSymlinksgate (templates.ts:663, currently only!options.noSymlinks && !isNativeWindows()) with a third condition; the Windows copy path itself is explicitly out of scope (unchanged).AC-6:
--dry-runpreviews both decisions before any writeVerification: Integration Test
Scenario: Given
sequant sync --dry-run→ When run → Then it prints the AGENTS.md decision (regenerate|preserved|skipped (--no-agents-md)) and, per changed scripts/dev link,old → new, and the project tree hash is identical before/after.Assumptions: See Open Question 1 — the AC also names
sequant update --dry-run, but the Verify command only exercisessync.test.ts, andupdate.tshas no AGENTS.md awareness today at all (confirmed: zero references insrc/commands/update.ts).AC-7:
sequant doctorwarns correctly on both artifact classesVerification: Integration Test
Scenario: Given a
scripts/dev/*.shlink whose target is missing or resolves outside bothnode_modules/sequantand the project tree → Whendoctorruns → Then it warns and names the fix command; given an unmarked/hash-mismatched AGENTS.md → Then it reportsuser-owned (preserved by sync)and the message contains no--force.Assumptions: Part (b) replaces the current
doctor.ts:331-336branch, which today recommendssync --forcefor exactly this case — the bug the issue's "Found in Phase 0" note calls out.AC-8: Behavior is documented
Verification: Integration Test
Scenario: Given the implementation lands → When
grep -c "sequant:agents-md" README.md CHANGELOG.mdruns → Then both counts are ≥ 1.Assumptions: CHANGELOG
[Unreleased]is currently empty (one bullet to add); README already documentssync --dry-run/update --dry-runnear line 69 — natural place to extend.AC-9: Suite green
Verification: Integration Test
Scenario: Given the full change set → When
npm run build && npm testruns → Then it passes.Assumptions: None beyond the above.
Implementation Plan
Phase 1: AGENTS.md ownership marker (AC-1, AC-2, AC-3)
src/lib/agents-md.ts(buildMarkerLine,parseMarkerLine, sha1 viacrypto); prepend the marker togenerateAgentsMd's output (agents-md.ts:112-116).sync.ts's regenerate block (sync.ts:498-521), read the existing file first; skip-and-report when unmarked or hash-mismatched (unless--force); regenerate when marked-and-matching or--force.--no-agents-mdto thesynccommand inbin/cli.ts(one.option()line, matchinginit's at line 189) and threadagentsMdthroughSyncOptions.Phase 2: Machine-specific symlink targeting (AC-4, AC-5)
templates.tsneargetTemplatesDir(lines 122-140): prefer<project>/node_modules/sequant/templates/scriptswhen present; else, if the resolved dir is under_npxor outsideprocess.cwd(), signal "copy" with a one-line reason naming--no-symlinks; else symlink as today.copyTemplates's scripts branch (templates.ts:662-682), replacing the current unconditionaluseSymlinksgate.Phase 3: Visibility — dry-run and doctor (AC-6, AC-7)
sync.ts's dry-run branch (sync.ts:366-441), print the AGENTS.md decision line and per-linkold → newlines using the Phase 1/2 helpers, writing nothing.doctor.ts: add a scripts/dev dead/foreign-target link check (new); replace the AGENTS.md consistency branch (doctor.ts:320-364) with the marker/hash-aware "user-owned (preserved by sync)" message, removing the--forcehint for that case.Phase 4: Docs and verification (AC-8, AC-9)
[Unreleased]bullet and extend the README sync section (~line 69) with the ownership rule, the marker, and the one-time--forcenote for pre-existing unmarked files.npm run build && npm test.Design Review
agents-md.tsbeside generation; symlink-target preference lives intemplates.tsbesidegetTemplatesDir. Both are consumed bysync.ts(write + dry-run) anddoctor.ts(read-only check) — no new module needed.CUSTOMIZABLE_FILES/isCustomizableFilesplit (fix(sync): plain sync overwrites CUSTOMIZABLE_FILES (constitution) — copyDir ignores force and never consults isCustomizableFile #814) already proves the minimal shape for exactly this kind of decision.--force." The only structural difference is how divergence is detected — constitution.md diffs against a stored template, but AGENTS.md content varies per-project (name, stack, conventions), so there's no template to diff against; the self-describing marker+hash is the substitute for a stored baseline.Feature Quality Planning
Most standard checks pass. Notable items:
update.ts/update.test.tsare not in the issue's file list but AC-6's prose namessequant update --dry-run— see Open Question 1; recommend descoping that clause from this PR.isNativeWindows()fallback.Derived ACs
None.
Open Questions
sequant update --dry-run, butupdate.tshas no AGENTS.md awareness today and isn't in the file scope. Confirmed: zeroAGENTS.md/agents-mdreferences anywhere insrc/commands/update.ts— its apply path only ever writes filescomputeTemplateChangesdiffs from thetemplates/tree, which never routes toAGENTS.md. The AC's own Verify command only runssync.test.ts -t "AC-6", so it doesn't gate anupdateassertion either. Recommendation: implement AC-6 forsync --dry-runonly (fully covered by the stated Verify command); call out in the PR body that theupdate --dry-runclause is descoped because it requires givingupdatea capability it doesn't have today, which is a bigger change than this issue's mechanical scope implies. Impact if wrong: a literal reading of the issue body could read this as incomplete even though the verify command is green — worth a one-line flag in the PR so QA doesn't treat it as silently dropped.sync.tsdry-run block anddoctor.ts.generateAgentsMdappends? Recommendation: hash the exact bytes written to disk (post-trimEnd()+"\n"), so "byte-identical" in AC-2 is unambiguous. Impact if wrong: a differently-trimmed hash would make freshly-generated files register as "user-owned" on the very next sync — a false positive that reproduces this issue's own bug class in the fix itself.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled
Reasoning: Correctness-critical file-ownership logic (the exact bug class behind the 2026-09-06 downstream incident, #988/#990/#991) with 4 mutation-gated ACs (2, 4, 5, 7) across 5 files; testgen because every AC names a specific
-t "AC-N"test that doesn't exist yet, spanningtemplates.test.ts,agents-md.test.ts,sync.test.ts,init.test.ts,doctor.test.ts.Label Review
Current: bug, cli, graph-2026-09-w2
Recommended: bug, cli, graph-2026-09-w2, planned
Reason: Standard post-spec marker; no complexity/UI labels apply (no
.tsx/.jsxinvolved, no browser testing needed).Quality Loop: Enabled — see Recommended Workflow reasoning above.
→
gh issue edit 990 --add-label plannedadmarble commentedon Sep 10, 2026
Runner context — exec resumed (2026-09-10 14:02Z). The first exec attempt was killed by the orchestrator's hard 30-minute per-phase budget with no commit. The worktree kept the work:
bin/cli.ts,src/commands/{doctor,sync}.ts(+tests),src/lib/{agents-md,templates}.ts(+tests, snapshot) are modified and uncommitted. On resume: readgit statusandgit difffirst, commit what is there as a WIP within the first 5 minutes, then continue from where it left off. Commit every ~10 minutes — every phase has a hard 30-minute wall and uncommitted work is only preserved by luck.admarble commentedon Sep 10, 2026
Runner context — exec resumed again (2026-09-10 15:20Z). The second attempt ended the same way as several other runs (#1032): the agent started
npm testin the background and ended its turn "waiting for the notification" — undersequant runthat ends the phase, and the 12 files were left uncommitted. The runner has checkpointed them as4daf25ea chore(#990): wip checkpoint. On resume:git log --oneline main..HEAD+git show --stat HEADfirst, then continue from that commit.Foreground only. Run every check in the foreground with a timeout, e.g.
timeout 600 npm test 2>&1 | tail -80. Do not userun_in_background, a Monitor, or any "wait for the notification" pattern — nothing will wake you; the phase simply ends. Commit every ~10 minutes; every phase has a hard 30-minute wall.fix(#990): doctor never recommends sync --force for a bad scripts/dev…
admarble commentedon Sep 10, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
docs(graph): wave-1 execution record — D15–D17, post-wave ledger, han…
docs(graph): wave-2 plan — node 09 (#1030), D14–D17, and the wave-1 e…
fix(exec): block background tasks under the orchestrator; WIP-commit …
chore(#990): fold the duplicate Fixed heading the union merge left un…
fix(sync): never rewrite a user-owned AGENTS.md or write a machine-sp…
test(agents-md): pin the package version in the per-stack snapshots s…