@entelligentsia/forgecli 1.0.10 → 1.0.20
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 +191 -0
- package/dist/CHANGELOG-forge-plugin.md +211 -0
- package/dist/bin/forge.js +0 -0
- package/dist/extensions/forgecli/config-layer.js.map +1 -1
- package/dist/extensions/forgecli/context-governor-compaction.d.ts +83 -0
- package/dist/extensions/forgecli/context-governor-compaction.js +302 -0
- package/dist/extensions/forgecli/context-governor-compaction.js.map +1 -0
- package/dist/extensions/forgecli/context-governor.d.ts +173 -0
- package/dist/extensions/forgecli/context-governor.js +618 -0
- package/dist/extensions/forgecli/context-governor.js.map +1 -0
- package/dist/extensions/forgecli/dashboard/component.d.ts +105 -0
- package/dist/extensions/forgecli/dashboard/component.js +861 -0
- package/dist/extensions/forgecli/dashboard/component.js.map +1 -0
- package/dist/extensions/forgecli/dashboard/register.d.ts +2 -0
- package/dist/extensions/forgecli/dashboard/register.js +31 -0
- package/dist/extensions/forgecli/dashboard/register.js.map +1 -0
- package/dist/extensions/forgecli/dashboard/theme.d.ts +27 -0
- package/dist/extensions/forgecli/dashboard/theme.js +91 -0
- package/dist/extensions/forgecli/dashboard/theme.js.map +1 -0
- package/dist/extensions/forgecli/dashboard/view-model.d.ts +35 -0
- package/dist/extensions/forgecli/dashboard/view-model.js +54 -0
- package/dist/extensions/forgecli/dashboard/view-model.js.map +1 -0
- package/dist/extensions/forgecli/fix-bug.js +126 -7
- package/dist/extensions/forgecli/fix-bug.js.map +1 -1
- package/dist/extensions/forgecli/forge-artifact-tool.js +2 -1
- package/dist/extensions/forgecli/forge-artifact-tool.js.map +1 -1
- package/dist/extensions/forgecli/forge-commands.js +1 -0
- package/dist/extensions/forgecli/forge-commands.js.map +1 -1
- package/dist/extensions/forgecli/forge-init/phase4-register.js +53 -0
- package/dist/extensions/forgecli/forge-init/phase4-register.js.map +1 -1
- package/dist/extensions/forgecli/forge-subagent.d.ts +20 -1
- package/dist/extensions/forgecli/forge-subagent.js +23 -7
- package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
- package/dist/extensions/forgecli/forge-tools.js +3 -1
- package/dist/extensions/forgecli/forge-tools.js.map +1 -1
- package/dist/extensions/forgecli/hook-dispatcher.d.ts +3 -1
- package/dist/extensions/forgecli/hook-dispatcher.js +37 -3
- package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
- package/dist/extensions/forgecli/index.js +38 -1
- package/dist/extensions/forgecli/index.js.map +1 -1
- package/dist/extensions/forgecli/lib/halt-advisor.d.ts +59 -0
- package/dist/extensions/forgecli/lib/halt-advisor.js +113 -0
- package/dist/extensions/forgecli/lib/halt-advisor.js.map +1 -0
- package/dist/extensions/forgecli/migration-engine.js +25 -12
- package/dist/extensions/forgecli/migration-engine.js.map +1 -1
- package/dist/extensions/forgecli/orchestrator-status-bar.d.ts +26 -0
- package/dist/extensions/forgecli/orchestrator-status-bar.js +213 -0
- package/dist/extensions/forgecli/orchestrator-status-bar.js.map +1 -0
- package/dist/extensions/forgecli/orchestrator-tree.d.ts +96 -0
- package/dist/extensions/forgecli/orchestrator-tree.js +390 -0
- package/dist/extensions/forgecli/orchestrator-tree.js.map +1 -0
- package/dist/extensions/forgecli/project-orientation.js +12 -8
- package/dist/extensions/forgecli/project-orientation.js.map +1 -1
- package/dist/extensions/forgecli/regenerate.d.ts +16 -0
- package/dist/extensions/forgecli/regenerate.js +110 -0
- package/dist/extensions/forgecli/regenerate.js.map +1 -1
- package/dist/extensions/forgecli/run-sprint.d.ts +3 -1
- package/dist/extensions/forgecli/run-sprint.js +34 -3
- package/dist/extensions/forgecli/run-sprint.js.map +1 -1
- package/dist/extensions/forgecli/run-task.d.ts +66 -1
- package/dist/extensions/forgecli/run-task.js +323 -12
- package/dist/extensions/forgecli/run-task.js.map +1 -1
- package/dist/extensions/forgecli/thread-switcher.d.ts +4 -1
- package/dist/extensions/forgecli/thread-switcher.js +118 -762
- package/dist/extensions/forgecli/thread-switcher.js.map +1 -1
- package/dist/extensions/forgecli/viewport-events.js +32 -0
- package/dist/extensions/forgecli/viewport-events.js.map +1 -1
- package/dist/forge-payload/.base-pack/commands/fix-bug.md +1 -1
- package/dist/forge-payload/.base-pack/commands/run-sprint.md +1 -1
- package/dist/forge-payload/.base-pack/commands/run-task.md +1 -1
- package/dist/forge-payload/.base-pack/personas/architect.md +1 -1
- package/dist/forge-payload/.base-pack/personas/bug-fixer.md +1 -1
- package/dist/forge-payload/.base-pack/personas/collator.md +3 -3
- package/dist/forge-payload/.base-pack/personas/engineer.md +1 -1
- package/dist/forge-payload/.base-pack/personas/librarian.md +1 -1
- package/dist/forge-payload/.base-pack/personas/orchestrator.md +1 -1
- package/dist/forge-payload/.base-pack/personas/product-manager.md +1 -1
- package/dist/forge-payload/.base-pack/personas/qa-engineer.md +1 -1
- package/dist/forge-payload/.base-pack/personas/supervisor.md +1 -1
- package/dist/forge-payload/.base-pack/workflows/_fragments/event-emission-schema.md +1 -1
- package/dist/forge-payload/.base-pack/workflows/_fragments/friction-emit.md +1 -1
- package/dist/forge-payload/.base-pack/workflows/_fragments/iron-laws.md +1 -1
- package/dist/forge-payload/.base-pack/workflows/_fragments/progress-reporting.md +2 -2
- package/dist/forge-payload/.base-pack/workflows/_fragments/store-cli-verbs.md +11 -2
- package/dist/forge-payload/.base-pack/workflows/architect_approve.md +6 -7
- package/dist/forge-payload/.base-pack/workflows/architect_review_sprint_completion.md +2 -2
- package/dist/forge-payload/.base-pack/workflows/architect_sprint_intake.md +2 -2
- package/dist/forge-payload/.base-pack/workflows/architect_sprint_plan.md +5 -5
- package/dist/forge-payload/.base-pack/workflows/collator_agent.md +4 -6
- package/dist/forge-payload/.base-pack/workflows/commit_task.md +5 -6
- package/dist/forge-payload/.base-pack/workflows/enhance.md +5 -5
- package/dist/forge-payload/.base-pack/workflows/implement_plan.md +15 -7
- package/dist/forge-payload/.base-pack/workflows/migrate_structural.md +12 -13
- package/dist/forge-payload/.base-pack/workflows/plan_task.md +12 -6
- package/dist/forge-payload/.base-pack/workflows/review_code.md +12 -11
- package/dist/forge-payload/.base-pack/workflows/review_plan.md +12 -11
- package/dist/forge-payload/.base-pack/workflows/sprint_retrospective.md +3 -3
- package/dist/forge-payload/.base-pack/workflows/triage.md +12 -9
- package/dist/forge-payload/.base-pack/workflows/update_implementation.md +2 -2
- package/dist/forge-payload/.base-pack/workflows/update_plan.md +2 -2
- package/dist/forge-payload/.base-pack/workflows/validate_task.md +9 -9
- package/dist/forge-payload/.base-pack/workflows-js/wfl-fix-bug.js +490 -0
- package/dist/forge-payload/.base-pack/workflows-js/wfl-run-sprint.js +416 -0
- package/dist/forge-payload/.base-pack/workflows-js/wfl-run-task.js +608 -0
- package/dist/forge-payload/.claude-plugin/plugin.json +1 -1
- package/dist/forge-payload/.schemas/config.schema.json +2 -3
- package/dist/forge-payload/.schemas/enum-catalog.json +2 -2
- package/dist/forge-payload/.schemas/event.schema.json +16 -0
- package/dist/forge-payload/.schemas/migrations.json +359 -18
- package/dist/forge-payload/commands/health.md +29 -0
- package/dist/forge-payload/commands/rebuild.md +143 -15
- package/dist/forge-payload/commands/update.md +28 -27
- package/dist/forge-payload/hooks/preflight-session.cjs +99 -0
- package/dist/forge-payload/init/phases/phase-3-materialize.md +18 -5
- package/dist/forge-payload/integrity.json +7 -6
- package/dist/forge-payload/meta/fragments/tool-discipline.md +1 -1
- package/dist/forge-payload/meta/personas/meta-architect.md +1 -1
- package/dist/forge-payload/meta/personas/meta-bug-fixer.md +1 -1
- package/dist/forge-payload/meta/personas/meta-collator.md +7 -7
- package/dist/forge-payload/meta/personas/meta-engineer.md +1 -1
- package/dist/forge-payload/meta/personas/meta-orchestrator.md +1 -1
- package/dist/forge-payload/meta/personas/meta-supervisor.md +1 -1
- package/dist/forge-payload/meta/tool-specs/store-cli.spec.md +1 -1
- package/dist/forge-payload/meta/workflows/_fragments/event-emission-schema.md +1 -1
- package/dist/forge-payload/meta/workflows/_fragments/friction-emit.md +1 -1
- package/dist/forge-payload/meta/workflows/_fragments/iron-laws.md +1 -1
- package/dist/forge-payload/meta/workflows/_fragments/progress-reporting.md +2 -2
- package/dist/forge-payload/meta/workflows/_fragments/store-cli-verbs.md +11 -2
- package/dist/forge-payload/meta/workflows/meta-approve.md +6 -7
- package/dist/forge-payload/meta/workflows/meta-bug-triage.md +12 -9
- package/dist/forge-payload/meta/workflows/meta-collate.md +5 -7
- package/dist/forge-payload/meta/workflows/meta-commit.md +5 -6
- package/dist/forge-payload/meta/workflows/meta-enhance.md +5 -5
- package/dist/forge-payload/meta/workflows/meta-fix-bug.md +35 -11
- package/dist/forge-payload/meta/workflows/meta-implement.md +15 -7
- package/dist/forge-payload/meta/workflows/meta-migrate.md +13 -14
- package/dist/forge-payload/meta/workflows/meta-new-sprint.md +3 -3
- package/dist/forge-payload/meta/workflows/meta-orchestrate.md +138 -39
- package/dist/forge-payload/meta/workflows/meta-plan-sprint.md +6 -6
- package/dist/forge-payload/meta/workflows/meta-plan-task.md +12 -6
- package/dist/forge-payload/meta/workflows/meta-retro.md +4 -4
- package/dist/forge-payload/meta/workflows/meta-retrospective.md +4 -4
- package/dist/forge-payload/meta/workflows/meta-review-implementation.md +12 -11
- package/dist/forge-payload/meta/workflows/meta-review-plan.md +12 -11
- package/dist/forge-payload/meta/workflows/meta-review-sprint-completion.md +3 -3
- package/dist/forge-payload/meta/workflows/meta-sprint-intake.md +3 -3
- package/dist/forge-payload/meta/workflows/meta-sprint-plan.md +6 -6
- package/dist/forge-payload/meta/workflows/meta-update-implementation.md +2 -2
- package/dist/forge-payload/meta/workflows/meta-update-plan.md +2 -2
- package/dist/forge-payload/meta/workflows/meta-validate.md +9 -9
- package/dist/forge-payload/schemas/config.schema.json +2 -3
- package/dist/forge-payload/schemas/enum-catalog.json +2 -2
- package/dist/forge-payload/schemas/event.schema.json +16 -0
- package/dist/forge-payload/schemas/structure-manifest.json +75 -73
- package/dist/forge-payload/skills/refresh-kb-links/SKILL.md +14 -7
- package/dist/forge-payload/tools/banners.cjs +29 -10
- package/dist/forge-payload/tools/check-structure.cjs +88 -7
- package/dist/forge-payload/tools/collate.cjs +48 -2
- package/dist/forge-payload/tools/manage-config.cjs +5 -7
- package/dist/forge-payload/tools/parse-gates.cjs +73 -1
- package/dist/forge-payload/tools/postflight-gate.cjs +298 -0
- package/dist/forge-payload/tools/preflight-gate.cjs +47 -0
- package/dist/forge-payload/tools/substitute-placeholders.cjs +5 -4
- package/dist/forge-payload/tools/verify-phase.cjs +17 -0
- package/package.json +2 -2
- package/dist/bin/forgecli.d.ts +0 -2
- package/dist/bin/forgecli.js +0 -6
- package/dist/bin/forgecli.js.map +0 -1
- package/dist/extensions/forgecli/config-tui/index.d.ts +0 -5
- package/dist/extensions/forgecli/config-tui/index.js +0 -5
- package/dist/extensions/forgecli/config-tui/index.js.map +0 -1
- package/dist/extensions/forgecli/loaders/persona-skill-loader.d.ts +0 -45
- package/dist/extensions/forgecli/loaders/persona-skill-loader.js +0 -227
- package/dist/extensions/forgecli/loaders/persona-skill-loader.js.map +0 -1
- package/dist/extensions/forgecli/loaders/template-render.d.ts +0 -20
- package/dist/extensions/forgecli/loaders/template-render.js +0 -85
- package/dist/extensions/forgecli/loaders/template-render.js.map +0 -1
- package/dist/extensions/forgecli/loaders/workflow-loader.d.ts +0 -41
- package/dist/extensions/forgecli/loaders/workflow-loader.js +0 -164
- package/dist/extensions/forgecli/loaders/workflow-loader.js.map +0 -1
- package/dist/forge-payload/.base-pack/workflows/fix_bug.md +0 -446
- package/dist/forge-payload/.base-pack/workflows/orchestrate_task.md +0 -928
- package/dist/forge-payload/.base-pack/workflows/run_sprint.md +0 -225
|
@@ -1,928 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
requirements:
|
|
3
|
-
reasoning: High
|
|
4
|
-
context: High
|
|
5
|
-
speed: Medium
|
|
6
|
-
audience: orchestrator-only
|
|
7
|
-
deps:
|
|
8
|
-
personas: [architect, engineer, supervisor, bug-fixer, collator, qa-engineer]
|
|
9
|
-
skills: [architect, engineer, supervisor, generic]
|
|
10
|
-
templates: []
|
|
11
|
-
sub_workflows: [plan_task, implement_plan, review_plan, review_code, fix_bug, architect_approve, commit_task, validate_task]
|
|
12
|
-
kb_docs: [architecture/stack.md]
|
|
13
|
-
context_pack: .forge/cache/context-pack.md
|
|
14
|
-
config_fields: [paths.engineering]
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Orchestrate Task
|
|
19
|
-
## Pipeline Phases
|
|
20
|
-
|
|
21
|
-
Each phase has:
|
|
22
|
-
- `name` — identifier
|
|
23
|
-
- `agent` — which role executes
|
|
24
|
-
- `workflow` — which workflow file to load
|
|
25
|
-
- `requires` — prerequisite artifact
|
|
26
|
-
- `produces` — output artifact
|
|
27
|
-
- `max_iterations` — revision loop limit (for review phases)
|
|
28
|
-
- `gate_checks` — conditions that must pass before proceeding
|
|
29
|
-
|
|
30
|
-
## Model Resolution
|
|
31
|
-
|
|
32
|
-
Detect cluster from env vars at session start, then dispatch accordingly:
|
|
33
|
-
|
|
34
|
-
| Env var | Purpose |
|
|
35
|
-
|---------|---------|
|
|
36
|
-
| `ANTHROPIC_DEFAULT_OPUS_MODEL` | What "opus" resolves to |
|
|
37
|
-
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | What "sonnet" resolves to |
|
|
38
|
-
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | What "haiku" resolves to |
|
|
39
|
-
|
|
40
|
-
- **Single cluster** — all three vars equal (or unset): omit `model` on Agent spawns; subagents inherit the parent.
|
|
41
|
-
- **Tiered cluster** — vars differ: pass `model=tier` (opus/sonnet/haiku) based on ROLE_TIER mapping.
|
|
42
|
-
- **Unknown cluster** — no `ANTHROPIC_DEFAULT_*` vars: pass the canonical model ID from ROLE_TIER_DEFAULTS.
|
|
43
|
-
- **Per-phase override** — `model` field in `config.pipelines` phase takes highest precedence.
|
|
44
|
-
|
|
45
|
-
### Role-to-Tier Mapping
|
|
46
|
-
|
|
47
|
-
| Role | Tier |
|
|
48
|
-
|------|------|
|
|
49
|
-
| `review-plan`, `review-code`, `validate`, `approve` | opus |
|
|
50
|
-
| `plan`, `implement` | sonnet |
|
|
51
|
-
| `commit`, `writeback` | haiku |
|
|
52
|
-
|
|
53
|
-
Unknown cluster canonical defaults: opus → `claude-opus-4-5`, sonnet → `claude-sonnet-4-6`, haiku → `claude-haiku-4-5`.
|
|
54
|
-
|
|
55
|
-
Phase announcement format: `→ TASK-ID [tier → resolved-model]` (e.g. `→ SPECT-T01 [opus → claude-opus-4-6]`).
|
|
56
|
-
On single cluster, show the model directly. On unknown, show `tier → canonical`.
|
|
57
|
-
|
|
58
|
-
## Pipeline Resolution
|
|
59
|
-
|
|
60
|
-
The orchestrator supports pluggable pipelines. When starting a task:
|
|
61
|
-
|
|
62
|
-
1. Read the task manifest from `.forge/store/tasks/{TASK_ID}.json`.
|
|
63
|
-
2. If `task.pipeline` is set, look up that key in `.forge/config.json` → `pipelines`.
|
|
64
|
-
3. If found, use the phases defined in that pipeline.
|
|
65
|
-
4. If `task.pipeline` is not set or the key is not found, use the `default` pipeline
|
|
66
|
-
(either from `config.pipelines.default` or the hardcoded default below).
|
|
67
|
-
|
|
68
|
-
Each phase in a pipeline has:
|
|
69
|
-
- `command` — the slash command to invoke (passed the task ID as argument)
|
|
70
|
-
- `role` — semantic role (`plan`, `review-plan`, `implement`, `review-code`, `approve`, `commit`)
|
|
71
|
-
- `maxIterations` — for review roles, the revision loop limit (default 3)
|
|
72
|
-
- `on_revision` — (optional) command name of the phase to re-invoke on "Revision Required";
|
|
73
|
-
if absent, defaults to the nearest preceding phase whose role is not a review role
|
|
74
|
-
|
|
75
|
-
## Default Pipeline
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
plan → review-plan → [loop max 3] → implement → review-code → [loop max 3] → validate → [loop max 3] → approve → writeback → commit
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
When no `pipelines` section exists in config, the orchestrator uses this
|
|
82
|
-
hardcoded default. Projects that define `config.pipelines.default` override it.
|
|
83
|
-
|
|
84
|
-
## Context Isolation
|
|
85
|
-
|
|
86
|
-
**Each phase MUST run as a subagent (Agent tool call), NOT inline.**
|
|
87
|
-
|
|
88
|
-
Invoking phases inline accumulates context from every prior phase and task into
|
|
89
|
-
the orchestrator's window. This violates Forge's design principle of keeping
|
|
90
|
-
context light and nimble. By the time a sprint reaches its third or fourth task,
|
|
91
|
-
an inline orchestrator is carrying tens of thousands of tokens of prior work that
|
|
92
|
-
is irrelevant to the current phase.
|
|
93
|
-
|
|
94
|
-
The fix: use the Agent tool to spawn a subagent per phase. Each subagent:
|
|
95
|
-
- Starts with a fresh context window
|
|
96
|
-
- Receives only what it needs: the workflow file path and the task ID
|
|
97
|
-
- Receives a PROJECT_OVERLAY (task-scoped index slice) instead of reading MASTER_INDEX.md directly
|
|
98
|
-
- Writes results to disk (artifacts, task status updates)
|
|
99
|
-
- Returns to the orchestrator, which then reads the verdict from disk
|
|
100
|
-
|
|
101
|
-
The orchestrator itself stays minimal — it only holds the phase loop and event log.
|
|
102
|
-
|
|
103
|
-
## Token Self-Reporting
|
|
104
|
-
|
|
105
|
-
Each phase subagent is responsible for reporting its own token usage via a sidecar file.
|
|
106
|
-
|
|
107
|
-
**Before returning, every subagent MUST:**
|
|
108
|
-
|
|
109
|
-
1. Probe token usage for the session: invoke `/cost` if the host runtime
|
|
110
|
-
supports it (Claude Code only); on any other runtime treat as unavailable.
|
|
111
|
-
Do NOT shell out to a `cost-cli.cjs` — there is no such tool.
|
|
112
|
-
2. Parse the output for the five fields:
|
|
113
|
-
`inputTokens`, `outputTokens`, `cacheReadTokens`, `cacheWriteTokens`, `estimatedCostUSD`.
|
|
114
|
-
3. Write the usage sidecar via `node "$FORGE_ROOT/tools/store-cli.cjs" emit {sprintId} '{sidecar-json}' --sidecar` with the exact format:
|
|
115
|
-
```json
|
|
116
|
-
{
|
|
117
|
-
"inputTokens": <integer>,
|
|
118
|
-
"outputTokens": <integer>,
|
|
119
|
-
"cacheReadTokens": <integer>,
|
|
120
|
-
"cacheWriteTokens": <integer>,
|
|
121
|
-
"estimatedCostUSD": <number>
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
The `eventId` is computed by the orchestrator before spawning and passed in the subagent prompt —
|
|
126
|
-
it follows the format `{ISO_TIMESTAMP}_{TASK_ID}_{role}_{action}` (e.g.
|
|
127
|
-
`20260415T141523000Z_ACME-S02-T03_engineer_implement`).
|
|
128
|
-
|
|
129
|
-
The leading underscore on the sidecar filename marks it as ephemeral — `validate-store.cjs` skips
|
|
130
|
-
files prefixed with `_`, so the sidecar will never be treated as a real event record. If `/cost` is
|
|
131
|
-
unavailable or token data cannot be parsed, skip writing the sidecar silently — the orchestrator
|
|
132
|
-
handles missing sidecars gracefully (see Execution Algorithm below).
|
|
133
|
-
|
|
134
|
-
## Role-to-Noun Mapping
|
|
135
|
-
|
|
136
|
-
The orchestrator resolves persona and skill file lookups using **noun-based**
|
|
137
|
-
filenames, not role-literal filenames. A role like `plan` maps to the noun
|
|
138
|
-
`engineer`, so the persona file is `engineer.md`, not `plan.md`.
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
ROLE_TO_NOUN = {
|
|
142
|
-
"plan": "engineer",
|
|
143
|
-
"implement": "engineer",
|
|
144
|
-
"update-plan": "engineer",
|
|
145
|
-
"update-impl": "engineer",
|
|
146
|
-
"commit": "engineer",
|
|
147
|
-
"review-plan": "supervisor",
|
|
148
|
-
"review-code": "supervisor",
|
|
149
|
-
"validate": "qa-engineer",
|
|
150
|
-
"approve": "architect",
|
|
151
|
-
"writeback": "collator",
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The `.get(key, fallback)` pattern preserves the old role-literal behaviour for
|
|
156
|
-
any role not yet in the table, which is a safe degradation path for custom
|
|
157
|
-
pipeline roles.
|
|
158
|
-
|
|
159
|
-
## Persona Injection Modes
|
|
160
|
-
|
|
161
|
-
Subagent prompts include a **role block** that tells the agent who it is
|
|
162
|
-
and what capabilities it has. Two modes are supported, selected by the
|
|
163
|
-
`FORGE_PROMPT_MODE` environment variable:
|
|
164
|
-
|
|
165
|
-
| Mode | Behaviour | Default |
|
|
166
|
-
|------|-----------|---------|
|
|
167
|
-
| `reference` | Compact summary from `.forge/cache/persona-pack.json`, plus a file_ref pointer to the full persona/skill definitions. | ✅ |
|
|
168
|
-
| `inline` | Legacy: inject the full verbatim persona and skill file contents. Kept for one version as a rollback path. | |
|
|
169
|
-
|
|
170
|
-
The pack is built by `/forge:rebuild` via
|
|
171
|
-
`forge/tools/build-persona-pack.cjs`. It compiles YAML frontmatter from
|
|
172
|
-
`$FORGE_ROOT/meta/personas/meta-*.md` and `$FORGE_ROOT/meta/skills/meta-*.md`
|
|
173
|
-
into `.forge/cache/persona-pack.json`.
|
|
174
|
-
|
|
175
|
-
### Helper: `compose_role_block(persona_noun)`
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
def compose_role_block(persona_noun):
|
|
179
|
-
mode = os.environ.get("FORGE_PROMPT_MODE", "reference")
|
|
180
|
-
|
|
181
|
-
if mode == "inline":
|
|
182
|
-
# Legacy behaviour — full persona + skill prose inline.
|
|
183
|
-
persona_content = read_file(f".forge/personas/{persona_noun}.md")
|
|
184
|
-
skill_content = read_file(f".forge/skills/{persona_noun}-skills.md")
|
|
185
|
-
return f"{persona_content}\n\n{skill_content}"
|
|
186
|
-
|
|
187
|
-
# Reference mode (default) — compact summary from the pack.
|
|
188
|
-
pack = read_json(".forge/cache/persona-pack.json")
|
|
189
|
-
persona = pack["personas"].get(persona_noun)
|
|
190
|
-
skill = pack["skills"].get(f"{persona_noun}-skills")
|
|
191
|
-
|
|
192
|
-
if not persona:
|
|
193
|
-
# Fail loud rather than silently degrade. Missing pack entry is a
|
|
194
|
-
# regeneration bug and should be reported via /forge:report-bug.
|
|
195
|
-
raise OrchestratorError(
|
|
196
|
-
f"persona '{persona_noun}' not in persona-pack. "
|
|
197
|
-
"Run /forge:rebuild to rebuild the pack."
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
lines = [
|
|
201
|
-
f"You are acting as the {persona['role']}.",
|
|
202
|
-
"",
|
|
203
|
-
f"Persona: {persona['id']} — {persona['summary']}",
|
|
204
|
-
"",
|
|
205
|
-
"Your responsibilities:",
|
|
206
|
-
]
|
|
207
|
-
for r in persona.get("responsibilities", []):
|
|
208
|
-
lines.append(f"- {r}")
|
|
209
|
-
if persona.get("outputs"):
|
|
210
|
-
lines.append("")
|
|
211
|
-
lines.append(f"Your outputs: {', '.join(persona['outputs'])}")
|
|
212
|
-
|
|
213
|
-
if skill:
|
|
214
|
-
lines.append("")
|
|
215
|
-
lines.append("Skill capabilities you have available:")
|
|
216
|
-
for c in skill.get("capabilities", []):
|
|
217
|
-
lines.append(f"- {c}")
|
|
218
|
-
|
|
219
|
-
lines.append("")
|
|
220
|
-
lines.append(
|
|
221
|
-
f"Full persona definition: {persona['file_ref']}. "
|
|
222
|
-
+ (f"Full skill definition: {skill['file_ref']}. " if skill else "")
|
|
223
|
-
+ "The summary above is authoritative. If insufficient, escalate — "
|
|
224
|
-
+ "do not read the full persona or skill file."
|
|
225
|
-
)
|
|
226
|
-
return "\n".join(lines)
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
**Rollback:** set `FORGE_PROMPT_MODE=inline`. No persisted state to revert.
|
|
230
|
-
The `inline` branch will be removed one version after `reference` ships.
|
|
231
|
-
|
|
232
|
-
## Execution Algorithm
|
|
233
|
-
|
|
234
|
-
The orchestrator MUST follow this procedure exactly. Do not deviate.
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
# --- Persona symbol lookup (emoji, name, tagline) ---
|
|
238
|
-
PERSONA_MAP = {
|
|
239
|
-
"plan": ("🌱", "Engineer", "I plan what will be built before any code is written."),
|
|
240
|
-
"implement": ("🌱", "Engineer", "I build what was planned. I do not move forward until the code is clean."),
|
|
241
|
-
"update-plan": ("🌱", "Engineer", "I address what the Supervisor found. No more, no less."),
|
|
242
|
-
"update-impl": ("🌱", "Engineer", "I address what the Supervisor found. No more, no less."),
|
|
243
|
-
"commit": ("🌱", "Engineer", "I close out completed work with a clean, honest commit."),
|
|
244
|
-
"review-plan": ("🌿", "Supervisor", "I review before things move forward. I read the actual task prompt, not just the plan."),
|
|
245
|
-
"review-code": ("🌿", "Supervisor", "I review before things move forward. I read the actual code, not the report."),
|
|
246
|
-
"validate": ("🍵", "QA Engineer", "I validate against what was promised. The code compiling is not enough."),
|
|
247
|
-
"approve": ("🗻", "Architect", "I hold the shape of the whole. I give final sign-off before commit."),
|
|
248
|
-
"writeback": ("🍃", "Collator", "I gather what exists and arrange it into views."),
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
# --- Banner identity map (banner name per phase role) ---
|
|
252
|
-
# Maps each role to a banner in forge/tools/banners.cjs.
|
|
253
|
-
# Displayed by the orchestrator ONLY (badge before spawn, exit signal after return).
|
|
254
|
-
# Subagents do NOT display banners — the orchestrator owns phase announcements.
|
|
255
|
-
BANNER_MAP = {
|
|
256
|
-
"plan": "forge",
|
|
257
|
-
"implement": "forge",
|
|
258
|
-
"update-plan": "forge",
|
|
259
|
-
"update-impl": "forge",
|
|
260
|
-
"commit": "forge",
|
|
261
|
-
"review-plan": "oracle",
|
|
262
|
-
"review-code": "oracle",
|
|
263
|
-
"validate": "lumen",
|
|
264
|
-
"approve": "north",
|
|
265
|
-
"writeback": "drift",
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
for each task in dependency_sorted(tasks):
|
|
269
|
-
# --- Pre-task status guard ---
|
|
270
|
-
# If a task is already blocked or escalated from a prior sprint/run,
|
|
271
|
-
# skip it entirely rather than attempting any phase.
|
|
272
|
-
task_record = read_json(f".forge/store/tasks/{task.taskId}.json")
|
|
273
|
-
if task_record and task_record.get("status") in ("blocked", "escalated"):
|
|
274
|
-
print(f" ⚠ {task.taskId} — status is {task_record['status']}, skipping\n")
|
|
275
|
-
emit_event(task, phase=None, action="task_skipped",
|
|
276
|
-
notes=f"task status is {task_record['status']}")
|
|
277
|
-
continue
|
|
278
|
-
|
|
279
|
-
phases = resolve_pipeline(task) # from config.pipelines or default
|
|
280
|
-
iteration_counts = {} # keyed by phase command name
|
|
281
|
-
retry_count = {} # keyed by phase command name (subagent retry tracking)
|
|
282
|
-
i = 0
|
|
283
|
-
|
|
284
|
-
# --- Detect execution cluster from env vars (see Model Resolution) ---
|
|
285
|
-
opus_model = env("ANTHROPIC_DEFAULT_OPUS_MODEL", "")
|
|
286
|
-
sonnet_model = env("ANTHROPIC_DEFAULT_SONNET_MODEL", "")
|
|
287
|
-
haiku_model = env("ANTHROPIC_DEFAULT_HAIKU_MODEL", "")
|
|
288
|
-
if opus_model and opus_model == sonnet_model == haiku_model:
|
|
289
|
-
cluster = "single"
|
|
290
|
-
resolved_model = opus_model # all tiers same model
|
|
291
|
-
elif opus_model:
|
|
292
|
-
cluster = "tiered"
|
|
293
|
-
resolved_model = None # each tier resolves differently
|
|
294
|
-
else:
|
|
295
|
-
cluster = "unknown"
|
|
296
|
-
resolved_model = env("CLAUDE_CODE_SUBAGENT_MODEL", "unknown")
|
|
297
|
-
|
|
298
|
-
# --- Role-to-tier mapping for tiered cluster dispatch ---
|
|
299
|
-
ROLE_TIER = {
|
|
300
|
-
"review-plan": "opus",
|
|
301
|
-
"review-code": "opus",
|
|
302
|
-
"validate": "opus",
|
|
303
|
-
"approve": "opus",
|
|
304
|
-
"plan": "sonnet",
|
|
305
|
-
"implement": "sonnet",
|
|
306
|
-
"commit": "haiku",
|
|
307
|
-
"writeback": "haiku",
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
# --- Clear progress log for this sprint ---
|
|
311
|
-
progress_log_path = f".forge/store/events/{sprint_id}/progress.log"
|
|
312
|
-
run_bash(f'FORGE_ROOT=$(node -e "console.log(require(\'./.forge/config.json\').paths.forgeRoot)") && node "$FORGE_ROOT/tools/store-cli.cjs" progress-clear {sprint_id}')
|
|
313
|
-
|
|
314
|
-
while i < len(phases):
|
|
315
|
-
phase = phases[i]
|
|
316
|
-
|
|
317
|
-
# --- Resolve model for display and dispatch (see Model Resolution) ---
|
|
318
|
-
if phase.model: # per-phase override from config
|
|
319
|
-
display_model = phase.model
|
|
320
|
-
dispatch_model = phase.model # pass override to Agent tool
|
|
321
|
-
if env(f"ANTHROPIC_DEFAULT_{phase.model.upper()}_MODEL"):
|
|
322
|
-
resolved = env(f"ANTHROPIC_DEFAULT_{phase.model.upper()}_MODEL")
|
|
323
|
-
display_model = f"{phase.model} → {resolved}"
|
|
324
|
-
elif cluster == "single" and resolved_model:
|
|
325
|
-
display_model = resolved_model
|
|
326
|
-
dispatch_model = None # inherit parent model
|
|
327
|
-
elif cluster == "tiered":
|
|
328
|
-
tier = ROLE_TIER.get(phase.role, "sonnet")
|
|
329
|
-
resolved = env(f"ANTHROPIC_DEFAULT_{tier.upper()}_MODEL", tier)
|
|
330
|
-
display_model = f"{tier} → {resolved}" if resolved != tier else tier
|
|
331
|
-
dispatch_model = tier # pass tier name, Claude Code resolves
|
|
332
|
-
else:
|
|
333
|
-
# Unknown cluster: no ANTHROPIC_DEFAULT_*_MODEL vars set.
|
|
334
|
-
# Fall back to ROLE_TIER with canonical model defaults so subagents
|
|
335
|
-
# run on a predictable model instead of inheriting the orchestrator's own.
|
|
336
|
-
ROLE_TIER_DEFAULTS = {
|
|
337
|
-
"opus": "claude-opus-4-5",
|
|
338
|
-
"sonnet": "claude-sonnet-4-6",
|
|
339
|
-
"haiku": "claude-haiku-4-5",
|
|
340
|
-
}
|
|
341
|
-
tier = ROLE_TIER.get(phase.role, "sonnet")
|
|
342
|
-
canonical = ROLE_TIER_DEFAULTS[tier]
|
|
343
|
-
display_model = f"{tier} → {canonical}"
|
|
344
|
-
dispatch_model = canonical # pass full model id to Agent tool
|
|
345
|
-
|
|
346
|
-
# --- Compute eventId before spawning so the subagent can name its sidecar ---
|
|
347
|
-
start_ts = current_iso_timestamp() # e.g. "20260415T141523000Z"
|
|
348
|
-
event_id = f"{start_ts}_{task_id}_{phase.role}_{phase.action}"
|
|
349
|
-
sidecar_path = f".forge/store/events/{sprint_id}/_{event_id}_usage.json" # used by merge-sidecar
|
|
350
|
-
|
|
351
|
-
# --- Compute agent name for progress IPC ---
|
|
352
|
-
persona_noun = ROLE_TO_NOUN.get(phase.role, phase.role)
|
|
353
|
-
iteration = iteration_counts.get(phase.command, 0) + 1
|
|
354
|
-
agent_name = f"{task_id}:{persona_noun}:{phase.role}:{iteration}"
|
|
355
|
-
|
|
356
|
-
# --- Announce phase with identity banner (badge) + task context ---
|
|
357
|
-
emoji, persona_name, tagline = PERSONA_MAP.get(phase.role, ("🌊", "Orchestrator", "I move tasks through their lifecycle."))
|
|
358
|
-
banner_name = BANNER_MAP.get(phase.role, "forge")
|
|
359
|
-
run_bash(f'FORGE_ROOT=$(node -e "console.log(require(\'./.forge/config.json\').paths.forgeRoot)") && node "$FORGE_ROOT/tools/banners.cjs" --badge {banner_name}')
|
|
360
|
-
print(f" → {task_id} [{display_model}]\n")
|
|
361
|
-
|
|
362
|
-
# --- Start progress Monitor before spawning subagent ---
|
|
363
|
-
# The Monitor streams lines from the progress log as the subagent works.
|
|
364
|
-
# New lines arrive as notifications while the Agent tool blocks on the subagent.
|
|
365
|
-
start_monitor(
|
|
366
|
-
command=f"tail -n +1 -F {progress_log_path} 2>/dev/null || true",
|
|
367
|
-
description=f"Progress: {agent_name}",
|
|
368
|
-
persistent=False
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
# --- Pre-flight gate check (see Phase Gates below) ---
|
|
372
|
-
# Resolve FORGE_ROOT once so the CLI shim can locate the gate parser.
|
|
373
|
-
FORGE_ROOT = resolve_forge_root()
|
|
374
|
-
preflight_result = run_bash(
|
|
375
|
-
f'node "$FORGE_ROOT/tools/preflight-gate.cjs" --phase {phase.role} --task {task_id}'
|
|
376
|
-
)
|
|
377
|
-
if preflight_result.exit_code == 1:
|
|
378
|
-
# Gate failed: halt the orchestrator loop for THIS task. Do not retry,
|
|
379
|
-
# do not spawn. Missing prerequisites are listed on stderr.
|
|
380
|
-
print(f" ✗ {task_id} {phase.role} — gate failed\n{preflight_result.stderr}")
|
|
381
|
-
append_progress(progress_log_path, f"❌ Gate failed for {phase.role}: {preflight_result.stderr}")
|
|
382
|
-
emit_event(task, phase, action="gate_failed", notes=preflight_result.stderr)
|
|
383
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
384
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
385
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
386
|
-
action="escalated", verdict="escalated",
|
|
387
|
-
notes=f"gate_failed: {preflight_result.stderr}")
|
|
388
|
-
print(f" ⚠ Task {task_id} escalated: gate_failed: {preflight_result.stderr}\n")
|
|
389
|
-
print(f" Review artifact: {artifact_path}\n")
|
|
390
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
391
|
-
break # stop processing this task
|
|
392
|
-
elif preflight_result.exit_code == 2:
|
|
393
|
-
# Misconfiguration (unknown phase, malformed gates block). Fail loud.
|
|
394
|
-
print(f" ⚠ {task_id} {phase.role} — gate misconfigured\n{preflight_result.stderr}")
|
|
395
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
396
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
397
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
398
|
-
action="escalated", verdict="escalated",
|
|
399
|
-
notes=f"gate_misconfigured: {preflight_result.stderr}")
|
|
400
|
-
print(f" ⚠ Task {task_id} escalated: gate_misconfigured: {preflight_result.stderr}\n")
|
|
401
|
-
print(f" Review artifact: {artifact_path}\n")
|
|
402
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
403
|
-
break
|
|
404
|
-
|
|
405
|
-
# --- Invoke phase as subagent (fresh context per phase) ---
|
|
406
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration, action="start")
|
|
407
|
-
|
|
408
|
-
# Symmetric Injection Assembly: Persona -> Skill -> Workflow
|
|
409
|
-
# Mode is governed by FORGE_PROMPT_MODE (default: "reference").
|
|
410
|
-
# See "Persona injection modes" below for the full helper definition.
|
|
411
|
-
role_block = compose_role_block(persona_noun)
|
|
412
|
-
|
|
413
|
-
# --- Compose prior-phase summary block (delta: last 3 phases only) ---
|
|
414
|
-
# <!-- See _fragments/context-injection.md for canonical definition -->
|
|
415
|
-
summary_block = compose_summary_block(task_id, record_type="task") if phase.context.prior_summaries != "none" else ""
|
|
416
|
-
|
|
417
|
-
# --- Compose architecture context block (conditional on phase.context.architecture) ---
|
|
418
|
-
# <!-- See _fragments/context-injection.md for canonical definition -->
|
|
419
|
-
architecture_block = (
|
|
420
|
-
compose_architecture_block(".forge/cache/context-pack.md", ".forge/cache/context-pack.json")
|
|
421
|
-
if phase.context.architecture else ""
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
# --- Materialize project overlay (replaces MASTER_INDEX.md read in subagent) ---
|
|
425
|
-
overlay_result = run_bash(
|
|
426
|
-
f'node "$FORGE_ROOT/tools/build-overlay.cjs" --task {task_id} --format md'
|
|
427
|
-
)
|
|
428
|
-
overlay_md = overlay_result.stdout if overlay_result.exit_code == 0 else ""
|
|
429
|
-
|
|
430
|
-
# --- Load finalize fragment (token reporting contract) ---
|
|
431
|
-
finalize_fragment = read_file(f"{FORGE_ROOT}/meta/workflows/_fragments/finalize.md") if file_exists(f"{FORGE_ROOT}/meta/workflows/_fragments/finalize.md") else ""
|
|
432
|
-
|
|
433
|
-
# --- Compose review loop context block (review-role phases only) ---
|
|
434
|
-
# Injected between summary_block and role_block so reviewers know their
|
|
435
|
-
# position in the revision loop at the moment they are spawned.
|
|
436
|
-
# `iteration` is the current attempt number (pre-spawn, not post-increment).
|
|
437
|
-
# `phase.maxIterations` is the configured limit (default 3).
|
|
438
|
-
if phase.role in ("review-plan", "review-code", "validate"):
|
|
439
|
-
review_loop_context = (
|
|
440
|
-
f"### Review Loop Context\n"
|
|
441
|
-
f"- Iteration: {iteration} of {phase.maxIterations}\n"
|
|
442
|
-
f"- Is final iteration: {iteration >= phase.maxIterations}\n\n"
|
|
443
|
-
)
|
|
444
|
-
else:
|
|
445
|
-
review_loop_context = ""
|
|
446
|
-
|
|
447
|
-
spawn_kwargs = dict(
|
|
448
|
-
prompt=(
|
|
449
|
-
f"Append progress entries to {progress_log_path} via store-cli "
|
|
450
|
-
f"(agent: {agent_name}, banner: {banner_name}) — see _fragments/progress-reporting.md.\n\n"
|
|
451
|
-
f"---\n\n"
|
|
452
|
-
f"{architecture_block}"
|
|
453
|
-
f"{summary_block}"
|
|
454
|
-
f"{review_loop_context}"
|
|
455
|
-
f"{role_block}\n\n"
|
|
456
|
-
f"### Project Context\n"
|
|
457
|
-
f"{overlay_md}\n\n"
|
|
458
|
-
f"### Current Working Context\n"
|
|
459
|
-
f"- Sprint Root: {sprint_root_path}\n"
|
|
460
|
-
f"- Task Root: {task_root_path}\n"
|
|
461
|
-
f"- Store Root: {store_root_path}\n\n"
|
|
462
|
-
f"Read `.forge/workflows/{phase.workflow}` and follow it. Task ID: {task_id}.\n\n"
|
|
463
|
-
f"{finalize_fragment}"
|
|
464
|
-
),
|
|
465
|
-
description=f"{emoji} {persona_name} — {phase.name} for {task_id}",
|
|
466
|
-
)
|
|
467
|
-
if dispatch_model:
|
|
468
|
-
spawn_kwargs["model"] = dispatch_model
|
|
469
|
-
spawn_subagent(**spawn_kwargs)
|
|
470
|
-
# Subagent reads all context from disk, does its work, writes artifacts/status to disk, then exits.
|
|
471
|
-
|
|
472
|
-
# --- Stop progress Monitor ---
|
|
473
|
-
stop_monitor(progress_log_path)
|
|
474
|
-
|
|
475
|
-
# --- Subagent response validation (retry once, escalate on second failure) ---
|
|
476
|
-
# The subagent must produce a usable result. Three failure classes:
|
|
477
|
-
# 1. Empty response: subagent returned nothing or whitespace-only output
|
|
478
|
-
# 2. Subagent error: subagent exited non-zero (crash, OOM, tool error)
|
|
479
|
-
# 3. Timeout: subagent did not return within the session timeout
|
|
480
|
-
#
|
|
481
|
-
# On first failure: retry once with a simplified prompt that strips
|
|
482
|
-
# non-essential context (summary block, architecture block) and adds
|
|
483
|
-
# a direct instruction to produce a verdict or error report.
|
|
484
|
-
# On second failure: escalate to human — do NOT continue the phase loop.
|
|
485
|
-
|
|
486
|
-
if subagent_failed_or_empty(result):
|
|
487
|
-
if retry_count.get(phase.command, 0) == 0:
|
|
488
|
-
# First failure: retry with simplified prompt
|
|
489
|
-
retry_count[phase.command] = 1
|
|
490
|
-
print(f" ⚠ {task_id} {phase.role} — subagent response empty or errored, retrying with simplified prompt\n")
|
|
491
|
-
emit_event(task, phase, action="subagent_retry",
|
|
492
|
-
notes=f"first failure: {subagent_failure_reason(result)}")
|
|
493
|
-
|
|
494
|
-
# Simplify: remove summary_block and architecture_block from prompt
|
|
495
|
-
simplified_kwargs = dict(spawn_kwargs)
|
|
496
|
-
simplified_kwargs["prompt"] = (
|
|
497
|
-
f"### Progress Reporting\n"
|
|
498
|
-
f"- Agent name: {agent_name}\n"
|
|
499
|
-
f"- Progress log: {progress_log_path}\n"
|
|
500
|
-
f"- Banner key: {banner_name}\n\n"
|
|
501
|
-
f"Append progress entries as you work.\n\n"
|
|
502
|
-
f"---\n\n"
|
|
503
|
-
f"{review_loop_context}"
|
|
504
|
-
f"{role_block}\n\n"
|
|
505
|
-
f"### Current Working Context\n"
|
|
506
|
-
f"- Sprint Root: {sprint_root_path}\n"
|
|
507
|
-
f"- Task Root: {task_root_path}\n"
|
|
508
|
-
f"- Store Root: {store_root_path}\n\n"
|
|
509
|
-
f"Read `.forge/workflows/{phase.workflow}` and follow it. Task ID: {task_id}.\n\n"
|
|
510
|
-
f"{overlay_md}\n\n"
|
|
511
|
-
f"IMPORTANT: You MUST produce a result. If the workflow cannot complete, "
|
|
512
|
-
f"write a verdict or error report to the expected artifact path and return."
|
|
513
|
-
)
|
|
514
|
-
spawn_subagent(**simplified_kwargs)
|
|
515
|
-
stop_monitor(progress_log_path)
|
|
516
|
-
|
|
517
|
-
# Re-validate the retry result
|
|
518
|
-
if subagent_failed_or_empty(result):
|
|
519
|
-
# Second failure: escalate
|
|
520
|
-
print(f" ✗ {task_id} {phase.role} — subagent failed after retry, escalating\n")
|
|
521
|
-
emit_event(task, phase, action="subagent_escalated",
|
|
522
|
-
notes=f"second failure: {subagent_failure_reason(result)}")
|
|
523
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
524
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
525
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
526
|
-
action="escalated", verdict="escalated",
|
|
527
|
-
notes=f"subagent failed after retry: {subagent_failure_reason(result)}")
|
|
528
|
-
print(f" ⚠ Task {task_id} escalated: subagent {phase.role} failed after retry — {subagent_failure_reason(result)}\n")
|
|
529
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
530
|
-
break
|
|
531
|
-
else:
|
|
532
|
-
# Already retried once — this is the second failure
|
|
533
|
-
print(f" ✗ {task_id} {phase.role} — subagent failed after retry, escalating\n")
|
|
534
|
-
emit_event(task, phase, action="subagent_escalated",
|
|
535
|
-
notes=f"second failure: {subagent_failure_reason(result)}")
|
|
536
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
537
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
538
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
539
|
-
action="escalated", verdict="escalated",
|
|
540
|
-
notes=f"subagent failed after retry: {subagent_failure_reason(result)}")
|
|
541
|
-
print(f" ⚠ Task {task_id} escalated: subagent {phase.role} failed after retry — {subagent_failure_reason(result)}\n")
|
|
542
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
543
|
-
break
|
|
544
|
-
|
|
545
|
-
# --- Sidecar merge: merge token usage written by subagent via custodian ---
|
|
546
|
-
# The subagent wrote the sidecar via node "$FORGE_ROOT/tools/store-cli.cjs" emit {sprintId} '{sidecar-json}' --sidecar
|
|
547
|
-
# Merge the sidecar into the canonical event and delete the sidecar file
|
|
548
|
-
FORGE_ROOT = resolve_forge_root()
|
|
549
|
-
run: node "$FORGE_ROOT/tools/store-cli.cjs" merge-sidecar {sprint_id} {event_id}
|
|
550
|
-
# merge-sidecar reads the sidecar, merges token fields into the canonical event, and deletes the sidecar
|
|
551
|
-
# If the sidecar does not exist, merge-sidecar exits 1 — treat as non-fatal (subagent may have skipped it)
|
|
552
|
-
emit_event(task, phase, action="complete")
|
|
553
|
-
|
|
554
|
-
# --- Phase-exit signal ---
|
|
555
|
-
# Non-review phases always advance with a completion signal
|
|
556
|
-
if phase.role not in ("review-plan", "review-code", "validate"):
|
|
557
|
-
print(f" ✓ {task_id} {phase.role} — completed\n")
|
|
558
|
-
i += 1
|
|
559
|
-
# Compact context: all state is on disk; preserve loop bookkeeping in the summary
|
|
560
|
-
print(f"[checkpoint] task={task_id} sprint={sprint_id} phase_index={i} iterations={iteration_counts}")
|
|
561
|
-
/compact
|
|
562
|
-
continue
|
|
563
|
-
|
|
564
|
-
# --- Review phase: detect verdict via read-verdict.cjs (see Verdict Detection below) ---
|
|
565
|
-
# Verdicts come from the STORE record (phase summaries / task.status), NOT from a
|
|
566
|
-
# markdown review artifact — the orchestrator never constructs an artifact path.
|
|
567
|
-
# stdout is one of: approved | revision | n/a | unknown. Never pattern-match a
|
|
568
|
-
# **Verdict:** line — the closed vocabulary lives in the tool.
|
|
569
|
-
verdict_result = run_bash(
|
|
570
|
-
f'node "$FORGE_ROOT/tools/read-verdict.cjs" --phase {phase.role} --task {task_id}'
|
|
571
|
-
)
|
|
572
|
-
verdict_token = verdict_result.stdout.strip()
|
|
573
|
-
if verdict_token == "approved":
|
|
574
|
-
verdict = "Approved"
|
|
575
|
-
elif verdict_token == "revision":
|
|
576
|
-
verdict = "Revision Required"
|
|
577
|
-
else:
|
|
578
|
-
# "n/a" / "unknown" (no verdict recorded) or exit 2 (record not found / bad args).
|
|
579
|
-
# Never guess.
|
|
580
|
-
print(f" ⚠ {task_id} {phase.role} — verdict_malformed, escalating\n")
|
|
581
|
-
emit_event(task, phase, action="verdict_malformed",
|
|
582
|
-
notes=f"read-verdict stdout='{verdict_token}' exit={verdict_result.exit_code}")
|
|
583
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
584
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
585
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
586
|
-
action="escalated", verdict="escalated",
|
|
587
|
-
notes="verdict_malformed: no verdict recorded in the phase summary / record")
|
|
588
|
-
print(f" ⚠ Task {task_id} escalated: verdict_malformed — no verdict recorded for {phase.role}\n")
|
|
589
|
-
print(f" Inspect with: node \"$FORGE_ROOT/tools/read-verdict.cjs\" --phase {phase.role} --task {task_id}\n")
|
|
590
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
591
|
-
break
|
|
592
|
-
|
|
593
|
-
if verdict == "Approved":
|
|
594
|
-
print(f" ✓ {task_id} {phase.role} — Approved\n")
|
|
595
|
-
i += 1 # advance to next phase
|
|
596
|
-
# Compact context: all state is on disk; preserve loop bookkeeping in the summary
|
|
597
|
-
print(f"[checkpoint] task={task_id} sprint={sprint_id} phase_index={i} iterations={iteration_counts}")
|
|
598
|
-
/compact
|
|
599
|
-
|
|
600
|
-
elif verdict == "Revision Required":
|
|
601
|
-
iteration_counts[phase.command] = iteration_counts.get(phase.command, 0) + 1
|
|
602
|
-
print(f" ↻ {task_id} {phase.role} — Revision Required (iteration {iteration_counts[phase.command]})\n")
|
|
603
|
-
|
|
604
|
-
if iteration_counts[phase.command] >= phase.maxIterations: # default 3
|
|
605
|
-
# ---- ESCALATION (mandatory hard stop — do NOT continue) ----
|
|
606
|
-
run_bash(f'node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {task_id} status escalated')
|
|
607
|
-
emit_event(task, phase, eventId=event_id, iteration=iteration,
|
|
608
|
-
action="escalated", verdict="escalated",
|
|
609
|
-
notes="max iterations reached")
|
|
610
|
-
print(f" ⚠ Task {task_id} escalated: max iterations reached\n")
|
|
611
|
-
print(f" Inspect with: node \"$FORGE_ROOT/tools/read-verdict.cjs\" --phase {phase.role} --task {task_id}\n")
|
|
612
|
-
print(f" Resume with: /{phase.command} {task_id} after addressing the issues.\n")
|
|
613
|
-
break
|
|
614
|
-
break # stop processing this task
|
|
615
|
-
|
|
616
|
-
# Route back to the revision target
|
|
617
|
-
target = phase.on_revision or nearest_preceding_non_review(phases, i)
|
|
618
|
-
i = index_of(phases, target) # loop back
|
|
619
|
-
# Compact context: all state is on disk; preserve loop bookkeeping in the summary
|
|
620
|
-
print(f"[checkpoint] task={task_id} sprint={sprint_id} phase_index={i} iterations={iteration_counts}")
|
|
621
|
-
/compact
|
|
622
|
-
|
|
623
|
-
# No `else:` branch needed — read-verdict.cjs already exhausts the
|
|
624
|
-
# possibilities (approved | revision | verdict_malformed), and the
|
|
625
|
-
# malformed case is handled above before this if/elif chain.
|
|
626
|
-
```
|
|
627
|
-
|
|
628
|
-
## Agent Naming Convention
|
|
629
|
-
|
|
630
|
-
Each subagent is assigned a structured name at spawn time:
|
|
631
|
-
|
|
632
|
-
```
|
|
633
|
-
{taskId}:{persona_noun}:{phase.role}:{iteration}
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
| Component | Source | Example |
|
|
637
|
-
|-----------|--------|---------|
|
|
638
|
-
| `taskId` | Task ID from manifest | `FORGE-S09-T01` |
|
|
639
|
-
| `persona_noun` | `ROLE_TO_NOUN` mapping | `engineer`, `supervisor`, `qa-engineer` |
|
|
640
|
-
| `phase.role` | Pipeline phase role | `plan`, `review-plan`, `implement` |
|
|
641
|
-
| `iteration` | 1-based revision count for this phase | `1`, `2`, `3` |
|
|
642
|
-
|
|
643
|
-
Examples:
|
|
644
|
-
|
|
645
|
-
- `FORGE-S09-T01:engineer:plan:1` — First plan attempt for T01
|
|
646
|
-
- `FORGE-S09-T01:supervisor:review-plan:1` — First plan review for T01
|
|
647
|
-
- `FORGE-S09-T01:engineer:update-impl:2` — Second implementation revision for T01
|
|
648
|
-
|
|
649
|
-
The agent name is passed in the subagent prompt and used in every progress log
|
|
650
|
-
entry the subagent writes. It provides identity and traceability for mid-task
|
|
651
|
-
feedback.
|
|
652
|
-
|
|
653
|
-
## Progress Reporting
|
|
654
|
-
|
|
655
|
-
<!-- See _fragments/progress-reporting.md for canonical definition -->
|
|
656
|
-
> See `_fragments/progress-reporting.md` for the full progress log format and `store-cli progress` command reference.
|
|
657
|
-
|
|
658
|
-
Log path: `.forge/store/events/{sprintId}/progress.log`. Format: `{ISO_TIMESTAMP}|{agent_name}|{banner_key}|{status}|{detail}`. Clear at task start: `store-cli progress-clear {sprintId}`.
|
|
659
|
-
|
|
660
|
-
## Phase-Exit Signals
|
|
661
|
-
|
|
662
|
-
After each subagent returns, the orchestrator prints a phase-exit signal:
|
|
663
|
-
|
|
664
|
-
| Outcome | Format |
|
|
665
|
-
|---------|--------|
|
|
666
|
-
| Non-review phase completed | ` ✓ {task_id} {phase_role} — completed` |
|
|
667
|
-
| Review verdict: Approved | ` ✓ {task_id} {phase_role} — Approved` |
|
|
668
|
-
| Review verdict: Revision Required | ` ↻ {task_id} {phase_role} — Revision Required (iteration {n})` |
|
|
669
|
-
| Escalated | ` ⚠ {task_id} {phase_role} — escalated to human` |
|
|
670
|
-
|
|
671
|
-
Examples:
|
|
672
|
-
|
|
673
|
-
```
|
|
674
|
-
✓ FORGE-S09-T01 plan — completed
|
|
675
|
-
✓ FORGE-S09-T01 review-plan — Approved
|
|
676
|
-
↻ FORGE-S09-T01 review-plan — Revision Required (iteration 2)
|
|
677
|
-
⚠ FORGE-S09-T01 validate — escalated to human
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
## Verdict Detection
|
|
681
|
-
|
|
682
|
-
After each review phase completes, the orchestrator MUST read the verdict
|
|
683
|
-
before branching. Do not infer the verdict from conversation context alone, and
|
|
684
|
-
**never construct or read a markdown artifact path** to find it — the verdict
|
|
685
|
-
lives in the **store record** (the phase summary written by `set-summary`, or
|
|
686
|
-
`task.status` for the approve phase).
|
|
687
|
-
|
|
688
|
-
**Read the verdict via `read-verdict.cjs`** — addressed by entity ID and phase
|
|
689
|
-
role, never by file path. The tool sources the verdict from the record and
|
|
690
|
-
enforces a closed vocabulary so typos, case drift, and reviewer prose cannot
|
|
691
|
-
cause silent misclassification:
|
|
692
|
-
|
|
693
|
-
```
|
|
694
|
-
FORGE_ROOT = resolve_forge_root()
|
|
695
|
-
result = run_bash(f'node "$FORGE_ROOT/tools/read-verdict.cjs" --phase {phase.role} --task {task_id}')
|
|
696
|
-
# stdout "approved" → approved
|
|
697
|
-
# stdout "revision" → revision
|
|
698
|
-
# stdout "n/a" | "unknown" → no verdict recorded (treat as malformed; do NOT guess)
|
|
699
|
-
# exit 2 → record not found / invalid args (treat as malformed)
|
|
700
|
-
```
|
|
701
|
-
|
|
702
|
-
Branch on the **stdout token** (exit 1 bundles both `revision` and the
|
|
703
|
-
no-verdict cases, so the token is authoritative). Recognised verdict values:
|
|
704
|
-
|
|
705
|
-
- **approved** — written as `verdict: "approved"` in the phase summary (or `task.status == approved` for the approve phase).
|
|
706
|
-
- **revision** — `verdict: "revision"`.
|
|
707
|
-
|
|
708
|
-
Anything else — `n/a`, `unknown`, a missing summary, or a missing record —
|
|
709
|
-
must NOT be treated as approved or revision; halt the loop and escalate via
|
|
710
|
-
`verdict_malformed`. (In bug mode pass `--bug {bug_id}`; `read-verdict.cjs`
|
|
711
|
-
applies the bug-specific phase→summary map.)
|
|
712
|
-
|
|
713
|
-
## Escalation Procedure
|
|
714
|
-
|
|
715
|
-
> **NOTE:** The Escalation Procedure is inlined at every call site in the
|
|
716
|
-
> Execution Algorithm. This section remains as a reference. When adding new
|
|
717
|
-
> escalation points, inline the full procedure — do NOT call `escalate_to_human()`
|
|
718
|
-
> as a bare function name.
|
|
719
|
-
|
|
720
|
-
When escalating to the human:
|
|
721
|
-
|
|
722
|
-
1. Update task status via `node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {taskId} status escalated`
|
|
723
|
-
2. Emit a final event with `verdict: "escalated"` and `notes` explaining the reason
|
|
724
|
-
3. Output a clear message:
|
|
725
|
-
```
|
|
726
|
-
⚠ Task {TASK_ID} escalated: {reason}
|
|
727
|
-
Review artifact: {artifact_path}
|
|
728
|
-
Resume with: /{phase.command} {TASK_ID} after addressing the issues.
|
|
729
|
-
```
|
|
730
|
-
4. Stop processing this task. Continue to the next task in the sprint.
|
|
731
|
-
|
|
732
|
-
## Phase Gates
|
|
733
|
-
|
|
734
|
-
Declarative pre-flight gates for each phase. The orchestrator evaluates these
|
|
735
|
-
via `forge/tools/preflight-gate.cjs` **before** every subagent spawn. A failing
|
|
736
|
-
gate halts the loop for this task — no retry, no fall-through to the subagent,
|
|
737
|
-
no silent recovery. Gates are data, not prose: the grammar is defined in
|
|
738
|
-
`forge/tools/parse-gates.cjs` and validated by its test suite.
|
|
739
|
-
|
|
740
|
-
Grammar (one directive per line):
|
|
741
|
-
- `artifact <path> [min=<bytes>]` — file must exist and meet size floor. Path
|
|
742
|
-
templates: `{sprint}` → sprintId, `{task}` → task suffix, `{bug}` → bugId.
|
|
743
|
-
- `require <field> <op> <value>` — predicate must hold. Ops: `==`, `!=`,
|
|
744
|
-
`in [v1, v2, ...]`. Fields are dotted paths against the store record, e.g.
|
|
745
|
-
`task.status`.
|
|
746
|
-
- `forbid <field> <op> <value>` — predicate must NOT hold.
|
|
747
|
-
- `after <phase> = <approved|revision>` — predecessor phase's stored verdict
|
|
748
|
-
must match (read from the record by `read-verdict.cjs`, not from markdown).
|
|
749
|
-
|
|
750
|
-
```gates phase=plan
|
|
751
|
-
forbid task.status == committed
|
|
752
|
-
forbid task.status == abandoned
|
|
753
|
-
forbid task.status == blocked
|
|
754
|
-
forbid task.status == escalated
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
```gates phase=implement
|
|
758
|
-
artifact {engineering}/sprints/{sprint}/{task}/PLAN.md min=200
|
|
759
|
-
after review-plan = approved
|
|
760
|
-
forbid task.status == committed
|
|
761
|
-
forbid task.status == blocked
|
|
762
|
-
forbid task.status == escalated
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
```gates phase=review-plan
|
|
766
|
-
artifact {engineering}/sprints/{sprint}/{task}/PLAN.md min=200
|
|
767
|
-
forbid task.status == blocked
|
|
768
|
-
forbid task.status == escalated
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
```gates phase=review-code
|
|
772
|
-
after review-plan = approved
|
|
773
|
-
forbid task.status == blocked
|
|
774
|
-
forbid task.status == escalated
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
```gates phase=validate
|
|
778
|
-
after review-code = approved
|
|
779
|
-
forbid task.status == blocked
|
|
780
|
-
forbid task.status == escalated
|
|
781
|
-
```
|
|
782
|
-
|
|
783
|
-
```gates phase=approve
|
|
784
|
-
after review-code = approved
|
|
785
|
-
forbid task.status == blocked
|
|
786
|
-
forbid task.status == escalated
|
|
787
|
-
```
|
|
788
|
-
|
|
789
|
-
```gates phase=commit
|
|
790
|
-
after approve = approved
|
|
791
|
-
forbid task.status == blocked
|
|
792
|
-
forbid task.status == escalated
|
|
793
|
-
```
|
|
794
|
-
|
|
795
|
-
Adjusting a gate is a data change — edit the block above, regenerate workflows
|
|
796
|
-
on the user side via `/forge:update`, and the new gate takes effect on the next
|
|
797
|
-
orchestrator run. No code change required to relax or tighten a gate.
|
|
798
|
-
|
|
799
|
-
## Write-Boundary Contract
|
|
800
|
-
|
|
801
|
-
You MAY write Forge-owned JSON (`task.json`, `sprint.json`, `bug.json`,
|
|
802
|
-
events sidecars, `COLLATION_STATE.json`, `progress.log`) directly with the
|
|
803
|
-
`Write` or `Edit` tools. You do NOT need to route every write through
|
|
804
|
-
`store-cli` — the probabilistic layer is free to bypass deterministic tools.
|
|
805
|
-
|
|
806
|
-
However, **every write to a Forge-owned path is schema-validated at the
|
|
807
|
-
filesystem boundary** by the `PreToolUse` hook at
|
|
808
|
-
`hooks/validate-write.js`. A malformed write is rejected with a message
|
|
809
|
-
naming the offending field and pointing at the relevant
|
|
810
|
-
`forge/schemas/<kind>.schema.json`. Fix the data and retry — do NOT try to
|
|
811
|
-
disable the hook.
|
|
812
|
-
|
|
813
|
-
`store-cli` is still the most convenient path (it handles ID allocation,
|
|
814
|
-
referential integrity, ghost-event semantics, and sidecar merging), but it
|
|
815
|
-
is one route among several. The schema invariant is preserved whichever
|
|
816
|
-
route you take.
|
|
817
|
-
|
|
818
|
-
**Emergency bypass.** For operator-driven repair, set
|
|
819
|
-
`FORGE_SKIP_WRITE_VALIDATION=1` for a single turn. The hook will let the
|
|
820
|
-
write through and append an audit line to the affected sprint's
|
|
821
|
-
`progress.log`.
|
|
822
|
-
|
|
823
|
-
<!-- See _fragments/iron-laws.md for Iron Laws section structure guidance (orchestrate uses orchestrator-special deferral to generic-skills.md § Orchestrator Iron Laws) -->
|
|
824
|
-
## Iron Laws
|
|
825
|
-
|
|
826
|
-
<!-- Shared orchestrator laws live in generic-skills.md § Orchestrator Iron Laws. -->
|
|
827
|
-
> See `generic-skills.md § Orchestrator Iron Laws` for the six universal laws that apply to all orchestrators.
|
|
828
|
-
|
|
829
|
-
**Additional law specific to this pipeline:**
|
|
830
|
-
|
|
831
|
-
**YOU MUST NOT silently work around a blocker.** If a phase fails, a subagent
|
|
832
|
-
returns empty, a gate fails, or a verdict cannot be parsed, the orchestrator
|
|
833
|
-
MUST either retry once (for recoverable failures) or escalate to the human.
|
|
834
|
-
Skipping the phase, fabricating a result, assuming success without evidence,
|
|
835
|
-
or continuing with a degraded response is NEVER acceptable. Every failure MUST
|
|
836
|
-
produce a visible signal (✗ or ⚠) and a structured event. Silent continuation
|
|
837
|
-
is a violation of the Iron Laws.
|
|
838
|
-
|
|
839
|
-
## Error Recovery
|
|
840
|
-
|
|
841
|
-
- Test/build failure: pass error to Engineer revision workflow, retry once
|
|
842
|
-
- Verdict "Revision Required": enter revision loop (up to max_iterations)
|
|
843
|
-
- Subagent empty/crash/timeout response: retry once with simplified prompt
|
|
844
|
-
(strip summary and architecture blocks). Escalate on second failure.
|
|
845
|
-
See Subagent Response Validation in the Execution Algorithm.
|
|
846
|
-
- Subagent non-zero exit code (not read-verdict): same as above — retry
|
|
847
|
-
once, escalate on second failure. The crash reason is captured in the
|
|
848
|
-
escalation event notes.
|
|
849
|
-
- Verdict malformed or missing: escalate to human immediately. Never guess.
|
|
850
|
-
- Revision loop exhaustion: escalate to human immediately. Never approve
|
|
851
|
-
to unblock.
|
|
852
|
-
- Gate failure (preflight): escalate to human. No retry, no fall-through.
|
|
853
|
-
- Gate misconfiguration: escalate to human. No retry, no fall-through.
|
|
854
|
-
- Git hook failure: diagnose, fix, create new commit
|
|
855
|
-
- Merge conflict: escalate to human
|
|
856
|
-
- Task status is blocked or escalated: skip the task entirely. Do not
|
|
857
|
-
attempt any phase on it.
|
|
858
|
-
|
|
859
|
-
## Event Emission
|
|
860
|
-
|
|
861
|
-
<!-- See _fragments/event-emission-schema.md for canonical contract -->
|
|
862
|
-
> See `_fragments/event-emission-schema.md` for the actor split (subagent
|
|
863
|
-
> writes judgement-only SUMMARY; orchestrator composes the canonical event
|
|
864
|
-
> from runtime telemetry + SUMMARY and emits it).
|
|
865
|
-
|
|
866
|
-
The **orchestrator** is the only actor that calls `store-cli emit` for phase
|
|
867
|
-
events. Phase subagents write `{PHASE}-SUMMARY.json` and return. After each
|
|
868
|
-
subagent returns, the orchestrator:
|
|
869
|
-
|
|
870
|
-
1. Captures the subagent's runtime attribution (`model`, `provider`, token
|
|
871
|
-
usage) from the runtime stream.
|
|
872
|
-
2. Records bracketed wall times around the spawn call (`startTimestamp`,
|
|
873
|
-
`endTimestamp`, `durationMinutes`).
|
|
874
|
-
3. Reads the SUMMARY for the judgement blob (`verdict`, `notes`, `findings`).
|
|
875
|
-
4. Composes the canonical event with `eventId`, `taskId`, `sprintId`, `role`,
|
|
876
|
-
`action`, `phase`, `iteration` from its own task state and `tokenSource:
|
|
877
|
-
"reported"` when the runtime surfaced usage.
|
|
878
|
-
5. Calls `node "$FORGE_ROOT/tools/store-cli.cjs" emit {sprintId} '{event-json}'`
|
|
879
|
-
with the complete record.
|
|
880
|
-
|
|
881
|
-
Do not include hardcoded example `model` or `provider` strings in the
|
|
882
|
-
generated orchestrator prose — they are the seed of LLM hallucination.
|
|
883
|
-
Refer subagents to `.forge/schemas/event.schema.json` instead.
|
|
884
|
-
|
|
885
|
-
<!-- See _fragments/generation-instructions.md for Generation Instructions template (orchestrate uses orchestrator-special long-form prose — cannot be reduced to standard subsections) -->
|
|
886
|
-
## Friction Emit
|
|
887
|
-
|
|
888
|
-
When the Orchestrator detects skill friction during orchestrate-task — a referenced skill is unused, fails on invocation, is missing from the registry, has gone stale relative to current architecture, or is redundant with another skill — emit a `friction` event so `/forge:rebuild --enrich` (phase 2) can act on the signal. This is the writer side of the channel whose reader landed in S13-T08; the reader is empty without these emits.
|
|
889
|
-
|
|
890
|
-
**Trigger conditions** (set `issue` to the matching token):
|
|
891
|
-
|
|
892
|
-
| Token | When to emit |
|
|
893
|
-
|--------------------|----------------------------------------------------------------------------------|
|
|
894
|
-
| `skill_unused` | A skill listed in the persona's skill block was loaded but never consulted. |
|
|
895
|
-
| `skill_failed` | A skill was consulted but its guidance produced an error or required correction. |
|
|
896
|
-
| `skill_missing` | The workflow needed guidance the available skills did not cover. |
|
|
897
|
-
| `skill_stale` | A skill's guidance contradicts current architecture / supersedes its own advice. |
|
|
898
|
-
| `skill_redundant` | Two skills provided overlapping or conflicting guidance for the same decision. |
|
|
899
|
-
|
|
900
|
-
**Two flavours of friction in orchestrate-task:**
|
|
901
|
-
|
|
902
|
-
1. **Subagent-experienced friction** (the persona running plan / implement /
|
|
903
|
-
validate / etc. detects skill friction). The subagent records the signal
|
|
904
|
-
via `node "$FORGE_ROOT/tools/friction-emit.cjs" --workflow {wf} --persona {p}
|
|
905
|
-
--issue {token} [--subkind {token}] [--evidence '{...}']`, which appends a
|
|
906
|
-
judgement-only record to `.forge/cache/FRICTION-{wf}.jsonl`. After the
|
|
907
|
-
subagent returns, the orchestrator drains this file, stamps the
|
|
908
|
-
subagent's captured runtime attribution (model, provider, usage, wall
|
|
909
|
-
times, eventId) onto each record, and emits the resulting events via
|
|
910
|
-
`store-cli emit` as event type `"friction"`. The orchestrator truncates
|
|
911
|
-
the file only after all emits succeed.
|
|
912
|
-
|
|
913
|
-
2. **Orchestrator-experienced friction** (spawn failure, sidecar missing,
|
|
914
|
-
FSM rejection, verdict malformed). The orchestrator emits inline using
|
|
915
|
-
its own model/provider attribution (`persona: "orchestrator"`,
|
|
916
|
-
`workflow: "orchestrate"`, `phase: "orchestrate"`). Same `store-cli emit`
|
|
917
|
-
path; no example record is reproduced here because the orchestrator
|
|
918
|
-
owns the field values — consult `.forge/schemas/event.schema.json` for
|
|
919
|
-
the required shape.
|
|
920
|
-
|
|
921
|
-
The schema enforces `{workflow, persona, issue}` as required when
|
|
922
|
-
`type === "friction"`. `subkind` is the frozen enum
|
|
923
|
-
`skill_unused|skill_failed|skill_missing|skill_stale|skill_redundant` or
|
|
924
|
-
experimental `^x_[a-z_]+$`. Emit one record per distinct friction signal
|
|
925
|
-
— do not coalesce.
|
|
926
|
-
|
|
927
|
-
The generated `orchestrate_task.md` MUST carry this section verbatim —
|
|
928
|
-
`/forge:rebuild --enrich` (phase 2) greps for it.
|