martin-loop 0.1.5 → 1.3.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 (274) hide show
  1. package/CODE_OF_CONDUCT.md +32 -0
  2. package/LICENSE +21 -21
  3. package/README.md +307 -398
  4. package/demo/seeded-workspace/README.md +35 -35
  5. package/demo/seeded-workspace/TASKS.md +29 -29
  6. package/demo/seeded-workspace/martin.config.yaml +11 -11
  7. package/demo/seeded-workspace/package.json +8 -8
  8. package/demo/seeded-workspace/src/invoice-summary.js +11 -11
  9. package/demo/seeded-workspace/test/invoice-summary.test.js +20 -20
  10. package/dist/bin/martin-loop.js +0 -0
  11. package/dist/vendor/adapters/counter.d.ts +1 -0
  12. package/dist/vendor/adapters/counter.js +4 -0
  13. package/dist/vendor/adapters/git-baseline.d.ts +50 -0
  14. package/dist/vendor/adapters/git-baseline.js +233 -0
  15. package/dist/vendor/adapters/openrouter-adapter.d.ts +15 -0
  16. package/dist/vendor/adapters/openrouter-adapter.js +302 -0
  17. package/dist/vendor/adapters/usage.d.ts +48 -0
  18. package/dist/vendor/adapters/usage.js +66 -0
  19. package/dist/vendor/cli/bin/exit.d.ts +12 -0
  20. package/dist/vendor/cli/bin/exit.js +28 -0
  21. package/dist/vendor/cli/commands/analyze.d.ts +5 -0
  22. package/dist/vendor/cli/commands/analyze.js +58 -0
  23. package/dist/vendor/cli/commands/audit-log-verify.d.ts +34 -0
  24. package/dist/vendor/cli/commands/audit-log-verify.js +99 -0
  25. package/dist/vendor/cli/commands/audit.d.ts +8 -0
  26. package/dist/vendor/cli/commands/audit.js +199 -0
  27. package/dist/vendor/cli/commands/corpus.d.ts +5 -0
  28. package/dist/vendor/cli/commands/corpus.js +60 -0
  29. package/dist/vendor/cli/commands/doctor.d.ts +8 -0
  30. package/dist/vendor/cli/commands/doctor.js +219 -0
  31. package/dist/vendor/cli/commands/explain.d.ts +17 -0
  32. package/dist/vendor/cli/commands/explain.js +176 -0
  33. package/dist/vendor/cli/commands/export.d.ts +5 -0
  34. package/dist/vendor/cli/commands/export.js +60 -0
  35. package/dist/vendor/cli/commands/governance.d.ts +8 -0
  36. package/dist/vendor/cli/commands/governance.js +95 -0
  37. package/dist/vendor/cli/commands/improve.d.ts +18 -0
  38. package/dist/vendor/cli/commands/improve.js +396 -0
  39. package/dist/vendor/cli/commands/init.d.ts +8 -0
  40. package/dist/vendor/cli/commands/init.js +281 -0
  41. package/dist/vendor/cli/commands/migration.d.ts +8 -0
  42. package/dist/vendor/cli/commands/migration.js +67 -0
  43. package/dist/vendor/cli/commands/prior.d.ts +23 -0
  44. package/dist/vendor/cli/commands/prior.js +145 -0
  45. package/dist/vendor/cli/commands/resume.d.ts +21 -0
  46. package/dist/vendor/cli/commands/resume.js +73 -0
  47. package/dist/vendor/cli/commands/verify.d.ts +6 -0
  48. package/dist/vendor/cli/commands/verify.js +43 -0
  49. package/dist/vendor/cli/research/public-corpus.d.ts +43 -0
  50. package/dist/vendor/cli/research/public-corpus.js +151 -0
  51. package/dist/vendor/cli/ui/error-card.d.ts +38 -0
  52. package/dist/vendor/cli/ui/error-card.js +103 -0
  53. package/dist/vendor/cli/ui/mission-brief.d.ts +41 -0
  54. package/dist/vendor/cli/ui/mission-brief.js +173 -0
  55. package/dist/vendor/cli/ui/summary-card.d.ts +34 -0
  56. package/dist/vendor/cli/ui/summary-card.js +102 -0
  57. package/dist/vendor/contracts/audit.d.ts +46 -0
  58. package/dist/vendor/contracts/audit.js +360 -0
  59. package/dist/vendor/contracts/post-phase15.d.ts +240 -0
  60. package/dist/vendor/contracts/post-phase15.js +166 -0
  61. package/dist/vendor/core/agent/mandates.d.ts +46 -0
  62. package/dist/vendor/core/agent/mandates.js +178 -0
  63. package/dist/vendor/core/agent/receipts.d.ts +38 -0
  64. package/dist/vendor/core/agent/receipts.js +131 -0
  65. package/dist/vendor/core/agent/signing.d.ts +17 -0
  66. package/dist/vendor/core/agent/signing.js +91 -0
  67. package/dist/vendor/core/attestation/sign.d.ts +25 -0
  68. package/dist/vendor/core/attestation/sign.js +216 -0
  69. package/dist/vendor/core/autonomy/autonomous-promotion.d.ts +120 -0
  70. package/dist/vendor/core/autonomy/autonomous-promotion.js +346 -0
  71. package/dist/vendor/core/autonomy/envelope-v2.d.ts +29 -0
  72. package/dist/vendor/core/autonomy/envelope-v2.js +60 -0
  73. package/dist/vendor/core/autonomy/envelope.d.ts +17 -0
  74. package/dist/vendor/core/autonomy/envelope.js +27 -0
  75. package/dist/vendor/core/autonomy/escalation-ledger.d.ts +20 -0
  76. package/dist/vendor/core/autonomy/escalation-ledger.js +18 -0
  77. package/dist/vendor/core/autonomy/resume.d.ts +15 -0
  78. package/dist/vendor/core/autonomy/resume.js +23 -0
  79. package/dist/vendor/core/circuit/circuit-breaker.d.ts +60 -0
  80. package/dist/vendor/core/circuit/circuit-breaker.js +143 -0
  81. package/dist/vendor/core/context-distillation.d.ts +3 -0
  82. package/dist/vendor/core/context-distillation.js +44 -0
  83. package/dist/vendor/core/context-flow/compile-context.d.ts +8 -0
  84. package/dist/vendor/core/context-flow/compile-context.js +111 -0
  85. package/dist/vendor/core/context-flow/entities.d.ts +2 -0
  86. package/dist/vendor/core/context-flow/entities.js +44 -0
  87. package/dist/vendor/core/context-flow/evaluate-policy.d.ts +2 -0
  88. package/dist/vendor/core/context-flow/evaluate-policy.js +42 -0
  89. package/dist/vendor/core/context-flow/index.d.ts +11 -0
  90. package/dist/vendor/core/context-flow/index.js +24 -0
  91. package/dist/vendor/core/context-flow/labels.d.ts +3 -0
  92. package/dist/vendor/core/context-flow/labels.js +17 -0
  93. package/dist/vendor/core/context-flow/normalizer.d.ts +9 -0
  94. package/dist/vendor/core/context-flow/normalizer.js +69 -0
  95. package/dist/vendor/core/context-flow/profiles.d.ts +33 -0
  96. package/dist/vendor/core/context-flow/profiles.js +36 -0
  97. package/dist/vendor/core/context-flow/redaction.d.ts +1 -0
  98. package/dist/vendor/core/context-flow/redaction.js +6 -0
  99. package/dist/vendor/core/context-flow/sensitivity.d.ts +2 -0
  100. package/dist/vendor/core/context-flow/sensitivity.js +27 -0
  101. package/dist/vendor/core/context-flow/sync-preview.d.ts +2 -0
  102. package/dist/vendor/core/context-flow/sync-preview.js +22 -0
  103. package/dist/vendor/core/context-flow/token-estimator.d.ts +3 -0
  104. package/dist/vendor/core/context-flow/token-estimator.js +13 -0
  105. package/dist/vendor/core/context-flow/types.d.ts +91 -0
  106. package/dist/vendor/core/context-flow/types.js +2 -0
  107. package/dist/vendor/core/context-utility.d.ts +47 -0
  108. package/dist/vendor/core/context-utility.js +405 -0
  109. package/dist/vendor/core/cost/pipeline.d.ts +92 -0
  110. package/dist/vendor/core/cost/pipeline.js +141 -0
  111. package/dist/vendor/core/cost/tagged-cost.d.ts +27 -0
  112. package/dist/vendor/core/cost/tagged-cost.js +55 -0
  113. package/dist/vendor/core/cost-governor.d.ts +2 -0
  114. package/dist/vendor/core/cost-governor.js +50 -0
  115. package/dist/vendor/core/cve/cve-check.d.ts +80 -0
  116. package/dist/vendor/core/cve/cve-check.js +172 -0
  117. package/dist/vendor/core/digital-twin/index.d.ts +27 -0
  118. package/dist/vendor/core/digital-twin/index.js +90 -0
  119. package/dist/vendor/core/drift/drift-graph.d.ts +47 -0
  120. package/dist/vendor/core/drift/drift-graph.js +100 -0
  121. package/dist/vendor/core/drift/objective-lock.d.ts +69 -0
  122. package/dist/vendor/core/drift/objective-lock.js +88 -0
  123. package/dist/vendor/core/drift/scope.d.ts +46 -0
  124. package/dist/vendor/core/drift/scope.js +102 -0
  125. package/dist/vendor/core/drift/signature-lock.d.ts +48 -0
  126. package/dist/vendor/core/drift/signature-lock.js +202 -0
  127. package/dist/vendor/core/drift/stale-proof-gate.d.ts +21 -0
  128. package/dist/vendor/core/drift/stale-proof-gate.js +19 -0
  129. package/dist/vendor/core/eval/known-bad-world-runner.d.ts +24 -0
  130. package/dist/vendor/core/eval/known-bad-world-runner.js +256 -0
  131. package/dist/vendor/core/evidence/claim-audit.d.ts +18 -0
  132. package/dist/vendor/core/evidence/claim-audit.js +89 -0
  133. package/dist/vendor/core/exit-intelligence.d.ts +2 -0
  134. package/dist/vendor/core/exit-intelligence.js +58 -0
  135. package/dist/vendor/core/explain/formatter.d.ts +42 -0
  136. package/dist/vendor/core/explain/formatter.js +171 -0
  137. package/dist/vendor/core/explain/timeline.d.ts +29 -0
  138. package/dist/vendor/core/explain/timeline.js +213 -0
  139. package/dist/vendor/core/failure-taxonomy.d.ts +2 -0
  140. package/dist/vendor/core/failure-taxonomy.js +76 -0
  141. package/dist/vendor/core/gateway/index.d.ts +10 -0
  142. package/dist/vendor/core/gateway/index.js +12 -0
  143. package/dist/vendor/core/gateway/registry.d.ts +40 -0
  144. package/dist/vendor/core/gateway/registry.js +97 -0
  145. package/dist/vendor/core/gateway/transport.d.ts +31 -0
  146. package/dist/vendor/core/gateway/transport.js +82 -0
  147. package/dist/vendor/core/gateway/vault.d.ts +19 -0
  148. package/dist/vendor/core/gateway/vault.js +29 -0
  149. package/dist/vendor/core/graph/adapters.d.ts +43 -0
  150. package/dist/vendor/core/graph/adapters.js +91 -0
  151. package/dist/vendor/core/graph/hotspots.d.ts +22 -0
  152. package/dist/vendor/core/graph/hotspots.js +30 -0
  153. package/dist/vendor/core/graph/index.d.ts +1 -0
  154. package/dist/vendor/core/graph/index.js +2 -0
  155. package/dist/vendor/core/honey/honey-tokens.d.ts +32 -0
  156. package/dist/vendor/core/honey/honey-tokens.js +44 -0
  157. package/dist/vendor/core/index.d.ts +2 -2
  158. package/dist/vendor/core/index.js +38 -12
  159. package/dist/vendor/core/learning/bayesian-update.d.ts +31 -0
  160. package/dist/vendor/core/learning/bayesian-update.js +60 -0
  161. package/dist/vendor/core/learning/prior-sets.d.ts +42 -0
  162. package/dist/vendor/core/learning/prior-sets.js +111 -0
  163. package/dist/vendor/core/learning/promotion-gate.d.ts +17 -0
  164. package/dist/vendor/core/learning/promotion-gate.js +23 -0
  165. package/dist/vendor/core/leash/blast-radius.d.ts +42 -0
  166. package/dist/vendor/core/leash/blast-radius.js +156 -0
  167. package/dist/vendor/core/leash/policy-leash.d.ts +31 -0
  168. package/dist/vendor/core/leash/policy-leash.js +117 -0
  169. package/dist/vendor/core/memo/memo.d.ts +63 -0
  170. package/dist/vendor/core/memo/memo.js +97 -0
  171. package/dist/vendor/core/memory/learning-pipeline.d.ts +154 -0
  172. package/dist/vendor/core/memory/learning-pipeline.js +391 -0
  173. package/dist/vendor/core/memory/palace.d.ts +84 -0
  174. package/dist/vendor/core/memory/palace.js +379 -0
  175. package/dist/vendor/core/merge/ast-merge.d.ts +22 -0
  176. package/dist/vendor/core/merge/ast-merge.js +350 -0
  177. package/dist/vendor/core/merge/text-merge.d.ts +12 -0
  178. package/dist/vendor/core/merge/text-merge.js +182 -0
  179. package/dist/vendor/core/otel/tracer.d.ts +45 -0
  180. package/dist/vendor/core/otel/tracer.js +116 -0
  181. package/dist/vendor/core/parallel/parallel-attempts.d.ts +28 -0
  182. package/dist/vendor/core/parallel/parallel-attempts.js +41 -0
  183. package/dist/vendor/core/parallel/scorer.d.ts +24 -0
  184. package/dist/vendor/core/parallel/scorer.js +65 -0
  185. package/dist/vendor/core/pattern-detection.d.ts +64 -0
  186. package/dist/vendor/core/pattern-detection.js +108 -0
  187. package/dist/vendor/core/persistence/checkpoint.d.ts +44 -0
  188. package/dist/vendor/core/persistence/checkpoint.js +156 -0
  189. package/dist/vendor/core/persistence/cleanup.d.ts +22 -0
  190. package/dist/vendor/core/persistence/cleanup.js +131 -0
  191. package/dist/vendor/core/persistence/index.d.ts +2 -0
  192. package/dist/vendor/core/persistence/index.js +1 -0
  193. package/dist/vendor/core/persistence/runs-reader.d.ts +52 -0
  194. package/dist/vendor/core/persistence/runs-reader.js +84 -0
  195. package/dist/vendor/core/persistence/store.d.ts +6 -1
  196. package/dist/vendor/core/persistence/store.js +5 -0
  197. package/dist/vendor/core/policy/file-touch-quota.d.ts +60 -0
  198. package/dist/vendor/core/policy/file-touch-quota.js +105 -0
  199. package/dist/vendor/core/policy/policy-loader.d.ts +30 -0
  200. package/dist/vendor/core/policy/policy-loader.js +170 -0
  201. package/dist/vendor/core/policy/policy-schema.d.ts +55 -0
  202. package/dist/vendor/core/policy/policy-schema.js +78 -0
  203. package/dist/vendor/core/probe/probe.d.ts +49 -0
  204. package/dist/vendor/core/probe/probe.js +115 -0
  205. package/dist/vendor/core/proof/patch-proof.d.ts +58 -0
  206. package/dist/vendor/core/proof/patch-proof.js +84 -0
  207. package/dist/vendor/core/proof/semantic-probe.d.ts +25 -0
  208. package/dist/vendor/core/proof/semantic-probe.js +82 -0
  209. package/dist/vendor/core/recovery/failure-mode-runner.d.ts +29 -0
  210. package/dist/vendor/core/recovery/failure-mode-runner.js +39 -0
  211. package/dist/vendor/core/red-blue/red-phase.d.ts +64 -0
  212. package/dist/vendor/core/red-blue/red-phase.js +141 -0
  213. package/dist/vendor/core/red-blue/risk-tiers.d.ts +22 -0
  214. package/dist/vendor/core/red-blue/risk-tiers.js +33 -0
  215. package/dist/vendor/core/replay/replay.d.ts +85 -0
  216. package/dist/vendor/core/replay/replay.js +109 -0
  217. package/dist/vendor/core/router/engine.d.ts +54 -0
  218. package/dist/vendor/core/router/engine.js +131 -0
  219. package/dist/vendor/core/router/index.d.ts +1 -0
  220. package/dist/vendor/core/router/index.js +2 -0
  221. package/dist/vendor/core/router/trust-calibration.d.ts +57 -0
  222. package/dist/vendor/core/router/trust-calibration.js +127 -0
  223. package/dist/vendor/core/run-martin.d.ts +2 -0
  224. package/dist/vendor/core/run-martin.js +287 -0
  225. package/dist/vendor/core/security/cve-scanner.d.ts +62 -0
  226. package/dist/vendor/core/security/cve-scanner.js +178 -0
  227. package/dist/vendor/core/sentinel/efficiency-sentinel.d.ts +29 -0
  228. package/dist/vendor/core/sentinel/efficiency-sentinel.js +30 -0
  229. package/dist/vendor/core/sentinel/progress-guard.d.ts +35 -0
  230. package/dist/vendor/core/sentinel/progress-guard.js +46 -0
  231. package/dist/vendor/core/siem/siem-emitter.d.ts +49 -0
  232. package/dist/vendor/core/siem/siem-emitter.js +157 -0
  233. package/dist/vendor/core/strategy/attempt-brief.d.ts +22 -0
  234. package/dist/vendor/core/strategy/attempt-brief.js +89 -0
  235. package/dist/vendor/core/summarize/diff-summary.d.ts +35 -0
  236. package/dist/vendor/core/summarize/diff-summary.js +204 -0
  237. package/dist/vendor/core/surface-signals.d.ts +21 -0
  238. package/dist/vendor/core/surface-signals.js +139 -0
  239. package/dist/vendor/core/truth/truth-wall.d.ts +51 -0
  240. package/dist/vendor/core/truth/truth-wall.js +69 -0
  241. package/dist/vendor/core/truth-spine.d.ts +26 -0
  242. package/dist/vendor/core/truth-spine.js +62 -0
  243. package/dist/vendor/core/types.d.ts +115 -0
  244. package/dist/vendor/core/types.js +2 -0
  245. package/dist/vendor/core/verification/tiered-verify.d.ts +17 -0
  246. package/dist/vendor/core/verification/tiered-verify.js +29 -0
  247. package/dist/vendor/core/verifier-pyramid.d.ts +32 -0
  248. package/dist/vendor/core/verifier-pyramid.js +111 -0
  249. package/dist/vendor/core/workflow-artifacts.d.ts +99 -0
  250. package/dist/vendor/core/workflow-artifacts.js +668 -0
  251. package/dist/vendor/core/wrap/supervised-run.d.ts +96 -0
  252. package/dist/vendor/core/wrap/supervised-run.js +178 -0
  253. package/docs/assets/cli-animated.svg +139 -0
  254. package/docs/assets/cli-static.svg +34 -0
  255. package/docs/assets/github-hero-v2.svg +23 -0
  256. package/docs/assets/martin-raplph.png.jpg +0 -0
  257. package/docs/assets/martinloop-logo.png +0 -0
  258. package/docs/assets/nvidia-inception-program-light.png +0 -0
  259. package/docs/assets/nvidia-inception-program.png +0 -0
  260. package/docs/assets/phase3c-sidesidebyside-demo.html +228 -0
  261. package/docs/assets/side-by-side.svg +134 -0
  262. package/docs/oss/CLAUDE-CODE-WALKTHROUGH.md +142 -142
  263. package/docs/oss/EXAMPLES.md +134 -134
  264. package/docs/oss/OSS-BOUNDARY-REPORT.json +1 -1
  265. package/docs/oss/OSS-BOUNDARY-REPORT.md +1 -1
  266. package/docs/oss/QUICKSTART.md +170 -165
  267. package/docs/oss/RALPH-LOOP-SAFETY.md +113 -113
  268. package/docs/oss/README.md +96 -96
  269. package/docs/oss/RELEASE-SURFACE-REPORT.json +2 -1
  270. package/docs/oss/RELEASE-SURFACE-REPORT.md +2 -1
  271. package/package.json +130 -58
  272. package/docs/distribution/DIRECTORY-SUBMISSIONS.md +0 -89
  273. package/docs/distribution/INTEGRATION-OUTREACH.md +0 -61
  274. package/docs/distribution/UNDER-3-CHALLENGE.md +0 -65
package/README.md CHANGED
@@ -1,398 +1,307 @@
1
- <div align="center">
2
-
3
- <img src="./docs/assets/martinloop-logo.png" alt="MartinLoop" width="260">
4
-
5
- ### The cross agent governance layer for autonomous AI coding agents.⭐
6
-
7
- [![License: MIT](https://img.shields.io/badge/license-MIT-7c3aed?style=flat-square)](./LICENSE)
8
- [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6?style=flat-square&logo=typescript&logoColor=white)](./tsconfig.base.json)
9
- [![Node](https://img.shields.io/badge/node-%3E%3D20-3c873a?style=flat-square&logo=nodedotjs&logoColor=white)](#quick-start)
10
- [![npm](https://img.shields.io/badge/npm-martin--loop-cc3534?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/martin-loop)
11
-
12
- MartinLoop has been accepted into the NVIDIA Inception program.
13
-
14
- <br>
15
-
16
- **Your overnight AI pipeline estimated $2.40.**
17
- **You woke up to a $65 bill.**
18
- <br> 47 retries. No hard stop. No rollback. No audit trail. Nothing merged.
19
- MartinLoop exists so that never happens again.✅ <br> <br>
20
- If you think autonomous AI coding agents need budgets, brakes, and receipts, Plase star ⭐ the repo so more builders can find it.
21
- <br>
22
-
23
- > AI coding agents are useful. Unbounded retry loops are not.
24
- >
25
- > MartinLoop wraps agent runs with budgets, policy checks, verifier gates, rollback evidence, and inspectable run records. Built for Enterprise Coding Agents, Agentic Teams, and Autonomous Companies.
26
- <br>
27
- <img src="./docs/assets/cli-animated.svg" alt="MartinLoop CLI — governed agent run" width="720">
28
-
29
- </div>
30
-
31
- ---
32
-
33
- ## The Problem
34
-
35
- A typical autonomous coding loop keeps attempting work until tests pass. Without a governance layer, that loop can keep spending, mutate files outside the intended scope, lose track of why it failed, and leave teams without a clean audit trail.
36
-
37
- Ralph-style loops are powerful but they attempt ➡️ check ➡️ retry ➡️ repeat, with no strong answer to:
38
-
39
- - What changed?
40
- - What did it cost?
41
- - Why was it allowed?
42
- - Why did it stop?
43
- - Can we inspect or resume it later?
44
-
45
- MartinLoop governs the failure mode.
46
-
47
- ---
48
-
49
- ## The Solution
50
-
51
- ✅ Martin Loop wraps AI coding loops with a governance layer.
52
-
53
- It does not try to replace the agent pattern. It makes that pattern safe to run.
54
-
55
- ### What MartinLoop Does Today
56
-
57
- | Capability | Current behavior |
58
- |---|---|
59
- | Budget governance | Enforces `maxUsd`, `softLimitUsd`, `maxIterations`, and `maxTokens`; rejects attempts projected to exceed remaining budget and exits on budget or iteration exhaustion. Hard USD budget caps that stop work before the next attempt breaches policy. |
60
- | Verifier gate | A run only reaches `completed` when the adapter result and verifier state pass. Unsafe verifier commands are blocked before agent execution. |
61
- | Failure taxonomy | Classifies failures across 11 current classes, including hallucination, test regression, scope creep, repo grounding failure, environment mismatch, and budget pressure, that distinguishes real success from unsafe, invalid, or terminal behavior.|
62
- | Safety leash | Evaluates verifier commands, file scope, dependency or migration changes that require approval, and secret-like values in task text. **Policy-as-code**. |
63
- | Context integrity | Scans user prompts and tool output for injection patterns (authority inversion, instruction override, identity redefinition) before any attempt is admitted. Aborts with human escalation on detection. |
64
- | Rollback evidence | Captures rollback boundaries and restore outcomes for repo-backed attempts when a persistence store is configured. |
65
- | Context distillation | Carries a distilled summary of recent attempts and remaining constraints into subsequent attempts. |
66
- | Run records | The CLI appends JSONL loop records under `~/.martin/runs/<workspaceId>.jsonl`; lower-level stores can also persist contracts, ledgers, and attempt artifacts.
67
-
68
-
69
- ⭐The result is a runtime that can complete good work, refuse unsafe work, stop uneconomical work, and leave evidence behind.✅
70
- ---
71
-
72
- ## Ralph-Style Loops Need a Control Layer
73
-
74
- **"Everybody has gotten infatuated with what we call these Ralph Wiggum loops, just like send the thing off and it'll just go figure something out..A, It never figures anything out. And B, you just get this ginormous bill...**" - Chamath Palihapitiya, All-In Podcast #263, March 2026
75
-
76
- The **Ralph Loop** is the failure mode where an AI coding agent keeps trying without knowing when it should stop.
77
-
78
- The pattern is simple: attempt the task, run checks, retry on failure, repeat. The problem is not that the loop exists. The problem is that most implementations have no hard budget cap, no signed evidence layer, and no pre-execution control system. They know how to keep trying. They do **not** know when continuing is unsafe, uneconomical, or impossible.
79
-
80
- Martin Loop solves the Ralph Loop problem by enforcing rules **before** damage happens:
81
-
82
- - it stops the next attempt before budget overspend
83
- - it classifies unsafe or invalid actions before execution
84
- - it appends a structured JSONL audit record for every attempt
85
- - it rolls back failed runs instead of leaving broken state behind
86
- - it reduces runaway token growth with context distillation
87
-
88
- If a Ralph-style loop has ever burned budget without producing a verified result, MartinLoop is designed to stop that failure mode before the next unsafe attempt runs. $165.70 on your dime, you're in the right place. Martin stopped him at $40.97 with a full audit trail.
89
-
90
- <div align="center">
91
- <img src="./docs/assets/martin-raplph.png.jpg" alt="Martin vs Ralph — governed vs ungoverned agent loop" width="240">
92
- </div>
93
-
94
- ### How It Works — Five Layers
95
-
96
- | Layer | What it does |
97
- |---|---|
98
- | **1. Task Contract** | Objective, verifier plan, repo root, allowed/denied paths, acceptance criteria, workspace, project, and budget. |
99
- | **2. Policy & Budget** | Defaults from `martin.config.yaml`; CLI flags override. Budget preflight rejects attempts before execution. |
100
- | **3. Agent Adapters** | Claude CLI, Codex CLI, direct-provider, and stub adapters normalize execution results into the core runtime contract. |
101
- | **4. Safety & Verification** | Verifier commands, file scope, approval-boundary changes, secret-like values, and grounding determine whether work is kept. |
102
- | **5. Persistence** | CLI writes JSONL records under `~/.martin/runs/`. Repo-backed runs can also persist contracts, ledgers, diffs, and rollback artifacts. |
103
-
104
- ---
105
-
106
- ## See It In Action
107
-
108
- Same task, same starting state. MartinLoop completes in one verified attempt at `$2.30`. The uncontrolled loop retries four times, spends `$5.20`, and fails with no audit trail.
109
-
110
- Martin Loop matters because it turns AI coding from an opaque experiment into something that can be governed, replayed, verified, and trusted.
111
-
112
- <div align="center">
113
- <img src="./docs/assets/side-by-side.svg" alt="Martin vs Ralph governed vs ungoverned agent loop side-by-side benchmark comparison" width="720" height="1080">
114
- </div>
115
-
116
-
117
- Reproducible locally:
118
-
119
- ```sh
120
- pnpm --filter @martin/benchmarks test
121
- pnpm --filter @martin/benchmarks eval
122
- pnpm --filter @martin/benchmarks eval:phase12
123
- ```
124
-
125
- Challenge page: [Can your AI coding agent finish this task under $3?](./docs/distribution/UNDER-3-CHALLENGE.md)
126
-
127
- ---
128
-
129
- ## Quick Start
130
-
131
- ```sh
132
- npm install -g martin-loop
133
- ```
134
-
135
- This installs both the `martin-loop` package and the `martin` command alias. The package is currently published on npm as version `0.1.4`.
136
-
137
- Want a safe sandbox first? Run `npx martin-loop demo` and MartinLoop will copy a disposable local workspace into `./martin-loop-demo`.
138
-
139
- ### Public Package Surface
140
-
141
- The frozen public package surface for this release candidate is:
142
-
143
- - Install target: `npm install martin-loop`
144
- - CLI target: `npx martin-loop`
145
- - SDK target: `import { MartinLoop } from "martin-loop"`
146
- - MCP target (registry-ready package): `npx -y @martinloop/mcp`
147
-
148
- The `martin` command alias is installed for local operator convenience, but the public CLI surface is `npx martin-loop`.
149
- The standalone MCP server package is smoke-validated locally with `pnpm --filter @martinloop/mcp smoke:pack` and is ready for registry publication as a separate release step.
150
-
151
- ### Claude Code MCP install
152
-
153
- Use the published MCP package directly:
154
-
155
- - macOS/Linux: `claude mcp add --scope user martin-loop -- npx -y @martinloop/mcp`
156
- - Windows PowerShell/cmd: `claude mcp add --scope user martin-loop -- cmd /c "npx -y @martinloop/mcp"`
157
-
158
- If you just want to launch the server manually, the one-line command is:
159
-
160
- ```sh
161
- npx @martinloop/mcp
162
- ```
163
-
164
- ### Run a governed task
165
-
166
- ```sh
167
- martin run "fix the auth regression" \
168
- --budget 3.00 \
169
- --verify "pnpm test"
170
- ```
171
-
172
- You can also pass the objective explicitly:
173
-
174
- ```sh
175
- martin run --objective "fix the auth regression" --budget 3.00 --verify "pnpm test"
176
- ```
177
-
178
- For a no-spend repo-local dry run, use the stub adapter:
179
-
180
- ```powershell
181
- $env:MARTIN_LIVE='false'
182
- pnpm run:cli -- run --objective "Summarize the current runtime state" --verify "pnpm --filter @martin/core test"
183
- Remove-Item Env:MARTIN_LIVE
184
- ```
185
-
186
- ### Inspect or resume runs
187
-
188
- ```sh
189
- martin inspect --file ~/.martin/runs/<workspaceId>.jsonl
190
- martin resume <loopId>
191
- ```
192
-
193
- `inspect` prints a portfolio summary for records in the file. `resume` looks up a persisted loop record by ID under `~/.martin/runs/`.
194
-
195
- ---
196
-
197
- ## CLI
198
-
199
- ```text
200
- martin run <objective> [options]
201
-
202
- --objective <text> The task to accomplish, or pass it as the first positional arg
203
- --budget <n> Hard cost cap in USD
204
- --budget-usd <n> Alias for --budget
205
- --soft-limit-usd <n> Soft budget threshold in USD
206
- --verify <cmd> Verifier command after each attempt
207
- --max-iterations <n> Maximum number of attempts
208
- --max-tokens <n> Maximum total token budget
209
- --engine <name> Adapter to use: claude (default) or codex
210
- --model <name> Override the adapter model
211
- --cwd <path> Repo root for the run
212
- --allow-path <glob> Restrict agent writes to this path pattern; repeatable
213
- --deny-path <glob> Block this path pattern; repeatable
214
- --accept <criterion> Add an acceptance criterion; repeatable
215
- --config <path> Path to a martin.config.yaml file
216
- --workspace <id> Workspace ID for the run record
217
- --project <id> Project ID for the run record
218
- --metadata <key=value> Attach metadata to the run record; repeatable
219
- ```
220
-
221
- The public CLI also includes `demo`, `inspect`, `resume`, and a `bench` redirect that points reviewers to the workspace benchmark harness.
222
-
223
- <div align="center">
224
- <img src="./docs/assets/cli-static.svg" alt="MartinLoop CLI terminal output" width="720">
225
- </div>
226
-
227
- ---
228
-
229
- ## Policy File
230
-
231
- Drop a `martin.config.yaml` in your repo root to set governance defaults:
232
-
233
- ```yaml
234
- budget:
235
- maxUsd: 5.00
236
- softLimitUsd: 3.75
237
- maxIterations: 5
238
- maxTokens: 40000
239
-
240
- governance:
241
- destructiveActionPolicy: approval
242
- telemetryDestination: local-only
243
- verifierRules:
244
- - pnpm test
245
- ```
246
-
247
- CLI flags override config values when provided.
248
-
249
- ---
250
-
251
- ## TypeScript SDK
252
-
253
- ```sh
254
- npm install martin-loop
255
- ```
256
-
257
- ```typescript
258
- import {
259
- MartinLoop,
260
- createClaudeCliAdapter,
261
- createCodexCliAdapter,
262
- runMartin
263
- } from "martin-loop";
264
-
265
- const loop = new MartinLoop({
266
- adapter: createClaudeCliAdapter({ workingDirectory: process.cwd() }),
267
- defaults: {
268
- workspaceId: "my-workspace",
269
- projectId: "my-project",
270
- budget: {
271
- maxUsd: 3.00,
272
- softLimitUsd: 2.25,
273
- maxIterations: 3,
274
- maxTokens: 20_000
275
- }
276
- }
277
- });
278
-
279
- const result = await loop.run({
280
- task: {
281
- title: "Fix auth regression",
282
- objective: "Fix the failing auth regression tests",
283
- verificationPlan: ["pnpm test"],
284
- repoRoot: process.cwd()
285
- }
286
- });
287
-
288
- console.log(result.decision.status);
289
- ```
290
-
291
- Use Codex instead of Claude by swapping adapters:
292
-
293
- ```typescript
294
- const loop = new MartinLoop({
295
- adapter: createCodexCliAdapter({ workingDirectory: process.cwd() })
296
- });
297
- ```
298
-
299
- The lower-level `runMartin` function is also exported for callers that want to assemble the runtime input directly.
300
-
301
- ---
302
-
303
- ## Workspace Map
304
-
305
- | Package or app | Role |
306
- |---|---|
307
- | `martin-loop` | Root public npm facade that vendors the runtime, CLI, adapters, and contracts into `dist/`. |
308
- | `@martin/contracts` | Shared types for loops, policy, governance, budget, telemetry, and rollback. |
309
- | `@martin/core` | Runtime controller, policy engine, safety leash, grounding, persistence, and rollback logic. |
310
- | `@martin/adapters` | Claude CLI, Codex CLI, direct-provider, and stub adapter surfaces. |
311
- | `@martin/cli` | Local CLI implementation for `run`, `inspect`, `resume`, and the benchmark redirect. |
312
- | `@martinloop/mcp` | MCP server tools: `martin_run`, `martin_inspect`, and `martin_status`. |
313
- | `benchmarks/` | Workspace-only deterministic benchmark and RC validation harness. |
314
- | `apps/control-plane/` | Hosted control-plane workstream, outside the initial npm package surface. |
315
- | `apps/local-dashboard/` | Local dashboard/read-model viewer, not currently packaged as public npm API. |
316
-
317
- The `@martin/core`, `@martin/adapters`, and `@martin/contracts` package manifests are still private workspace packages. The public runtime install target is the root `martin-loop` facade, while `@martinloop/mcp` is packaged as a standalone MCP server with vendored internal runtime dependencies for registry publication.
318
-
319
- ---
320
- ## Development
321
-
322
- Requirements:
323
-
324
- - Node 20+
325
- - pnpm 10.x
326
-
327
- ```bash
328
- git clone https://github.com/Keesan12/martin-loop.git
329
- cd martin-loop
330
- pnpm install
331
-
332
- pnpm test
333
- pnpm lint
334
- pnpm build
335
-
336
- ```
337
-
338
- Current RC gate commands:
339
-
340
- ```sh
341
- pnpm oss:validate
342
- pnpm public:smoke
343
- pnpm repo:smoke
344
- pnpm rc:validate
345
- pnpm pilot:prep:validate
346
- pnpm release:matrix:local
347
- ```
348
-
349
- > **Caution:** This package is live on npm. Treat registry publication as a guarded release step — verify the RC gate commands, confirm semantic versioning, and document breaking changes before publishing.
350
-
351
- The repository is organized as a dual-track workspace: the OSS runtime and package facade are present and published, while the hosted control-plane, local dashboard, and benchmark harness remain gated in private workspace for future release rather than the primary npm package API.
352
-
353
- Helpful docs:
354
-
355
- - [OSS quickstart](./docs/oss/QUICKSTART.md)
356
- - [OSS examples](./docs/oss/EXAMPLES.md)
357
- - [Under-$3 benchmark challenge](./docs/distribution/UNDER-3-CHALLENGE.md)
358
- - [Directory submission pack](./docs/distribution/DIRECTORY-SUBMISSIONS.md)
359
- - [Integration outreach pack](./docs/distribution/INTEGRATION-OUTREACH.md)
360
- - [Claude Code walkthrough](./docs/oss/CLAUDE-CODE-WALKTHROUGH.md)
361
- - [Ralph-style loop safety guide](./docs/oss/RALPH-LOOP-SAFETY.md)
362
- - [OSS boundary report](./docs/oss/OSS-BOUNDARY-REPORT.md)
363
- - [Release surface report](./docs/oss/RELEASE-SURFACE-REPORT.md)
364
-
365
- ---
366
-
367
- ## Contributing
368
-
369
- ```sh
370
- git checkout -b feat/your-feature
371
- pnpm lint
372
- pnpm test
373
- git commit -m "feat: describe what you built"
374
- git push -u origin feat/your-feature
375
- ```
376
-
377
- Conventional commit prefixes: `feat:`, `fix:`, `chore:`, `docs:`, `refactor:`, and `test:`.
378
-
379
- ---
380
-
381
- <div align="center">
382
-
383
- **⭐Give the repo a star⭐** if you think AI coding needs budgets, brakes, and receipts.
384
-
385
- **MIT Licensed** · [martinloop.com](https://martinloop.com) · [keesan@martinloop.com](mailto:keesan@martinloop.com)
386
-
387
- *"AI coding accountability: completes good work, refuses unsafe work, stops uneconomical work."*
388
-
389
- </div>
390
-
391
- <div align="center">
392
- <br>
393
- <picture>
394
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/nvidia-inception-program.png">
395
- <img src="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/nvidia-inception-program-light.png" alt="NVIDIA Inception Program logo" width="280">
396
- </picture>
397
- <br>
398
- </div>
1
+ # Martin Loop
2
+
3
+ Governed runtime for AI coding agents with budgets, policy gates, rollback evidence, and auditable run records.
4
+
5
+ ![Martin Loop CLI release surface](./docs/assets/marketing/github-readme-cli.svg)
6
+
7
+ <picture>
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/nvidia-inception-program.png" />
9
+ <img src="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/nvidia-inception-program-light.png" alt="NVIDIA Inception Program logo" width="280" />
10
+ </picture>
11
+
12
+ Martin Loop has been accepted into the NVIDIA Inception program.
13
+
14
+ [![License](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
15
+ [![TypeScript](https://img.shields.io/badge/language-TypeScript-3178c6)](./tsconfig.base.json)
16
+ [![Node](https://img.shields.io/badge/node-%3E%3D20-green)](./package.json)
17
+
18
+ AI coding agents can write files, run commands, spend provider budget, and leave behind hard-to-review state. Martin Loop wraps those actions in a runtime that answers five questions before you trust the result:
19
+
20
+ - What is the task allowed to touch?
21
+ - What is the hard budget?
22
+ - Which safety and policy gates ran?
23
+ - Did the verifier actually execute?
24
+ - Where is the evidence if the result needs review, rollback, or resume?
25
+
26
+ Current public wording should describe Martin Loop as a **bounded governed AI-coding runtime**, not as a hands-off unrestricted production developer or broadly self-updating system. Trace-autonomy certification exists as a gate, but public trace-autonomy wording remains blocked until the signed evidence pack and external audit signoff pass.
27
+
28
+ ## Release State
29
+
30
+ - Phase 14 staged pilot: closed
31
+ - Phase 15 public release: active
32
+ - Phase 15 adds release-specific truth, packaging, and final-gate checks on top of this baseline.
33
+
34
+ ## Why It Exists
35
+
36
+ | Risk in agentic coding loops | Martin Loop control |
37
+ |---|---|
38
+ | Retry loops can spend without a hard stop | Budget admission checks, soft limits, hard USD caps, iteration caps, and token caps |
39
+ | Agents can mutate the wrong surface | Task contracts, allowed paths, denied paths, policy leashes, and rollback evidence |
40
+ | "Verifier passed" can hide that no verifier ran | Verifier lifecycle state, failure taxonomy, and machine-readable exit reasons |
41
+ | Failure evidence is easy to lose | Canonical run records, ledger events, receipts, and handoff artifacts |
42
+ | Operators need proof before widening claims | Claim linting, release gates, audit packs, and signed autonomy certification artifacts |
43
+
44
+ Martin Loop does not replace Claude, Codex, or other coding agents. It gives those agents an operating envelope.
45
+
46
+ ![Martin Loop architecture](./docs/assets/architecture.svg)
47
+
48
+ ## What It Does Today
49
+
50
+ | Capability | Current behavior |
51
+ |---|---|
52
+ | Budget governance | Enforces `maxUsd`, `softLimitUsd`, `maxIterations`, and `maxTokens`; rejects attempts projected to exceed remaining budget. |
53
+ | Safety leash | Blocks unsafe verifier commands, out-of-scope writes, secret-like task text, and policy-restricted surfaces before accepting work. |
54
+ | Adapter execution | Normalizes Claude CLI, Codex CLI, direct-provider, and stub execution into one runtime result contract. |
55
+ | Verification gate | A run reaches `completed` only when adapter execution and verifier state both support the result. |
56
+ | Rollback evidence | Captures rollback boundaries and restore outcomes for repo-backed attempts when persistence is configured. |
57
+ | Trace intelligence | Reads run ledgers and reports loop patterns such as recovery exhaustion, verifier blind spots, oscillation, and budget pressure. |
58
+ | Guarded improvement | Emits improvement evidence and promotion artifacts; trusted-surface promotion remains policy-gated and claim-safe. |
59
+ | MCP package | Provides a standalone `@martinloop/mcp` server with `martin_run`, `martin_inspect`, and `martin_status`. |
60
+
61
+ ## Quick Start
62
+
63
+ Install the public package:
64
+
65
+ ```bash
66
+ npm install martin-loop
67
+ npx martin-loop --help
68
+ ```
69
+
70
+ Run a provider-free stub loop first:
71
+
72
+ ```bash
73
+ MARTIN_LIVE=false MARTIN_NO_BRIEF=1 npx martin-loop run --objective "Summarize this repository" --yes
74
+ ```
75
+
76
+ Run a governed task with budget and verifier controls:
77
+
78
+ ```bash
79
+ npx martin-loop run \
80
+ --objective "Fix the auth regression" \
81
+ --budget 3.00 \
82
+ --verify "pnpm test" \
83
+ --allow-path "src/**" \
84
+ --deny-path ".env*"
85
+ ```
86
+
87
+ Inspect a persisted run record:
88
+
89
+ ```bash
90
+ npx martin-loop inspect --file ~/.martin/runs/<workspaceId>.jsonl
91
+ ```
92
+
93
+ ## MCP Server
94
+
95
+ Use the standalone MCP package when an MCP host needs to invoke Martin Loop:
96
+
97
+ ```bash
98
+ npx @martinloop/mcp
99
+ ```
100
+
101
+ Claude Code examples:
102
+
103
+ ```bash
104
+ claude mcp add --scope user martin-loop -- npx @martinloop/mcp
105
+ ```
106
+
107
+ Windows PowerShell or cmd:
108
+
109
+ ```powershell
110
+ claude mcp add --scope user martin-loop cmd /c "npx @martinloop/mcp"
111
+ ```
112
+
113
+ The standalone MCP package is intentionally narrow. It exposes:
114
+
115
+ - `martin_run`
116
+ - `martin_inspect`
117
+ - `martin_status`
118
+
119
+ Official registry publication is a guarded release step. The local package gate is:
120
+
121
+ ```bash
122
+ pnpm --filter @martinloop/mcp test
123
+ pnpm --filter @martinloop/mcp build
124
+ pnpm --filter @martinloop/mcp smoke:pack
125
+ pnpm --filter @martinloop/mcp smoke:published
126
+ ```
127
+
128
+ ## Public Package Surface
129
+
130
+ Frozen public install targets:
131
+
132
+ - Install: `npm install martin-loop`
133
+ - CLI: `npx martin-loop`
134
+ - SDK: `import { MartinLoop } from "martin-loop"`
135
+ - MCP: `npx @martinloop/mcp`
136
+
137
+ The root package facade vendors the runtime, adapters, CLI, SDK, contracts, policy, audit exporter, and HeadlessOS core into `dist/`. Internal workspace package names such as `@martin/core` and `@martin/adapters` are implementation details unless separately published.
138
+
139
+ ## TypeScript SDK
140
+
141
+ ```typescript
142
+ import {
143
+ MartinLoop,
144
+ createClaudeCliAdapter,
145
+ createCodexCliAdapter,
146
+ runMartin
147
+ } from "martin-loop";
148
+
149
+ const loop = new MartinLoop({
150
+ adapter: createClaudeCliAdapter({ workingDirectory: process.cwd() }),
151
+ defaults: {
152
+ workspaceId: "my-workspace",
153
+ projectId: "my-project",
154
+ budget: {
155
+ maxUsd: 3.00,
156
+ softLimitUsd: 2.25,
157
+ maxIterations: 3,
158
+ maxTokens: 20000
159
+ }
160
+ }
161
+ });
162
+
163
+ const result = await loop.run({
164
+ task: {
165
+ title: "Fix auth regression",
166
+ objective: "Fix the failing auth regression tests",
167
+ verificationPlan: ["pnpm test"],
168
+ repoRoot: process.cwd()
169
+ }
170
+ });
171
+
172
+ console.log(result.decision.status);
173
+ ```
174
+
175
+ Use Codex instead of Claude by swapping adapters:
176
+
177
+ ```typescript
178
+ const loop = new MartinLoop({
179
+ adapter: createCodexCliAdapter({ workingDirectory: process.cwd() })
180
+ });
181
+ ```
182
+
183
+ `runMartin` is also exported for callers that want to assemble runtime input directly.
184
+
185
+ ## CLI Reference
186
+
187
+ ```text
188
+ martin-loop run <objective> [options]
189
+
190
+ --objective <text> Task to accomplish, or pass it as the first positional arg
191
+ --budget <n> Hard cost cap in USD
192
+ --budget-usd <n> Alias for --budget
193
+ --soft-limit-usd <n> Soft budget threshold in USD
194
+ --verify <cmd> Verifier command after each attempt
195
+ --max-iterations <n> Maximum number of attempts
196
+ --max-tokens <n> Maximum total token budget
197
+ --engine <name> Adapter to use: claude or codex
198
+ --model <name> Adapter model override
199
+ --cwd <path> Repo root for the run
200
+ --allow-path <glob> Restrict agent writes to this path pattern; repeatable
201
+ --deny-path <glob> Block this path pattern; repeatable
202
+ --accept <criterion> Acceptance criterion; repeatable
203
+ --config <path> Path to martin.config.yaml
204
+ --workspace <id> Workspace ID for the run record
205
+ --project <id> Project ID for the run record
206
+ --metadata <key=value> Attach metadata to the run record; repeatable
207
+ ```
208
+
209
+ The public CLI also includes `inspect`, `resume`, and a `bench` redirect that points reviewers to the workspace benchmark harness.
210
+
211
+ ## Configuration
212
+
213
+ Drop a `martin.config.yaml` in the repo root to set governance defaults:
214
+
215
+ ```yaml
216
+ budget:
217
+ maxUsd: 5.00
218
+ softLimitUsd: 3.75
219
+ maxIterations: 5
220
+ maxTokens: 40000
221
+
222
+ governance:
223
+ destructiveActionPolicy: approval
224
+ telemetryDestination: local-only
225
+ verifierRules:
226
+ - pnpm test
227
+ ```
228
+
229
+ CLI flags override config values when provided.
230
+
231
+ ## Claim Boundaries
232
+
233
+ Martin Loop has implemented guarded learning, signed promotion artifacts, trace-autonomy certification tooling, and fail-closed claim gates. That is not the same as an unrestricted self-modifying production system.
234
+
235
+ Do not use unqualified public wording for full hands-off operation, unrestricted system writes, any-part self-updates, fully self-learning behavior, or improvement claims without scope and evidence qualifiers.
236
+
237
+ The bounded future trace-intelligence claim is allowed only after the trace-autonomy certification gate, signed bundle, required live evidence, and external audit signoff pass.
238
+
239
+ ## Development
240
+
241
+ Requirements:
242
+
243
+ - Node 20+
244
+ - pnpm 10.x
245
+
246
+ ```bash
247
+ git clone https://github.com/Keesan12/martin-loop.git
248
+ cd martin-loop
249
+ pnpm install
250
+ pnpm build
251
+ pnpm test
252
+ pnpm lint
253
+ ```
254
+
255
+ Release and claim gates:
256
+
257
+ ```bash
258
+ pnpm oss:validate
259
+ pnpm release:surface:validate
260
+ pnpm public:smoke
261
+ pnpm mcp:published:smoke
262
+ pnpm repo:smoke
263
+ pnpm rc:validate
264
+ pnpm pilot:prep:validate
265
+ pnpm claims:lint
266
+ pnpm release:gate:review
267
+ pnpm release:matrix:local
268
+ ```
269
+
270
+ Useful evidence docs:
271
+
272
+ - [OSS quickstart](./docs/oss/QUICKSTART.md)
273
+ - [OSS examples](./docs/oss/EXAMPLES.md)
274
+ - [OSS boundary report](./docs/oss/OSS-BOUNDARY-REPORT.md)
275
+ - [Release surface report](./docs/oss/RELEASE-SURFACE-REPORT.md)
276
+ - [Release gate review](./docs/release/RELEASE-GATE-REVIEW.md)
277
+ - [Phase 3 autonomy handoff](./docs/handoffs/2026-05-07-phase3-autonomy-implementation-handoff.md)
278
+
279
+ ## Workspace Map
280
+
281
+ | Package or app | Role |
282
+ |---|---|
283
+ | `martin-loop` | Root public npm facade that vendors the runtime, CLI, adapters, SDK, contracts, and policy into `dist/`. |
284
+ | `@martin/core` | Runtime controller, policy engine, safety leash, grounding, persistence, rollback, and autonomy primitives. |
285
+ | `@martin/adapters` | Claude CLI, Codex CLI, direct-provider, and stub adapter surfaces. |
286
+ | `@martin/cli` | Local CLI implementation for `run`, `inspect`, `resume`, `verify`, `audit`, `doctor`, `explain`, and improvement flows. |
287
+ | `@martin/trace-intelligence` | Run-ledger analysis, trace pattern detection, improvement tasks, and trace-autonomy certification. |
288
+ | `@martinloop/mcp` | Standalone MCP server package for `martin_run`, `martin_inspect`, and `martin_status`. |
289
+ | `apps/control-plane` | Hosted/operator control-plane workstream, outside the initial npm package surface. |
290
+ | `apps/local-dashboard` | Local read-model viewer, not currently packaged as public npm API. |
291
+ | `benchmarks` | Workspace-only deterministic benchmark and RC validation harness. |
292
+
293
+ ## Contributing
294
+
295
+ ```bash
296
+ git checkout -b feat/your-feature
297
+ pnpm lint
298
+ pnpm test
299
+ git commit -m "feat: describe what you built"
300
+ git push -u origin feat/your-feature
301
+ ```
302
+
303
+ Use conventional commit prefixes such as `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, and `chore:`.
304
+
305
+ ## License
306
+
307
+ MIT. See [LICENSE](./LICENSE).