session-orchestrator 3.22.0 → 3.23.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 (268) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.cursor/commands/autopilot-multi.md +14 -0
  5. package/.cursor/commands/autopilot.md +14 -0
  6. package/.cursor/commands/bootstrap.md +14 -0
  7. package/.cursor/commands/brainstorm.md +14 -0
  8. package/.cursor/commands/close.md +13 -0
  9. package/.cursor/commands/contract-version-bump.md +14 -0
  10. package/.cursor/commands/debug.md +14 -0
  11. package/.cursor/commands/discovery.md +14 -0
  12. package/.cursor/commands/dispatcher.md +14 -0
  13. package/.cursor/commands/eli5.md +14 -0
  14. package/.cursor/commands/eval.md +14 -0
  15. package/.cursor/commands/evolve.md +14 -0
  16. package/.cursor/commands/go.md +14 -0
  17. package/.cursor/commands/grill.md +14 -0
  18. package/.cursor/commands/harness-audit.md +13 -0
  19. package/.cursor/commands/journey-audit.md +14 -0
  20. package/.cursor/commands/memory-cleanup.md +14 -0
  21. package/.cursor/commands/persona-panel.md +14 -0
  22. package/.cursor/commands/plan.md +14 -0
  23. package/.cursor/commands/portfolio.md +14 -0
  24. package/.cursor/commands/reconcile.md +14 -0
  25. package/.cursor/commands/release.md +14 -0
  26. package/.cursor/commands/repo-audit.md +13 -0
  27. package/.cursor/commands/session.md +14 -0
  28. package/.cursor/commands/spinout.md +14 -0
  29. package/.cursor/commands/sunset-review.md +14 -0
  30. package/.cursor/commands/templates-ack.md +14 -0
  31. package/.cursor/commands/test.md +14 -0
  32. package/.cursor/hooks.json +60 -0
  33. package/.cursor/rules/000-session-orchestrator.mdc +8 -0
  34. package/.cursor/rules/010-session-workflow.mdc +9 -1
  35. package/.cursor/rules/020-quality-gates.mdc +1 -1
  36. package/.cursor/rules/030-wave-execution.mdc +1 -1
  37. package/.cursor/rules/050-plan.mdc +2 -2
  38. package/.cursor/rules/070-gitlab-ops.mdc +73 -57
  39. package/.cursor/rules/080-ecosystem-health.mdc +7 -7
  40. package/.cursor/skills/architecture/SKILL.md +13 -0
  41. package/.cursor/skills/autopilot/SKILL.md +12 -0
  42. package/.cursor/skills/bootstrap/SKILL.md +12 -0
  43. package/.cursor/skills/brainstorm/SKILL.md +13 -0
  44. package/.cursor/skills/claude-md-drift-check/SKILL.md +13 -0
  45. package/.cursor/skills/contract-version-bump/SKILL.md +12 -0
  46. package/.cursor/skills/convergence-monitoring/SKILL.md +12 -0
  47. package/.cursor/skills/daily/SKILL.md +12 -0
  48. package/.cursor/skills/debug/SKILL.md +13 -0
  49. package/.cursor/skills/discovery/SKILL.md +13 -0
  50. package/.cursor/skills/dispatcher/SKILL.md +13 -0
  51. package/.cursor/skills/docs-orchestrator/SKILL.md +13 -0
  52. package/.cursor/skills/domain-model/SKILL.md +13 -0
  53. package/.cursor/skills/ecosystem-health/SKILL.md +13 -0
  54. package/.cursor/skills/eli5/SKILL.md +13 -0
  55. package/.cursor/skills/eval/SKILL.md +12 -0
  56. package/.cursor/skills/evolve/SKILL.md +13 -0
  57. package/.cursor/skills/frontmatter-guard/SKILL.md +13 -0
  58. package/.cursor/skills/gitlab-ops/SKILL.md +13 -0
  59. package/.cursor/skills/gitlab-portfolio/SKILL.md +13 -0
  60. package/.cursor/skills/grill/SKILL.md +13 -0
  61. package/.cursor/skills/hook-development/SKILL.md +13 -0
  62. package/.cursor/skills/journey-audit/SKILL.md +13 -0
  63. package/.cursor/skills/mcp-builder/SKILL.md +13 -0
  64. package/.cursor/skills/memory-cleanup/SKILL.md +12 -0
  65. package/.cursor/skills/mode-selector/SKILL.md +13 -0
  66. package/.cursor/skills/npm-publish/SKILL.md +12 -0
  67. package/.cursor/skills/peekaboo-driver/SKILL.md +13 -0
  68. package/.cursor/skills/persona-panel/SKILL.md +12 -0
  69. package/.cursor/skills/plan/SKILL.md +13 -0
  70. package/.cursor/skills/playwright-driver/SKILL.md +13 -0
  71. package/.cursor/skills/quality-gates/SKILL.md +13 -0
  72. package/.cursor/skills/reconcile/SKILL.md +12 -0
  73. package/.cursor/skills/repo-audit/SKILL.md +13 -0
  74. package/.cursor/skills/session-end/SKILL.md +13 -0
  75. package/.cursor/skills/session-plan/SKILL.md +13 -0
  76. package/.cursor/skills/session-start/SKILL.md +13 -0
  77. package/.cursor/skills/skill-creator/SKILL.md +13 -0
  78. package/.cursor/skills/spinout/SKILL.md +12 -0
  79. package/.cursor/skills/sunset-review/SKILL.md +13 -0
  80. package/.cursor/skills/test-runner/SKILL.md +13 -0
  81. package/.cursor/skills/tmux-layout/SKILL.md +13 -0
  82. package/.cursor/skills/ubiquitous-language/SKILL.md +13 -0
  83. package/.cursor/skills/using-orchestrator/SKILL.md +13 -0
  84. package/.cursor/skills/vault-mirror/SKILL.md +13 -0
  85. package/.cursor/skills/vault-sync/SKILL.md +13 -0
  86. package/.cursor/skills/wave-executor/SKILL.md +13 -0
  87. package/.cursor/skills/write-executable-plan/SKILL.md +13 -0
  88. package/.mcp.json +4 -1
  89. package/CHANGELOG.md +168 -0
  90. package/README.md +18 -15
  91. package/agents/AGENTS.md +23 -4
  92. package/agents/code-implementer.md +2 -1
  93. package/agents/db-specialist.md +2 -1
  94. package/agents/docs-writer.md +3 -1
  95. package/agents/eval-judge.md +1 -1
  96. package/agents/session-reviewer.md +7 -1
  97. package/agents/test-writer.md +2 -1
  98. package/agents/ui-developer.md +2 -1
  99. package/commands/bootstrap.md +2 -2
  100. package/commands/close.md +3 -1
  101. package/commands/go.md +1 -1
  102. package/commands/journey-audit.md +43 -0
  103. package/docs/USER-GUIDE.md +2 -2
  104. package/docs/ci-setup.md +14 -0
  105. package/docs/codex-setup.md +64 -0
  106. package/docs/components.md +6 -6
  107. package/docs/cursor-setup.md +26 -47
  108. package/docs/events-schema.md +76 -4
  109. package/docs/github-mirror-protection.md +197 -0
  110. package/docs/pi-setup.md +2 -0
  111. package/docs/rule-authoring.md +3 -1
  112. package/docs/scope-collision-guard.md +49 -2
  113. package/docs/session-config-reference.md +26 -4
  114. package/docs/session-config-template.md +4 -3
  115. package/docs/telemetry.md +22 -0
  116. package/hooks/_lib/lock-bootstrap.mjs +8 -4
  117. package/hooks/_lib/vcs-create-matcher.mjs +397 -38
  118. package/hooks/enforce-scope.mjs +64 -0
  119. package/hooks/hooks-codex.json +1 -1
  120. package/hooks/hooks-cursor.json +201 -20
  121. package/hooks/hooks-pi.json +1 -1
  122. package/hooks/hooks.json +2 -2
  123. package/hooks/on-session-end.mjs +211 -10
  124. package/hooks/on-session-start.mjs +214 -11
  125. package/hooks/on-stop.mjs +48 -9
  126. package/hooks/post-subagent-discovery-validator.mjs +34 -3
  127. package/hooks/post-tool-batch-wave-signal.mjs +11 -2
  128. package/hooks/pre-bash-issue-budget.mjs +117 -4
  129. package/hooks/pre-bash-sessions-ledger-guard.mjs +159 -0
  130. package/hooks/pre-bash-staging-fence.mjs +4 -0
  131. package/hooks/pre-task-scope-disjoint.mjs +368 -35
  132. package/hooks/skill-invocation-telemetry.mjs +21 -10
  133. package/monitors/monitors.json +6 -0
  134. package/package.json +1 -1
  135. package/pi/prompts/journey-audit.md +12 -0
  136. package/rules/_index.md +9 -1
  137. package/rules/always-on/ask-via-tool.md +62 -0
  138. package/rules/always-on/bash-harness-pitfalls.md +168 -0
  139. package/rules/always-on/build-value.md +47 -0
  140. package/rules/always-on/cross-session-messaging.md +59 -0
  141. package/rules/always-on/loop-and-monitor.md +221 -0
  142. package/rules/always-on/parallel-sessions.md +142 -12
  143. package/rules/always-on/receiving-review.md +108 -0
  144. package/rules/always-on/test-value.md +40 -0
  145. package/rules/always-on/verification-before-completion.md +77 -0
  146. package/scripts/archive-closed-prds.mjs +258 -18
  147. package/scripts/autopilot.mjs +5 -0
  148. package/scripts/backfill-evidence-digest.mjs +376 -0
  149. package/scripts/cursor-install.mjs +89 -48
  150. package/scripts/export-hw-learnings.mjs +143 -2
  151. package/scripts/express-path.mjs +299 -0
  152. package/scripts/generate-cursor-adapter.mjs +253 -0
  153. package/scripts/github-protection-audit.mjs +358 -0
  154. package/scripts/lib/autopilot/worktree-pipeline.mjs +240 -16
  155. package/scripts/lib/build-live-signals.mjs +24 -5
  156. package/scripts/lib/ci-status-banner.mjs +158 -11
  157. package/scripts/lib/command-blocker.mjs +70 -0
  158. package/scripts/lib/config/reconcile.mjs +79 -4
  159. package/scripts/lib/config/section-extractor.mjs +235 -36
  160. package/scripts/lib/config-schema.mjs +9 -1
  161. package/scripts/lib/config.mjs +57 -6
  162. package/scripts/lib/convergence-monitor.mjs +13 -2
  163. package/scripts/lib/cursor-hook-bridge.mjs +443 -0
  164. package/scripts/lib/dispatcher/cli.mjs +2 -2
  165. package/scripts/lib/express-path.mjs +327 -0
  166. package/scripts/lib/file-lock.mjs +22 -4
  167. package/scripts/lib/gates/gate-full.mjs +81 -8
  168. package/scripts/lib/gates/gate-helpers.mjs +76 -15
  169. package/scripts/lib/git-config-drift.mjs +134 -5
  170. package/scripts/lib/host-identity.mjs +247 -2
  171. package/scripts/lib/instruction-budget-guard.mjs +31 -1
  172. package/scripts/lib/issue-budget.mjs +229 -30
  173. package/scripts/lib/learnings/io.mjs +55 -10
  174. package/scripts/lib/learnings/schema.mjs +95 -28
  175. package/scripts/lib/lock-reaper.mjs +7 -1
  176. package/scripts/lib/locks/staging-fence-lock.mjs +5 -1
  177. package/scripts/lib/locks/state-md-lock.mjs +8 -1
  178. package/scripts/lib/memory-banner.mjs +5 -2
  179. package/scripts/lib/memory-paths.mjs +15 -6
  180. package/scripts/lib/mode-selector/scoring.mjs +53 -6
  181. package/scripts/lib/platform.mjs +72 -9
  182. package/scripts/lib/plugin-root.mjs +143 -19
  183. package/scripts/lib/project-hygiene.mjs +43 -3
  184. package/scripts/lib/quality-gate.mjs +271 -13
  185. package/scripts/lib/reconcile/emitter.mjs +87 -19
  186. package/scripts/lib/reconcile/engine.mjs +281 -13
  187. package/scripts/lib/reconcile/idempotency.mjs +102 -1
  188. package/scripts/lib/reconcile/renderer.mjs +148 -3
  189. package/scripts/lib/reconcile/sanitize.mjs +40 -17
  190. package/scripts/lib/reconcile/writer.mjs +415 -84
  191. package/scripts/lib/rule-loader.mjs +37 -2
  192. package/scripts/lib/rules-sync.mjs +51 -8
  193. package/scripts/lib/scope-gate.mjs +90 -0
  194. package/scripts/lib/session-close-backfill.mjs +369 -28
  195. package/scripts/lib/session-discovery.mjs +13 -3
  196. package/scripts/lib/session-end/phase-skip.mjs +37 -4
  197. package/scripts/lib/session-end/worktree-cleanup.mjs +154 -7
  198. package/scripts/lib/session-id.mjs +30 -14
  199. package/scripts/lib/session-identity/own-session.mjs +159 -0
  200. package/scripts/lib/session-lock.mjs +85 -30
  201. package/scripts/lib/session-schema/normalizer.mjs +70 -3
  202. package/scripts/lib/session-schema/validator.mjs +40 -0
  203. package/scripts/lib/session-start-probes.mjs +608 -0
  204. package/scripts/lib/session-transition.mjs +277 -0
  205. package/scripts/lib/sessions-staleness-banner.mjs +124 -57
  206. package/scripts/lib/spiral-carryover.mjs +90 -9
  207. package/scripts/lib/state-md/frontmatter-mutators.mjs +41 -8
  208. package/scripts/lib/state-md/mission-status.mjs +350 -52
  209. package/scripts/lib/state-md/yaml-parser.mjs +145 -16
  210. package/scripts/lib/state-md.mjs +12 -2
  211. package/scripts/lib/telemetry/sync.mjs +46 -8
  212. package/scripts/lib/validate/check-agents.mjs +66 -0
  213. package/scripts/lib/validate/check-cursor-adapter.mjs +102 -0
  214. package/scripts/lib/validate/check-dead-bridge.mjs +24 -2
  215. package/scripts/lib/validate/check-doc-cli-commands.mjs +16 -32
  216. package/scripts/lib/validate/check-hooks-symmetry.mjs +29 -63
  217. package/scripts/lib/validate/check-playwright-mcp-canary.mjs +13 -22
  218. package/scripts/lib/validate/check-plugin-monitors.mjs +10 -4
  219. package/scripts/lib/validate/check-test-value-bans.mjs +165 -17
  220. package/scripts/lib/validate/check-unwired-features.mjs +340 -32
  221. package/scripts/lib/validate/repo-files.mjs +275 -0
  222. package/scripts/lib/validate-vendored-rules.mjs +229 -7
  223. package/scripts/lib/vault-mirror/process.mjs +99 -43
  224. package/scripts/lib/vault-mirror/telemetry.mjs +210 -0
  225. package/scripts/lib/vault-staleness-banner.mjs +76 -6
  226. package/scripts/lib/vault-status/board-writer.mjs +211 -10
  227. package/scripts/lib/vault-status/narrative-mirror.mjs +188 -8
  228. package/scripts/lib/wave-executor/foreign-dispatch.mjs +832 -0
  229. package/scripts/lib/wave-transcript-tail.mjs +869 -0
  230. package/scripts/materialize-wave-scope.mjs +209 -12
  231. package/scripts/mcp-server.sh +11 -2
  232. package/scripts/parse-config.mjs +65 -0
  233. package/scripts/token-audit.sh +9 -2
  234. package/scripts/validate-plugin.mjs +3 -0
  235. package/scripts/validate-wave-scope.mjs +67 -0
  236. package/scripts/vault-mirror.mjs +203 -34
  237. package/skills/_shared/monitor-patterns.md +31 -5
  238. package/skills/_shared/parallel-aware-auq.md +1 -1
  239. package/skills/_shared/parallel-aware-preamble.md +4 -2
  240. package/skills/_shared/platform-tools.md +11 -5
  241. package/skills/_shared/state-ownership.md +29 -2
  242. package/skills/autopilot/SKILL.md +5 -1
  243. package/skills/bootstrap/SKILL.md +3 -3
  244. package/skills/bootstrap/_shared-template.md +18 -10
  245. package/skills/bootstrap/deep-template.md +10 -6
  246. package/skills/bootstrap/fast-template.md +15 -8
  247. package/skills/bootstrap/standard-template.md +10 -6
  248. package/skills/claude-md-drift-check/checker.mjs +39 -11
  249. package/skills/dispatcher/SKILL.md +1 -1
  250. package/skills/journey-audit/SKILL.md +269 -0
  251. package/skills/peekaboo-driver/SKILL.md +15 -3
  252. package/skills/persona-panel/SKILL.md +1 -1
  253. package/skills/reconcile/SKILL.md +41 -1
  254. package/skills/session-end/SKILL.md +17 -4
  255. package/skills/session-end/metrics-collection.md +7 -4
  256. package/skills/session-end/phase-3-6-tail.md +11 -3
  257. package/skills/session-end/phase-3-7a-recommendations.md +16 -2
  258. package/skills/session-plan/SKILL.md +6 -1
  259. package/skills/session-plan/wave-template.md +1 -0
  260. package/skills/session-start/SKILL.md +30 -16
  261. package/skills/session-start/phase-7-5-mode-selector.md +15 -3
  262. package/skills/session-start/phase-8-5-express-path.md +77 -12
  263. package/skills/vault-sync/validator.mjs +31 -0
  264. package/skills/wave-executor/SKILL.md +4 -2
  265. package/skills/wave-executor/circuit-breaker.md +34 -9
  266. package/skills/wave-executor/wave-loop.md +102 -19
  267. package/templates/_shared/journey-manifest.md +110 -0
  268. package/templates/_shared/rules/parallel-sessions.md +0 -77
@@ -3,21 +3,95 @@
3
3
 
4
4
  Multiple Claude Code sessions may be active in the same working directory simultaneously. Another agent may be editing files, creating commits, or running builds right now. Treat the repo as a shared workspace, not a private sandbox.
5
5
 
6
- ## Recognizing Parallel Work (PSA-001: Detect Before Acting)
7
- - **Unexpected git status changes:** Files modified or staged that are not part of your current task likely belong to another session.
8
- - **Unfamiliar commits:** New entries in `git log` that you did not create mean another agent (or the user manually) committed work.
9
- - **Spontaneous errors:** Build failures, type errors, or test failures in code you did not touch may be in-progress work from another session — not pre-existing bugs.
10
- - **Files changed between reads:** If a file's content differs from what you read moments ago, another session likely edited it.
11
- - **New untracked files:** Files appearing in `git status` that you did not create belong to someone else's work.
12
-
13
- ## Behavioral Guidance (PSA-002: Ask, Don't Assume)
14
- - **When you detect signs of parallel work, stop and ask the user:** "I notice changes I didn't make (e.g., modified files in git status, new commits). Is another session active?"
6
+ ## PSA Scope Axes — Operator-Session vs In-Run
7
+
8
+ PSA rules span two distinct axes. Naming them keeps clear which rule protects what:
9
+
10
+ - **Operator-session axis:** independent parallel operator / Claude sessions in the **same working copy**. PSA-001..004, plus the per-repo session lock, guard this domain. Native in-run multi-agent primitives cannot enter it — they are per-process / per-session, never per-repo.
11
+ - **In-run axis:** multiple agents coordinated inside a single session/run. Native agent-coordination features provide **no automatic isolation**: file-scope deconfliction (no two agents in the same wave may modify the same file) plus serialized STATE.md writes still do work the platform does not.
12
+
13
+ PSA-005 spans **both** axes; only its session-lock half is purely operator-scoped. PSA-006 is **orthogonal** to both (Discovery grep-discipline). PSA-007 is in-run only.
14
+
15
+ ## Decision Tree — What To Do When You Detect Parallel Signals
16
+
17
+ ```
18
+ Did I detect any parallel-session signal?
19
+
20
+ ├─ No → Continue normally.
21
+
22
+ └─ Yes → Does the signal originate from a SIBLING wave-agent dispatched in
23
+ THIS SAME wave (in-run axis — same dispatch round, the file sits
24
+ inside that sibling's declared file-scope per the wave plan) —
25
+ AND the file is NOT ALSO inside my own declared file-scope?
26
+
27
+ ├─ Yes → NOT a PSA-002 case. Confirm the sibling's file-scope
28
+ │ ownership against the wave plan, then continue working —
29
+ │ note it PSA-001-style, do not pause. (PSA-007 governs the
30
+ │ in-run git-write rule.)
31
+
32
+ └─ No → Does the signal touch files/scope I own in this task?
33
+
34
+ ├─ No → PSA-001 (Aware): note the signal, continue
35
+ │ working. Do NOT pause. Do NOT "fix" the foreign
36
+ │ change.
37
+
38
+ └─ Yes → PSA-002 (Pause): stop the current action, ask the
39
+ user before proceeding. This branch also catches a
40
+ file assigned to BOTH my scope AND a sibling's
41
+ scope per the wave plan (a wave-plan deconfliction
42
+ bug) — that overlap is a genuine in-run collision,
43
+ never a benign sibling signal, so the sibling
44
+ branch above may not mask it.
45
+ ```
46
+
47
+ **Scope overlap examples (triggers PSA-002):**
48
+ - A file you are about to edit is already modified by someone else.
49
+ - Staged changes in `git diff --cached` include files you did not touch.
50
+ - A build error appears in a file you just edited — but the error is in a line you didn't change.
51
+
52
+ **No-overlap examples (stay at PSA-001):**
53
+ - Unfamiliar commits in `git log` for modules you are not working on.
54
+ - New untracked files in directories outside your file scope.
55
+ - A test failure in a file not in your task's file-scope list.
56
+
57
+ ## PSA-001 — Aware (Passive Detection, No Pause)
58
+
59
+ Detect and note parallel-session signals without interrupting your work. Continue normally when the signal does not overlap your owned files.
60
+
61
+ **Signals to recognise:**
62
+ - **Unexpected git status changes:** files modified or staged that are not part of your current task likely belong to another session.
63
+ - **Unfamiliar commits:** new entries in `git log` that you did not create mean another agent (or the user manually) committed work.
64
+ - **Spontaneous errors:** build failures, type errors, or test failures in code you did not touch may be in-progress work from another session — not pre-existing bugs.
65
+ - **Files changed between reads:** if a file's content differs from what you read moments ago, another session likely edited it.
66
+ - **New untracked files:** files appearing in `git status` that you did not create belong to someone else's work.
67
+
68
+ **In-run caveat:** in a wave dispatched without per-agent isolation, unfamiliar modifications outside your own scope may simply belong to a sibling wave-agent's declared file-scope in the SAME dispatch round — disambiguate against the wave plan before logging it as a generic parallel-session signal (see PSA-007).
69
+
70
+ **PSA-001 behaviour:**
71
+ - Log the observation in your response narrative.
72
+ - Do NOT pause, do NOT ask the user, do NOT "fix" foreign changes.
73
+ - Continue with your assigned task in your own file scope.
74
+
75
+ ## PSA-002 — Pause (Active Conflict, Stop and Ask)
76
+
77
+ When a parallel-session signal **directly overlaps your owned scope**, stop the current action and ask the user before proceeding.
78
+
79
+ **Triggers (overlap = PSA-002):**
80
+ - A file in your task's file-scope list has unexpected modifications you did not make.
81
+ - `git diff --cached` includes staged changes you did not stage.
82
+ - A file you need to write or edit is locked in an in-progress state by another session.
83
+ - External changes block your task (e.g. a merge conflict in one of your files).
84
+
85
+ **PSA-002 behaviour:**
86
+ - Stop immediately — do not overwrite, merge, or work around the conflict.
87
+ - Ask the user: *"I notice changes I didn't make in [file(s)] that are in my task scope. Is another session active?"*
88
+ - Wait for user guidance before touching the affected file(s).
15
89
  - **Never "fix" code outside your task scope.** Errors in files you are not working on may be intentional intermediate states from another session.
16
- - **Stay in your lane.** Only read, create, modify, and delete files directly relevant to your assigned task.
17
90
  - **If blocked by external changes, ask the user** rather than reverting, resetting, or working around them.
18
91
  - **Track your own footprint.** Be aware of which files you have created or modified. Your commits should contain only your changes.
19
92
 
20
- ## Destructive Action Safeguards (PSA-003: Never Destroy What You Didn't Create)
93
+ ## PSA-003 — Destructive Action Safeguards (Never Destroy What You Didn't Create)
94
+
21
95
  These commands require explicit user confirmation even in normal operation. When parallel work is suspected, they are **forbidden** without user approval:
22
96
  - **`git reset` (any form)** — destroys staged or committed work that may belong to another session.
23
97
  - **`git checkout -- <file>`** — discards uncommitted changes another session is actively building.
@@ -29,15 +103,71 @@ These commands require explicit user confirmation even in normal operation. When
29
103
 
30
104
  Before running any of the above, ask: "Did I create this file/commit/change? If not, it is not mine to touch."
31
105
 
32
- ## Commit Discipline (PSA-004: Isolate Your Changes)
106
+ ## PSA-004 — Commit Discipline (Isolate Your Changes)
107
+
33
108
  - **Stage files individually** (`git add <file>`) rather than `git add .` or `git add -A`, which may sweep in another session's work.
34
109
  - **Review `git diff --cached` before committing** to verify every staged change is yours.
35
110
  - **If you see unfamiliar changes in the diff, unstage them** and ask the user.
36
111
  - **Never amend a commit you did not create.**
37
112
 
113
+ ## PSA-005 — Mechanical STATE.md Write Protection
114
+
115
+ The behavioural rules above are complemented by mechanical enforcement. When `state-md-lock.enabled: true` is set in Session Config, every STATE.md write is wrapped by the plugin's session-lock helper (`withStateMdLock(repoRoot, fn)`), which guards an `.orchestrator/state.lock` lockfile using atomic tmp-file + rename acquisition with liveness-based stale detection.
116
+
117
+ **What this mechanically enforces:**
118
+ - **PSA-003:** a concurrent writer cannot overwrite STATE.md while another writer holds the lock. The race is structurally impossible — not merely discouraged.
119
+ - **PSA-004:** STATE.md updates are serialised; no frontmatter update can be silently lost between two concurrent callers.
120
+
121
+ **Bypass mechanics:** lock timeout defaults to 10s (`state-md-lock.timeout-ms`). On a stale lock (holder no longer alive) → atomic override + WARN on stderr. On genuine contention timeout → the caller receives a failure result and must decide whether to retry or abort.
122
+
123
+ **When to use:** all STATE.md writers (session-start, inter-wave checkpoints, session-end), and any hook that mutates STATE.md.
124
+
125
+ **When NOT to use:** STATE.md *readers* — locking readers serialises them with no safety benefit. The session lock is a separate, orthogonal domain: the session lock means "this working copy is occupied by an active session"; the state lock means "STATE.md is being written right now".
126
+
127
+ ## PSA-006 — Discovery Grep-Verification
128
+
129
+ Discovery agents and exploration agents MUST verify any distributional claim — "100% of callers opt-in", "N of M sites use pattern X", "no remaining references to Y", "all instances replaced" — **and any bare number describing repo state** ("14 commits since the ref", "5 dirty files", "412 lines") with an EXECUTED measurement command: `grep`/`rg`/`find` for code locations, `git`/`wc`/`jq`/`ls`/`node` for repo state. The output MUST quote:
130
+
131
+ 1. The exact command executed.
132
+ 2. The file scope passed to the tool.
133
+ 3. The resulting count or zero-match assertion.
134
+ 4. WHEN it was measured — an ISO date, or the SHA / `HEAD` it was measured at. A fact re-used by a downstream wave hours later is a claim about the PAST unless it carries its measurement time.
135
+
136
+ Untestable adoption claims based on inference, partial sampling, or model recall are **forbidden**. Coordinators reviewing Discovery output MUST REJECT claims that lack a quoted measurement transcript and ask for re-verification — even when the claim is plausible. Verification cost is cheap; mid-session correction cost is expensive.
137
+
138
+ **When PSA-006 does NOT apply:**
139
+ - Inline single-file reads — the file read IS the verification.
140
+ - Claims about the behaviour of a SINGLE function — a focused test verifies, not a grep.
141
+ - Hypotheticals stated as such ("if all callers opted in, ..." is a question, not a claim).
142
+
143
+ **Mechanical enforcement:** when `discovery-validator.enabled: true` in Session Config, a `SubagentStop` hook scans the subagent's transcript tail for these claim patterns and records a violation event (plus a stderr WARN) whenever such a claim lacks an adjacent measurement transcript. The hook is log + warn only and never blocks the agent — it complements the rule rather than replacing the coordinator's REJECT obligation.
144
+
145
+ ## PSA-007 — Subagent Git-Write Prohibition
146
+
147
+ *In-run axis. Distinct from PSA-003/PSA-004, which govern the COORDINATOR's own destructive-op and commit discipline; PSA-007 governs what a DISPATCHED SUBAGENT may touch of the shared VCS state.*
148
+
149
+ The git index and stash are **shared resources of the working copy**, not a private workspace scoped to each dispatched agent. When a wave dispatches multiple subagents in parallel, a subagent that runs a git-write command competes with its siblings for the SAME `.git/index` and stash stack — observed failure modes include `index.lock` collisions and stash operations that silently discard sibling work-in-progress.
150
+
151
+ **Dispatched subagents MUST NEVER run:**
152
+ - `git add` / `git commit` — index writes race with a sibling agent's concurrent index write, even when each agent only stages its own files.
153
+ - `git stash` (any form) — captures (and can drop) a sibling agent's uncommitted work; the sibling has no way to find or recover it.
154
+ - `git mv` / `git rm` — index-mutating, same race class as `git add`.
155
+ - `git push` — no subagent has the authority to publish; also destructive at the remote-history layer.
156
+ - `git reset` / `git checkout -- <file>` — destructive to sibling work AND an index-write race; banned from subagents unconditionally, not only "when parallel work is suspected".
157
+
158
+ **The only write channel a subagent has is editing files inside its own declared file scope.** All VCS operations — staging, committing, pushing — belong to the coordinator. This makes the PSA-004 guarantee structural rather than behavioural at the subagent layer: an agent that never touches the index cannot violate PSA-004 by construction.
159
+
160
+ **Anti-patterns:**
161
+ - A subagent running `git add <its own files>` "to be helpful" before reporting done — even scoped to its own files, it races the coordinator's staging pass and any sibling's concurrent index write.
162
+ - A subagent running `git stash` to "save progress" before switching tasks — report `blocked` and let the coordinator decide, never stash.
163
+ - A subagent running `git commit --no-verify` "just this once to unblock the wave".
164
+
38
165
  ## Anti-Patterns
166
+
39
167
  - Seeing unfamiliar changes and assuming they are "leftover mess" to clean up — they are likely active work.
40
168
  - Running `git reset --hard` to "start fresh" — this destroys all uncommitted work across all sessions.
41
169
  - Fixing type errors or lint issues in files outside your scope — the other session will handle their own files.
42
170
  - Using `git add .` in a shared workspace — you will commit another session's partial work.
43
171
  - Reverting "broken" commits without asking — another session may have intentionally pushed incremental progress.
172
+ - Pausing at PSA-001 signals when your scope is unaffected — unnecessary interruptions slow the session.
173
+ - A subagent staging or committing its own work (PSA-007).
@@ -0,0 +1,108 @@
1
+ <!-- source: session-orchestrator plugin (canonical: rules/always-on/receiving-review.md) -->
2
+ # Receiving Code Review (Always-on)
3
+
4
+ How the coordinator — and any agent receiving review output — handles feedback, and what a reviewer owes in return. The default failure mode is performative agreement: accepting before verifying, then half-implementing a wrong suggestion.
5
+
6
+ ## RCR-001: The 6-Step Pattern
7
+
8
+ When you receive review output containing feedback items, process them in this order. Do NOT skip steps.
9
+
10
+ 1. **READ** — every item, in full, never just the summary. Reviewers nest the actionable detail below the headline.
11
+ 2. **UNDERSTAND** — restate each item in your own words. Cannot restate it precisely? Re-read the code the reviewer cited.
12
+ 3. **VERIFY** — check the claim against the codebase: is the cited file still shaped that way, the function still on that line? Reviewers can be wrong, especially after recent edits.
13
+ 4. **EVALUATE** — improvement, stylistic preference, or misunderstanding? Project conventions (the rules directory, the project instruction file) are the tiebreaker.
14
+ 5. **RESPOND** — per item: accept, modify, or push back, each with its rationale. Never accept silently — the rationale is the audit trail.
15
+ 6. **IMPLEMENT** — one item at a time, running the verification command after each (`verification-before-completion.md`).
16
+
17
+ ## RCR-002: Forbidden Phrases
18
+
19
+ Signals that you skipped steps 2-4. Forbidden in any response to review feedback:
20
+
21
+ - "You're absolutely right!"
22
+ - "Great point!"
23
+ - "Excellent feedback!"
24
+ - "Let me implement that now" (before VERIFY + EVALUATE)
25
+ - "Thanks for catching that!" / "Thanks for [anything]" — gratitude standing in for analysis, before verifying it is a catch
26
+
27
+ Replace these with: a restatement (UNDERSTAND), a verification reference (VERIFY), and a decision (EVALUATE).
28
+
29
+ ## RCR-003: Source-Specific Handling
30
+
31
+ | Source | Default posture | Why |
32
+ |---|---|---|
33
+ | **Human user (the operator)** | Trust-after-understanding — restate, verify, then implement | Operator usually has context you do not |
34
+ | **Automated reviewer agents** (architect, QA, analyst personas) | Skeptical — verify against codebase before accepting | Agent output can lag behind the most recent edits |
35
+ | **Security reviewer** | Take seriously, verify scope | Security findings have asymmetric cost — false positives are cheaper than false negatives |
36
+ | **Automated quality gates** | Mechanical — typecheck/lint failures are facts, fix them | Automated tool output is rarely wrong, often surprising |
37
+ | **External code review (PR comments)** | Skeptical, push back if wrong | External reviewers lack project context |
38
+
39
+ The default posture is **skeptical** unless explicitly overridden — falsely accepting a wrong suggestion costs as much as implementing a bad feature.
40
+
41
+ ## RCR-004: YAGNI Check (Especially for "Implement Properly")
42
+
43
+ When a reviewer suggests "implement X properly" / "add validation for this case" / "make this configurable":
44
+
45
+ 1. **Grep for usage**: is the code path the reviewer cites actually called in production? `git grep <function-name>` + `git log -p -- <file>`
46
+ 2. **Check the call site**: does the caller actually pass the inputs the reviewer's hypothetical case would trigger?
47
+ 3. **If unused**: suggest REMOVAL (the dead code is the real problem) instead of "implementing properly"
48
+ 4. **If used but the case is impossible at the call site**: push back with the call-site analysis
49
+
50
+ ## RCR-005: Implementation Order
51
+
52
+ Multi-item review responses follow this order:
53
+
54
+ 1. **Clarify first** — items that reference each other ("fix X AND consider Y"): ASK before partial-implementing. Partial implementations of related items create incoherent intermediate states.
55
+ 2. **Blocking items** — anything stopping the work (a type error your edit introduced) goes first.
56
+ 3. **Simple items** — no dependencies; batch them.
57
+ 4. **Complex items** — needs its own design discussion; surface as a question first.
58
+
59
+ Verify after each step before moving on (RCR-001.6).
60
+
61
+ ## RCR-006: Push-Back Posture
62
+
63
+ You are allowed — and expected — to push back on review feedback that is wrong.
64
+
65
+ Cite one of three: the codebase ("the function at file:line already handles this — the check would duplicate"), the convention ("per the project rule the pattern is Y, not Z"), or the trade-off ("surface area without a prevented failure mode").
66
+
67
+ Push-back is a feature, not a bug: an implementer who never pushes back implements every wrong suggestion.
68
+
69
+ ## RCR-007: Four-Class Finding Triage
70
+
71
+ Classify every finding into **exactly one** class before patching:
72
+
73
+ | Class | Meaning | Action |
74
+ |---|---|---|
75
+ | **`in-scope-blocker`** | Introduced by this diff, same owner boundary, fixable without changing the task's contract | Fix this cycle |
76
+ | **`same-pattern-sweep`** | The identical defect recurs at further sites, all inside your own file scope, none needing a contract change | Fix every site this cycle |
77
+ | **`follow-up`** | Real, but an adjacent bug class or sibling surface | Route to a follow-up issue |
78
+ | **`stop-and-escalate`** | The correct fix would break the frozen scope | Never patch, however small — escalate |
79
+
80
+ `same-pattern-sweep` needs all four, else the finding is `follow-up`: identical pattern (one edit shape fixes every site, not merely a related bug class); every site inside your file scope; none whose fix changes a contract (that site is `stop-and-escalate` and ends the sweep); population ENUMERATED by a quoted census of CALL SITES — not files, and not a payload-keyed grep, which misses consumers pinning only the channel (`parallel-sessions.md` § PSA-006). Cannot enumerate it → a suspicion, not a sweep; out-of-scope sites go to `follow-up` with the census.
81
+
82
+ `stop-and-escalate` triggers — exactly these five, nothing else: (1) a new protocol, (2) a new config surface, (3) a storage change, (4) a public-API contract, (5) a different owner boundary or a release-process change.
83
+
84
+ Frozen-scope exceptions — exactly these five, nothing else: (1) active data loss, (2) crash, (3) broken install/upgrade, (4) release blocker, (5) concrete security exposure.
85
+
86
+ Before invoking `stop-and-escalate`: name which of the five applies, show that no in-scope-blocker subset resolves the finding without crossing it, and hand the operator both — escalating IS the action, never a workaround commit.
87
+
88
+ ## RCR-008: Two-Cycle Reclassify
89
+
90
+ After two fix cycles without a **strict decrease** in blocking findings: pause, reclassify every remaining finding. A third cycle starts only if every finding is still `in-scope-blocker`; otherwise move the smallest safely-landable subset forward and the rest to `follow-up`.
91
+
92
+ **Landing-lane hygiene**: no stacked, no pushed fix commits while a classification or a focused proof is open. Edits stay local until the cycle is proven in-scope.
93
+
94
+ A retry cap **stops** on budget; RCR-008 forces **reclassification**. They are different instruments — do not substitute one for the other.
95
+
96
+ ## RCR-009: Depth, and the Reviewer's Authority
97
+
98
+ A review that only confirms has not reviewed: report the surfaces examined and found SOUND and the suspicions MEASURED AWAY, not findings alone — otherwise the next pass re-opens the same file to learn what you already know. And a reviewer MAY REFUSE an instruction it can REFUTE, provided the refusal carries the measurement and never a preference (the reverse of RCR-006; complying against a measurement you already hold is the costlier error). Self-review is a precondition of handoff, never a substitute — nor is a green gate.
99
+
100
+ ## Anti-Patterns
101
+
102
+ - Accepting before VERIFY — gratitude, "great point", or a reviewer claim taken as fact without grep-verification (RCR-001/002)
103
+ - A review that returns findings only, or an agent that complies with an instruction it can measurably refute (RCR-009)
104
+ - One site fixed with its enumerated siblings left standing (RCR-007)
105
+
106
+ ## See Also
107
+
108
+ verification-before-completion.md · ask-via-tool.md · parallel-sessions.md · test-value.md · build-value.md
@@ -0,0 +1,40 @@
1
+ <!-- source: session-orchestrator plugin (canonical: rules/always-on/test-value.md) -->
2
+ # Test Value Over Test Volume (Always-on)
3
+
4
+ A test earns its place by catching a bug the existing suite would miss. Volume is a cost, not an achievement. This rule is always-on because the "write this test / don't" decision is made in implementation work, where path-scoped testing rules are not loaded.
5
+
6
+ ## TV-001: The Core Question (before writing any test)
7
+
8
+ Name the concrete bug this test would catch that the existing suite does not. If you cannot name it, do NOT write the test — report `no-tests-needed: <reason>` instead. That report is a SUCCESS outcome, not a gap.
9
+
10
+ ## TV-002: Deletion Is a Feature
11
+
12
+ A test MAY be deleted or consolidated without approval ceremony when it (a) fails TV-001's falsification check, (b) duplicates behaviour another test already covers, or (c) pins the prose or structure of documentation (`.md` content assertions). Count removals in your reported test delta — a negative test delta is a valid, reportable result.
13
+
14
+ ## TV-003: Budget Corridor (advisory)
15
+
16
+ Target a tests:src LOC ratio of ≤ 1.60. Above that ceiling, the next quality pass is a CONSOLIDATION pass: no new test lands without removing a redundant one. The corridor bounds test VOLUME only — the project's coverage floor is unchanged and still binds.
17
+
18
+ **Measure the ratio with a script, never by hand.** While the recipe lived only in prose, six numbers for the one metric were in simultaneous circulation, differing only in which files each measurer chose to count. A threshold steered by six numbers is steered blind. Pin the recipe in code and cite its output: **numerator = tracked code under the test directory; denominator = every other tracked code file** (src by negation, so a new top-level directory is counted the moment it is committed), counting physical lines including blanks and comments. The number is reproducible at a SHA only when the working tree is clean.
19
+
20
+ The ceiling is derived from measurement, not aspiration. An unreachable ceiling only manufactures standing deletion pressure with no nameable target per file — the precise thing TV-001 and TV-002 forbid. The consolidation rule above is the operative instrument; the ratio is merely the trigger that switches it on.
21
+
22
+ **Corridor, not ratchet — deliberately.** A bidirectional ratchet (baseline the current value; fail the build on any worsening AND on any un-banked improvement) fails three ways: (a) the un-banked-improvement half turns deleting worthless tests — which TV-002 calls a *feature* — into a build break; (b) the worsening half forces a compensating deletion with no nameable target per file the moment a legitimate new test lands; and (c) a ratchet on a *ratio* is satisfiable by adding production LOC, an incentive that catches no bug. What this rule needs is a trustworthy number, not a tripwire — so the ratio check reports the consolidation trigger and is not wired into a blocking gate.
23
+
24
+ ## TV-004: Duplication Check Before Writing
25
+
26
+ Grep for an existing test of the same behaviour first. Extend or parametrize that test instead of adding a sibling case or a near-duplicate file.
27
+
28
+ ## TV-005: Where Bugs Are Actually Caught
29
+
30
+ Measured across a multi-repo fleet: of 27 escaped bugs, 0 were caught by the unit-test corpus and 9 by a review panel. Prefer, in this order: wiring/contract tests exercising the real production call shape; golden fixtures derived from real production records; lint/AST gates for structural invariants, which hold repo-wide where a test holds for one case. Unit-test volume is the last resort, not the first.
31
+
32
+ ## Anti-Patterns
33
+
34
+ - Writing a test because the task said "add tests", with no nameable bug (TV-001).
35
+ - Asserting that a sentence is present in a `.md` file — that pins prose, not behaviour (TV-002c).
36
+ - Treating a coverage drop caused by DELETING worthless tests as a regression (TV-003).
37
+
38
+ ## See Also
39
+
40
+ build-value.md · verification-before-completion.md · receiving-review.md · npm-quality-gates.md
@@ -0,0 +1,77 @@
1
+ <!-- source: session-orchestrator plugin (canonical: rules/always-on/verification-before-completion.md) -->
2
+ # Verification Before Completion (Always-on)
3
+
4
+ Evidence before assertions. If you have not run the verification command in this message, you cannot claim it passes. This rule exists because the most expensive failure class in a long-lived repo is the silent regression that ships behind a "should work" claim.
5
+
6
+ ## The Iron Law
7
+
8
+ > **NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE.**
9
+
10
+ "Fresh" means: in the current message thread, within the last few tool calls, against the current working tree. A test result from 5 minutes ago no longer counts if you have written code since. A type check from before the last edit no longer counts.
11
+
12
+ ## VBC-001: The Gate Function
13
+
14
+ Before any claim of completion ("done", "passes", "green", "complete", "fixed"), run this gate:
15
+
16
+ 1. **IDENTIFY** — name the specific command that verifies the claim (the project's test / typecheck / lint command, `gh pr checks`, `glab ci status`, `curl <url>`, …)
17
+ 2. **RUN** — execute the command completely. Do not extrapolate from partial output. Do not skip flags ("the long version is slow" is not an exception).
18
+ 3. **READ** — read the FULL output (not just the last 5 lines) and check the exit code. Many test runners report "PASS" lines for individual cases while exiting non-zero overall.
19
+ 4. **VERIFY** — confirm the output actually demonstrates the claim. "312 passed" verifies "tests pass". "312 passed / 7 failed" does NOT verify "tests pass" even though the first number is impressive.
20
+ 5. **STATE** — make the claim, quoting the evidence: "Tests pass: 312 passed / 0 failed / 12 skipped (exit 0)" — never "Tests pass" alone.
21
+
22
+ ## VBC-002: Banned Phrases
23
+
24
+ The following phrases are forbidden when used to characterize completion without fresh evidence. They are signals that the Gate Function was skipped.
25
+
26
+ - "should work now" / "should pass" / "should be fine"
27
+ - "I'm confident" / "I believe" / "I'm pretty sure"
28
+ - "looks correct" / "looks right" / "looks good"
29
+ - "Great!" / "Perfect!" / "Done!" / "Excellent!"
30
+ - "Just this once" / "I'll verify later"
31
+ - "Agent said success" — the agent's word is not evidence; the verification command is
32
+
33
+ If you catch yourself typing one of these without the verification evidence in the SAME message, stop. Run the command first, then state the claim with the evidence inline.
34
+
35
+ ## VBC-003: Common Failures Table
36
+
37
+ | Claim type | Required verification | Common shortcut to avoid |
38
+ |---|---|---|
39
+ | "Tests pass" | The project's test command exits 0 + per-file count | "I ran one file" |
40
+ | "TypeScript clean" | `tsgo --noEmit` / `tsc --noEmit` exit 0 | "The file I edited compiled" |
41
+ | "Lint clean" | The project's lint command exits 0 | "The editor extension shows no errors" |
42
+ | "CI green" | `glab ci status` / `gh pr checks` on the current SHA | "Last pipeline was green" (last week) |
43
+ | "Migration applies" | A reset against a clean database succeeds | "It worked on my dev DB" |
44
+ | "Endpoint works" | `curl <url>` returns expected status + body | "The browser showed it" |
45
+ | "Hook fires" | Trigger the hook event + read the resulting log line | "The hook config looks right" |
46
+ | "Issue closed" | `gh issue view <N>` / `glab issue view <N>` shows state=closed | "I commented `closes #N`" |
47
+ | "Subagent edit persisted" | `git diff --stat` / `--name-only` shows the declared file(s) changed after the agent reported done | "The agent reported done" |
48
+
49
+ ## VBC-004: Exceptions (Narrow)
50
+
51
+ These are the only acceptable contexts in which a verification command may be deferred:
52
+
53
+ 1. **Read-only exploration**: claims about CODE STATE (not behavior) can cite a file read instead of a command run. "The function is at file:line" verifies via a read, not via test execution.
54
+ 2. **Coordinator orchestration**: claims about SUBAGENT outputs (not your own work) cite the agent's reported status — but the coordinator accepts that status only paired with its OWN `git diff --name-only` evidence that the agent's declared files actually changed. An agent's word is a claim, not proof of a filesystem effect. The agent itself must have followed VBC-001 — the coordinator's claim is "agent reported done with evidence X, confirmed changed in `git diff --name-only`", not "the work is done" on the status alone.
55
+ 3. **Documentation-only changes**: changes to `*.md` files that affect no code paths can skip test runs. They still require typecheck/lint if those tools touch markdown.
56
+
57
+ If you think you have a fourth exception, you do not. Run the command.
58
+
59
+ ## VBC-005: Why This Is Strict
60
+
61
+ - The most expensive failures are the ones a claim covers up.
62
+ - "Should pass" claims are not falsifiable — they invite no challenge and produce no learning. Evidence-anchored claims either pass or surface a real problem; both outcomes have value.
63
+ - Verification commands are cheap. Investigating a regression days after the fact is expensive. The cost ratio is at least 10:1, often 100:1.
64
+ - Treat this rule with the same enforcement weight as the ask-via-tool and destructive-action safeguards: the default is the command, and skipping it requires an explicit named exception above.
65
+
66
+ ## Anti-Patterns
67
+
68
+ - Claiming "tests pass" without running the test command in the current message
69
+ - Citing a test run from before the last edit
70
+ - Quoting only the success count when failures exist ("312 passed" suppressing "/ 7 failed")
71
+ - Saying "should work now" instead of running the verification
72
+ - Treating an agent's reported "done" as evidence (it's a claim that needs its own verification)
73
+ - Skipping verification because "the change is trivial"
74
+
75
+ ## See Also
76
+
77
+ npm-quality-gates.md · ask-via-tool.md · parallel-sessions.md · receiving-review.md · test-value.md · build-value.md