/** * Structured diagnostic shape — see ADR-0008. Used uniformly across * static validation, boot-time, and runtime feedback. The public `test` * phase remains reserved for consumer-authored test diagnostics; Core's * shipped performance harnesses emit purpose-shaped reports instead. * * Codes are unprefixed UPPER_SNAKE strings; the `phase` field * disambiguates which loop emitted each diagnostic. The same `code` * may appear in multiple phases when it names the same root cause — * AI consumers can group by code OR filter by phase. * * `candidates` is security-sensitive at runtime; `redactForWire` * strips it before HTTP egress. */ export type Phase = "validate" | "test" | "boot" | "runtime"; /** * Closed catalog of diagnostic codes the SDK emits across all phases. * Per ADR-0008, spec **defines** the catalog; runtime / cli / adapters * **emit** them. Codes in the cross-phase and runtime-only sections * below are not raised by spec source — they live here because the * catalog is the public contract, not the union of what spec happens * to throw today. Adding a new code is a grammar-revise event * (ADR-0001). * * Single source of truth: the const array drives `DiagnosticCode` * (type), so adding a code is one edit. */ export declare const DIAGNOSTIC_CODES: readonly ["RESOURCE_EXHAUSTED", "RESOURCE_UNAVAILABLE", "RATE_LIMITED", "OUTCOME_UNKNOWN", "PARTIAL_FAILURE", "PRECONDITION_FAILED", "INVALID_MANIFEST_ENVELOPE", "DUPLICATE_NAME", "VIEW_FROM_UNKNOWN_SCHEMA", "VIEW_FIELD_NOT_IN_SCHEMA", "VIEW_FILTER_FIELD_NOT_IN_SCHEMA", "VIEW_PARAMS_INVALID_SHAPE", "VIEW_PARAMS_RESERVED_NAME", "VIEW_FILTER_PARAM_REF_UNKNOWN", "VIEW_FILTER_PARAM_REF_NOT_REQUIRED", "VIEW_FILTER_CTX_USER_REF_INVALID", "VIEW_FILTER_CTX_USER_REF_REQUIRES_AUTH", "VIEW_FILTER_CTX_USER_REF_REQUIRES_INDEX", "VIEW_ORDERBY_INVALID", "VIEW_CACHE_INVALID", "VIEW_PUBLIC_STATUS_INVALID", "VIEW_UI_INVALID", "REQUIRED_FIELD_UNKNOWN", "INVALID_PATTERN", "JSON_SCHEMA_UNSUPPORTED", "JSON_SCHEMA_REF_INVALID", "JSON_SCHEMA_LIMIT_EXCEEDED", "BIND_VALUE_NOT_IN_ENUM", "AUTH_PREDICATE_NOT_IN_ENUM", "GUARD_PROCEDURE_UNKNOWN", "GUARD_SELF_REFERENCE", "GUARD_PROCEDURE_BUILTIN", "GUARD_CHAIN_NOT_ALLOWED", "SCHEMA_INDEX_INVALID", "SCHEMA_INDEX_FIELD_UNKNOWN", "UNIQUE_INDEX_FIELD_UNKNOWN", "SCHEMA_SEARCH_INVALID", "SCHEMA_SEARCH_FIELD_UNKNOWN", "SCHEMA_UI_INVALID", "HANDLER_BUILTIN_NOT_IN_V010", "MANIFEST_ROOT_NOT_FOUND", "MANIFEST_READ_FAILED", "CODEGEN_IDENTIFIER_COLLISION", "FIXTURE_SCHEMA_VIOLATION", "HANDLER_NOT_REGISTERED", "TRIGGER_TARGET_PROCEDURE_UNKNOWN", "TRIGGER_PATH_COLLISION", "TRIGGER_PATH_INVALID", "MCP_TOOL_NAME_COLLISION", "MCP_TOOL_DESCRIPTION_MISSING", "MCP_TOOL_INPUT_UNREACHABLE", "MCP_TOOL_INPUT_UNION_AMBIGUOUS", "MCP_TOOL_INPUT_UNBOUNDED", "PROCEDURE_NOT_FOUND", "NOT_FOUND", "METHOD_NOT_ALLOWED", "VIEW_DIALECT_UNSUPPORTED", "BUILTIN_HANDLER_SCHEMA_UNKNOWN", "BUILTIN_HANDLER_CONTRACT_INVALID", "LIFECYCLE_SCHEMA_UNKNOWN", "LIFECYCLE_HOOK_REJECTED", "SCHEMA_LOCALIZED_REQUIRES_SITE_LOCALES", "TRANSLATES_PARENT_UNKNOWN", "TRANSLATES_REQUIRES_LOCALIZED", "TRANSLATES_REQUIRES_CONTENT_FIELD", "TRANSLATES_FIELD_NOT_IN_PARENT", "TRANSLATES_FIELD_NOT_IN_CHILD", "TRANSLATES_PARENT_IS_LOCALIZED", "INPUT_VALIDATION_FAILED", "UNAUTHENTICATED", "AUTH_DENIED", "ENTITLEMENT_REQUIRED", "CONFLICT", "DISPATCHER_NOT_BUILT", "INTERNAL_ERROR", "OUTPUT_VALIDATION_FAILED", "INVALID_LOCALE", "MEDIA_NOT_CONFIGURED", "MEDIA_UPLOAD_EXPIRED", "MEDIA_OBJECT_NOT_FOUND", "MEDIA_MIME_REJECTED", "MEDIA_SIZE_EXCEEDED", "MEDIA_SVG_REJECTED", "MEDIA_CHECKSUM_MISMATCH", "MEDIA_PURPOSE_REJECTED", "MEDIA_VARIANTS_INCOMPLETE", "MEDIA_VARIANT_SIZE_EXCEEDED", "MEDIA_VARIANTS_SUSPICIOUS_SIZE", "MEDIA_ASSET_NOT_FOUND"]; export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number]; export interface SourcePosition { readonly line: number; readonly column: number; readonly offset: number; } export interface SourceSpan { readonly start: SourcePosition; readonly end: SourcePosition; } /** Authored location retained independently from a rendered diagnostic path. */ export interface SourceLocation { readonly sourceId: string; readonly documentIndex: number; /** JSON Pointer inside the YAML document. */ readonly path: string; readonly span?: SourceSpan; } export interface Diagnostic { readonly code: DiagnosticCode; readonly phase: Phase; readonly severity: "error" | "warning"; readonly path: string; readonly source?: SourceLocation; readonly value?: unknown; readonly expected?: string; readonly candidates?: readonly string[]; readonly suggestion?: string; readonly message: string; /** Safe effect/retry facts supplied by a port; never provider payloads. */ readonly failure?: { readonly outcome: "not-applied" | "partial" | "unknown"; readonly retry: "never" | "after-change" | "safe" | "reconcile"; readonly resource?: string; }; } /** * HTTP status mapping for codes that surface on the wire (runtime * phase). Codes not in this map default to 500 when surfaced over * HTTP. Validate / test / boot phases don't map to HTTP — they * surface in CLI exit codes / thrown errors / Worker init logs. * * Narrowed to a status-literal union so adding a code with a status * outside the v0.1 set fails compile. */ export type RuntimeHttpStatus = 400 | 401 | 402 | 403 | 404 | 405 | 409 | 410 | 412 | 429 | 500 | 501 | 503 | 507; export declare const HTTP_STATUS_BY_CODE: Readonly>>; /** Resolve a Diagnostic's HTTP status for wire egress; unknown codes * default to 500. Lives in the kernel so every adapter shares one * mapping. */ export declare function httpStatusFor(d: Diagnostic): RuntimeHttpStatus; /** * Build a Diagnostic with a derived default `message`. Call sites may supply * contextual prose, but the structured fields remain authoritative. */ export declare function makeDiagnostic(input: Omit & { message?: string; }): Diagnostic; /** Phase-stamping helpers — equivalent to `makeDiagnostic({...input, phase})` * but read cleaner at call sites. `phase: "test"` has no Core helper because * the shipped performance harnesses emit purpose-shaped reports; the phase * remains part of the public Diagnostic contract for consumer tests. */ export declare const validateDiagnostic: (input: PhaselessInput) => Diagnostic; export declare const bootDiagnostic: (input: PhaselessInput) => Diagnostic; export declare const runtimeDiagnostic: (input: PhaselessInput) => Diagnostic; type PhaselessInput = Omit & { message?: string; }; /** * Throwable carrier for one or more Diagnostics. Layers that surface * an error across a transport boundary (HTTP handler, MCP tool call, * render pipeline) throw this so the boundary catch can detect a * structured payload and emit it on the wire instead of falling back * to the INTERNAL_ERROR envelope reserved for genuinely unexpected * throws. */ export declare class DiagnosticError extends Error { readonly diagnostics: readonly Diagnostic[]; constructor(diagnostic: Diagnostic | readonly Diagnostic[], options?: ErrorOptions); /** First diagnostic — convenience for single-diagnostic call sites. */ get diagnostic(): Diagnostic; } /** * Strip security-sensitive fields for wire egress. Per ADR-0008: * never expose `candidates` to untrusted callers — that leaks * schema information. Internal phases (validate / test / boot) * skip this redaction. */ export declare function redactForWire(d: Diagnostic): Diagnostic; /** * Walk a JSON Pointer (RFC 6901) on a value. Returns `undefined` for * any miss. Best-effort — used to surface the offending value inside * a diagnostic, not for strict pointer dereferencing. */ export declare function readJsonPointer(root: unknown, jsonPointer: string): unknown; export {}; //# sourceMappingURL=diagnostic.d.ts.map