@ludecker/aaac 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +1 -1
  2. package/src/generators/generate-commands.mjs +17 -9
  3. package/src/run-engine/advance-phase.mjs +152 -1
  4. package/src/run-engine/capability-evidence.mjs +460 -0
  5. package/src/run-engine/gate-write.mjs +14 -2
  6. package/src/run-engine/init-run.mjs +92 -1
  7. package/src/run-engine/lib.mjs +38 -0
  8. package/src/run-engine/record-task.mjs +7 -1
  9. package/src/run-engine/stop-check.mjs +7 -1
  10. package/src/run-engine/verify-website-build.mjs +185 -0
  11. package/templates/cursor/aaac/capabilities/promotion-rules.json +64 -0
  12. package/templates/cursor/aaac/capabilities/registry.json +11 -11
  13. package/templates/cursor/aaac/dispatch.md +2 -2
  14. package/templates/cursor/aaac/enforcement.json +6 -3
  15. package/templates/cursor/aaac/governance/gates.json +3 -1
  16. package/templates/cursor/aaac/graph.project.yaml +4 -204
  17. package/templates/cursor/aaac/layers.md +3 -0
  18. package/templates/cursor/aaac/observability/telemetry.yaml +3 -0
  19. package/templates/cursor/aaac/ontology.md +17 -32
  20. package/templates/cursor/aaac/project.config.json +4 -1
  21. package/templates/cursor/aaac/run/schema.json +5 -1
  22. package/templates/cursor/aaac/scripts/run-engine/advance-phase.mjs +152 -1
  23. package/templates/cursor/aaac/scripts/run-engine/capability-evidence.mjs +460 -0
  24. package/templates/cursor/aaac/scripts/run-engine/gate-write.mjs +14 -2
  25. package/templates/cursor/aaac/scripts/run-engine/init-run.mjs +92 -1
  26. package/templates/cursor/aaac/scripts/run-engine/lib.mjs +38 -0
  27. package/templates/cursor/aaac/scripts/run-engine/record-task.mjs +7 -1
  28. package/templates/cursor/aaac/scripts/run-engine/stop-check.mjs +7 -1
  29. package/templates/cursor/aaac/scripts/run-engine/verify-website-build.mjs +185 -0
  30. package/templates/cursor/aaac/state/capability-stats.json +5 -0
  31. package/templates/cursor/agents/playwright-check-run.md +8 -26
  32. package/templates/cursor/agents/release-git.md +2 -2
  33. package/templates/cursor/agents/unit-test-run.md +3 -7
  34. package/templates/cursor/skills/shared/governance/implementation/SKILL.md +25 -396
  35. package/templates/cursor/skills/shared/platform-release/SKILL.md +22 -19
  36. package/templates/cursor/skills/shared/platform-release/orchestrator/contract.yaml +27 -7
  37. package/templates/cursor/skills/shared/testing/SKILL.md +5 -0
  38. package/templates/cursor/skills/shared/verbs/check/orchestrator/SKILL.md +1 -1
  39. package/templates/cursor/skills/shared/verification/SKILL.md +2 -1
  40. package/templates/docs/agentic_architecture.md +163 -60
@@ -1,127 +1,7 @@
1
- resolvers:
2
- update-module-by-slug:
3
- map:
4
- cms: cms-update
5
- ui: ui-update
6
- database: database-update
7
- aaac: aaac-update
8
- update-component-by-scope:
9
- map:
10
- cms: cms-design-update
11
- ui: ui-design-update
12
- create-feature-by-slug:
13
- map:
14
- cms: cms-create-feature
15
- aaac: aaac-create-feature
16
- fix-bug-by-slug:
17
- map:
18
- cms: cms-fix-bug
19
- ui: ui-fix-bug
20
- database: database-fix-bug
21
- aaac: aaac-fix-bug
22
- default: verb-fix
23
- default_object: feature
24
- fix-domain-by-slug:
25
- map:
26
- cms: cms-fix-bug
27
- ui: ui-fix-bug
28
- database: database-fix-bug
29
- aaac: aaac-fix-bug
30
- default: verb-fix
31
- default_object: module
32
- fix-component-by-scope:
33
- map:
34
- cms: cms-fix-bug
35
- ui: ui-fix-bug
36
- default: verb-fix
37
- default_object: component
38
- fix-data-by-slug:
39
- map:
40
- database: database-fix-bug
41
- default: database-fix-bug
42
- default_object: schema
43
- fix-integration-by-slug:
44
- map:
45
- cms: cms-fix-bug
46
- ui: ui-fix-bug
47
- database: database-fix-bug
48
- aaac: aaac-fix-bug
49
- default: verb-fix
50
- default_object: integration
51
- test-module-by-slug:
52
- map:
53
- cms: cms-test-module
54
- ui: ui-test-module
55
- database: database-test-module
56
- aaac: aaac-test-module
1
+ # Generic AAAC project overlay — verb orchestrators + exception commands only.
2
+ # Add domain resolvers, orchestrators, and project skills in your repo after init.
57
3
 
58
4
  orchestrators:
59
- cms-update:
60
- domain: cms
61
- path: domains/cms/update/orchestrator
62
- inventory: domains/cms/update/inventory
63
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
64
- phases: [load_inventory, discover, investigate_lite, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
65
-
66
- ui-update:
67
- domain: ui
68
- path: domains/ui/update/orchestrator
69
- inventory: domains/ui/update/inventory
70
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
71
- phases: [load_inventory, discover, investigate_lite, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
72
-
73
- database-update:
74
- domain: database
75
- path: domains/database/update/orchestrator
76
- inventory: domains/database/update/inventory
77
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
78
- phases: [load_inventory, discover, investigate_lite, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
79
-
80
- cms-design-update:
81
- domain: cms
82
- path: domains/cms/update/orchestrator
83
- inventory: domains/cms/update/inventory
84
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
85
- design_mode: true
86
-
87
- ui-design-update:
88
- domain: ui
89
- path: domains/ui/update/orchestrator
90
- inventory: domains/ui/update/inventory
91
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
92
- design_mode: true
93
-
94
- cms-create-feature:
95
- domain: cms
96
- path: domains/cms/update/orchestrator
97
- inventory: domains/cms/update/inventory
98
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting, module-authoring]
99
- create_mode: true
100
-
101
- cms-fix-bug:
102
- domain: cms
103
- path: domains/cms/update/orchestrator
104
- inventory: domains/cms/update/inventory
105
- requires: [discovery, investigation, root-cause, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
106
- fix_mode: true
107
- phases: [load_inventory, discover, investigate_swarm, root_cause, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
108
-
109
- ui-fix-bug:
110
- domain: ui
111
- path: domains/ui/update/orchestrator
112
- inventory: domains/ui/update/inventory
113
- requires: [discovery, investigation, root-cause, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
114
- fix_mode: true
115
- phases: [load_inventory, discover, investigate_swarm, root_cause, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
116
-
117
- database-fix-bug:
118
- domain: database
119
- path: domains/database/update/orchestrator
120
- inventory: domains/database/update/inventory
121
- requires: [discovery, investigation, root-cause, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting]
122
- fix_mode: true
123
- phases: [load_inventory, discover, investigate_swarm, root_cause, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
124
-
125
5
  update-doc:
126
6
  path: skills/shared/documentation/orchestrator
127
7
  requires: [discovery, documentation, reporting]
@@ -130,7 +10,7 @@ orchestrators:
130
10
  review-incident:
131
11
  path: skills/shared/investigation/orchestrator
132
12
  requires: [discovery, investigation, reporting]
133
- optional: [execution, ludecker-infrastructure]
13
+ optional: [execution]
134
14
 
135
15
  review-module:
136
16
  path: skills/shared/architecture/orchestrator
@@ -146,73 +26,9 @@ orchestrators:
146
26
  path: skills/shared/testing/orchestrator
147
27
  requires: [discovery, testing, verification, reporting]
148
28
 
149
- cms-test-module:
150
- domain: cms
151
- path: domains/cms/update/orchestrator
152
- inventory: domains/cms/update/inventory
153
- requires: [testing, verification, reporting]
154
- test_only: true
155
-
156
- ui-test-module:
157
- domain: ui
158
- path: domains/ui/update/orchestrator
159
- inventory: domains/ui/update/inventory
160
- requires: [testing, verification, reporting]
161
- test_only: true
162
-
163
- database-test-module:
164
- domain: database
165
- path: domains/database/update/orchestrator
166
- inventory: domains/database/update/inventory
167
- requires: [testing, verification, reporting]
168
- test_only: true
169
-
170
- aaac-update:
171
- domain: aaac
172
- path: domains/aaac/update/orchestrator
173
- inventory: domains/aaac/update/inventory
174
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting, integration]
175
- phases: [load_inventory, discover, investigate_lite, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
176
-
177
- aaac-create-feature:
178
- domain: aaac
179
- path: domains/aaac/update/orchestrator
180
- inventory: domains/aaac/update/inventory
181
- requires: [discovery, investigation-lite, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting, module-authoring, integration]
182
- create_mode: true
183
-
184
- aaac-fix-bug:
185
- domain: aaac
186
- path: domains/aaac/update/orchestrator
187
- inventory: domains/aaac/update/inventory
188
- requires: [discovery, investigation, root-cause, planning, validation, impact-analysis, dependency-graph, fitness-functions, rollback, execution, testing, verification, reporting, integration]
189
- fix_mode: true
190
- phases: [load_inventory, discover, investigate_swarm, root_cause, plan, validate, impact_analysis, dependency_graph, fitness_functions, rollback, execute, verify, sync_inventory, report]
191
-
192
- aaac-test-module:
193
- domain: aaac
194
- path: domains/aaac/update/orchestrator
195
- inventory: domains/aaac/update/inventory
196
- requires: [testing, verification, reporting, integration]
197
- test_only: true
198
-
199
- aaac-publish:
200
- domain: aaac
201
- path: domains/aaac/update/orchestrator
202
- inventory: domains/aaac/update/inventory
203
- requires: [testing, verification, execution, reporting, integration]
204
- publish_mode: true
205
-
206
- write-article:
207
- domain: content
208
- path: domains/content/write/orchestrator
209
- requires: [run, reporting]
210
- workflow: write-article
211
- phases: [parse, research_swarm, write, review, persist, report]
212
-
213
29
  release-app:
214
30
  path: skills/shared/platform-release/orchestrator
215
- requires: [testing, verification, execution, reporting, ludecker-infrastructure]
31
+ requires: [testing, verification, execution, reporting]
216
32
 
217
33
  verb-create:
218
34
  path: skills/shared/verbs/create/orchestrator
@@ -322,18 +138,6 @@ skills:
322
138
  path: skills/shared/platform-release
323
139
  governance/implementation:
324
140
  path: skills/shared/governance/implementation
325
- ludecker-design-system:
326
- path: skills/ludecker/design-system
327
- ludecker-database-schema:
328
- path: skills/ludecker/database-schema
329
- ludecker-api-first:
330
- path: skills/ludecker/api-first
331
- ludecker-security:
332
- path: skills/ludecker/security
333
- ludecker-user-experience:
334
- path: skills/ludecker/user-experience
335
- ludecker-infrastructure:
336
- path: skills/ludecker/infrastructure
337
141
 
338
142
  agents:
339
143
  discovery-inventory:
@@ -382,10 +186,6 @@ agents:
382
186
  path: agents/release-git.md
383
187
  wave: 1
384
188
  blocking: true
385
- release-render:
386
- path: agents/release-render.md
387
- wave: 2
388
- requires: [release-git]
389
189
 
390
190
  policies:
391
191
  - policies/master-rules.md
@@ -36,6 +36,8 @@ Execution Layer
36
36
  ├─ Verb orchestrators .cursor/skills/shared/verbs/*/orchestrator/
37
37
  ├─ Shared pipeline skills .cursor/skills/shared/
38
38
  ├─ Capability registry .cursor/aaac/capabilities/registry.json
39
+ ├─ Capability promotion rules .cursor/aaac/capabilities/promotion-rules.json
40
+ ├─ Capability stats (derived) .cursor/aaac/state/capability-stats.json
39
41
  ├─ Agent specs .cursor/agents/
40
42
 
41
43
  Knowledge Layer
@@ -87,6 +89,7 @@ Policies → Ontology → Graph → Create Run
87
89
  → Lifecycle (work) + Gates (composed into Run.pending)
88
90
  → Orchestrator → Capabilities resolved (recorded on Run)
89
91
  → Execute phases → Update Run → Report
92
+ → Run completes → capability-evidence.mjs → update capability-stats.json + evaluate promotion
90
93
  ```
91
94
 
92
95
  ## Deprecated
@@ -21,6 +21,9 @@ log_on:
21
21
  - human_approval_required
22
22
  - human_approval_received
23
23
  - capability_resolved
24
+ - evidence_aggregated
25
+ - capability_promoted
26
+ - evidence_aggregation_failed
24
27
  - skill_loaded
25
28
  - doc_loaded
26
29
  - agent_spawned
@@ -3,8 +3,7 @@
3
3
  SSOT: [ontology.json](ontology.json). Regenerate graph and commands:
4
4
 
5
5
  ```bash
6
- node .cursor/aaac/generate-graph.mjs
7
- node .cursor/aaac/generate-commands.mjs
6
+ npx @ludecker/aaac@latest generate
8
7
  ```
9
8
 
10
9
  ## Hierarchy (how developers already think)
@@ -22,18 +21,10 @@ Four layers in the graph:
22
21
  | **product** | feature, workflow, integration | `/create-feature`, `/check-workflow` |
23
22
  | **system** | app, domain, architecture | `/release-app`, `/update-domain`, `/review-architecture` |
24
23
 
25
- ## Verbs (unchanged)
24
+ ## Verbs
26
25
 
27
26
  create · update · fix · review · check · test · release · remove
28
27
 
29
- ## Ludecker domains
30
-
31
- | Slug | Bounded context |
32
- |------|-----------------|
33
- | `cms` | `apps/website` — public site + CMS admin |
34
- | `ui` | `packages/ui` — design system |
35
- | `database` | `supabase/migrations` — schema, RLS, type mirrors |
36
-
37
28
  ## Granular aliases
38
29
 
39
30
  Finer nouns (api, endpoint, hook, spec, skill, graph, …) map to a canonical command — see `command_aliases` in [ontology.json](ontology.json). Examples:
@@ -43,48 +34,42 @@ Finer nouns (api, endpoint, hook, spec, skill, graph, …) map to a canonical co
43
34
  | `/update-api` | `update-integration` |
44
35
  | `/fix-hook` | `fix-function` |
45
36
  | `/update-doc` | `update-architecture` |
46
- | `/update-design` | `update-component` (cms/ui resolver) |
47
37
  | `/check-inventory` | `check-module` |
48
38
  | `/create-skill` | `create-module` |
49
- | `/ship-ludecker` | `release-app` |
50
39
 
51
40
  ## Exceptions
52
41
 
53
42
  | Command | Note |
54
43
  |---------|------|
55
- | `fix-bug` | Defect repair; domain resolver (`cms`, `ui`, `database`); unknown slug → `verb-fix` |
44
+ | `fix-bug` | Defect repair; routes to `verb-fix` + object `feature` by default |
45
+ | `fix-module` | Same fix swarm; routes to `verb-fix` + object `module` by default |
56
46
  | `review-incident` | Production/deploy incident (`swarm-check` alias) |
57
47
  | `test-function` | Journey verification (dedicated orchestrator) |
58
- | `release-app` | Full platform ship (`ship-ludecker` alias) |
59
- | `write-article` | Content research swarm → CMS persist |
48
+ | `release-app` | Platform release swarm |
49
+
50
+ Add domain resolvers in `graph.project.yaml` to route `/update-module <slug>` to domain orchestrators.
60
51
 
61
52
  ## Invalid `release-*`
62
53
 
63
- Use `release-app`, `release-feature`, or `release-integration` — not `release-function`, `release-module`, `release-schema`, etc. (see `invalid_pairs` in graph).
54
+ Use `release-app`, `release-feature`, or `release-integration` — not `release-function`, `release-module`, etc. (see `invalid_pairs` in graph).
64
55
 
65
56
  ## Verb lifecycle and gates
66
57
 
67
- **Work:** [lifecycle/lifecycle.json](lifecycle/lifecycle.json) → graph `verb_work_phases`
68
- **Gates:** [governance/gates.json](governance/gates.json) → graph `governance_gate_stacks`
69
- **Runtime (composed):** graph `verb_runtime` on Run at dispatch
70
- **Run:** [run/schema.json](run/schema.json) — primary execution object
71
-
72
- Phase → skill: [lifecycle/phases.json](lifecycle/phases.json)
58
+ **Work:** [lifecycle/lifecycle.json](lifecycle/lifecycle.json)
59
+ **Gates:** [governance/gates.json](governance/gates.json)
60
+ **Run:** [run/schema.json](run/schema.json)
73
61
 
74
62
  ## Object capabilities
75
63
 
76
- Ontology declares `object_capabilities` per object. Graph resolves to provider skills via [capabilities/registry.json](capabilities/registry.json). Generated `object_skills` in graph.yaml is derived do not edit by hand.
64
+ Ontology declares `object_capabilities` per object. Graph resolves providers via [capabilities/registry.json](capabilities/registry.json). Generic install uses shared skills; replace with project skills in your overlay.
77
65
 
78
- Example: `component` → `[component-model, layer-boundaries, ui-design]` → `[component, architecture, ludecker-design-system]`
66
+ Example: `component` → `[component-model, layer-boundaries, ui-design]` → `[component, architecture, component]`
79
67
 
80
68
  ## Domain argument
81
69
 
82
- - **Required:** `update-module`, `update-domain`, …
83
- - **Optional:** `*-function`, `review-incident`, `write-article`
70
+ - **Recommended:** `update-module`, `fix-module`, … once you add domains
71
+ - **Optional:** `*-function`, `review-incident`
84
72
 
85
- ## Manual commands (not in graph)
73
+ ## Manual commands
86
74
 
87
- | Command | Purpose |
88
- |---------|---------|
89
- | `/launch-ludecker` | Local dev: kill stale processes, clean `.next`, start `pnpm dev` |
90
- | `/kill-ludecker` | Kill local dev port listeners |
75
+ Add filenames to [project.config.json](project.config.json) `manual_commands` — not generated from ontology.
@@ -1,3 +1,6 @@
1
1
  {
2
- "manual_commands": []
2
+ "manual_commands": [],
3
+ "verify": {
4
+ "enabled": false
5
+ }
3
6
  }
@@ -10,7 +10,7 @@
10
10
  "domain": "string | null",
11
11
  "intent": "string",
12
12
  "orchestrator": "string",
13
- "status": "pending | running | blocked | completed | failed",
13
+ "status": "pending | running | blocked | completed | failed | cancelled",
14
14
  "phase": "string | null",
15
15
  "phase_kind": "work | gate | null",
16
16
  "awaiting_approval": false,
@@ -22,6 +22,10 @@
22
22
  "checkpoints": [],
23
23
  "log": [],
24
24
  "capabilities_resolved": {},
25
+ "capability_runtime": {},
26
+ "capability_runtime_approved": false,
27
+ "capability_evidence_processed": false,
28
+ "capability_evidence_outcomes": [],
25
29
  "confidence": {
26
30
  "architecture": null,
27
31
  "requirements": null,
@@ -5,6 +5,8 @@
5
5
  */
6
6
  import fs from "fs";
7
7
  import path from "path";
8
+ import { spawnSync } from "child_process";
9
+ import { fileURLToPath } from "url";
8
10
  import {
9
11
  loadRegistry,
10
12
  loadEnforcement,
@@ -18,6 +20,14 @@ import {
18
20
  saveActiveRun,
19
21
  } from "./lib.mjs";
20
22
  import { recordLog } from "./log.mjs";
23
+ import {
24
+ processRunEvidence,
25
+ evaluateCapabilityRuntimePolicy,
26
+ resolveCapabilitiesWithRuntime,
27
+ loadObjectMaturity,
28
+ } from "./capability-evidence.mjs";
29
+
30
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
31
 
22
32
  const runId = process.argv[2];
23
33
  const completedPhase = process.argv[3];
@@ -67,6 +77,46 @@ if (minAgents && launches < minAgents && !force) {
67
77
  process.exit(2);
68
78
  }
69
79
 
80
+ const verifyVerbs = enforcement.verify_verbs ?? ["create", "update", "fix"];
81
+ if (
82
+ completedPhase === "verify" &&
83
+ verifyVerbs.includes(manifest.verb) &&
84
+ !force
85
+ ) {
86
+ const verifyScript = path.join(__dirname, "verify-website-build.mjs");
87
+ const verifyRun = spawnSync("node", [verifyScript, "--run-id", runId], {
88
+ encoding: "utf8",
89
+ });
90
+ if (verifyRun.status !== 0) {
91
+ const detail =
92
+ verifyRun.stderr?.trim() ||
93
+ verifyRun.stdout?.trim() ||
94
+ "verify-website-build failed";
95
+ recordLog(manifest, {
96
+ event: "gate_fail",
97
+ phase: completedPhase,
98
+ phase_kind: manifest.phase_kind,
99
+ detail: `website verify failed: ${detail.slice(0, 500)}`,
100
+ level: "warn",
101
+ });
102
+ manifest.updated_at = isoNow();
103
+ writeJson(manifestPath, manifest);
104
+ console.error(
105
+ "App verify failed (see project.config.json verify). Fix errors, then re-run:\n" +
106
+ ` node .cursor/aaac/scripts/run-engine/verify-website-build.mjs --run-id ${runId}\n` +
107
+ detail,
108
+ );
109
+ process.exit(2);
110
+ }
111
+ recordLog(manifest, {
112
+ event: "verify_website_pass",
113
+ phase: completedPhase,
114
+ phase_kind: manifest.phase_kind,
115
+ detail: "app verify gate",
116
+ level: "info",
117
+ });
118
+ }
119
+
70
120
  const requiredArtifacts = enforcement.phase_artifacts?.[completedPhase] ?? [];
71
121
  for (const rel of requiredArtifacts) {
72
122
  const artifactPath = path.join(runDir(runId), rel);
@@ -119,7 +169,68 @@ recordLog(manifest, {
119
169
  level: "info",
120
170
  });
121
171
 
122
- const nextPhase = manifest.pending.shift() ?? null;
172
+ let nextPhase = manifest.pending.shift() ?? null;
173
+
174
+ if (nextPhase === "execute" && !force) {
175
+ const resolved =
176
+ manifest.capabilities_resolved &&
177
+ Object.keys(manifest.capabilities_resolved).length > 0
178
+ ? manifest.capabilities_resolved
179
+ : resolveCapabilitiesWithRuntime(manifest.object, manifest.verb);
180
+ const policy = evaluateCapabilityRuntimePolicy(resolved, {
181
+ object_maturity: loadObjectMaturity(manifest.object),
182
+ });
183
+ manifest.capability_runtime = policy;
184
+
185
+ const needsBlock =
186
+ policy.action === "block" ||
187
+ (policy.action === "require_approval" && !manifest.capability_runtime_approved);
188
+
189
+ if (needsBlock) {
190
+ manifest.pending.unshift(nextPhase);
191
+ nextPhase = null;
192
+ manifest.status = "blocked";
193
+ manifest.awaiting_approval = policy.action === "require_approval";
194
+ manifest.blocked_reason = policy.reasons.join("; ") || "capability runtime policy";
195
+ recordLog(manifest, {
196
+ event: "gate_fail",
197
+ phase: completedPhase,
198
+ phase_kind: manifest.phase_kind,
199
+ detail: `capability runtime ${policy.action}: ${manifest.blocked_reason}`,
200
+ level: "warn",
201
+ });
202
+ manifest.updated_at = isoNow();
203
+ writeJson(manifestPath, manifest);
204
+ saveActiveRun(manifest.conversation_id ?? null, {
205
+ run_id: runId,
206
+ conversation_id: manifest.conversation_id ?? null,
207
+ command: manifest.command,
208
+ phase: manifest.phase,
209
+ status: manifest.status,
210
+ task_launches_this_phase: 0,
211
+ edit_allowed: false,
212
+ started_at: manifest.created_at,
213
+ });
214
+ console.error(
215
+ `Capability runtime ${policy.action}: ${manifest.blocked_reason}. ` +
216
+ (policy.action === "require_approval"
217
+ ? "User must approve in chat; set capability_runtime_approved on Run and retry."
218
+ : "Cannot proceed to execute."),
219
+ );
220
+ process.exit(2);
221
+ }
222
+
223
+ if (policy.action === "warn") {
224
+ recordLog(manifest, {
225
+ event: "capability_runtime_warn",
226
+ phase: completedPhase,
227
+ phase_kind: manifest.phase_kind,
228
+ detail: policy.reasons.join("; "),
229
+ level: "warn",
230
+ });
231
+ }
232
+ }
233
+
123
234
  if (!nextPhase) {
124
235
  manifest.status = "completed";
125
236
  manifest.phase = "report";
@@ -131,6 +242,46 @@ if (!nextPhase) {
131
242
  detail: "all phases completed",
132
243
  level: "info",
133
244
  });
245
+
246
+ try {
247
+ const evidenceResult = processRunEvidence(runId, { manifest, skipManifestWrite: true });
248
+ if (evidenceResult.ok && !evidenceResult.skipped) {
249
+ manifest.capability_evidence_processed = true;
250
+ manifest.capability_evidence_outcomes = evidenceResult.outcomes;
251
+ if (
252
+ !manifest.capabilities_resolved ||
253
+ !Object.keys(manifest.capabilities_resolved).length
254
+ ) {
255
+ manifest.capabilities_resolved = evidenceResult.resolved;
256
+ }
257
+ recordLog(manifest, {
258
+ event: "evidence_aggregated",
259
+ phase: "report",
260
+ phase_kind: "work",
261
+ detail: `capabilities=${(evidenceResult.capabilities ?? []).join(",")}`,
262
+ level: "info",
263
+ });
264
+ for (const outcome of evidenceResult.outcomes ?? []) {
265
+ if (outcome.previous_state !== outcome.new_state) {
266
+ recordLog(manifest, {
267
+ event: "capability_promoted",
268
+ phase: "report",
269
+ phase_kind: "work",
270
+ detail: `${outcome.capability_id}:${outcome.previous_state}→${outcome.new_state}`,
271
+ level: "info",
272
+ });
273
+ }
274
+ }
275
+ }
276
+ } catch (err) {
277
+ recordLog(manifest, {
278
+ event: "evidence_aggregation_failed",
279
+ phase: "report",
280
+ phase_kind: "work",
281
+ detail: String(err.message ?? err).slice(0, 300),
282
+ level: "warn",
283
+ });
284
+ }
134
285
  } else {
135
286
  manifest.phase = nextPhase;
136
287
  manifest.phase_kind = phaseKind(nextPhase, registry);