@jstn-sdk/ma 0.1.12 → 0.14.0

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 (198) hide show
  1. package/.codex/agents/Architect.toml +1 -2
  2. package/.codex/agents/Auditor.toml +1 -2
  3. package/.codex/agents/Builder.toml +1 -2
  4. package/.codex/agents/Flow.toml +1 -2
  5. package/.codex/agents/Sage.toml +1 -2
  6. package/.codex/agents/Vibe.toml +1 -2
  7. package/.codex/hooks.json +24 -13
  8. package/.codex/prompts/enforcement.md +4 -0
  9. package/.codex/prompts/onboarding.md +6 -1
  10. package/.codex/prompts/release-rules.md +0 -0
  11. package/.codex/prompts/skill-contract.md +4 -0
  12. package/COVERAGE.md +211 -0
  13. package/DEMO.md +274 -0
  14. package/LICENSE +0 -0
  15. package/README.md +132 -656
  16. package/bin/ma.js +748 -55
  17. package/data/clone-data.ledger.json +41 -0
  18. package/data/clone-data.proof.json +50 -0
  19. package/data/clone-data.rvf +37 -0
  20. package/docs/README.md +10 -1
  21. package/docs/autonomous-tasks.md +46 -0
  22. package/docs/codex-integration.md +16 -0
  23. package/docs/getting-started.md +62 -22
  24. package/docs/mcp-setup.md +64 -0
  25. package/docs/qa/release-issue-gates-0.14.0.json +644 -0
  26. package/docs/qa/release-readiness-0.1.5.md +1 -1
  27. package/docs/qa/{release-readiness-0.1.12.md → release-readiness-0.14.0.md} +25 -9
  28. package/docs/quality.md +24 -0
  29. package/docs/reference/native-security-playbooks.md +6 -0
  30. package/docs/reference/native-source-selection.md +6 -0
  31. package/docs/release-spec.md +39 -10
  32. package/docs/skills.md +14 -1
  33. package/index.js +295 -2
  34. package/mcp/collections.json +23 -6
  35. package/mcp/fallback.json +0 -0
  36. package/mcp/local/code-intel.js +179 -41
  37. package/mcp/local/context.js +180 -0
  38. package/mcp/local/memory.js +17 -6
  39. package/mcp/local/quality.js +39 -0
  40. package/mcp/local/state.js +7 -3
  41. package/mcp/local/team-run.js +56 -4
  42. package/mcp/local-capabilities.json +9 -0
  43. package/mcp/servers.json +24 -0
  44. package/package.json +29 -4
  45. package/plugins/meta-architect/.app.json +1 -1
  46. package/plugins/meta-architect/.codex-plugin/plugin.json +1 -1
  47. package/plugins/meta-architect/.mcp.json +1 -1
  48. package/plugins/meta-architect/README.md +8 -1
  49. package/plugins/meta-architect/obsidian/main.js +534 -0
  50. package/plugins/meta-architect/obsidian/manifest.json +9 -0
  51. package/plugins/meta-architect/obsidian/styles.css +7 -0
  52. package/plugins/meta-architect/skills/arch/SKILL.md +2 -0
  53. package/plugins/meta-architect/skills/build/SKILL.md +3 -0
  54. package/plugins/meta-architect/skills/flow/SKILL.md +2 -0
  55. package/plugins/meta-architect/skills/sage/SKILL.md +2 -0
  56. package/plugins/meta-architect/skills/sage/references/source-selection.md +8 -0
  57. package/plugins/meta-architect/skills/vet/SKILL.md +2 -0
  58. package/plugins/meta-architect/skills/vet/references/security-playbooks.md +7 -0
  59. package/plugins/meta-architect/skills/vibe/SKILL.md +2 -0
  60. package/schemas/autonomous-task-queue.schema.json +56 -0
  61. package/schemas/handoff-packet.schema.json +36 -0
  62. package/schemas/setup-receipt.schema.json +28 -0
  63. package/schemas/skill-frontmatter.schema.json +20 -0
  64. package/schemas/support-bundle.schema.json +37 -0
  65. package/schemas/task-contract.schema.json +31 -0
  66. package/scripts/active-autonomy-hook.mjs +226 -0
  67. package/scripts/build-linux-packages.mjs +7 -3
  68. package/scripts/cleanup-test-fixtures.sh +55 -0
  69. package/scripts/context-hydration-hook.mjs +89 -0
  70. package/scripts/demo-smoke.js +285 -0
  71. package/scripts/doctor.js +27 -12
  72. package/scripts/install.sh +57 -0
  73. package/scripts/install.sh.sha256 +1 -0
  74. package/scripts/linux-package-smoke.mjs +2 -2
  75. package/scripts/package-size-check.mjs +26 -0
  76. package/scripts/plugin-sync.js +83 -17
  77. package/scripts/postinstall.js +17 -10
  78. package/scripts/prepack.js +9 -0
  79. package/scripts/ralph/prompt.md +35 -0
  80. package/scripts/release-sync.js +72 -7
  81. package/scripts/release-verify.js +260 -2
  82. package/scripts/setup-npmrc.js +48 -23
  83. package/scripts/skills-install.js +9 -2
  84. package/scripts/skills-manifest.js +2 -21
  85. package/scripts/skills-pack.js +2 -2
  86. package/scripts/skills-validate.js +5 -55
  87. package/skills/arch/SKILL.md +2 -0
  88. package/skills/build/SKILL.md +3 -0
  89. package/skills/flow/SKILL.md +2 -0
  90. package/skills/index.json +0 -0
  91. package/skills/sage/SKILL.md +2 -0
  92. package/skills/sage/references/source-selection.md +8 -0
  93. package/skills/vet/SKILL.md +2 -0
  94. package/skills/vet/references/security-playbooks.md +7 -0
  95. package/skills/vibe/SKILL.md +2 -0
  96. package/sprint/00-idea.md +0 -0
  97. package/sprint/01-architecture.md +0 -0
  98. package/sprint/02-oss-evidence.md +0 -0
  99. package/sprint/03-logic.md +0 -0
  100. package/sprint/04-security.md +0 -0
  101. package/sprint/05-dx-ux.md +0 -0
  102. package/sprint/06-build-plan.md +0 -0
  103. package/sprint/07-release.md +0 -0
  104. package/src/agents.js +279 -0
  105. package/src/bootstrap.js +268 -62
  106. package/src/build-gate.js +2 -2
  107. package/src/codex-app-server.js +291 -0
  108. package/src/decision-log.js +0 -0
  109. package/src/fs-utils.js +175 -4
  110. package/src/launcher.js +28 -21
  111. package/src/mcp-config.js +9 -1
  112. package/src/mcp-live-client.js +422 -3
  113. package/src/paths.js +10 -1
  114. package/src/policy.js +3 -3
  115. package/src/prelaunch.js +189 -0
  116. package/src/quality/ai-quality-orchestrator.js +328 -0
  117. package/src/release-issue-gates.js +252 -0
  118. package/src/release-operations.js +62 -0
  119. package/src/release-state.js +0 -0
  120. package/src/runtime/active-autonomy-core.js +208 -0
  121. package/src/runtime/agent-compat.js +31 -0
  122. package/src/runtime/alignment-sentinel.js +165 -0
  123. package/src/runtime/architect-review.js +326 -0
  124. package/src/runtime/autonomous-tasks.js +408 -0
  125. package/src/runtime/build-readiness.js +28 -4
  126. package/src/runtime/code-graph-rehearse.js +113 -0
  127. package/src/runtime/codeburn-core.js +112 -0
  128. package/src/runtime/context-authority.js +40 -0
  129. package/src/runtime/context-economy-core.js +316 -0
  130. package/src/runtime/continuity-graph.js +201 -0
  131. package/src/runtime/continuity-notes.js +71 -26
  132. package/src/runtime/core-source-ingest.js +379 -0
  133. package/src/runtime/detached-provider.js +142 -0
  134. package/src/runtime/doctor-report.js +18 -0
  135. package/src/runtime/environment-awareness-core.js +460 -0
  136. package/src/runtime/exposure-catalog.js +276 -0
  137. package/src/runtime/graphify-core.js +167 -0
  138. package/src/runtime/guidance-stack.js +9 -2
  139. package/src/runtime/handoff-packets.js +92 -0
  140. package/src/runtime/headroom-core.js +104 -0
  141. package/src/runtime/helper-orchestration-core.js +307 -0
  142. package/src/runtime/hook-profiles.js +20 -0
  143. package/src/runtime/learning-loop-core.js +344 -0
  144. package/src/runtime/live-agent-verification.js +122 -0
  145. package/src/runtime/maestro-events.js +18 -0
  146. package/src/runtime/maestro-manager.js +19 -0
  147. package/src/runtime/maestro-output.js +58 -0
  148. package/src/runtime/maestro-state.js +125 -0
  149. package/src/runtime/managed-markdown.js +29 -0
  150. package/src/runtime/mcp-authority.js +147 -0
  151. package/src/runtime/mcp-policy.js +192 -0
  152. package/src/runtime/obsidian-integration-core.js +1089 -0
  153. package/src/runtime/obsidian-plugin-bridge.js +1045 -0
  154. package/src/runtime/pi-maestro-core.js +89 -0
  155. package/src/runtime/preferences.js +79 -0
  156. package/src/runtime/project-context.js +636 -0
  157. package/src/runtime/prompt-strategy-core.js +230 -0
  158. package/src/runtime/quorum-review.js +90 -0
  159. package/src/runtime/ralph-execution-core.js +217 -0
  160. package/src/runtime/redaction-gateway.js +373 -0
  161. package/src/runtime/runtime-state.js +935 -2
  162. package/src/runtime/schema-migrations.js +162 -0
  163. package/src/runtime/semantic-recording-core.js +147 -0
  164. package/src/runtime/signal-hooks.js +28 -0
  165. package/src/runtime/skills-registry-export.js +754 -0
  166. package/src/runtime/task-contracts.js +83 -0
  167. package/src/runtime/universal-plugin-broker-core.js +898 -0
  168. package/src/runtime/workspace-intelligence-runtime.js +674 -0
  169. package/src/runtime/workspace-virtualizer.js +102 -0
  170. package/src/runtime-artifacts.js +225 -62
  171. package/src/setup-lifecycle.js +359 -0
  172. package/src/skill-frontmatter.js +78 -0
  173. package/src/skill-installer.js +226 -71
  174. package/src/skills.js +1166 -96
  175. package/src/state-sync.js +0 -0
  176. package/src/test-fixtures.js +543 -0
  177. package/src/tui/grid.js +67 -0
  178. package/src/tui/status-grid.js +23 -0
  179. package/support-bundle.json +114 -0
  180. package/templates/AGENTS.md +6 -2
  181. package/templates/catalog-manifest.json +0 -0
  182. package/templates/model-instructions/core.md +0 -0
  183. package/templates/model-instructions/release.md +0 -0
  184. package/templates/model-instructions/security.md +0 -0
  185. package/templates/quality/ai-quality-rules.yml +37 -0
  186. package/docs/assets/image/Screenshot(1).png +0 -0
  187. package/docs/assets/image/Screenshot(2).png +0 -0
  188. package/docs/assets/image/Screenshot(3).png +0 -0
  189. package/docs/assets/image/Screenshot(4).png +0 -0
  190. package/docs/assets/image/Screenshot(5).png +0 -0
  191. package/docs/assets/image/Screenshot(6).png +0 -0
  192. package/docs/assets/image/Screenshot(7).png +0 -0
  193. package/docs/assets/image/Screenshot(8).png +0 -0
  194. package/docs/assets/image/Screenshot(9).png +0 -0
  195. package/docs/assets/meta-architect-logo.png +0 -0
  196. package/docs/assets/meta-architect-logo.svg +0 -8
  197. package/docs/onboarding.md +0 -65
  198. package/docs/skills-publishing.md +0 -255
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "meta-architect",
3
+ "name": "Meta-Architect",
4
+ "version": "0.14.0",
5
+ "minAppVersion": "1.5.0",
6
+ "description": "Connects active Obsidian notes, selections, graph metadata, canvases, attachments, and request queues to Meta-Architect vault context.",
7
+ "author": "JustineDevs",
8
+ "isDesktopOnly": false
9
+ }
@@ -0,0 +1,7 @@
1
+ .ma-status {
2
+ color: var(--text-muted);
3
+ }
4
+
5
+ .ma-context-modal pre {
6
+ white-space: pre-wrap;
7
+ }
@@ -11,9 +11,11 @@ Use this skill inside Codex to turn a product idea into a concrete architecture
11
11
 
12
12
  Produce:
13
13
  - problem framing
14
+ - `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
14
15
  - user and workload assumptions
15
16
  - system architecture and subsystem boundaries
16
17
  - stack recommendation with tradeoffs
18
+ - rejected alternatives with rationale
17
19
  - data model and storage choices
18
20
  - auth, security, and operational concerns
19
21
  - phased delivery plan
@@ -14,11 +14,14 @@ Produce:
14
14
  - blockers that still prevent implementation
15
15
  - the narrowest viable build slice
16
16
  - branch or worktree suggestions when relevant
17
+ - bounded execution state when the build lane is already in progress
17
18
  - test and verification expectations
19
+ - repair path when the bounded slice needs another pass
18
20
  - the exact next implementation step
19
21
 
20
22
  ## Rules
21
23
 
22
24
  - Do not claim readiness if architecture, evidence, logic, security, or DX/UX gaps remain unresolved.
23
25
  - Keep the recommended build slice small, testable, and reversible.
26
+ - Treat `$build` as the sole owner of `.ma/plans/build.md` and `build_status`.
24
27
  - If the user wants code immediately and the path is clear, end with a concrete implementation plan rather than more review prose.
@@ -10,7 +10,9 @@ Use this skill inside Codex to pressure-test how the system behaves, not just ho
10
10
  ## Output
11
11
 
12
12
  Produce:
13
+ - `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
13
14
  - key actors and system states
15
+ - state map and failure flows
14
16
  - main flows and failure flows
15
17
  - invariants and state transitions
16
18
  - race conditions, dead ends, and consistency risks
@@ -11,8 +11,10 @@ Use this skill inside Codex to verify or challenge stack choices with real sourc
11
11
 
12
12
  Produce:
13
13
  - candidate tools, libraries, or services
14
+ - `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
14
15
  - why each option fits or fails the architecture
15
16
  - source-backed evidence from official docs, upstream repos, or approved GitMCP sources
17
+ - evidence grade and exact upstream mapping
16
18
  - recommendation with tradeoffs
17
19
  - unresolved gaps or missing evidence
18
20
  - exact next trigger, usually `$flow`
@@ -23,6 +23,14 @@ Use this reference pack inside `$sage` when the repo needs evidence-backed selec
23
23
  - Claimed capability verified from a primary source
24
24
  - Maturity caveats called out when evidence is weak
25
25
 
26
+ ## Evidence grades
27
+
28
+ - `VERIFIED`: exact upstream mapping plus primary-source confirmation
29
+ - `PARTIAL`: candidate is mapped, but live proof or maturity proof is incomplete
30
+ - `MISSING`: no trustworthy exact upstream mapping yet
31
+
32
+ Always expose the evidence grade and the exact upstream mapping in user-facing `$sage` output.
33
+
26
34
  ## Native posture
27
35
 
28
36
  Meta-Architect ships curated guidance and playbooks. It does not ship a raw mirror of external catalogs. External sources remain evidence inputs, not user-facing skill identities.
@@ -10,11 +10,13 @@ Use this skill inside Codex to review security posture before the build lane. `$
10
10
  ## Output
11
11
 
12
12
  Produce:
13
+ - `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
13
14
  - trust boundaries
14
15
  - authn/authz expectations
15
16
  - sensitive data paths
16
17
  - abuse cases and likely failure modes
17
18
  - concrete mitigations
19
+ - accepted risks
18
20
  - release blockers vs acceptable risks
19
21
  - exact next trigger, usually `$vibe`
20
22
 
@@ -18,6 +18,13 @@ Use this reference pack inside `$vet` for repeatable trust-boundary reviews that
18
18
  - Distinguish blockers from accepted risk.
19
19
  - Route remediation back to the owning lane rather than creating a parallel security workflow.
20
20
 
21
+ ## Adversarial hardening
22
+
23
+ - For higher-risk changes, run a bounded adversarial hardening pass before final approval.
24
+ - Keep the hardening work inside the private scratchpad/runtime layer.
25
+ - Return structured findings, not direct gate mutations.
26
+ - If the hardening pass cannot resolve or clearly classify the risk, keep `$vet` in a non-terminal state instead of over-approving.
27
+
21
28
  ## Product boundary
22
29
 
23
30
  This pack deepens `$vet`; it does not create a new security skill family. Security patterns are packaged as Meta-Architect guidance, not as mirrored external catalogs or branded upstream surfaces.
@@ -10,8 +10,10 @@ Use this skill inside Codex to review whether the system will feel coherent for
10
10
  ## Output
11
11
 
12
12
  Produce:
13
+ - `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
13
14
  - developer workflow risks
14
15
  - user workflow risks
16
+ - operator friction and user friction
15
17
  - complexity hotspots
16
18
  - onboarding or operability friction
17
19
  - simplifications that improve clarity
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meta-architect.dev/schemas/autonomous-task-queue.schema.json",
4
+ "title": "Meta-Architect Autonomous Task Queue",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "record_type", "tasks"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "0.1.0" },
10
+ "record_type": { "const": "autonomous_task_queue" },
11
+ "tasks": {
12
+ "type": "array",
13
+ "items": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": [
17
+ "id",
18
+ "goal",
19
+ "priority",
20
+ "dependencies",
21
+ "labels",
22
+ "status",
23
+ "attempts",
24
+ "maxAttempts",
25
+ "contract",
26
+ "createdAt",
27
+ "updatedAt"
28
+ ],
29
+ "properties": {
30
+ "id": { "type": "string", "minLength": 1 },
31
+ "goal": { "type": "string", "minLength": 1 },
32
+ "priority": { "enum": ["low", "normal", "high", "critical"] },
33
+ "dependencies": { "type": "array", "items": { "type": "string" } },
34
+ "labels": { "type": "array", "items": { "type": "string" } },
35
+ "deadline": { "type": ["string", "null"], "format": "date-time" },
36
+ "status": {
37
+ "enum": ["queued", "running", "completed", "failed", "blocked", "cancelled"]
38
+ },
39
+ "attempts": { "type": "integer", "minimum": 0 },
40
+ "maxAttempts": { "type": "integer", "minimum": 1 },
41
+ "vendor": { "type": ["string", "null"] },
42
+ "contract": { "$ref": "task-contract.schema.json" },
43
+ "createdAt": { "type": "string", "format": "date-time" },
44
+ "updatedAt": { "type": "string", "format": "date-time" },
45
+ "startedAt": { "type": ["string", "null"], "format": "date-time" },
46
+ "completedAt": { "type": ["string", "null"], "format": "date-time" },
47
+ "error": { "type": ["string", "null"] },
48
+ "blocker": { "type": ["string", "null"] },
49
+ "evidence": { "type": "array", "items": {} },
50
+ "selectedCapabilities": { "type": "array", "items": { "type": "object" } },
51
+ "invocation": { "type": ["string", "null"] }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meta-architect.dev/schemas/handoff-packet.schema.json",
4
+ "title": "Meta-Architect Handoff Packet",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "record_type",
10
+ "goal",
11
+ "current_state",
12
+ "context_used",
13
+ "decisions",
14
+ "blockers",
15
+ "risks",
16
+ "changed_files",
17
+ "verification",
18
+ "next_action",
19
+ "status"
20
+ ],
21
+ "properties": {
22
+ "schemaVersion": { "const": "0.1.0" },
23
+ "record_type": { "const": "handoff_packet" },
24
+ "goal": { "type": "string", "minLength": 1 },
25
+ "current_state": { "type": "string", "minLength": 1 },
26
+ "context_used": { "type": "array", "items": { "type": "string" } },
27
+ "decisions": { "type": "array", "items": { "type": "string" } },
28
+ "blockers": { "type": "array", "items": { "type": "string" } },
29
+ "risks": { "type": "array", "items": { "type": "string" } },
30
+ "changed_files": { "type": "array", "items": { "type": "string" } },
31
+ "verification": { "type": "array", "items": { "type": "string" } },
32
+ "next_action": { "type": "string", "minLength": 1 },
33
+ "status": { "enum": ["active", "blocked", "verified"] },
34
+ "created_at": { "type": "string", "format": "date-time" }
35
+ }
36
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "required": ["schemaVersion", "record_type", "generatedAt", "managedBy", "artifacts"],
5
+ "properties": {
6
+ "schemaVersion": { "const": "0.1.0" },
7
+ "record_type": { "const": "setup_receipt" },
8
+ "generatedAt": { "type": "string", "format": "date-time" },
9
+ "managedBy": { "const": "@jstn-sdk/ma" },
10
+ "artifacts": {
11
+ "type": "array",
12
+ "items": {
13
+ "type": "object",
14
+ "required": ["path", "kind", "status", "created"],
15
+ "properties": {
16
+ "path": { "type": "string", "minLength": 1 },
17
+ "kind": { "enum": ["file", "directory"] },
18
+ "status": {
19
+ "enum": ["created", "existing", "refreshed", "skipped", "warning", "failed"]
20
+ },
21
+ "created": { "type": "boolean" }
22
+ },
23
+ "additionalProperties": true
24
+ }
25
+ }
26
+ },
27
+ "additionalProperties": true
28
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meta-architect.jstn.site/schemas/skill-frontmatter.schema.json",
4
+ "$comment": "Schema version: 1.0.0",
5
+ "title": "Meta-Architect skill frontmatter",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["name", "description"],
9
+ "properties": {
10
+ "name": {
11
+ "type": "string",
12
+ "pattern": "^[a-z0-9-]+$",
13
+ "minLength": 1
14
+ },
15
+ "description": {
16
+ "type": "string",
17
+ "minLength": 10
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meta-architect.dev/schemas/support-bundle.schema.json",
4
+ "type": "object",
5
+ "required": ["schemaVersion", "bundleVersion", "assets", "compatibility"],
6
+ "properties": {
7
+ "schemaVersion": { "const": "1.0.0" },
8
+ "bundleVersion": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
9
+ "compatibility": {
10
+ "type": "object",
11
+ "required": ["node", "managedBy"],
12
+ "properties": {
13
+ "node": { "type": "string", "minLength": 1 },
14
+ "managedBy": { "const": "@jstn-sdk/ma" }
15
+ },
16
+ "additionalProperties": false
17
+ },
18
+ "assets": {
19
+ "type": "array",
20
+ "minItems": 1,
21
+ "items": {
22
+ "type": "object",
23
+ "required": ["name", "class", "source", "destination", "type", "required"],
24
+ "properties": {
25
+ "name": { "type": "string", "pattern": "^[a-z0-9-]+$" },
26
+ "class": { "enum": ["runtime", "guidance", "plugin", "documentation"] },
27
+ "source": { "type": "string", "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+" },
28
+ "destination": { "type": "string", "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+" },
29
+ "type": { "enum": ["file", "directory"] },
30
+ "required": { "type": "boolean" }
31
+ },
32
+ "additionalProperties": false
33
+ }
34
+ }
35
+ },
36
+ "additionalProperties": false
37
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meta-architect.dev/schemas/task-contract.schema.json",
4
+ "title": "Meta-Architect Task Contract",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "record_type",
10
+ "goal",
11
+ "context_used",
12
+ "assumptions",
13
+ "constraints",
14
+ "risk",
15
+ "verification",
16
+ "stop_condition"
17
+ ],
18
+ "properties": {
19
+ "schemaVersion": { "const": "0.1.0" },
20
+ "record_type": { "const": "task_contract" },
21
+ "goal": { "type": "string", "minLength": 1 },
22
+ "context_used": { "type": "array", "items": { "type": "string" } },
23
+ "assumptions": { "type": "array", "items": { "type": "string" } },
24
+ "constraints": { "type": "array", "items": { "type": "string" } },
25
+ "risk": { "enum": ["low", "medium", "high"] },
26
+ "verification": { "type": "array", "items": { "type": "string" } },
27
+ "stop_condition": { "type": "string", "minLength": 1 },
28
+ "persist": { "type": "boolean" },
29
+ "created_at": { "type": "string", "format": "date-time" }
30
+ }
31
+ }
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs/promises";
4
+ import path from "node:path";
5
+ import {
6
+ createDefaultActiveAutonomyCore,
7
+ detectPassivePermissionHandoff,
8
+ } from "../src/runtime/active-autonomy-core.js";
9
+ import { resolveHookProfile } from "../src/runtime/hook-profiles.js";
10
+ import { maskSensitiveText } from "../src/runtime/redaction-gateway.js";
11
+
12
+ const DEFAULT_RESPONSE =
13
+ "AUTO-CONTINUE: continue the current safe branch, execute the next reversible step, then verify before reporting.";
14
+
15
+ async function readStdinJson() {
16
+ const chunks = [];
17
+ for await (const chunk of process.stdin) {
18
+ chunks.push(chunk);
19
+ }
20
+
21
+ const raw = Buffer.concat(chunks).toString("utf8").trim();
22
+ if (!raw) {
23
+ return {};
24
+ }
25
+
26
+ try {
27
+ return JSON.parse(raw);
28
+ } catch (error) {
29
+ return {
30
+ type: "invalid-hook-payload",
31
+ raw,
32
+ parseError: error instanceof Error ? error.message : String(error),
33
+ };
34
+ }
35
+ }
36
+
37
+ function extractAssistantText(payload) {
38
+ const candidates = [
39
+ payload.last_assistant_message,
40
+ payload["last-assistant-message"],
41
+ payload.message,
42
+ payload.text,
43
+ payload.output,
44
+ ];
45
+
46
+ for (const candidate of candidates) {
47
+ if (typeof candidate === "string" && candidate.trim()) {
48
+ return candidate;
49
+ }
50
+ }
51
+
52
+ if (Array.isArray(payload.messages)) {
53
+ const assistant = [...payload.messages]
54
+ .reverse()
55
+ .find((message) => message?.role === "assistant" && typeof message.content === "string");
56
+ return assistant?.content ?? "";
57
+ }
58
+
59
+ return "";
60
+ }
61
+
62
+ function extractUserText(payload) {
63
+ const candidates = [
64
+ payload.last_user_message,
65
+ payload["last-user-message"],
66
+ payload.user_message,
67
+ payload.prompt,
68
+ ];
69
+
70
+ for (const candidate of candidates) {
71
+ if (typeof candidate === "string" && candidate.trim()) return candidate;
72
+ }
73
+
74
+ if (Array.isArray(payload.messages)) {
75
+ const user = [...payload.messages]
76
+ .reverse()
77
+ .find((message) => message?.role === "user" && typeof message.content === "string");
78
+ return user?.content ?? "";
79
+ }
80
+
81
+ return "";
82
+ }
83
+
84
+ function redactAuditPreview(value) {
85
+ if (typeof value !== "string" || !value) return { value: value ?? "", redactions: [] };
86
+ const redacted = maskSensitiveText(value.slice(0, 200));
87
+ return {
88
+ value: redacted.sanitizedText,
89
+ redactions: redacted.replacements.map(({ placeholder, placeholderBase }) => ({
90
+ placeholder,
91
+ placeholderBase,
92
+ })),
93
+ };
94
+ }
95
+
96
+ async function appendAudit(cwd, entry) {
97
+ const auditDir = path.join(cwd, ".ma", "hooks");
98
+ await fs.mkdir(auditDir, { recursive: true });
99
+ const assistantPreview = redactAuditPreview(entry.assistantPreview);
100
+ const userPreview = redactAuditPreview(entry.userPreview);
101
+ const safeEntry = {
102
+ ...entry,
103
+ ...(entry.assistantPreview !== undefined ? { assistantPreview: assistantPreview.value } : {}),
104
+ ...(entry.userPreview !== undefined ? { userPreview: userPreview.value } : {}),
105
+ previewRedactions: {
106
+ assistant: assistantPreview.redactions,
107
+ user: userPreview.redactions,
108
+ },
109
+ };
110
+ await fs.appendFile(
111
+ path.join(auditDir, "audit.log"),
112
+ `${JSON.stringify({ timestamp: new Date().toISOString(), ...safeEntry })}\n`,
113
+ "utf8",
114
+ );
115
+ }
116
+
117
+ function classifyFinding(file) {
118
+ const value = String(file ?? "").toLowerCase();
119
+ if (/(node_modules|site-packages|vendor)/.test(value)) return "dependency";
120
+ if (/(dist|build|\.next|coverage|cache)/.test(value)) return "generated";
121
+ if (/(compat|legacy|history)/.test(value)) return "compatibility";
122
+ return "source";
123
+ }
124
+
125
+ async function writeBlockingReceipt(cwd, receipt) {
126
+ const receiptDir = path.join(cwd, ".ma", "hooks", "receipts");
127
+ await fs.mkdir(receiptDir, { recursive: true });
128
+ const receiptPath = path.join(receiptDir, `active-autonomy-${Date.now()}.json`);
129
+ await fs.writeFile(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`, "utf8");
130
+ return path.relative(cwd, receiptPath);
131
+ }
132
+
133
+ const payload = await readStdinJson();
134
+ const profile = resolveHookProfile(payload.profile);
135
+ const cwd = path.resolve(
136
+ payload.project_root ||
137
+ payload.cwd ||
138
+ payload.working_directory ||
139
+ process.env.MA_ROOT ||
140
+ process.cwd(),
141
+ );
142
+ const broadScan =
143
+ profile.scanScope === "broad" ||
144
+ payload.broad_scan === true ||
145
+ process.env.MA_HOOK_BROAD_SCAN === "1";
146
+ const ignoredArtifactClasses = [
147
+ "node_modules",
148
+ ".next",
149
+ "dist",
150
+ "build",
151
+ "coverage",
152
+ "cache",
153
+ "venv",
154
+ ".venv",
155
+ "site-packages",
156
+ "vendored bundles",
157
+ ];
158
+ const assistantText = extractAssistantText(payload);
159
+ const userText = extractUserText(payload);
160
+ const blocked =
161
+ profile.block && detectPassivePermissionHandoff(assistantText, createDefaultActiveAutonomyCore());
162
+
163
+ const result = blocked
164
+ ? {
165
+ decision: "block",
166
+ reason: DEFAULT_RESPONSE,
167
+ stopReason: "active_autonomy_passive_handoff",
168
+ systemMessage:
169
+ "Meta-Architect Active Autonomy blocked passive permission-handoff wording on an AUTO-CONTINUE branch.",
170
+ }
171
+ : {
172
+ decision: "approve",
173
+ reason: "active_autonomy_no_passive_handoff_detected",
174
+ };
175
+
176
+ const matchedFiles = Array.isArray(payload.files) ? payload.files : [];
177
+ const receiptPath = blocked
178
+ ? await writeBlockingReceipt(cwd, {
179
+ schemaVersion: "0.1.0",
180
+ record_type: "hook_receipt",
181
+ hook: "active-autonomy",
182
+ ruleId: "active_autonomy_passive_handoff",
183
+ scanRoot: cwd,
184
+ include: broadScan ? ["all"] : ["active-project"],
185
+ exclude: broadScan ? [] : ignoredArtifactClasses,
186
+ matchedFiles: matchedFiles.map((file) => ({
187
+ path: String(file.path ?? file),
188
+ line: Number.isInteger(file.line) ? file.line : null,
189
+ classification: classifyFinding(file.path ?? file),
190
+ })),
191
+ classification: matchedFiles.some((file) => classifyFinding(file.path ?? file) === "source")
192
+ ? "source"
193
+ : "false_positive_candidate",
194
+ blocked: true,
195
+ reason: result.reason,
196
+ recommendedAction: "Rewrite the response to continue the safe branch and verify it.",
197
+ suppressionPolicy: "No suppression without an explicit rationale.",
198
+ createdAt: new Date().toISOString(),
199
+ profile: profile.id,
200
+ })
201
+ : null;
202
+
203
+ if (!profile.readOnly)
204
+ await appendAudit(cwd, {
205
+ hook: "active-autonomy",
206
+ scanRoot: cwd,
207
+ scope: broadScan ? "broad-opt-in" : "active-project",
208
+ ignoredArtifactClasses: broadScan ? [] : ignoredArtifactClasses,
209
+ event: payload.type || payload.event || "unknown",
210
+ decision: result.decision,
211
+ stopReason: result.stopReason,
212
+ assistantPreview: assistantText,
213
+ userPreview: userText,
214
+ });
215
+
216
+ process.stdout.write(
217
+ `${JSON.stringify({
218
+ ...result,
219
+ scanRoot: cwd,
220
+ scope: broadScan ? "broad-opt-in" : "active-project",
221
+ ignoredArtifactClasses: broadScan ? [] : ignoredArtifactClasses,
222
+ profile: profile.id,
223
+ readOnly: profile.readOnly,
224
+ ...(receiptPath ? { receiptPath } : {}),
225
+ })}\n`,
226
+ );
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { spawnSync } from "node:child_process";
4
4
  import fsp from "node:fs/promises";
5
- import os from "node:os";
6
5
  import path from "node:path";
7
6
  import process from "node:process";
7
+ import { createTestNamespace } from "../src/test-fixtures.js";
8
8
  import {
9
9
  getDebArtifactPath,
10
10
  getLinuxPackageManifestPath,
@@ -87,6 +87,10 @@ async function createCommonRoot(root, packArtifactPath) {
87
87
  run("tar", ["-xzf", packArtifactPath, "-C", libRoot, "--strip-components=1", "package"], {
88
88
  cwd: repoRoot,
89
89
  });
90
+ const agentCompatSource = path.join(repoRoot, "node_modules", "@jstn-sdk", "agents");
91
+ const agentCompatTarget = path.join(libRoot, "node_modules", "@jstn-sdk", "agents");
92
+ await fsp.access(agentCompatSource);
93
+ await copyDir(agentCompatSource, agentCompatTarget);
90
94
 
91
95
  const wrapper = `#!/bin/sh
92
96
  PREFIX="\${META_ARCHITECT_PREFIX:-}"
@@ -267,6 +271,7 @@ async function main() {
267
271
 
268
272
  await fsp.mkdir(distRoot, { recursive: true });
269
273
  const packArtifactPath = getPackArtifactPath(distRoot, packageName, version);
274
+ const workRoot = createTestNamespace("meta-architect-linux-packages");
270
275
  await fsp.rm(packArtifactPath, { force: true });
271
276
  run(
272
277
  "npm",
@@ -275,14 +280,13 @@ async function main() {
275
280
  ".",
276
281
  "--ignore-scripts",
277
282
  "--cache",
278
- path.join(distRoot, ".npm-cache"),
283
+ path.join(workRoot, "npm-cache"),
279
284
  "--pack-destination",
280
285
  distRoot,
281
286
  ],
282
287
  { cwd: repoRoot },
283
288
  );
284
289
 
285
- const workRoot = await fsp.mkdtemp(path.join(os.tmpdir(), "meta-architect-linux-packages-"));
286
290
  const commonRoot = path.join(workRoot, "root");
287
291
  await createCommonRoot(commonRoot, packArtifactPath);
288
292
 
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REQUESTED_TMP_DIR="${MA_TEST_ROOT:-/tmp/ma-tests}"
5
+ MAX_SIZE_BYTES=$((2 * 1024 * 1024 * 1024))
6
+
7
+ case "$REQUESTED_TMP_DIR" in
8
+ /tmp/ma-tests|/tmp/ma-tests/*) ;;
9
+ *) echo "Refusing to clean unexpected path: $REQUESTED_TMP_DIR" >&2; exit 2 ;;
10
+ esac
11
+
12
+ TMP_DIR=$(node -e 'const path = require("node:path"); process.stdout.write(path.resolve(process.argv[1]));' "$REQUESTED_TMP_DIR")
13
+ case "$TMP_DIR" in
14
+ /tmp/ma-tests|/tmp/ma-tests/*) ;;
15
+ *) echo "Refusing to clean resolved path: $TMP_DIR" >&2; exit 2 ;;
16
+ esac
17
+
18
+ if [ ! -d "$TMP_DIR" ]; then
19
+ echo "Test fixture root does not exist: $TMP_DIR"
20
+ exit 0
21
+ fi
22
+
23
+ find "$TMP_DIR" -type f \( -name '*.tar.zst' -o -name '*.tar.gz' \) -mtime +7 -delete
24
+ find "$TMP_DIR" -type f -name '*.log' -mtime +3 -delete
25
+ namespace_is_active() {
26
+ local namespace="$1"
27
+ local pid
28
+ if [ ! -f "$namespace/.active" ]; then return 1; fi
29
+ pid=$(cat "$namespace/.active" 2>/dev/null || true)
30
+ [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null
31
+ }
32
+
33
+ prune_namespaces_older_than() {
34
+ local age_minutes="$1"
35
+ local namespace
36
+ shopt -s nullglob
37
+ for namespace in "$TMP_DIR"/*; do
38
+ [ -d "$namespace" ] || continue
39
+ [ "$(basename "$namespace")" = retained ] && continue
40
+ namespace_is_active "$namespace" && continue
41
+ find "$namespace" -maxdepth 0 -type d -mmin +"$age_minutes" -exec rm -rf -- {} +
42
+ done
43
+ }
44
+
45
+ # Retained archives have their own seven-day policy and are not namespaces.
46
+ prune_namespaces_older_than 1440
47
+
48
+ CURRENT_KIB=$(du -sk "$TMP_DIR" 2>/dev/null | cut -f1 || echo 0)
49
+ CURRENT_BYTES=$((CURRENT_KIB * 1024))
50
+ echo "Current $TMP_DIR usage: $CURRENT_BYTES bytes"
51
+
52
+ if [ "$CURRENT_BYTES" -gt "$MAX_SIZE_BYTES" ]; then
53
+ echo "::warning::$TMP_DIR exceeded 2GB; removing expired namespaces"
54
+ prune_namespaces_older_than 60
55
+ fi