cleargate 0.10.0 → 0.11.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 (72) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +11 -1
  3. package/dist/MANIFEST.json +40 -26
  4. package/dist/chunk-HZPJ5QX4.js +459 -0
  5. package/dist/chunk-HZPJ5QX4.js.map +1 -0
  6. package/dist/cli.cjs +419 -202
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/cli.js +387 -513
  9. package/dist/cli.js.map +1 -1
  10. package/dist/lib/lifecycle-reconcile.cjs +497 -0
  11. package/dist/lib/lifecycle-reconcile.cjs.map +1 -0
  12. package/dist/lib/lifecycle-reconcile.d.cts +136 -0
  13. package/dist/lib/lifecycle-reconcile.d.ts +136 -0
  14. package/dist/lib/lifecycle-reconcile.js +20 -0
  15. package/dist/lib/lifecycle-reconcile.js.map +1 -0
  16. package/dist/templates/cleargate-planning/.claude/agents/architect.md +55 -2
  17. package/dist/templates/cleargate-planning/.claude/agents/developer.md +22 -0
  18. package/dist/templates/cleargate-planning/.claude/agents/devops.md +249 -0
  19. package/dist/templates/cleargate-planning/.claude/agents/qa.md +41 -0
  20. package/dist/templates/cleargate-planning/.claude/agents/reporter.md +44 -8
  21. package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +21 -0
  22. package/dist/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +12 -1
  23. package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +21 -1
  24. package/dist/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +200 -29
  25. package/dist/templates/cleargate-planning/.cleargate/knowledge/mid-sprint-triage-rubric.md +160 -0
  26. package/dist/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +41 -9
  27. package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +98 -16
  28. package/dist/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +3 -3
  29. package/dist/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +86 -10
  30. package/dist/templates/cleargate-planning/.cleargate/scripts/run_script.sh +173 -87
  31. package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +150 -22
  32. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +20 -20
  33. package/dist/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +32 -8
  34. package/dist/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +12 -1
  35. package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +3 -0
  36. package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +3 -0
  37. package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +3 -0
  38. package/dist/templates/cleargate-planning/.cleargate/templates/hotfix.md +3 -0
  39. package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +1 -1
  40. package/dist/templates/cleargate-planning/.cleargate/templates/sprint_context.md +8 -0
  41. package/dist/templates/cleargate-planning/.cleargate/templates/story.md +3 -0
  42. package/dist/templates/cleargate-planning/CLAUDE.md +3 -1
  43. package/dist/templates/cleargate-planning/MANIFEST.json +40 -26
  44. package/package.json +8 -5
  45. package/templates/cleargate-planning/.claude/agents/architect.md +55 -2
  46. package/templates/cleargate-planning/.claude/agents/developer.md +22 -0
  47. package/templates/cleargate-planning/.claude/agents/devops.md +249 -0
  48. package/templates/cleargate-planning/.claude/agents/qa.md +41 -0
  49. package/templates/cleargate-planning/.claude/agents/reporter.md +44 -8
  50. package/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +21 -0
  51. package/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +12 -1
  52. package/templates/cleargate-planning/.claude/hooks/token-ledger.sh +21 -1
  53. package/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +200 -29
  54. package/templates/cleargate-planning/.cleargate/knowledge/mid-sprint-triage-rubric.md +160 -0
  55. package/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +41 -9
  56. package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +98 -16
  57. package/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +3 -3
  58. package/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +86 -10
  59. package/templates/cleargate-planning/.cleargate/scripts/run_script.sh +173 -87
  60. package/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +150 -22
  61. package/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +20 -20
  62. package/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +32 -8
  63. package/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +12 -1
  64. package/templates/cleargate-planning/.cleargate/templates/Bug.md +3 -0
  65. package/templates/cleargate-planning/.cleargate/templates/CR.md +3 -0
  66. package/templates/cleargate-planning/.cleargate/templates/epic.md +3 -0
  67. package/templates/cleargate-planning/.cleargate/templates/hotfix.md +3 -0
  68. package/templates/cleargate-planning/.cleargate/templates/initiative.md +1 -1
  69. package/templates/cleargate-planning/.cleargate/templates/sprint_context.md +8 -0
  70. package/templates/cleargate-planning/.cleargate/templates/story.md +3 -0
  71. package/templates/cleargate-planning/CLAUDE.md +3 -1
  72. package/templates/cleargate-planning/MANIFEST.json +40 -26
@@ -19,11 +19,12 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
19
  const REPO_ROOT = path.resolve(__dirname, '..', '..');
20
20
 
21
21
  /**
22
- * Validate a parsed state object.
22
+ * Validate a parsed state object, ignoring schema_version check.
23
+ * Used PRE-MIGRATION so that v1 files pass shape validation before being upgraded.
23
24
  * @param {object} state - Parsed state.json content
24
25
  * @returns {{ valid: boolean, errors: string[] }}
25
26
  */
26
- export function validateState(state) {
27
+ export function validateShapeIgnoringVersion(state) {
27
28
  const errors = [];
28
29
 
29
30
  if (typeof state !== 'object' || state === null) {
@@ -31,12 +32,6 @@ export function validateState(state) {
31
32
  return { valid: false, errors };
32
33
  }
33
34
 
34
- if (state.schema_version !== SCHEMA_VERSION) {
35
- errors.push(
36
- `schema_version mismatch: expected ${SCHEMA_VERSION}, got ${state.schema_version}`
37
- );
38
- }
39
-
40
35
  if (!state.sprint_id) {
41
36
  errors.push('missing required field: sprint_id');
42
37
  }
@@ -98,6 +93,35 @@ export function validateState(state) {
98
93
  return { valid: errors.length === 0, errors };
99
94
  }
100
95
 
96
+ /**
97
+ * Validate a parsed state object (strict — includes schema_version check).
98
+ * Call this AFTER migration to assert the file is fully v2-compliant.
99
+ * @param {object} state - Parsed state.json content
100
+ * @returns {{ valid: boolean, errors: string[] }}
101
+ */
102
+ export function validateState(state) {
103
+ const errors = [];
104
+
105
+ if (typeof state !== 'object' || state === null) {
106
+ errors.push('state is not an object');
107
+ return { valid: false, errors };
108
+ }
109
+
110
+ if (state.schema_version !== SCHEMA_VERSION) {
111
+ errors.push(
112
+ `schema_version mismatch: expected ${SCHEMA_VERSION}, got ${state.schema_version}`
113
+ );
114
+ }
115
+
116
+ // Delegate shape validation (everything except version check)
117
+ const shapeResult = validateShapeIgnoringVersion(state);
118
+ for (const e of shapeResult.errors) {
119
+ errors.push(e);
120
+ }
121
+
122
+ return { valid: errors.length === 0, errors };
123
+ }
124
+
101
125
  // CLI mode
102
126
  if (process.argv[1] === fileURLToPath(import.meta.url)) {
103
127
  const args = process.argv.slice(2);
@@ -17,7 +17,7 @@
17
17
  #
18
18
  # Args:
19
19
  # $1 work_item_id — e.g. STORY-020-02, CR-016, BUG-021
20
- # $2 agent_type — one of: developer|architect|qa|reporter|cleargate-wiki-contradict
20
+ # $2 agent_type — one of: developer|architect|qa|reporter|devops|cleargate-wiki-contradict
21
21
  #
22
22
  # Env (optional):
23
23
  # CLAUDE_SESSION_ID — session UUID of the orchestrator session
@@ -49,6 +49,17 @@ fi
49
49
  WORK_ITEM_ID="${1}"
50
50
  AGENT_TYPE="${2}"
51
51
 
52
+ # ─── Validate agent_type ────────────────────────────────────────────────────
53
+ case "${AGENT_TYPE}" in
54
+ developer|architect|qa|reporter|devops|cleargate-wiki-contradict)
55
+ ;;
56
+ *)
57
+ printf '[%s] error: invalid agent_type: %s\n' "$(date -u +%FT%TZ)" "${AGENT_TYPE}" >> "${LOG}"
58
+ printf 'error: invalid agent_type: %s (expected developer|architect|qa|reporter|devops|cleargate-wiki-contradict)\n' "${AGENT_TYPE}" >&2
59
+ exit 3
60
+ ;;
61
+ esac
62
+
52
63
  # ─── Resolve active sprint ──────────────────────────────────────────────────
53
64
  ACTIVE_SENTINEL="${REPO_ROOT}/.cleargate/sprint-runs/.active"
54
65
  if [[ ! -f "${ACTIVE_SENTINEL}" ]]; then
@@ -12,6 +12,7 @@ POST-WRITE BRIEF
12
12
  After Writing this document, render a Brief in chat with the following sections,
13
13
  mechanically extracted from the document's own structure:
14
14
 
15
+ - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
15
16
  - Summary ← §1 The Anomaly (repro)
16
17
  - Open Questions ← §0.5 Open Questions
17
18
  - Edge Cases ← §2 Impact (edge conditions)
@@ -106,6 +107,8 @@ last_synced_body_sha: null # sha256 of body at last sync
106
107
  ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
107
108
  **Current Status: 🔴 High Ambiguity**
108
109
 
110
+ *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
111
+
109
112
  Requirements to pass to Green (Ready for Fix):
110
113
  - [ ] Reproduction steps are 100% deterministic.
111
114
  - [ ] Actual vs. Expected behavior is explicitly defined.
@@ -12,6 +12,7 @@ POST-WRITE BRIEF
12
12
  After Writing this document, render a Brief in chat with the following sections,
13
13
  mechanically extracted from the document's own structure:
14
14
 
15
+ - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
15
16
  - Summary ← §1 The Context Override
16
17
  - Open Questions ← §0.5 Open Questions
17
18
  - Edge Cases ← §2 Blast Radius & Invalidation
@@ -108,6 +109,8 @@ last_synced_body_sha: null # sha256 of body at last sync
108
109
  ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
109
110
  **Current Status: 🔴 High Ambiguity**
110
111
 
112
+ *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
113
+
111
114
  Requirements to pass to Green (Ready for Execution):
112
115
  - [ ] "Obsolete Logic" to be evicted is explicitly declared.
113
116
  - [ ] All impacted downstream Epics/Stories are identified and reverted to 🔴 High Ambiguity.
@@ -16,6 +16,7 @@ POST-WRITE BRIEF
16
16
  After Writing this document, render a Brief in chat with the following sections,
17
17
  mechanically extracted from the document's own structure:
18
18
 
19
+ - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
19
20
  - Summary ← §1 Problem & Value
20
21
  - Open Questions ← §6 AI Interrogation Loop
21
22
  - Edge Cases ← §2 OUT-OF-SCOPE list + §5 error scenarios
@@ -153,6 +154,8 @@ Feature: {Epic Name}
153
154
  ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
154
155
  **Current Status: 🔴 High Ambiguity**
155
156
 
157
+ *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
158
+
156
159
  Requirements to pass to Green (Ready for Coding Agent):
157
160
  - [ ] Proposal document has `approved: true`.
158
161
  - [ ] The `<agent_context>` block is complete and validated.
@@ -14,6 +14,7 @@ POST-WRITE BRIEF
14
14
  After Writing this document, render a Brief in chat with the following sections,
15
15
  mechanically extracted from the document's own structure:
16
16
 
17
+ - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
17
18
  - Summary ← §1 Anomaly (Problem)
18
19
  - Open Questions ← §0.5 Open Questions
19
20
  - Edge Cases ← §3 Files Affected (risk of adjacent regression)
@@ -101,6 +102,8 @@ If the hotfix introduces a regression, revert by running `git revert <commit-sha
101
102
  ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
102
103
  **Current Status: 🔴 High Ambiguity**
103
104
 
105
+ *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
106
+
104
107
  Requirements to pass to Green (Ready for Merge):
105
108
  - [ ] Anomaly is deterministically reproducible (§1 filled).
106
109
  - [ ] Files Touched list is ≤2 files (§2 filled).
@@ -26,7 +26,7 @@ DO NOT output these instructions in the rendered file.
26
26
  </instructions>
27
27
 
28
28
  ---
29
- initiative_id: "INIT-{NNN}"
29
+ initiative_id: "INITIATIVE-{NNN}"
30
30
  remote_id: null
31
31
  source_tool: "linear | jira | github | manual-paste"
32
32
  status: "{PM native status — e.g. Discovery, In Triage, Triaged}"
@@ -8,6 +8,10 @@ last_updated: "YYYY-MM-DDTHH:MM:SSZ"
8
8
 
9
9
  Per-sprint audit artefact. Populated at sprint init (M1 planning) and re-touched after each story merges. Referenced from every Developer/QA/Architect task brief so all agents start from the same baseline.
10
10
 
11
+ ## Sprint Goal
12
+
13
+ _(populated by orchestrator from sprint plan §0 at kickoff)_
14
+
11
15
  ## Locked Versions
12
16
 
13
17
  Frozen dependency versions for this sprint. Orchestrator populates from `package.json` snapshots at sprint init; Developers must not upgrade these mid-sprint without an explicit CR.
@@ -40,3 +44,7 @@ Exported helpers and modules from already-merged stories in this sprint. The Arc
40
44
  | Story | Module / Export | Path |
41
45
  |-------|----------------|------|
42
46
  | (populated as stories merge) | | |
47
+
48
+ ## Mid-Sprint Amendments
49
+
50
+ _(populated by Architect on CR:scope-change or CR:approach-change; never rewrite, only append. Format: '<ISO-ts> · <ID> · <one-line note>')_
@@ -40,6 +40,7 @@ POST-WRITE BRIEF
40
40
  After Writing this document, render a Brief in chat with the following sections,
41
41
  mechanically extracted from the document's own structure:
42
42
 
43
+ - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
43
44
  - Summary ← §1.1 User Story
44
45
  - Open Questions ← §1.4 Open Questions
45
46
  - Edge Cases ← §2.1 Gherkin error scenarios
@@ -199,6 +200,8 @@ Feature: {Story Name}
199
200
  ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
200
201
  **Current Status: 🔴 High Ambiguity**
201
202
 
203
+ *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
204
+
202
205
  Requirements to pass to Green (Ready for Execution):
203
206
  - [ ] Gherkin scenarios completely cover all detailed requirements in §1.2.
204
207
  - [ ] Implementation Guide (§3) maps to specific, verified file paths from the approved proposal.
@@ -23,12 +23,14 @@ This repository uses **ClearGate** — a standalone planning framework for AI co
23
23
 
24
24
  **Codebase is source of truth.** Wiki, memory, and `context_source` are derived caches. On conflict between cache and code, the code wins; the cache rebuilds. Before stating that a capability exists or doesn't exist, grep the code.
25
25
 
26
- **Duplicate check before drafting.** Before drafting an Initiative or work item, grep `.cleargate/delivery/archive/` + `.cleargate/FLASHCARD.md` for similar past work. If you find overlap, surface it as a one-liner (*"This is very close to STORY-003-05 shipped in SPRINT-01 are you extending it or redoing it?"*) instead of drafting a duplicate. If the request names an integration, feature, or capability, also grep the source tree for existing implementations and cite findings in `## Existing Surfaces`.
26
+ **Duplicate check before drafting.** Before Writing any new file under `.cleargate/delivery/pending-sync/`, dispatch the `cleargate-wiki-query` subagent with the request topic. Record the result (`[[IDs]]` of related prior work, or `none found`) on a `Prior work:` line in the Brief — this is auditable evidence the check ran. Then grep `.cleargate/delivery/archive/` + `.cleargate/FLASHCARD.md` for residual hits the wiki may have missed (raw items not yet ingested). If the request names an integration, feature, or capability, also grep the source tree for existing implementations and cite findings in `## Existing Surfaces`. If you find overlap, surface it as a one-liner (*"This is very close to STORY-003-05 shipped in SPRINT-01 — are you extending it or redoing it?"*) before drafting.
27
27
 
28
28
  **Halt at gates.** You halt at Gate 1 (Initiative approval) and Gate 2 (Ambiguity resolution) and wait for explicit human sign-off. You never call `cleargate_push_item` without `approved: true` (hard reject) and explicit human confirmation. Readiness gates (`cached_gate_result.pass`) are advisory by default — the push proceeds and the item body receives an `[advisory: gate_failed — <criteria>]` prefix; opt into hard-reject via `STRICT_PUSH_GATES=true` on the MCP server.
29
29
 
30
30
  **Sprint mode.** Read `execution_mode:` in the active sprint's frontmatter before spawning Developer/QA. `v1` = advisory; `v2` = enforce the rules in `cleargate-enforcement.md`. Default `v1`.
31
31
 
32
+ **Ambiguity Gate criteria are evaluated literally.** Each `[ ]` box in a work-item's Ambiguity Gate footer must be evaluated against the literal criterion text, not against your interpretation of its intent. If a criterion is not met but you believe the human's intent is satisfied, leave the box unchecked, say so explicitly in the Brief, and ask. Do not substitute "in spirit" satisfaction for literal satisfaction. The gate exists specifically to catch the case where you are about to declare 🟢 by interpretive leap.
33
+
32
34
  **Brief is the universal pre-push handshake.** Every work-item template's `<instructions>` block tells you to render a Brief in chat after Writing the document — Summary / Open Questions / Edge Cases / Risks / Ambiguity. Halt for human review. When ambiguity reaches 🟢, push via `cleargate_push_item` automatically — the same approval covers Gate 1 and the push.
33
35
 
34
36
  **Boundary gates (CR-017).** `cleargate sprint init` runs the decomposition gate; `close_sprint.mjs` runs the lifecycle reconciler. Both block in v2.
@@ -1,10 +1,10 @@
1
1
  {
2
- "cleargate_version": "0.10.0",
3
- "generated_at": "2026-05-02T19:21:41.996Z",
2
+ "cleargate_version": "0.11.0",
3
+ "generated_at": "2026-05-04T21:55:12.920Z",
4
4
  "files": [
5
5
  {
6
6
  "path": ".claude/agents/architect.md",
7
- "sha256": "5aa58a549f74ecc73be1630428ef1903faae5c3779b7b5371307c5cb63621026",
7
+ "sha256": "a2d11d6a7f21bce22730ba9076af9ddde44b258082e33aa99fcd57c14ad75f55",
8
8
  "tier": "agent",
9
9
  "overwrite_policy": "always",
10
10
  "preserve_on_uninstall": false
@@ -39,21 +39,28 @@
39
39
  },
40
40
  {
41
41
  "path": ".claude/agents/developer.md",
42
- "sha256": "55790014320187e500f6b904756bbc8bda4806274805e883d62492bf75a34f12",
42
+ "sha256": "36f75fe9f8dc8412eb22706dfd021f5db5694c81d73e0c938e701a83c0149126",
43
+ "tier": "agent",
44
+ "overwrite_policy": "always",
45
+ "preserve_on_uninstall": false
46
+ },
47
+ {
48
+ "path": ".claude/agents/devops.md",
49
+ "sha256": "65e84275b7a6480be2144250cc00573e8c26840abed98768ce4c168d594c7f8e",
43
50
  "tier": "agent",
44
51
  "overwrite_policy": "always",
45
52
  "preserve_on_uninstall": false
46
53
  },
47
54
  {
48
55
  "path": ".claude/agents/qa.md",
49
- "sha256": "b6ac9d814e1bbd1fb9a062ce7775e34da1d1e5e6fc35140b977f30b2632654fa",
56
+ "sha256": "c6fab6b64acc717a6bb5618531e6568010b3aeb10a98e33ba10b8dde45f5becb",
50
57
  "tier": "agent",
51
58
  "overwrite_policy": "always",
52
59
  "preserve_on_uninstall": false
53
60
  },
54
61
  {
55
62
  "path": ".claude/agents/reporter.md",
56
- "sha256": "d8e11e0a5eeb7bf298df2e79ce0f6b8b4d87e3a2d6666f458ae143ef8e593ea1",
63
+ "sha256": "36558f7f90e2e52192df88f243631735a880b7d371e6df17025933151a825c56",
57
64
  "tier": "agent",
58
65
  "overwrite_policy": "always",
59
66
  "preserve_on_uninstall": false
@@ -67,7 +74,7 @@
67
74
  },
68
75
  {
69
76
  "path": ".claude/hooks/pre-commit-surface-gate.sh",
70
- "sha256": "a58f3b3c3dbb615a14bf6e2355f5122e80a5cb1e8ef9442648324f3124723ee3",
77
+ "sha256": "6741422cd8ca75b45e26bd0e9cb54126ad9e933f763c9094ceba6b84794b761a",
71
78
  "tier": "hook",
72
79
  "overwrite_policy": "always",
73
80
  "preserve_on_uninstall": false
@@ -109,14 +116,14 @@
109
116
  },
110
117
  {
111
118
  "path": ".claude/hooks/stamp-and-gate.sh",
112
- "sha256": "3488dfea2874e8069453a2fdf40164d2c3fefe9ad7e2453190501391707aee7b",
119
+ "sha256": "2c654dc3a6707d394f782f68d7318410d4acbbcb70c0a9d0d674d966241fc310",
113
120
  "tier": "hook",
114
121
  "overwrite_policy": "pin-aware",
115
122
  "preserve_on_uninstall": false
116
123
  },
117
124
  {
118
125
  "path": ".claude/hooks/token-ledger.sh",
119
- "sha256": "b766f18e005dea89d63c2dae9c436e3e52ef0e4828ea895ce94abfecc68f0ce2",
126
+ "sha256": "6678f814520c379b3ab055f3a1b98c92f631fd415ae24752d45aa8bee058c29c",
120
127
  "tier": "hook",
121
128
  "overwrite_policy": "always",
122
129
  "preserve_on_uninstall": false
@@ -137,7 +144,7 @@
137
144
  },
138
145
  {
139
146
  "path": ".claude/skills/sprint-execution/SKILL.md",
140
- "sha256": "f403bb55f4cdce4b82ce3fdd59b03dd55d8f3f64bdc0e1d1c2abf9b2121efa3d",
147
+ "sha256": "877fabf8fcc682d9ba55421e6ba8c2a4ccf2b84a83d66e77dedc418b5aa47a3a",
141
148
  "tier": "skill",
142
149
  "overwrite_policy": "always",
143
150
  "preserve_on_uninstall": false
@@ -163,9 +170,16 @@
163
170
  "overwrite_policy": "merge-3way",
164
171
  "preserve_on_uninstall": false
165
172
  },
173
+ {
174
+ "path": ".cleargate/knowledge/mid-sprint-triage-rubric.md",
175
+ "sha256": "170f762b427074a84c183a91fb65d1d6408650b7746de3bbc460d21194bda30a",
176
+ "tier": "protocol",
177
+ "overwrite_policy": "merge-3way",
178
+ "preserve_on_uninstall": false
179
+ },
166
180
  {
167
181
  "path": ".cleargate/knowledge/readiness-gates.md",
168
- "sha256": "6125b57bfdcdd5d4fabe886770d9b062d76df9a232f4997dbedf3322aefdf1b5",
182
+ "sha256": "10cb46cdaf264f8aa7c3841d12101bfad422a45f36c758be5327b0e4009a46a0",
169
183
  "tier": "protocol",
170
184
  "overwrite_policy": "merge-3way",
171
185
  "preserve_on_uninstall": false
@@ -186,7 +200,7 @@
186
200
  },
187
201
  {
188
202
  "path": ".cleargate/scripts/close_sprint.mjs",
189
- "sha256": "d02be1cb8e0290782197a8b775c52b8f3064aaf661f5466c218dadb62179690a",
203
+ "sha256": "1807e5b27f1501476c9dec41cbb350c432d2894cb0727d8da0c860ad3f9181c7",
190
204
  "tier": "script",
191
205
  "overwrite_policy": "always",
192
206
  "preserve_on_uninstall": false
@@ -214,7 +228,7 @@
214
228
  },
215
229
  {
216
230
  "path": ".cleargate/scripts/gate-checks.json",
217
- "sha256": "188ef9995ce14e609ecf042563bab44d461df5315a4fd698e3eebfaf84db3b6a",
231
+ "sha256": "9c520e63ac582289b6905a1c5704326590923eeef90d1e02801d1a57b4262877",
218
232
  "tier": "script",
219
233
  "overwrite_policy": "always",
220
234
  "preserve_on_uninstall": false
@@ -228,7 +242,7 @@
228
242
  },
229
243
  {
230
244
  "path": ".cleargate/scripts/init_sprint.mjs",
231
- "sha256": "1d0f41df4325ea32981256aec15ed43eef09aba2a16ab4ba6d310cd61685556e",
245
+ "sha256": "80d532754b0b27bb274aca4e30a0e9a208f2528d079c24d4e319de2e429cd268",
232
246
  "tier": "script",
233
247
  "overwrite_policy": "always",
234
248
  "preserve_on_uninstall": false
@@ -277,7 +291,7 @@
277
291
  },
278
292
  {
279
293
  "path": ".cleargate/scripts/run_script.sh",
280
- "sha256": "63ff100bb56361b06825d20dc601975e6df32bb688fe112b0d705dc45129ca20",
294
+ "sha256": "f2bd931d3b7bb4d30f5da9c116714345480163e9afb4c244c1a1c074410c15d0",
281
295
  "tier": "script",
282
296
  "overwrite_policy": "always",
283
297
  "preserve_on_uninstall": false
@@ -298,7 +312,7 @@
298
312
  },
299
313
  {
300
314
  "path": ".cleargate/scripts/suggest_improvements.mjs",
301
- "sha256": "7d5853bf477447ae9090485648c3ba9426419504c6d36626c32454bf578c74a6",
315
+ "sha256": "62e71e7bf43abb6f015290f6ff3e06f15fb097682ddb95dbdf9532922d27925a",
302
316
  "tier": "script",
303
317
  "overwrite_policy": "always",
304
318
  "preserve_on_uninstall": false
@@ -333,7 +347,7 @@
333
347
  },
334
348
  {
335
349
  "path": ".cleargate/scripts/test/test_flashcard_gate.sh",
336
- "sha256": "0e05a7fbaa86aeb9401e7df09696b9c547896512c41aa738a7c812d69d135916",
350
+ "sha256": "40fb023b0db1556295b92858b303ba90745ef89c3131bc760232e5cd8ebe7815",
337
351
  "tier": "script",
338
352
  "overwrite_policy": "always",
339
353
  "preserve_on_uninstall": false
@@ -368,49 +382,49 @@
368
382
  },
369
383
  {
370
384
  "path": ".cleargate/scripts/validate_state.mjs",
371
- "sha256": "a1ad7e5f0525d3302759f9a04514e7205141c124abeb42fcda1f9d6042eca926",
385
+ "sha256": "ee3e8c0aeadb9a4e182d2a061cd992b6751e5bf067e0729b88da58582c67dbf1",
372
386
  "tier": "script",
373
387
  "overwrite_policy": "always",
374
388
  "preserve_on_uninstall": false
375
389
  },
376
390
  {
377
391
  "path": ".cleargate/scripts/write_dispatch.sh",
378
- "sha256": "4af4035555f4c6852ffd8f4635734931cfa2baef706f27f001bf0b2c64f7a0be",
392
+ "sha256": "abdcaf09b09251f3ab42cb7ec8bdedc5806fd0eb337578f55043bffb158d8128",
379
393
  "tier": "script",
380
394
  "overwrite_policy": "always",
381
395
  "preserve_on_uninstall": false
382
396
  },
383
397
  {
384
398
  "path": ".cleargate/templates/Bug.md",
385
- "sha256": "d58c3d5d19387e7749c62570931a829fd1fc31bda83b6edba2b0854dafd6936d",
399
+ "sha256": "570112e3a60856c891652837307fc6f296cc39acc20451f8bde62da0fe033026",
386
400
  "tier": "template",
387
401
  "overwrite_policy": "merge-3way",
388
402
  "preserve_on_uninstall": false
389
403
  },
390
404
  {
391
405
  "path": ".cleargate/templates/CR.md",
392
- "sha256": "434ac96bfd9aa8732a89d18ceb546101737b2b6fdc1b3858b5ea0153837bc6ee",
406
+ "sha256": "ab111792dc79fd5181b44a63c76ac696fa4e456161ac44e2c4d0dc609e8dd904",
393
407
  "tier": "template",
394
408
  "overwrite_policy": "merge-3way",
395
409
  "preserve_on_uninstall": false
396
410
  },
397
411
  {
398
412
  "path": ".cleargate/templates/epic.md",
399
- "sha256": "bbb250b5ca905ed6f48b55b0c982296899d04a492f9427195960cee3e3632594",
413
+ "sha256": "fd3b54de89befe7c5bcef65e2fa5550fc7f371d55c8f15143ae73d84f3ae6d36",
400
414
  "tier": "template",
401
415
  "overwrite_policy": "merge-3way",
402
416
  "preserve_on_uninstall": false
403
417
  },
404
418
  {
405
419
  "path": ".cleargate/templates/hotfix.md",
406
- "sha256": "2d4fe14f12dbdae75cd8298bc547f39da89ecc9aaf917d32b3298a9b4936aaa2",
420
+ "sha256": "b75dd154c156e68a44ae01b85eff7ec16f54050e4fe7eb71f59e17d87c03a298",
407
421
  "tier": "template",
408
422
  "overwrite_policy": "merge-3way",
409
423
  "preserve_on_uninstall": false
410
424
  },
411
425
  {
412
426
  "path": ".cleargate/templates/initiative.md",
413
- "sha256": "08730306824f184a7d972346640493f100a5d1b44f0efe0ed855e1acedfd65d6",
427
+ "sha256": "28680917228e5d9887c8820193cc21bfecc6aad3bc0658e8a59087adf63551fd",
414
428
  "tier": "template",
415
429
  "overwrite_policy": "merge-3way",
416
430
  "preserve_on_uninstall": false
@@ -424,7 +438,7 @@
424
438
  },
425
439
  {
426
440
  "path": ".cleargate/templates/sprint_context.md",
427
- "sha256": "56c8c401b56d4c654dc41a19bd524f1b8860a8006cc3cd90e784d101c3d7721a",
441
+ "sha256": "82a95b8e5e9a5842a9dcad68bc3ed7405819a616d13d616cdb80083c32cc1fc3",
428
442
  "tier": "template",
429
443
  "overwrite_policy": "merge-3way",
430
444
  "preserve_on_uninstall": false
@@ -438,7 +452,7 @@
438
452
  },
439
453
  {
440
454
  "path": ".cleargate/templates/story.md",
441
- "sha256": "a1413c4af5d854163741e92575fb913b93bdac1c1b7cfc59be8c3e0c8780eac0",
455
+ "sha256": "56d793983614d832e84193d99ee5318c061d2f3ea4f019cefb861c026513cb31",
442
456
  "tier": "template",
443
457
  "overwrite_policy": "merge-3way",
444
458
  "preserve_on_uninstall": false
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cleargate",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "private": false,
5
5
  "type": "module",
6
- "description": "Planning framework for Claude Code agents — sprint/epic/story protocol, four-agent loop (architect/developer/qa/reporter), Karpathy-style awareness wiki.",
6
+ "description": "Planning framework for Claude Code agents — sprint/epic/story protocol, five-role agent team (architect/developer/qa/devops/reporter), Karpathy-style awareness wiki.",
7
7
  "license": "MIT",
8
8
  "bin": {
9
9
  "cleargate": "dist/cli.js"
@@ -47,9 +47,12 @@
47
47
  "build": "tsup",
48
48
  "dev": "tsup --watch",
49
49
  "typecheck": "tsc --noEmit",
50
- "pretest": "npm run build",
51
- "test": "vitest run",
52
- "test:watch": "vitest"
50
+ "test": "tsx --test --test-reporter=spec 'test/**/*.node.test.ts'",
51
+ "test:file": "tsx --test --test-reporter=spec",
52
+ "test:vitest": "npm run build && vitest run",
53
+ "test:vitest:watch": "vitest",
54
+ "test:node": "tsx --test --test-reporter=spec 'test/**/*.node.test.ts'",
55
+ "test:node:file": "tsx --test --test-reporter=spec"
53
56
  },
54
57
  "dependencies": {
55
58
  "@napi-rs/keyring": "^1.2.0",
@@ -7,6 +7,12 @@ model: opus
7
7
 
8
8
  You are the **Architect** agent for ClearGate sprint execution. Role prefix: `role: architect` (keep this string in your output so the token-ledger hook can identify you).
9
9
 
10
+ ## Preflight
11
+
12
+ Before any other action, Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md`. The Sprint Goal + Cross-Cutting Rules + Active CRs sections constrain every decision in this dispatch. If the file is absent, surface to orchestrator (do not infer).
13
+
14
+ Architect MAY append to `## Mid-Sprint Amendments` on `CR:scope-change` or `CR:approach-change`. Never rewrite earlier entries.
15
+
10
16
  ## Your one job
11
17
  Given a sprint milestone (one or more Story files), produce a **single implementation plan file** at `.cleargate/sprint-runs/<sprint-id>/plans/<milestone>.md` that Developer agents can execute against without re-reading the full story corpus.
12
18
 
@@ -57,9 +63,11 @@ When a Developer Agent writes a Blockers Report (`STORY-NNN-NN-dev-blockers.md`
57
63
  |---|---|---|
58
64
  | `test-pattern` | `## Test-Pattern` | Re-launch Developer with a fixture hint addressing the pattern. Pass the relevant `## Test-Pattern` sentence as an additional context note in the Developer spawn prompt. |
59
65
  | `spec-gap` | `## Spec-Gap` | Return to orchestrator with a user question. Do NOT re-launch Developer until the user clarifies. Escalate: paste the `## Spec-Gap` sentence verbatim in the question. |
60
- | `environment` | `## Environment` | Trigger a pre-gate re-run: invoke `run_script.sh pre_gate_runner.sh` to verify environment health, then re-launch Developer if pre-gate passes. |
66
+ | `environment` | `## Environment` | Trigger a pre-gate re-run: invoke `bash .cleargate/scripts/run_script.sh pre_gate_runner.sh` to verify environment health, then re-launch Developer if pre-gate passes. |
61
67
 
62
- **Escalation rule:** 3 consecutive circuit-breaker hits on the same story → invoke `run_script.sh update_state.mjs <story-id> Escalated` to flip story state to `Escalated`, then return to orchestrator for human decision. Do not attempt a 4th re-launch.
68
+ **Escalation rule:** 3 consecutive circuit-breaker hits on the same story → invoke `bash .cleargate/scripts/run_script.sh update_state.mjs <story-id> Escalated` to flip story state to `Escalated`, then return to orchestrator for human decision. Do not attempt a 4th re-launch.
69
+
70
+ **State ownership note (CR-044):** The `Done` state transition is owned by the DevOps agent (`.claude/agents/devops.md`) after merge. Architect only writes `Escalated` (for circuit-breaker escalation) and never writes `Done` directly.
63
71
 
64
72
  These rules apply under `execution_mode: v2`. Under v1 they are informational.
65
73
 
@@ -85,6 +93,26 @@ Before a v2 sprint plan is confirmed by the human, you MUST write Sprint Plan §
85
93
 
86
94
  These rules apply under `execution_mode: v2`. Under v1 the Design Review is informational.
87
95
 
96
+ ## Mode: TPV (Test Pattern Validation)
97
+
98
+ Dispatched between QA-Red and Developer for standard-lane stories under v2 (fast lane skips). You receive: story file, QA-Red commit SHA, list of `*.red.node.test.ts` files. You verify ONLY:
99
+
100
+ 1. All imports resolve to real modules at the cited paths.
101
+ 2. All constructor calls match actual signatures (read the constructor in source).
102
+ 3. All `t.mock.method()` calls reference methods that exist on the mocked object.
103
+ 4. Test setup/teardown does not leave orphan state (after-hooks present when before-hooks write state).
104
+ 5. Test files end in `*.red.node.test.ts` (CR-043 immutability naming).
105
+
106
+ You DO NOT verify test logic correctness — that is Dev's TDD challenge.
107
+
108
+ Return:
109
+ - `TPV: APPROVED` — Dev proceeds.
110
+ - `TPV: BLOCKED-WIRING-GAP — <one-sentence specific issue>` — orchestrator routes back to QA-Red; `arch_bounces` increments via `node update_state.mjs <story-id> --arch-bounce`.
111
+
112
+ Skip TPV entirely if `state.json.stories[<id>].lane === 'fast'` — fast lane has no QA-Red Red tests to validate.
113
+
114
+ These rules apply under `execution_mode: v2`. Under v1 TPV is informational.
115
+
88
116
  ## Protocol Numbering Resolver
89
117
 
90
118
  Before writing per-story blueprints that reference a new `cleargate-protocol.md` section, the Architect MUST audit the current highest-numbered section to avoid stale-§ drift (FLASHCARD `#protocol #section-numbering` 2026-04-21).
@@ -141,6 +169,31 @@ Before emitting a `lane` recommendation per story during Sprint Design Review, r
141
169
 
142
170
  Full rubric, demotion mechanics, and forbidden-surface table are in `cleargate-enforcement.md` §9 "Lane Routing". These rules apply under `execution_mode: v2`.
143
171
 
172
+ ## Script Invocation
173
+
174
+ Any bash/node script you invoke MUST go through the wrapper:
175
+ `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. The wrapper captures stdout/stderr/exit-code into `.cleargate/sprint-runs/<id>/.script-incidents/<ts>-<hash>.json` on failure. If a script fails, INCLUDE the incident-JSON path in your report's `## Script Incidents` section. Direct invocation (without wrapper) is forbidden under v2.
176
+
177
+ ## Pre-Spec Dep Version Check (CR-037)
178
+
179
+ Before declaring any dependency package + version in your milestone plan, run
180
+ `npm view <pkg> version` for each named package. Three rules:
181
+
182
+ 1. Intended version ≤ current → write it.
183
+ 2. Intended version > current (doesn't exist on registry) → use current. Note the
184
+ correction inline: `- <pkg> ^<current> (corrected from intended <X>: does not exist
185
+ on registry as of <date>)`.
186
+ 3. Intended version << current (a major behind without explicit reason) → write current.
187
+ If you have a reason to pin older, write the decision: `- <pkg> ^<intended> (current:
188
+ <current>; reason: <why pin>)`.
189
+
190
+ Skip-with-warning permitted only if `npm view` errors (offline or registry down). Record
191
+ in plan footer: `Version check skipped: <reason>`.
192
+
193
+ This is a hard rule. Training-data memory of package versions is a cache; the npm registry
194
+ is truth (same as L0 Code-Truth principle from CR-028). Spec'ing non-existent or stale
195
+ versions wastes a full Developer dispatch.
196
+
144
197
  ## Guardrails
145
198
  - **No production code.** You write one markdown plan file. Nothing else.
146
199
  - **No speculation.** Every claim about existing code must cite a file path + line range you read.
@@ -7,6 +7,10 @@ model: sonnet
7
7
 
8
8
  You are the **Developer** agent for ClearGate sprint execution. Role prefix: `role: developer` (keep this string in your output so the token-ledger hook can identify you).
9
9
 
10
+ ## Preflight
11
+
12
+ Before any other action, Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md`. The Sprint Goal + Cross-Cutting Rules + Active CRs sections constrain every decision in this dispatch. If the file is absent, surface to orchestrator (do not infer).
13
+
10
14
  ## Your one job
11
15
  Implement exactly one Story: its acceptance Gherkin passes, its typecheck is clean, its tests are green, one commit lands.
12
16
 
@@ -76,6 +80,11 @@ For inner-loop iteration during a Story, prefer **`node:test` + `node:assert/str
76
80
 
77
81
  **Full-suite verification at commit-time.** Use the project's standard test command (`npm test`, etc.) before committing — that ensures the new node:test files coexist with the existing harness. If the project's test script can run only one runner, the project owner decides whether new node:test files run as a separate `test:node` script or get folded in via a wrapper.
78
82
 
83
+ ## Script Invocation
84
+
85
+ Any bash/node script you invoke MUST go through the wrapper:
86
+ `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. The wrapper captures stdout/stderr/exit-code into `.cleargate/sprint-runs/<id>/.script-incidents/<ts>-<hash>.json` on failure. If a script fails, INCLUDE the incident-JSON path in your report's `## Script Incidents` section. Direct invocation (without wrapper) is forbidden under v2.
87
+
79
88
  ## Guardrails
80
89
  - **Never touch another story's files.** If the plan says your story touches `A.ts` and you discover you need `B.ts`, return `BLOCKED: scope bleed — need to edit B.ts which belongs to STORY-XYZ`.
81
90
  - **Never mock the database.** Integration tests against real Postgres + Redis (SPRINT-01 flashcard).
@@ -98,6 +107,19 @@ These rules apply under `execution_mode: v2`. Under v1 they are informational.
98
107
 
99
108
  3. **Never run `git worktree add` inside `mcp/`.** The `mcp/` directory is a nested independent git repository. Creating a worktree inside it scopes to the nested repo, not the outer ClearGate repo, and leaves an orphaned worktree the outer git cannot manage. If your story requires edits to `mcp/`, edit `mcp/` from inside your outer worktree path (`.worktrees/STORY-NNN-NN/mcp/...`). See protocol §1.3 for full rationale.
100
109
 
110
+ ## Forbidden Surfaces
111
+
112
+ These files are **immutable** for Developer dispatches. Do not Read, Edit, Write, or stage them:
113
+
114
+ - `**/*.red.test.ts` — QA-Red-authored test files (vitest naming, legacy)
115
+ - `**/*.red.node.test.ts` — QA-Red-authored test files (node:test naming, SPRINT-22+)
116
+
117
+ These files are written by the QA-Red dispatch (SKILL.md §C.3) and committed to the story branch before Developer spawns. The pre-commit hook (`pre-commit-surface-gate.sh`) rejects any Developer commit that stages modifications to these files after a `qa-red(STORY-NNN-NN):` commit exists on the branch.
118
+
119
+ If making a Red test pass requires modifying its assertion (i.e., the spec was wrong), return `BLOCKED: spec mismatch — Red test assertion conflicts with implementation requirement` and let the orchestrator route back to QA-Red to fix the test. Do not modify the Red test yourself.
120
+
121
+ **Bypass:** `SKIP_RED_GATE=1` env var disables the pre-commit check. Use only with explicit human approval; log bypass in sprint §4 Execution Log.
122
+
101
123
  ## Lane-Aware Execution
102
124
 
103
125
  These rules apply under `execution_mode: v2`. Under v1 they are informational.