/** * failure: typed taxonomy for every way a turn can fail, and the reduction * that collapses many observations into one self-sufficient summary on `done`. * * Provider-unavailable vs work-verdict is the load-bearing split: a provider- * unavailable failure (rate-limit, usage-limit, quota, auth, transport) reached * no verdict on the work, so routing the same work elsewhere is safe. A * work-verdict failure (task, budget) means the model did the work and the * work is wrong or incomplete - the router must NOT auto-route it elsewhere, * or it would hide a model error behind a retry. `rejected` is the library * refusing to build the call at all (unexpressible option, bad value); it is * non-retryable across the whole model chain because the remedy is different * options or a different harness, not a different model. */ import type { RefusalIssue } from "../interpretation/refusal.js"; import type { AuthFailureKind, DiscoveryFacet, HarnessDescriptor, LimitCode } from "../knowledge/descriptor.js"; import type { NativeApprovalFailure } from "../knowledge/native-approvals.js"; import type { Clock } from "./deps.js"; import type { LineOverflow } from "./lines.js"; export declare const FAILURE_CLASSES: readonly ["rate-limit", "usage-limit", "quota", "auth", "budget", "task", "transport", "unavailable", "rejected", "native", "timeout", "trust-refused", "internal"]; export type FailureClass = (typeof FAILURE_CLASSES)[number]; export interface FailureSummary { readonly nativeApproval?: import("../knowledge/native-approvals.js").NativeApprovalFailure; readonly class: FailureClass; readonly retryable: boolean; readonly message: string; readonly code?: LimitCode; readonly authKind?: AuthFailureKind; readonly resetsAt?: number; readonly issue?: RefusalIssue; readonly option?: import("../interpretation/refusal.js").RefusalOption; readonly facet?: DiscoveryFacet; readonly supported?: readonly string[]; /** D7: cross-harness support entries derived from descriptors. */ readonly supportedBy?: ReadonlyArray<{ harness: string; spelling: string; }>; /** D8: nearest-alternative hint for the current harness. */ readonly hint?: string; /** D6: the harness process's own exit code for a native failure - data, * because native conventions differ from hcn's (codex usage errors exit * 2, which hcn reserves for refusals). */ readonly nativeExitCode?: number; } export declare const retryableOf: (cls: FailureClass) => boolean; /** Stray secret-shaped tokens are masked; identifiers (session UUIDs, model * ids, paths) log verbatim - they are what the log exists to correlate. */ export declare const SECRETISH: RegExp; /** Replace every secret-shaped token with `[redacted]`. */ export declare const redactSecrets: (text: string) => string; /** Redact before slicing to `max`: a credential split by the bound is too * short for `SECRETISH` to match, so redacting after the bound would leak * the cut end. */ export declare const redactBounded: (text: string, max: number) => string; export declare const failureFromTimeout: () => FailureSummary; /** A runtime error headline, distinct from its indented stack frames. */ export declare const isStderrErrorHeadline: (line: string) => boolean; /** D6: a failure that belongs to the harness, not hcn. Prefers the first * Error headline, otherwise the last three stderr lines. Detail is redacted * and bounded; the native exit code is data. */ export declare const failureFromNative: (nativeExitCode: number | null, stderrTail: readonly string[]) => FailureSummary; /** hcn's own bug: the crash tier. Terminal and non-retryable; the process * exits 4 and (in a --json stream) the failure/done pair follows. */ export declare const failureFromInternal: (detail: string) => FailureSummary; /** A limit, from a wall phrasing (detail defaults to the code) or from a * structured record that names its status and, sometimes, a reset time. */ export declare const failureFromLimit: (code: LimitCode, detail?: string, resetsAt?: number) => FailureSummary; export declare const failureFromAuth: (kind: AuthFailureKind) => FailureSummary; /** Whether a summary is a limit failure (rate-limit, usage-limit, quota): * the classes a limit wall decodes to. Consumers that classify outside the * limit-event path use this to record the wall the same way. */ export declare const isLimitFailure: (failure: FailureSummary) => boolean; /** The reset time a limit wall's own text states, resolved against the * clock's zone. Undefined when the line states none, when no clock is * given, or when the clock cannot place a local timestamp. */ export declare const resetsAtInLine: (line: string, clock: Pick | undefined) => number | undefined; /** A terminal error the harness reported on its stream: classify by what * it says. An auth wall, a limit wall, or a transport fault reached no * verdict on the work (retryable); anything else is the model's own * failure (task). A limit wall whose prose states a reset time carries * `resetsAt` when a clock is supplied; without one it does not. */ export declare const failureFromTerminalError: (h: HarnessDescriptor, message: string, clock?: Pick) => FailureSummary; /** No work ran, so a work verdict (task) is wrong; walls keep their class. */ export declare const failureFromNativeRejection: (h: HarnessDescriptor, message: string, clock?: Pick) => FailureSummary; export declare const failureFromTask: (detail?: string) => FailureSummary; export declare const failureFromBudget: (detail?: string) => FailureSummary; export declare const failureFromTransport: (detail?: string) => FailureSummary; /** A harness output line longer than hcn's line bound. hcn discarded it, so * whatever it carried - often the whole reply - never reached the caller. * Transport family: hcn could not carry the harness's output, which is no * verdict on the work, so a retry or another route is safe. */ export declare const failureFromLineOverflow: (stream: "stdout" | "stderr", overflow: LineOverflow) => FailureSummary; /** Short detail shared by the blocked-approval error event and failure. * Issue #189: a sandbox escalation (the command asked to run outside the * harness shell sandbox) says so in the detail, so the failure can name * the narrow sandbox-network remedy instead of only --autonomy. */ export declare const blockedApprovalDetail: (harness: import("../knowledge/descriptor.js").HarnessName, subject: "approval" | "input", kind: string, sandboxEscalation: boolean) => string; /** Issue #179: the harness waits on a native approval (or user-input * request) that a headless run can never answer - muse exec omits pending * approvals from stdout, so without observation the turn hangs until * --timeout. A task failure, non-retryable: the remedy is answering in the * harness, or --autonomy only when unattended approvals are acceptable - * never auto-routing the same work elsewhere. The subject kind names the * blocked subject (network, shell, fileAccess, process, tool, or user * input); native payload values (commands, hosts, paths) are never copied * here. Issue #189: a sandbox escalation (sandboxEscalation true) names a * narrow remedy first - the sandbox-network passthrough keeps approvals * and the filesystem sandbox and fits a command that needs network or a * local listening socket - because --autonomy renders muse's --yolo, * which turns off approvals, the sandbox, and workspace trust together. * The ordinary text is unchanged. */ export declare const failureFromBlockedApproval: (harness: import("../knowledge/descriptor.js").HarnessName, subject: "approval" | "input", kind: string, sandboxEscalation: boolean) => FailureSummary; /** The observer itself failed (helper spawn, helper crash, repeated * unreadable samples): the pending set is unknown, never empty. Fail * closed - a turn hcn cannot supervise must not hang silently until * --timeout. A transport failure, retryable: hcn's own supervision broke, * not the model's work, so routing the same work elsewhere is safe. */ export declare const failureFromApprovalUnobserved: (harness: import("../knowledge/descriptor.js").HarnessName) => FailureSummary; export declare const failureFromUnavailable: (detail?: string) => FailureSummary; /** L5: the installed muse helper speaks an MSP surface hcn cannot use * (an operation or the handshake was rejected as unknown). Classed * `native`, not `transport`: per ADR 0001 the harness failing on hcn's * own protocol call is a harness-side failure, not a verdict on the * model's work (`task`) and not hcn refusing to build the call * (`rejected`). Native is non-retryable, so a caller that retries the * same muse route cannot loop the way retryable transport would - the * remedy is a newer hcn, a different harness, or --autonomy, never the * same call again. */ export declare const failureFromMuseIncompatibleSurface: (harness: import("../knowledge/descriptor.js").HarnessName, verifiedAgainst: string, method: string, code: number | null) => FailureSummary; /** RFC-05: Cursor refused an untrusted workspace before any inference ran. * Retryable derives true from the provider-unavailable family; the * messageFor arm names the remedy. * RFC-06 Phase 5 ordering note: on `--continue` the no-session check * (`No previous chats found.`, exit 1) fires before the trust gate, so a * resume-last turn in an untrusted empty cwd fails as native, never * trust-refused. That stderr never matches trustMatchers; it falls * through to the native arm with verbatim stderr. */ export declare const failureFromTrust: (detail?: string) => FailureSummary; /** The post-queue nonzero-exit tail scan (stream-turn.ts): transport first, * then unavailable, then the trust gate, then the native fallthrough, and * transport on an empty tail (a silent nonzero exit reads as environment, * not harness judgment). One owner so the precedence is unit-tested * directly; the supervisor per-line check usually fires first, so the * trust arm here is defense-in-depth. */ export declare const failureFromStderrTail: (h: HarnessDescriptor, exitCode: number | null, tail: readonly string[]) => FailureSummary; export declare const nativeApprovalPreflightEvidence: (issue: RefusalIssue) => NativeApprovalFailure; export declare const failureFromRejected: (opts: { issue: RefusalIssue; option?: import("../interpretation/refusal.js").RefusalOption; facet?: DiscoveryFacet; supported?: readonly string[]; supportedBy?: ReadonlyArray<{ harness: string; spelling: string; }>; hint?: string; detail?: string; }) => FailureSummary; export declare const reduceFailures: (failures: readonly FailureSummary[]) => FailureSummary | undefined; //# sourceMappingURL=failure.d.ts.map