cleargate 0.14.0 → 0.15.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 (149) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/MANIFEST.json +71 -15
  3. package/dist/admin-api/index.cjs +0 -1
  4. package/dist/admin-api/index.js +1 -2
  5. package/dist/auth/factory.cjs +0 -1
  6. package/dist/auth/factory.js +2 -3
  7. package/dist/auth/require-token.cjs +0 -1
  8. package/dist/auth/require-token.js +1 -2
  9. package/dist/auth/token-store.cjs +0 -1
  10. package/dist/auth/token-store.js +1 -2
  11. package/dist/{bootstrap-root-QKSA5V75.js → bootstrap-root-2H5HVTCC.js} +1 -2
  12. package/dist/{chunk-PDE37WFQ.js → chunk-A7MSQUU7.js} +2 -3
  13. package/dist/{chunk-BTSZOEWC.js → chunk-P6KEDAK2.js} +0 -1
  14. package/dist/{chunk-E3X7IE5E.js → chunk-PY6FHGV5.js} +1 -2
  15. package/dist/{chunk-5DI2Z3C2.js → chunk-Y53ZZYYU.js} +1 -2
  16. package/dist/cli.cjs +1564 -1414
  17. package/dist/cli.js +1514 -1364
  18. package/dist/lib/ledger.cjs +0 -1
  19. package/dist/lib/ledger.js +1 -2
  20. package/dist/lib/lifecycle-reconcile.cjs +0 -1
  21. package/dist/lib/lifecycle-reconcile.js +2 -3
  22. package/dist/{whoami-EANGN46Z.js → whoami-JKQQPABQ.js} +3 -4
  23. package/package.json +4 -3
  24. package/templates/cleargate-planning/.claude/agents/architect.md +4 -2
  25. package/templates/cleargate-planning/.claude/agents/developer.md +4 -11
  26. package/templates/cleargate-planning/.claude/agents/qa.md +14 -6
  27. package/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +2 -2
  28. package/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +19 -1
  29. package/templates/cleargate-planning/.cleargate/config.example.yml +16 -0
  30. package/templates/cleargate-planning/.cleargate/scripts/close_sprint.deferred-verify.red.node.test.ts +245 -0
  31. package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +227 -0
  32. package/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +5 -4
  33. package/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +75 -2
  34. package/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +48 -0
  35. package/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +57 -1
  36. package/templates/cleargate-planning/.cleargate/scripts/provision_worktree_config.sh +155 -0
  37. package/templates/cleargate-planning/.cleargate/scripts/qa_red_lint.mjs +380 -0
  38. package/templates/cleargate-planning/.cleargate/scripts/run_script.sh +34 -1
  39. package/templates/cleargate-planning/.cleargate/scripts/test/cr077_eviction.red.sh +113 -0
  40. package/templates/cleargate-planning/.cleargate/scripts/test/cr078_init.test.sh +309 -0
  41. package/templates/cleargate-planning/.cleargate/scripts/test/cr079_provision.red.sh +262 -0
  42. package/templates/cleargate-planning/.cleargate/scripts/test/cr080_wrapper.test.sh +177 -0
  43. package/templates/cleargate-planning/.cleargate/scripts/test/cr081_qa_red_lint.red.sh +348 -0
  44. package/templates/cleargate-planning/.cleargate/sprint-runs/_off-sprint/.session-totals.json +1 -0
  45. package/templates/cleargate-planning/.cleargate/sprint-runs/_off-sprint/token-ledger.jsonl +27 -0
  46. package/templates/cleargate-planning/.cleargate/templates/sprint_context.md +17 -0
  47. package/templates/cleargate-planning/.cleargate/templates/story.md +1 -0
  48. package/templates/cleargate-planning/MANIFEST.json +71 -15
  49. package/dist/admin-api/index.cjs.map +0 -1
  50. package/dist/admin-api/index.js.map +0 -1
  51. package/dist/auth/factory.cjs.map +0 -1
  52. package/dist/auth/factory.js.map +0 -1
  53. package/dist/auth/require-token.cjs.map +0 -1
  54. package/dist/auth/require-token.js.map +0 -1
  55. package/dist/auth/token-store.cjs.map +0 -1
  56. package/dist/auth/token-store.js.map +0 -1
  57. package/dist/bootstrap-root-QKSA5V75.js.map +0 -1
  58. package/dist/chunk-5DI2Z3C2.js.map +0 -1
  59. package/dist/chunk-BTSZOEWC.js.map +0 -1
  60. package/dist/chunk-E3X7IE5E.js.map +0 -1
  61. package/dist/chunk-PDE37WFQ.js.map +0 -1
  62. package/dist/cli.cjs.map +0 -1
  63. package/dist/cli.js.map +0 -1
  64. package/dist/lib/ledger.cjs.map +0 -1
  65. package/dist/lib/ledger.js.map +0 -1
  66. package/dist/lib/lifecycle-reconcile.cjs.map +0 -1
  67. package/dist/lib/lifecycle-reconcile.js.map +0 -1
  68. package/dist/templates/cleargate-planning/.claude/agents/architect-reader.md +0 -61
  69. package/dist/templates/cleargate-planning/.claude/agents/architect-synth.md +0 -124
  70. package/dist/templates/cleargate-planning/.claude/agents/architect.md +0 -230
  71. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-contradict.md +0 -108
  72. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +0 -194
  73. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +0 -261
  74. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-query.md +0 -143
  75. package/dist/templates/cleargate-planning/.claude/agents/developer.md +0 -185
  76. package/dist/templates/cleargate-planning/.claude/agents/devops.md +0 -257
  77. package/dist/templates/cleargate-planning/.claude/agents/qa.md +0 -171
  78. package/dist/templates/cleargate-planning/.claude/agents/reporter.md +0 -274
  79. package/dist/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +0 -209
  80. package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +0 -33
  81. package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +0 -58
  82. package/dist/templates/cleargate-planning/.claude/hooks/pre-commit.sh +0 -19
  83. package/dist/templates/cleargate-planning/.claude/hooks/pre-edit-gate.sh +0 -162
  84. package/dist/templates/cleargate-planning/.claude/hooks/pre-tool-use-autonomy.sh +0 -58
  85. package/dist/templates/cleargate-planning/.claude/hooks/pre-tool-use-task.sh +0 -148
  86. package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +0 -75
  87. package/dist/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +0 -43
  88. package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +0 -590
  89. package/dist/templates/cleargate-planning/.claude/settings.json +0 -68
  90. package/dist/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +0 -102
  91. package/dist/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +0 -742
  92. package/dist/templates/cleargate-planning/.cleargate/FLASHCARD.md +0 -7
  93. package/dist/templates/cleargate-planning/.cleargate/config.example.yml +0 -67
  94. package/dist/templates/cleargate-planning/.cleargate/config.yml +0 -18
  95. package/dist/templates/cleargate-planning/.cleargate/delivery/archive/.gitkeep +0 -0
  96. package/dist/templates/cleargate-planning/.cleargate/delivery/pending-sync/.gitkeep +0 -0
  97. package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-enforcement.md +0 -551
  98. package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +0 -878
  99. package/dist/templates/cleargate-planning/.cleargate/knowledge/mid-sprint-triage-rubric.md +0 -160
  100. package/dist/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +0 -213
  101. package/dist/templates/cleargate-planning/.cleargate/knowledge/sprint-closeout-checklist.md +0 -71
  102. package/dist/templates/cleargate-planning/.cleargate/scripts/_migrate-schema-v3.mjs +0 -120
  103. package/dist/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +0 -265
  104. package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +0 -1012
  105. package/dist/templates/cleargate-planning/.cleargate/scripts/collision_surface.sh +0 -114
  106. package/dist/templates/cleargate-planning/.cleargate/scripts/constants.mjs +0 -62
  107. package/dist/templates/cleargate-planning/.cleargate/scripts/dedupe_frontmatter.mjs +0 -219
  108. package/dist/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +0 -320
  109. package/dist/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +0 -15
  110. package/dist/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +0 -38
  111. package/dist/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +0 -240
  112. package/dist/templates/cleargate-planning/.cleargate/scripts/launch_wave.mjs +0 -341
  113. package/dist/templates/cleargate-planning/.cleargate/scripts/lib/report-filename.mjs +0 -54
  114. package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +0 -206
  115. package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +0 -371
  116. package/dist/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +0 -280
  117. package/dist/templates/cleargate-planning/.cleargate/scripts/prep_doc_refresh.mjs +0 -378
  118. package/dist/templates/cleargate-planning/.cleargate/scripts/prep_qa_context.mjs +0 -888
  119. package/dist/templates/cleargate-planning/.cleargate/scripts/run_script.sh +0 -209
  120. package/dist/templates/cleargate-planning/.cleargate/scripts/sprint_trends.mjs +0 -71
  121. package/dist/templates/cleargate-planning/.cleargate/scripts/state.schema.json +0 -127
  122. package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +0 -717
  123. package/dist/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +0 -27
  124. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +0 -261
  125. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +0 -210
  126. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +0 -190
  127. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_prep_qa_context.sh +0 -482
  128. package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +0 -327
  129. package/dist/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +0 -261
  130. package/dist/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +0 -246
  131. package/dist/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +0 -111
  132. package/dist/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +0 -184
  133. package/dist/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +0 -172
  134. package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +0 -126
  135. package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +0 -130
  136. package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +0 -137
  137. package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +0 -166
  138. package/dist/templates/cleargate-planning/.cleargate/templates/hotfix.md +0 -111
  139. package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +0 -122
  140. package/dist/templates/cleargate-planning/.cleargate/templates/sprint_context.md +0 -50
  141. package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +0 -224
  142. package/dist/templates/cleargate-planning/.cleargate/templates/story.md +0 -213
  143. package/dist/templates/cleargate-planning/CLAUDE.md +0 -66
  144. package/dist/templates/cleargate-planning/MANIFEST.json +0 -503
  145. package/dist/templates/synthesis/active-sprint.md +0 -30
  146. package/dist/templates/synthesis/open-gates.md +0 -38
  147. package/dist/templates/synthesis/product-state.md +0 -31
  148. package/dist/templates/synthesis/roadmap.md +0 -63
  149. package/dist/whoami-EANGN46Z.js.map +0 -1
@@ -1,172 +0,0 @@
1
- #!/usr/bin/env bash
2
- # write_dispatch.sh — write a dispatch marker JSON file before each Task() spawn.
3
- #
4
- # The token-ledger.sh SubagentStop hook reads this file (keyed by session_id) to
5
- # get explicit attribution (work_item_id + agent_type) rather than relying on
6
- # transcript-grep heuristics.
7
- #
8
- # Usage:
9
- # bash .cleargate/scripts/write_dispatch.sh <work_item_id> <agent_type>
10
- #
11
- # FALLBACK PATH (CR-026): The primary dispatch-marker path is the PreToolUse:Task hook
12
- # at `.claude/hooks/pre-tool-use-task.sh`, which auto-writes the marker on every Task()
13
- # spawn without manual orchestrator intervention. This script is retained for one-off
14
- # Architect dispatches or spawns whose Task() prompt does not contain a parseable
15
- # work-item marker. Use it only when the PreToolUse:Task hook cannot determine the
16
- # work_item_id from the prompt (e.g., a generic Architect spawn not tied to a sprint item).
17
- #
18
- # Args:
19
- # $1 work_item_id — e.g. STORY-020-02, CR-016, BUG-021
20
- # $2 agent_type — one of: developer|architect|qa|reporter|devops|cleargate-wiki-contradict
21
- #
22
- # Env (optional):
23
- # CLAUDE_SESSION_ID — session UUID of the orchestrator session
24
- # ORCHESTRATOR_PROJECT_DIR — override for repo root (cross-project routing)
25
- #
26
- # Exit codes:
27
- # 0 success
28
- # 1 missing required args
29
- # 2 no .active sprint sentinel found
30
- #
31
- # Output: .cleargate/sprint-runs/<sprint>/.dispatch-<session-id>.json
32
- # Log: .cleargate/hook-log/write_dispatch.log
33
-
34
- set -u
35
-
36
- # ─── Resolve repo root ──────────────────────────────────────────────────────
37
- REPO_ROOT="${ORCHESTRATOR_PROJECT_DIR:-${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}}"
38
- LOG_DIR="${REPO_ROOT}/.cleargate/hook-log"
39
- mkdir -p "${LOG_DIR}"
40
- LOG="${LOG_DIR}/write_dispatch.log"
41
-
42
- # ─── Validate args ──────────────────────────────────────────────────────────
43
- if [[ $# -lt 2 || -z "${1:-}" || -z "${2:-}" ]]; then
44
- printf '[%s] error: usage: write_dispatch.sh <work_item_id> <agent_type>\n' "$(date -u +%FT%TZ)" >> "${LOG}"
45
- printf 'Usage: write_dispatch.sh <work_item_id> <agent_type>\n' >&2
46
- exit 1
47
- fi
48
-
49
- WORK_ITEM_ID="${1}"
50
- AGENT_TYPE="${2}"
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
-
63
- # ─── Resolve active sprint ──────────────────────────────────────────────────
64
- ACTIVE_SENTINEL="${REPO_ROOT}/.cleargate/sprint-runs/.active"
65
- if [[ ! -f "${ACTIVE_SENTINEL}" ]]; then
66
- printf '[%s] error: no .active sentinel at %s\n' "$(date -u +%FT%TZ)" "${ACTIVE_SENTINEL}" >> "${LOG}"
67
- printf 'error: no active sprint sentinel at %s\n' "${ACTIVE_SENTINEL}" >&2
68
- exit 2
69
- fi
70
-
71
- SPRINT_ID="$(tr -d '[:space:]' < "${ACTIVE_SENTINEL}")"
72
- if [[ -z "${SPRINT_ID}" ]]; then
73
- printf '[%s] error: .active sentinel is empty\n' "$(date -u +%FT%TZ)" >> "${LOG}"
74
- printf 'error: .active sentinel is empty\n' >&2
75
- exit 2
76
- fi
77
-
78
- SPRINT_DIR="${REPO_ROOT}/.cleargate/sprint-runs/${SPRINT_ID}"
79
- mkdir -p "${SPRINT_DIR}"
80
-
81
- # ─── Fallback guard (CR-026 / STORY-043-09) ─────────────────────────────────
82
- # If the PreToolUse:Task hook already wrote a same-session auto-marker for THIS
83
- # EXACT SPAWN (same work_item_id + agent_type + session_id), this script is a
84
- # no-op fallback. Exit 0 without writing a duplicate marker.
85
- #
86
- # SPAWN-SCOPED: a stale auto-marker from a DIFFERENT prior spawn (different
87
- # work_item_id or different agent_type) must NOT trigger a skip — it is not a
88
- # duplicate for this spawn. Fail toward writing: when no exact same-spawn match
89
- # is found, always write. (A duplicate is harmless; a missing marker loses
90
- # attribution — bias toward writing.)
91
- if [[ -n "${CLAUDE_SESSION_ID:-}" ]]; then
92
- for _marker in "${SPRINT_DIR}"/.dispatch-*.json; do
93
- [[ -f "${_marker}" ]] || continue
94
- _session_id="$(jq -r '.session_id // ""' "${_marker}" 2>/dev/null || true)"
95
- _writer="$(jq -r '.writer // ""' "${_marker}" 2>/dev/null || true)"
96
- _work_item_id="$(jq -r '.work_item_id // ""' "${_marker}" 2>/dev/null || true)"
97
- _agent_type="$(jq -r '.agent_type // ""' "${_marker}" 2>/dev/null || true)"
98
- if [[ "${_session_id}" == "${CLAUDE_SESSION_ID}" \
99
- && "${_writer}" == pre-tool-use-task.sh* \
100
- && "${_work_item_id}" == "${WORK_ITEM_ID}" \
101
- && "${_agent_type}" == "${AGENT_TYPE}" ]]; then
102
- printf '[%s] fallback: same-spawn auto-marker present for session=%s work_item=%s agent=%s (writer=%s), no-op\n' \
103
- "$(date -u +%FT%TZ)" "${CLAUDE_SESSION_ID}" "${WORK_ITEM_ID}" "${AGENT_TYPE}" "${_writer}" >> "${LOG}"
104
- exit 0
105
- fi
106
- done
107
- fi
108
-
109
- # ─── Resolve session_id ─────────────────────────────────────────────────────
110
- SESSION_ID="${CLAUDE_SESSION_ID:-}"
111
-
112
- if [[ -z "${SESSION_ID}" ]]; then
113
- # Fall back to scanning the most recent transcript filename (UUID) under
114
- # ~/.claude/projects/-*-ClearGate/ pattern.
115
- TRANSCRIPT_DIR="${HOME}/.claude/projects"
116
- if [[ -d "${TRANSCRIPT_DIR}" ]]; then
117
- SESSION_ID="$(find "${TRANSCRIPT_DIR}" -maxdepth 2 -name '*.jsonl' 2>/dev/null \
118
- | sort -t '/' -k1 2>/dev/null | tail -1 \
119
- | xargs -I{} basename {} .jsonl 2>/dev/null || true)"
120
- fi
121
- fi
122
-
123
- if [[ -z "${SESSION_ID}" ]]; then
124
- # Final fallback: generate a pseudo-id from timestamp
125
- SESSION_ID="fallback-$(date -u +%s)"
126
- printf '[%s] warn: no CLAUDE_SESSION_ID and no transcript found; using %s\n' "$(date -u +%FT%TZ)" "${SESSION_ID}" >> "${LOG}"
127
- fi
128
-
129
- # ─── Resolve cleargate version ───────────────────────────────────────────────
130
- # Read from cleargate-cli/package.json if available; otherwise use "unknown"
131
- PKG_JSON="${REPO_ROOT}/cleargate-cli/package.json"
132
- CG_VERSION="unknown"
133
- if [[ -f "${PKG_JSON}" ]]; then
134
- CG_VERSION="$(jq -r '.version // "unknown"' "${PKG_JSON}" 2>/dev/null || echo "unknown")"
135
- fi
136
-
137
- # ─── Write dispatch file atomically ─────────────────────────────────────────
138
- # BUG-029 fix: uniquify the dispatch filename so that two parallel Task()
139
- # spawns from the same orchestrator session (same SESSION_ID) do NOT collide
140
- # on the same target path. Pattern matches pre-tool-use-task.sh:115.
141
- # Old: .dispatch-${SESSION_ID}.json ← second parallel write silently overwrites first.
142
- # New: .dispatch-${TS}-${PID}-${RAND}.json ← each spawn gets a distinct file.
143
- TS_EPOCH="$(date -u +%s)"
144
- DISPATCH_TARGET="${SPRINT_DIR}/.dispatch-${TS_EPOCH}-$$-${RANDOM}.json"
145
- SPAWNED_AT="$(date -u +%FT%TZ)"
146
-
147
- DISPATCH_JSON="$(jq -cn \
148
- --arg work_item_id "${WORK_ITEM_ID}" \
149
- --arg agent_type "${AGENT_TYPE}" \
150
- --arg spawned_at "${SPAWNED_AT}" \
151
- --arg session_id "${SESSION_ID}" \
152
- --arg writer "write_dispatch.sh@cleargate-${CG_VERSION}" \
153
- --arg run_id "${RUN_ID:-}" \
154
- '{
155
- work_item_id: $work_item_id,
156
- agent_type: $agent_type,
157
- spawned_at: $spawned_at,
158
- session_id: $session_id,
159
- writer: $writer
160
- }
161
- | if $run_id == "" then . else .run_id = $run_id end')"
162
-
163
- # Atomic write via mktemp + mv (rename is atomic on POSIX same-fs)
164
- TMP="$(mktemp "${SPRINT_DIR}/.dispatch-tmp-XXXXXX")"
165
- printf '%s\n' "${DISPATCH_JSON}" > "${TMP}"
166
- mv "${TMP}" "${DISPATCH_TARGET}"
167
-
168
- printf '[%s] wrote dispatch: sprint=%s session=%s work_item=%s agent=%s\n' \
169
- "${SPAWNED_AT}" "${SPRINT_ID}" "${SESSION_ID}" "${WORK_ITEM_ID}" "${AGENT_TYPE}" >> "${LOG}"
170
-
171
- printf '%s\n' "${DISPATCH_TARGET}"
172
- exit 0
@@ -1,126 +0,0 @@
1
- <instructions>
2
- FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-5.
3
- YAML Frontmatter: Bug ID, Parent Ref, Status, Severity, Reporter, Approved gate.
4
- §1 The Anomaly: Expected vs. Actual behavior.
5
- §2 Reproduction Protocol: Deterministic steps to recreate.
6
- §3 Evidence & Context: Raw logs, stack traces, payloads — no paraphrasing.
7
- §4 Execution Sandbox: Exact file paths to investigate. Restrict scope to prevent unrelated refactoring.
8
- §5 Verification Protocol: The failing test that proves the bug exists and proves the fix resolves it.
9
- Output location: .cleargate/delivery/pending-sync/BUG-{ID}.md
10
-
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
- - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
16
- - Summary ← §1 The Anomaly (repro)
17
- - Open Questions ← §0.5 Open Questions
18
- - Edge Cases ← §2 Impact (edge conditions)
19
- - Risks ← §2 Impact
20
- - Ambiguity ← bottom-of-doc ambiguity gate block
21
-
22
- Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
23
- Do NOT ask separately for push confirmation — Brief approval covers it.
24
-
25
- Do NOT output these instructions.
26
- </instructions>
27
-
28
- ---
29
- bug_id: "BUG-{ID}"
30
- parent_ref: "EPIC-{ID} | STORY-{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
34
- status: "Draft | Triaged | In Fix | Completed"
35
- severity: "P0-Critical | P1-High | P2-Medium | P3-Low"
36
- reporter: "{name}"
37
- approved: false
38
- context_source: "approved Epic / verified codebase grounding + recorded direct approval"
39
- created_at: "2026-04-17T00:00:00Z"
40
- updated_at: "2026-04-17T00:00:00Z"
41
- created_at_version: "strategy-phase-pre-init"
42
- updated_at_version: "strategy-phase-pre-init"
43
- server_pushed_at_version: null
44
- draft_tokens:
45
- input: null
46
- output: null
47
- cache_read: null
48
- cache_creation: null
49
- model: null
50
- sessions: []
51
- cached_gate_result:
52
- pass: null
53
- failing_criteria: []
54
- last_gate_check: null
55
- # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
56
- pushed_by: null # set by push: which user pushed
57
- pushed_at: null # set by push: ISO-8601 timestamp
58
- last_pulled_by: null # set by pull: which user pulled
59
- last_pulled_at: null # set by pull: ISO-8601 timestamp
60
- last_remote_update: null # set by pull: server's last-modified timestamp
61
- source: "local-authored" # flips to "remote-authored" on intake
62
- last_synced_status: null # required for conflict-detector; status at last sync
63
- last_synced_body_sha: null # sha256 of body at last sync
64
- ---
65
-
66
- # BUG-{ID}: {Bug Name}
67
-
68
- ### Open Questions
69
-
70
- > Populate during drafting. Resolve every entry before flipping ambiguity to 🟢.
71
-
72
- - **Question:** {edge case, contradiction, or missing detail}
73
- - **Recommended:** {agent's proposed answer}
74
- - **Human decision:** {populated during Brief review}
75
-
76
- ## 1. The Anomaly (Expected vs. Actual)
77
- **Expected Behavior:** {What the system should do under normal conditions.}
78
-
79
- **Actual Behavior:** {What it is doing right now.}
80
-
81
- ## 2. Reproduction Protocol
82
- *(AI agents need strict, deterministic steps. "If it can't be reproduced reliably, it can't be fixed safely.")*
83
-
84
- - Go to...
85
- - Click...
86
- - Observe...
87
-
88
- ## 3. Evidence & Context
89
- *(Provide the raw truth: stack traces, terminal errors, network payloads. Do not paraphrase.)*
90
-
91
- ```
92
- [Paste exact logs or error messages here]
93
- ```
94
-
95
- ## 4. Execution Sandbox (Suspected Blast Radius)
96
- *(Restrict the agent's focus to prevent unrelated refactoring.)*
97
-
98
- **Investigate / Modify:**
99
- - `src/...`
100
-
101
- ## 5. Verification Protocol (The Failing Test)
102
- *(The agent must write or run a specific test that proves the bug exists, then prove the fix resolves it.)*
103
-
104
- **Command:** `npm test ...`
105
-
106
- ---
107
-
108
- ## Context Source
109
-
110
- > Discovery audit. Populated from the approved Epic, verified codebase grounding, and recorded direct approval.
111
-
112
- **context_source:** {approved Epic / verified codebase grounding + recorded direct approval}
113
-
114
- ---
115
-
116
- ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
117
- **Current Status: 🔴 High Ambiguity**
118
-
119
- *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
120
-
121
- Requirements to pass to Green (Ready for Fix):
122
- - [ ] Reproduction steps are 100% deterministic.
123
- - [ ] Actual vs. Expected behavior is explicitly defined.
124
- - [ ] Raw error logs/evidence are attached.
125
- - [ ] Verification command (failing test) is provided.
126
- - [ ] `approved: true` is set in the YAML frontmatter.
@@ -1,130 +0,0 @@
1
- <instructions>
2
- FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
3
- YAML Frontmatter: CR ID, Parent Ref (Epic or Story being changed), Status, Approved gate.
4
- Use this template when CHANGING an existing feature. For net-new functionality, use story.md instead.
5
- §1 The Context Override: What to remove/forget + the new truth. AI agents hallucinate when old context conflicts with new requests.
6
- §2 Blast Radius & Invalidation: Which downstream items does this CR break? A CR acts as a "Gate Reset" on affected items.
7
- §3 Execution Sandbox: Exact file paths to modify.
8
- §4 Verification Protocol: How to confirm new logic works and old logic is fully evicted.
9
- Output location: .cleargate/delivery/pending-sync/CR-{ID}.md
10
-
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
- - Prior work ← cleargate-wiki-query result (cite [[IDs]] or write "none found")
16
- - Summary ← §1 The Context Override
17
- - Open Questions ← §0.5 Open Questions
18
- - Edge Cases ← §2 Blast Radius & Invalidation
19
- - Risks ← §2 Blast Radius (downstream invalidation = risk)
20
- - Ambiguity ← bottom-of-doc ambiguity gate block
21
-
22
- Halt for human review. When ambiguity reaches 🟢, proceed to call cleargate_push_item.
23
- Do NOT ask separately for push confirmation — Brief approval covers it.
24
-
25
- Do NOT output these instructions.
26
- </instructions>
27
-
28
- ---
29
- cr_id: "CR-{ID}"
30
- parent_ref: "EPIC-{ID} | STORY-{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
34
- status: "Draft | In Review | Approved | Completed"
35
- approved: false
36
- context_source: "approved Epic / verified codebase grounding + recorded direct approval"
37
- created_at: "2026-04-17T00:00:00Z"
38
- updated_at: "2026-04-17T00:00:00Z"
39
- created_at_version: "strategy-phase-pre-init"
40
- updated_at_version: "strategy-phase-pre-init"
41
- server_pushed_at_version: null
42
- draft_tokens:
43
- input: null
44
- output: null
45
- cache_read: null
46
- cache_creation: null
47
- model: null
48
- sessions: []
49
- cached_gate_result:
50
- pass: null
51
- failing_criteria: []
52
- last_gate_check: null
53
- # Sync attribution. Optional; stamped by `cleargate push` / `cleargate pull`.
54
- pushed_by: null # set by push: which user pushed
55
- pushed_at: null # set by push: ISO-8601 timestamp
56
- last_pulled_by: null # set by pull: which user pulled
57
- last_pulled_at: null # set by pull: ISO-8601 timestamp
58
- last_remote_update: null # set by pull: server's last-modified timestamp
59
- source: "local-authored" # flips to "remote-authored" on intake
60
- last_synced_status: null # required for conflict-detector; status at last sync
61
- last_synced_body_sha: null # sha256 of body at last sync
62
- ---
63
-
64
- # CR-{ID}: {Change Request Name}
65
-
66
- ## 0.5 Open Questions
67
-
68
- > Populate during drafting. Resolve every entry before flipping ambiguity to 🟢.
69
-
70
- - **Question:** {edge case, contradiction, or missing detail}
71
- - **Recommended:** {agent's proposed answer}
72
- - **Human decision:** {populated during Brief review}
73
-
74
- ## 1. The Context Override (Old vs. New)
75
- *(AI agents hallucinate when old context conflicts with new requests. Explicitly declare what to evict.)*
76
-
77
- **Obsolete Logic (What to Remove / Forget):**
78
- - {e.g., We no longer use Stripe for this flow.}
79
-
80
- **New Logic (The New Truth):**
81
- - {e.g., Route all payments through PayPal.}
82
-
83
- ## 2. Blast Radius & Invalidation
84
- *(A CR acts as a "Gate Reset" — all affected downstream items revert to 🔴 High Ambiguity.)*
85
-
86
- - [ ] Invalidate/Update Story: [Link]
87
- - [ ] Invalidate/Update Epic: [Link]
88
- - [ ] Database schema impacts? {Yes/No — describe}
89
-
90
- ## Existing Surfaces
91
-
92
- > L1 reuse audit. List source-tree implementations this CR extends or modifies. Cite file:line.
93
- > Cite paths with at least one '/' separator; root files use './name.ext'. Bare filenames and dotted code references are ignored.
94
-
95
- - **Surface:** `path/to/file.ext:NN` — {what it does today}
96
- - **Why this CR extends rather than rebuilds:** {one paragraph — required when the change names a capability that already exists somewhere in the tree}
97
-
98
- ## 3. Execution Sandbox
99
- *(Restrict the agent's scope to prevent unrelated refactoring.)*
100
-
101
- **Modify:**
102
- - `src/...`
103
-
104
- ## 4. Verification Protocol
105
- *(How do we confirm new logic works and old logic is completely removed?)*
106
-
107
- **Command/Test:** `npm test ...`
108
-
109
- ---
110
-
111
- ## Context Source
112
-
113
- > Discovery audit. Populated from the approved Epic, verified codebase grounding, and recorded direct approval.
114
-
115
- **context_source:** {approved Epic / verified codebase grounding + recorded direct approval}
116
-
117
- ---
118
-
119
- ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
120
- **Current Status: 🔴 High Ambiguity**
121
-
122
- *Evaluate each criterion against its literal text. If you substituted an interpretation, leave the box unchecked and surface the substitution in the Brief.*
123
-
124
- Requirements to pass to Green (Ready for Execution):
125
- - [ ] "Obsolete Logic" to be evicted is explicitly declared.
126
- - [ ] All impacted downstream Epics/Stories are identified and reverted to 🔴 High Ambiguity.
127
- - [ ] Execution Sandbox contains exact file paths.
128
- - [ ] Verification command is provided.
129
- - [ ] `approved: true` is set in the YAML frontmatter.
130
- - [ ] Existing Surfaces cites at least one source-tree path the CR extends.
@@ -1,137 +0,0 @@
1
- <instructions>
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).
35
-
36
- Do NOT output these instructions.
37
- </instructions>
38
-
39
- ---
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+
45
- remote_id: "{PM_TOOL_SPRINT_ID}"
46
- source_tool: "linear | jira"
47
- status: "Draft | Active | Completed"
48
- start_date: "{YYYY-MM-DD}"
49
- end_date: "{YYYY-MM-DD}"
50
- synced_at: "{ISO-8601 timestamp}"
51
- created_at: "2026-04-17T00:00:00Z"
52
- updated_at: "2026-04-17T00:00:00Z"
53
- created_at_version: "strategy-phase-pre-init"
54
- updated_at_version: "strategy-phase-pre-init"
55
- draft_tokens:
56
- input: null
57
- output: null
58
- cache_read: null
59
- cache_creation: null
60
- model: null
61
- sessions: []
62
- cached_gate_result:
63
- pass: null
64
- failing_criteria: []
65
- last_gate_check: null
66
- ---
67
-
68
- # SPRINT-{ID}: {Sprint Number / Name}
69
-
70
- ## 0. Stakeholder Brief
71
- *(Sponsor-readable summary. Pushed via cleargate push. Pair with §3 Risks below.)*
72
-
73
- - **Sprint Goal:** {1 sentence}
74
- - **Business Outcome:** {what the user / sponsor gets}
75
- - **Risks (top 3):** {bullet list, see §3 for full table}
76
- - **Metrics:** {expected impact / KPIs}
77
-
78
- ## Sprint Goal
79
- {One clear sentence describing the primary objective of this sprint, as defined in the PM tool.}
80
-
81
- ## 1. Consolidated Deliverables
82
- *(Pulled from PM tool. IDs are the remote PM entity IDs.)*
83
-
84
- | Story ID | Title | Lane | Milestone | Parallel? | Bounce Exposure |
85
- |---|---|---|---|---|---|
86
- | `{STORY-NNN-NN}` | {Title} | standard / fast | M{N} | y / n | low / med / high |
87
-
88
- ## 2. Execution Strategy
89
- *(Written by Architect during Sprint Design Review. Required before sprint start.)*
90
-
91
- ### 2.1 Phase Plan
92
- {Parallel vs sequential story groups. List which stories run concurrently in each wave and which must be serialized.}
93
- Example:
94
- - Wave 1 (sequential): STORY-NNN-01 → STORY-NNN-02 (02 depends on 01's schema)
95
- - Wave 2 (parallel): STORY-NNN-03 ‖ STORY-NNN-04
96
-
97
- ### 2.2 Merge Ordering (Shared-File Surface Analysis)
98
- {List files touched by more than one story. For each shared file, specify which story lands first and why.}
99
-
100
- | Shared File | Stories Touching It | Merge Order | Rationale |
101
- |---|---|---|---|
102
- | `.cleargate/knowledge/cleargate-enforcement.md` | STORY-NNN-01, STORY-NNN-02 | 01 → 02 | 01 adds §2; 02 amends §2 |
103
-
104
- ### 2.3 Shared-Surface Warnings
105
- {Explicit conflict risks. One bullet per risk. Cite file + story pair.}
106
- - None identified. (Replace with actual warnings if applicable.)
107
-
108
- ### 2.4 Lane Audit
109
- {Architect populates one row per fast-lane story during Sprint Design Review. Empty by default — rows added only for non-`standard` lanes.}
110
-
111
- | Story | Lane | Rationale (≤80 chars) |
112
- |---|---|---|
113
- | `STORY-NNN-NN` | fast | <one-line rationale> |
114
-
115
- ### 2.5 ADR-Conflict Flags
116
- {Any story whose implementation conflicts with an Architectural Decision Record in `.cleargate/knowledge/` or prior sprint decisions. One bullet per flag.}
117
- - None identified. (Replace with actual flags if applicable.)
118
-
119
- ## Risks & Dependencies
120
- *(As defined in the PM tool.)*
121
-
122
- | Risk | Mitigation |
123
- |---|---|
124
- | {Description} | {Action} |
125
-
126
- ## Metrics & Metadata
127
- - **Expected Impact:** {e.g., performance improvement %, specific user outcome}
128
- - **Priority Alignment:** {Notes on prioritization from the PM tool}
129
-
130
- ---
131
-
132
- ## Execution Guidelines (Local Annotation — Not Pushed)
133
- *(Vibe Coder: Fill this in locally to direct Claude Code during the Execution Phase. This section never syncs to the PM tool.)*
134
-
135
- - **Starting Point:** {Which deliverable to tackle first and why}
136
- - **Relevant Context:** {Key documentation or codebase areas to reference}
137
- - **Constraints:** {Specific technical boundaries or "out of scope" rules for this sprint}