@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
@@ -0,0 +1,674 @@
1
+ import { ensureDir, readJson, writeFileIfMissing } from "../fs-utils.js";
2
+ import { getRuntimeReadPath, getRuntimeSubsystemPath } from "../paths.js";
3
+
4
+ export const workspaceIntelligenceSchemaVersion = "0.1.0";
5
+
6
+ export function getCapabilityCompositionPath() {
7
+ return getRuntimeSubsystemPath("context", "capability-composition.json");
8
+ }
9
+
10
+ export function getWorkspaceContextPackPath() {
11
+ return getRuntimeSubsystemPath("context", "workspace-context-pack.json");
12
+ }
13
+
14
+ export function getWorkspaceEffectivenessPath() {
15
+ return getRuntimeSubsystemPath("context", "workspace-effectiveness.json");
16
+ }
17
+
18
+ export function getSemanticReceiptIndexPath() {
19
+ return getRuntimeReadPath("evidence", "semantic-receipts.json");
20
+ }
21
+
22
+ export function createDefaultCapabilityComposition() {
23
+ return {
24
+ schemaVersion: workspaceIntelligenceSchemaVersion,
25
+ product: "Meta-Architect",
26
+ purpose:
27
+ "Defines how MA default capabilities compose through one workspace runtime instead of becoming redundant skills.",
28
+ capability_matrix: [
29
+ {
30
+ capability: "environment_awareness_core",
31
+ semantic_role: "available_capability_discovery",
32
+ reads: [
33
+ "repo_local_skill_surfaces",
34
+ "repo_local_mcp_configs",
35
+ "plugin_manifests",
36
+ "opt_in_global_user_config",
37
+ ],
38
+ writes: ["environment_capability_index", "available_capability_records"],
39
+ cannot_mutate: [
40
+ "discovered_user_configs",
41
+ ".ma/release.json",
42
+ ".ma/decisions.json",
43
+ "build_evidence",
44
+ ],
45
+ records_as: "available_capability",
46
+ never_records_as: "build_evidence",
47
+ applies_to: [
48
+ "$maestro",
49
+ "all_gated_lanes",
50
+ "all_applicable_agents",
51
+ "all_applicable_roles",
52
+ "team_workers",
53
+ "exported_host_payloads",
54
+ ],
55
+ },
56
+ {
57
+ capability: "helper_orchestration_core",
58
+ semantic_role: "non_gating_helper_support",
59
+ reads: [
60
+ "release_state",
61
+ "runtime_summary",
62
+ "lane_status",
63
+ "workspace_context_pack",
64
+ "manager_run_dispatch_plan",
65
+ ],
66
+ writes: [
67
+ "helper_alignment_receipt",
68
+ "helper_diagnosis_receipt",
69
+ "helper_tdd_receipt",
70
+ "helper_cleanup_receipt",
71
+ "exact_next_trigger",
72
+ ],
73
+ cannot_mutate: [".ma/release.json", ".ma/decisions.json", "gate_approval_status"],
74
+ supports: ["$align", "$diagnose", "$tdd", "$cleanup"],
75
+ records_as: "helper_receipt",
76
+ never_records_as: "gate_approval",
77
+ applies_to: [
78
+ "$maestro",
79
+ "all_gated_lanes",
80
+ "all_applicable_agents",
81
+ "all_applicable_roles",
82
+ "team_workers",
83
+ "exported_host_payloads",
84
+ ],
85
+ },
86
+ {
87
+ capability: "obsidian_integration_core",
88
+ semantic_role: "brain_context",
89
+ reads: [
90
+ "operator_selected_vault_notes",
91
+ "tag_graph",
92
+ "vault_links",
93
+ "exported_ma_snapshots",
94
+ ],
95
+ writes: ["vault_snapshot_exports", "queued_plugin_requests", "note_selection_metadata"],
96
+ cannot_mutate: [".ma/release.json", ".ma/decisions.json", ".ma/plans/", ".ma/specs/"],
97
+ records_as: "vault_context",
98
+ never_records_as: "build_evidence",
99
+ applies_to: ["all_applicable_agents", "all_applicable_roles", "exported_host_payloads"],
100
+ },
101
+ {
102
+ capability: "context_economy_core",
103
+ semantic_role: "context_budget",
104
+ reads: ["progress_updates", "runtime_summaries", "mcp_descriptors", "worker_handoffs"],
105
+ writes: ["terse_summaries", "compressed_artifact_views", "budgeted_tool_descriptions"],
106
+ cannot_mutate: ["code_blocks", "command_output", "warning_semantics", "authority_fields"],
107
+ safety_valves: [
108
+ "security_warning",
109
+ "irreversible_action",
110
+ "user_confusion",
111
+ "verification_failure",
112
+ ],
113
+ applies_to: ["all_applicable_agents", "all_applicable_roles"],
114
+ },
115
+ {
116
+ capability: "prompt_strategy_core",
117
+ semantic_role: "prompt_strategy",
118
+ reads: ["workspace_context_pack", "capability_matrix", "semantic_receipts", "lane_policy"],
119
+ writes: ["prompt_strategy_policy", "lane_prompt_constraints", "host_payload_prompt_rules"],
120
+ cannot_mutate: ["release_state", "lane_authority", "redaction_policy", "semantic_receipts"],
121
+ evidence_source: "NirDiamant/Prompt_Engineering",
122
+ applies_to: ["all_applicable_agents", "all_applicable_roles", "exported_host_payloads"],
123
+ },
124
+ {
125
+ capability: "active_autonomy_core",
126
+ semantic_role: "anti_passive_execution_contract",
127
+ reads: [
128
+ "workspace_contract",
129
+ "prompt_strategy_core",
130
+ "runtime_hook_policy",
131
+ "semantic_receipts",
132
+ ],
133
+ writes: [
134
+ "autonomy_directive",
135
+ "auto_continue_rule",
136
+ "stall_policy",
137
+ "terminal_handoff_contract",
138
+ ],
139
+ cannot_mutate: ["closed_ask_list", "verification_requirements", "safety_boundaries"],
140
+ applies_to: [
141
+ "all_applicable_agents",
142
+ "all_applicable_roles",
143
+ "runtime_hooks",
144
+ "exported_host_payloads",
145
+ ],
146
+ },
147
+ {
148
+ capability: "ralph_execution_core",
149
+ semantic_role: "story_execution",
150
+ reads: ["approved_prd", "test_spec", "semantic_receipts", "workspace_context_pack"],
151
+ writes: ["story_progress", "execution_log", "scoped_learnings"],
152
+ cannot_mutate: [".ma/release.json", "final_build_promotion", "lane_approval_status"],
153
+ authority: "$maestro_or_owning_lane_dispatch",
154
+ applies_to: ["executor_roles", "team_workers", "verifier_followups", "reviewer_followups"],
155
+ },
156
+ {
157
+ capability: "redaction_gateway",
158
+ semantic_role: "provider_boundary",
159
+ reads: ["vault_context", "workspace_context_pack", "provider_bound_prompts"],
160
+ writes: ["sanitized_context", "redaction_receipts"],
161
+ cannot_mutate: ["source_evidence", "release_state", "lane_decisions"],
162
+ applies_to: ["all_provider_bound_agents", "mcp_payloads", "exported_host_payloads"],
163
+ },
164
+ {
165
+ capability: "quorum_review_engine",
166
+ semantic_role: "verification_confidence",
167
+ reads: ["build_plan", "semantic_receipts", "review_votes"],
168
+ writes: ["quorum_verdict", "minority_report", "confidence_receipt"],
169
+ cannot_mutate: ["release_state_without_build_lane", "source_artifacts"],
170
+ applies_to: ["$build", "reviewer_roles", "verifier_roles"],
171
+ },
172
+ {
173
+ capability: "alignment_sentinel",
174
+ semantic_role: "runtime_drift_detection",
175
+ reads: ["release_state", "decisions", "manager_runs", "semantic_receipts"],
176
+ writes: ["drift_report", "bounded_recovery_recommendation"],
177
+ cannot_mutate: ["release_state_without_owning_lane"],
178
+ applies_to: ["$maestro", "owning_lanes", "team_workers"],
179
+ },
180
+ {
181
+ capability: "workspace_virtualizer",
182
+ semantic_role: "bounded_verification_sandbox",
183
+ reads: ["workspace_context_pack", "build_plan", "test_commands"],
184
+ writes: ["virtual_workspace_result", "verification_receipt"],
185
+ cannot_mutate: ["source_workspace_without_explicit_build_lane"],
186
+ applies_to: ["$build", "executor_roles", "verifier_roles"],
187
+ },
188
+ {
189
+ capability: "code_graph_rehearse",
190
+ semantic_role: "trajectory_preview",
191
+ reads: ["code_graph", "workspace_context_pack", "planned_story"],
192
+ writes: ["rehearsal_trace", "risk_receipt", "touchpoint_map"],
193
+ cannot_mutate: ["source_code", "release_state"],
194
+ applies_to: ["$arch", "$flow", "$build", "executor_roles"],
195
+ },
196
+ {
197
+ capability: "skills_registry_export",
198
+ semantic_role: "host_compatibility_payload",
199
+ reads: ["canonical_ma_contracts", "capability_matrix", "workspace_context_pack"],
200
+ writes: ["exported_skill_payloads", "host_install_receipts"],
201
+ cannot_mutate: ["canonical_ma_contracts"],
202
+ applies_to: ["supported_hosts", "package_install", "exported_host_payloads"],
203
+ },
204
+ {
205
+ capability: "universal_plugin_broker_core",
206
+ semantic_role: "cross_agent_plugin_broker",
207
+ reads: [
208
+ "ma_plugin_manifest",
209
+ "plugin_entrypoint",
210
+ "vendor_host_config_roots",
211
+ "skills_registry_export",
212
+ ],
213
+ writes: [
214
+ "isolated_plugin_bundle",
215
+ "executable_plugin_wrapper",
216
+ "vendor_mcp_config_entries",
217
+ "plugin_context_skill_payload",
218
+ "plugin_broker_receipt",
219
+ ],
220
+ cannot_mutate: [
221
+ ".ma/release.json",
222
+ ".ma/decisions.json",
223
+ ".ma/plans/",
224
+ ".ma/specs/",
225
+ "build_evidence",
226
+ ],
227
+ records_as: "plugin_compatibility_configuration",
228
+ never_records_as: "build_evidence",
229
+ applies_to: [
230
+ "claude-code",
231
+ "antigravity",
232
+ "cursor",
233
+ "codex",
234
+ "all_supported_context_layer_agents",
235
+ "exported_host_payloads",
236
+ ],
237
+ },
238
+ ],
239
+ global_rules: [
240
+ "Skills are UI shortcuts over shared runtime contracts, not independent architectures.",
241
+ "Every capability must declare reads, writes, forbidden mutations, semantic role, and applicable surfaces.",
242
+ "Release-state mutation remains lane-owned even when helper roles, workers, or host payloads participate.",
243
+ "Brain context, technical evidence, execution progress, and verification confidence are separate semantic channels.",
244
+ ],
245
+ };
246
+ }
247
+
248
+ export function createDefaultWorkspaceContextPack() {
249
+ return {
250
+ schemaVersion: workspaceIntelligenceSchemaVersion,
251
+ product: "Meta-Architect",
252
+ purpose:
253
+ "Shared workspace context consumed by applicable MA agents, roles, lanes, workers, reviewers, and host exports.",
254
+ workspace_identity: {
255
+ mode: "workspace_intelligence_runtime",
256
+ user_workspace_native: true,
257
+ primary_surface: "$maestro",
258
+ skill_policy: "ui_shortcuts_over_shared_runtime_contracts",
259
+ },
260
+ semantic_channels: {
261
+ brain_context: {
262
+ sources: [".ma/context/project.md", ".ma/memory/notes.md", "obsidian_integration_core"],
263
+ meaning:
264
+ "User notes, project narrative, Obsidian vault context, and durable workspace memory.",
265
+ },
266
+ technical_evidence: {
267
+ sources: [".ma/evidence/", "mcp/servers.json", "$sage"],
268
+ meaning: "Source-backed evidence allowed to support technical and build claims.",
269
+ },
270
+ executable_intent: {
271
+ sources: [".ma/plans/", ".ma/specs/", "ralph_execution_core"],
272
+ meaning: "Approved PRD, test shape, story state, and bounded execution intent.",
273
+ },
274
+ verification_confidence: {
275
+ sources: [
276
+ "$flow",
277
+ "$vet",
278
+ "$vibe",
279
+ "$build",
280
+ "quorum_review_engine",
281
+ "workspace_virtualizer",
282
+ ],
283
+ meaning:
284
+ "Evidence that the current step is safe, testable, and ready to execute or promote.",
285
+ },
286
+ provider_boundary: {
287
+ sources: ["redaction_gateway"],
288
+ meaning: "Controls what workspace or vault context may leave the local runtime.",
289
+ },
290
+ context_budget: {
291
+ sources: ["context_economy_core"],
292
+ meaning:
293
+ "Controls terse summaries without reducing safety, evidence, schemas, or warnings.",
294
+ },
295
+ prompt_strategy: {
296
+ sources: ["prompt_strategy_core", "NirDiamant/Prompt_Engineering"],
297
+ meaning:
298
+ "Selects MA-owned prompt strategies for clarity, decomposition, validation, constraints, context examples, and safety.",
299
+ },
300
+ active_autonomy: {
301
+ sources: ["active_autonomy_core", "runtime_hook_policy", "prompt_strategy_core"],
302
+ meaning:
303
+ "Prevents passive chatbot behavior with AUTO-CONTINUE / ASK rules, completion loops, and hook backstops.",
304
+ },
305
+ helper_support: {
306
+ sources: ["helper_orchestration_core", "$align", "$diagnose", "$tdd", "$cleanup"],
307
+ meaning:
308
+ "Non-gating helper receipts that clarify, diagnose, lock tests, or simplify while returning authority to $maestro or the owning lane.",
309
+ },
310
+ available_capabilities: {
311
+ sources: ["environment_awareness_core"],
312
+ meaning:
313
+ "Existing repo, host, MCP, and plugin capabilities MA may consider when task-relevant without taking ownership or treating them as evidence.",
314
+ },
315
+ plugin_compatibility: {
316
+ sources: ["universal_plugin_broker_core", "skills_registry_export"],
317
+ meaning:
318
+ "Hybrid plugin compatibility: MCP tooling for supported vendors plus MA skill context payloads for all supported host agents.",
319
+ },
320
+ },
321
+ required_workspace_facts: [
322
+ "stack",
323
+ "package_manager",
324
+ "test_commands",
325
+ "build_commands",
326
+ "release_state",
327
+ "trusted_evidence_sources",
328
+ "active_gates",
329
+ "brain_context_sources",
330
+ "redaction_policy",
331
+ "prompt_strategy_policy",
332
+ "active_autonomy_policy",
333
+ "plugin_manifest_policy",
334
+ ],
335
+ applies_to: ["all_applicable_agents", "all_applicable_roles", "exported_host_payloads"],
336
+ };
337
+ }
338
+
339
+ export function createDefaultWorkspaceEffectiveness() {
340
+ const checks = [
341
+ {
342
+ id: "stack_identified",
343
+ proves: "MA can identify the workspace stack before making architectural or build claims.",
344
+ required_for: ["$arch", "$sage", "$build"],
345
+ status: "pending",
346
+ },
347
+ {
348
+ id: "commands_identified",
349
+ proves: "MA can identify test/build commands for bounded verification.",
350
+ required_for: ["$build", "ralph_execution_core", "workspace_virtualizer"],
351
+ status: "pending",
352
+ },
353
+ {
354
+ id: "evidence_channels_bound",
355
+ proves: "MA can separate technical evidence from brain context and generated artifacts.",
356
+ required_for: ["$sage", "$vet", "$build"],
357
+ status: "pending",
358
+ },
359
+ {
360
+ id: "brain_context_bound",
361
+ proves:
362
+ "MA can preserve user/project notes, including Obsidian context, without treating them as build evidence.",
363
+ required_for: ["obsidian_integration_core", "$arch", "$vibe"],
364
+ status: "pending",
365
+ },
366
+ {
367
+ id: "executable_prd_ready",
368
+ proves: "MA can turn approved planning into story-sized execution contracts.",
369
+ required_for: ["ralph_execution_core", "$build"],
370
+ status: "pending",
371
+ },
372
+ {
373
+ id: "environment_awareness_bound",
374
+ proves:
375
+ "MA can discover existing skills, MCP servers, and plugins as available capabilities without auto-running them or turning them into build evidence.",
376
+ required_for: ["$maestro", "all_gated_lanes", "team_workers", "exported_host_payloads"],
377
+ status: "pending",
378
+ },
379
+ {
380
+ id: "helper_support_bound",
381
+ proves:
382
+ "MA can use $align, $diagnose, $tdd, and $cleanup together without creating parallel gates or mutating release state.",
383
+ required_for: ["$maestro", "all_gated_lanes", "team_workers", "exported_host_payloads"],
384
+ status: "pending",
385
+ },
386
+ {
387
+ id: "universal_plugin_broker_bound",
388
+ proves:
389
+ "MA can install a local plugin bundle, generate an MCP wrapper, inject detected vendor configs, and export context-layer skill payloads without claiming build evidence.",
390
+ required_for: ["supported_hosts", "exported_host_payloads", "extensibility"],
391
+ status: "pending",
392
+ },
393
+ {
394
+ id: "semantic_receipts_available",
395
+ proves: "MA can explain what a capability wrote, why it matters, and what it unlocks.",
396
+ required_for: ["all_applicable_agents", "all_applicable_roles"],
397
+ status: "pending",
398
+ },
399
+ {
400
+ id: "prompt_strategy_bound",
401
+ proves:
402
+ "MA can select prompt techniques through first-party lane policy without creating redundant user-facing skills.",
403
+ required_for: ["all_applicable_agents", "all_applicable_roles", "exported_host_payloads"],
404
+ status: "pending",
405
+ },
406
+ {
407
+ id: "active_autonomy_bound",
408
+ proves:
409
+ "MA can continue clear safe work automatically, ask only on a closed risk list, and reject passive permission handoffs.",
410
+ required_for: ["all_applicable_agents", "all_applicable_roles", "runtime_hooks"],
411
+ status: "pending",
412
+ },
413
+ ];
414
+ return {
415
+ schemaVersion: workspaceIntelligenceSchemaVersion,
416
+ product: "Meta-Architect",
417
+ purpose: "Readiness gate for proving MA is effective inside a user workspace.",
418
+ ready: false,
419
+ checks,
420
+ minimum_ready_rule: "All checks must be pass or explicitly waived with owner and reason.",
421
+ };
422
+ }
423
+
424
+ export function createDefaultSemanticReceiptIndex() {
425
+ return {
426
+ schemaVersion: workspaceIntelligenceSchemaVersion,
427
+ product: "Meta-Architect",
428
+ purpose:
429
+ "Semantic receipt registry for explaining capability outputs, provenance, unlocks, and non-unlocks.",
430
+ receipt_schema: {
431
+ semantic_role: "string",
432
+ source: "string",
433
+ claim: "string",
434
+ provenance: ["path_or_url"],
435
+ writes: ["path_or_artifact"],
436
+ unlocks: ["capability_or_gate"],
437
+ does_not_unlock: ["capability_or_gate"],
438
+ authority: "string",
439
+ created_at: "iso_timestamp",
440
+ },
441
+ receipts: [],
442
+ };
443
+ }
444
+
445
+ function validateBaseDocument(value, label) {
446
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
447
+ throw new Error(`${label} must be an object`);
448
+ }
449
+ if (value.schemaVersion !== workspaceIntelligenceSchemaVersion) {
450
+ throw new Error(`Unsupported ${label} schemaVersion: ${value.schemaVersion}`);
451
+ }
452
+ if (JSON.stringify(value).includes(".omx")) {
453
+ throw new Error(`${label} must not expose OMX runtime paths`);
454
+ }
455
+ return value;
456
+ }
457
+
458
+ export function validateCapabilityComposition(value) {
459
+ validateBaseDocument(value, "capability composition");
460
+ if (!Array.isArray(value.capability_matrix) || value.capability_matrix.length === 0) {
461
+ throw new Error("capability composition requires non-empty capability_matrix");
462
+ }
463
+ for (const entry of value.capability_matrix) {
464
+ if (
465
+ typeof entry.capability !== "string" ||
466
+ typeof entry.semantic_role !== "string" ||
467
+ !Array.isArray(entry.reads) ||
468
+ !Array.isArray(entry.writes) ||
469
+ !Array.isArray(entry.cannot_mutate) ||
470
+ !Array.isArray(entry.applies_to)
471
+ ) {
472
+ throw new Error(
473
+ "capability composition entries require capability, semantic_role, reads, writes, cannot_mutate, applies_to",
474
+ );
475
+ }
476
+ }
477
+ const obsidian = value.capability_matrix.find(
478
+ (entry) => entry.capability === "obsidian_integration_core",
479
+ );
480
+ if (obsidian?.records_as !== "vault_context" || obsidian?.never_records_as !== "build_evidence") {
481
+ throw new Error("Obsidian capability must record as vault_context, not build_evidence");
482
+ }
483
+ const helper = value.capability_matrix.find(
484
+ (entry) => entry.capability === "helper_orchestration_core",
485
+ );
486
+ if (helper?.records_as !== "helper_receipt" || helper?.never_records_as !== "gate_approval") {
487
+ throw new Error("Helper orchestration must record helper receipts, not gate approvals");
488
+ }
489
+ const environment = value.capability_matrix.find(
490
+ (entry) => entry.capability === "environment_awareness_core",
491
+ );
492
+ if (
493
+ environment?.records_as !== "available_capability" ||
494
+ environment?.never_records_as !== "build_evidence"
495
+ ) {
496
+ throw new Error("Environment awareness must record available capabilities, not build evidence");
497
+ }
498
+ const broker = value.capability_matrix.find(
499
+ (entry) => entry.capability === "universal_plugin_broker_core",
500
+ );
501
+ if (
502
+ broker?.records_as !== "plugin_compatibility_configuration" ||
503
+ broker?.never_records_as !== "build_evidence"
504
+ ) {
505
+ throw new Error("Universal plugin broker must record compatibility config, not build evidence");
506
+ }
507
+ return value;
508
+ }
509
+
510
+ export function validateWorkspaceContextPack(value) {
511
+ validateBaseDocument(value, "workspace context pack");
512
+ if (!value.semantic_channels || typeof value.semantic_channels !== "object") {
513
+ throw new Error("workspace context pack requires semantic_channels");
514
+ }
515
+ if (
516
+ value.semantic_channels.brain_context?.sources?.includes("obsidian_integration_core") !== true
517
+ ) {
518
+ throw new Error("workspace context pack must include Obsidian as brain_context");
519
+ }
520
+ if (
521
+ value.semantic_channels.helper_support?.sources?.includes("helper_orchestration_core") !== true
522
+ ) {
523
+ throw new Error("workspace context pack must include helper orchestration as helper_support");
524
+ }
525
+ if (
526
+ value.semantic_channels.available_capabilities?.sources?.includes(
527
+ "environment_awareness_core",
528
+ ) !== true
529
+ ) {
530
+ throw new Error("workspace context pack must include environment awareness");
531
+ }
532
+ if (
533
+ value.semantic_channels.plugin_compatibility?.sources?.includes(
534
+ "universal_plugin_broker_core",
535
+ ) !== true
536
+ ) {
537
+ throw new Error("workspace context pack must include universal plugin broker");
538
+ }
539
+ if (
540
+ !Array.isArray(value.required_workspace_facts) ||
541
+ value.required_workspace_facts.length === 0
542
+ ) {
543
+ throw new Error("workspace context pack requires required_workspace_facts");
544
+ }
545
+ return value;
546
+ }
547
+
548
+ export function validateWorkspaceEffectiveness(value) {
549
+ validateBaseDocument(value, "workspace effectiveness");
550
+ if (!Array.isArray(value.checks) || value.checks.length === 0) {
551
+ throw new Error("workspace effectiveness requires checks");
552
+ }
553
+ if (!value.checks.some((check) => check.id === "brain_context_bound")) {
554
+ throw new Error("workspace effectiveness must check brain context binding");
555
+ }
556
+ if (!value.checks.some((check) => check.id === "helper_support_bound")) {
557
+ throw new Error("workspace effectiveness must check helper support binding");
558
+ }
559
+ if (!value.checks.some((check) => check.id === "environment_awareness_bound")) {
560
+ throw new Error("workspace effectiveness must check environment awareness binding");
561
+ }
562
+ if (!value.checks.some((check) => check.id === "universal_plugin_broker_bound")) {
563
+ throw new Error("workspace effectiveness must check universal plugin broker binding");
564
+ }
565
+ return value;
566
+ }
567
+
568
+ export function validateSemanticReceiptIndex(value) {
569
+ validateBaseDocument(value, "semantic receipt index");
570
+ if (!value.receipt_schema || typeof value.receipt_schema !== "object") {
571
+ throw new Error("semantic receipt index requires receipt_schema");
572
+ }
573
+ if (!Array.isArray(value.receipts)) {
574
+ throw new Error("semantic receipt index requires receipts array");
575
+ }
576
+ return value;
577
+ }
578
+
579
+ export function createSemanticReceipt({
580
+ semanticRole,
581
+ source,
582
+ claim,
583
+ provenance = [],
584
+ writes = [],
585
+ unlocks = [],
586
+ doesNotUnlock = [],
587
+ authority = "$maestro_or_owning_lane",
588
+ }) {
589
+ if (!semanticRole || !source || !claim) {
590
+ throw new Error("Semantic receipt requires semanticRole, source, and claim");
591
+ }
592
+
593
+ return {
594
+ semantic_role: semanticRole,
595
+ source,
596
+ claim,
597
+ provenance: provenance.filter((entry) => typeof entry === "string" && entry.trim()),
598
+ writes: writes.filter((entry) => typeof entry === "string" && entry.trim()),
599
+ unlocks: unlocks.filter((entry) => typeof entry === "string" && entry.trim()),
600
+ does_not_unlock: doesNotUnlock.filter((entry) => typeof entry === "string" && entry.trim()),
601
+ authority,
602
+ created_at: new Date().toISOString(),
603
+ };
604
+ }
605
+
606
+ export function addSemanticReceipt(index, receipt) {
607
+ const next = validateSemanticReceiptIndex({
608
+ ...index,
609
+ receipts: [...index.receipts, receipt],
610
+ });
611
+ return next;
612
+ }
613
+
614
+ export function evaluateWorkspaceEffectiveness(value) {
615
+ const document = validateWorkspaceEffectiveness(value);
616
+ const blockingChecks = document.checks.filter(
617
+ (check) => !["passed", "waived"].includes(check.status),
618
+ );
619
+
620
+ return {
621
+ record_type: "workspace_effectiveness_evaluation",
622
+ ready: blockingChecks.length === 0,
623
+ total: document.checks.length,
624
+ passed: document.checks.filter((check) => check.status === "passed").length,
625
+ waived: document.checks.filter((check) => check.status === "waived").length,
626
+ blocking: blockingChecks.map((check) => check.id),
627
+ };
628
+ }
629
+
630
+ export async function seedWorkspaceIntelligenceArtifacts() {
631
+ await Promise.all([
632
+ ensureDir(getRuntimeSubsystemPath("context")),
633
+ ensureDir(getRuntimeReadPath("evidence")),
634
+ ]);
635
+ await Promise.all([
636
+ writeFileIfMissing(
637
+ getCapabilityCompositionPath(),
638
+ `${JSON.stringify(createDefaultCapabilityComposition(), null, 2)}\n`,
639
+ ),
640
+ writeFileIfMissing(
641
+ getWorkspaceContextPackPath(),
642
+ `${JSON.stringify(createDefaultWorkspaceContextPack(), null, 2)}\n`,
643
+ ),
644
+ writeFileIfMissing(
645
+ getWorkspaceEffectivenessPath(),
646
+ `${JSON.stringify(createDefaultWorkspaceEffectiveness(), null, 2)}\n`,
647
+ ),
648
+ writeFileIfMissing(
649
+ getSemanticReceiptIndexPath(),
650
+ `${JSON.stringify(createDefaultSemanticReceiptIndex(), null, 2)}\n`,
651
+ ),
652
+ ]);
653
+ }
654
+
655
+ export async function loadWorkspaceIntelligenceArtifacts() {
656
+ const [
657
+ capabilityComposition,
658
+ workspaceContextPack,
659
+ workspaceEffectiveness,
660
+ semanticReceiptIndex,
661
+ ] = await Promise.all([
662
+ readJson(getCapabilityCompositionPath()).then(validateCapabilityComposition),
663
+ readJson(getWorkspaceContextPackPath()).then(validateWorkspaceContextPack),
664
+ readJson(getWorkspaceEffectivenessPath()).then(validateWorkspaceEffectiveness),
665
+ readJson(getSemanticReceiptIndexPath()).then(validateSemanticReceiptIndex),
666
+ ]);
667
+
668
+ return {
669
+ capabilityComposition,
670
+ workspaceContextPack,
671
+ workspaceEffectiveness,
672
+ semanticReceiptIndex,
673
+ };
674
+ }