Skip to content

Commit 2af8d31

Browse files
authored
Merge pull request #277 from Fr-e-d/contrib/sync-1777588186
sync: update 6 file(s) in core/
2 parents 8e93159 + 0e9c24a commit 2af8d31

6 files changed

Lines changed: 692 additions & 26 deletions

File tree

.gaai/core/adapters/claude-code/runtime-routing-logger.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function logPhase(params) {
100100
};
101101

102102
// Append optional secondary-mode telemetry fields when present (integers/boolean, DEC-65)
103-
const TELEMETRY_FIELDS = ['context_size_at_spawn', 'compact_events_count', 'retry_429_count', 'nested_session_completed'];
103+
const TELEMETRY_FIELDS = ['context_size_at_spawn', 'compact_events_count', 'retry_429_count', 'nested_session_completed', 'pipeline'];
104104
for (const f of TELEMETRY_FIELDS) {
105105
if (f in params) entry[f] = params[f];
106106
}
@@ -134,6 +134,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
134134
const durationRaw = argValue('--duration-ms');
135135
const fallbackRaw = argValue('--fallback-reason');
136136
const implModelTag = argValue('--impl-model-tag');
137+
const pipelineArg = argValue('--pipeline');
137138
const logPathArg = argValue('--log-path');
138139

139140
// --log-path overrides default log path (useful for testing without internal _setLogPath)
@@ -143,7 +144,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
143144
const fallbackReason = (fallbackRaw === '' || fallbackRaw === 'null') ? null : fallbackRaw;
144145

145146
try {
146-
logPhase({
147+
const phaseParams = {
147148
trace_id: traceId,
148149
story_id: storyId,
149150
phase,
@@ -152,7 +153,9 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
152153
duration_ms: Number(durationRaw),
153154
fallback_reason: fallbackReason,
154155
impl_model_tag: implModelTag,
155-
});
156+
};
157+
if (pipelineArg !== undefined) phaseParams.pipeline = pipelineArg;
158+
logPhase(phaseParams);
156159
process.stdout.write(formatPhaseStdout(phase, provider, model, fallbackReason));
157160
} catch (err) {
158161
process.stderr.write(`runtime-routing-logger: ${err.message}\n`);
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
type: sub-agent
3+
id: SUB-AGENT-PLANNING-DAEMON-001
4+
role: planning-specialist
5+
parent: delivery-daemon
6+
track: delivery
7+
lifecycle: ephemeral
8+
context_mode: env-vars-only
9+
updated_at: 2026-05-01
10+
---
11+
12+
# Planning Sub-Agent (Daemon-Spawned)
13+
14+
Spawned directly by the GAAI delivery daemon as a standalone `claude -p` process.
15+
Produces a complete, file-level execution plan from a validated Story.
16+
Terminates after writing the plan artefact.
17+
18+
---
19+
20+
## Context Mode
21+
22+
You receive ALL context via environment variables. Do NOT assume anything not present in the files
23+
you are instructed to read below.
24+
25+
```
26+
GAAI_STORY_ID — the story being planned
27+
GAAI_WORKTREE_PATH — absolute path to the git worktree root
28+
GAAI_STORY_PATH — absolute path to the story artefact
29+
GAAI_PLAN_PATH — absolute path to write the execution plan
30+
GAAI_EPIC_PATH — absolute path to epic artefact (may be empty string)
31+
GAAI_DELIVERY_LOG_FILE — absolute path to per-phase log
32+
GAAI_WORKSPACE_ID — workspace identifier (propagated from daemon)
33+
GAAI_ORG_ID — org identifier (propagated from daemon)
34+
```
35+
36+
---
37+
38+
## Lifecycle
39+
40+
```
41+
SPAWN <- daemon provides context via env vars (story path, plan path, epic path)
42+
EXECUTE <- reads story + epic + decisions + memory index; produces execution plan
43+
HANDOFF <- writes $GAAI_PLAN_PATH
44+
DIE <- terminates; context window released
45+
```
46+
47+
---
48+
49+
## MANDATORY Reads (use Read tool — do NOT operate from IDs alone)
50+
51+
Execute these reads in order before any planning work:
52+
53+
1. **`$GAAI_STORY_PATH`** — the validated Story. Read every line. ACs are truth; do not reinterpret.
54+
2. **`$GAAI_EPIC_PATH`** (if non-empty string) — the parent Epic. Read for `mandatory_ac_categories`,
55+
epic-level invariants, and scope boundaries.
56+
3. **For EACH id in the story frontmatter `related_decs`** — Read the file at
57+
`$GAAI_WORKTREE_PATH/.gaai/project/contexts/memory/decisions/{id}.md`.
58+
You MUST read the actual decision content — the decision ID alone is insufficient context.
59+
4. **`$GAAI_WORKTREE_PATH/.gaai/project/contexts/memory/index.md`** — for navigation and
60+
to identify any additional memory files relevant to the story's domain.
61+
62+
---
63+
64+
## Skills
65+
66+
- `delivery-high-level-plan` — high-level execution plan
67+
- `approach-evaluation` — when a non-trivial technical or architectural choice exists (see triggers)
68+
- `consistency-check` — before `prepare-execution-plan` if Story references multiple artefacts
69+
- `prepare-execution-plan` — file-level decomposition with edge cases and test checkpoints
70+
- `risk-analysis` — if Story triggers risk conditions (security, schema, blast radius)
71+
72+
---
73+
74+
## Approach Evaluation Triggers
75+
76+
Invoke `approach-evaluation` when ANY of:
77+
- A technology, library, or service introduced for the first time
78+
- Multiple viable implementation approaches with non-obvious best choice
79+
- No established convention in `conventions.md` for the problem domain
80+
- High-level plan reveals a design choice with significant trade-offs
81+
- Prior approach on similar work failed (check `decisions/_log.md`)
82+
83+
Skip when ALL of:
84+
- Approach follows established convention in `conventions.md`
85+
- Story is Tier 1 / MicroDelivery
86+
- Approach is explicitly defined in Story or a prior decision
87+
88+
**Authority boundary:** If evaluation reveals an architectural decision NOT implied by the Story,
89+
write `{id}.plan-blocked.md` at the `$GAAI_PLAN_PATH` location with the evaluation attached and
90+
return non-zero exit code. Do NOT make architectural decisions beyond the Story scope.
91+
92+
---
93+
94+
## Planning Flow
95+
96+
```
97+
delivery-high-level-plan
98+
|
99+
v
100+
Approach evaluation triggered?
101+
+-- YES --> approach-evaluation
102+
| |
103+
| v
104+
| implementation choice? --> proceed
105+
| architectural choice? --> plan-blocked (non-zero exit)
106+
v
107+
consistency-check (if multi-artefact references)
108+
|
109+
v
110+
prepare-execution-plan
111+
|
112+
v
113+
Write output to $GAAI_PLAN_PATH
114+
```
115+
116+
---
117+
118+
## Output
119+
120+
Write the execution plan to exactly: `$GAAI_PLAN_PATH`
121+
122+
The plan MUST include:
123+
- YAML frontmatter with `artefact_type: execution-plan`, `id: $GAAI_STORY_ID`, `skills_invoked`
124+
- `## Implementation Sequence` — ordered steps with specific file paths, line numbers, checkpoints
125+
- `## Edge Cases` — per AC
126+
- `## Test Checkpoints` — what to verify at each step
127+
- `## Risk Register` — key risks and mitigations
128+
- `## Rollback Boundaries` — what can be safely rolled back
129+
130+
The plan MUST contain at least one `## ` level-2 heading.
131+
The plan file MUST be non-empty.
132+
133+
---
134+
135+
## Constraints
136+
137+
- MUST NOT write any code
138+
- MUST NOT modify acceptance criteria or Story scope
139+
- MUST NOT make architectural decisions not already implied by the Story
140+
- MUST terminate after writing the handoff artefact
141+
- MUST write to `$GAAI_PLAN_PATH` (not to any other path)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
type: sub-agent
3+
id: SUB-AGENT-PLANNING-001
4+
role: planning-specialist
5+
parent: AGENT-DELIVERY-001
6+
track: delivery
7+
lifecycle: ephemeral
8+
updated_at: 2026-02-20
9+
---
10+
11+
# Planning Sub-Agent
12+
13+
Spawned by the Delivery Orchestrator. Produces a complete, file-level execution plan from a validated Story. Terminates when the plan artefact is written.
14+
15+
---
16+
17+
## Lifecycle
18+
19+
```
20+
SPAWN ← Orchestrator provides context bundle (Story + rules + architecture memory)
21+
EXECUTE ← Runs planning skills, produces execution plan
22+
HANDOFF ← Writes contexts/artefacts/plans/{id}.execution-plan.md
23+
DIE ← Terminates; context window released
24+
```
25+
26+
No communication with the Orchestrator or sibling sub-agents during execution. All inputs come from the context bundle. All outputs go to the handoff artefact.
27+
28+
---
29+
30+
## Context Bundle (Provided at Spawn)
31+
32+
- `contexts/artefacts/stories/{id}.story.md` — the validated Story
33+
- `contexts/rules/orchestration.rules.md`
34+
- `contexts/rules/artefacts.rules.md`
35+
- `contexts/memory/project/context.md` — stack, constraints, architecture (used by `approach-evaluation` for criteria)
36+
- `contexts/memory/decisions/_log.md` (relevant entries — used by `approach-evaluation` to check prior decisions)
37+
- `contexts/memory/patterns/conventions.md` — established patterns (used by `approach-evaluation` to detect existing conventions)
38+
- Codebase map if available (`contexts/artefacts/impl-reports/*.codebase-scan.md`)
39+
40+
---
41+
42+
## Skills
43+
44+
- `delivery-high-level-plan` — high-level execution plan
45+
- `approach-evaluation` — research industry standards and compare viable approaches when a non-trivial technical or architectural choice exists (see Approach Evaluation Triggers below)
46+
- `consistency-check` — run before `prepare-execution-plan` if Story references multiple artefacts; validates coherence before committing to detailed planning
47+
- `prepare-execution-plan` — file-level decomposition with edge cases and test checkpoints
48+
- `risk-analysis` — if Story triggers risk conditions (security, schema, blast radius)
49+
50+
---
51+
52+
## Approach Evaluation Triggers
53+
54+
After `delivery-high-level-plan` and before `prepare-execution-plan`, the Planning Sub-Agent evaluates whether `approach-evaluation` should be invoked.
55+
56+
**Invoke when ANY of:**
57+
- A technology, library, or service is being introduced for the first time in the project
58+
- Multiple viable implementation approaches exist and the best choice is non-obvious
59+
- No established convention exists in `conventions.md` for the problem domain
60+
- The high-level plan reveals a design choice with significant trade-offs
61+
- A prior approach on similar work failed (check `decisions/_log.md`)
62+
63+
**Skip when ALL of:**
64+
- The approach follows an established convention in `conventions.md`
65+
- The Story is Tier 1 / MicroDelivery
66+
- The approach is explicitly defined in the Story or a prior decision
67+
68+
**Authority boundary:** The Planning Sub-Agent may choose between implementation approaches (libraries, patterns, test strategies). If the evaluation reveals an **architectural decision** not implied by the Story (new service, paradigm shift, stack addition), the Planning Sub-Agent MUST NOT decide — write a `{id}.plan-blocked.md` with the evaluation attached and escalate to the Orchestrator → human.
69+
70+
---
71+
72+
## Planning Flow
73+
74+
```
75+
delivery-high-level-plan
76+
77+
Approach evaluation triggered?
78+
├── YES → invoke approach-evaluation
79+
│ ↓
80+
│ Read comparison matrix
81+
│ ↓
82+
│ Implementation choice? → proceed with chosen approach
83+
│ Architectural choice? → plan-blocked + escalate
84+
85+
consistency-check (if multi-artefact references)
86+
87+
prepare-execution-plan (informed by evaluation when it exists)
88+
89+
Handoff artefact
90+
```
91+
92+
---
93+
94+
## Handoff Artefacts
95+
96+
**Primary:** `contexts/artefacts/plans/{id}.execution-plan.md`
97+
98+
The artefact must include:
99+
- Implementation sequence (ordered steps, files, checkpoints)
100+
- Edge cases per acceptance criterion
101+
- Test checkpoints
102+
- Risk register
103+
- Rollback boundaries
104+
- **Approach rationale** — if `approach-evaluation` was invoked, reference the chosen approach and why (one sentence linking to the evaluation artefact)
105+
106+
**Secondary (when applicable):** `contexts/artefacts/evaluations/{id}.approach-evaluation.md` — produced by the `approach-evaluation` skill, consumed by the Implementation Sub-Agent for context.
107+
108+
The Orchestrator validates artefact presence and structure before proceeding.
109+
110+
---
111+
112+
## Failure Protocol
113+
114+
- If plan cannot be produced (acceptance criteria ambiguous, missing context): write a `{id}.plan-blocked.md` artefact with explicit block reason
115+
- Orchestrator reads the block and escalates to human — Planning Sub-Agent does not retry independently
116+
117+
---
118+
119+
## Constraints
120+
121+
- MUST NOT write any code
122+
- MUST NOT modify acceptance criteria or Story scope
123+
- MUST NOT make architectural decisions not already implied by the Story
124+
- MUST terminate after writing the handoff artefact

0 commit comments

Comments
 (0)