sequant 2.8.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 (68) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +9 -1
  4. package/dist/bin/cli.js +2 -1
  5. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +1 -1
  6. package/dist/marketplace/external_plugins/sequant/README.md +2 -0
  7. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +18 -3
  8. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +330 -57
  9. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +96 -15
  10. package/dist/marketplace/external_plugins/sequant/skills/assess/references/predicted-collision-detection.md +9 -6
  11. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +1 -1
  12. package/dist/marketplace/external_plugins/sequant/skills/reflect/SKILL.md +27 -13
  13. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/documentation-tiers.md +80 -68
  14. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/phase-reflection.md +31 -15
  15. package/dist/marketplace/external_plugins/sequant/skills/release/SKILL.md +10 -2
  16. package/dist/marketplace/external_plugins/sequant/skills/spec/references/verification-criteria.md +1 -1
  17. package/dist/src/commands/logs.js +6 -1
  18. package/dist/src/commands/run-display.d.ts +20 -0
  19. package/dist/src/commands/run-display.js +80 -1
  20. package/dist/src/commands/stats.js +47 -0
  21. package/dist/src/lib/assess-collision-detect.d.ts +19 -2
  22. package/dist/src/lib/assess-collision-detect.js +68 -4
  23. package/dist/src/lib/cli-ui/run-renderer.js +17 -9
  24. package/dist/src/lib/errors.d.ts +6 -0
  25. package/dist/src/lib/errors.js +9 -2
  26. package/dist/src/lib/manifest.js +1 -17
  27. package/dist/src/lib/version-check.js +1 -5
  28. package/dist/src/lib/workflow/batch-executor.d.ts +13 -0
  29. package/dist/src/lib/workflow/batch-executor.js +81 -18
  30. package/dist/src/lib/workflow/chain-preflight.d.ts +89 -0
  31. package/dist/src/lib/workflow/chain-preflight.js +199 -0
  32. package/dist/src/lib/workflow/chain-resume.d.ts +116 -0
  33. package/dist/src/lib/workflow/chain-resume.js +166 -0
  34. package/dist/src/lib/workflow/dependency-markers.d.ts +29 -0
  35. package/dist/src/lib/workflow/dependency-markers.js +79 -0
  36. package/dist/src/lib/workflow/drivers/claude-code.d.ts +7 -0
  37. package/dist/src/lib/workflow/drivers/claude-code.js +30 -6
  38. package/dist/src/lib/workflow/error-classifier.d.ts +9 -2
  39. package/dist/src/lib/workflow/error-classifier.js +14 -1
  40. package/dist/src/lib/workflow/log-writer.js +6 -8
  41. package/dist/src/lib/workflow/metrics-schema.d.ts +39 -0
  42. package/dist/src/lib/workflow/metrics-schema.js +16 -0
  43. package/dist/src/lib/workflow/metrics-writer.d.ts +2 -1
  44. package/dist/src/lib/workflow/phase-executor.d.ts +32 -0
  45. package/dist/src/lib/workflow/phase-executor.js +77 -5
  46. package/dist/src/lib/workflow/run-log-schema.d.ts +23 -0
  47. package/dist/src/lib/workflow/run-log-schema.js +45 -1
  48. package/dist/src/lib/workflow/run-orchestrator.d.ts +14 -0
  49. package/dist/src/lib/workflow/run-orchestrator.js +291 -30
  50. package/dist/src/lib/workflow/status-derivation.d.ts +30 -0
  51. package/dist/src/lib/workflow/status-derivation.js +27 -0
  52. package/dist/src/lib/workflow/types.d.ts +23 -0
  53. package/dist/src/lib/workflow/worktree-manager.d.ts +43 -1
  54. package/dist/src/lib/workflow/worktree-manager.js +103 -33
  55. package/dist/src/mcp/tools/run.d.ts +2 -0
  56. package/dist/src/mcp/tools/run.js +2 -0
  57. package/package.json +2 -4
  58. package/templates/hooks/post-tool.sh +18 -3
  59. package/templates/hooks/pre-tool.sh +330 -57
  60. package/templates/scripts/cleanup-worktree.sh +103 -14
  61. package/templates/skills/assess/SKILL.md +96 -15
  62. package/templates/skills/assess/references/predicted-collision-detection.md +9 -6
  63. package/templates/skills/fullsolve/SKILL.md +1 -1
  64. package/templates/skills/reflect/SKILL.md +27 -13
  65. package/templates/skills/reflect/references/documentation-tiers.md +80 -68
  66. package/templates/skills/reflect/references/phase-reflection.md +31 -15
  67. package/templates/skills/release/SKILL.md +10 -2
  68. package/templates/skills/spec/references/verification-criteria.md +1 -1
@@ -1,8 +1,20 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Clean up a worktree after PR is merged
4
- # Usage: ./scripts/cleanup-worktree.sh <branch-name>
4
+ # Usage: ./scripts/cleanup-worktree.sh [flags] <branch-name>
5
5
  # Example: ./scripts/cleanup-worktree.sh feature/123-add-user-dashboard
6
+ #
7
+ # The remote branch is deleted ONLY when the branch's PR is MERGED (the
8
+ # documented post-merge contract) or when an explicit override flag is passed.
9
+ # Local teardown (worktree + local branch) always runs so the branch lock is
10
+ # freed for a subsequent `gh pr merge --delete-branch`.
11
+ #
12
+ # Flags:
13
+ # -y, --yes Skip the confirmation prompt (non-interactive confirm).
14
+ # Does NOT override the merge gate on remote deletion.
15
+ # --delete-remote Override the merge gate and delete the remote branch even
16
+ # when the PR is not merged (still honors the TTY confirm).
17
+ # --force Implies both --yes and --delete-remote.
6
18
 
7
19
  set -e
8
20
 
@@ -13,7 +25,65 @@ YELLOW='\033[1;33m'
13
25
  RED='\033[0;31m'
14
26
  NC='\033[0m'
15
27
 
16
- BRANCH_NAME=$1
28
+ # Print CLI usage/help (kept in sync with the header comment above).
29
+ print_usage() {
30
+ cat <<'USAGE'
31
+ Usage: ./scripts/cleanup-worktree.sh [flags] <branch-name>
32
+
33
+ Clean up a feature worktree. The remote branch is deleted ONLY when the
34
+ branch's PR is MERGED (the documented post-merge contract) or when an
35
+ explicit override flag is passed. Local teardown (worktree + local branch)
36
+ always runs so the branch lock is freed for a subsequent
37
+ `gh pr merge --delete-branch`.
38
+
39
+ Flags:
40
+ -y, --yes Skip the confirmation prompt (non-interactive confirm).
41
+ Does NOT override the merge gate on remote deletion.
42
+ --delete-remote Override the merge gate and delete the remote branch even
43
+ when the PR is not merged (still honors the confirm gate).
44
+ --force Implies both --yes and --delete-remote.
45
+ -h, --help Show this help and exit.
46
+
47
+ Example:
48
+ ./scripts/cleanup-worktree.sh feature/123-add-user-dashboard
49
+ USAGE
50
+ }
51
+
52
+ # Parse flags. ASSUME_YES bypasses the confirmation prompt; DELETE_REMOTE
53
+ # overrides the merge gate on remote deletion. The first non-flag argument is
54
+ # the branch name. --force is the combined opt-in (both behaviors).
55
+ BRANCH_NAME=""
56
+ ASSUME_YES=false
57
+ DELETE_REMOTE=false
58
+ while [ $# -gt 0 ]; do
59
+ case "$1" in
60
+ -y|--yes)
61
+ ASSUME_YES=true
62
+ ;;
63
+ --delete-remote)
64
+ DELETE_REMOTE=true
65
+ ;;
66
+ --force)
67
+ ASSUME_YES=true
68
+ DELETE_REMOTE=true
69
+ ;;
70
+ -h|--help)
71
+ print_usage
72
+ exit 0
73
+ ;;
74
+ -*)
75
+ echo -e "${RED}❌ Error: Unknown flag: $1${NC}" >&2
76
+ print_usage >&2
77
+ exit 1
78
+ ;;
79
+ *)
80
+ if [ -z "$BRANCH_NAME" ]; then
81
+ BRANCH_NAME="$1"
82
+ fi
83
+ ;;
84
+ esac
85
+ shift
86
+ done
17
87
 
18
88
  # Resolve main worktree (first entry in porcelain output) so subsequent git
19
89
  # commands run from a stable cwd even if the caller invoked us from inside the
@@ -23,11 +93,11 @@ MAIN_WORKTREE=$(git worktree list --porcelain | sed -n 's/^worktree //p' | head
23
93
 
24
94
  # Check if branch name provided
25
95
  if [ -z "$BRANCH_NAME" ]; then
26
- echo -e "${RED}❌ Error: Branch name required${NC}"
27
- echo "Usage: ./scripts/cleanup-worktree.sh <branch-name>"
28
- echo ""
29
- echo "Active worktrees:"
30
- git worktree list
96
+ echo -e "${RED}❌ Error: Branch name required${NC}" >&2
97
+ print_usage >&2
98
+ echo "" >&2
99
+ echo "Active worktrees:" >&2
100
+ git worktree list >&2
31
101
  exit 1
32
102
  fi
33
103
 
@@ -58,12 +128,24 @@ echo ""
58
128
  # Check if PR is merged
59
129
  PR_STATUS=$(gh pr list --head "$BRANCH_NAME" --state merged --json number,state --jq '.[0].state' 2>/dev/null || echo "")
60
130
 
131
+ # Confirmation gate — only reached when the PR is NOT merged. When MERGED we
132
+ # short-circuit past this entirely (no prompt, no TTY check) so the documented
133
+ # post-merge happy path is unchanged.
61
134
  if [ "$PR_STATUS" != "MERGED" ]; then
62
135
  echo -e "${YELLOW}⚠️ Warning: PR for this branch is not merged${NC}"
63
- read -p "Are you sure you want to delete this worktree? (y/n) " -n 1 -r
64
- echo
65
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
66
- echo -e "${BLUE}Cancelled.${NC}"
136
+ if [ "$ASSUME_YES" = true ]; then
137
+ echo -e "${BLUE}Proceeding (--yes/--force).${NC}"
138
+ elif [ -t 0 ]; then
139
+ read -p "Are you sure you want to delete this worktree? (y/n) " -n 1 -r
140
+ echo
141
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
142
+ echo -e "${BLUE}Cancelled.${NC}"
143
+ exit 0
144
+ fi
145
+ else
146
+ # Non-interactive (no TTY) and no confirm flag: exit safely instead of
147
+ # stalling on `read`. Pass --yes/--force to proceed without a prompt.
148
+ echo -e "${BLUE}Non-interactive context and PR not merged — pass --yes or --force to proceed. Exiting without changes.${NC}"
67
149
  exit 0
68
150
  fi
69
151
  fi
@@ -101,9 +183,16 @@ git worktree remove "$WORKTREE_PATH" --force
101
183
  echo -e "${BLUE}🌿 Deleting local branch...${NC}"
102
184
  git branch -D "$BRANCH_NAME" 2>/dev/null || true
103
185
 
104
- # Delete remote branch
105
- echo -e "${BLUE}☁️ Deleting remote branch...${NC}"
106
- git push origin --delete "$BRANCH_NAME" 2>/dev/null || true
186
+ # Delete remote branch — hard-gated on merge state. Only delete when the PR is
187
+ # MERGED or an explicit override flag (--delete-remote/--force) was passed.
188
+ # Otherwise leave the remote branch (and any open PR) intact: deleting an open
189
+ # PR's head branch makes GitHub close the PR unmerged, stranding the work.
190
+ if [ "$PR_STATUS" = "MERGED" ] || [ "$DELETE_REMOTE" = true ]; then
191
+ echo -e "${BLUE}☁️ Deleting remote branch...${NC}"
192
+ git push origin --delete "$BRANCH_NAME" 2>/dev/null || true
193
+ else
194
+ echo -e "${YELLOW}⏭️ Skipped remote-branch delete (PR not merged; pass --delete-remote or --force to override).${NC}"
195
+ fi
107
196
 
108
197
  # Update main
109
198
  echo -e "${BLUE}📥 Updating main branch...${NC}"
@@ -196,11 +196,10 @@ Triggers (any one):
196
196
  - Issue body or comments mention `"depends on #N"`, `"blocked by #N"`, or `"after #N"`
197
197
  - One issue's described output is another issue's input (e.g., A changes a function signature that B consumes)
198
198
 
199
- Format: `Chain: <CMD_PREFIX> run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
199
+ Format: `Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
200
200
 
201
201
  Flag references:
202
202
  - `--chain` chains issues (each branches from previous; implies `--sequential`)
203
- - `--qa-gate` pauses chain on QA failure (requires `--chain`)
204
203
  - `--base <branch>` — issue references a feature branch
205
204
 
206
205
  ### Step 5: Conflict Detection
@@ -255,7 +254,7 @@ Order: <N> → <N> (<dependency reason>)
255
254
  ⚠ #<N> <warning>
256
255
  ⚠ #<N> <warning>
257
256
 
258
- Chain: <CMD_PREFIX> run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <reason>
257
+ Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <reason>
259
258
 
260
259
  Flags:
261
260
  <flag> <one-line reason>
@@ -318,7 +317,7 @@ Emit annotations in this order between the separators that follow `Commands:`:
318
317
  - `⚠ #412 bug + auth labels — domain label (auth) takes priority over bug`
319
318
 
320
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:
321
- `Chain: <CMD_PREFIX> run <N1> <N2> --chain --qa-gate -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
320
+ `Chain: <CMD_PREFIX> run <N1> <N2> --chain -Q <phases> # alternative — <one-line reason>` (`<CMD_PREFIX>` resolved in Step 1)
322
321
 
323
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:
324
323
  ```
@@ -402,7 +401,7 @@ Order: 185 → 186 (185 changes fetchApi error format that 186 consumes)
402
401
  ⚠ #185 Domain errors already exist in repository layer — scope may be smaller than expected
403
402
  ⚠ #186 @tanstack/react-query not installed; large scope (9 hooks + optimistic updates)
404
403
 
405
- Chain: npx sequant run 185 186 --chain --qa-gate -Q --testgen
404
+ Chain: npx sequant run 185 186 --chain -Q --testgen
406
405
  # alternative — use if 186 should branch from 185's work
407
406
 
408
407
  Flags:
@@ -669,16 +668,97 @@ Every separator and section is conditional. If there are no warnings, no chain,
669
668
 
670
669
  After displaying output, prompt the user to save using `AskUserQuestion` with options "Yes (Recommended)" and "No".
671
670
 
672
- If confirmed, post a structured comment to each issue via `gh issue comment`. Each posted comment should include:
673
- - **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.
674
- - The action headline (`→ ACTION — reason`)
675
- - The workflow (for PROCEED/REWRITE)
676
- - Standard HTML markers on separate lines:
677
- ```
678
- <!-- assess:action=PROCEED -->
679
- <!-- assess:phases=spec,exec,qa -->
680
- <!-- assess:quality-loop=true -->
681
- ```
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
+ ```
682
762
 
683
763
  ## Notes
684
764
 
@@ -709,4 +789,5 @@ If confirmed, post a structured comment to each issue via `gh issue comment`. Ea
709
789
  - [ ] Supersession header prepended when prior assess comments exist (`buildSupersessionHeader`)
710
790
  - [ ] Churn warning included in dashboard when `detectChurn(...).isChurn === true`
711
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
712
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.
@@ -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
@@ -120,21 +120,35 @@ For each proposal, specify:
120
120
 
121
121
  ### **Documentation Health Check**
122
122
 
123
- Review CLAUDE.md size and relevance:
124
- - Current line count (target: 700-800)
125
- - Sections that feel bloated
126
- - Sections that are missing
127
- - Redundancy check
128
- - Extract candidates (sections >50 lines)
129
- - Recommendation: [Prune | Expand | Restructure | Extract | Good as-is]
123
+ **CLAUDE.md is an index, not a knowledge store.** Durable knowledge belongs in
124
+ auto-memory, `docs/`, or the relevant skill; CLAUDE.md holds only what must be
125
+ loaded into *every* session (commit rules, hook gotchas, skill-invocation
126
+ rules). A short CLAUDE.md is a sign the other tiers are doing their job — do
127
+ **not** recommend padding it toward some line count. There is no target length.
128
+
129
+ Review CLAUDE.md relevance:
130
+ - Does every line still apply, and is it still accurate?
131
+ - Anything that only matters in one workflow → move to that skill or `docs/`
132
+ - Anything that is durable session-to-session context → auto-memory
133
+ - Redundancy check (same rule stated here and in a skill)
134
+ - Extract candidates (sections >50 lines — CLAUDE.md should rarely have any)
135
+ - Recommendation: [Prune | Restructure | Extract | Good as-is]
136
+
137
+ Also check the **memory** tier, which carries most of this repo's knowledge:
138
+ - Entries citing script flags, CLI behavior, or `file:line` **rot silently** —
139
+ spot-check any entry you relied on this session against current code and fix
140
+ it. A wrong memory is worse than a missing one.
141
+ - Index (`MEMORY.md`) one-liners still accurate?
130
142
 
131
143
  ### **Action Items**
132
144
 
133
- Generate a checklist:
134
- - [ ] Add section to CLAUDE.md: [topic]
135
- - [ ] Update slash command: [command name]
136
- - [ ] Move to docs/archive/: [file name]
137
- - [ ] Create new command: [command name]
145
+ Generate a checklist. Prefer concrete targets — a file, a memory entry, a
146
+ command over intentions:
147
+ - [ ] Correct/remove a stale memory entry: [name] (verify against current code first)
148
+ - [ ] Add a memory entry for: [durable lesson]
149
+ - [ ] Update skill: [name] — remember all three skill dirs
150
+ - [ ] Update docs: [path] (check main README + marketplace README + docs/)
151
+ - [ ] Add a pointer to CLAUDE.md: [one line + link] — only if needed most sessions
138
152
  - [ ] Remove outdated content: [location]
139
153
 
140
154
  ## Workflow Analytics
@@ -172,7 +186,7 @@ At the end of reflection, ask:
172
186
  - [ ] **Session Summary** - What was accomplished, what went well, friction points
173
187
  - [ ] **Effectiveness Analysis** - Token efficiency, context gathering, pattern reuse
174
188
  - [ ] **Proposed Changes** - Specific changes with target files and rationale
175
- - [ ] **Documentation Health** - Line count, bloat assessment, recommendations
189
+ - [ ] **Documentation Health** - CLAUDE.md relevance/accuracy (not length) + memory-tier rot check
176
190
  - [ ] **Action Items** - Checklist of concrete next steps
177
191
 
178
192
  **DO NOT respond until all items are verified.**
@@ -1,70 +1,82 @@
1
1
  # Documentation Tiers
2
2
 
3
- Organize information by access frequency:
4
-
5
- ## Tier 1: Hot Path (CLAUDE.md)
6
-
7
- - Used in 50%+ of sessions
8
- - Core architecture decisions
9
- - Most common commands and patterns
10
- - **Target: 700-800 lines** (check with `wc -l CLAUDE.md`)
11
- - Quick summaries with links to detailed docs
12
- - Review monthly
13
-
14
- **Keep in CLAUDE.md:**
15
- - ✅ Core architecture patterns (database, routing, components)
16
- - ✅ Most common commands (development, discovery, enrichment)
17
- - ✅ Critical patterns (validation, audit logging, state management)
18
- - ✅ Quick reference information needed in 50%+ of sessions
19
-
20
- ## Tier 2: Reference (docs/ folder)
21
-
22
- - Used in 10-50% of sessions
23
- - Detailed specs, schemas, guides
24
- - Can be 1000+ lines per doc
25
- - Review quarterly
26
-
27
- **Current specialized docs:**
28
- - `ARCHITECTURE.md` - System architecture overview
29
- - `DATA_PIPELINE.md` - Data processing workflows
30
- - `TESTING.md` - Testing patterns and strategies
31
- - `ADMIN_CMS_ARCHITECTURE.md` - Full CMS architecture
32
-
33
- ## Tier 3: Archive (docs/archive/)
34
-
35
- - Used in <10% of sessions
36
- - Historical context, deprecated patterns
37
- - Move here after 6 months of non-use
38
- - Keep for searchability, not active use
39
-
40
- ## Tier 4: Code Comments
41
-
42
- - Implementation-specific details
43
- - Edge case handling
44
- - Why certain approaches were chosen
45
- - Lives with the code, not in docs
46
-
47
- ## When to Extract to Separate Docs
48
-
49
- Move from CLAUDE.md to docs/ when:
50
- - Section exceeds 50 lines
51
- - ✅ Contains detailed workflow steps (>3 steps)
52
- - Has extensive examples or command variations
53
- - Used occasionally but not in every session
54
- - Could evolve independently
55
-
56
- ## Documentation Health Metrics
57
-
58
- **CLAUDE.md Health Check:**
59
- - Current line count vs target (700-800)
60
- - Lines added in last month
61
- - Sections that feel bloated
62
- - Sections that are missing
63
- - Redundancy between CLAUDE.md and docs/
64
-
65
- **Recommendations:**
66
- - **Prune:** >900 lines, multiple bloated sections
67
- - **Expand:** <600 lines, missing critical patterns
68
- - **Restructure:** Hard to find information
69
- - **Extract:** Multiple sections >50 lines
70
- - **Good as-is:** 700-800 lines, balanced content
3
+ Where knowledge lives in this repo, by how often it's needed and how long it stays true.
4
+
5
+ **There are no line-count targets.** Judge a tier by whether the right reader
6
+ finds the right thing, not by size. A short CLAUDE.md means the other tiers are
7
+ working, not that it needs filling.
8
+
9
+ ## Tier 1: CLAUDE.md the always-loaded index
10
+
11
+ Loaded into **every** session, so everything here is a tax on every session.
12
+
13
+ **Keep only:**
14
+ - ✅ Rules with no natural home in a skill or doc (commit conventions, hook gotchas)
15
+ - ✅ Pointers a one-line "here's the trap, here's the link"
16
+ - ✅ Things that are wrong to learn late (e.g. skill-invocation namespacing)
17
+
18
+ **Move out:**
19
+ - ❌ Anything that matters in one workflow → that skill
20
+ - Anything explanatory or >~10 lines → `docs/` and link to it
21
+ - ❌ Session-to-session context about *this developer's* work → auto-memory
22
+
23
+ ## Tier 2: Auto-memory the main knowledge store
24
+
25
+ `~/.claude/projects/<project>/memory/`, indexed by `MEMORY.md`. This is where
26
+ most of this repo's hard-won knowledge actually lives (100+ entries): pitfalls,
27
+ feedback, architecture decisions, roadmap state.
28
+
29
+ - One fact per file; `MEMORY.md` carries a one-line pointer.
30
+ - Best tier for "I learned this the hard way and would re-learn it otherwise".
31
+
32
+ **Its failure mode is rot, not bloat.** Entries citing script flags, CLI
33
+ behavior, or `file:line` go stale silently, and a *wrong* memory is worse than a
34
+ missing one — it gets trusted. Verify before asserting; fix on sight.
35
+
36
+ ## Tier 3: docs/ — reference for humans
37
+
38
+ Real structure: `concepts/`, `features/`, `guides/`, `reference/`,
39
+ `getting-started/`, `examples/`, `internal/`, `incidents/`, `investigations/`.
40
+
41
+ - Detailed specs, architecture, runbooks. Length is fine here.
42
+ - User-facing behavior changes must land here, and often in **more than one
43
+ place** check the main README, the marketplace README, and `docs/`.
44
+ - Review when the behavior it describes changes, not on a calendar.
45
+
46
+ ## Tier 4: Skills — workflow instructions
47
+
48
+ `skills/`, `templates/skills/`, `.claude/skills/` — **three real copies**;
49
+ fix all three or `sequant init`/`update` regenerates the bug (CI enforces this
50
+ via `npm run lint:skill-sync`).
51
+
52
+ - Procedure a skill must follow belongs in its `SKILL.md`.
53
+ - Detail a skill needs only sometimes its `references/`, linked from `SKILL.md`.
54
+ - **When editing a SKILL.md, grep its `references/` for the same claim.** Prose
55
+ specs of a rule drift out of sync with the rule itself.
56
+
57
+ ## Tier 5: Code comments
58
+
59
+ Constraints the code can't show why this approach, what breaks otherwise.
60
+ Not what the next line does, and not where it came from.
61
+
62
+ ## When to extract from CLAUDE.md
63
+
64
+ - ✅ It's explanatory rather than a pointer
65
+ - ✅ It only applies to one workflow or one command
66
+ - It has examples, steps, or rationale
67
+ - It could evolve independently of the rest
68
+
69
+ ## Health check
70
+
71
+ **CLAUDE.md:** is every line still true, still needed in *most* sessions, and
72
+ not duplicated in a skill? Recommend `Prune | Restructure | Extract | Good as-is`
73
+ — never "Expand".
74
+
75
+ **Memory:** spot-check entries relied on this session against current code.
76
+ Are `MEMORY.md` one-liners still accurate? Any entry superseded by shipped work?
77
+
78
+ **docs/:** does anything contradict what shipped? Behavior changes are the usual
79
+ source of drift.
80
+
81
+ **Skills:** are the three copies in sync, and does each `SKILL.md` agree with its
82
+ own `references/`?