@jstn-sdk/ma 0.1.12 → 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 (177) hide show
  1. package/.agents/plugins/marketplace.json +0 -0
  2. package/.codex/agents/Architect.toml +0 -2
  3. package/.codex/agents/Auditor.toml +0 -2
  4. package/.codex/agents/Builder.toml +0 -2
  5. package/.codex/agents/Flow.toml +0 -2
  6. package/.codex/agents/Sage.toml +0 -2
  7. package/.codex/agents/Vibe.toml +0 -2
  8. package/.codex/hooks.json +14 -13
  9. package/.codex/prompts/enforcement.md +4 -0
  10. package/.codex/prompts/skill-contract.md +4 -0
  11. package/COVERAGE.md +211 -0
  12. package/DEMO.md +265 -0
  13. package/README.md +159 -16
  14. package/bin/ma.js +219 -14
  15. package/data/clone-data.ledger.json +41 -0
  16. package/data/clone-data.proof.json +50 -0
  17. package/data/clone-data.rvf +37 -0
  18. package/docs/README.md +4 -1
  19. package/docs/assets/image/Screenshot(1).png +0 -0
  20. package/docs/assets/image/Screenshot(2).png +0 -0
  21. package/docs/assets/image/Screenshot(3).png +0 -0
  22. package/docs/assets/image/Screenshot(4).png +0 -0
  23. package/docs/assets/image/Screenshot(5).png +0 -0
  24. package/docs/assets/image/Screenshot(6).png +0 -0
  25. package/docs/assets/image/Screenshot(7).png +0 -0
  26. package/docs/assets/image/Screenshot(8).png +0 -0
  27. package/docs/assets/image/Screenshot(9).png +0 -0
  28. package/docs/assets/meta-architect-logo.png +0 -0
  29. package/docs/assets/meta-architect-logo.svg +0 -0
  30. package/docs/getting-started.md +38 -22
  31. package/docs/installed-sdk.md +0 -0
  32. package/docs/mcp-setup.md +35 -0
  33. package/docs/onboarding.md +18 -2
  34. package/docs/prompt-guidance-contract.md +17 -0
  35. package/docs/prompt-guidance-fragments/active-autonomy-core.md +7 -0
  36. package/docs/qa/release-issue-gates-0.1.13.json +644 -0
  37. package/docs/qa/{release-readiness-0.1.12.md → release-readiness-0.1.13.md} +25 -9
  38. package/docs/qa/release-readiness-0.1.5.md +1 -1
  39. package/docs/reference/native-engineering-patterns.md +0 -0
  40. package/docs/reference/native-security-playbooks.md +6 -0
  41. package/docs/reference/native-source-selection.md +6 -0
  42. package/docs/reference/native-style-and-deslop.md +0 -0
  43. package/docs/release-spec.md +25 -9
  44. package/docs/skills.md +14 -1
  45. package/index.js +222 -2
  46. package/mcp/collections.json +23 -6
  47. package/mcp/local/code-intel.js +0 -0
  48. package/mcp/local/memory.js +0 -0
  49. package/mcp/local/playbooks.js +0 -0
  50. package/mcp/local/state.js +0 -0
  51. package/mcp/local/team-run.js +48 -1
  52. package/mcp/local/trace.js +0 -0
  53. package/mcp/local-capabilities.json +0 -0
  54. package/mcp/native-playbooks.json +0 -0
  55. package/mcp/servers.json +24 -0
  56. package/package.json +5 -2
  57. package/plugins/meta-architect/.app.json +1 -1
  58. package/plugins/meta-architect/.codex-plugin/plugin.json +1 -1
  59. package/plugins/meta-architect/.mcp.json +1 -1
  60. package/plugins/meta-architect/README.md +8 -1
  61. package/plugins/meta-architect/obsidian/main.js +401 -0
  62. package/plugins/meta-architect/obsidian/manifest.json +9 -0
  63. package/plugins/meta-architect/obsidian/styles.css +7 -0
  64. package/plugins/meta-architect/skills/align/SKILL.md +0 -0
  65. package/plugins/meta-architect/skills/align/agents/openai.yaml +0 -0
  66. package/plugins/meta-architect/skills/align/references/shared-language.md +0 -0
  67. package/plugins/meta-architect/skills/arch/SKILL.md +2 -0
  68. package/plugins/meta-architect/skills/arch/agents/openai.yaml +0 -0
  69. package/plugins/meta-architect/skills/build/SKILL.md +3 -0
  70. package/plugins/meta-architect/skills/build/agents/openai.yaml +0 -0
  71. package/plugins/meta-architect/skills/cleanup/SKILL.md +0 -0
  72. package/plugins/meta-architect/skills/cleanup/agents/openai.yaml +0 -0
  73. package/plugins/meta-architect/skills/cleanup/references/style-and-deslop.md +0 -0
  74. package/plugins/meta-architect/skills/diagnose/SKILL.md +0 -0
  75. package/plugins/meta-architect/skills/diagnose/agents/openai.yaml +0 -0
  76. package/plugins/meta-architect/skills/flow/SKILL.md +2 -0
  77. package/plugins/meta-architect/skills/flow/agents/openai.yaml +0 -0
  78. package/plugins/meta-architect/skills/maestro/SKILL.md +0 -0
  79. package/plugins/meta-architect/skills/maestro/agents/openai.yaml +0 -0
  80. package/plugins/meta-architect/skills/maestro/references/core-release-rules.md +0 -0
  81. package/plugins/meta-architect/skills/maestro/references/native-ingest-map.md +0 -0
  82. package/plugins/meta-architect/skills/sage/SKILL.md +2 -0
  83. package/plugins/meta-architect/skills/sage/agents/openai.yaml +0 -0
  84. package/plugins/meta-architect/skills/sage/references/source-selection.md +8 -0
  85. package/plugins/meta-architect/skills/tdd/SKILL.md +0 -0
  86. package/plugins/meta-architect/skills/tdd/agents/openai.yaml +0 -0
  87. package/plugins/meta-architect/skills/vet/SKILL.md +2 -0
  88. package/plugins/meta-architect/skills/vet/agents/openai.yaml +0 -0
  89. package/plugins/meta-architect/skills/vet/references/security-playbooks.md +7 -0
  90. package/plugins/meta-architect/skills/vibe/SKILL.md +2 -0
  91. package/plugins/meta-architect/skills/vibe/agents/openai.yaml +0 -0
  92. package/scripts/active-autonomy-hook.mjs +96 -0
  93. package/scripts/biome-staged.js +0 -0
  94. package/scripts/build-linux-packages.mjs +0 -0
  95. package/scripts/doctor.js +17 -4
  96. package/scripts/install.sh +28 -0
  97. package/scripts/linux-package-lib.mjs +0 -0
  98. package/scripts/linux-package-smoke.mjs +0 -0
  99. package/scripts/plugin-sync.js +0 -0
  100. package/scripts/postinstall.js +0 -0
  101. package/scripts/ralph/prompt.md +35 -0
  102. package/scripts/release-metadata.js +0 -0
  103. package/scripts/release-sync.js +0 -0
  104. package/scripts/release-verify.js +166 -1
  105. package/scripts/setup-npmrc.js +0 -0
  106. package/skills/align/SKILL.md +0 -0
  107. package/skills/align/agents/openai.yaml +0 -0
  108. package/skills/align/references/shared-language.md +0 -0
  109. package/skills/arch/SKILL.md +2 -0
  110. package/skills/arch/agents/openai.yaml +0 -0
  111. package/skills/build/SKILL.md +3 -0
  112. package/skills/build/agents/openai.yaml +0 -0
  113. package/skills/cleanup/SKILL.md +0 -0
  114. package/skills/cleanup/agents/openai.yaml +0 -0
  115. package/skills/cleanup/references/style-and-deslop.md +0 -0
  116. package/skills/diagnose/SKILL.md +0 -0
  117. package/skills/diagnose/agents/openai.yaml +0 -0
  118. package/skills/flow/SKILL.md +2 -0
  119. package/skills/flow/agents/openai.yaml +0 -0
  120. package/skills/maestro/SKILL.md +0 -0
  121. package/skills/maestro/agents/openai.yaml +0 -0
  122. package/skills/maestro/references/core-release-rules.md +0 -0
  123. package/skills/maestro/references/native-ingest-map.md +0 -0
  124. package/skills/sage/SKILL.md +2 -0
  125. package/skills/sage/agents/openai.yaml +0 -0
  126. package/skills/sage/references/source-selection.md +8 -0
  127. package/skills/tdd/SKILL.md +0 -0
  128. package/skills/tdd/agents/openai.yaml +0 -0
  129. package/skills/vet/SKILL.md +2 -0
  130. package/skills/vet/agents/openai.yaml +0 -0
  131. package/skills/vet/references/security-playbooks.md +7 -0
  132. package/skills/vibe/SKILL.md +2 -0
  133. package/skills/vibe/agents/openai.yaml +0 -0
  134. package/src/bootstrap.js +17 -0
  135. package/src/build-gate.js +2 -2
  136. package/src/launcher.js +4 -0
  137. package/src/mcp-live-client.js +289 -3
  138. package/src/paths.js +4 -0
  139. package/src/policy.js +1 -1
  140. package/src/release-issue-gates.js +190 -0
  141. package/src/runtime/active-autonomy-core.js +208 -0
  142. package/src/runtime/alignment-sentinel.js +165 -0
  143. package/src/runtime/architect-review.js +88 -0
  144. package/src/runtime/build-readiness.js +28 -4
  145. package/src/runtime/code-graph-rehearse.js +113 -0
  146. package/src/runtime/context-economy-core.js +276 -0
  147. package/src/runtime/continuity-notes.js +0 -0
  148. package/src/runtime/core-source-ingest.js +379 -0
  149. package/src/runtime/detached-provider.js +74 -0
  150. package/src/runtime/environment-awareness-core.js +460 -0
  151. package/src/runtime/exposure-catalog.js +276 -0
  152. package/src/runtime/guidance-stack.js +0 -0
  153. package/src/runtime/helper-orchestration-core.js +307 -0
  154. package/src/runtime/learning-loop-core.js +238 -0
  155. package/src/runtime/maestro-events.js +18 -0
  156. package/src/runtime/maestro-manager.js +19 -0
  157. package/src/runtime/maestro-state.js +125 -0
  158. package/src/runtime/mcp-policy.js +192 -0
  159. package/src/runtime/obsidian-integration-core.js +851 -0
  160. package/src/runtime/obsidian-plugin-bridge.js +739 -0
  161. package/src/runtime/orchestrator.js +0 -0
  162. package/src/runtime/prompt-strategy-core.js +230 -0
  163. package/src/runtime/quorum-review.js +90 -0
  164. package/src/runtime/ralph-execution-core.js +217 -0
  165. package/src/runtime/redaction-gateway.js +174 -0
  166. package/src/runtime/runtime-state.js +843 -2
  167. package/src/runtime/semantic-recording-core.js +147 -0
  168. package/src/runtime/signal-hooks.js +15 -0
  169. package/src/runtime/skills-registry-export.js +670 -0
  170. package/src/runtime/startup-path.js +0 -0
  171. package/src/runtime/universal-plugin-broker-core.js +575 -0
  172. package/src/runtime/workspace-intelligence-runtime.js +674 -0
  173. package/src/runtime/workspace-virtualizer.js +102 -0
  174. package/src/runtime/workspaces.js +0 -0
  175. package/src/runtime-artifacts.js +225 -62
  176. package/src/skill-installer.js +0 -0
  177. package/src/skills.js +876 -84
@@ -0,0 +1,102 @@
1
+ import { ensureDir, readJson, writeFileIfMissing } from "../fs-utils.js";
2
+ import { getRepoRoot, getRuntimeSubsystemPath } from "../paths.js";
3
+
4
+ export const workspaceVirtualizerSchemaVersion = "0.1.0";
5
+
6
+ export function getWorkspaceVirtualizerPath() {
7
+ return getRuntimeSubsystemPath("context", "workspace-virtualizer.json");
8
+ }
9
+
10
+ export function createDefaultWorkspaceVirtualizer() {
11
+ return {
12
+ schemaVersion: workspaceVirtualizerSchemaVersion,
13
+ product: "Meta-Architect",
14
+ purpose:
15
+ "Defines bounded synthetic workspace verification without replacing real source or production release evidence.",
16
+ evidence_boundary: {
17
+ records_as: "virtual_workspace_result",
18
+ never_records_as: "production_evidence",
19
+ production_promotion_requires: ["real_workspace_test", "release_issue_gate_proof"],
20
+ },
21
+ mutation_policy: {
22
+ default: "read_only",
23
+ may_mutate_source: false,
24
+ may_mutate_release_state: false,
25
+ },
26
+ applies_to: ["$build", "executor_roles", "verifier_roles"],
27
+ };
28
+ }
29
+
30
+ export function validateWorkspaceVirtualizer(value) {
31
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
32
+ throw new Error("workspace virtualizer must be an object");
33
+ }
34
+ if (value.schemaVersion !== workspaceVirtualizerSchemaVersion) {
35
+ throw new Error(`Unsupported workspace virtualizer schemaVersion: ${value.schemaVersion}`);
36
+ }
37
+ if (value.evidence_boundary?.records_as !== "virtual_workspace_result") {
38
+ throw new Error("workspace virtualizer must record as virtual_workspace_result");
39
+ }
40
+ if (value.evidence_boundary?.never_records_as !== "production_evidence") {
41
+ throw new Error("workspace virtualizer must not record as production_evidence");
42
+ }
43
+ if (value.mutation_policy?.may_mutate_source !== false) {
44
+ throw new Error("workspace virtualizer must not mutate source by default");
45
+ }
46
+ return value;
47
+ }
48
+
49
+ export async function seedWorkspaceVirtualizerArtifacts() {
50
+ await ensureDir(getRuntimeSubsystemPath("context"));
51
+ await writeFileIfMissing(
52
+ getWorkspaceVirtualizerPath(),
53
+ `${JSON.stringify(createDefaultWorkspaceVirtualizer(), null, 2)}\n`,
54
+ );
55
+ }
56
+
57
+ export async function loadWorkspaceVirtualizer() {
58
+ return validateWorkspaceVirtualizer(await readJson(getWorkspaceVirtualizerPath()));
59
+ }
60
+
61
+ export function createVirtualWorkspacePlan({
62
+ commands = [],
63
+ touchpoints = [],
64
+ root = getRepoRoot(),
65
+ }) {
66
+ return {
67
+ record_type: "virtual_workspace_result",
68
+ root,
69
+ source_mutation_allowed: false,
70
+ production_evidence: false,
71
+ commands: commands.filter((command) => typeof command === "string" && command.trim()),
72
+ touchpoints: touchpoints.filter((filePath) => typeof filePath === "string" && filePath.trim()),
73
+ required_followup:
74
+ "Run the equivalent checks against the real workspace before production pass.",
75
+ };
76
+ }
77
+
78
+ export function createVirtualVerificationReceipt({ plan, commandResults = [] }) {
79
+ if (plan?.record_type !== "virtual_workspace_result") {
80
+ throw new Error("Virtual verification receipt requires a virtual workspace plan");
81
+ }
82
+
83
+ const normalizedResults = commandResults.map((result) => ({
84
+ command: `${result.command ?? ""}`.trim(),
85
+ exitCode: Number.isInteger(result.exitCode) ? result.exitCode : null,
86
+ outputPreview: `${result.outputPreview ?? ""}`.slice(0, 500),
87
+ }));
88
+ const passed =
89
+ normalizedResults.length > 0 &&
90
+ normalizedResults.every((result) => result.command && result.exitCode === 0);
91
+
92
+ return {
93
+ record_type: "virtual_verification_receipt",
94
+ records_as: "virtual_workspace_result",
95
+ passed,
96
+ production_evidence: false,
97
+ source_mutation_allowed: false,
98
+ commands: normalizedResults,
99
+ touchpoints: plan.touchpoints,
100
+ required_followup: plan.required_followup,
101
+ };
102
+ }
File without changes
@@ -52,6 +52,36 @@ function renderRuntimeSummary(summary) {
52
52
  `- manager runs: ${summary.managerRunCount}`,
53
53
  `- active manager runs: ${summary.activeManagerRunCount}`,
54
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}`,
55
85
  `- build status: ${summary.buildStatus}`,
56
86
  `- missing runtime artifacts: ${summary.missingArtifacts.length}`,
57
87
  `- invalid runtime artifacts: ${summary.invalidArtifacts.length}`,
@@ -59,6 +89,51 @@ function renderRuntimeSummary(summary) {
59
89
  ];
60
90
  }
61
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
+
62
137
  function formatManagerHelper(helper) {
63
138
  return `${helper.skill}: ${helper.objective} [${helper.status}]`;
64
139
  }
@@ -110,12 +185,49 @@ function renderManagerSection(managerRun) {
110
185
  return lines;
111
186
  }
112
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
+
113
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
+ ];
114
219
  return [
115
220
  "# Architecture Spec",
116
221
  "",
117
222
  `Updated: ${new Date().toISOString()}`,
118
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
+ }),
119
231
  "## Problem Statement",
120
232
  "",
121
233
  idea,
@@ -128,32 +240,42 @@ function renderArchitectureSpec({ idea, blueprint, runtimeSummary }) {
128
240
  "",
129
241
  ...blueprint.suggestedStack.map((item) => `- ${item}`),
130
242
  "",
243
+ ...renderListSection("Rejected Alternatives", blueprint.rejectedAlternatives ?? []),
131
244
  "## Intended Outcome",
132
245
  "",
133
246
  blueprint.outcome,
134
247
  "",
135
248
  ...renderRuntimeSummary(runtimeSummary),
136
- "## Next Recommended Trigger",
137
- "",
138
- "`$sage`",
139
- "",
140
249
  ].join("\n");
141
250
  }
142
251
 
143
252
  function renderEvidenceSpec({ idea, sourceEntries, verified, blockers, runtimeSummary }) {
144
253
  const status = verified ? "VERIFIED" : sourceEntries.length > 0 ? "PARTIAL" : "MISSING";
254
+ const evidenceGrade = verified ? "VERIFIED" : sourceEntries.length > 0 ? "PARTIAL" : "MISSING";
145
255
  const lines = [
146
256
  "# Evidence Spec",
147
257
  "",
148
258
  `Updated: ${new Date().toISOString()}`,
149
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
+ }),
150
269
  "## Probe Basis",
151
270
  "",
152
271
  idea,
153
272
  "",
154
- "## Evidence Status",
273
+ ...renderKeyValueSection("Evidence Grade", [["grade", evidenceGrade]]),
274
+ "## Exact Upstream Mapping",
155
275
  "",
156
- status,
276
+ ...(sourceEntries.length === 0
277
+ ? ["No upstream mappings recorded."]
278
+ : sourceEntries.map((source) => `- ${source.repo} -> ${source.endpoint}`)),
157
279
  "",
158
280
  "## Sources",
159
281
  "",
@@ -176,15 +298,7 @@ function renderEvidenceSpec({ idea, sourceEntries, verified, blockers, runtimeSu
176
298
  lines.push("");
177
299
  }
178
300
 
179
- lines.push("## Blockers", "");
180
- if (blockers.length === 0) {
181
- lines.push("None.", "");
182
- } else {
183
- lines.push(...blockers.map((blocker) => `- ${blocker}`), "");
184
- }
185
-
186
301
  lines.push(...renderRuntimeSummary(runtimeSummary));
187
- lines.push("## Next Recommended Trigger", "", verified ? "`$flow`" : "`$sage`", "");
188
302
  return lines.join("\n");
189
303
  }
190
304
 
@@ -194,22 +308,17 @@ function renderLogicSpec(logicMap) {
194
308
  "",
195
309
  `Updated: ${new Date().toISOString()}`,
196
310
  "",
197
- ...(logicMap.actors
198
- ? ["## Actors", "", ...logicMap.actors.map((actor) => `- ${actor}`), ""]
199
- : []),
200
- "## States",
201
- "",
202
- ...logicMap.states.map((state) => `- ${state}`),
203
- "",
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 ?? []),
204
321
  ...(logicMap.runtimeSummary ? renderRuntimeSummary(logicMap.runtimeSummary) : []),
205
- "## Blockers",
206
- "",
207
- ...(logicMap.blockers.length === 0 ? ["None."] : logicMap.blockers.map((item) => `- ${item}`)),
208
- "",
209
- "## Next Recommended Trigger",
210
- "",
211
- logicMap.nextTrigger ?? "`$vet`",
212
- "",
213
322
  ].join("\n");
214
323
  }
215
324
 
@@ -225,22 +334,26 @@ function renderSecuritySpec({
225
334
  "",
226
335
  `Updated: ${new Date().toISOString()}`,
227
336
  "",
228
- "## Latest Finding",
229
- "",
230
- `- severity: ${finding.severity}`,
231
- `- summary: ${finding.summary}`,
232
- `- unresolved: ${finding.unresolved}`,
233
- "",
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 ?? []),
234
351
  "## Evidence Files",
235
352
  "",
236
353
  `- audits logged: ${auditCount}`,
237
354
  `- cve entries logged: ${cveCount}`,
238
355
  "",
239
356
  ...renderRuntimeSummary(runtimeSummary),
240
- "## Next Recommended Trigger",
241
- "",
242
- nextTrigger,
243
- "",
244
357
  ].join("\n");
245
358
  }
246
359
 
@@ -250,20 +363,26 @@ function renderExperienceSpec({ note, outcomeCount, runtimeSummary, nextTrigger
250
363
  "",
251
364
  `Updated: ${new Date().toISOString()}`,
252
365
  "",
253
- "## Latest Outcome",
254
- "",
255
- `- area: ${note.area}`,
256
- `- summary: ${note.summary}`,
257
- "",
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 ?? []),
258
381
  "## Evidence Files",
259
382
  "",
260
383
  `- outcomes logged: ${outcomeCount}`,
261
384
  "",
262
385
  ...renderRuntimeSummary(runtimeSummary),
263
- "## Next Recommended Trigger",
264
- "",
265
- nextTrigger,
266
- "",
267
386
  ].join("\n");
268
387
  }
269
388
 
@@ -351,9 +470,14 @@ function renderMaestroPlan({
351
470
 
352
471
  function renderBuildPlan({
353
472
  allowed,
473
+ gateState = allowed ? "READY" : "LOCKED",
354
474
  blockers,
355
475
  nextTriggers,
356
476
  suggestedBranches = [],
477
+ buildSlice = [],
478
+ verificationPlan = [],
479
+ repairPath = [],
480
+ completionEvidence = [],
357
481
  runtimeSummary = null,
358
482
  }) {
359
483
  const lines = [
@@ -361,27 +485,48 @@ function renderBuildPlan({
361
485
  "",
362
486
  `Updated: ${new Date().toISOString()}`,
363
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
+ }),
364
502
  "## Gate State",
365
503
  "",
366
- allowed ? "READY" : "LOCKED",
367
- "",
368
- "## Blockers",
504
+ gateState,
369
505
  "",
370
506
  ];
371
507
 
372
- if (blockers.length === 0) {
373
- lines.push("None.", "");
374
- } else {
375
- 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}`), "");
376
514
  }
377
515
 
378
- lines.push(...renderRuntimeSummary(runtimeSummary));
516
+ if (verificationPlan.length > 0) {
517
+ lines.push("## Verification Plan", "");
518
+ lines.push(...verificationPlan.map((item) => `- ${item}`), "");
519
+ }
379
520
 
380
- lines.push("## Next Allowed Triggers", "");
381
- lines.push(
382
- ...(nextTriggers.length === 0 ? ["- $build"] : nextTriggers.map((item) => `- ${item}`)),
383
- "",
384
- );
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
+ }
385
530
 
386
531
  if (suggestedBranches.length > 0) {
387
532
  lines.push(
@@ -422,6 +567,8 @@ function renderRunbook() {
422
567
  "- `.ma/specs/experience.md`",
423
568
  "- `.ma/plans/implementation.md`",
424
569
  "- `.ma/plans/build.md`",
570
+ "- `.ma/state/manager-runs.json`",
571
+ "- `.ma/state/maestro-state.json`",
425
572
  "- `.ma/decisions.json`",
426
573
  "- `.ma/release.json`",
427
574
  "",
@@ -540,14 +687,30 @@ export async function writeExperienceSpec({
540
687
 
541
688
  export async function writeBuildPlanArtifact({
542
689
  allowed,
690
+ gateState = allowed ? "READY" : "LOCKED",
543
691
  blockers,
544
692
  nextTriggers,
545
693
  suggestedBranches = [],
694
+ buildSlice = [],
695
+ verificationPlan = [],
696
+ repairPath = [],
697
+ completionEvidence = [],
546
698
  runtimeSummary = null,
547
699
  }) {
548
700
  await writeArtifact(
549
701
  "plans/build.md",
550
- renderBuildPlan({ allowed, blockers, nextTriggers, suggestedBranches, runtimeSummary }),
702
+ renderBuildPlan({
703
+ allowed,
704
+ gateState,
705
+ blockers,
706
+ nextTriggers,
707
+ suggestedBranches,
708
+ buildSlice,
709
+ verificationPlan,
710
+ repairPath,
711
+ completionEvidence,
712
+ runtimeSummary,
713
+ }),
551
714
  );
552
715
  }
553
716
 
File without changes