cleargate 0.8.1 → 0.10.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 (98) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/README.md +11 -0
  3. package/dist/MANIFEST.json +259 -28
  4. package/dist/{chunk-OM4FAEA7.js → chunk-Q3BTSXCK.js} +69 -3
  5. package/dist/chunk-Q3BTSXCK.js.map +1 -0
  6. package/dist/cli.cjs +2621 -548
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/cli.js +2548 -560
  9. package/dist/cli.js.map +1 -1
  10. package/dist/lib/ledger.cjs +120 -0
  11. package/dist/lib/ledger.cjs.map +1 -0
  12. package/dist/lib/ledger.d.cts +64 -0
  13. package/dist/lib/ledger.d.ts +64 -0
  14. package/dist/lib/ledger.js +96 -0
  15. package/dist/lib/ledger.js.map +1 -0
  16. package/dist/templates/cleargate-planning/.claude/agents/architect.md +10 -8
  17. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-contradict.md +108 -0
  18. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +49 -3
  19. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +6 -1
  20. package/dist/templates/cleargate-planning/.claude/agents/developer.md +29 -2
  21. package/dist/templates/cleargate-planning/.claude/agents/qa.md +50 -1
  22. package/dist/templates/cleargate-planning/.claude/agents/reporter.md +31 -9
  23. package/dist/templates/cleargate-planning/.claude/hooks/pre-tool-use-task.sh +148 -0
  24. package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +6 -0
  25. package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +314 -96
  26. package/dist/templates/cleargate-planning/.claude/settings.json +4 -0
  27. package/dist/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +473 -0
  28. package/dist/templates/cleargate-planning/.cleargate/config.example.yml +19 -0
  29. package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-enforcement.md +542 -0
  30. package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +102 -428
  31. package/dist/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +31 -0
  32. package/dist/templates/cleargate-planning/.cleargate/knowledge/sprint-closeout-checklist.md +71 -0
  33. package/dist/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +24 -2
  34. package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +387 -27
  35. package/dist/templates/cleargate-planning/.cleargate/scripts/dedupe_frontmatter.mjs +219 -0
  36. package/dist/templates/cleargate-planning/.cleargate/scripts/lib/report-filename.mjs +54 -0
  37. package/dist/templates/cleargate-planning/.cleargate/scripts/prep_doc_refresh.mjs +378 -0
  38. package/dist/templates/cleargate-planning/.cleargate/scripts/prep_qa_context.mjs +888 -0
  39. package/dist/templates/cleargate-planning/.cleargate/scripts/sprint_trends.mjs +71 -0
  40. package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +355 -13
  41. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +20 -20
  42. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_prep_qa_context.sh +482 -0
  43. package/dist/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +125 -0
  44. package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +33 -10
  45. package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +41 -10
  46. package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +48 -14
  47. package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +46 -12
  48. package/dist/templates/cleargate-planning/.cleargate/templates/hotfix.md +51 -1
  49. package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +98 -29
  50. package/dist/templates/cleargate-planning/.cleargate/templates/proposal.md +26 -13
  51. package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +23 -4
  52. package/dist/templates/cleargate-planning/.cleargate/templates/story.md +64 -12
  53. package/dist/templates/cleargate-planning/CLAUDE.md +28 -10
  54. package/dist/templates/cleargate-planning/MANIFEST.json +259 -28
  55. package/dist/{whoami-CX7CXJD5.js → whoami-W4U6DPVG.js} +17 -17
  56. package/dist/whoami-W4U6DPVG.js.map +1 -0
  57. package/package.json +13 -2
  58. package/templates/cleargate-planning/.claude/agents/architect.md +10 -8
  59. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-contradict.md +108 -0
  60. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +49 -3
  61. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +6 -1
  62. package/templates/cleargate-planning/.claude/agents/developer.md +29 -2
  63. package/templates/cleargate-planning/.claude/agents/qa.md +50 -1
  64. package/templates/cleargate-planning/.claude/agents/reporter.md +31 -9
  65. package/templates/cleargate-planning/.claude/hooks/pre-tool-use-task.sh +148 -0
  66. package/templates/cleargate-planning/.claude/hooks/session-start.sh +6 -0
  67. package/templates/cleargate-planning/.claude/hooks/token-ledger.sh +314 -96
  68. package/templates/cleargate-planning/.claude/settings.json +4 -0
  69. package/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +473 -0
  70. package/templates/cleargate-planning/.cleargate/config.example.yml +19 -0
  71. package/templates/cleargate-planning/.cleargate/knowledge/cleargate-enforcement.md +542 -0
  72. package/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +102 -428
  73. package/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +31 -0
  74. package/templates/cleargate-planning/.cleargate/knowledge/sprint-closeout-checklist.md +71 -0
  75. package/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +24 -2
  76. package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +387 -27
  77. package/templates/cleargate-planning/.cleargate/scripts/dedupe_frontmatter.mjs +219 -0
  78. package/templates/cleargate-planning/.cleargate/scripts/lib/report-filename.mjs +54 -0
  79. package/templates/cleargate-planning/.cleargate/scripts/prep_doc_refresh.mjs +378 -0
  80. package/templates/cleargate-planning/.cleargate/scripts/prep_qa_context.mjs +888 -0
  81. package/templates/cleargate-planning/.cleargate/scripts/sprint_trends.mjs +71 -0
  82. package/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +355 -13
  83. package/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +20 -20
  84. package/templates/cleargate-planning/.cleargate/scripts/test/test_prep_qa_context.sh +482 -0
  85. package/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +125 -0
  86. package/templates/cleargate-planning/.cleargate/templates/Bug.md +33 -10
  87. package/templates/cleargate-planning/.cleargate/templates/CR.md +41 -10
  88. package/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +48 -14
  89. package/templates/cleargate-planning/.cleargate/templates/epic.md +46 -12
  90. package/templates/cleargate-planning/.cleargate/templates/hotfix.md +51 -1
  91. package/templates/cleargate-planning/.cleargate/templates/initiative.md +98 -29
  92. package/templates/cleargate-planning/.cleargate/templates/sprint_report.md +23 -4
  93. package/templates/cleargate-planning/.cleargate/templates/story.md +64 -12
  94. package/templates/cleargate-planning/CLAUDE.md +28 -10
  95. package/templates/cleargate-planning/MANIFEST.json +259 -28
  96. package/dist/chunk-OM4FAEA7.js.map +0 -1
  97. package/dist/whoami-CX7CXJD5.js.map +0 -1
  98. package/templates/cleargate-planning/.cleargate/templates/proposal.md +0 -61
@@ -8,13 +8,28 @@ Use this template when CHANGING an existing feature. For net-new functionality,
8
8
  §4 Verification Protocol: How to confirm new logic works and old logic is fully evicted.
9
9
  Output location: .cleargate/delivery/pending-sync/CR-{ID}.md
10
10
 
11
- CRITICAL PHASE GATE: Do NOT invoke cleargate_push_item until all impacted downstream Epics/Stories are identified and reverted to 🔴 High Ambiguity.
11
+ POST-WRITE BRIEF
12
+ After Writing this document, render a Brief in chat with the following sections,
13
+ mechanically extracted from the document's own structure:
14
+
15
+ - Summary ← §1 The Context Override
16
+ - Open Questions ← §0.5 Open Questions
17
+ - Edge Cases ← §2 Blast Radius & Invalidation
18
+ - Risks ← §2 Blast Radius (downstream invalidation = risk)
19
+ - Ambiguity ← bottom-of-doc ambiguity gate block
20
+
21
+ Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
22
+ Do NOT ask separately for push confirmation — Brief approval covers it.
23
+
12
24
  Do NOT output these instructions.
13
25
  </instructions>
14
26
 
15
27
  ---
16
28
  cr_id: "CR-{ID}"
17
29
  parent_ref: "EPIC-{ID} | STORY-{ID}"
30
+ parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
31
+ sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
32
+ carry_over: false # set true to skip lifecycle reconciliation at sprint close
18
33
  status: "Draft | In Review | Approved"
19
34
  approved: false
20
35
  created_at: "2026-04-17T00:00:00Z"
@@ -33,19 +48,27 @@ cached_gate_result:
33
48
  pass: null
34
49
  failing_criteria: []
35
50
  last_gate_check: null
36
- # Sync attribution (EPIC-010). Optional; stamped by `cleargate push` / `cleargate pull`.
37
- pushed_by: null # STORY-010-07 writer / STORY-010-04 reader
38
- pushed_at: null # STORY-010-07 writer / STORY-010-04 reader
39
- last_pulled_by: null # STORY-010-04 writer / STORY-010-03 reader
40
- last_pulled_at: null # STORY-010-04 writer / STORY-010-03 reader
41
- last_remote_update: null # STORY-010-02 writer (from MCP) / STORY-010-03 reader
42
- source: "local-authored" # STORY-010-05 flips to "remote-authored" on intake
43
- last_synced_status: null # STORY-010-04 writer; required for conflict-detector rule 6
44
- last_synced_body_sha: null # STORY-010-04 writer; sha256 of body at last sync
51
+ # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
52
+ pushed_by: null # set by push: which user pushed
53
+ pushed_at: null # set by push: ISO-8601 timestamp
54
+ last_pulled_by: null # set by pull: which user pulled
55
+ last_pulled_at: null # set by pull: ISO-8601 timestamp
56
+ last_remote_update: null # set by pull: server's last-modified timestamp
57
+ source: "local-authored" # flips to "remote-authored" on intake
58
+ last_synced_status: null # required for conflict-detector; status at last sync
59
+ last_synced_body_sha: null # sha256 of body at last sync
45
60
  ---
46
61
 
47
62
  # CR-{ID}: {Change Request Name}
48
63
 
64
+ ## 0.5 Open Questions
65
+
66
+ > Populate during drafting. Resolve every entry before flipping ambiguity to 🟢.
67
+
68
+ - **Question:** {edge case, contradiction, or missing detail}
69
+ - **Recommended:** {agent's proposed answer}
70
+ - **Human decision:** {populated during Brief review}
71
+
49
72
  ## 1. The Context Override (Old vs. New)
50
73
  *(AI agents hallucinate when old context conflicts with new requests. Explicitly declare what to evict.)*
51
74
 
@@ -62,6 +85,13 @@ last_synced_body_sha: null # STORY-010-04 writer; sha256 of body at last sync
62
85
  - [ ] Invalidate/Update Epic: [Link]
63
86
  - [ ] Database schema impacts? {Yes/No — describe}
64
87
 
88
+ ## 2.5 Existing Surfaces
89
+
90
+ > L1 reuse audit. List source-tree implementations this CR extends or modifies. Cite file:line.
91
+
92
+ - **Surface:** `path/to/file.ext:NN` — {what it does today}
93
+ - **Why this CR extends rather than rebuilds:** {one paragraph — required when the change names a capability that already exists somewhere in the tree}
94
+
65
95
  ## 3. Execution Sandbox
66
96
  *(Restrict the agent's scope to prevent unrelated refactoring.)*
67
97
 
@@ -84,3 +114,4 @@ Requirements to pass to Green (Ready for Execution):
84
114
  - [ ] Execution Sandbox contains exact file paths.
85
115
  - [ ] Verification command is provided.
86
116
  - [ ] `approved: true` is set in the YAML frontmatter.
117
+ - [ ] §2.5 Existing Surfaces cites at least one source-tree path the CR extends.
@@ -1,25 +1,51 @@
1
1
  <instructions>
2
- This is a READ artifact. It is written by cleargate_pull_initiative when syncing a Sprint from the remote PM tool.
3
- Do NOT draft this file manually. Do NOT invoke cleargate_push_item on this file.
4
- The Vibe Coder may annotate the "Execution Guidelines" section locally — this section is never pushed.
5
- Output location: .cleargate/plans/SPRINT-{ID}.md
6
- Do NOT output these instructions.
7
-
8
- §1 Lane column placement: "Lane" is inserted between "Title" and "Milestone" in the Consolidated Deliverables
9
- table (§1). This positions lane as a planning signal adjacent to the story title, which is where the Architect
10
- most naturally reads it during Sprint Design Review. Values are "standard" (default) or "fast" (see protocol §24).
2
+ This template is actively authored during the Prepare phase.
3
+
4
+ WHAT TO GATHER
5
+ - Sprint number — read .cleargate/wiki/active-sprint.md, scan pending-sync/SPRINT-*.md, emit max(N) + 1
6
+ - Available work items — pending-sync/{EPIC,STORY,CR,BUG,HOTFIX}-*.md filtered ambiguity:🟢 + status:Ready
7
+ - Human-set priorities — frontmatter `priority` field per item
8
+ - Cross-item dependencies `parent_epic_ref:` + shared file-surface analysis
9
+
10
+ HOW TO GATHER
11
+ - Read for sprint-runs/, Grep for pending-sync/, scripts/wiki-query for awareness layer
12
+ - cleargate-cli/src/lib/admin-url.ts for any admin-link references
13
+
14
+ ANALYSIS REQUIRED
15
+ - Propose priority reordering for technical reasons (dep chains, shared-surface conflicts, fast-lane bundling). One-line rationale per change.
16
+ - Flag missing decomposition (epics with no child stories) — must resolve before Gate 2 passes.
17
+ - Trigger Architect Sprint Design Review (writes §2 Execution Strategy) once scope is locked.
18
+
19
+ WHERE TO WRITE
20
+ - .cleargate/delivery/pending-sync/SPRINT-<#>_<name>.md
21
+
22
+ POST-WRITE BRIEF
23
+ Render in chat with these sections:
24
+ - Sprint Goal (1 sentence)
25
+ - Selected items (table: id / type / lane / milestone / parallel? / bounce-exposure)
26
+ - Recommended priority changes (with one-line rationale per change)
27
+ - Open questions for human (with recommended answers)
28
+ - Risks (with mitigations)
29
+ - Current ambiguity + Gate 2 readiness checklist (decomposed? all 🟢? SDR §2 written?)
30
+ Halt for human review. When ambiguity reaches 🟢 AND Gate 2 conditions satisfy, proceed to call cleargate_push_item.
31
+
32
+ DUAL-AUDIENCE STRUCTURE
33
+ Top of body: Stakeholder/Sponsor view (Sprint Goal, Business Outcome, Risks/Mitigations, Metrics).
34
+ Bottom of body: AI-execution view (Phase Plan, Merge Ordering, Lane Audit, ADR-Conflict Flags, Decomposition Status).
11
35
 
12
- §2.4 Lane Audit: The Architect populates one row per fast-lane story during Sprint Design Review. Empty by default.
13
- Rows are added only for non-`standard` lanes. The subsection is numbered 2.4; the former §2.4 ADR-Conflict Flags
14
- is renumbered to §2.5.
36
+ Do NOT output these instructions.
15
37
  </instructions>
16
38
 
17
39
  ---
18
40
  sprint_id: "SPRINT-{ID}"
41
+ parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
42
+ sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
43
+ carry_over: false # set true to skip lifecycle reconciliation at sprint close
44
+ lifecycle_init_mode: "warn" # "warn" | "block" — controls sprint-init lifecycle gate (§10.4); use "block" for SPRINT-16+
19
45
  remote_id: "{PM_TOOL_SPRINT_ID}"
20
46
  source_tool: "linear | jira"
21
47
  status: "Draft | Active | Completed"
22
- execution_mode: "v1" # Enum: "v1" | "v2". Default "v1". Under "v2", §§15–18 of cleargate-protocol.md are enforcing (worktree isolation, pre-gate scanning, bounce counters, flashcard gate, sprint-close pipeline). Under "v1", those sections are advisory only and all new CLI commands (sprint init|close, story start|complete, gate qa|arch, state update|validate) print an inert-mode message. Set to "v2" only after all EPIC-013 M2 stories have shipped and the Architect has completed a Sprint Design Review (see §19 of the protocol).
48
+ execution_mode: "v1" # Enum: "v1" | "v2". Default "v1". Under "v2", §§1–18 of cleargate-enforcement.md are enforcing (worktree isolation, pre-gate scanning, bounce counters, flashcard gate, sprint-close pipeline). Under "v1", those sections are advisory only and all new CLI commands (sprint init|close, story start|complete, gate qa|arch, state update|validate) print an inert-mode message. Set to "v2" only after all EPIC-013 M2 stories have shipped and the Architect has completed a Sprint Design Review (see §5 of the protocol).
23
49
  start_date: "{YYYY-MM-DD}"
24
50
  end_date: "{YYYY-MM-DD}"
25
51
  synced_at: "{ISO-8601 timestamp}"
@@ -42,6 +68,14 @@ cached_gate_result:
42
68
 
43
69
  # SPRINT-{ID}: {Sprint Number / Name}
44
70
 
71
+ ## 0. Stakeholder Brief
72
+ *(Sponsor-readable summary. Pushed to PM tool. Pair with §3 Risks below.)*
73
+
74
+ - **Sprint Goal:** {1 sentence}
75
+ - **Business Outcome:** {what the user / sponsor gets}
76
+ - **Risks (top 3):** {bullet list, see §3 for full table}
77
+ - **Metrics:** {expected impact / KPIs}
78
+
45
79
  ## Sprint Goal
46
80
  {One clear sentence describing the primary objective of this sprint, as defined in the PM tool.}
47
81
 
@@ -66,7 +100,7 @@ Example:
66
100
 
67
101
  | Shared File | Stories Touching It | Merge Order | Rationale |
68
102
  |---|---|---|---|
69
- | `.cleargate/knowledge/cleargate-protocol.md` | STORY-NNN-01, STORY-NNN-02 | 01 → 02 | 01 adds §16; 02 amends §16 |
103
+ | `.cleargate/knowledge/cleargate-enforcement.md` | STORY-NNN-01, STORY-NNN-02 | 01 → 02 | 01 adds §2; 02 amends §2 |
70
104
 
71
105
  ### 2.3 Shared-Surface Warnings
72
106
  {Explicit conflict risks. One bullet per risk. Cite file + story pair.}
@@ -1,22 +1,40 @@
1
1
  <instructions>
2
2
  FOLLOW THIS EXACT STRUCTURE. Output sections in order.
3
- YAML Frontmatter: Epic ID, Status, Ambiguity, Context Source (MUST link to approved proposal.md), Owner, Target Date.
3
+ YAML Frontmatter: Epic ID, Status, Ambiguity, Context Source, Owner, Target Date.
4
4
  §0 Agent Handoff: XML block specifically formulated for AI coding agents to ingest.
5
5
  §1 Problem & Value: Why (problem), What (solution), Success Metrics.
6
6
  §2 Scope Boundaries: IN-SCOPE checkboxes, OUT-OF-SCOPE list.
7
7
  §3 The Reality Check (Context): Constraints table.
8
- §4 Technical Grounding: Verified files and data changes. Copied strictly from approved proposal.md.
8
+ §4 Technical Grounding: Verified files and data changes.
9
9
  §5 Acceptance Criteria: Gherkin scenarios (happy path + error cases).
10
10
  §6 AI Interrogation Loop: Explicit questions the Planning AI needs the Human to answer.
11
11
  Output location: .cleargate/delivery/pending-sync/EPIC-{NNN}_{epic_name}.md
12
12
 
13
13
  Codebase research is mandatory. Do NOT guess at affected files.
14
- You MUST base this strictly on an approved: true proposal document.
14
+
15
+ POST-WRITE BRIEF
16
+ After Writing this document, render a Brief in chat with the following sections,
17
+ mechanically extracted from the document's own structure:
18
+
19
+ - Summary ← §1 Problem & Value
20
+ - Open Questions ← §6 AI Interrogation Loop
21
+ - Edge Cases ← §2 OUT-OF-SCOPE list + §5 error scenarios
22
+ - Risks ← §3 The Reality Check
23
+ - Existing Surfaces ← §3.5 Existing Surfaces
24
+ - Why not simpler? ← §3.6 Why not simpler?
25
+ - Ambiguity ← bottom-of-doc ambiguity gate block
26
+
27
+ Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
28
+ Do NOT ask separately for push confirmation — Brief approval covers it.
29
+
15
30
  Do NOT output these instructions.
16
31
  </instructions>
17
32
 
18
33
  ---
19
34
  epic_id: "EPIC-{ID}"
35
+ parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
36
+ sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
37
+ carry_over: false # set true to skip lifecycle reconciliation at sprint close
20
38
  status: "Draft"
21
39
  ambiguity: "🔴 High"
22
40
  context_source: "PROPOSAL-{ID}.md"
@@ -38,15 +56,15 @@ cached_gate_result:
38
56
  pass: null
39
57
  failing_criteria: []
40
58
  last_gate_check: null
41
- # Sync attribution (EPIC-010). Optional; stamped by `cleargate push` / `cleargate pull`.
42
- pushed_by: null # STORY-010-07 writer / STORY-010-04 reader
43
- pushed_at: null # STORY-010-07 writer / STORY-010-04 reader
44
- last_pulled_by: null # STORY-010-04 writer / STORY-010-03 reader
45
- last_pulled_at: null # STORY-010-04 writer / STORY-010-03 reader
46
- last_remote_update: null # STORY-010-02 writer (from MCP) / STORY-010-03 reader
47
- source: "local-authored" # STORY-010-05 flips to "remote-authored" on intake
48
- last_synced_status: null # STORY-010-04 writer; required for conflict-detector rule 6
49
- last_synced_body_sha: null # STORY-010-04 writer; sha256 of body at last sync
59
+ # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
60
+ pushed_by: null # set by push: which user pushed
61
+ pushed_at: null # set by push: ISO-8601 timestamp
62
+ last_pulled_by: null # set by pull: which user pulled
63
+ last_pulled_at: null # set by pull: ISO-8601 timestamp
64
+ last_remote_update: null # set by pull: server's last-modified timestamp
65
+ source: "local-authored" # flips to "remote-authored" on intake
66
+ last_synced_status: null # required for conflict-detector; status at last sync
67
+ last_synced_body_sha: null # sha256 of body at last sync
50
68
  ---
51
69
 
52
70
  # EPIC-{ID}: {Epic Name}
@@ -91,6 +109,20 @@ last_synced_body_sha: null # STORY-010-04 writer; sha256 of body at last sync
91
109
  | Performance | {e.g., Must complete in < 200ms} |
92
110
  | Security | {e.g., No PII in logs} |
93
111
 
112
+ ## 3.5 Existing Surfaces
113
+
114
+ > L1 reuse audit. List source-tree implementations the epic could extend. Cite file:line.
115
+
116
+ - **Surface:** `path/to/file.ext:NN` — {what it does}
117
+ - **Coverage of this epic's scope:** {≥80% extension / partial / none — and why}
118
+
119
+ ## 3.6 Why not simpler?
120
+
121
+ > L2 / L3 right-size + justify-complexity. Answer both.
122
+
123
+ - **Smallest existing surface that could carry this epic:** {citation or "none — net-new abstraction required"}
124
+ - **Why isn't extension / parameterization / config sufficient?** {one paragraph}
125
+
94
126
  ## 4. Technical Grounding (The "Shadow Spec")
95
127
  *(AI Planning Engine: Populate this strictly from the approved proposal.md)*
96
128
 
@@ -127,3 +159,5 @@ Requirements to pass to Green (Ready for Coding Agent):
127
159
  - [ ] §4 Technical Grounding contains 100% real, verified file paths.
128
160
  - [ ] §6 AI Interrogation Loop is empty (all human answers integrated into the spec).
129
161
  - [ ] 0 "TBDs" exist in the document.
162
+ - [ ] §3.5 Existing Surfaces cites at least one source-tree path or explicitly states "none — net-new."
163
+ - [ ] §3.6 Why not simpler? has both sub-bullets answered.
@@ -1,5 +1,36 @@
1
+ <instructions>
2
+ USE THIS TEMPLATE FOR EMERGENCY HOTFIXES ONLY — production anomalies requiring immediate fix outside the sprint cycle. Hotfix discipline: ≤2 files, ≤30 LOC net.
3
+
4
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order 0.5–4.
5
+ YAML Frontmatter: Hotfix ID, severity, originating signal, lane: "hotfix".
6
+ §0.5 Open Questions: Capture any remaining ambiguity before merge.
7
+ §1 Anomaly: Expected vs. Actual behavior.
8
+ §2 Files Touched: ≤2 files (constraint from EPIC-022 §3).
9
+ §3 Verification Steps: Non-empty before merging (blocks merge if empty).
10
+ §4 Rollback: Git revert instructions.
11
+ Output location: .cleargate/delivery/pending-sync/HOTFIX-{ID}-{Slug}.md
12
+
13
+ POST-WRITE BRIEF
14
+ After Writing this document, render a Brief in chat with the following sections,
15
+ mechanically extracted from the document's own structure:
16
+
17
+ - Summary ← §1 Anomaly (Problem)
18
+ - Open Questions ← §0.5 Open Questions
19
+ - Edge Cases ← §3 Files Affected (risk of adjacent regression)
20
+ - Risks ← §4 Verification + risk-of-missing
21
+ - Ambiguity ← bottom-of-doc ClearGate Ambiguity Gate block
22
+
23
+ Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
24
+ Do NOT ask separately for push confirmation — Brief approval covers it.
25
+
26
+ Do NOT output these instructions.
27
+ </instructions>
28
+
1
29
  ---
2
30
  hotfix_id: "{ID}"
31
+ parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
32
+ sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
33
+ carry_over: false # set true to skip lifecycle reconciliation at sprint close
3
34
  status: "Draft"
4
35
  severity: "P2"
5
36
  originating_signal: "user-report"
@@ -20,7 +51,7 @@ cached_gate_result:
20
51
  pass: null
21
52
  failing_criteria: []
22
53
  last_gate_check: null
23
- # Sync attribution (EPIC-010). Optional; stamped by `cleargate push` / `cleargate pull`.
54
+ # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
24
55
  pushed_by: null
25
56
  pushed_at: null
26
57
  last_pulled_by: null
@@ -33,6 +64,14 @@ last_synced_body_sha: null
33
64
 
34
65
  # {ID}: {SLUG}
35
66
 
67
+ ## 0.5 Open Questions
68
+
69
+ > Populate during drafting. Resolve every entry before flipping ambiguity to 🟢.
70
+
71
+ - **Question:** {edge case, contradiction, or missing detail}
72
+ - **Recommended:** {agent's proposed answer}
73
+ - **Human decision:** {populated during Brief review}
74
+
36
75
  ## 1. Anomaly
37
76
 
38
77
  **Expected Behavior:** {What the system should do under normal conditions.}
@@ -56,3 +95,14 @@ Hotfix discipline: ≤2 files, ≤30 LOC net (EPIC-022 §3).
56
95
  ## 4. Rollback
57
96
 
58
97
  If the hotfix introduces a regression, revert by running `git revert <commit-sha>` on the sprint or main branch. The original anomaly will reappear; escalate to a sprint story for a permanent fix. No data migrations are involved unless noted in §2 above.
98
+
99
+ ---
100
+
101
+ ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
102
+ **Current Status: 🔴 High Ambiguity**
103
+
104
+ Requirements to pass to Green (Ready for Merge):
105
+ - [ ] Anomaly is deterministically reproducible (§1 filled).
106
+ - [ ] Files Touched list is ≤2 files (§2 filled).
107
+ - [ ] Verification Steps (§3) are non-empty.
108
+ - [ ] `approved: true` is set in the YAML frontmatter.
@@ -1,21 +1,43 @@
1
1
  <instructions>
2
- This is a READ artifact. It is written by cleargate_pull_initiative when syncing from the remote PM tool.
3
- Do NOT draft this file from scratch. Do NOT invoke cleargate_push_item on this file — it is already synced from the remote.
4
- Use this file as context input when drafting a Proposal or Epic.
5
- Output location: .cleargate/plans/INIT-{ID}.md
6
- Do NOT output these instructions.
2
+ USE THIS TEMPLATE TO DOCUMENT WHAT AN INITIATIVE LOOKS LIKE the BA/PM-authored
3
+ stakeholder-input artifact that captures business intent BEFORE AI decomposition.
4
+
5
+ WHO AUTHORS THIS: a human BA / PM / sponsor — outside the codebase OR in the upstream
6
+ PM tool (Linear / Jira / GitHub Issues). The AI does NOT author Initiatives from
7
+ scratch in the repo. This template is a cheat sheet for the human author.
8
+
9
+ HOW IT GETS INTO THE REPO (two paths):
10
+ 1. MCP pull (preferred): `cleargate_pull_initiative` fetches from the upstream PM
11
+ tool → caches at `.cleargate/delivery/pending-sync/INITIATIVE-NNN_*.md`.
12
+ 2. Manual paste: human drops a markdown file matching this shape into
13
+ `pending-sync/`. AI stamps `source: manual-paste` then triages.
14
+
15
+ WHAT THE AI DOES WITH IT:
16
+ - Reads the cached/pasted Initiative.
17
+ - Asks open questions in chat.
18
+ - DECOMPOSES into Epic / Story / CR / Bug — NEVER edits the Initiative body.
19
+ - On triage completion: moves the Initiative to `archive/INITIATIVE-NNN_*.md`
20
+ with frontmatter stamps `triaged_at: <ISO-8601>` and
21
+ `spawned_items: [EPIC-NNN, STORY-NNN-NN, ...]`.
22
+
23
+ OUTPUT LOCATION: `.cleargate/delivery/pending-sync/INITIATIVE-{NNN}_{short_name}.md`
24
+
25
+ DO NOT output these instructions in the rendered file.
7
26
  </instructions>
8
27
 
9
28
  ---
10
- initiative_id: "INIT-{ID}"
11
- remote_id: "{PM_TOOL_ID}"
12
- source_tool: "linear | jira"
13
- status: "{PM native status}"
14
- synced_at: "{ISO-8601 timestamp}"
15
- created_at: "2026-04-17T00:00:00Z"
16
- updated_at: "2026-04-17T00:00:00Z"
17
- created_at_version: "strategy-phase-pre-init"
18
- updated_at_version: "strategy-phase-pre-init"
29
+ initiative_id: "INIT-{NNN}"
30
+ remote_id: null
31
+ source_tool: "linear | jira | github | manual-paste"
32
+ status: "{PM native status — e.g. Discovery, In Triage, Triaged}"
33
+ synced_at: null
34
+ triaged_at: null
35
+ spawned_items: []
36
+ created_at: "{ISO-8601 timestamp}"
37
+ updated_at: "{ISO-8601 timestamp}"
38
+ created_at_version: "cleargate@{semver}"
39
+ updated_at_version: "cleargate@{semver}"
40
+ server_pushed_at_version: null
19
41
  draft_tokens:
20
42
  input: null
21
43
  output: null
@@ -27,27 +49,74 @@ cached_gate_result:
27
49
  pass: null
28
50
  failing_criteria: []
29
51
  last_gate_check: null
52
+ # Sync attribution. Optional; stamped by `cleargate_pull_initiative`.
53
+ pushed_by: null
54
+ pushed_at: null
55
+ last_pulled_by: null
56
+ last_pulled_at: null
57
+ last_remote_update: null
58
+ source: "remote-pulled" # or "manual-paste"
59
+ last_synced_status: null
60
+ last_synced_body_sha: null
30
61
  ---
31
62
 
32
- # INIT-{ID}: {Initiative Name}
63
+ # INITIATIVE-{NNN}: {Initiative Name}
64
+
65
+ ## 1. User Flow
66
+
67
+ {End-to-end walkthrough of what the user does — step-by-step, in plain language.
68
+ Capture the happy path first, then named alternative flows. Diagrams welcome
69
+ (see §2). No technical implementation details — that's the AI's job during
70
+ decomposition.}
71
+
72
+ ## 2. Diagrams
33
73
 
34
- ## 1. Objective & Business Value
35
- {High-level summary of what this initiative achieves and the expected outcome for the user or system.}
74
+ {Embedded mermaid / asciiart / linked image. Optional but encouraged for any
75
+ flow with branching, parallel paths, or multiple actors.
36
76
 
37
- ## 2. Success Criteria
38
- - {Concrete metric or functional requirement 1}
39
- - {Concrete metric or functional requirement 2}
77
+ Placeholder:
78
+ ```
79
+ [ User ] [ Action 1 ] → [ Outcome ]
80
+
81
+ [ Branch ]
82
+ ```
83
+ }
40
84
 
41
- ## 3. Scope & Constraints
85
+ ## 3. End-to-End Verbal Description
42
86
 
43
- **In scope:**
44
- - {What is included}
87
+ {The "tell me what this does" paragraph. 3-8 sentences. Captures the intent,
88
+ the ask, and the boundary of the work. Skim-readable for a stakeholder; rich
89
+ enough that the AI can ground the first round of decomposition questions in it.}
45
90
 
46
- **Out of scope:**
47
- - {What is explicitly excluded}
91
+ ## 4. Business Outcome
92
+
93
+ {Why this matters. 1-2 sentences linking the work to a business metric, user
94
+ need, or strategic goal. Answers "if this ships, what changes?"}
95
+
96
+ ## 5. Success Criteria
97
+
98
+ - {Concrete, measurable criterion 1 — what must be true to call this done.}
99
+ - {Concrete, measurable criterion 2}
100
+ - {Concrete, measurable criterion 3 (optional)}
101
+
102
+ ## 6. Open Questions for AI Triage
103
+
104
+ {Questions the BA/PM knows are unresolved and wants the AI to surface during
105
+ decomposition. The AI MAY answer in chat then propose decomposition; the AI
106
+ does NOT edit this section in the Initiative body.
107
+
108
+ - Question 1
109
+ - Question 2
110
+ }
111
+
112
+ ---
48
113
 
49
- **Hard constraints:**
50
- - {Deadlines, architectural rules, compliance requirements}
114
+ ## Stakeholder Authoring Notes (not pushed)
51
115
 
52
- ## 4. Target Sprint / Timeline
53
- {Sprint number or date range as defined in the PM tool.}
116
+ - Initiative is the **stakeholder-input artifact**, not an AI-authored draft.
117
+ See `.cleargate/knowledge/cleargate-protocol.md` Plan-phase intake (post-CR-025).
118
+ - The AI never invokes `cleargate_push_item` on this file. Push semantics are
119
+ one-way: Initiative is **pulled**, Epic / Story / CR / Bug / Hotfix are **pushed**.
120
+ - After triage, this file moves to `archive/` with `triaged_at` + `spawned_items`
121
+ stamped. The PM tool retains source-of-truth for content; the repo retains
122
+ the audit trail.
@@ -1,15 +1,28 @@
1
- <instructions> FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
1
+ <instructions>
2
+ USE THIS TEMPLATE FOR INITIATIVE-CLASS SCOPE ONLY — multi-Epic work where a persistent file-based Brief is genuinely useful before decomposition begins. For single Epic / Story / CR / Bug / Hotfix, triage directly into the appropriate template; no Proposal step is needed.
3
+
4
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
2
5
  YAML Frontmatter: Proposal ID, Status, Author, and the crucial approved boolean.
3
6
  §1 Initiative & Context: The "Why" and "What".
4
7
  §2 Technical Architecture & Constraints: Architecture constraints, data flow, dependencies.
5
8
  §3 Touched Files: Real files that will need modification.
6
9
  Output location: .cleargate/delivery/pending-sync/PROPOSAL-{Name}.md
7
10
 
8
- Document Hierarchy Position: LEVEL 0 (Proposal → Epic → Story)
11
+ POST-WRITE BRIEF
12
+ After Writing this document, render a Brief in chat with the following sections,
13
+ mechanically extracted from the document's own structure:
14
+
15
+ - Summary ← §1 Initiative & Context
16
+ - Open Questions ← (new — add §1.4 Open Questions if multi-Epic scope is ambiguous)
17
+ - Edge Cases ← (new — add §3.3 Edge Cases)
18
+ - Risks ← §2 Constraints
19
+ - Ambiguity ← bottom-of-doc ambiguity gate block
9
20
 
10
- CRITICAL PHASE GATE: Do NOT generate Epics or Stories, and do NOT invoke cleargate_push_item, until the Human has reviewed this document and manually changed approved: false to approved: true in the frontmatter.
21
+ Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
22
+ Do NOT ask separately for push confirmation — Brief approval covers it.
11
23
 
12
- Do NOT output these instructions. </instructions>
24
+ Do NOT output these instructions.
25
+ </instructions>
13
26
 
14
27
  proposal_id: "PROP-{ID}" status: "Draft / In Review / Approved" author: "{AI Agent / Vibe Coder}" approved: false
15
28
  created_at: "2026-04-17T00:00:00Z"
@@ -28,15 +41,15 @@ cached_gate_result:
28
41
  pass: null
29
42
  failing_criteria: []
30
43
  last_gate_check: null
31
- # Sync attribution (EPIC-010). Optional; stamped by `cleargate push` / `cleargate pull`.
32
- pushed_by: null # STORY-010-07 writer / STORY-010-04 reader
33
- pushed_at: null # STORY-010-07 writer / STORY-010-04 reader
34
- last_pulled_by: null # STORY-010-04 writer / STORY-010-03 reader
35
- last_pulled_at: null # STORY-010-04 writer / STORY-010-03 reader
36
- last_remote_update: null # STORY-010-02 writer (from MCP) / STORY-010-03 reader
37
- source: "local-authored" # STORY-010-05 flips to "remote-authored" on intake
38
- last_synced_status: null # STORY-010-04 writer; required for conflict-detector rule 6
39
- last_synced_body_sha: null # STORY-010-04 writer; sha256 of body at last sync
44
+ # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
45
+ pushed_by: null # set by push: which user pushed
46
+ pushed_at: null # set by push: ISO-8601 timestamp
47
+ last_pulled_by: null # set by pull: which user pulled
48
+ last_pulled_at: null # set by pull: ISO-8601 timestamp
49
+ last_remote_update: null # set by pull: server's last-modified timestamp
50
+ source: "local-authored" # flips to "remote-authored" on intake
51
+ last_synced_status: null # required for conflict-detector; status at last sync
52
+ last_synced_body_sha: null # sha256 of body at last sync
40
53
  PROPOSAL-{ID}: {Initiative Name}
41
54
  1. Initiative & Context
42
55
  1.1 Objective
@@ -7,7 +7,7 @@ template_version: 2
7
7
  ---
8
8
 
9
9
  <!-- Sprint Report v2 Template — template_version: 2 -->
10
- <!-- Event-type vocabulary (STORY-013-05 / protocol §§16–17):
10
+ <!-- Event-type vocabulary (STORY-013-05 / protocol §§2–17):
11
11
  User-Review: UR:review-feedback | UR:bug
12
12
  Change-Request: CR:bug | CR:spec-clarification | CR:scope-change | CR:approach-change
13
13
  Circuit-breaker: test-pattern | spec-gap | environment
@@ -103,7 +103,26 @@ template_version: 2
103
103
 
104
104
  ---
105
105
 
106
- ## §4 Lessons
106
+ ## §4 Observe Phase Findings
107
+
108
+ > Populated from sprint plan §4 Execution Log entries dated within the Observe window
109
+ > [last-story-merge-timestamp, sprint-close-timestamp]. Reporter date-filters and groups by event type.
110
+ >
111
+ > SKIP THIS SECTION ENTIRELY (no header, no body) if all three subsections are empty.
112
+ > Output a single line in its place: "Observe phase: no findings."
113
+
114
+ ### 4.1 Bugs Found (UR:bug)
115
+ | Date | Description | Resolution | Commit |
116
+
117
+ ### 4.2 Hotfixes Triggered
118
+ | ID | Trigger | Resolution | Commit |
119
+
120
+ ### 4.3 Review Feedback (UR:review-feedback)
121
+ | Date | Description | Status (folded / deferred) | Deferred to / Rationale |
122
+
123
+ ---
124
+
125
+ ## §5 Lessons
107
126
 
108
127
  <!-- Flashcards added during this sprint window, grouped by tag.
109
128
  Preserve the stale-detection pass from reporter.md §5b — stale-candidate symbols
@@ -132,7 +151,7 @@ If zero candidates: No stale flashcards detected.
132
151
 
133
152
  ---
134
153
 
135
- ## §5 Framework Self-Assessment
154
+ ## §6 Framework Self-Assessment
136
155
 
137
156
  <!-- Rate each dimension: Green (working well) / Yellow (friction) / Red (blocking).
138
157
  "Tooling" subsection MUST include token-divergence finding if §3 divergence flag = YES. -->
@@ -196,7 +215,7 @@ intact for sprints with no hotfixes.>
196
215
 
197
216
  ---
198
217
 
199
- ## §6 Change Log
218
+ ## §7 Change Log
200
219
 
201
220
  <!-- Append one line per material revision to this report after initial generation. -->
202
221