sequant 2.7.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +18 -2
  4. package/dist/bin/cli.d.ts +1 -1
  5. package/dist/bin/cli.js +12 -2
  6. package/dist/bin/preflight.d.ts +21 -0
  7. package/dist/bin/preflight.js +45 -0
  8. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +1 -1
  9. package/dist/marketplace/external_plugins/sequant/README.md +2 -0
  10. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +18 -3
  11. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +330 -57
  12. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/force-push.md +34 -0
  13. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +117 -19
  14. package/dist/marketplace/external_plugins/sequant/skills/assess/references/predicted-collision-detection.md +9 -6
  15. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +29 -0
  16. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +1 -1
  17. package/dist/marketplace/external_plugins/sequant/skills/loop/SKILL.md +100 -2
  18. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +24 -0
  19. package/dist/marketplace/external_plugins/sequant/skills/qa/references/anti-pattern-detection.md +285 -0
  20. package/dist/marketplace/external_plugins/sequant/skills/qa/references/call-site-review.md +202 -0
  21. package/dist/marketplace/external_plugins/sequant/skills/qa/references/quality-gates.md +287 -0
  22. package/dist/marketplace/external_plugins/sequant/skills/qa/references/test-quality-checklist.md +272 -0
  23. package/dist/marketplace/external_plugins/sequant/skills/qa/references/testing-requirements.md +40 -0
  24. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +95 -11
  25. package/dist/marketplace/external_plugins/sequant/skills/references/shared/framework-gotchas.md +186 -0
  26. package/dist/marketplace/external_plugins/sequant/skills/reflect/SKILL.md +27 -13
  27. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/documentation-tiers.md +80 -68
  28. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/phase-reflection.md +31 -15
  29. package/dist/marketplace/external_plugins/sequant/skills/release/SKILL.md +669 -0
  30. package/dist/marketplace/external_plugins/sequant/skills/spec/references/verification-criteria.md +1 -1
  31. package/dist/marketplace/external_plugins/sequant/skills/test/references/browser-testing-patterns.md +423 -0
  32. package/dist/marketplace/external_plugins/sequant/skills/upstream/SKILL.md +419 -0
  33. package/dist/src/commands/logs.js +6 -1
  34. package/dist/src/commands/run-display.d.ts +20 -0
  35. package/dist/src/commands/run-display.js +80 -1
  36. package/dist/src/commands/stats.js +47 -0
  37. package/dist/src/lib/assess-collision-detect.d.ts +19 -2
  38. package/dist/src/lib/assess-collision-detect.js +68 -4
  39. package/dist/src/lib/cli-ui/run-renderer.js +17 -9
  40. package/dist/src/lib/errors.d.ts +91 -0
  41. package/dist/src/lib/errors.js +118 -0
  42. package/dist/src/lib/manifest.js +1 -17
  43. package/dist/src/lib/version-check.d.ts +19 -0
  44. package/dist/src/lib/version-check.js +45 -5
  45. package/dist/src/lib/workflow/batch-executor.d.ts +13 -0
  46. package/dist/src/lib/workflow/batch-executor.js +142 -24
  47. package/dist/src/lib/workflow/chain-preflight.d.ts +89 -0
  48. package/dist/src/lib/workflow/chain-preflight.js +199 -0
  49. package/dist/src/lib/workflow/chain-resume.d.ts +116 -0
  50. package/dist/src/lib/workflow/chain-resume.js +166 -0
  51. package/dist/src/lib/workflow/dependency-markers.d.ts +29 -0
  52. package/dist/src/lib/workflow/dependency-markers.js +79 -0
  53. package/dist/src/lib/workflow/drivers/agent-driver.d.ts +17 -0
  54. package/dist/src/lib/workflow/drivers/claude-code.d.ts +29 -0
  55. package/dist/src/lib/workflow/drivers/claude-code.js +136 -8
  56. package/dist/src/lib/workflow/error-classifier.d.ts +9 -2
  57. package/dist/src/lib/workflow/error-classifier.js +14 -1
  58. package/dist/src/lib/workflow/log-writer.d.ts +1 -1
  59. package/dist/src/lib/workflow/log-writer.js +6 -8
  60. package/dist/src/lib/workflow/metrics-schema.d.ts +39 -0
  61. package/dist/src/lib/workflow/metrics-schema.js +16 -0
  62. package/dist/src/lib/workflow/metrics-writer.d.ts +2 -1
  63. package/dist/src/lib/workflow/phase-executor.d.ts +50 -0
  64. package/dist/src/lib/workflow/phase-executor.js +151 -17
  65. package/dist/src/lib/workflow/run-log-schema.d.ts +26 -0
  66. package/dist/src/lib/workflow/run-log-schema.js +52 -1
  67. package/dist/src/lib/workflow/run-orchestrator.d.ts +14 -0
  68. package/dist/src/lib/workflow/run-orchestrator.js +291 -30
  69. package/dist/src/lib/workflow/state-manager.d.ts +1 -0
  70. package/dist/src/lib/workflow/state-manager.js +6 -0
  71. package/dist/src/lib/workflow/state-schema.d.ts +3 -0
  72. package/dist/src/lib/workflow/state-schema.js +7 -0
  73. package/dist/src/lib/workflow/status-derivation.d.ts +30 -0
  74. package/dist/src/lib/workflow/status-derivation.js +27 -0
  75. package/dist/src/lib/workflow/types.d.ts +40 -0
  76. package/dist/src/lib/workflow/worktree-manager.d.ts +43 -1
  77. package/dist/src/lib/workflow/worktree-manager.js +103 -33
  78. package/dist/src/mcp/tools/run.d.ts +2 -0
  79. package/dist/src/mcp/tools/run.js +2 -0
  80. package/dist/src/ui/tui/theme.d.ts +18 -4
  81. package/dist/src/ui/tui/theme.js +18 -4
  82. package/package.json +5 -6
  83. package/templates/hooks/post-tool.sh +18 -3
  84. package/templates/hooks/pre-tool.sh +330 -57
  85. package/templates/scripts/cleanup-worktree.sh +103 -14
  86. package/templates/skills/_shared/references/force-push.md +34 -0
  87. package/templates/skills/assess/SKILL.md +117 -19
  88. package/templates/skills/assess/references/predicted-collision-detection.md +9 -6
  89. package/templates/skills/exec/SKILL.md +29 -0
  90. package/templates/skills/fullsolve/SKILL.md +1 -1
  91. package/templates/skills/loop/SKILL.md +100 -2
  92. package/templates/skills/qa/SKILL.md +24 -0
  93. package/templates/skills/qa/references/anti-pattern-detection.md +285 -0
  94. package/templates/skills/qa/references/call-site-review.md +202 -0
  95. package/templates/skills/qa/references/quality-gates.md +287 -0
  96. package/templates/skills/qa/references/test-quality-checklist.md +272 -0
  97. package/templates/skills/qa/references/testing-requirements.md +40 -0
  98. package/templates/skills/qa/scripts/quality-checks.sh +95 -11
  99. package/templates/skills/references/shared/framework-gotchas.md +186 -0
  100. package/templates/skills/reflect/SKILL.md +27 -13
  101. package/templates/skills/reflect/references/documentation-tiers.md +80 -68
  102. package/templates/skills/reflect/references/phase-reflection.md +31 -15
  103. package/templates/skills/release/SKILL.md +669 -0
  104. package/templates/skills/spec/references/verification-criteria.md +1 -1
  105. package/templates/skills/test/references/browser-testing-patterns.md +423 -0
  106. package/templates/skills/upstream/SKILL.md +419 -0
@@ -69,6 +69,20 @@ If the output is non-empty, paste every line verbatim above the dashboard table
69
69
 
70
70
  The orchestrator/MCP mode (`SEQUANT_ORCHESTRATOR` set) returns no output, so the call is safe to make unconditionally.
71
71
 
72
+ **Command prefix (#740, read-only):**
73
+
74
+ Probe once here for a global/PATH `sequant`, and reuse the result for every emitted run command below. `npx sequant` is the invocation most prone to version skew (a dual node prefix plus npx cache reuse can silently run a *stale* binary while a directly-installed `sequant` on PATH is current), so prefer a resolvable global install when one exists.
75
+
76
+ ```bash
77
+ # Resolve CMD_PREFIX once here; reuse it for every emitted run command below.
78
+ command -v sequant >/dev/null 2>&1 && CMD_PREFIX="sequant" || CMD_PREFIX="npx sequant"
79
+ ```
80
+
81
+ - Global install on PATH → `CMD_PREFIX="sequant"` → emit `sequant run …`
82
+ - No global install (npx-only) → `CMD_PREFIX="npx sequant"` → emit `npx sequant run …` (unchanged default — zero behavior change for npx-only users)
83
+
84
+ The probe is read-only and side-effect-free, so it runs unconditionally, including in orchestrator/MCP mode (`SEQUANT_ORCHESTRATOR` set).
85
+
72
86
  **From GitHub (parallel for all issues):**
73
87
 
74
88
  ```bash
@@ -182,11 +196,10 @@ Triggers (any one):
182
196
  - Issue body or comments mention `"depends on #N"`, `"blocked by #N"`, or `"after #N"`
183
197
  - One issue's described output is another issue's input (e.g., A changes a function signature that B consumes)
184
198
 
185
- Format: `Chain: npx sequant run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <one-line reason>`
199
+ Format: `Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
186
200
 
187
201
  Flag references:
188
202
  - `--chain` chains issues (each branches from previous; implies `--sequential`)
189
- - `--qa-gate` pauses chain on QA failure (requires `--chain`)
190
203
  - `--base <branch>` — issue references a feature branch
191
204
 
192
205
  ### Step 5: Conflict Detection
@@ -233,15 +246,15 @@ False-positive guards and tunables (excluded paths, the path regex, the slash-co
233
246
  ...
234
247
  ────────────────────────────────────────────────────────────────
235
248
  Commands:
236
- npx sequant run <N1> <N2> <flags>
237
- npx sequant run <N3> <flags> # resume
249
+ <CMD_PREFIX> run <N1> <N2> <flags>
250
+ <CMD_PREFIX> run <N3> <flags> # resume
238
251
  ────────────────────────────────────────────────────────────────
239
252
  Order: <N> → <N> (<dependency reason>)
240
253
 
241
254
  ⚠ #<N> <warning>
242
255
  ⚠ #<N> <warning>
243
256
 
244
- Chain: npx sequant run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <reason>
257
+ Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <reason>
245
258
 
246
259
  Flags:
247
260
  <flag> <one-line reason>
@@ -286,6 +299,7 @@ The commands block is headed by `Commands:` — no box-drawing, no character cou
286
299
  6. If ALL issues share the same workflow, emit a single command
287
300
  7. **Line splitting:** When a single command would contain more than 6 issue numbers, split into multiple commands of at most 6 issues each, grouped by compatible workflow. Example: 11 issues → two commands (6 + 5)
288
301
  8. **Minimal flags:** Omit `--phases` when the resulting workflow equals the CLI default (registered at `bin/cli.ts:186`, defined as `DEFAULT_PHASES` in `src/lib/workflow/types.ts`). Prefer additive flags over restating phases — additive flags: `--testgen` and `--security-review` (`bin/cli.ts:208-209`). Use `--testgen` instead of `--phases spec,testgen,exec,qa` (or `…,testgen,…,test,qa` for ui-labelled issues, since `phase-mapper.determinePhasesForIssue` auto-adds `test` from the ui label). Use `--security-review` instead of `--phases spec,security-review,exec,qa`. The posted marker (`<!-- assess:phases=… -->`) records the full resolved workflow regardless — markers are machine-readable, displayed commands are human shorthand. This intentional divergence is fine: parsers consume markers, humans copy commands.
302
+ 9. **Command prefix:** Substitute the Step-1 `CMD_PREFIX` for **every** emitted `sequant run` command — the Commands block, the `Chain:` line, and both single-issue detail-mode commands (PROCEED and the REWRITE "fresh start"). `Cleanup:` commands are `git`/`gh`, not `sequant`, so they are unaffected. A resolvable global `sequant` on PATH yields `sequant run …`; npx-only yields `npx sequant run …` (the default). Never mix prefixes within a single assessment.
289
303
 
290
304
  #### Annotation Rules
291
305
 
@@ -303,7 +317,7 @@ Emit annotations in this order between the separators that follow `Commands:`:
303
317
  - `⚠ #412 bug + auth labels — domain label (auth) takes priority over bug`
304
318
 
305
319
  - **`Chain:`** — Only when 2+ PROCEED issues have a detected dependency (see "Chain detection" in Step 4). Suggests an alternative execution topology. Does not replace the default per-issue commands. Format:
306
- `Chain: npx sequant run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <one-line reason>`
320
+ `Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
307
321
 
308
322
  - **`Flags:`** — Only when non-default flags appear in the commands and the reason isn't obvious. One line per **distinct** flag used across all commands. Omit entire section when `-Q` is the only non-default flag AND its reason is obvious (e.g., all issues are enhancements). Format:
309
323
  ```
@@ -321,6 +335,8 @@ Emit annotations in this order between the separators that follow `Commands:`:
321
335
 
322
336
  Not all issues have explicit `- [ ]` checkboxes, so the `ACs` column is omitted.
323
337
 
338
+ > **Prefix in examples:** The worked examples in this doc show the `npx sequant` default (the zero-install path). When the Step-1 probe resolves a global `sequant` on PATH, `CMD_PREFIX="sequant"` and every emitted command uses `sequant run …` instead — consistently within one assessment (see Commands Block Rule #9).
339
+
324
340
  ```
325
341
  # Action Reason Run
326
342
  462 PARK Manual measurement task ‖
@@ -385,7 +401,7 @@ Order: 185 → 186 (185 changes fetchApi error format that 186 consumes)
385
401
  ⚠ #185 Domain errors already exist in repository layer — scope may be smaller than expected
386
402
  ⚠ #186 @tanstack/react-query not installed; large scope (9 hooks + optimistic updates)
387
403
 
388
- Chain: npx sequant run 185 186 --chain --qa-gate -Q --testgen
404
+ Chain: npx sequant run 185 186 --chain -Q --testgen
389
405
  # alternative — use if 186 should branch from 185's work
390
406
 
391
407
  Flags:
@@ -485,7 +501,7 @@ More context since you're focused on one issue. Separators between every section
485
501
  → PROCEED — <one-line reason>
486
502
 
487
503
  Commands:
488
- npx sequant run <N> <flags>
504
+ <CMD_PREFIX> run <N> <flags>
489
505
 
490
506
  <phases> · <N> ACs
491
507
 
@@ -617,7 +633,7 @@ Need: <specific information required>
617
633
  → REWRITE — <reason>
618
634
 
619
635
  Commands:
620
- npx sequant run <N> <flags> # fresh start
636
+ <CMD_PREFIX> run <N> <flags> # fresh start
621
637
 
622
638
  <phases> · <N> ACs
623
639
  ────────────────────────────────────────────────────────────────
@@ -652,16 +668,97 @@ Every separator and section is conditional. If there are no warnings, no chain,
652
668
 
653
669
  After displaying output, prompt the user to save using `AskUserQuestion` with options "Yes (Recommended)" and "No".
654
670
 
655
- If confirmed, post a structured comment to each issue via `gh issue comment`. Each posted comment should include:
656
- - **Supersession header** (when priors exist): If `findAllAssessComments` returned ≥1 prior, prepend `buildSupersessionHeader(priors)` immediately above the `→ ACTION — reason` line. When `detectChurn(...).isChurn === true`, also emit a `⚠ Re-assessed N times since <firstDate> without execution — possible blocker or low priority` warning in the dashboard. When `shouldPromptOnConflict(prior, new) === true`, confirm with the user via `AskUserQuestion` before posting. See "Prior Assessment Detection" in Step 1 for full protocol.
657
- - The action headline (`→ ACTION — reason`)
658
- - The workflow (for PROCEED/REWRITE)
659
- - Standard HTML markers on separate lines:
660
- ```
661
- <!-- assess:action=PROCEED -->
662
- <!-- assess:phases=spec,exec,qa -->
663
- <!-- assess:quality-loop=true -->
664
- ```
671
+ If confirmed, post a structured comment to each issue via `gh issue comment`. **Each posted comment is rendered with the single-mode template that matches that issue's verdict** — the same `#### PROCEED / CLOSE / CLARIFY / PARK / MERGE / REWRITE` templates defined under [Single Mode (1 issue)](#single-mode-1-issue) above. There is no separate, thinner shape for posted comments: the batch **dashboard** in chat and the **posted comment** on each issue are the only two formats, and the posted comment always reuses the single-mode template for its verdict. (Note: this is *not* a reversal of #453 — the single-mode templates are themselves the streamlined, scan-friendly format.)
672
+
673
+ Render each comment as follows:
674
+
675
+ 1. **Pick the template by verdict.** For issue `#N`'s action, use the matching single-mode template (`#### PROCEED`, `#### REWRITE`, etc.) and fill it exactly as single mode would, including — where that template defines them:
676
+ - the `#<N> — <Title>` / `<State> · <labels>` header,
677
+ - the section separators the template defines,
678
+ - the `Commands:` block with the **resolved `CMD_PREFIX`** (Step-1 probe — `sequant` when a global is on PATH, else `npx sequant`) and the **real current flags** for that issue. When the dashboard batched several issues onto one `run` line (e.g. `run 461 460 458 443 -Q`), restate just `#N`'s own single-issue invocation (`run 458 -Q`): the shared flags that applied to `#N`, plus any per-issue flags the dashboard listed separately for it (e.g. `#412`'s `--security-review`, `#411`'s `--phases exec,qa`),
679
+ - the `<phases> · <N> ACs` line,
680
+ - for **CLOSE**, the `Cleanup:` block populated with just `#N`'s cleanup commands, de-aggregated from the dashboard's combined `Cleanup:` block.
681
+
682
+ Reference these templates rather than re-copying their bodies here — they are the single source of truth (avoids drift). Verdicts whose template omits a field (CLOSE / CLARIFY / PARK / MERGE have no `Commands:` or `<phases> · <N> ACs` line) simply omit it, exactly as the template shows.
683
+
684
+ 2. **Carry per-issue warnings.** Any `⚠` line from the batch dashboard that concerns `#N` (collision/conflict, churn, staleness, dual-concern, partial-AC) is carried into that issue's comment, with the leading `#N` dropped (the comment is already scoped to that issue). Placement depends on whether the verdict's template defines a warning slot:
685
+ - **PROCEED / REWRITE** — the template already defines a `⚠ ...` region between its two trailing separators; place the warning there.
686
+ - **CLOSE / CLARIFY / PARK / MERGE** — these templates have no `⚠` region (just a single trailing separator before the markers). Add the warning as its own separator-delimited block immediately above the marker block, so the tail reads: `<trailing separator>` → `⚠ ...` → `<separator>` → `<!-- assess:action=... -->`. This is the sole case where a posted comment extends a slot-less template; every other field still follows Step 1's "omit what the template omits." When an issue has no `⚠`, the template is emitted unchanged.
687
+
688
+ 3. **Supersession header** (when priors exist): If `findAllAssessComments` returned ≥1 prior, prepend `buildSupersessionHeader(priors)` immediately above the `→ ACTION — reason` line. When `detectChurn(...).isChurn === true`, also emit the `⚠ Re-assessed N times since <firstDate> without execution — possible blocker or low priority` warning in the warning slot (per step 2). When `shouldPromptOnConflict(prior, new) === true`, confirm with the user via `AskUserQuestion` before posting. See "Prior Assessment Detection" in Step 1 for full protocol.
689
+
690
+ 4. **Machine markers.** The posted comment keeps the single-mode **3-line** marker block — one directive per line, and only those directives the verdict defines:
691
+ ```
692
+ <!-- assess:action=PROCEED -->
693
+ <!-- assess:phases=spec,exec,qa -->
694
+ <!-- assess:quality-loop=true -->
695
+ ```
696
+ Do **not** use the batch dashboard's compact one-line marker (`<!-- #N assess:action=… assess:phases=… -->`) in a posted comment — that form is for the chat dashboard only.
697
+
698
+ The chat batch dashboard is unchanged — this step governs only what lands on each issue.
699
+
700
+ ### Batch: dashboard vs posted comment
701
+
702
+ A batch run shows one scannable dashboard in chat, then posts one single-mode comment per issue. The two are distinct by design: the dashboard is a triage table across all issues; each comment is the full single-mode assessment for that one issue.
703
+
704
+ Dashboard (chat) — excerpt for #458:
705
+
706
+ ```
707
+ # Action Reason Run
708
+ 458 PROCEED Parallel UX + race condition spec → exec → qa
709
+ ────────────────────────────────────────────────────────────────
710
+ Commands:
711
+ npx sequant run 458 -Q
712
+ ────────────────────────────────────────────────────────────────
713
+ ⚠ #458 Dual concern (UX + race) across 4 files
714
+
715
+ Flags:
716
+ -Q dual concern across 4 files
717
+ ────────────────────────────────────────────────────────────────
718
+
719
+ <!-- #458 assess:action=PROCEED assess:phases=spec,exec,qa assess:quality-loop=true -->
720
+ ```
721
+
722
+ Posted comment on issue #458 (single-mode PROCEED template — `#N` dropped from the warning, 3-line markers):
723
+
724
+ ```
725
+ #458 — Parallel run UX freeze + reconcileState race condition
726
+ Open · bug, enhancement, cli
727
+ ────────────────────────────────────────────────────────────────
728
+
729
+ → PROCEED — Both root causes confirmed in codebase
730
+
731
+ Commands:
732
+ npx sequant run 458 -Q
733
+
734
+ spec → exec → qa · 8 ACs
735
+
736
+ Flags:
737
+ -Q dual concern across 4 files
738
+ ────────────────────────────────────────────────────────────────
739
+ ⚠ Dual concern (UX + race) across 4 files
740
+ ────────────────────────────────────────────────────────────────
741
+
742
+ <!-- assess:action=PROCEED -->
743
+ <!-- assess:phases=spec,exec,qa -->
744
+ <!-- assess:quality-loop=true -->
745
+ ```
746
+
747
+ For a verdict whose template has no `⚠` slot, the carried warning becomes its own separator-delimited block above the markers (Step 2). Posted comment on a **PARK** issue the churn detector flagged:
748
+
749
+ ```
750
+ #530 — Measure real-world assess latency across 20 repos
751
+ Open · task, needs-data
752
+ ────────────────────────────────────────────────────────────────
753
+
754
+ → PARK — Blocked on manual measurement not yet scheduled
755
+ Resume after: latency sampling run completes
756
+ ────────────────────────────────────────────────────────────────
757
+ ⚠ Re-assessed 3 times since 2026-06-30 without execution — possible blocker or low priority
758
+ ────────────────────────────────────────────────────────────────
759
+
760
+ <!-- assess:action=PARK -->
761
+ ```
665
762
 
666
763
  ## Notes
667
764
 
@@ -692,4 +789,5 @@ If confirmed, post a structured comment to each issue via `gh issue comment`. Ea
692
789
  - [ ] Supersession header prepended when prior assess comments exist (`buildSupersessionHeader`)
693
790
  - [ ] Churn warning included in dashboard when `detectChurn(...).isChurn === true`
694
791
  - [ ] Batch mode: table is the primary output, no per-issue detail sections
792
+ - [ ] Persist step: each posted comment uses the single-mode verdict template (not the dashboard shape or a thinner form), with per-issue `⚠` carried into the warning slot and the 3-line marker block
695
793
  - [ ] Single mode: focused summary with separators between sections
@@ -15,9 +15,12 @@ The detector runs automatically during Step 5 whenever ≥2 PROCEED issues are p
15
15
 
16
16
  For each issue body, paths are extracted in this order:
17
17
 
18
- ### 1. Strip code blocks and HTML comments
18
+ ### 1. Strip code blocks, HTML comments, and background sections
19
19
 
20
- Fenced code blocks (```` ``` … ``` ````) and HTML comments (`<!-- … -->`) are removed before any path matching. This is the **AC-5 false-positive guard**: paths quoted as code in prose count, paths inside a code block don't.
20
+ Two pre-extraction strips run before any path matching:
21
+
22
+ - **Code blocks and HTML comments.** Fenced code blocks (```` ``` … ``` ````) and HTML comments (`<!-- … -->`) are removed. This is the **AC-5 false-positive guard**: paths quoted as code in prose count, paths inside a code block don't.
23
+ - **Background/citation sections (#769).** Content under any H1/H2 heading whose text prefix-matches `BACKGROUND_SECTIONS` — `References`, `Context`, `Motivation`, `Additional context`, `See also` (case-insensitive) — is removed, up to the next H1/H2 heading. A path named *only* under such a section is a citation of existing code, not a file the issue will modify, so it no longer contributes to the path set. A path named in an AC bullet (or any other foreground section) survives even when it is *also* cited under `## References`.
21
24
 
22
25
  ### 2. Backtick-quoted source paths (PATH_REGEX)
23
26
 
@@ -85,9 +88,9 @@ These paths are stripped from every issue's path set before pairwise intersectio
85
88
 
86
89
  `EXCLUDED_PATHS` in `src/lib/assess-collision-detect.ts` is the canonical list. To add or remove an entry, edit that constant; this document and the skill prose pick up the change automatically.
87
90
 
88
- ### Code block / HTML comment stripping
91
+ ### Code block / HTML comment / background-section stripping
89
92
 
90
- Step 1 of the extraction (above) removes all fenced code blocks and HTML comments before path matching. A path mentioned **only** inside one of those will not contribute to the issue's path set.
93
+ Step 1 of the extraction (above) removes all fenced code blocks, HTML comments, and background/citation sections (`## References`, `## Context`, `## Motivation`, `## Additional context`, `## See also`) before path matching. A path mentioned **only** inside one of those will not contribute to the issue's path set. This is what stops sibling issues that all cite the same background doc under `## References` from being reported as a phantom collision (#769).
91
94
 
92
95
  ### Path-shape constraints
93
96
 
@@ -95,7 +98,7 @@ The PATH_REGEX requires a directory prefix (one of the six tracked roots) and a
95
98
 
96
99
  ## Tuning notes
97
100
 
98
- - **Proximity weighting** is not implemented. The original feature design proposed weighting paths inside `- [ ] **AC-N:**` bullets higher than paths in "Motivation" or "Additional context". Adding it is a follow-up if the false-positive rate becomes a problem in practice; leave it out until evidence demands it.
101
+ - **Background-section exclusion is implemented (#769); proximity *scoring* is not.** The original design (#556) proposed weighting paths by proximity to `- [ ] **AC-N:**` bullets. #769 shipped the cheap version of that mitigation instead — strip whole background sections (`BACKGROUND_SECTIONS`: `References`, `Context`, `Motivation`, `Additional context`, `See also`) before extraction, so a path cited *only* as background drops out while AC-bullet paths survive. The fuller per-path scoring model remains a follow-up if wholesale section exclusion proves too blunt (e.g. a real target named only under `## Context` becomes a false negative); leave it out until evidence demands it.
99
102
  - **Cost.** For 13 issues (the realistic batch ceiling), pairwise comparison is 78 pairs — cheap, no real performance concern. Don't optimize prematurely.
100
103
 
101
104
  ## Output rules
@@ -104,6 +107,6 @@ The detector returns `CollisionResult[]` from `detectFileCollisions`. The format
104
107
 
105
108
  - `Order: A → B (path)` per pair (or `Order: A → B → C (path)` for 3+ on the same file). `path` is the canonical bare form (e.g. `qa/SKILL.md`).
106
109
  - `⚠ #N Modifies <path> (overlaps #M); land sequentially` per affected issue.
107
- - `Chain: npx sequant run A B C --chain --qa-gate -Q # alternative — N issues modify <path> (chain length≥3 historically 1/6 = 17%; see docs/reference/chain-mode-analysis-2026-05.md)` only when ≥3 issues collide on the same file (suggest-only). The historical-rate annotation comes from the #604 forensic write-up; users see the suggestion alongside the parallel default and can weigh the trade-off.
110
+ - `Chain: npx sequant run A B C --chain -Q # alternative — N issues modify <path> (chain length≥3 historically 1/6 = 17%, predates the #748/#749 fixes; see docs/reference/chain-mode-analysis-2026-05.md)` only when ≥3 issues collide on the same file (suggest-only). The historical-rate annotation comes from the #604 forensic write-up; users see the suggestion alongside the parallel default and can weigh the trade-off.
108
111
 
109
112
  The bare-filename `Order:` exception (defined in the skill's "Annotation Rules") applies here — predicted collisions are file-collision reasons by definition, so the filename in parentheses is the reason verbatim.
@@ -1657,6 +1657,35 @@ Parse the agent's output text for these patterns to detect failures:
1657
1657
  | `blocked by hook` | Operation was blocked by pre-tool hook |
1658
1658
  | `I'm unable to` | Agent hit a blocking constraint |
1659
1659
 
1660
+ ### 4b2. Detecting Turn-Capped Implementers (Incomplete, not Failed)
1661
+
1662
+ Every spawned implementer runs under a `maxTurns` cap (live since #484). Hitting the cap is **not** a failure — the agent did real, partial work before running out of turns, and that work is preserved (driver returns it flagged `capped: true` and warns rather than erroring, #733). Treat a capped implementer as **incomplete**, distinct from the hook-block failures in Section 4b.
1663
+
1664
+ **Turn-cap detection keywords** (parse the agent's output text):
1665
+
1666
+ | Pattern | Meaning |
1667
+ |---------|---------|
1668
+ | `error_max_turns` | Agent hit its turn cap |
1669
+ | `turn cap` / `Returning partial results` | Driver-emitted turn-cap warning |
1670
+ | Output ends mid-task with no completion report | Likely capped |
1671
+
1672
+ **How to handle a capped implementer:**
1673
+
1674
+ - Do **not** discard its changes or roll back the group — keep the partial work it committed.
1675
+ - Record, per task, **which tasks finished vs. which were capped**. A capped task is incomplete, not done.
1676
+ - Continue with the remaining (non-capped) tasks normally; one cap does not abort the whole `/exec` run.
1677
+ - The next `/exec` iteration (or a resumed session) picks up the capped task to finish it — note it explicitly so it is not mistaken for complete.
1678
+ - Reflect capped tasks honestly in the AC verification table (⚠️ Partial) and the progress update, rather than reporting the AC as fully satisfied.
1679
+
1680
+ ```markdown
1681
+ ### Parallel Group Results
1682
+
1683
+ | Task | Status |
1684
+ |------|--------|
1685
+ | Create types/metrics.ts | ✅ Finished |
1686
+ | Refactor batch-executor | ⚠️ Capped (incomplete — resume next iteration) |
1687
+ ```
1688
+
1660
1689
  ### 4c. Prompt Templates for Sub-Agents
1661
1690
 
1662
1691
  When spawning sub-agents for implementation tasks, use task-specific prompt templates for better results. See [prompt-templates.md](../_shared/references/prompt-templates.md) for the full reference.
@@ -855,7 +855,7 @@ export CLAUDE_HOOKS_SMART_TESTS=true
855
855
  When enabled, smart tests will:
856
856
  - Auto-run related tests after each file edit during Phase 2 (EXEC)
857
857
  - Catch regressions immediately instead of waiting for explicit `npm test`
858
- - Log results to `/tmp/claude-tests.log` for debugging
858
+ - Log results to `claude-tests.log` for debugging (`/logs/`, else `/.sequant/logs/`)
859
859
 
860
860
  **Benefits:**
861
861
  - Faster feedback loop during implementation
@@ -42,6 +42,30 @@ When invoked as `/loop <issue-number>`, your job is to:
42
42
  4. Re-run validation until quality gates pass
43
43
  5. Exit when `READY_FOR_MERGE` or max iterations reached
44
44
 
45
+ ## Orchestration Context
46
+
47
+ When running as part of an orchestrated workflow (e.g., `sequant run` or `/fullsolve`), this skill receives environment variables that indicate the orchestration context:
48
+
49
+ | Environment Variable | Description | Example Value |
50
+ |---------------------|-------------|---------------|
51
+ | `SEQUANT_ORCHESTRATOR` | The orchestrator invoking this skill | `sequant-run` |
52
+ | `SEQUANT_PHASE` | Current phase in the workflow | `loop` |
53
+ | `SEQUANT_ISSUE` | Issue number being processed | `123` |
54
+ | `SEQUANT_WORKTREE` | Path to the feature worktree | `/path/to/worktrees/feature/...` |
55
+
56
+ **Behavior when orchestrated (SEQUANT_ORCHESTRATOR is set):**
57
+
58
+ 1. **Use provided worktree** - Work in `SEQUANT_WORKTREE` path directly
59
+ 2. **Use `SEQUANT_ISSUE`** - Skip issue number parsing from invocation
60
+ 3. **Reduce GitHub comment frequency** - Defer updates to orchestrator
61
+ 4. **Trust issue context** - Orchestrator has already validated issue
62
+
63
+ **Behavior when standalone (SEQUANT_ORCHESTRATOR is NOT set):**
64
+
65
+ - Locate worktree from issue number
66
+ - Post progress comments to GitHub
67
+ - Fetch issue context if needed
68
+
45
69
  ## Invocation
46
70
 
47
71
  - `/loop 123` - Parse log for issue #123, fix issues, re-validate
@@ -50,12 +74,66 @@ When invoked as `/loop <issue-number>`, your job is to:
50
74
 
51
75
  ### Step 1: Read Previous Phase Output
52
76
 
77
+ **The source of findings depends on whether you're running in orchestrated or standalone mode.**
78
+
79
+ #### Step 1A: Orchestrated Mode (SEQUANT_ORCHESTRATOR is set)
80
+
81
+ When `SEQUANT_ORCHESTRATOR` is set, read QA findings from the GitHub issue comments instead of a log file:
82
+
83
+ ```bash
84
+ # Check if we're in orchestrated mode
85
+ if [[ -n "$SEQUANT_ORCHESTRATOR" ]]; then
86
+ echo "Orchestrated mode detected (orchestrator: $SEQUANT_ORCHESTRATOR)"
87
+
88
+ # Use SEQUANT_ISSUE if provided, otherwise parse from invocation
89
+ ISSUE_NUMBER="${SEQUANT_ISSUE:-<issue-number>}"
90
+
91
+ # Fetch QA findings from issue comments (use startswith to avoid matching comments that reference QA format)
92
+ gh issue view "$ISSUE_NUMBER" --json comments -q '.comments[] | select(.body | startswith("## QA Review for Issue")) | .body' | tail -1
93
+ fi
94
+ ```
95
+
96
+ **How to identify QA comments:**
97
+
98
+ | Pattern | Meaning |
99
+ |---------|---------|
100
+ | `## QA Review for Issue #N` | QA phase comment header |
101
+ | `### Verdict:` | Contains AC_NOT_MET, AC_MET_BUT_NOT_A_PLUS, etc. |
102
+ | `### AC Coverage` | Table with MET/NOT_MET/PARTIALLY_MET statuses |
103
+ | `### Required Fixes` or `### Recommendations` | Actionable items to fix |
104
+
105
+ **Parsing QA comment:**
106
+ ```bash
107
+ # Extract verdict from QA comment
108
+ verdict=$(echo "$qa_comment" | grep -oE "Verdict:\s*\w+" | head -1 | awk '{print $2}' || true)
109
+
110
+ # Extract NOT_MET AC items
111
+ not_met_acs=$(echo "$qa_comment" | grep -E "NOT_MET|PARTIALLY_MET" || true)
112
+
113
+ # Extract recommendations section
114
+ recommendations=$(echo "$qa_comment" | sed -n '/### Required Fixes/,/###/p' | head -n -1)
115
+ ```
116
+
117
+ **If no QA comment found in orchestrated mode:**
118
+ 1. Log a clear error: `"Warning: No QA comment found in issue #N"`
119
+ 2. Fall back to Step 1B (log file) as a recovery mechanism
120
+ 3. If log file also doesn't exist, exit with error
121
+
122
+ #### Step 1B: Standalone Mode (no SEQUANT_ORCHESTRATOR)
123
+
124
+ When running standalone (interactive `/loop` invocation), read from the log file:
125
+
53
126
  Use the Read tool to read the log file for this issue:
54
127
  ```
55
128
  Read(file_path="/tmp/claude-issue-<issue-number>.log")
56
129
  ```
57
130
 
58
- Parse the log to find:
131
+ **If log file doesn't exist:**
132
+ - Error: `"Log file not found at /tmp/claude-issue-<N>.log. Please run /spec, /exec, /test, or /qa first."`
133
+
134
+ #### Parsing Findings (Both Modes)
135
+
136
+ Parse the output (from comment or log file) to find:
59
137
  - **Last phase executed:** `/test` or `/qa`
60
138
  - **Verdict:** `READY_FOR_MERGE`, `AC_MET_BUT_NOT_A_PLUS`, `NEEDS_VERIFICATION`,
61
139
  or `AC_NOT_MET`
@@ -102,6 +180,12 @@ Extract:
102
180
 
103
181
  ### Step 4: Locate Feature Worktree
104
182
 
183
+ **If orchestrated (SEQUANT_WORKTREE is set):**
184
+ - Use the provided worktree path directly: `cd $SEQUANT_WORKTREE`
185
+ - Skip the lookup steps below
186
+
187
+ **If standalone:**
188
+
105
189
  Find the worktree for this issue:
106
190
  ```bash
107
191
  git worktree list | grep -E "feature.*<issue-number>" || true
@@ -365,7 +449,21 @@ For each iteration, output:
365
449
 
366
450
  ## Error Handling
367
451
 
368
- **If log file doesn't exist:**
452
+ **If orchestrated but no QA comment found:**
453
+ ```
454
+ Warning: No QA comment found in issue #<N>
455
+ Attempting fallback to log file...
456
+ ```
457
+
458
+ If fallback also fails:
459
+ ```
460
+ Error: No QA findings available.
461
+ - No QA comment found in issue #<N>
462
+ - Log file not found at /tmp/claude-issue-<N>.log
463
+ Please run /qa <N> first.
464
+ ```
465
+
466
+ **If log file doesn't exist (standalone mode):**
369
467
  ```
370
468
  Error: Log file not found at /tmp/claude-issue-<N>.log
371
469
  Please run /spec, /exec, /test, or /qa first.
@@ -1085,6 +1085,30 @@ skill_modified=$(git diff main...HEAD --name-only | grep -E "^\.(claude/skills|s
1085
1085
  ```
1086
1086
  If skill files are modified, the quality-checks.sh script automatically runs the three-directory sync check (section 12). If divergence is detected, this blocks `READY_FOR_MERGE` — verdict becomes `AC_MET_BUT_NOT_A_PLUS` with a note to run `npx tsx scripts/check-skill-sync.ts --fix`.
1087
1087
 
1088
+ #### Turn-Capped Checks → Inconclusive (not a phase failure)
1089
+
1090
+ A spawned quality-check sub-agent runs under a `maxTurns` cap (live on every agent since #484). When an agent hits that cap, its work is **partial**, not failed — the driver returns it flagged `capped: true` and warns rather than erroring (#733).
1091
+
1092
+ **How to recognize a turn-capped check:** the sub-agent's reported output is truncated mid-analysis, ends without a verdict, or explicitly notes it ran out of turns (look for `error_max_turns`, "turn cap", or "Returning partial results" in its output).
1093
+
1094
+ **How to handle it — do NOT fail the whole QA phase on a cap alone:**
1095
+
1096
+ - Mark that single check **⚠️ Inconclusive** in the QA summary, with a one-line reason (`hit turn cap — partial analysis`).
1097
+ - Use whatever partial findings the capped agent *did* surface; do not discard them.
1098
+ - Let the **other** checks proceed and contribute to the verdict normally.
1099
+ - If a capped check leaves an AC genuinely unverified, the verdict is `NEEDS_VERIFICATION` for that AC — never a hard `AC_NOT_MET` justified solely by the cap.
1100
+ - Surface inconclusive checks prominently so a human can re-run that check (e.g. with a higher cap) rather than silently treating the cap as a pass.
1101
+
1102
+ ```markdown
1103
+ ### Quality Checks
1104
+
1105
+ | Check | Status | Notes |
1106
+ |-------|--------|-------|
1107
+ | Type safety | ✅ Pass | 0 issues |
1108
+ | Scope/size | ⚠️ Inconclusive | hit turn cap — partial analysis, re-run recommended |
1109
+ | Security | ✅ Pass | 0 critical |
1110
+ ```
1111
+
1088
1112
  See [quality-gates.md](references/quality-gates.md) for detailed verdict synthesis.
1089
1113
 
1090
1114
  ### Using MCP Tools (Optional)