import type { GoldenTrace, GoldenTraceDecision } from '../golden-trace.js'; import type { ReplayEvaluateFn } from '../golden-trace-replay-validator.js'; import type { RuleHostDecision } from './rule-host-contracts.js'; import type { ToolSemanticRegistry } from './tool-semantic-registry.js'; export type RefinerSandboxErrorType = 'forbidden_pattern' | 'syntax_error' | 'runtime_error' | 'timeout' | 'validation_failed' | 'unknown'; export interface RefinerSandboxFailedCase { caseId: string; errorType: RefinerSandboxErrorType; message: string; stack?: string; /** * PRI-634 PR-A: the trace case's expected decision. Present on every REAL * trace-case failure (timeout / throw / mismatch); absent on system * sentinel failures (__compile__ / __return_shape__ / …) which have no * trace identity. This is the authoritative expected/actual pairing for * replay evidence — it supersedes reconstructing the pair from the * adversarial-case list, which cannot see merged positive-case failures. */ expectedDecision?: GoldenTraceDecision; /** * PRI-634 PR-A: the decision the rule actually returned. Present ONLY when * evaluate() produced a well-formed decision that mismatched the expected * one. Absent for timeouts, throws, and null results — an errorType is * never a decision value (SPEC §14 actualDecision semantic fix). */ actualDecision?: RuleHostDecision; } export interface RefinerSandboxResult { success: boolean; failedCases: RefinerSandboxFailedCase[]; executionTimeMs: number; forbiddenPatternViolations: string[]; } export interface RefinerSandboxOptions { /** Elapsed-time classification threshold (NOT hard cancellation). See evaluateInRefinerSandbox JSDoc. */ softTimeoutMs?: number; /** * PRI-634-F Phase 2: the ToolSemanticRegistry used by the production gate. * When provided, replay synthetic inputs resolve canonicalKind and * bash/write extraction hints from the SAME registry, closing the * replay/production divergence (baseline: replay built every input with * no hints, so bash command extraction never fired and normalizedPath * stayed null). Absent → legacy behavior. */ toolSemantics?: ToolSemanticRegistry; /** * PRI-634-F Phase 2: workspace root for path normalization. The production * gate normalizes against the live workspace dir; replay normalizes against * this. Same root + same pure function ⇒ identical normalizedPath for * every case shape (absolute-under-root relativizes, escape paths return * as-is, relative paths and synthetic paths are root-invariant). */ projectDir?: string; } export interface RefinerSandboxDependencies { evaluateCode?: ReplayEvaluateFn; } export declare const DEFAULT_TIMEOUT_MS = 5000; export declare const MAX_TIMEOUT_MS = 30000; /** * Evaluate rule code against GoldenTrace cases with structured error reporting. * * **Timeout semantics**: `softTimeoutMs` is an elapsed-time classification * threshold, NOT a hard cancellation mechanism. If `evaluateCode` blocks * synchronously (infinite loop, long computation), this wrapper cannot * interrupt it — the timeout is only detected after `evaluateCode` returns. * Hard cancellation requires `node:vm` or `AbortController` at the * plugin/sandbox-adapter layer, which is out of scope for core. */ export declare function evaluateInRefinerSandbox(code: string, goldenTrace: GoldenTrace, deps: RefinerSandboxDependencies & RefinerSandboxOptions): RefinerSandboxResult; //# sourceMappingURL=refiner-sandbox-wrapper.d.ts.map