@martinloop/mcp 0.8.7 → 0.8.9

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.
@@ -1,4 +1,4 @@
1
- import { type ApprovalPolicy, type AgentExecutionIntent, type ContextHandoffReceipt, type CostProvenance, type ExecutionProfile, type ExternalOutcomeEvidenceReference, type FailureClass, type InterventionType, type LoopArtifact, type LoopAttempt, type LoopBudget, type ProviderUsageSettlement, type MutationMode, type LoopRecord, type LoopTask, type ReceiptScope } from "../contracts/index.js";
1
+ import { type ApprovalPolicy, type AgentExecutionIntent, type ContextHandoffReceipt, type CostProvenance, type ExecutionProfile, type ExternalOutcomeEvidenceReference, type FailureClass, type InterventionType, type LoopArtifact, type LoopAttempt, type LoopBudget, type ProviderUsageSettlement, type MutationMode, type LoopRecord, type LoopTask, type ReceiptScope, type RollbackBoundaryArtifact } from "../contracts/index.js";
2
2
  import { classifyFailure, computeEvidenceVector, evaluatePatchDecision, evaluateCostGovernor, evaluateBudgetPreflight, inferExit, nextPolicyPhase, policyPhaseToLifecycleState, scorePatchDecision, selectRecoveryRecipe, type ExitDecision } from "./policy.js";
3
3
  import { evaluateChangeApprovalLeash, evaluateFilesystemLeash, evaluateSecretLeash, redactSecretsFromText, resolveExecutionProfile, evaluateVerificationLeash } from "./leash.js";
4
4
  import { buildRepoGroundingIndex, loadOrBuildRepoGroundingIndex, queryRepoGroundingIndex, scanPatchForGroundingViolations } from "./grounding.js";
@@ -7,6 +7,7 @@ import { type RunStore } from "./persistence/index.js";
7
7
  import { type ExitPolicyOverrides } from "./exits.js";
8
8
  import { type ExitSignalSource } from "./exit-signal.js";
9
9
  import { type VerifierExecutionBinding } from "./verified-handoff.js";
10
+ import { acquireRunExecutionLease, evaluateRunResumability, loadResumeCandidateBoundary, loadResumeVerifierFailure } from "./resume.js";
10
11
  export type { AgentExecutionIntent, ApprovalPolicy, BudgetPreflightEstimate, BudgetSettlement, CostProvenance, EvidenceVector, ExecutionProfile, FailureClass, InterventionType, PatchDecision, PatchDecisionArtifact, PatchDecisionReasonCode, PatchScore, MutationMode, RollbackBoundaryArtifact, RollbackBoundaryStrategy, RollbackFileSnapshot, RollbackOutcomeArtifact, RollbackOutcomeStatus, PolicyPhase, CallStage, AgentRole, FirstDelta, RoutingEconomics } from "../contracts/index.js";
11
12
  export { DEFAULT_AGENT_EXECUTION_INTENT, DEFAULT_PROVIDER_EXECUTION_TIMEOUT_MS, GOVERNED_AUTONOMOUS_BOUNDARY, normalizeProviderExecutionTimeoutMs } from "../contracts/index.js";
12
13
  export { classifyFailure, computeEvidenceVector, evaluatePatchDecision, evaluateCostGovernor, evaluateBudgetPreflight, inferExit, nextPolicyPhase, policyPhaseToLifecycleState, scorePatchDecision, selectRecoveryRecipe, evaluateVerificationLeash, evaluateFilesystemLeash, evaluateChangeApprovalLeash, evaluateSecretLeash, resolveExecutionProfile, redactSecretsFromText, buildRepoGroundingIndex, loadOrBuildRepoGroundingIndex, queryRepoGroundingIndex, scanPatchForGroundingViolations, captureRollbackBoundary, listAttemptChangedFilesSinceBoundary, listIgnoredFileChangesSinceBoundary, restoreRollbackBoundary };
@@ -22,6 +23,7 @@ export type { LocalIdentityAuthority } from "./identity.js";
22
23
  export { compileExecutionPolicy } from "./policy-compiler.js";
23
24
  export { assessTrajectory, decideCircuitBreak } from "./trajectory.js";
24
25
  export { calculateAvoidedUsd, calculateLoopAvoidedUsd } from "./savings.js";
26
+ export { acquireRunExecutionLease, evaluateRunResumability, loadResumeCandidateBoundary, loadResumeVerifierFailure };
25
27
  export type { AvoidedUsdInput } from "./savings.js";
26
28
  export { classifyRoute, evaluatePreworkBurnPolicy } from "./routing.js";
27
29
  export type { RouteDecision, RouteClassificationInput } from "./routing.js";
@@ -83,6 +85,29 @@ export interface MartinAdapterRequest {
83
85
  remainingTokens?: number;
84
86
  /** Who executes verifier commands. Defaults to provider_and_host for standalone compatibility. */
85
87
  verificationExecutionOwner?: "provider_and_host" | "host_only";
88
+ /** Structured failure evidence from the most recent attempt, for repair context. */
89
+ lastVerifierFailure?: {
90
+ /** The failing verifier command. */
91
+ command: string;
92
+ /** Native exit code when a normal exit occurred; undefined for crash/timeout. */
93
+ exitCode?: number;
94
+ /** Whether the step crashed (signal/exception) before producing a normal exit. */
95
+ crashed?: boolean;
96
+ /** Whether the verifier step timed out. */
97
+ timedOut?: boolean;
98
+ /** Bounded, sanitized failure excerpt (max 1500 chars, tail kept). */
99
+ failureExcerpt: string;
100
+ /** ID of the attempt that produced this failure. */
101
+ attemptId: string;
102
+ /** Index of the attempt that produced this failure (1-based). */
103
+ attemptIndex: number;
104
+ };
105
+ /**
106
+ * True when the previous attempt's candidate patch was retained in the workspace
107
+ * (SAFE_UNVERIFIED) rather than rolled back. The next agent should inspect the
108
+ * existing changes and repair only the failing part — not rebuild from scratch.
109
+ */
110
+ previousCandidateRetained?: boolean;
86
111
  };
87
112
  previousAttempts: LoopAttempt[];
88
113
  /** Non-persisted synchronous parent authority for cumulative live usage. */
@@ -234,6 +259,15 @@ export interface RunMartinInput {
234
259
  idFactory?: (prefix: string) => string;
235
260
  maxRecentAttempts?: number;
236
261
  fallbackAdapters?: MartinAdapter[];
262
+ /**
263
+ * Continue an unfinished persisted run under the same loop ID and authority.
264
+ * runMartin acquires the durable execution lease before any store persistence.
265
+ */
266
+ resume?: {
267
+ loop: LoopRecord;
268
+ preCandidateBoundary?: RollbackBoundaryArtifact;
269
+ lastVerifierFailure?: MartinAdapterRequest["context"]["lastVerifierFailure"];
270
+ };
237
271
  receiptScope?: ReceiptScope;
238
272
  /** Optional persistence store. When provided, runMartin writes artifacts on each lifecycle event. */
239
273
  store?: RunStore;
@@ -266,6 +300,21 @@ export declare function distillContext(loop: Pick<LoopRecord, "task" | "budget"
266
300
  maxRecentAttempts?: number;
267
301
  }): DistilledContext;
268
302
  export declare function runMartin(input: RunMartinInput): Promise<RunMartinResult>;
303
+ /**
304
+ * Sanitize verifier output before it is stored as a structured failure excerpt
305
+ * that will eventually appear in a provider prompt.
306
+ *
307
+ * Two-layer contract:
308
+ * Layer 1 (here, core): hard size cap + strip control characters and secrets.
309
+ * Layer 2 (adapter): sanitizeForPrompt removes prompt-injection patterns.
310
+ *
311
+ * Rules:
312
+ * - Keep tail (most recent lines are most relevant for repair).
313
+ * - Strip null bytes and C0/C1 control characters except \n and \t.
314
+ * - Hard cap at 1500 characters — large test output cannot flood the context.
315
+ * - Tag the excerpt so downstream consumers know it is untrusted evidence.
316
+ */
317
+ export declare function sanitizeVerifierExcerpt(raw: string): string;
269
318
  export { createDefaultExitPolicy, evaluateExitPolicy, hashProgressState, toLegacyExitDecision, validateExitPolicy } from "./exits.js";
270
319
  export type { ExitPolicyOverrides, LegacyExitDecision } from "./exits.js";
271
320
  export { SignalDiagnosticError, createFileExitSignalSource, exitSignalPath, readAllExitSignals, readExitSignal, startExitSignalMonitor, writeExitSignal } from "./exit-signal.js";