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.
- package/CHANGELOG.md +16 -0
- package/dist/MANIFEST.json +71 -15
- package/dist/admin-api/index.cjs +0 -1
- package/dist/admin-api/index.js +1 -2
- package/dist/auth/factory.cjs +0 -1
- package/dist/auth/factory.js +2 -3
- package/dist/auth/require-token.cjs +0 -1
- package/dist/auth/require-token.js +1 -2
- package/dist/auth/token-store.cjs +0 -1
- package/dist/auth/token-store.js +1 -2
- package/dist/{bootstrap-root-QKSA5V75.js → bootstrap-root-2H5HVTCC.js} +1 -2
- package/dist/{chunk-PDE37WFQ.js → chunk-A7MSQUU7.js} +2 -3
- package/dist/{chunk-BTSZOEWC.js → chunk-P6KEDAK2.js} +0 -1
- package/dist/{chunk-E3X7IE5E.js → chunk-PY6FHGV5.js} +1 -2
- package/dist/{chunk-5DI2Z3C2.js → chunk-Y53ZZYYU.js} +1 -2
- package/dist/cli.cjs +1564 -1414
- package/dist/cli.js +1514 -1364
- package/dist/lib/ledger.cjs +0 -1
- package/dist/lib/ledger.js +1 -2
- package/dist/lib/lifecycle-reconcile.cjs +0 -1
- package/dist/lib/lifecycle-reconcile.js +2 -3
- package/dist/{whoami-EANGN46Z.js → whoami-JKQQPABQ.js} +3 -4
- package/package.json +4 -3
- package/templates/cleargate-planning/.claude/agents/architect.md +4 -2
- package/templates/cleargate-planning/.claude/agents/developer.md +4 -11
- package/templates/cleargate-planning/.claude/agents/qa.md +14 -6
- package/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +2 -2
- package/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +19 -1
- package/templates/cleargate-planning/.cleargate/config.example.yml +16 -0
- package/templates/cleargate-planning/.cleargate/scripts/close_sprint.deferred-verify.red.node.test.ts +245 -0
- package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +227 -0
- package/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +5 -4
- package/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +75 -2
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +48 -0
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +57 -1
- package/templates/cleargate-planning/.cleargate/scripts/provision_worktree_config.sh +155 -0
- package/templates/cleargate-planning/.cleargate/scripts/qa_red_lint.mjs +380 -0
- package/templates/cleargate-planning/.cleargate/scripts/run_script.sh +34 -1
- package/templates/cleargate-planning/.cleargate/scripts/test/cr077_eviction.red.sh +113 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/cr078_init.test.sh +309 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/cr079_provision.red.sh +262 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/cr080_wrapper.test.sh +177 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/cr081_qa_red_lint.red.sh +348 -0
- package/templates/cleargate-planning/.cleargate/sprint-runs/_off-sprint/.session-totals.json +1 -0
- package/templates/cleargate-planning/.cleargate/sprint-runs/_off-sprint/token-ledger.jsonl +27 -0
- package/templates/cleargate-planning/.cleargate/templates/sprint_context.md +17 -0
- package/templates/cleargate-planning/.cleargate/templates/story.md +1 -0
- package/templates/cleargate-planning/MANIFEST.json +71 -15
- package/dist/admin-api/index.cjs.map +0 -1
- package/dist/admin-api/index.js.map +0 -1
- package/dist/auth/factory.cjs.map +0 -1
- package/dist/auth/factory.js.map +0 -1
- package/dist/auth/require-token.cjs.map +0 -1
- package/dist/auth/require-token.js.map +0 -1
- package/dist/auth/token-store.cjs.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/bootstrap-root-QKSA5V75.js.map +0 -1
- package/dist/chunk-5DI2Z3C2.js.map +0 -1
- package/dist/chunk-BTSZOEWC.js.map +0 -1
- package/dist/chunk-E3X7IE5E.js.map +0 -1
- package/dist/chunk-PDE37WFQ.js.map +0 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/lib/ledger.cjs.map +0 -1
- package/dist/lib/ledger.js.map +0 -1
- package/dist/lib/lifecycle-reconcile.cjs.map +0 -1
- package/dist/lib/lifecycle-reconcile.js.map +0 -1
- package/dist/templates/cleargate-planning/.claude/agents/architect-reader.md +0 -61
- package/dist/templates/cleargate-planning/.claude/agents/architect-synth.md +0 -124
- package/dist/templates/cleargate-planning/.claude/agents/architect.md +0 -230
- package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-contradict.md +0 -108
- package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +0 -194
- package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +0 -261
- package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-query.md +0 -143
- package/dist/templates/cleargate-planning/.claude/agents/developer.md +0 -185
- package/dist/templates/cleargate-planning/.claude/agents/devops.md +0 -257
- package/dist/templates/cleargate-planning/.claude/agents/qa.md +0 -171
- package/dist/templates/cleargate-planning/.claude/agents/reporter.md +0 -274
- package/dist/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +0 -209
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +0 -33
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +0 -58
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit.sh +0 -19
- package/dist/templates/cleargate-planning/.claude/hooks/pre-edit-gate.sh +0 -162
- package/dist/templates/cleargate-planning/.claude/hooks/pre-tool-use-autonomy.sh +0 -58
- package/dist/templates/cleargate-planning/.claude/hooks/pre-tool-use-task.sh +0 -148
- package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +0 -75
- package/dist/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +0 -43
- package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +0 -590
- package/dist/templates/cleargate-planning/.claude/settings.json +0 -68
- package/dist/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +0 -102
- package/dist/templates/cleargate-planning/.claude/skills/sprint-execution/SKILL.md +0 -742
- package/dist/templates/cleargate-planning/.cleargate/FLASHCARD.md +0 -7
- package/dist/templates/cleargate-planning/.cleargate/config.example.yml +0 -67
- package/dist/templates/cleargate-planning/.cleargate/config.yml +0 -18
- package/dist/templates/cleargate-planning/.cleargate/delivery/archive/.gitkeep +0 -0
- package/dist/templates/cleargate-planning/.cleargate/delivery/pending-sync/.gitkeep +0 -0
- package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-enforcement.md +0 -551
- package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +0 -878
- package/dist/templates/cleargate-planning/.cleargate/knowledge/mid-sprint-triage-rubric.md +0 -160
- package/dist/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +0 -213
- package/dist/templates/cleargate-planning/.cleargate/knowledge/sprint-closeout-checklist.md +0 -71
- package/dist/templates/cleargate-planning/.cleargate/scripts/_migrate-schema-v3.mjs +0 -120
- package/dist/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +0 -265
- package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +0 -1012
- package/dist/templates/cleargate-planning/.cleargate/scripts/collision_surface.sh +0 -114
- package/dist/templates/cleargate-planning/.cleargate/scripts/constants.mjs +0 -62
- package/dist/templates/cleargate-planning/.cleargate/scripts/dedupe_frontmatter.mjs +0 -219
- package/dist/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +0 -320
- package/dist/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +0 -15
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +0 -38
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +0 -240
- package/dist/templates/cleargate-planning/.cleargate/scripts/launch_wave.mjs +0 -341
- package/dist/templates/cleargate-planning/.cleargate/scripts/lib/report-filename.mjs +0 -54
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +0 -206
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +0 -371
- package/dist/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +0 -280
- package/dist/templates/cleargate-planning/.cleargate/scripts/prep_doc_refresh.mjs +0 -378
- package/dist/templates/cleargate-planning/.cleargate/scripts/prep_qa_context.mjs +0 -888
- package/dist/templates/cleargate-planning/.cleargate/scripts/run_script.sh +0 -209
- package/dist/templates/cleargate-planning/.cleargate/scripts/sprint_trends.mjs +0 -71
- package/dist/templates/cleargate-planning/.cleargate/scripts/state.schema.json +0 -127
- package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +0 -717
- package/dist/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +0 -27
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +0 -261
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +0 -210
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +0 -190
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_prep_qa_context.sh +0 -482
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +0 -327
- package/dist/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +0 -261
- package/dist/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +0 -246
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +0 -111
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +0 -184
- package/dist/templates/cleargate-planning/.cleargate/scripts/write_dispatch.sh +0 -172
- package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +0 -126
- package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +0 -130
- package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +0 -137
- package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +0 -166
- package/dist/templates/cleargate-planning/.cleargate/templates/hotfix.md +0 -111
- package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +0 -122
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_context.md +0 -50
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +0 -224
- package/dist/templates/cleargate-planning/.cleargate/templates/story.md +0 -213
- package/dist/templates/cleargate-planning/CLAUDE.md +0 -66
- package/dist/templates/cleargate-planning/MANIFEST.json +0 -503
- package/dist/templates/synthesis/active-sprint.md +0 -30
- package/dist/templates/synthesis/open-gates.md +0 -38
- package/dist/templates/synthesis/product-state.md +0 -31
- package/dist/templates/synthesis/roadmap.md +0 -63
- package/dist/whoami-EANGN46Z.js.map +0 -1
|
@@ -1,742 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sprint-execution
|
|
3
|
-
description: |
|
|
4
|
-
Use to orchestrate the five-dispatch sprint loop end-to-end — Architect → QA-Red →
|
|
5
|
-
Developer → QA-Verify → Reporter — across one ClearGate sprint. Activates from sprint kickoff
|
|
6
|
-
(preflight + cut sprint branch + state init) through per-story execution
|
|
7
|
-
(worktree → dev → QA → flashcard gate → merge) into walkthrough and Gate-4 close.
|
|
8
|
-
Triggers: SessionStart banner mentioning an active sprint; explicit user phrases
|
|
9
|
-
"start the sprint", "run the sprint", "execute the sprint", "begin sprint
|
|
10
|
-
execution", "kick off SPRINT-NN", "run STORY-NNN-NN"; CLI directives ending
|
|
11
|
-
with `→ Load skill: sprint-execution`. The skill does not draft work items, run
|
|
12
|
-
triage, or manage planning — those stay in always-on CLAUDE.md surface.
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
# Sprint Execution — The Playbook
|
|
16
|
-
|
|
17
|
-
You are the **Orchestrator**. You read this playbook top to bottom once when a sprint becomes active, then execute it. You never write production code. You delegate every implementation step to the four execution agents (`architect`, `developer`, `qa`, `reporter`) by spawning them via the `Agent` tool with the matching `subagent_type`.
|
|
18
|
-
|
|
19
|
-
This skill is the **execution-time** layer. Triage, drafting, and pre-sprint planning stay in CLAUDE.md and `cleargate-protocol.md`. Read those before deciding to load this skill.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 0. When This Skill Loads
|
|
24
|
-
|
|
25
|
-
Three explicit load points (belt-and-suspenders — the SKILL description handles the rest):
|
|
26
|
-
|
|
27
|
-
1. **SessionStart banner.** When the doctor banner reports `Active sprint: SPRINT-NN`, the skill auto-loads. (Banner emitted by `.claude/hooks/session-start.sh`; `.cleargate/sprint-runs/.active` is the sentinel file.)
|
|
28
|
-
2. **CLI directive.** Any `cleargate sprint *` command finishing with the line `→ Load skill: sprint-execution` instructs the orchestrator to load this skill before continuing.
|
|
29
|
-
3. **Natural-language triggers.** "start the sprint", "kick off SPRINT-NN", "run the sprint", "execute the loop", "run STORY-NNN-NN" → load the skill, do not improvise.
|
|
30
|
-
|
|
31
|
-
If you are running a sprint and you have not loaded this skill yet, **stop and load it now**. Do not orchestrate from memory.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 0.5 Goal-First Execution
|
|
36
|
-
|
|
37
|
-
**The sprint goal is the success criterion — not the count of merged stories.** A sprint where every story passes QA but the goal is not met is a failed sprint. Read `sprint_goal:` from the active sprint plan's frontmatter (or §1 if unstructured) at kickoff and treat it as the anchor for every decision the orchestrator makes.
|
|
38
|
-
|
|
39
|
-
Five touchpoints where the goal is the tiebreaker:
|
|
40
|
-
|
|
41
|
-
1. **Kickoff (§A.5).** Surface the sprint goal verbatim in chat before any Architect dispatch. State it as the explicit acceptance condition for the sprint.
|
|
42
|
-
2. **Architect dispatch (§B).** Pass the sprint goal in the dispatch prompt. The milestone plan should reference how each story advances the goal, not only what files it changes.
|
|
43
|
-
3. **Mid-sprint CR triage (§C.10 rubric → §C.11 routing).** When classifying `CR:scope-change`, evaluate goal alignment before quarantining. If the new requirement is critical to the goal, escalate to the human with "this may need to land THIS sprint, not the next."
|
|
44
|
-
4. **Escalation (§8).** When `qa_bounces ≥ 3`, `arch_bounces ≥ 3`, or 3 circuit-breaker hits flip a story to `Escalated`, frame the human-decision question through the goal lens: "Drop this story → goal still met? Re-approach → goal still met by sprint end?"
|
|
45
|
-
5. **Walkthrough + Reporter brief (§D, §E.2).** Walkthrough invitation leads with the goal, not the feature checklist. Reporter brief MUST include a goal-achievement verdict — `met / partial / missed` — as a first-class signal in the close-gate Brief.
|
|
46
|
-
|
|
47
|
-
**What goal-first is NOT:**
|
|
48
|
-
- Not authority to skip stories the orchestrator deems "off-goal" — splits and merges are decomposition-time decisions, never mid-sprint.
|
|
49
|
-
- Not authority to rewrite the goal mid-flight — that requires a CR or a sprint reset.
|
|
50
|
-
- Not a license to relax acceptance criteria — story Gherkin still passes verbatim.
|
|
51
|
-
|
|
52
|
-
It is pure framing: surface deviations from the goal as first-class events, not afterthoughts.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 1. Agent Roster + Dispatch Contract
|
|
57
|
-
|
|
58
|
-
| Subagent | Model | Spawn point | Output artifact |
|
|
59
|
-
|---|---|---|---|
|
|
60
|
-
| `architect` | opus | (a) Sprint Design Review pre-confirm, (b) per-milestone plan | `sprint-runs/<id>/plans/M<N>.md` (per milestone); markdown block §2 (design review) |
|
|
61
|
-
| `developer` | sonnet | One per story, inside its worktree | One commit `feat(<epic>): STORY-NNN-NN <desc>` + `STORY-NNN-NN-dev.md` report |
|
|
62
|
-
| `qa` | sonnet | After Developer reports `STATUS=done` | `STORY-NNN-NN-qa.md` report (no code edits) |
|
|
63
|
-
| `devops` | sonnet | Per-story, after QA-Verify + Architect post-flight | One merge commit (no-ff) + `STORY-NNN-NN-devops.md` report |
|
|
64
|
-
| `reporter` | sonnet | Once at sprint close, after all stories merged + walkthrough done | `sprint-runs/<id>/SPRINT-<#>_REPORT.md` |
|
|
65
|
-
|
|
66
|
-
**Registration constraint:** The Claude Code agent registry caches at session start. If an agent `.md` file under `.claude/agents/` was added or modified after the current session began, `Agent(subagent_type=<name>)` will return "Agent type '<name>' not found" even though the file exists. Fix: restart the Claude Code session. Verify `devops` reachable at sprint preflight (§A.1 check 6). If unavailable mid-sprint, use the §C.7 DevOps Escape Hatch.
|
|
67
|
-
|
|
68
|
-
### Wall-clock budgets
|
|
69
|
-
|
|
70
|
-
Each agent dispatch has a target duration. Note the start time before each `Agent` spawn; after the call returns, compare elapsed against the budget. Ran-long stories get flagged in sprint §4 Execution Log even on success.
|
|
71
|
-
|
|
72
|
-
| Agent | Budget | Notes |
|
|
73
|
-
|---|---|---|
|
|
74
|
-
| `architect` (per milestone) | ≤ 10 min | Plan-only output; long runs usually mean too many stories in the milestone |
|
|
75
|
-
| `developer` (per story) | ≤ 30 min | Includes typecheck + tests in the worktree; long runs near the circuit-breaker threshold |
|
|
76
|
-
| `qa` (per story) | ≤ 15 min | Read + re-run gates; should not edit code |
|
|
77
|
-
| `devops` (per story) | ≤ 5 min | Mechanical work only — merge, teardown, state; long runs indicate git/npm issue |
|
|
78
|
-
| `reporter` (per sprint) | ≤ 20 min | Single file write; long runs mean ledger reconciliation issues |
|
|
79
|
-
|
|
80
|
-
If a Task call has been pending for **>2× the budget** with no visible progress, surface it to the human and offer to interrupt. There is no automatic stall detection — the parent session blocks on `Agent` calls and cannot poll mid-run. The human's interrupt is the only reliable kill path until ambient watcher infra exists.
|
|
81
|
-
|
|
82
|
-
### Dispatch marker — written automatically before every spawn (fallback only)
|
|
83
|
-
|
|
84
|
-
The token-ledger hook attributes tokens by reading `.cleargate/sprint-runs/<sprint>/.dispatch-<session-id>.json`. The **primary path** is the PreToolUse:Task hook (`pre-tool-use-task.sh`), which auto-writes the marker on every `Agent` call without manual orchestrator intervention. The manual script below is a **fallback** for spawns the auto-hook cannot attribute (e.g. a generic Architect dispatch whose Task() prompt lacks a parseable work-item marker):
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
bash .cleargate/scripts/write_dispatch.sh <work_item_id> <agent_type>
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- `<work_item_id>`: e.g. `STORY-020-02`, `CR-016`, `BUG-021`. For the Reporter at sprint close use the sprint ID (e.g. `SPRINT-19`).
|
|
91
|
-
- `<agent_type>`: exact string — `developer | architect | qa | reporter | devops | cleargate-wiki-contradict`.
|
|
92
|
-
|
|
93
|
-
The script is idempotent: if a same-session auto-marker (written by `pre-tool-use-task.sh`) already exists for the current session, it exits 0 without writing a duplicate. Omitting the manual call when the auto-hook fires is correct; calling it when unsure is safe (the guard prevents duplication). The hook deletes the marker after consumption — write fresh per dispatch if needed.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 2. v1 / v2 Mode Switch
|
|
98
|
-
|
|
99
|
-
Every step below is gated by the active sprint's `execution_mode:` frontmatter:
|
|
100
|
-
|
|
101
|
-
| Mode | Effect |
|
|
102
|
-
|---|---|
|
|
103
|
-
| `v1` | All §§ rules in `cleargate-enforcement.md` are advisory — document workflow; no script enforcement. Rework counters, flashcard gate, surface contract, etc. are informational. |
|
|
104
|
-
| `v2` | All §§ rules are mandatory. Hooks block on violations. Worktree isolation, pre-gate scans, file-surface contract, flashcard gate, sprint close — all enforced. |
|
|
105
|
-
|
|
106
|
-
Default is `v1`. Read the field before spawning Developer/QA/Reporter. If absent, treat as `v1`. **Do not infer mode from sprint number — read the frontmatter.**
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## 3. Phase A — Sprint Kickoff (Ready → Active)
|
|
111
|
-
|
|
112
|
-
Run this sequence exactly once, when the human says "start sprint NN" or equivalent. Halt on any failure; do not improvise around a failed gate.
|
|
113
|
-
|
|
114
|
-
### A.1 Sprint Execution Gate (Gate 3) — preflight
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
cleargate sprint preflight <sprint-id>
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Six checks, all must pass:
|
|
121
|
-
|
|
122
|
-
1. Previous sprint `sprint_status: "Completed"` in `state.json`.
|
|
123
|
-
2. No leftover worktrees — `git worktree list` must not contain `.worktrees/STORY-*`.
|
|
124
|
-
3. Sprint branch ref free — `git show-ref refs/heads/sprint/S-NN` returns nothing.
|
|
125
|
-
4. `main` clean — `git status --porcelain` empty.
|
|
126
|
-
5. Per-item readiness gates pass — every work-item ID in §1 Consolidated Deliverables has fresh `cached_gate_result.pass: true` (or terminal status). Under `execution_mode: v2` a failing item hard-blocks; under `v1` it warns. Failure punch-list names each item + its failing criteria.
|
|
127
|
-
6. **Verify `devops` subagent reachable** — attempt `Agent(subagent_type=devops, prompt: "echo preflight-check")` immediately after session start. If it returns "Agent type 'devops' not found", halt and ask the human to restart the Claude Code session; do NOT proceed under assumption the escape hatch will cover every merge. This check is manual (not enforced by `cleargate sprint preflight`); document result in sprint §4 Execution Log.
|
|
128
|
-
|
|
129
|
-
On failure, surface the punch list verbatim and halt. Per-item resolution:
|
|
130
|
-
|
|
131
|
-
- Prev sprint not closed → run sprint close on prev first.
|
|
132
|
-
- Leftover worktree → `git worktree remove` if abandoned, otherwise merge.
|
|
133
|
-
- Branch ref exists → investigate; force-deletion only with explicit human approval.
|
|
134
|
-
- Dirty main → human commits/stashes/discards. **Never `git reset --hard` or stash without explicit human approval.**
|
|
135
|
-
- Per-item gate fail → run `cleargate gate check <file> -v` for the named item; fix the failing criterion (e.g., populate `context_source`, resolve TBDs); re-run preflight.
|
|
136
|
-
- Devops unreachable → restart Claude Code session; re-run all 6 preflight checks.
|
|
137
|
-
|
|
138
|
-
### A.2 Cut sprint branch
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
git checkout -b sprint/S-NN main
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Sprint branch is **never committed to directly**. All work lands via story-branch merges.
|
|
145
|
-
|
|
146
|
-
### A.3 Initialize sprint state
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
node .cleargate/scripts/init_sprint.mjs SPRINT-NN
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
This writes `.cleargate/sprint-runs/SPRINT-NN/state.json` and flips `.cleargate/sprint-runs/.active` to `SPRINT-NN`. Without `state.json` the lane router, dispatch hook, and close pipeline all fail.
|
|
153
|
-
|
|
154
|
-
`init_sprint.mjs` also writes `<sprintDir>/sprint-context.md` from `.cleargate/templates/sprint_context.md`, populated with `sprint_id` + goal (extracted from sprint plan §0 `- **Sprint Goal:** …` bullet, or placeholder if absent) + active CR list. Every Dev/QA/Architect/DevOps dispatch reads this file as preflight (see §B + §C contracts + agent prompts `## Preflight`).
|
|
155
|
-
|
|
156
|
-
### A.4 Architect Sprint Design Review (v2 only)
|
|
157
|
-
|
|
158
|
-
Mandatory under `execution_mode: v2`; optional but encouraged under `v1`. Spawn the Architect with all candidate stories' §3 Implementation Guides + ADRs + flashcards + sprint plan path:
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
Task instruction: "SPRINT DESIGN REVIEW — write Sprint Plan §2 Execution Strategy.
|
|
162
|
-
You have WRITE ACCESS to Sprint Plan §2 ONLY. Produce §§2.1–2.4 (Phase Plan,
|
|
163
|
-
Merge Ordering, Shared-Surface Warnings, ADR-Conflict Flags) plus §2.4 Lane Audit."
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Architect returns a markdown block; you insert it into the sprint plan file. Then halt and ask the human to confirm the sprint plan before any story executes.
|
|
167
|
-
|
|
168
|
-
### A.5 Flip sprint status
|
|
169
|
-
|
|
170
|
-
After human confirms, update sprint frontmatter `status: Active` (via `cleargate stamp` after the edit).
|
|
171
|
-
|
|
172
|
-
> 🎯 **Goal check.** Before the first Architect dispatch, surface the sprint goal verbatim from the plan's `sprint_goal:` frontmatter (or §1 if unstructured) in chat: *"Sprint goal: <verbatim>. Success = this is met by close. Stories are the means; this is the end."* All subsequent halts and decisions reference back to this line.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## 4. Phase B — Per-Milestone Architect Plan
|
|
177
|
-
|
|
178
|
-
Before any Developer dispatches in a milestone, spawn the Architect once for the whole milestone:
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
182
|
-
bash .cleargate/scripts/write_dispatch.sh M<N> architect
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Then `Agent(subagent_type=architect, ...)` with the milestone story IDs and instruction to write `.cleargate/sprint-runs/<sprint-id>/plans/M<N>.md`.
|
|
186
|
-
|
|
187
|
-
**Skip per-milestone Architect for `lane: fast` stories** — they dispatch to Developer without a plan, per the lane contract (see `.claude/agents/architect.md` Lane Classification).
|
|
188
|
-
|
|
189
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action (Sprint Goal + Cross-Cutting Rules + Active CRs sections constrain every decision).
|
|
190
|
-
|
|
191
|
-
> 🎯 **Goal check.** Pass the sprint goal verbatim in the Architect's dispatch prompt. The plan should explicitly tie each story to the goal under "Per-story blueprint" — e.g. *"STORY-NNN-NN advances goal by <one sentence>"*. Plans that don't reference the goal go back to the Architect with a re-dispatch.
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## 5. Phase C — Per-Story Execution Loop
|
|
196
|
-
|
|
197
|
-
Run this loop **per story**, in the order the milestone plan declares (parallel waves vs sequential chains). Each iteration: Worktree → **QA-Red** → **TPV (Test Pattern Validation, Architect-only)** → Developer → QA-Verify → (Architect pass for `lane: standard` v2 only) → Merge → Flashcard Gate.
|
|
198
|
-
|
|
199
|
-
> **Naming note.** State-machine values (`Bouncing`, `Ready to Bounce`), `state.json` counter fields (`qa_bounces`, `arch_bounces`), and script names (`validate_bounce_readiness.mjs`) retain the legacy "bounce" term because they are code-bound. The narrative in this skill uses "execution loop", "story cycle", and "rework" to describe the same mechanics.
|
|
200
|
-
|
|
201
|
-
### C.0 Execution mode — serial loop vs parallel waves (kill-switch)
|
|
202
|
-
|
|
203
|
-
Before running any story, read the sprint frontmatter `execution_mode` and pick the loop:
|
|
204
|
-
|
|
205
|
-
| `execution_mode` | Override | Loop |
|
|
206
|
-
|---|---|---|
|
|
207
|
-
| `v2-serial` (or `v1`/`v2`) | — | **Serial** — run §C.1–§C.9 below, one story at a time, in milestone-plan order. |
|
|
208
|
-
| `v2-parallel` | `CLEARGATE_PARALLEL_WAVES=off` set in the session env | **Serial** — kill-switch active; revert to the serial loop. |
|
|
209
|
-
| `v2-parallel` | (none) | **Parallel waves** — launch each Architect-planned wave via `launch_wave.mjs` (§C.0.1). |
|
|
210
|
-
|
|
211
|
-
**Kill-switch contract (zero behavior change).** Either revert path — `execution_mode: v2-serial` OR `CLEARGATE_PARALLEL_WAVES=off` — runs **today's serial five-dispatch Phase C loop** (§C.1–§C.9) verbatim, with **zero behavior change**: no `launch_wave.mjs` invocation appears, and every story executes through the existing Worktree → QA-Red → TPV → Developer → QA-Verify → Architect → Merge → Flashcard sequence one at a time. The parallel-wave code never runs on the kill-switch path. This guarantee is what lets the next sprint adopt `v2-parallel` and instantly fall back if a wave misbehaves. The selector function is `shouldRunParallel(execution_mode, env)` in `.cleargate/scripts/launch_wave.mjs`.
|
|
212
|
-
|
|
213
|
-
> **SPRINT-32 note.** This sprint ships the parallel-wave capability but runs SERIALLY (serial loop above). The §C.0.1 wave mechanics below ship for the NEXT (self-hosting) sprint. Full contract: protocol §23 "Parallel-Wave Execution Contract".
|
|
214
|
-
|
|
215
|
-
#### C.0.1 Parallel-wave launch (`execution_mode: v2-parallel`)
|
|
216
|
-
|
|
217
|
-
When parallel waves are active, the Orchestrator runs each wave from the Architect's `waves.json` (produced by the planning workflow, STORY-033-03) as one `parallel()` Workflow of worktree-isolated per-story **segments**, then consolidates at a serial **barrier**:
|
|
218
|
-
|
|
219
|
-
1. **Pre-launch (worktrees).** Pre-create each wave story's worktree **serially** via `git worktree add .worktrees/STORY-X -b story/STORY-X sprint/S-NN` (ClearGate-managed worktrees — NOT the Workflow tool's `isolation:'worktree'`, which checks out tracked-files-only off the wrong base; spike decision 2). Serial pre-creation avoids concurrent `git worktree add` racing the repo index. The flashcard **WRITE-gate** suppression (`SKIP_FLASHCARD_GATE=1`, inherited by every segment because per-thunk child env is not settable — spike Q5; reading is unaffected) is **owned by `launch_wave.mjs`, not the Orchestrator** (BUG-034): `launchWave()` snapshots the prior value, sets `=1` before `parallel()`, and restores the exact prior value in a `try/finally`. The Orchestrator MUST NOT set or restore this var by hand — doing so would double-manage it and reintroduce the leak.
|
|
220
|
-
|
|
221
|
-
2. **Launch.** Invoke `launch_wave.mjs`, which drives `parallel()` over one segment per story. Each segment mints a stable, distinct `RUN_ID` (`mintRunId(storyId, sprintId)`), runs the linear pipeline (QA-Red → TPV → Developer → QA-Verify → Architect post-flight) inside its OWN `.worktrees/STORY-X`, accumulates `tokens` from the outset, and **RETURNS a schema-typed verdict** — it never blocks. A §22 true-blocker becomes a `BLOCKED` verdict carrying `blocker.type` (one of the five §22 kinds), **never an `AskUserQuestion`** (workflows cannot halt for a human mid-run).
|
|
222
|
-
|
|
223
|
-
3. **Barrier — validate.** Run `validateVerdicts(verdicts)` (exported from `launch_wave.mjs`). It accepts a well-formed array and raises a validation Error **naming the offending `storyId`** on a malformed verdict (missing required field, unknown discriminant, or non-GREEN without `blocker`). The named segment is marked ESCALATED and gets **no ledger row**; sibling GREEN verdicts consolidate normally.
|
|
224
|
-
|
|
225
|
-
4. **Barrier — flashcards (between-wave gate, §C.9).** Process every segment's `flashcards_flagged[]` and write the `.processed-<hash>` markers **before launching the next wave** — see §C.9.
|
|
226
|
-
|
|
227
|
-
5. **Barrier — serial merge (§C.7).** For each GREEN story in turn, DevOps merges `story/STORY-X` to `sprint/S-NN` — **one worktree at a time, never two concurrently** — see §C.7.
|
|
228
|
-
|
|
229
|
-
6. **Barrier — advance.** The `SKIP_FLASHCARD_GATE` value was ALREADY restored by `launch_wave.mjs`'s `finally` the moment `launchWave()` returned or threw (BUG-034 — no longer a prose obligation; a mid-barrier throw can no longer leak gate suppression into the serial fallback). If every verdict is GREEN, advance to the next wave. If any verdict is `ESCALATED`/`BLOCKED`, **halt the wave loop for the human** (fully autonomous up to this point per §6 Q3 / protocol §22); on the human's "re-approach", `resumeFromRunId` re-enters the **same run** and re-dispatches only the ESCALATED/BLOCKED story's segment — GREEN segments **short-circuit on resume with zero new ledger rows** (spike Q4: 0 tokens on replay), so re-merging GREEN stories is a no-op.
|
|
230
|
-
|
|
231
|
-
**Idempotent segments.** Segments are **idempotent** as a belt-and-suspenders safety net: a `resumeFromRunId` re-run of a GREEN segment, or a re-launch after a partial failure, must produce no duplicate side effects (no double-commit, no double-merge, no duplicate ledger row). The RUN_ID-keyed ledger no-op (STORY-033-02) and the serial barrier merge together enforce this; segment idempotency is the redundant guard if either upstream protection regresses.
|
|
232
|
-
|
|
233
|
-
### C.1 Pre-execution check
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
node .cleargate/scripts/validate_state.mjs
|
|
237
|
-
node .cleargate/scripts/validate_bounce_readiness.mjs STORY-NNN-NN
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
`state.json` `sprintId` must equal the active sprint. If not, re-run `init_sprint.mjs` — **do not create a worktree with a stale state.json**.
|
|
241
|
-
|
|
242
|
-
`validate_bounce_readiness.mjs` checks: story is "Ready to Bounce", §§1/2/3 present, working tree clean. Fail → halt.
|
|
243
|
-
|
|
244
|
-
### C.2 Create worktree
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
git worktree add .worktrees/STORY-NNN-NN -b story/STORY-NNN-NN sprint/S-NN
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Story branch is cut from the **sprint branch**, never from main. Verify:
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
git worktree list
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
**Do not run `git worktree add` inside `mcp/`.** It is a nested git repo. If the story touches `mcp/`, the Developer edits `mcp/` from inside `.worktrees/STORY-NNN-NN/mcp/...` — visible as a subdirectory of the outer worktree. (`cleargate-enforcement.md` §1.3.)
|
|
257
|
-
|
|
258
|
-
### C.3 Spawn QA-Red (standard lane only — fast lane skips this step)
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
262
|
-
bash .cleargate/scripts/write_dispatch.sh STORY-NNN-NN qa
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Script invocation rule (CR-046):** Any bash/node script invoked within the QA-Red dispatch MUST go through the wrapper: `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. Direct invocation without the wrapper is forbidden under v2.
|
|
266
|
-
|
|
267
|
-
Then spawn with `subagent_type=qa`. Dispatch prompt MUST inject:
|
|
268
|
-
|
|
269
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action.
|
|
270
|
-
|
|
271
|
-
> `Mode: RED — write failing tests against §4 acceptance, no implementation Read access. Tests must fail with "not yet implemented" errors against the clean baseline. File-naming: *.red.node.test.ts (immutable post-Red). Forbidden: editing implementation files.`
|
|
272
|
-
|
|
273
|
-
QA-Red returns:
|
|
274
|
-
|
|
275
|
-
```
|
|
276
|
-
QA-RED: WRITTEN | BLOCKED
|
|
277
|
-
RED_TESTS: <list of *.red.node.test.ts files written>
|
|
278
|
-
BASELINE_FAIL: <count of failing scenarios>
|
|
279
|
-
flashcards_flagged: [ ... ]
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
On `QA-RED: BLOCKED`: surface Spec-Gap to human; do not proceed to §C.4 until resolved.
|
|
283
|
-
|
|
284
|
-
On `QA-RED: WRITTEN`: orchestrator commits the Red tests on the story branch with subject `qa-red(STORY-NNN-NN): write failing tests`, then proceeds to §C.3.5 TPV Gate.
|
|
285
|
-
|
|
286
|
-
**Fast lane skip:** if `state.json.stories[<id>].lane === "fast"`, skip this entire step AND §C.3.5 and proceed directly to §C.4 Spawn Developer.
|
|
287
|
-
|
|
288
|
-
### C.3.5 TPV Gate (Architect-only — standard lane, v2 only)
|
|
289
|
-
|
|
290
|
-
**Skip if:** `state.json.stories[<id>].lane === 'fast'` OR `execution_mode: v1`.
|
|
291
|
-
|
|
292
|
-
After QA-Red commits Red tests, run the wiring/pre-gate scan first:
|
|
293
|
-
|
|
294
|
-
```bash
|
|
295
|
-
bash .cleargate/scripts/pre_gate_runner.sh arch .worktrees/STORY-NNN-NN/ sprint/S-NN
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
**Conditional TPV dispatch (scan-flag gated — a clean standard-lane story proceeds to §C.4 with NO Architect TPV dispatch):**
|
|
299
|
-
|
|
300
|
-
- **If the scan returns exit 0 with no flags:** skip the live Architect `Mode: TPV` dispatch and proceed directly to §C.4 Spawn Developer. No Architect agent is spawned for TPV on the clean path.
|
|
301
|
-
- **If the scan returns a flag (exit 1) or scan-could-not-run (exit 2):** spawn the Architect in `Mode: TPV` to perform wiring-only validation before Dev dispatch. TPV does NOT evaluate test logic correctness — it verifies wiring so Dev does not waste a full dispatch on a mis-wired test harness.
|
|
302
|
-
|
|
303
|
-
> **Safeguard (non-removable):** ANY pre-gate flag — demotion, `arch_bounce` signal, surface drift, new-deps, structural issue, OR exit-2 (scan-could-not-run) — MUST still dispatch the live Architect. Treat exit 2 as a flag (fail toward dispatching, never toward skipping). This optimization removes the Architect ONLY on a proven-clean scan; it never removes the Architect from a flagged path.
|
|
304
|
-
|
|
305
|
-
```bash
|
|
306
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
307
|
-
bash .cleargate/scripts/write_dispatch.sh STORY-NNN-NN architect
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
Dispatch prompt MUST inject:
|
|
311
|
-
|
|
312
|
-
> `Mode: TPV — Test Pattern Validation only. You receive: story file, QA-Red commit SHA, list of *.red.node.test.ts files. Verify ONLY: (1) imports resolve to real paths, (2) constructor signatures match, (3) mocked methods exist on the mocked object, (4) after-hooks present when before-hooks write state, (5) file naming *.red.node.test.ts. Do NOT evaluate test logic. Return: TPV: APPROVED (Dev proceeds) or TPV: BLOCKED-WIRING-GAP — <one-sentence specific issue> (orchestrator routes back to QA-Red).`
|
|
313
|
-
|
|
314
|
-
Architect returns one of:
|
|
315
|
-
|
|
316
|
-
- `TPV: APPROVED` — proceed to §C.4 Spawn Developer.
|
|
317
|
-
- `TPV: BLOCKED-WIRING-GAP — <issue>` — orchestrator increments `arch_bounces` via:
|
|
318
|
-
```bash
|
|
319
|
-
node .cleargate/scripts/update_state.mjs STORY-NNN-NN --arch-bounce
|
|
320
|
-
```
|
|
321
|
-
Then routes back to §C.3 QA-Red with the gap description in the re-dispatch prompt. If `arch_bounces ≥ 3` → flip story to `Escalated`, halt.
|
|
322
|
-
|
|
323
|
-
TPV is a WIRING gate, not a correctness gate. A test that imports the right module but asserts incorrectly still gets `TPV: APPROVED` — Dev's TDD cycle handles assertion correctness.
|
|
324
|
-
|
|
325
|
-
### C.4 Spawn Developer
|
|
326
|
-
|
|
327
|
-
```bash
|
|
328
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
329
|
-
bash .cleargate/scripts/write_dispatch.sh STORY-NNN-NN developer
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
**Script invocation rule (CR-046):** Any bash/node script invoked within the Developer dispatch MUST go through the wrapper: `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. Direct invocation without the wrapper is forbidden under v2.
|
|
333
|
-
|
|
334
|
-
Then spawn with `subagent_type=developer`. Inputs the prompt must include verbatim:
|
|
335
|
-
|
|
336
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action.
|
|
337
|
-
|
|
338
|
-
- `STORY=NNN-NN` (Developer must echo this on its first response line).
|
|
339
|
-
- Path to story file.
|
|
340
|
-
- Path to milestone plan.
|
|
341
|
-
- Worktree path (assigned).
|
|
342
|
-
- Sprint ID.
|
|
343
|
-
|
|
344
|
-
Developer returns:
|
|
345
|
-
|
|
346
|
-
```
|
|
347
|
-
STORY: STORY-NNN-NN
|
|
348
|
-
STATUS: done | blocked
|
|
349
|
-
COMMIT: <sha> | none
|
|
350
|
-
TYPECHECK: pass | fail
|
|
351
|
-
TESTS: X passed, Y failed
|
|
352
|
-
FILES_CHANGED: <list>
|
|
353
|
-
flashcards_flagged: [ ... ]
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
If `STATUS=blocked`: route per §C.8 (Blockers Triage).
|
|
357
|
-
|
|
358
|
-
### C.5 Spawn QA-Verify
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
362
|
-
bash .cleargate/scripts/write_dispatch.sh STORY-NNN-NN qa
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
**Script invocation rule (CR-046):** Any bash/node script invoked within the QA-Verify dispatch MUST go through the wrapper: `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. Direct invocation without the wrapper is forbidden under v2.
|
|
366
|
-
|
|
367
|
-
Dispatch prompt MUST inject: `Mode: VERIFY — read-only acceptance trace. Verify Developer's implementation against the story's §4 acceptance Gherkin. Do not write or modify any files.`
|
|
368
|
-
|
|
369
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action.
|
|
370
|
-
|
|
371
|
-
QA inputs: story file path, worktree path, Developer commit SHA. QA returns:
|
|
372
|
-
|
|
373
|
-
```
|
|
374
|
-
QA: PASS | FAIL
|
|
375
|
-
ACCEPTANCE_COVERAGE: N of M scenarios
|
|
376
|
-
MISSING: <list>
|
|
377
|
-
REGRESSIONS: <list>
|
|
378
|
-
flashcards_flagged: [ ... ]
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
**On `QA: FAIL`:** increment `qa_bounces` via `update_state.mjs STORY-NNN-NN --qa-bounce`. If counter ≥ 3 → flip story to `Escalated`, surface to human, halt. Else → re-spawn Developer with QA's bug report as input. Return to §C.4.
|
|
382
|
-
|
|
383
|
-
**On `QA: PASS`:** update state to `QA Passed`, proceed.
|
|
384
|
-
|
|
385
|
-
### C.6 Architect Pass (v2, `lane: standard` only)
|
|
386
|
-
|
|
387
|
-
`lane: fast` skips this step entirely.
|
|
388
|
-
|
|
389
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action.
|
|
390
|
-
|
|
391
|
-
**Script invocation rule (CR-046):** Any bash/node script invoked within the Architect Pass dispatch MUST go through the wrapper: `bash .cleargate/scripts/run_script.sh <cmd> [args...]`. Direct invocation without the wrapper is forbidden under v2.
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
bash .cleargate/scripts/pre_gate_runner.sh arch .worktrees/STORY-NNN-NN/ sprint/S-NN
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
If pre-gate scan reveals new dependencies / structural issues → return to Developer (do NOT spawn Architect for mechanical failures). 3+ pre-gate failures → escalate.
|
|
398
|
-
|
|
399
|
-
**Conditional post-flight dispatch (scan-flag gated — a clean standard-lane story dispatches ≤4 agents, not 6; ≤5 when one re-entry fires; 6 when both flag):**
|
|
400
|
-
|
|
401
|
-
- **If the scan returns exit 0 with no flags (clean scan):** skip the live Architect post-flight dispatch and proceed directly to §C.7 Story Merge. No Architect agent is spawned on the clean path. This drops a fully-clean standard-lane story from 6 dispatches to 4 (QA-Red → Developer → QA-Verify → DevOps — both §C.3.5 TPV and §C.6 post-flight skipped on a fully-clean scan).
|
|
402
|
-
- **If the scan returns a flag (exit 1) or scan-could-not-run (exit 2):** spawn the live Architect for post-flight review. On `FAIL`: increment `arch_bounces`. ≥ 3 → escalate.
|
|
403
|
-
|
|
404
|
-
> **Safeguard (non-removable):** ANY pre-gate flag — demotion, `arch_bounce` signal, surface drift, new-deps, structural issue, OR exit-2 (scan-could-not-run) — MUST still dispatch the live Architect. Treat exit 2 as a flag (fail toward dispatching, never toward skipping). This optimization removes the Architect ONLY on a proven-clean scan; it never removes the Architect from a flagged path.
|
|
405
|
-
|
|
406
|
-
### C.7 Story Merge
|
|
407
|
-
|
|
408
|
-
**DevOps-owned.** The orchestrator does NOT run `git merge`, `git worktree remove`, `git branch -d`, `update_state.mjs`, or `npm run prebuild` directly. All mechanical merge work is delegated to the DevOps agent.
|
|
409
|
-
|
|
410
|
-
**Serial barrier merge (parallel waves only).** Under `execution_mode: v2-parallel`, when a wave's verdicts consolidate at the barrier, the merge is **serial**: DevOps merges each GREEN `story/STORY-X` to `sprint/S-NN` **one worktree at a time** — **no two worktrees merge concurrently**. Even though the wave's segments ran in parallel and committed to FS-isolated `.worktrees/STORY-X` (each with its own `.git` index, so the per-worktree pre-commit surface gate never races), the shared `sprint/S-NN` branch is a single-writer axis. The Orchestrator therefore loops over the GREEN stories in order and dispatches DevOps for **one merge at a time**, awaiting `STATUS=done` before the next. A mixed GREEN+ESCALATED wave merges the GREEN stories immediately at the barrier (serial), then resumes only the ESCALATED segment via `resumeFromRunId` — the already-merged GREEN segments short-circuit on resume (zero new ledger rows). Serial-loop sprints merge each story as it completes, exactly as below.
|
|
411
|
-
|
|
412
|
-
**Required reports — verify before dispatch:**
|
|
413
|
-
|
|
414
|
-
| Report | Required when |
|
|
415
|
-
|---|---|
|
|
416
|
-
| `STORY-NNN-NN-dev.md` | Always (all lanes) |
|
|
417
|
-
| `STORY-NNN-NN-qa.md` | Always, unless lane=fast explicitly skipped QA-Verify |
|
|
418
|
-
| `STORY-NNN-NN-arch.md` | v2 standard-lane only, AND only when the §C.6 pre-gate scan flagged (Architect post-flight was dispatched); absent on a clean-scan story |
|
|
419
|
-
| `STORY-NNN-NN-devops.md` | Written BY DevOps during this step (not a prerequisite) |
|
|
420
|
-
|
|
421
|
-
Missing `dev.md` or `qa.md` (when required) → return to spawn that agent. **Do not dispatch DevOps with missing reports.**
|
|
422
|
-
|
|
423
|
-
**Orchestrator dispatch sequence:**
|
|
424
|
-
|
|
425
|
-
1. Mark the dispatch:
|
|
426
|
-
```bash
|
|
427
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
428
|
-
bash .cleargate/scripts/write_dispatch.sh STORY-NNN-NN devops
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
2. Spawn the DevOps agent with the following context (§3.1 Context Pack):
|
|
432
|
-
```
|
|
433
|
-
SPRINT-{NN} — DevOps dispatch for {STORY-ID}.
|
|
434
|
-
|
|
435
|
-
INPUTS:
|
|
436
|
-
- Story ID: {STORY-ID}
|
|
437
|
-
- Sprint ID: SPRINT-{NN}
|
|
438
|
-
- Worktree path: .worktrees/{STORY-ID}/
|
|
439
|
-
- Story branch: story/{STORY-ID}
|
|
440
|
-
- Sprint branch: sprint/S-{NN}
|
|
441
|
-
- Dev commit SHA: {abc1234}
|
|
442
|
-
- QA commit SHA (if present): {def5678}
|
|
443
|
-
- Architect commit SHA (if present): {ghi9012}
|
|
444
|
-
- Files-changed manifest: {list from git show --stat <dev-sha>}
|
|
445
|
-
- Canonical scaffold touched? {yes|no}
|
|
446
|
-
- Lane: {standard | fast}
|
|
447
|
-
- Required reports present:
|
|
448
|
-
- {STORY-ID}-dev.md ✓
|
|
449
|
-
- {STORY-ID}-qa.md ✓ (or "skipped — fast lane")
|
|
450
|
-
- {STORY-ID}-arch.md ✓ (v2 standard lane only, AND only when pre-gate scan flagged — absent if Architect was not dispatched)
|
|
451
|
-
|
|
452
|
-
ACTIONS (in order):
|
|
453
|
-
1. Verify all required reports exist; halt if any missing. Exception: arch.md is required ONLY when the §C.6 pre-gate scan flagged (Architect was dispatched); a clean-scan story legitimately has no arch.md and must NOT halt.
|
|
454
|
-
2. Checkout sprint branch.
|
|
455
|
-
3. git merge story/{STORY-ID} --no-ff -m "merge(story/{STORY-ID}): {commit subject}"
|
|
456
|
-
4. If canonical scaffold touched: cd cleargate-cli && npm run prebuild
|
|
457
|
-
5. Mirror parity audit: for each file in files-changed where canonical mirror exists,
|
|
458
|
-
diff live ↔ canonical. Report drift in §Mirror Parity (DO NOT auto-fix).
|
|
459
|
-
6. Post-merge test verification: run only test files touched by this commit.
|
|
460
|
-
7. git worktree remove .worktrees/{STORY-ID}
|
|
461
|
-
8. git branch -d story/{STORY-ID}
|
|
462
|
-
9. CLEARGATE_STATE_FILE=... node .cleargate/scripts/update_state.mjs {STORY-ID} Done
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
3. **Halt** and wait for DevOps to return `STATUS=done` or `STATUS=blocked`.
|
|
466
|
-
|
|
467
|
-
**On `STATUS=done`:** DevOps has written `.cleargate/sprint-runs/SPRINT-{NN}/reports/{STORY-ID}-devops.md`. If it notes live re-sync needed (mirror parity drift), address via `cleargate init` or hand-port at Gate-4 doc-refresh (see §C.9 Flashcard Gate for the next step, then proceed to the next story / wave).
|
|
468
|
-
|
|
469
|
-
**On `STATUS=blocked`:** DevOps has written `{STORY-ID}-devops-blockers.md`. Surface the blockers report to the human. DevOps does NOT auto-resolve conflicts — orchestrator escalates and waits for human resolution before re-dispatching DevOps.
|
|
470
|
-
|
|
471
|
-
**Forbidden orchestrator patterns (v2):** `git merge`, `git worktree remove`, `git branch -d`, `update_state.mjs`, `npm run prebuild` in the orchestrator's main session bash log. If any appear, classify as edge case and document in sprint §4 Execution Log.
|
|
472
|
-
|
|
473
|
-
#### DevOps Escape Hatch — subagent_type=devops unavailable
|
|
474
|
-
|
|
475
|
-
If spawning `Agent(subagent_type=devops)` returns "Agent type 'devops' not found" (registry miss — see §1 registration constraint note), the orchestrator executes the §C.7 ACTIONS steps 2-9 verbatim inline (in the orchestrator's own bash session). All rules still apply: no `git merge` short-circuit, no conflict auto-resolution. Write the same `STORY-NNN-NN-devops.md` report with an additional frontmatter field `operator: orchestrator-fallback` and note the session restart requirement. This path is exceptional — if it triggers, queue a session restart at the next natural break and verify `devops` appears in the next session's available agent list before continuing the sprint.
|
|
476
|
-
|
|
477
|
-
### C.8 Blockers Triage (Developer circuit breaker)
|
|
478
|
-
|
|
479
|
-
When Developer returns `BLOCKED: circuit breaker triggered`, read `.cleargate/sprint-runs/<id>/reports/STORY-NNN-NN-dev-blockers.md`. The report has three sections:
|
|
480
|
-
|
|
481
|
-
| Non-N/A section | Routing |
|
|
482
|
-
|---|---|
|
|
483
|
-
| `## Test-Pattern` | Re-launch Developer with the pattern hint as additional context. Pass the sentence verbatim in the new prompt. |
|
|
484
|
-
| `## Spec-Gap` | **Halt and surface the sentence to the human.** Do NOT re-launch Developer until human clarifies. |
|
|
485
|
-
| `## Environment` | Re-run `pre_gate_runner.sh`. If pre-gate passes, re-launch Developer; otherwise surface env issue. |
|
|
486
|
-
|
|
487
|
-
3 consecutive circuit-breaker hits on the same story → `update_state.mjs STORY-NNN-NN Escalated`, halt.
|
|
488
|
-
|
|
489
|
-
### C.9 Flashcard Gate (v2 mandatory; v1 dogfood)
|
|
490
|
-
|
|
491
|
-
After every story merge — **before creating story N+1's worktree** — process the merged `flashcards_flagged` list (union of dev + QA, dedupe by exact-string):
|
|
492
|
-
|
|
493
|
-
For each card:
|
|
494
|
-
|
|
495
|
-
| Action | Effect |
|
|
496
|
-
|---|---|
|
|
497
|
-
| **Approve** | Append the line verbatim to `.cleargate/FLASHCARD.md` (newest-first). |
|
|
498
|
-
| **Reject** | Discard. Log `FLASHCARD-REJECT YYYY-MM-DD — "<card>" — reason: <one sentence>` in sprint §4 Execution Log. |
|
|
499
|
-
|
|
500
|
-
Then mark each card processed:
|
|
501
|
-
|
|
502
|
-
```bash
|
|
503
|
-
HASH=$(printf '%s' "<card text>" | shasum -a 1 | cut -c1-12)
|
|
504
|
-
touch .cleargate/sprint-runs/<sprint-id>/.processed-${HASH}
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
Under v2, the `pending-task-sentinel.sh` PreToolUse hook blocks the next `Task` spawn until every card has a `.processed-<hash>` marker. Bypass only with `SKIP_FLASHCARD_GATE=1` — log the bypass in sprint §4.
|
|
508
|
-
|
|
509
|
-
**Between-wave relocation (parallel waves only).** Under `execution_mode: v2-parallel` the flashcard gate moves from **between-story** to **between-wave**. The PreToolUse write-gate cannot fire mid-wave (it would block a segment's own `Task` spawns inside the running `parallel()` Workflow and deadlock the wave), so `launch_wave.mjs` sets `SKIP_FLASHCARD_GATE=1` (relocating only the WRITE-gate; flashcard reading inside segments is unaffected) for the duration of the `parallel()` dispatch and restores it in a `try/finally` (BUG-034 — code-enforced, not a prose obligation). Each segment returns its cards in its verdict's `flashcards_flagged[]` instead of blocking. At the barrier, BEFORE launching the next wave, the Orchestrator collects the union of every segment's `flashcards_flagged[]` (dedupe by exact-string), approves/rejects each card exactly as in the per-story table above, and writes the `.processed-<hash>` markers — `HASH=$(printf '%s' "<card text>" | shasum -a 1 | cut -c1-12); touch .cleargate/sprint-runs/<sprint-id>/.processed-${HASH}`. Because `launchWave()`'s `finally` has already restored the gate to its exact prior value by the time it returns, the write-gate is active again before any non-wave dispatch — even if validation or merge throws. The markers are written **between waves**, not between stories.
|
|
510
|
-
|
|
511
|
-
### C.10 Mid-Sprint Triage
|
|
512
|
-
|
|
513
|
-
When the user injects new input mid-sprint (between story kickoff and merge), classify it before routing. Apply the keyword-heuristic rubric from `.cleargate/knowledge/mid-sprint-triage-rubric.md` as a first-pass advisory, then confirm with the user. The four classes are: `bug`, `clarification`, `scope`, `approach` — match the user's language against the keyword banks in the rubric doc.
|
|
514
|
-
|
|
515
|
-
| Class | Trigger | Counter | Human Approval | First-pass action |
|
|
516
|
-
|---|---|---|---|---|
|
|
517
|
-
| `bug` | Defect vs spec | `qa_bounces++` | No | Re-open story; Dev fix; QA re-verify |
|
|
518
|
-
| `clarification` | Ambiguity question | None | No (yes if spec gap) | Update §1.2 in place; re-run impacted test |
|
|
519
|
-
| `scope` | Net-new requirement | None | YES for mid-sprint add | Quarantine to next sprint (default); escalate if goal-critical |
|
|
520
|
-
| `approach` | Different impl, same spec | None | No (yes if cross-story impact) | Reset Dev context; re-spawn with updated approach |
|
|
521
|
-
|
|
522
|
-
**Confidence signal:** When no keyword in the rubric matches the user's input, treat the classification as low-confidence. LOW confidence classifications MUST be confirmed with the human before routing.
|
|
523
|
-
|
|
524
|
-
**Scope-only note:** This rubric covers USER input only. QA-FAIL bounces continue to use `qa_bounces` (existing §C.5 path). TPV-gap bounces use `arch_bounces` (§C.3.5 path).
|
|
525
|
-
|
|
526
|
-
For the operational routing table with per-type routing rules, see §C.11 (Mid-cycle User Input — CR Triage).
|
|
527
|
-
|
|
528
|
-
### C.11 Mid-cycle User Input — CR Triage
|
|
529
|
-
|
|
530
|
-
If the user injects new input mid-story, classify before routing:
|
|
531
|
-
|
|
532
|
-
| Type | Effect | Routing |
|
|
533
|
-
|---|---|---|
|
|
534
|
-
| `CR:bug` | Defect in current story | Increments `qa_bounces`; re-open story; Dev fixes; QA re-verifies |
|
|
535
|
-
| `CR:spec-clarification` | Removes ambiguity, no new scope | No counter; update §1.2 in place; re-run impacted test |
|
|
536
|
-
| `CR:scope-change` | Net-new requirement | **Quarantine.** New Story file in `pending-sync/`; current story unchanged |
|
|
537
|
-
| `CR:approach-change` | Different impl, same spec | No counter; reset Dev context; re-spawn with updated approach |
|
|
538
|
-
|
|
539
|
-
Log every CR in sprint §4 Execution Log with date + ID.
|
|
540
|
-
|
|
541
|
-
> 🎯 **Goal check on `CR:scope-change`.** Default routing is quarantine-into-next-sprint. **Override the default if the new requirement is critical to the active sprint goal** — escalate to the human with: *"This scope-change is goal-critical: the sprint goal is `<verbatim>` and without this change, the goal will not be met. Add to current sprint? (Adding mid-sprint requires explicit ack per §C.11.)"* Quarantine remains default for goal-incidental scope.
|
|
542
|
-
|
|
543
|
-
### C.11 Script Invocation Contract (CR-046)
|
|
544
|
-
|
|
545
|
-
All bash/node script invocations dispatched FROM agents (Developer / QA / Architect / DevOps) MUST use the wrapper:
|
|
546
|
-
|
|
547
|
-
```bash
|
|
548
|
-
bash .cleargate/scripts/run_script.sh <command> [args...]
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
**What the wrapper does (on failure):**
|
|
552
|
-
- Captures stdout + stderr independently (≤4KB each; truncated with `... [truncated]` if exceeded).
|
|
553
|
-
- Writes a structured JSON incident to `.cleargate/sprint-runs/<sprint-id>/.script-incidents/<ts>-<hash>.json`.
|
|
554
|
-
- Propagates the original exit code to the caller.
|
|
555
|
-
|
|
556
|
-
**Self-exemption clause:** The wrapper itself (`run_script.sh`) is exempt from wrapping — it sets `RUN_SCRIPT_ACTIVE=1` before executing the wrapped command so recursive calls pass through directly. Orchestrator-direct invocations of `run_script.sh` are the canonical entry point; they are exempt by this contract.
|
|
557
|
-
|
|
558
|
-
**Agent reporting obligation:** If a wrapped script fails (incident JSON written), the dispatching agent MUST include the incident JSON path in its report's `## Script Incidents` section.
|
|
559
|
-
|
|
560
|
-
**Pre-sprint invocations (before `.active` sentinel exists):** Wrapper writes to `.cleargate/sprint-runs/_off-sprint/.script-incidents/` when no active sprint is detected. This is expected during preflight steps.
|
|
561
|
-
|
|
562
|
-
---
|
|
563
|
-
|
|
564
|
-
## 6. Phase D — Sprint Walkthrough (v2)
|
|
565
|
-
|
|
566
|
-
Mandatory under v2. After all stories merged into `sprint/S-NN` (every story state ∈ `TERMINAL_STATES`) and **before** sprint→main merge, invite the user to test on the sprint branch. Classify every piece of feedback:
|
|
567
|
-
|
|
568
|
-
| Event | Definition | Bug-Fix Tax |
|
|
569
|
-
|---|---|---|
|
|
570
|
-
| `UR:bug` | Defect, crash, behavior broken vs spec | Increments |
|
|
571
|
-
| `UR:review-feedback` | Polish, copy, UX preference | Does not increment |
|
|
572
|
-
|
|
573
|
-
**When in doubt, ask:** "Is this broken vs spec, or a preference?" Do not default to `UR:bug`.
|
|
574
|
-
|
|
575
|
-
Log every event in sprint §4. **Sprint branch MUST NOT merge to main while any `UR:bug` is unresolved.** `UR:review-feedback` may defer with explicit human sign-off.
|
|
576
|
-
|
|
577
|
-
> 🎯 **Goal check.** Open the walkthrough invitation with the sprint goal verbatim, not a feature checklist: *"Sprint goal: `<verbatim>`. The branch is ready on `sprint/S-NN`. Test it and tell me — does the running build achieve the goal?"* This forces the framing to be outcome-vs-spec rather than feature-tour.
|
|
578
|
-
|
|
579
|
-
---
|
|
580
|
-
|
|
581
|
-
## 6.5 Phase D.5 — Consolidation
|
|
582
|
-
|
|
583
|
-
**When:** Runs ONCE per sprint, after all stories have merged into `sprint/S-NN` (walkthrough done, all `UR:bug` items resolved) and **before** Gate-4 close (Phase E). Worktrees are already torn down by §C.7 at this point — this is a sprint-branch operation, not a story-branch operation.
|
|
584
|
-
|
|
585
|
-
**Rationale:** Each story is built by a Developer sealed in its own worktree, blind to the others. Cross-story duplication, divergent patterns, and missed reuse are structurally invisible during execution. Phase D.5 is the only place one reviewer sees the whole sprint diff — it is the dedup/reuse/altitude pass that per-story isolation cannot provide.
|
|
586
|
-
|
|
587
|
-
### D.5.1 Run /simplify on the full sprint diff
|
|
588
|
-
|
|
589
|
-
Invoke the `code-simplifier` agent (`/simplify`) against the full sprint diff:
|
|
590
|
-
|
|
591
|
-
```bash
|
|
592
|
-
git diff main...sprint/S-NN
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
The agent applies reuse, deduplication, and altitude fixes and produces ONE consolidation commit on the sprint branch `sprint/S-NN`. This is not a story branch commit — the worktrees are gone.
|
|
596
|
-
|
|
597
|
-
**Red-test immutability constraint:** The consolidation MUST NOT touch any `*.red.node.test.ts` file (frozen post-Red per §C.3 — same immutability rule as Developer). Before accepting the consolidation commit, the Orchestrator MUST verify the commit's file list contains no `*.red.node.test.ts` path:
|
|
598
|
-
|
|
599
|
-
```bash
|
|
600
|
-
git show --name-only <consolidation-sha> | grep '\.red\.node\.test\.ts'
|
|
601
|
-
# Must return empty — any match is a violation; revert immediately.
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
If `*.red.node.test.ts` files appear in the consolidation commit's file list, revert the commit unconditionally and log the violation in sprint §4 Execution Log.
|
|
605
|
-
|
|
606
|
-
### D.5.2 QA-Verify re-runs the full suite (safety net)
|
|
607
|
-
|
|
608
|
-
After the consolidation commit lands on `sprint/S-NN`, dispatch QA in Consolidation mode (see `qa.md` § Consolidation-mode dispatch) — a sprint-diff full-suite re-run, read-only, sole question: does the full suite stay green after the /simplify commit?
|
|
609
|
-
|
|
610
|
-
**Green → keep:** Full suite is green — keep the consolidation commit on `sprint/S-NN` and proceed to Phase E (Gate 4 close).
|
|
611
|
-
|
|
612
|
-
**Red → revert:** Full suite is red — run `git revert <consolidation-sha>` on `sprint/S-NN`. Log the revert in sprint §4 Execution Log. Close the sprint on the un-simplified still-green diff. The un-simplified diff is the correctness floor — a failed simplification never blocks the sprint.
|
|
613
|
-
|
|
614
|
-
### D.5.3 Optional advisory sprint-diff code review
|
|
615
|
-
|
|
616
|
-
After D.5.1–D.5.2 (whether or not consolidation succeeded), the Orchestrator MAY run an advisory `/code-review` on `git diff main...sprint/S-NN`. This is advisory only — it is NOT a gate. Findings go into sprint §4 Execution Log; they do not block Phase E.
|
|
617
|
-
|
|
618
|
-
---
|
|
619
|
-
|
|
620
|
-
## 7. Phase E — Gate 4 Close (Reporter + Human Sign-off)
|
|
621
|
-
|
|
622
|
-
This is a **Gate-3-class action**. Authorising sprint execution does NOT authorise close. Close requires its own dedicated human approval.
|
|
623
|
-
|
|
624
|
-
### E.1 Step A — orchestrator runs close
|
|
625
|
-
|
|
626
|
-
```bash
|
|
627
|
-
node .cleargate/scripts/close_sprint.mjs <sprint-id>
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
No flags. Script validates Steps 1–2.6 (lifecycle reconciler runs at Step 2.6; see `cleargate-enforcement.md` §10), prefills `SPRINT-<#>_REPORT.md` stub if missing via the Reporter agent, and exits 0 with the prompt:
|
|
631
|
-
|
|
632
|
-
> Review the report, then confirm close by re-running with --assume-ack.
|
|
633
|
-
|
|
634
|
-
### E.2 Reporter dispatch (Step 3.5)
|
|
635
|
-
|
|
636
|
-
If the report stub does not exist, dispatch the Reporter:
|
|
637
|
-
|
|
638
|
-
```bash
|
|
639
|
-
# Fallback only — auto-marker written by PreToolUse:Task hook in most sessions.
|
|
640
|
-
bash .cleargate/scripts/write_dispatch.sh SPRINT-NN reporter
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
- Cross-cutting rules: Read `.cleargate/sprint-runs/<sprint-id>/sprint-context.md` BEFORE any other action.
|
|
644
|
-
|
|
645
|
-
> **Fresh session.** The Reporter MUST dispatch in a fresh session — do not inherit dev+qa cumulative context. `write_dispatch.sh` already spawns a clean shell child; the `Agent` tool path requires no session-continuation flag. If the runtime offers a session-reset knob (e.g. `--resume false` or equivalent), use it. The Reporter starts cold and reads only `.reporter-context.md` + `sprint_report.md`.
|
|
646
|
-
|
|
647
|
-
> **Token budget.** Soft warn at 200k tokens, hard advisory at 500k (per CR-036). The token-ledger SubagentStop hook emits the warning to stdout; orchestrator surfaces the line into chat. Hard advisory auto-records a flashcard. The dispatch is NOT killed — the warning is informational; review the bundle slices on next sprint.
|
|
648
|
-
|
|
649
|
-
Reporter writes `.cleargate/sprint-runs/<id>/SPRINT-<#>_REPORT.md` and returns the Brief:
|
|
650
|
-
|
|
651
|
-
> **Goal:** `<verbatim sprint goal>` — **Verdict: met | partial | missed.**
|
|
652
|
-
> Delivered N stories, M epics. Observe: X bugs, Y review-feedback. Carry-over: Z. Token cost: T.
|
|
653
|
-
> See SPRINT-\<#>_REPORT.md for full report.
|
|
654
|
-
> Ready to authorize close (Gate 4)?
|
|
655
|
-
|
|
656
|
-
> 🎯 **Goal check.** The verdict line is mandatory and is the first line of the Brief. `met` = goal achieved as written. `partial` = some sprint-goal acceptance criteria met, others not — explain which in REPORT §1. `missed` = goal not achieved despite stories merging. A `partial` or `missed` verdict does NOT block close, but it is a first-class signal to the human that close-ack should be deliberate, not reflexive.
|
|
657
|
-
|
|
658
|
-
### E.3 Step B — surface and HALT
|
|
659
|
-
|
|
660
|
-
Surface the Brief verbatim to the human. **Halt.** Do not re-run with `--assume-ack`.
|
|
661
|
-
|
|
662
|
-
The human either:
|
|
663
|
-
|
|
664
|
-
- Re-runs `close_sprint.mjs <id> --assume-ack` themselves, OR
|
|
665
|
-
- Says "approved, close it" — at which point you may pass the flag on their behalf.
|
|
666
|
-
|
|
667
|
-
`--assume-ack` is reserved for **automated test environments only**. Passing it autonomously is a Gate-4 breach equivalent to an unauthorized push.
|
|
668
|
-
|
|
669
|
-
### E.4 Doc & metadata refresh on close
|
|
670
|
-
|
|
671
|
-
During Gate 4 sign-off, read `.cleargate/sprint-runs/<id>/.doc-refresh-checklist.md` (generated by `prep_doc_refresh.mjs`). Apply or punt each `- [ ]` item per `.cleargate/knowledge/sprint-closeout-checklist.md`. Items already `- [x]` mean "no changes detected, skip."
|
|
672
|
-
|
|
673
|
-
### E.5 Sprint→main merge
|
|
674
|
-
|
|
675
|
-
After sign-off and after all walkthrough `UR:bug` items resolved:
|
|
676
|
-
|
|
677
|
-
```bash
|
|
678
|
-
git checkout main
|
|
679
|
-
git merge sprint/S-NN --no-ff -m "Sprint S-NN: <goal>"
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
Then flip sprint frontmatter `status: Completed`, archive the sprint file (`pending-sync/` → `archive/`).
|
|
683
|
-
|
|
684
|
-
---
|
|
685
|
-
|
|
686
|
-
## 8. Rework Counter Quick Reference
|
|
687
|
-
|
|
688
|
-
| Counter | Increment trigger | Escalation |
|
|
689
|
-
|---|---|---|
|
|
690
|
-
| `qa_bounces` | Each `QA: FAIL` | ≥ 3 → `Escalated`, halt |
|
|
691
|
-
| `arch_bounces` | Each `Architect: FAIL` | ≥ 3 → `Escalated`, halt |
|
|
692
|
-
| Circuit breaker | 50 tool calls without test pass OR 2 identical failures | 3 hits same story → `Escalated`, halt |
|
|
693
|
-
| Pre-gate failures | Each `pre_gate_runner.sh` non-zero | 3 hits same story → human escalation (descope / re-approach) |
|
|
694
|
-
|
|
695
|
-
> 🎯 **Goal check on escalation.** When a story flips to `Escalated`, frame the human-decision question through the goal lens, not in isolation: *"STORY-NNN-NN escalated after N rework cycles. Sprint goal is `<verbatim>`. Options: (a) drop the story — is the goal still met without it? (b) re-approach with X — same goal met by sprint end? (c) split into smaller stories — which scope serves the goal? (d) defer to next sprint — does the goal change?"* Never present escalation as a generic "what do you want to do?" — always tie options to goal achievement.
|
|
696
|
-
|
|
697
|
-
State updates go through:
|
|
698
|
-
|
|
699
|
-
```bash
|
|
700
|
-
node .cleargate/scripts/update_state.mjs STORY-NNN-NN [--qa-bounce | --arch-bounce | <new-state>]
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
`Escalated` halts the loop until human decides: descope, re-assign approach, or split story.
|
|
704
|
-
|
|
705
|
-
---
|
|
706
|
-
|
|
707
|
-
## 9. File-Surface Contract (v2)
|
|
708
|
-
|
|
709
|
-
Each story's §3.1 "Context & Files" table is the **authoritative file surface** for its commit. The pre-commit hook (`.git/hooks/pre-commit` → `.claude/hooks/pre-commit-surface-gate.sh`) blocks commits that touch off-surface files.
|
|
710
|
-
|
|
711
|
-
Off-surface edits require **either**:
|
|
712
|
-
|
|
713
|
-
1. A `CR:scope-change` approved before the commit, OR
|
|
714
|
-
2. An updated §3.1 table committed in the same story (self-amending — must be justified in commit message).
|
|
715
|
-
|
|
716
|
-
Bypass with `SKIP_SURFACE_GATE=1` only when absolutely necessary; log in sprint §4. Under v1 the hook only warns.
|
|
717
|
-
|
|
718
|
-
---
|
|
719
|
-
|
|
720
|
-
## 10. What This Skill Does NOT Cover
|
|
721
|
-
|
|
722
|
-
These live elsewhere — do not duplicate inline:
|
|
723
|
-
|
|
724
|
-
- **Triage / drafting / Gate 1 Brief** → CLAUDE.md + `cleargate-protocol.md` §§1–4.
|
|
725
|
-
- **Worktree command details and edge cases** → `cleargate-enforcement.md` §1.
|
|
726
|
-
- **Lane classification rubric (7 checks)** → `.claude/agents/architect.md` Lane Classification + `cleargate-enforcement.md` §9.
|
|
727
|
-
- **Sprint Plan template / Gate 2 Sprint Ready** → `.cleargate/templates/Sprint Plan Template.md`.
|
|
728
|
-
- **Wiki ingest / lint / contradiction detection** → `cleargate-protocol.md` §10.
|
|
729
|
-
- **Doctor exit codes** → `cleargate-enforcement.md` §8.
|
|
730
|
-
- **Hotfix flow** → V-Bounce-style hotfix handling, see flashcard tag `#hotfix` and `wiki/topics/hotfix-ledger.md`.
|
|
731
|
-
|
|
732
|
-
When in doubt, read the source-of-truth doc — this skill cites them, it does not replace them.
|
|
733
|
-
|
|
734
|
-
---
|
|
735
|
-
|
|
736
|
-
## 11. Conversational Discipline During Execution
|
|
737
|
-
|
|
738
|
-
- **Sprint execution is autonomous.** See `.cleargate/knowledge/cleargate-protocol.md` § Sprint Execution Autonomy for the canonical rule and blocker enumeration. In short: once started, run the loop end-to-end; halt only on the five defined true-blocker cases (destructive actions, secrets, user-intent decisions, technical impossibility, spec-internal contradictions).
|
|
739
|
-
- **Terse output.** Status updates one sentence each. Details live in story reports and `SPRINT-<#>_REPORT.md`, not in chat.
|
|
740
|
-
- **Halt at gates without negotiation.** Gate 3 (preflight), Gate 4 (close sign-off), `Escalated` state — these are not advisory. Surface, halt, wait.
|
|
741
|
-
- **Never `--no-verify`, `--assume-ack` autonomously, force-push, or `git reset --hard`.** Every one of these requires explicit per-action human approval.
|
|
742
|
-
- **Verify, don't trust agent self-reports.** A Developer claiming `STATUS=done` is not done — QA verifies. A `QA: PASS` is not approved-to-merge until reports exist and merge prerequisites pass.
|