import { type ApprovalPolicy, type AgentExecutionIntent, type ContextHandoffReceipt, type CostProvenance, type ExecutionProfile, type FailureClass, type InterventionType, type LoopArtifact, type LoopAttempt, type LoopBudget, type ProviderUsageSettlement, type MutationMode, type LoopRecord, type LoopTask, type ReceiptScope } from "../contracts/index.js"; import { classifyFailure, computeEvidenceVector, evaluatePatchDecision, evaluateCostGovernor, evaluateBudgetPreflight, inferExit, nextPolicyPhase, policyPhaseToLifecycleState, scorePatchDecision, selectRecoveryRecipe, type ExitDecision } from "./policy.js"; import { evaluateChangeApprovalLeash, evaluateFilesystemLeash, evaluateSecretLeash, redactSecretsFromText, resolveExecutionProfile, evaluateVerificationLeash } from "./leash.js"; import { buildRepoGroundingIndex, loadOrBuildRepoGroundingIndex, queryRepoGroundingIndex, scanPatchForGroundingViolations } from "./grounding.js"; import { captureRollbackBoundary, listAttemptChangedFilesSinceBoundary, restoreRollbackBoundary } from "./rollback.js"; import { type RunStore } from "./persistence/index.js"; import { type ExitPolicyOverrides } from "./exits.js"; import { type ExitSignalSource } from "./exit-signal.js"; import { type VerifierExecutionBinding } from "./verified-handoff.js"; 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"; export { DEFAULT_AGENT_EXECUTION_INTENT, DEFAULT_PROVIDER_EXECUTION_TIMEOUT_MS, GOVERNED_AUTONOMOUS_BOUNDARY, normalizeProviderExecutionTimeoutMs } from "../contracts/index.js"; export { classifyFailure, computeEvidenceVector, evaluatePatchDecision, evaluateCostGovernor, evaluateBudgetPreflight, inferExit, nextPolicyPhase, policyPhaseToLifecycleState, scorePatchDecision, selectRecoveryRecipe, evaluateVerificationLeash, evaluateFilesystemLeash, evaluateChangeApprovalLeash, evaluateSecretLeash, resolveExecutionProfile, redactSecretsFromText, buildRepoGroundingIndex, loadOrBuildRepoGroundingIndex, queryRepoGroundingIndex, scanPatchForGroundingViolations, captureRollbackBoundary, listAttemptChangedFilesSinceBoundary, restoreRollbackBoundary }; export type { BudgetPreflightDecision, BudgetPreflightInput, CostGovernorState, EvidenceVectorInput, EvaluatedPatchDecision, ExitDecision, FailureAssessment, PatchDecisionInput, RecoveryDecision, RecoveryRecipe } from "./policy.js"; export type { ResolvedExecutionProfile, SafetyLeashDecision, SafetyViolation } from "./leash.js"; export type { GroundingScanResult, GroundingViolation, GroundingViolationKind, RepoGroundingHit, RepoGroundingIndex } from "./grounding.js"; export { buildContextGraphSnapshot, queryContextGraph } from "./context-graph.js"; export { createLocalIdentityAuthority, hasIdentityScope, issueIdentityToken, verifyIdentityToken } from "./identity.js"; export type { LocalIdentityAuthority } from "./identity.js"; export { compileExecutionPolicy } from "./policy-compiler.js"; export { assessTrajectory, decideCircuitBreak } from "./trajectory.js"; export { calculateAvoidedUsd, calculateLoopAvoidedUsd } from "./savings.js"; export type { AvoidedUsdInput } from "./savings.js"; export { classifyRoute, evaluatePreworkBurnPolicy } from "./routing.js"; export type { RouteDecision, RouteClassificationInput } from "./routing.js"; export { validateTestIntegrity, snapshotTestFiles, identifyNewTests, findTestFiles, isTestFile, extractImports, hasTrivialAssertionsOnly, importsPreExistingCode } from "./test-integrity.js"; export type { TestIntegrityReport, TestIntegrityFinding } from "./test-integrity.js"; export { analyzeRepoStyle, buildPromptDirectives } from "./repo-analyzer.js"; export type { RepoStyleProfile } from "./repo-analyzer.js"; export { runContextIntegrityPrecheck } from "./context-integrity.js"; export type { ContextIntegrityPrecheck, ContextIntegrityVerdict } from "./context-integrity.js"; export { compilePromptPacket } from "./compiler.js"; export type { PromptPacket, CompilerAdapterRequest } from "./compiler.js"; export { buildVerifiedHandoff, deriveVerifiedHandoffExecutionBoundary, resolveVerifiedHandoffOutcome, toTestIntegrityVerdict, verifierActuallyPassed, } from "./verified-handoff.js"; export type { BoundVerifierEvidence, BuildVerifiedHandoffInput, VerifierExecutionBinding, } from "./verified-handoff.js"; export { createFileRunStore, makeLedgerEvent, readAllLoopRecords, readLatestLoopRecord, readLatestLoopRecordFromFile, readLoopRecordsFromFile, resolveRunsRoot, resolveReceiptIntegrityPath, verifyReceiptIntegrityFromFiles, writeReceiptIntegrityMaterial } from "./persistence/index.js"; export type { AttemptArtifacts, LedgerEvent, LedgerEventKind, LoopAttemptRecord, LoopRunRecord, ReceiptIntegrityChainEntry, RunContract, RunStore, StoredReceiptIntegrityMaterial } from "./persistence/index.js"; export { compileAndPersistContext } from "./persistence/index.js"; export type { CompileResult } from "./persistence/index.js"; export { compileContextShadow, estimateContextTokens } from "./context-shadow.js"; export type { CompileContextShadowInput, CompileContextShadowResult, ContextShadowSegment } from "./context-shadow.js"; export { compileContext, HEURISTIC_ADAPTER, MAX_RENDER_PASSES } from "./context-compiler.js"; export type { CompileContextInput, CompileContextOutput, ContextAdapter } from "./context-compiler.js"; export { verifyContextHandoff, decideContextCircuitBreak } from "./context-handoff.js"; export type { VerifyContextHandoffInput } from "./context-handoff.js"; export { evaluateChainGate, renderGatePrComment } from "./context-chain-gate.js"; export type { ChainGateConfig, ChainGateCost, ChainGateConclusion, ChainGateInput, ChainGateResult, GatePrCommentOptions } from "./context-chain-gate.js"; export { appendMemory, readMemoryEntries, getPreference, buildMemorySummary, recordPreference, recordConsent } from "./persistence/memory-store.js"; export type { MemoryEntry, MemoryKind, MemorySummary } from "./persistence/memory-store.js"; export { appendTraceEntry, readTraceEntries, aggregateTraces, getHistoricalDirectSuccessRate } from "./persistence/trace-store.js"; export type { TraceEntry, TraceAggregation } from "./persistence/trace-store.js"; export interface MartinAdapterRequest { loopId: string; workspaceId: string; attemptId: string; context: { taskTitle: string; objective: string; verificationPlan: string[]; verificationStack?: LoopTask["verificationStack"]; mutationMode?: MutationMode; definitionOfDonePreSatisfied?: boolean; /** Absolute path to the repository root. */ repoRoot?: string; /** Glob patterns for files the agent may modify. Empty = no restriction. */ allowedPaths?: string[]; /** Glob patterns for files the agent must never modify. */ deniedPaths?: string[]; /** Human-readable acceptance criteria injected into the prompt. */ acceptanceCriteria?: string[]; executionProfile?: ExecutionProfile; allowedNetworkDomains?: string[]; approvalPolicy?: ApprovalPolicy; agentExecutionIntent?: AgentExecutionIntent; providerExecutionTimeoutMs?: number; focus: string; remainingBudgetUsd: number; remainingIterations: number; remainingTokens?: number; }; previousAttempts: LoopAttempt[]; /** Abort signal propagated from the harness — adapters should honour it. */ signal?: AbortSignal; } export interface MartinVerificationStep { command: string; launched: boolean; completed?: boolean; crashed?: boolean; exitCode?: number; timedOut: boolean; fastFail?: boolean; detail?: string; } export interface MartinVerificationOutcome { passed: boolean; summary: string; steps?: MartinVerificationStep[]; warnings?: string[]; binding?: VerifierExecutionBinding; } export interface MartinAdapterResult { status: "completed" | "failed"; summary: string; usage: { actualUsd: number; estimatedUsd?: number; tokensIn: number; tokensOut: number; cachedInputTokens?: number; reasoningTokensOut?: number; provenance?: CostProvenance; providerSettlement?: ProviderUsageSettlement; }; verification: { passed: boolean; summary: string; steps?: MartinVerificationStep[]; warnings?: string[]; binding?: VerifierExecutionBinding; }; execution?: { changedFiles?: string[]; diffStats?: { filesChanged: number; addedLines: number; deletedLines: number; }; structuredErrors?: Array<{ file: string; line?: number; col?: number; code?: string; message: string; }>; }; artifacts?: LoopArtifact[]; failure?: { message: string; classHint?: FailureClass; }; } export interface MartinAdapter { adapterId: string; kind: "direct-provider" | "agent-cli"; label: string; metadata: { providerId: string; model?: string; transport?: "cli" | "http" | "routed_http"; capabilities?: { preflight?: boolean; usageSettlement?: boolean; diffArtifacts?: boolean; structuredErrors?: boolean; cachingSignals?: boolean; workspaceMutations?: boolean; }; [key: string]: unknown; }; execute(request: MartinAdapterRequest): Promise; } export interface DistilledContext { focus: string; recentAttempts: LoopAttempt[]; constraints: { remainingBudgetUsd: number; remainingIterations: number; remainingTokens?: number; }; } export interface AttemptPolicyDecision { allowed: boolean; reason: string; recommendedIntervention?: InterventionType; trajectoryAssessment?: import("../contracts/index.js").TrajectoryAssessment; circuitBreakDecision?: import("../contracts/index.js").CircuitBreakDecision; } /** * Admission gate — must pass before any attempt is executed. * Evaluates budget headroom, oscillation, and repetitive failure patterns. * PolicyPhase remains explicit: attempts are only admitted in ADMIT phase. */ export declare function evaluateAttemptPolicy(input: { request: MartinAdapterRequest; projectedUsd: number; }): AttemptPolicyDecision; export interface RunMartinInput { workspaceId: string; projectId: string; teamId?: string; task: LoopTask; budget: LoopBudget; metadata?: Record; adapter: MartinAdapter; now?: () => string; idFactory?: (prefix: string) => string; maxRecentAttempts?: number; fallbackAdapters?: MartinAdapter[]; receiptScope?: ReceiptScope; /** Optional persistence store. When provided, runMartin writes artifacts on each lifecycle event. */ store?: RunStore; /** Overrides for the default eight-exit policy derived from budget. */ exitPolicy?: ExitPolicyOverrides; /** Source for durable cancellation/external-event signals. */ exitSignalSource?: ExitSignalSource; /** Poll interval for the signal monitor in ms (default 250). */ exitSignalPollIntervalMs?: number; /** Clock override for testing (default Date.now). */ nowMs?: () => number; /** When provided, runMartin verifies the handoff before invoking the adapter. */ contextHandoff?: ContextHandoffReceipt; /** true when the producer receipt file hash has been independently confirmed. */ producerReceiptVerified?: boolean; /** Map of sha256 → true for every artifact available to the verifier. */ availableArtifacts?: ReadonlyMap; } export interface RunMartinResult { loop: LoopRecord; decision: ExitDecision; } export declare function distillContext(loop: Pick, options?: { maxRecentAttempts?: number; }): DistilledContext; export declare function runMartin(input: RunMartinInput): Promise; export { createDefaultExitPolicy, evaluateExitPolicy, hashProgressState, toLegacyExitDecision, validateExitPolicy } from "./exits.js"; export type { ExitPolicyOverrides, LegacyExitDecision } from "./exits.js"; export { SignalDiagnosticError, createFileExitSignalSource, exitSignalPath, readAllExitSignals, readExitSignal, startExitSignalMonitor, writeExitSignal } from "./exit-signal.js"; export type { ExitSignalSource, SignalDiagnostic, SignalReadResult } from "./exit-signal.js"; export { cacheMessage, fetchSelectedMessage, getCliInstalledVersion, getMcpInstalledVersion, isCooldownExpired, isDismissed, isNewerVersion, loadDeliveryRecord, parseMessageSelectionResponse, recordDismissed, recordShown, resolveDefaultLedgerPath, saveDeliveryRecord, } from "./delivery/index.js"; export type { MessageClientOptions, MessageSelectRequest, ParseFailure, ParseResult, ValidationError, } from "./delivery/index.js";