@jstn-sdk/ma 0.1.11 → 0.1.13

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 (159) hide show
  1. package/.codex/agents/Architect.toml +0 -2
  2. package/.codex/agents/Auditor.toml +0 -2
  3. package/.codex/agents/Builder.toml +0 -2
  4. package/.codex/agents/Flow.toml +0 -2
  5. package/.codex/agents/Sage.toml +0 -2
  6. package/.codex/agents/Vibe.toml +0 -2
  7. package/.codex/hooks.json +14 -13
  8. package/.codex/prompts/enforcement.md +4 -0
  9. package/.codex/prompts/skill-contract.md +4 -0
  10. package/COVERAGE.md +211 -0
  11. package/DEMO.md +265 -0
  12. package/README.md +287 -37
  13. package/bin/ma.js +232 -71
  14. package/data/clone-data.ledger.json +41 -0
  15. package/data/clone-data.proof.json +50 -0
  16. package/data/clone-data.rvf +37 -0
  17. package/docs/README.md +7 -1
  18. package/docs/getting-started.md +108 -37
  19. package/docs/installed-sdk.md +23 -0
  20. package/docs/mcp-setup.md +65 -1
  21. package/docs/onboarding.md +18 -2
  22. package/docs/prompt-guidance-contract.md +17 -0
  23. package/docs/prompt-guidance-fragments/active-autonomy-core.md +7 -0
  24. package/docs/qa/release-issue-gates-0.1.13.json +644 -0
  25. package/docs/qa/release-readiness-0.1.13.md +116 -0
  26. package/docs/qa/release-readiness-0.1.5.md +1 -1
  27. package/docs/reference/native-engineering-patterns.md +35 -0
  28. package/docs/reference/native-security-playbooks.md +27 -0
  29. package/docs/reference/native-source-selection.md +27 -0
  30. package/docs/reference/native-style-and-deslop.md +20 -0
  31. package/docs/release-spec.md +37 -10
  32. package/docs/skills-publishing.md +25 -1
  33. package/docs/skills.md +37 -12
  34. package/index.js +222 -2
  35. package/mcp/collections.json +23 -6
  36. package/mcp/local/code-intel.js +113 -0
  37. package/mcp/local/memory.js +46 -0
  38. package/mcp/local/playbooks.js +168 -0
  39. package/mcp/local/state.js +71 -0
  40. package/mcp/local/team-run.js +113 -0
  41. package/mcp/local/trace.js +60 -0
  42. package/mcp/local-capabilities.json +56 -0
  43. package/mcp/native-playbooks.json +117 -0
  44. package/mcp/servers.json +34 -0
  45. package/package.json +8 -2
  46. package/plugins/meta-architect/.app.json +1 -1
  47. package/plugins/meta-architect/.codex-plugin/plugin.json +4 -4
  48. package/plugins/meta-architect/.mcp.json +1 -1
  49. package/plugins/meta-architect/README.md +34 -1
  50. package/plugins/meta-architect/obsidian/main.js +401 -0
  51. package/plugins/meta-architect/obsidian/manifest.json +9 -0
  52. package/plugins/meta-architect/obsidian/styles.css +7 -0
  53. package/plugins/meta-architect/skills/align/SKILL.md +24 -0
  54. package/plugins/meta-architect/skills/align/agents/openai.yaml +4 -0
  55. package/plugins/meta-architect/skills/align/references/shared-language.md +24 -0
  56. package/plugins/meta-architect/skills/arch/SKILL.md +2 -0
  57. package/plugins/meta-architect/skills/build/SKILL.md +3 -0
  58. package/plugins/meta-architect/skills/cleanup/SKILL.md +23 -0
  59. package/plugins/meta-architect/skills/cleanup/agents/openai.yaml +4 -0
  60. package/plugins/meta-architect/skills/cleanup/references/style-and-deslop.md +18 -0
  61. package/plugins/meta-architect/skills/diagnose/SKILL.md +24 -0
  62. package/plugins/meta-architect/skills/diagnose/agents/openai.yaml +4 -0
  63. package/plugins/meta-architect/skills/flow/SKILL.md +2 -0
  64. package/plugins/meta-architect/skills/maestro/SKILL.md +36 -3
  65. package/plugins/meta-architect/skills/maestro/agents/openai.yaml +2 -2
  66. package/plugins/meta-architect/skills/maestro/references/native-ingest-map.md +44 -0
  67. package/plugins/meta-architect/skills/sage/SKILL.md +5 -1
  68. package/plugins/meta-architect/skills/sage/references/source-selection.md +36 -0
  69. package/plugins/meta-architect/skills/tdd/SKILL.md +24 -0
  70. package/plugins/meta-architect/skills/tdd/agents/openai.yaml +4 -0
  71. package/plugins/meta-architect/skills/vet/SKILL.md +5 -1
  72. package/plugins/meta-architect/skills/vet/references/security-playbooks.md +30 -0
  73. package/plugins/meta-architect/skills/vibe/SKILL.md +2 -0
  74. package/scripts/active-autonomy-hook.mjs +96 -0
  75. package/scripts/build-linux-packages.mjs +328 -0
  76. package/scripts/doctor.js +36 -4
  77. package/scripts/install.sh +28 -0
  78. package/scripts/linux-package-lib.mjs +40 -0
  79. package/scripts/linux-package-smoke.mjs +103 -0
  80. package/scripts/ralph/prompt.md +35 -0
  81. package/scripts/release-sync.js +13 -6
  82. package/scripts/release-verify.js +166 -1
  83. package/skills/align/SKILL.md +24 -0
  84. package/skills/align/agents/openai.yaml +4 -0
  85. package/skills/align/references/shared-language.md +24 -0
  86. package/skills/arch/SKILL.md +2 -0
  87. package/skills/build/SKILL.md +3 -0
  88. package/skills/cleanup/SKILL.md +23 -0
  89. package/skills/cleanup/agents/openai.yaml +4 -0
  90. package/skills/cleanup/references/style-and-deslop.md +18 -0
  91. package/skills/diagnose/SKILL.md +24 -0
  92. package/skills/diagnose/agents/openai.yaml +4 -0
  93. package/skills/flow/SKILL.md +2 -0
  94. package/skills/index.json +21 -6
  95. package/skills/maestro/SKILL.md +36 -3
  96. package/skills/maestro/agents/openai.yaml +2 -2
  97. package/skills/maestro/references/native-ingest-map.md +44 -0
  98. package/skills/sage/SKILL.md +5 -1
  99. package/skills/sage/references/source-selection.md +36 -0
  100. package/skills/tdd/SKILL.md +24 -0
  101. package/skills/tdd/agents/openai.yaml +4 -0
  102. package/skills/vet/SKILL.md +5 -1
  103. package/skills/vet/references/security-playbooks.md +30 -0
  104. package/skills/vibe/SKILL.md +2 -0
  105. package/src/bootstrap.js +141 -24
  106. package/src/build-gate.js +2 -2
  107. package/src/decision-log.js +12 -9
  108. package/src/launcher.js +4 -0
  109. package/src/mcp-config.js +130 -8
  110. package/src/mcp-live-client.js +289 -3
  111. package/src/paths.js +37 -1
  112. package/src/policy.js +1 -1
  113. package/src/release-issue-gates.js +190 -0
  114. package/src/release-state.js +30 -1
  115. package/src/runtime/active-autonomy-core.js +208 -0
  116. package/src/runtime/alignment-sentinel.js +165 -0
  117. package/src/runtime/architect-review.js +88 -0
  118. package/src/runtime/build-readiness.js +62 -0
  119. package/src/runtime/code-graph-rehearse.js +113 -0
  120. package/src/runtime/context-economy-core.js +276 -0
  121. package/src/runtime/continuity-notes.js +79 -0
  122. package/src/runtime/core-source-ingest.js +379 -0
  123. package/src/runtime/detached-provider.js +74 -0
  124. package/src/runtime/environment-awareness-core.js +460 -0
  125. package/src/runtime/exposure-catalog.js +276 -0
  126. package/src/runtime/guidance-stack.js +42 -0
  127. package/src/runtime/helper-orchestration-core.js +307 -0
  128. package/src/runtime/learning-loop-core.js +238 -0
  129. package/src/runtime/maestro-events.js +18 -0
  130. package/src/runtime/maestro-manager.js +605 -0
  131. package/src/runtime/maestro-state.js +125 -0
  132. package/src/runtime/mcp-policy.js +192 -0
  133. package/src/runtime/obsidian-integration-core.js +851 -0
  134. package/src/runtime/obsidian-plugin-bridge.js +739 -0
  135. package/src/runtime/orchestrator.js +158 -0
  136. package/src/runtime/prompt-strategy-core.js +230 -0
  137. package/src/runtime/quorum-review.js +90 -0
  138. package/src/runtime/ralph-execution-core.js +217 -0
  139. package/src/runtime/redaction-gateway.js +174 -0
  140. package/src/runtime/runtime-state.js +1223 -0
  141. package/src/runtime/semantic-recording-core.js +147 -0
  142. package/src/runtime/signal-hooks.js +67 -0
  143. package/src/runtime/skills-registry-export.js +670 -0
  144. package/src/runtime/startup-path.js +14 -0
  145. package/src/runtime/universal-plugin-broker-core.js +575 -0
  146. package/src/runtime/workspace-intelligence-runtime.js +674 -0
  147. package/src/runtime/workspace-virtualizer.js +102 -0
  148. package/src/runtime/workspaces.js +25 -0
  149. package/src/runtime-artifacts.js +407 -84
  150. package/src/skill-installer.js +53 -5
  151. package/src/skills.js +1454 -78
  152. package/src/state-sync.js +51 -8
  153. package/docs/qa/release-readiness-0.1.11.md +0 -79
  154. package/plugins/meta-architect/skills/meta-architect/SKILL.md +0 -32
  155. package/plugins/meta-architect/skills/meta-architect/agents/openai.yaml +0 -4
  156. package/skills/meta-architect/SKILL.md +0 -32
  157. package/skills/meta-architect/agents/openai.yaml +0 -4
  158. /package/plugins/meta-architect/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
  159. /package/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { ensureDir, writeFileIfMissing } from "./fs-utils.js";
4
4
  import { getRuntimeWritePath } from "./paths.js";
5
+ import { ensureRuntimeSubsystems } from "./runtime/runtime-state.js";
5
6
 
6
7
  const runtimeDirs = ["context", "specs", "plans"];
7
8
 
@@ -23,17 +24,210 @@ function renderProjectContext({ idea = null }) {
23
24
  "",
24
25
  "## Next Recommended Trigger",
25
26
  "",
26
- idea ? "`$arch`" : "`ma idea`",
27
+ idea ? "`$maestro`" : "`ma idea`",
27
28
  "",
28
29
  ].join("\n");
29
30
  }
30
31
 
31
- function renderArchitectureSpec({ idea, blueprint }) {
32
+ function renderRuntimeSummary(summary) {
33
+ if (!summary) {
34
+ return [];
35
+ }
36
+
37
+ return [
38
+ "## Runtime Context",
39
+ "",
40
+ `- guidance sources: ${summary.guidanceSourceCount}`,
41
+ `- guidance include roots: ${summary.guidanceIncludeRoots}`,
42
+ `- continuity sessions: ${summary.continuitySessionCount}`,
43
+ `- continuity notes present: ${summary.continuityHasNotes}`,
44
+ `- compatibility hooks: ${summary.compatibilityHookCount}`,
45
+ `- runtime hook events: ${summary.runtimeHookCount}`,
46
+ `- configured runtime hooks: ${summary.configuredRuntimeHookCount}`,
47
+ `- workers: ${summary.workerCount}`,
48
+ `- tasks: ${summary.taskCount}`,
49
+ `- pending mailbox proposals: ${summary.pendingMailboxCount}`,
50
+ `- workspaces: ${summary.workspaceCount}`,
51
+ `- recorded decisions: ${summary.decisionCount}`,
52
+ `- manager runs: ${summary.managerRunCount}`,
53
+ `- active manager runs: ${summary.activeManagerRunCount}`,
54
+ `- waiting-review manager runs: ${summary.waitingReviewManagerRunCount}`,
55
+ `- maestro global status: ${summary.maestroGlobalStatus}`,
56
+ `- maestro runtime tracks: ${summary.maestroTrackCount}`,
57
+ `- active autonomy ask-only reasons: ${summary.activeAutonomyAskOnlyCount}`,
58
+ `- active autonomy stall patterns: ${summary.activeAutonomyStallPatternCount}`,
59
+ `- active autonomy hook enabled: ${summary.activeAutonomyHookEnabled}`,
60
+ `- semantic recording layers: ${summary.semanticRecordingLayerCount}`,
61
+ `- default core capabilities: ${summary.semanticDefaultCoreCount}`,
62
+ `- learning loop domains: ${summary.learningLoopDomainCount}`,
63
+ `- learning loop records: ${summary.learningLoopRecordCount}`,
64
+ `- prompt strategy technique families: ${summary.promptStrategyTechniqueFamilyCount}`,
65
+ `- prompt strategy lane policies: ${summary.promptStrategyLaneCount}`,
66
+ `- context economy applies-to surfaces: ${summary.contextEconomyAppliesToCount}`,
67
+ `- context economy exact-preserve rules: ${summary.contextEconomyPreserveExactCount}`,
68
+ `- context economy safety valves: ${summary.contextEconomySafetyValveCount}`,
69
+ `- Obsidian bridge records as: ${summary.obsidianBridgeRecordsAs}`,
70
+ `- Obsidian bridge never records as: ${summary.obsidianBridgeNeverRecordsAs}`,
71
+ `- Obsidian queued plugin requests: ${summary.obsidianBridgeQueuedRequestCount}`,
72
+ `- Obsidian note selections: ${summary.obsidianBridgeNoteSelectionCount}`,
73
+ `- Obsidian tag graph claims: ${summary.obsidianBridgeTagGraphClaimCount}`,
74
+ `- workspace virtualizer records as: ${summary.workspaceVirtualizerRecordsAs}`,
75
+ `- code graph rehearse max steps: ${summary.codeGraphRehearseMaxSteps}`,
76
+ `- skills registry universal targets: ${summary.skillsRegistryUniversalTargetCount}`,
77
+ `- skills registry non-universal targets: ${summary.skillsRegistryNonUniversalTargetCount}`,
78
+ `- capability composition entries: ${summary.capabilityCompositionCount}`,
79
+ `- workspace context channels: ${summary.workspaceContextChannelCount}`,
80
+ `- workspace effectiveness ready: ${summary.workspaceEffectivenessReady}`,
81
+ `- workspace effectiveness checks: ${summary.workspaceEffectivenessCheckCount}`,
82
+ `- semantic receipts: ${summary.semanticReceiptCount}`,
83
+ `- Obsidian semantic role: ${summary.obsidianSemanticRole}`,
84
+ `- Obsidian records as: ${summary.obsidianRecordsAs}`,
85
+ `- build status: ${summary.buildStatus}`,
86
+ `- missing runtime artifacts: ${summary.missingArtifacts.length}`,
87
+ `- invalid runtime artifacts: ${summary.invalidArtifacts.length}`,
88
+ "",
89
+ ];
90
+ }
91
+
92
+ function renderListSection(title, items, fallback = "None.") {
93
+ return [
94
+ `## ${title}`,
95
+ "",
96
+ ...(items.length === 0 ? [fallback] : items.map((item) => `- ${item}`)),
97
+ "",
98
+ ];
99
+ }
100
+
101
+ function renderKeyValueSection(title, entries, fallback = "None.") {
102
+ const lines = [`## ${title}`, ""];
103
+ if (entries.length === 0) {
104
+ lines.push(fallback, "");
105
+ return lines;
106
+ }
107
+
108
+ for (const [label, value] of entries) {
109
+ lines.push(`- ${label}: ${value}`);
110
+ }
111
+ lines.push("");
112
+ return lines;
113
+ }
114
+
115
+ function renderSharedDecisionSections({
116
+ decision,
117
+ status,
118
+ evidence = [],
119
+ blockers = [],
120
+ nextAllowedTriggers = [],
121
+ }) {
122
+ return [
123
+ "## Decision",
124
+ "",
125
+ decision,
126
+ "",
127
+ "## Status",
128
+ "",
129
+ status,
130
+ "",
131
+ ...renderListSection("Evidence", evidence),
132
+ ...renderListSection("Blockers", blockers),
133
+ ...renderListSection("Next Allowed Triggers", nextAllowedTriggers, "`$maestro`"),
134
+ ];
135
+ }
136
+
137
+ function formatManagerHelper(helper) {
138
+ return `${helper.skill}: ${helper.objective} [${helper.status}]`;
139
+ }
140
+
141
+ function formatManagerGate(gate) {
142
+ return `${gate.skill}: ${gate.objective} [${gate.status}]`;
143
+ }
144
+
145
+ function renderManagerSection(managerRun) {
146
+ if (!managerRun) {
147
+ return [];
148
+ }
149
+
150
+ const lines = [
151
+ "## Manager Run",
152
+ "",
153
+ `- id: ${managerRun.id}`,
154
+ `- state: ${managerRun.state}`,
155
+ `- mode: ${managerRun.mode}`,
156
+ `- next action: ${managerRun.nextAction}`,
157
+ ];
158
+
159
+ if (managerRun.dispatchPlan.helpers.length > 0) {
160
+ lines.push("- helper dispatch:");
161
+ lines.push(
162
+ ...managerRun.dispatchPlan.helpers.map((item) => ` - ${formatManagerHelper(item)}`),
163
+ );
164
+ }
165
+
166
+ if (managerRun.dispatchPlan.gated.length > 0) {
167
+ lines.push("- gated dispatch:");
168
+ lines.push(...managerRun.dispatchPlan.gated.map((item) => ` - ${formatManagerGate(item)}`));
169
+ }
170
+
171
+ if (managerRun.dispatchPlan.team) {
172
+ lines.push("- team dispatch:");
173
+ lines.push(` - title: ${managerRun.dispatchPlan.team.title}`);
174
+ lines.push(` - objective: ${managerRun.dispatchPlan.team.objective}`);
175
+ if (managerRun.dispatchPlan.team.createdTaskIds.length > 0) {
176
+ lines.push(` - created tasks: ${managerRun.dispatchPlan.team.createdTaskIds.join(", ")}`);
177
+ }
178
+ }
179
+
180
+ if (managerRun.pendingReview.proposalPath) {
181
+ lines.push(`- pending review: ${managerRun.pendingReview.proposalPath}`);
182
+ }
183
+
184
+ lines.push("");
185
+ return lines;
186
+ }
187
+
188
+ function renderBuildContextBoundaries(runtimeSummary) {
189
+ if (!runtimeSummary) {
190
+ return [];
191
+ }
192
+
193
+ return [
194
+ "## Context Boundaries",
195
+ "",
196
+ "- Virtual workspace output is context only; it must not be counted as production proof.",
197
+ `- virtual workspace records as: ${runtimeSummary.workspaceVirtualizerRecordsAs}`,
198
+ `- virtual workspace never records as: ${runtimeSummary.workspaceVirtualizerNeverRecordsAs}`,
199
+ `- virtual workspace source mutation allowed: ${runtimeSummary.workspaceVirtualizerSourceMutationAllowed}`,
200
+ "- Code-graph rehearsal is a bounded read-only preview; it must not unlock source mutation or release promotion.",
201
+ `- code graph rehearsal records as: ${runtimeSummary.codeGraphRehearseRecordsAs}`,
202
+ `- code graph rehearsal max steps: ${runtimeSummary.codeGraphRehearseMaxSteps}`,
203
+ `- code graph rehearsal source mutation allowed: ${runtimeSummary.codeGraphRehearseSourceMutationAllowed}`,
204
+ "- Exported skills are compatibility payloads; canonical authority stays with `$maestro` or the owning lane.",
205
+ `- skills registry canonical dir: ${runtimeSummary.skillsRegistryCanonicalDir}`,
206
+ `- exported skills may mutate release state: ${runtimeSummary.skillsRegistryReleaseMutationAllowed}`,
207
+ `- Obsidian context records as: ${runtimeSummary.obsidianRecordsAs}`,
208
+ `- Obsidian bridge records as: ${runtimeSummary.obsidianBridgeRecordsAs}`,
209
+ "- Obsidian/vault-derived claims are brain context, not build evidence.",
210
+ "",
211
+ ];
212
+ }
213
+
214
+ function renderArchitectureSpec({ idea, blueprint, runtimeSummary }) {
215
+ const evidence = blueprint.evidence ?? [
216
+ `Workload assumptions: ${(blueprint.workloadAssumptions ?? []).join(", ") || "baseline assumptions only"}`,
217
+ `Suggested stack count: ${blueprint.suggestedStack.length}`,
218
+ ];
32
219
  return [
33
220
  "# Architecture Spec",
34
221
  "",
35
222
  `Updated: ${new Date().toISOString()}`,
36
223
  "",
224
+ ...renderSharedDecisionSections({
225
+ decision: blueprint.decision ?? "Approve the first bounded architecture direction.",
226
+ status: blueprint.status ?? "APPROVED",
227
+ evidence,
228
+ blockers: blueprint.blockers ?? [],
229
+ nextAllowedTriggers: blueprint.nextAllowedTriggers ?? ["`$sage`"],
230
+ }),
37
231
  "## Problem Statement",
38
232
  "",
39
233
  idea,
@@ -46,31 +240,42 @@ function renderArchitectureSpec({ idea, blueprint }) {
46
240
  "",
47
241
  ...blueprint.suggestedStack.map((item) => `- ${item}`),
48
242
  "",
243
+ ...renderListSection("Rejected Alternatives", blueprint.rejectedAlternatives ?? []),
49
244
  "## Intended Outcome",
50
245
  "",
51
246
  blueprint.outcome,
52
247
  "",
53
- "## Next Recommended Trigger",
54
- "",
55
- "`$sage`",
56
- "",
248
+ ...renderRuntimeSummary(runtimeSummary),
57
249
  ].join("\n");
58
250
  }
59
251
 
60
- function renderEvidenceSpec({ idea, sourceEntries, verified, blockers }) {
252
+ function renderEvidenceSpec({ idea, sourceEntries, verified, blockers, runtimeSummary }) {
61
253
  const status = verified ? "VERIFIED" : sourceEntries.length > 0 ? "PARTIAL" : "MISSING";
254
+ const evidenceGrade = verified ? "VERIFIED" : sourceEntries.length > 0 ? "PARTIAL" : "MISSING";
62
255
  const lines = [
63
256
  "# Evidence Spec",
64
257
  "",
65
258
  `Updated: ${new Date().toISOString()}`,
66
259
  "",
260
+ ...renderSharedDecisionSections({
261
+ decision: verified
262
+ ? "Approve the current source-backed stack direction."
263
+ : "Evidence remains incomplete; keep the recommendation conditional.",
264
+ status,
265
+ evidence: sourceEntries.map((source) => `${source.repo} (${source.category})`),
266
+ blockers,
267
+ nextAllowedTriggers: verified ? ["`$flow`"] : ["`$sage`"],
268
+ }),
67
269
  "## Probe Basis",
68
270
  "",
69
271
  idea,
70
272
  "",
71
- "## Evidence Status",
273
+ ...renderKeyValueSection("Evidence Grade", [["grade", evidenceGrade]]),
274
+ "## Exact Upstream Mapping",
72
275
  "",
73
- status,
276
+ ...(sourceEntries.length === 0
277
+ ? ["No upstream mappings recorded."]
278
+ : sourceEntries.map((source) => `- ${source.repo} -> ${source.endpoint}`)),
74
279
  "",
75
280
  "## Sources",
76
281
  "",
@@ -93,14 +298,7 @@ function renderEvidenceSpec({ idea, sourceEntries, verified, blockers }) {
93
298
  lines.push("");
94
299
  }
95
300
 
96
- lines.push("## Blockers", "");
97
- if (blockers.length === 0) {
98
- lines.push("None.", "");
99
- } else {
100
- lines.push(...blockers.map((blocker) => `- ${blocker}`), "");
101
- }
102
-
103
- lines.push("## Next Recommended Trigger", "", verified ? "`$flow`" : "`$sage`", "");
301
+ lines.push(...renderRuntimeSummary(runtimeSummary));
104
302
  return lines.join("\n");
105
303
  }
106
304
 
@@ -110,68 +308,85 @@ function renderLogicSpec(logicMap) {
110
308
  "",
111
309
  `Updated: ${new Date().toISOString()}`,
112
310
  "",
113
- "## States",
114
- "",
115
- ...logicMap.states.map((state) => `- ${state}`),
116
- "",
117
- "## Blockers",
118
- "",
119
- ...(logicMap.blockers.length === 0 ? ["None."] : logicMap.blockers.map((item) => `- ${item}`)),
120
- "",
121
- "## Next Recommended Trigger",
122
- "",
123
- "`$vet`",
124
- "",
311
+ ...renderSharedDecisionSections({
312
+ decision:
313
+ logicMap.decision ?? "Validate the current behavioral model before later gates proceed.",
314
+ status: logicMap.status ?? (logicMap.blockers.length === 0 ? "GREEN" : "RED"),
315
+ evidence: logicMap.evidence ?? logicMap.actors.map((actor) => `actor: ${actor}`),
316
+ blockers: logicMap.blockers,
317
+ nextAllowedTriggers: logicMap.nextAllowedTriggers ?? [logicMap.nextTrigger ?? "`$vet`"],
318
+ }),
319
+ ...renderListSection("State Map", logicMap.stateMap ?? logicMap.states),
320
+ ...renderListSection("Failure Flows", logicMap.failureFlows ?? []),
321
+ ...(logicMap.runtimeSummary ? renderRuntimeSummary(logicMap.runtimeSummary) : []),
125
322
  ].join("\n");
126
323
  }
127
324
 
128
- function renderSecuritySpec({ finding, auditCount, cveCount }) {
325
+ function renderSecuritySpec({
326
+ finding,
327
+ auditCount,
328
+ cveCount,
329
+ runtimeSummary,
330
+ nextTrigger = "`$vibe`",
331
+ }) {
129
332
  return [
130
333
  "# Security Spec",
131
334
  "",
132
335
  `Updated: ${new Date().toISOString()}`,
133
336
  "",
134
- "## Latest Finding",
135
- "",
136
- `- severity: ${finding.severity}`,
137
- `- summary: ${finding.summary}`,
138
- `- unresolved: ${finding.unresolved}`,
139
- "",
337
+ ...renderSharedDecisionSections({
338
+ decision:
339
+ finding.unresolved === false
340
+ ? "Security posture is acceptable for the current bounded release step."
341
+ : "Security review remains provisional until explicit approval evidence exists.",
342
+ status: finding.unresolved === false ? "GREEN" : "PENDING",
343
+ evidence: [`severity: ${finding.severity}`, `summary: ${finding.summary}`],
344
+ blockers: finding.unresolved
345
+ ? ["Security review evidence has not been explicitly approved yet."]
346
+ : [],
347
+ nextAllowedTriggers: [nextTrigger],
348
+ }),
349
+ ...renderListSection("Trust Boundaries", finding.trustBoundaries ?? []),
350
+ ...renderListSection("Accepted Risks", finding.acceptedRisks ?? []),
140
351
  "## Evidence Files",
141
352
  "",
142
353
  `- audits logged: ${auditCount}`,
143
354
  `- cve entries logged: ${cveCount}`,
144
355
  "",
145
- "## Next Recommended Trigger",
146
- "",
147
- "`$vibe`",
148
- "",
356
+ ...renderRuntimeSummary(runtimeSummary),
149
357
  ].join("\n");
150
358
  }
151
359
 
152
- function renderExperienceSpec({ note, outcomeCount }) {
360
+ function renderExperienceSpec({ note, outcomeCount, runtimeSummary, nextTrigger = "`$build`" }) {
153
361
  return [
154
362
  "# Experience Spec",
155
363
  "",
156
364
  `Updated: ${new Date().toISOString()}`,
157
365
  "",
158
- "## Latest Outcome",
159
- "",
160
- `- area: ${note.area}`,
161
- `- summary: ${note.summary}`,
162
- "",
366
+ ...renderSharedDecisionSections({
367
+ decision:
368
+ note.approved === true
369
+ ? "DX/UX friction is acceptable for the current bounded release step."
370
+ : "DX/UX review remains provisional until explicit approval evidence exists.",
371
+ status: note.approved === true ? "GREEN" : "PENDING",
372
+ evidence: [`area: ${note.area}`, `summary: ${note.summary}`],
373
+ blockers:
374
+ note.approved === true
375
+ ? []
376
+ : ["DX/UX review evidence has not been explicitly approved yet."],
377
+ nextAllowedTriggers: [nextTrigger],
378
+ }),
379
+ ...renderListSection("Operator Friction", note.operatorFriction ?? []),
380
+ ...renderListSection("User Friction", note.userFriction ?? []),
163
381
  "## Evidence Files",
164
382
  "",
165
383
  `- outcomes logged: ${outcomeCount}`,
166
384
  "",
167
- "## Next Recommended Trigger",
168
- "",
169
- "`$build`",
170
- "",
385
+ ...renderRuntimeSummary(runtimeSummary),
171
386
  ].join("\n");
172
387
  }
173
388
 
174
- function renderImplementationPlan({ idea, blueprint }) {
389
+ function renderImplementationPlan({ idea, blueprint, runtimeSummary }) {
175
390
  return [
176
391
  "# Implementation Plan",
177
392
  "",
@@ -193,10 +408,17 @@ function renderImplementationPlan({ idea, blueprint }) {
193
408
  "",
194
409
  blueprint.summary,
195
410
  "",
411
+ ...renderRuntimeSummary(runtimeSummary),
196
412
  ].join("\n");
197
413
  }
198
414
 
199
- function renderMaestroPlan({ releaseState, recommendation }) {
415
+ function renderMaestroPlan({
416
+ releaseState,
417
+ recommendation,
418
+ runtimeSummary,
419
+ workflowSequence,
420
+ managerRun = null,
421
+ }) {
200
422
  return [
201
423
  "# Maestro Plan",
202
424
  "",
@@ -220,6 +442,12 @@ function renderMaestroPlan({ releaseState, recommendation }) {
220
442
  "",
221
443
  recommendation.why,
222
444
  "",
445
+ ...renderManagerSection(managerRun),
446
+ "## Workflow Sequence",
447
+ "",
448
+ ...workflowSequence.map((trigger) => `- ${trigger}`),
449
+ "",
450
+ ...renderRuntimeSummary(runtimeSummary),
223
451
  "## Recommended Lane",
224
452
  "",
225
453
  `- primary: ${recommendation.primaryLane}`,
@@ -240,31 +468,65 @@ function renderMaestroPlan({ releaseState, recommendation }) {
240
468
  ].join("\n");
241
469
  }
242
470
 
243
- function renderBuildPlan({ allowed, blockers, nextTriggers, suggestedBranches = [] }) {
471
+ function renderBuildPlan({
472
+ allowed,
473
+ gateState = allowed ? "READY" : "LOCKED",
474
+ blockers,
475
+ nextTriggers,
476
+ suggestedBranches = [],
477
+ buildSlice = [],
478
+ verificationPlan = [],
479
+ repairPath = [],
480
+ completionEvidence = [],
481
+ runtimeSummary = null,
482
+ }) {
244
483
  const lines = [
245
484
  "# Build Plan",
246
485
  "",
247
486
  `Updated: ${new Date().toISOString()}`,
248
487
  "",
488
+ ...renderSharedDecisionSections({
489
+ decision:
490
+ gateState === "DONE"
491
+ ? "Complete the current bounded build slice and proceed to merge."
492
+ : gateState === "RUNNING"
493
+ ? "Continue the active bounded build execution substep."
494
+ : gateState === "READY"
495
+ ? "Prepare and begin the next bounded build execution substep."
496
+ : "Build execution remains locked under the current runtime and release state.",
497
+ status: gateState,
498
+ evidence: completionEvidence,
499
+ blockers,
500
+ nextAllowedTriggers: nextTriggers,
501
+ }),
249
502
  "## Gate State",
250
503
  "",
251
- allowed ? "READY" : "LOCKED",
252
- "",
253
- "## Blockers",
504
+ gateState,
254
505
  "",
255
506
  ];
256
507
 
257
- if (blockers.length === 0) {
258
- lines.push("None.", "");
259
- } else {
260
- lines.push(...blockers.map((blocker) => `- ${blocker}`), "");
508
+ lines.push(...renderRuntimeSummary(runtimeSummary));
509
+ lines.push(...renderBuildContextBoundaries(runtimeSummary));
510
+
511
+ if (buildSlice.length > 0) {
512
+ lines.push("## Build Slice", "");
513
+ lines.push(...buildSlice.map((item) => `- ${item}`), "");
261
514
  }
262
515
 
263
- lines.push("## Next Allowed Triggers", "");
264
- lines.push(
265
- ...(nextTriggers.length === 0 ? ["- $build"] : nextTriggers.map((item) => `- ${item}`)),
266
- "",
267
- );
516
+ if (verificationPlan.length > 0) {
517
+ lines.push("## Verification Plan", "");
518
+ lines.push(...verificationPlan.map((item) => `- ${item}`), "");
519
+ }
520
+
521
+ if (repairPath.length > 0) {
522
+ lines.push("## Repair Path", "");
523
+ lines.push(...repairPath.map((item) => `- ${item}`), "");
524
+ }
525
+
526
+ if (completionEvidence.length > 0) {
527
+ lines.push("## Completion Evidence", "");
528
+ lines.push(...completionEvidence.map((item) => `- ${item}`), "");
529
+ }
268
530
 
269
531
  if (suggestedBranches.length > 0) {
270
532
  lines.push(
@@ -290,13 +552,10 @@ function renderRunbook() {
290
552
  "",
291
553
  "1. `ma setup`",
292
554
  '2. `ma idea "..."`',
293
- "3. `ma run '$arch'`",
294
- "4. `ma run '$sage'`",
295
- "5. `ma run '$flow'`",
296
- "6. `ma run '$vet'`",
297
- "7. `ma run '$vibe'`",
298
- "8. `ma status`",
299
- "9. `ma run '$build'`",
555
+ "3. `ma run '$maestro'`",
556
+ "4. follow the exact next trigger from `.ma/plans/maestro.md`",
557
+ "5. return to `$maestro` whenever the next lane is unclear",
558
+ "6. `ma status`",
300
559
  "",
301
560
  "## Runtime Artifacts",
302
561
  "",
@@ -308,6 +567,8 @@ function renderRunbook() {
308
567
  "- `.ma/specs/experience.md`",
309
568
  "- `.ma/plans/implementation.md`",
310
569
  "- `.ma/plans/build.md`",
570
+ "- `.ma/state/manager-runs.json`",
571
+ "- `.ma/state/maestro-state.json`",
311
572
  "- `.ma/decisions.json`",
312
573
  "- `.ma/release.json`",
313
574
  "",
@@ -330,6 +591,7 @@ export async function seedRuntimeArtifacts() {
330
591
  for (const dir of runtimeDirs) {
331
592
  await ensureDir(getRuntimeWritePath(dir));
332
593
  }
594
+ await ensureRuntimeSubsystems();
333
595
 
334
596
  await writeFileIfMissing(
335
597
  getRuntimeWritePath("context", "project.md"),
@@ -370,15 +632,27 @@ export async function writeProjectContext(idea) {
370
632
  await writeArtifact("context/project.md", renderProjectContext({ idea }));
371
633
  }
372
634
 
373
- export async function writeArchitectureArtifacts({ idea, blueprint }) {
374
- await writeArtifact("specs/architecture.md", renderArchitectureSpec({ idea, blueprint }));
375
- await writeArtifact("plans/implementation.md", renderImplementationPlan({ idea, blueprint }));
635
+ export async function writeArchitectureArtifacts({ idea, blueprint, runtimeSummary = null }) {
636
+ await writeArtifact(
637
+ "specs/architecture.md",
638
+ renderArchitectureSpec({ idea, blueprint, runtimeSummary }),
639
+ );
640
+ await writeArtifact(
641
+ "plans/implementation.md",
642
+ renderImplementationPlan({ idea, blueprint, runtimeSummary }),
643
+ );
376
644
  }
377
645
 
378
- export async function writeEvidenceSpec({ idea, sourceEntries, verified, blockers }) {
646
+ export async function writeEvidenceSpec({
647
+ idea,
648
+ sourceEntries,
649
+ verified,
650
+ blockers,
651
+ runtimeSummary = null,
652
+ }) {
379
653
  await writeArtifact(
380
654
  "specs/evidence.md",
381
- renderEvidenceSpec({ idea, sourceEntries, verified, blockers }),
655
+ renderEvidenceSpec({ idea, sourceEntries, verified, blockers, runtimeSummary }),
382
656
  );
383
657
  }
384
658
 
@@ -386,26 +660,75 @@ export async function writeLogicSpec(logicMap) {
386
660
  await writeArtifact("specs/logic.md", renderLogicSpec(logicMap));
387
661
  }
388
662
 
389
- export async function writeSecuritySpec({ finding, auditCount, cveCount }) {
390
- await writeArtifact("specs/security.md", renderSecuritySpec({ finding, auditCount, cveCount }));
663
+ export async function writeSecuritySpec({
664
+ finding,
665
+ auditCount,
666
+ cveCount,
667
+ runtimeSummary = null,
668
+ nextTrigger = "`$vibe`",
669
+ }) {
670
+ await writeArtifact(
671
+ "specs/security.md",
672
+ renderSecuritySpec({ finding, auditCount, cveCount, runtimeSummary, nextTrigger }),
673
+ );
391
674
  }
392
675
 
393
- export async function writeExperienceSpec({ note, outcomeCount }) {
394
- await writeArtifact("specs/experience.md", renderExperienceSpec({ note, outcomeCount }));
676
+ export async function writeExperienceSpec({
677
+ note,
678
+ outcomeCount,
679
+ runtimeSummary = null,
680
+ nextTrigger = "`$build`",
681
+ }) {
682
+ await writeArtifact(
683
+ "specs/experience.md",
684
+ renderExperienceSpec({ note, outcomeCount, runtimeSummary, nextTrigger }),
685
+ );
395
686
  }
396
687
 
397
688
  export async function writeBuildPlanArtifact({
398
689
  allowed,
690
+ gateState = allowed ? "READY" : "LOCKED",
399
691
  blockers,
400
692
  nextTriggers,
401
693
  suggestedBranches = [],
694
+ buildSlice = [],
695
+ verificationPlan = [],
696
+ repairPath = [],
697
+ completionEvidence = [],
698
+ runtimeSummary = null,
402
699
  }) {
403
700
  await writeArtifact(
404
701
  "plans/build.md",
405
- renderBuildPlan({ allowed, blockers, nextTriggers, suggestedBranches }),
702
+ renderBuildPlan({
703
+ allowed,
704
+ gateState,
705
+ blockers,
706
+ nextTriggers,
707
+ suggestedBranches,
708
+ buildSlice,
709
+ verificationPlan,
710
+ repairPath,
711
+ completionEvidence,
712
+ runtimeSummary,
713
+ }),
406
714
  );
407
715
  }
408
716
 
409
- export async function writeMaestroPlan({ releaseState, recommendation }) {
410
- await writeArtifact("plans/maestro.md", renderMaestroPlan({ releaseState, recommendation }));
717
+ export async function writeMaestroPlan({
718
+ releaseState,
719
+ recommendation,
720
+ runtimeSummary = null,
721
+ workflowSequence = [],
722
+ managerRun = null,
723
+ }) {
724
+ await writeArtifact(
725
+ "plans/maestro.md",
726
+ renderMaestroPlan({
727
+ releaseState,
728
+ recommendation,
729
+ runtimeSummary,
730
+ workflowSequence,
731
+ managerRun,
732
+ }),
733
+ );
411
734
  }