@martinloop/mcp 0.3.3 → 0.3.4

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 (55) hide show
  1. package/README.md +112 -107
  2. package/dist/discovery-support.js +2 -2
  3. package/dist/resources.js +147 -147
  4. package/dist/server-validation.js +2 -0
  5. package/dist/server.js +1 -1
  6. package/dist/tools/eval.js +29 -5
  7. package/dist/tools/execution-policy.d.ts +11 -0
  8. package/dist/tools/execution-policy.js +47 -0
  9. package/dist/tools/run-dossier.js +2 -2
  10. package/dist/tools/run-loop.d.ts +1 -0
  11. package/dist/tools/run-loop.js +15 -2
  12. package/dist/tools/run-store.js +4 -4
  13. package/dist/tools/tool-support.d.ts +1 -1
  14. package/dist/tools/tool-support.js +111 -18
  15. package/dist/tools/triage-runs.js +31 -6
  16. package/dist/vendor/adapters/claude-cli.js +69 -19
  17. package/dist/vendor/adapters/cli-bridge.d.ts +6 -0
  18. package/dist/vendor/adapters/cli-bridge.js +62 -2
  19. package/dist/vendor/adapters/codex-launcher.js +65 -8
  20. package/dist/vendor/adapters/openai-compatible.js +6 -6
  21. package/dist/vendor/contracts/adapter-capabilities.d.ts +17 -0
  22. package/dist/vendor/contracts/adapter-capabilities.js +35 -0
  23. package/dist/vendor/contracts/context-graph.d.ts +48 -0
  24. package/dist/vendor/contracts/context-graph.js +26 -0
  25. package/dist/vendor/contracts/execution-policy.d.ts +62 -0
  26. package/dist/vendor/contracts/execution-policy.js +34 -0
  27. package/dist/vendor/contracts/governance.d.ts +6 -3
  28. package/dist/vendor/contracts/identity.d.ts +29 -0
  29. package/dist/vendor/contracts/identity.js +30 -0
  30. package/dist/vendor/contracts/index.d.ts +13 -2
  31. package/dist/vendor/contracts/index.js +4 -0
  32. package/dist/vendor/contracts/observation.d.ts +21 -0
  33. package/dist/vendor/contracts/observation.js +27 -0
  34. package/dist/vendor/contracts/trajectory.d.ts +26 -0
  35. package/dist/vendor/contracts/trajectory.js +27 -0
  36. package/dist/vendor/contracts/verification.d.ts +28 -0
  37. package/dist/vendor/contracts/verification.js +7 -0
  38. package/dist/vendor/core/context-graph.d.ts +3 -0
  39. package/dist/vendor/core/context-graph.js +371 -0
  40. package/dist/vendor/core/identity.d.ts +20 -0
  41. package/dist/vendor/core/identity.js +86 -0
  42. package/dist/vendor/core/index.d.ts +9 -2
  43. package/dist/vendor/core/index.js +67 -11
  44. package/dist/vendor/core/persistence/integrity.js +2 -2
  45. package/dist/vendor/core/persistence/store.js +0 -13
  46. package/dist/vendor/core/policy-compiler.d.ts +2 -0
  47. package/dist/vendor/core/policy-compiler.js +195 -0
  48. package/dist/vendor/core/policy.d.ts +2 -0
  49. package/dist/vendor/core/policy.js +71 -4
  50. package/dist/vendor/core/rollback.d.ts +0 -4
  51. package/dist/vendor/core/rollback.js +32 -27
  52. package/dist/vendor/core/trajectory.d.ts +18 -0
  53. package/dist/vendor/core/trajectory.js +295 -0
  54. package/package.json +76 -75
  55. package/server.json +21 -21
package/README.md CHANGED
@@ -1,132 +1,137 @@
1
1
  # @martinloop/mcp
2
2
 
3
- Governed MCP server for AI coding agents over local stdio.
4
-
5
- `@martinloop/mcp@0.3.2` is the live public baseline today. `0.3.3` is the next planned public cut.
6
-
7
- This package stays local-first and stdio-first in the public OSS lane.
8
-
9
- ## Public release train
10
-
11
- - `0.2.7` made the guided MCP workflow easier to adopt and harder to misuse.
12
- - `0.3.0` is the live adoption baseline that made host setup and onboarding clearer.
13
- - `0.3.1` is the live review and handoff release.
14
- - `0.3.2` is the live engine-validation hotfix that fixes spend-limit requests for Gemini-backed runs.
15
- - `0.3.3` is the planned follow-on for opt-in execution controls.
16
-
17
- ## What ships today
18
-
19
- ### Tools
20
-
21
- - `martin_doctor`
22
- - `martin_plan`
23
- - `martin_preflight`
24
- - `martin_run`
25
- - `martin_inspect`
26
- - `martin_status`
27
- - `martin_logs`
28
- - `martin_pause`
29
- - `martin_cancel`
30
- - `martin_continue`
31
- - `martin_list_runs`
32
- - `martin_triage_runs`
33
- - `martin_get_run`
34
- - `martin_get_attempt`
35
- - `martin_get_verification_results`
36
- - `martin_run_dossier`
37
- - `martin_dossier`
38
- - `martin_eval`
39
- - `martin_pr_summary`
40
- - `martin_create_pr`
41
- - `martin_review_pr`
42
-
43
- ### Resources
44
-
45
- - `martin://server/health`
46
- - `martin://runs/recent`
47
- - `martin://runs/triage`
48
- - `martin://runs/latest`
49
- - `martin://runs/latest/summary`
50
- - `martin://runs/latest/proof-card`
51
- - `martin://runs/latest/budget-status`
52
- - `martin://runs/latest/verifier-evidence`
53
- - `martin://runs/latest/rollback-evidence`
54
- - `martin://policies/current`
55
- - `martin://repo/risk-map`
56
- - `martin://verifiers/results`
57
- - `martin://agent/next-step`
58
- - `martin://guides/mcp-usage`
59
- - `martin://guides/agent-start`
60
- - `martin://guides/publish-readiness`
61
-
62
- ### Prompts
63
-
64
- - `martin_start`
65
- - `martin_preflight`
66
- - `martin_triage`
67
- - `martin_resume`
68
- - `martin_prove`
69
- - `martin_release_check`
70
- - `martin_governed_coding_kickoff`
71
- - `martin_debug_failed_run`
72
- - `martin_publish_readiness_review`
73
- - `martin_triage_run_store`
74
-
75
- ## Recommended flow
76
-
77
- 1. `martin_doctor`
78
- 2. `martin_plan`
79
- 3. `martin_preflight`
80
- 4. `martin_run`
81
- 5. `martin_status` or `martin_logs`
82
- 6. `martin_dossier`
83
- 7. `martin_eval`
3
+ You give an AI agent a coding task. It runs. You get a bill.
4
+
5
+ But did it actually work? Did it pass your tests? How much did it spend? What files did it touch? Did it loop 47 times trying the same broken approach?
6
+
7
+ You don't know. And that's the problem.
8
+
9
+ ## What This Does
10
+
11
+ MartinLoop is a governed loop for AI coding agents. You tell it what to do, set a budget, and point it at your test suite. It runs the agent, checks your tests after every attempt, and stops when either the tests pass or the money runs out.
12
+
13
+ When it's done, you get a receipt — not a vague summary, but a structured record: dollars spent, attempts made, verification results, files changed, and whether you got what you asked for.
14
+
15
+ **One line to connect it:**
16
+
17
+ ```sh
18
+ claude mcp add martin-loop -- npx -y @martinloop/mcp
19
+ ```
20
+
21
+ That's it. Your agent now runs governed.
22
+
23
+ ## Real Numbers From Real Runs
24
+
25
+ We tested this against live repos with real API spend:
26
+
27
+ | What happened | Without MartinLoop | With MartinLoop |
28
+ |---|---|---|
29
+ | Budget: $1.50 task | Agent spent **$28.42** | Agent stopped at **$1.20** |
30
+ | Failing verifier | Retried indefinitely | Stopped after 3 attempts with diagnosis |
31
+ | CLI not on PATH | "not available on PATH" (dead stop) | Auto-discovered in AppData, kept running |
32
+ | `bun run lint && bun run test` | Passed `&&` as a literal arg (always fails) | Routed through shell, worked |
33
+
34
+ These aren't hypotheticals. The $28 overshoot happened in production testing. We fixed the circuit breaker in `0.3.8`.
84
35
 
85
36
  ## Install
86
37
 
38
+ ### Claude Code
87
39
  ```sh
88
- npx -y @martinloop/mcp
40
+ claude mcp add martin-loop -- npx -y @martinloop/mcp
89
41
  ```
90
42
 
91
- Codex:
43
+ Windows:
44
+ ```sh
45
+ claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
46
+ ```
92
47
 
48
+ ### Codex
93
49
  ```sh
94
50
  codex mcp add martin-loop -- npx -y @martinloop/mcp
95
51
  ```
96
52
 
97
- Claude Code:
98
-
53
+ ### Gemini CLI
99
54
  ```sh
100
- # macOS/Linux
101
- claude mcp add --transport stdio --scope user martin-loop -- npx -y @martinloop/mcp
55
+ gemini mcp add martin-loop -- npx -y @martinloop/mcp
56
+ ```
102
57
 
103
- # Windows PowerShell or cmd.exe
104
- claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
58
+ ### Any MCP Host
59
+ ```sh
60
+ npx -y @martinloop/mcp
105
61
  ```
106
62
 
107
- If you want generated host config, use the MartinLoop CLI:
63
+ ## How a Governed Run Works
108
64
 
109
- ```sh
110
- martin mcp print-config --host codex --transport stdio --profile minimal
111
- martin mcp print-config --host claude --transport stdio --profile diagnostic
112
- martin mcp print-config --host gemini --transport stdio --profile full-local
113
- martin mcp print-config --host generic --transport stdio --profile github-review
114
65
  ```
66
+ You: "Fix the auth bug. Budget $3. Verify: npm test"
67
+
68
+ martin_doctor → checks CLI, auth, environment
69
+ martin_plan → scopes the task, sets constraints
70
+ martin_preflight → validates before any spend
71
+ martin_run → agent works inside budget + verifier gates
72
+ martin_dossier → receipt: $1.40 spent, 2 attempts, tests pass
73
+ ```
74
+
75
+ Every attempt runs your verifier. Every dollar is tracked. If the agent drifts off-task, the scope contract catches it. If it blows the budget, the circuit breaker kills the subprocess mid-stream — not after the bill arrives.
76
+
77
+ ## What Your Agent Gets
78
+
79
+ ### 21 Tools
80
+
81
+ **Run the loop:**
82
+ `martin_doctor` `martin_plan` `martin_preflight` `martin_run` `martin_pause` `martin_continue` `martin_cancel`
83
+
84
+ **Inspect results:**
85
+ `martin_status` `martin_logs` `martin_dossier` `martin_eval` `martin_inspect` `martin_list_runs` `martin_get_run` `martin_get_attempt` `martin_get_verification_results` `martin_triage_runs`
86
+
87
+ **Ship the work:**
88
+ `martin_pr_summary` `martin_create_pr` `martin_review_pr`
89
+
90
+ ### 11 Read-Only Resources
91
+
92
+ Your agent can pull context without side effects:
115
93
 
116
- ## Compatibility posture
94
+ `martin://runs/latest` · `martin://runs/latest/proof-card` · `martin://runs/latest/budget-status` · `martin://runs/latest/verifier-evidence` · `martin://runs/recent` · `martin://server/health` · `martin://policies/current` · `martin://agent/next-step` · `martin://guides/mcp-usage` · `martin://guides/agent-start` · `martin://repo/risk-map`
117
95
 
118
- - `martin_run` remains the single execution entrypoint.
119
- - Read-only inspection stays available without execution-capable profiles.
120
- - The OSS package stays focused on local stdio workflows. Hosted and team features live on a separate product track.
121
- - Later `0.3.x` releases should widen adoption and guidance without blurring those boundaries.
96
+ ### Configuration Profiles
122
97
 
123
- ## Verification
98
+ Generate host config tuned to your workflow:
124
99
 
125
100
  ```sh
126
- pnpm --filter @martinloop/mcp lint
127
- pnpm --filter @martinloop/mcp test
128
- pnpm --filter @martinloop/mcp build
129
- pnpm --filter @martinloop/mcp smoke:pack
130
- pnpm --filter @martinloop/mcp smoke:published:pack
131
- pnpm --filter @martinloop/mcp verify:release
101
+ npx martin-loop mcp print-config --host claude --profile minimal # run + inspect
102
+ npx martin-loop mcp print-config --host claude --profile diagnostic # + doctor + triage
103
+ npx martin-loop mcp print-config --host claude --profile full-local # all local tools
104
+ npx martin-loop mcp print-config --host claude --profile github-review # + PR workflow
132
105
  ```
106
+
107
+ ## What Happens When Things Go Wrong
108
+
109
+ MartinLoop doesn't just report failures — it tries to fix them:
110
+
111
+ | Failure | Old behavior | Now |
112
+ |---|---|---|
113
+ | CLI not on PATH | Error message, dead stop | Searches npm global, homebrew, nvm, scoop — uses what it finds |
114
+ | Verifier says "command not found" | Generic "verification failed" | Tells the next attempt: "bun is missing, install with `npm i -g bun`" |
115
+ | `git restore` fails mid-rollback | Throws, leaves dirty state | Retries once, falls back to `git checkout`, cleans up |
116
+ | Invalid `--profile` flag | Crashes | Warns, falls back to `minimal`, keeps running |
117
+
118
+ ## Who Uses This
119
+
120
+ - **Engineers running overnight agent loops** — you need a kill switch that actually works, and a receipt in the morning
121
+ - **Teams with shared API budgets** — you need per-task spend caps, not org-wide prayer
122
+ - **Anyone reviewing agent-generated PRs** — the dossier shows what the agent tried, what passed, and what didn't
123
+
124
+ ## Requirements
125
+
126
+ - Node.js 20+
127
+ - One AI coding CLI: [Claude Code](https://docs.anthropic.com/claude-code), [Codex](https://github.com/openai/codex), or [Gemini CLI](https://github.com/google/gemini-cli)
128
+
129
+ ## Links
130
+
131
+ - [martin-loop](https://www.npmjs.com/package/martin-loop) — the standalone CLI
132
+ - [GitHub](https://github.com/Keesan12/martin-loop) — source and issues
133
+ - [martinloop.com](https://martinloop.com)
134
+
135
+ ## License
136
+
137
+ Apache-2.0
@@ -143,7 +143,7 @@ function collectVerificationSnapshots(loop, ledgerEvents) {
143
143
  }
144
144
  snapshots.sort((left, right) => new Date(left.timestamp).getTime() - new Date(right.timestamp).getTime());
145
145
  if (hasConflictingStatusesForLatestAttempt(snapshots)) {
146
- warnings.push("Verification evidence conflicts for the latest attempt; reporting status as unavailable.");
146
+ warnings.push("Verification evidence conflicts for the latest attempt; marking verification as contradicted.");
147
147
  }
148
148
  return { snapshots, warnings };
149
149
  }
@@ -176,7 +176,7 @@ function verificationSnapshotKey(snapshot) {
176
176
  ].join(":");
177
177
  }
178
178
  function selectLatestVerificationSnapshot(snapshots, warnings) {
179
- if (warnings.includes("Verification evidence conflicts for the latest attempt; reporting status as unavailable.")) {
179
+ if (warnings.includes("Verification evidence conflicts for the latest attempt; marking verification as contradicted.")) {
180
180
  return undefined;
181
181
  }
182
182
  return snapshots.at(-1);
package/dist/resources.js CHANGED
@@ -626,173 +626,173 @@ function inferAgentNextStep(loop, verification) {
626
626
  }
627
627
  function buildMcpUsageGuide(runsRoot) {
628
628
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
629
- return `# Martin Loop MCP Usage
630
-
631
- Discovery revision: \`${metadata.discoveryRevision}\`
632
- Server version: \`${metadata.serverVersion}\`
633
- Runs root: \`${runsRoot}\`
634
-
635
- Martin Loop exposes governed coding workflows over MCP. Use the server health and run-store views to decide when to preflight, execute, inspect, or escalate.
636
-
637
- ## Recommended Flow
638
-
639
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` or call \`martin_doctor\` to confirm the environment and run-store visibility.
640
- 2. Use the \`martin_governed_coding_kickoff\` prompt to frame a governed coding request.
641
- 3. Call \`martin_preflight\` before \`martin_run\` when the task or safety envelope is non-trivial.
642
- 4. After execution, inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`martin://runs/{loopId}\`, and \`martin://runs/{loopId}/verification\`.
643
- 5. For low-context agents, read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, or \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\` before asking for full JSON.
644
- 6. Read \`${MARTIN_STATIC_RESOURCE_URIS.triage}\` or call \`martin_triage_runs\` to prioritize which run needs attention first.
645
- 7. Use \`martin_debug_failed_run\` when a loop exits failed, budget-bound, or escalated.
646
-
647
- ## Current Martin MCP Surface
648
-
649
- - Tools: \`martin_run\`, \`martin_inspect\`, \`martin_status\`, \`martin_doctor\`, \`martin_preflight\`, \`martin_list_runs\`, \`martin_triage_runs\`, \`martin_get_run\`, \`martin_get_attempt\`, \`martin_get_verification_results\`, \`martin_run_dossier\`
650
- - Static resources: \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\`, \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`${MARTIN_STATIC_RESOURCE_URIS.triage}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestBudgetStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestVerifierEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestRollbackEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.mcpUsageGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.publishReadinessGuide}\`
651
- - Resource templates: \`martin://runs/{loopId}\`, \`martin://runs/{loopId}/attempts/{attemptIndex}\`, \`martin://runs/{loopId}/verification\`
652
- - Prompts: \`martin_start\`, \`martin_preflight\`, \`martin_triage\`, \`martin_resume\`, \`martin_prove\`, \`martin_release_check\`, \`martin_governed_coding_kickoff\`, \`martin_debug_failed_run\`, \`martin_publish_readiness_review\`, \`martin_triage_run_store\`
653
-
654
- ## Notes
655
-
656
- - Discovery helpers read the existing Martin run-store; they do not create new schema.
657
- - Verification history is derived from persisted \`verification.completed\` evidence in loop records and ledgers.
658
- - Attempt inspection stays aligned with the same loop selectors used by \`martin_status\` and \`martin_inspect\`.
629
+ return `# Martin Loop MCP Usage
630
+
631
+ Discovery revision: \`${metadata.discoveryRevision}\`
632
+ Server version: \`${metadata.serverVersion}\`
633
+ Runs root: \`${runsRoot}\`
634
+
635
+ Martin Loop exposes governed coding workflows over MCP. Use the server health and run-store views to decide when to preflight, execute, inspect, or escalate.
636
+
637
+ ## Recommended Flow
638
+
639
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` or call \`martin_doctor\` to confirm the environment and run-store visibility.
640
+ 2. Use the \`martin_governed_coding_kickoff\` prompt to frame a governed coding request.
641
+ 3. Call \`martin_preflight\` before \`martin_run\` when the task or safety envelope is non-trivial.
642
+ 4. After execution, inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`martin://runs/{loopId}\`, and \`martin://runs/{loopId}/verification\`.
643
+ 5. For low-context agents, read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, or \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\` before asking for full JSON.
644
+ 6. Read \`${MARTIN_STATIC_RESOURCE_URIS.triage}\` or call \`martin_triage_runs\` to prioritize which run needs attention first.
645
+ 7. Use \`martin_debug_failed_run\` when a loop exits failed, budget-bound, or escalated.
646
+
647
+ ## Current Martin MCP Surface
648
+
649
+ - Tools: \`martin_run\`, \`martin_inspect\`, \`martin_status\`, \`martin_doctor\`, \`martin_preflight\`, \`martin_list_runs\`, \`martin_triage_runs\`, \`martin_get_run\`, \`martin_get_attempt\`, \`martin_get_verification_results\`, \`martin_run_dossier\`
650
+ - Static resources: \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\`, \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`${MARTIN_STATIC_RESOURCE_URIS.triage}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestBudgetStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestVerifierEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestRollbackEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.mcpUsageGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.publishReadinessGuide}\`
651
+ - Resource templates: \`martin://runs/{loopId}\`, \`martin://runs/{loopId}/attempts/{attemptIndex}\`, \`martin://runs/{loopId}/verification\`
652
+ - Prompts: \`martin_start\`, \`martin_preflight\`, \`martin_triage\`, \`martin_resume\`, \`martin_prove\`, \`martin_release_check\`, \`martin_governed_coding_kickoff\`, \`martin_debug_failed_run\`, \`martin_publish_readiness_review\`, \`martin_triage_run_store\`
653
+
654
+ ## Notes
655
+
656
+ - Discovery helpers read the existing Martin run-store; they do not create new schema.
657
+ - Verification history is derived from persisted \`verification.completed\` evidence in loop records and ledgers.
658
+ - Attempt inspection stays aligned with the same loop selectors used by \`martin_status\` and \`martin_inspect\`.
659
659
  `;
660
660
  }
661
661
  function buildAgentStartGuide(runsRoot) {
662
662
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
663
- return `# Agent Start Here
664
-
665
- Discovery revision: \`${metadata.discoveryRevision}\`
666
- Server version: \`${metadata.serverVersion}\`
667
- Runs root: \`${runsRoot}\`
668
-
669
- Use Martin Loop as the local governor before you spend agent tokens or retry a failed coding loop.
670
-
671
- ## Cheap Default Flow
672
-
673
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\` first. It is the smallest "what should I do now?" payload.
674
- 2. If no runs exist, call \`martin_doctor\`, then \`martin_preflight\`.
675
- 3. If a run exists, read \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\` before reading full run JSON.
676
- 4. If the verifier failed, use prompt \`martin_debug_failed_run\` or \`martin_triage\`.
677
- 5. If you need a shareable receipt, read \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`.
678
-
679
- ## Install Profiles
680
-
681
- - \`minimal\` (default): doctor, preflight, list, triage, dossier. Good for low tool bloat.
682
- - \`diagnostic\`: read-only inspection tools for debugging without execution.
683
- - \`full-local\`: all local tools, including \`martin_run\`.
684
- - \`github-review\`: review-oriented local profile for PR drafting and reviewer evidence.
685
- - \`starter\` and \`full\`: compatibility aliases.
686
-
687
- ## Copy-Paste Agent Rule
688
-
689
- Before running or retrying an autonomous coding task, call Martin. Prefer compact resources first, then full dossiers only when the compact receipt says more evidence is needed. Never claim success unless Martin shows verifier-backed completion or a clear blocked reason.
663
+ return `# Agent Start Here
664
+
665
+ Discovery revision: \`${metadata.discoveryRevision}\`
666
+ Server version: \`${metadata.serverVersion}\`
667
+ Runs root: \`${runsRoot}\`
668
+
669
+ Use Martin Loop as the local governor before you spend agent tokens or retry a failed coding loop.
670
+
671
+ ## Cheap Default Flow
672
+
673
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\` first. It is the smallest "what should I do now?" payload.
674
+ 2. If no runs exist, call \`martin_doctor\`, then \`martin_preflight\`.
675
+ 3. If a run exists, read \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\` before reading full run JSON.
676
+ 4. If the verifier failed, use prompt \`martin_debug_failed_run\` or \`martin_triage\`.
677
+ 5. If you need a shareable receipt, read \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`.
678
+
679
+ ## Install Profiles
680
+
681
+ - \`minimal\` (default): doctor, preflight, list, triage, dossier. Good for low tool bloat.
682
+ - \`diagnostic\`: read-only inspection tools for debugging without execution.
683
+ - \`full-local\`: all local tools, including \`martin_run\`.
684
+ - \`github-review\`: review-oriented local profile for PR drafting and reviewer evidence.
685
+ - \`starter\` and \`full\`: compatibility aliases.
686
+
687
+ ## Copy-Paste Agent Rule
688
+
689
+ Before running or retrying an autonomous coding task, call Martin. Prefer compact resources first, then full dossiers only when the compact receipt says more evidence is needed. Never claim success unless Martin shows verifier-backed completion or a clear blocked reason.
690
690
  `;
691
691
  }
692
692
  function buildCommandMapGuide(runsRoot) {
693
693
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
694
- return `# Martin Command Map
695
-
696
- Discovery revision: \`${metadata.discoveryRevision}\`
697
- Server version: \`${metadata.serverVersion}\`
698
- Runs root: \`${runsRoot}\`
699
-
700
- Use this guide when an IDE or agent needs to know which Martin surface to call next.
701
-
702
- ## Default Governed Sequence
703
-
704
- 1. \`martin_doctor\` — confirm environment and visibility.
705
- 2. \`martin_plan\` — propose the bounded approach without spending a run.
706
- 3. \`martin_preflight\` — turn the plan into an explicit contract.
707
- 4. \`martin_run\` — execute only after the contract is safe.
708
- 5. \`martin_dossier\` — inspect what happened and what Martin prevented.
709
- 6. \`martin_eval\` — convert the result into review posture when needed.
710
-
711
- ## When To Use Which Surface
712
-
713
- - Need the smallest next action: \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`
714
- - Need a quick receipt: \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`
715
- - Need a shareable proof object: \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`
716
- - Need a full run review: \`martin_dossier\`
717
- - Need to decide whether to retry: \`martin_triage_runs\`
718
- - Need IDE setup guidance: \`${MARTIN_STATIC_RESOURCE_URIS.ideOnboardingGuide}\`
694
+ return `# Martin Command Map
695
+
696
+ Discovery revision: \`${metadata.discoveryRevision}\`
697
+ Server version: \`${metadata.serverVersion}\`
698
+ Runs root: \`${runsRoot}\`
699
+
700
+ Use this guide when an IDE or agent needs to know which Martin surface to call next.
701
+
702
+ ## Default Governed Sequence
703
+
704
+ 1. \`martin_doctor\` — confirm environment and visibility.
705
+ 2. \`martin_plan\` — propose the bounded approach without spending a run.
706
+ 3. \`martin_preflight\` — turn the plan into an explicit contract.
707
+ 4. \`martin_run\` — execute only after the contract is safe.
708
+ 5. \`martin_dossier\` — inspect what happened and what Martin prevented.
709
+ 6. \`martin_eval\` — convert the result into review posture when needed.
710
+
711
+ ## When To Use Which Surface
712
+
713
+ - Need the smallest next action: \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`
714
+ - Need a quick receipt: \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`
715
+ - Need a shareable proof object: \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`
716
+ - Need a full run review: \`martin_dossier\`
717
+ - Need to decide whether to retry: \`martin_triage_runs\`
718
+ - Need IDE setup guidance: \`${MARTIN_STATIC_RESOURCE_URIS.ideOnboardingGuide}\`
719
719
  `;
720
720
  }
721
721
  function buildIdeOnboardingGuide(runsRoot) {
722
722
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
723
- return `# Martin IDE Onboarding
724
-
725
- Discovery revision: \`${metadata.discoveryRevision}\`
726
- Server version: \`${metadata.serverVersion}\`
727
- Runs root: \`${runsRoot}\`
728
-
729
- Use this guide after the MCP server is installed so the host naturally uses MartinLoop during real work.
730
-
731
- ## IDE Default Flow
732
-
733
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`
734
- 2. Read \`${MARTIN_STATIC_RESOURCE_URIS.operatingRulesGuide}\`
735
- 3. Use prompt \`martin_start\` or \`martin_governed_coding_kickoff\`
736
- 4. Call \`martin_doctor\`
737
- 5. Call \`martin_plan\`
738
- 6. Call \`martin_preflight\`
739
- 7. Only then call \`martin_run\`
740
-
741
- ## Goal
742
-
743
- MartinLoop should become the normal path for coding work in the host, not a manual extra step the human has to remember.
723
+ return `# Martin IDE Onboarding
724
+
725
+ Discovery revision: \`${metadata.discoveryRevision}\`
726
+ Server version: \`${metadata.serverVersion}\`
727
+ Runs root: \`${runsRoot}\`
728
+
729
+ Use this guide after the MCP server is installed so the host naturally uses MartinLoop during real work.
730
+
731
+ ## IDE Default Flow
732
+
733
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`
734
+ 2. Read \`${MARTIN_STATIC_RESOURCE_URIS.operatingRulesGuide}\`
735
+ 3. Use prompt \`martin_start\` or \`martin_governed_coding_kickoff\`
736
+ 4. Call \`martin_doctor\`
737
+ 5. Call \`martin_plan\`
738
+ 6. Call \`martin_preflight\`
739
+ 7. Only then call \`martin_run\`
740
+
741
+ ## Goal
742
+
743
+ MartinLoop should become the normal path for coding work in the host, not a manual extra step the human has to remember.
744
744
  `;
745
745
  }
746
746
  function buildOperatingRulesGuide(runsRoot) {
747
747
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
748
- return `# Martin Operating Rules
749
-
750
- Discovery revision: \`${metadata.discoveryRevision}\`
751
- Server version: \`${metadata.serverVersion}\`
752
- Runs root: \`${runsRoot}\`
753
-
754
- Use these rules inside the IDE or MCP host as the default MartinLoop operating posture.
755
-
756
- ## Required Sequence Before Real Work
757
-
758
- 1. \`martin_doctor\`
759
- 2. \`martin_plan\`
760
- 3. \`martin_preflight\`
761
- 4. \`martin_run\`
762
- 5. \`martin_dossier\`
763
-
764
- ## Enforcement Rule
765
-
766
- Do not execute real coding work through MartinLoop until doctor and preflight have both been used for the current task.
767
-
768
- ## Completion Rule
769
-
770
- Do not claim success until MartinLoop shows verifier-backed completion or an explicit blocked reason backed by evidence.
748
+ return `# Martin Operating Rules
749
+
750
+ Discovery revision: \`${metadata.discoveryRevision}\`
751
+ Server version: \`${metadata.serverVersion}\`
752
+ Runs root: \`${runsRoot}\`
753
+
754
+ Use these rules inside the IDE or MCP host as the default MartinLoop operating posture.
755
+
756
+ ## Required Sequence Before Real Work
757
+
758
+ 1. \`martin_doctor\`
759
+ 2. \`martin_plan\`
760
+ 3. \`martin_preflight\`
761
+ 4. \`martin_run\`
762
+ 5. \`martin_dossier\`
763
+
764
+ ## Enforcement Rule
765
+
766
+ Do not execute real coding work through MartinLoop until doctor and preflight have both been used for the current task.
767
+
768
+ ## Completion Rule
769
+
770
+ Do not claim success until MartinLoop shows verifier-backed completion or an explicit blocked reason backed by evidence.
771
771
  `;
772
772
  }
773
773
  function buildPublishReadinessGuide(runsRoot) {
774
774
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
775
- return `# Martin MCP Publish Readiness
776
-
777
- Discovery revision: \`${metadata.discoveryRevision}\`
778
- Server version: \`${metadata.serverVersion}\`
779
- Runs root: \`${runsRoot}\`
780
-
781
- Use this guide when reviewing whether the public MCP package is ready to publish, promote, or hand off for registry submission.
782
-
783
- ## Review Areas
784
-
785
- 1. Environment health: confirm \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` shows a sane working directory, runs root, and engine availability for the target mode.
786
- 2. Discovery surface: verify tools, prompts, static resources, and resource templates are all discoverable and named consistently.
787
- 3. Run evidence: inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\` and, when relevant, \`martin://runs/{loopId}/verification\` to confirm verification outcomes are explainable from persisted data.
788
- 4. Packaging lane: run the MCP package test, build, and smoke-pack commands before calling the package publish-ready.
789
- 5. Findings-first reporting: call out missing schema, integration gaps, triage-critical runs, and verification blockers before summarizing strengths.
790
-
791
- ## Evidence Expectations
792
-
793
- - Prefer concrete run IDs, attempt indices, and verification summaries over vague statements.
794
- - Distinguish local package validation from live registry readiness.
795
- - If a discovery helper exists but is not yet wired into the server, report that as an integration gap instead of treating the capability as fully shipped.
775
+ return `# Martin MCP Publish Readiness
776
+
777
+ Discovery revision: \`${metadata.discoveryRevision}\`
778
+ Server version: \`${metadata.serverVersion}\`
779
+ Runs root: \`${runsRoot}\`
780
+
781
+ Use this guide when reviewing whether the public MCP package is ready to publish, promote, or hand off for registry submission.
782
+
783
+ ## Review Areas
784
+
785
+ 1. Environment health: confirm \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` shows a sane working directory, runs root, and engine availability for the target mode.
786
+ 2. Discovery surface: verify tools, prompts, static resources, and resource templates are all discoverable and named consistently.
787
+ 3. Run evidence: inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\` and, when relevant, \`martin://runs/{loopId}/verification\` to confirm verification outcomes are explainable from persisted data.
788
+ 4. Packaging lane: run the MCP package test, build, and smoke-pack commands before calling the package publish-ready.
789
+ 5. Findings-first reporting: call out missing schema, integration gaps, triage-critical runs, and verification blockers before summarizing strengths.
790
+
791
+ ## Evidence Expectations
792
+
793
+ - Prefer concrete run IDs, attempt indices, and verification summaries over vague statements.
794
+ - Distinguish local package validation from live registry readiness.
795
+ - If a discovery helper exists but is not yet wired into the server, report that as an integration gap instead of treating the capability as fully shipped.
796
796
  `;
797
797
  }
798
798
  function withDiscoveryMetadata(value, runsRoot) {
@@ -148,6 +148,7 @@ function validateRunInput(args) {
148
148
  "maxUsd",
149
149
  "maxIterations",
150
150
  "maxTokens",
151
+ "verifyTimeoutMs",
151
152
  "maxMinutes",
152
153
  "maxFilesChanged",
153
154
  "maxCommands",
@@ -176,6 +177,7 @@ function validateRunInput(args) {
176
177
  ...optionalPositiveNumber(record.maxUsd, "maxUsd"),
177
178
  ...optionalPositiveInteger(record.maxIterations, "maxIterations"),
178
179
  ...optionalPositiveInteger(record.maxTokens, "maxTokens"),
180
+ ...optionalPositiveInteger(record.verifyTimeoutMs, "verifyTimeoutMs"),
179
181
  ...optionalPositiveInteger(record.maxMinutes, "maxMinutes"),
180
182
  ...optionalPositiveInteger(record.maxFilesChanged, "maxFilesChanged"),
181
183
  ...optionalPositiveInteger(record.maxCommands, "maxCommands"),
package/dist/server.js CHANGED
@@ -118,7 +118,7 @@ const verificationSchema = {
118
118
  type: "object",
119
119
  additionalProperties: true,
120
120
  properties: {
121
- status: { type: "string", enum: ["passed", "failed", "unavailable"] },
121
+ status: { type: "string", enum: ["passed", "failed", "contradicted", "not_run"] },
122
122
  eventCount: { type: "integer" },
123
123
  ledgerEventCount: { type: "integer" },
124
124
  latestAttemptIndex: { type: "integer" },