/** * Versioned, provider-neutral artifacts for the Human-to-Code pipeline. * * This module deliberately has no dependency on an LLM SDK. Artifacts are * plain JSON values, are validated with an exact-key policy, and are hashed * using a canonical representation so they can be persisted and audited. */ export declare const ARTIFACT_SCHEMA_VERSION: 1; export type JsonPrimitive = string | number | boolean | null; export type JsonValue = JsonPrimitive | JsonValue[] | { readonly [key: string]: JsonValue; }; /** Canonical JSON (RFC 8785-style key ordering, with stricter JSON inputs). */ export declare function canonicalJson(value: unknown): string; export declare function sha256Text(text: string): string; export declare function sha256Bytes(bytes: Uint8Array): string; export declare function hashCanonical(value: unknown): string; export type RunStatus = "VERIFIED" | "NEEDS_INPUT" | "UNSUPPORTED" | "INCONCLUSIVE" | "FAILED" | "SECURITY_BLOCKED"; export type PatchOperationKind = "create" | "edit" | "delete" | "rename"; export type RiskCategory = "dependency_change" | "lockfile_change" | "database_migration" | "public_api_break" | "authentication_change" | "unsafe_rust" | "ffi" | "validation_config_change"; export interface FileDigestV1 { path: string; sha256: string; } export interface RequirementV1 { id: string; description: string; } export interface AcceptanceCriteriaV1 { automated: string[]; manual: string[]; } export interface ChangeScopeV1 { allowedPaths: string[]; allowedOperations: PatchOperationKind[]; prohibitedPaths: string[]; } export interface RiskAssessmentV1 { category: RiskCategory; reason: string; } export interface UnresolvedQuestionV1 { id: string; question: string; material: boolean; } export interface ChangeContractV1 { schemaVersion: 1; source: FileDigestV1; projectFingerprint: string; targetWorkspaces: string[]; targetSymbols: string[]; requirements: RequirementV1[]; acceptanceCriteria: AcceptanceCriteriaV1; scope: ChangeScopeV1; prohibitedChanges: string[]; risks: RiskAssessmentV1[]; authorizedRisks: RiskCategory[]; unresolvedQuestions: UnresolvedQuestionV1[]; } export interface CreatePatchOperationV1 { kind: "create"; path: string; content: string; } export interface EditPatchOperationV1 { kind: "edit"; path: string; baseHash: string; oldText: string; newText: string; } export interface DeletePatchOperationV1 { kind: "delete"; path: string; baseHash: string; } export interface RenamePatchOperationV1 { kind: "rename"; from: string; path: string; baseHash: string; } export type PatchOperationV1 = CreatePatchOperationV1 | EditPatchOperationV1 | DeletePatchOperationV1 | RenamePatchOperationV1; /** Backwards-compatible short name used by patch preparation code. */ export type PatchOperation = PatchOperationV1; export interface PatchSetV1 { schemaVersion: 1; contractHash: string; snapshotHash: string; operations: PatchOperationV1[]; requirementIds: string[]; proposedTests: string[]; } export type ValidationCategory = "format" | "lint" | "typecheck" | "test" | "build" | "integration" | "security"; export interface ValidationCommandV1 { id: string; argv: string[]; cwd: string; timeoutMs: number; required: boolean; category: ValidationCategory; } export interface ValidationPlanV1 { schemaVersion: 1; profileFingerprint: string; commands: ValidationCommandV1[]; manualChecks: string[]; } export type ValidationCommandStatus = "passed" | "failed" | "skipped" | "error"; export interface ValidationCommandResultV1 { id: string; status: ValidationCommandStatus; exitCode: number | null; signal: string | null; durationMs: number; stdout: string; stderr: string; timedOut: boolean; flaky: boolean; outputTruncated: boolean; startedAt: string; finishedAt: string; } export interface RepairAttemptV1 { attempt: number; diagnostics: string[]; patchHash?: string; } export interface ManualCheckResultV1 { description: string; status: "passed" | "failed" | "pending" | "not_applicable"; evidence?: string; } export interface ValidationReportV1 { schemaVersion: 1; status: "validated" | "non_regression_only" | "unvalidated" | "failed"; sandbox: "strong" | "degraded" | "none"; baseline: ValidationCommandResultV1[]; candidate: ValidationCommandResultV1[]; repairs: RepairAttemptV1[]; manualChecks: ManualCheckResultV1[]; diagnostics: string[]; startedAt: string; finishedAt: string; } export interface ProviderIdentityV1 { name: string; requestedModel: string; resolvedModel: string; requestIds: string[]; } export interface UsageSummaryV1 { inputTokens: number; outputTokens: number; totalTokens: number; requests: number; repairs?: number; costUsd?: number; } export interface RunRecordV1 { runId: string; schemaVersion: 1; createdAt: string; updatedAt: string; root: string; status: RunStatus; contractHash?: string; contextManifestHash?: string; patchHash?: string; validationReportHash?: string; provider?: ProviderIdentityV1; usage?: UsageSummaryV1; diagnostics: string[]; } export interface ValidationIssue { path: string; code: "TYPE" | "UNKNOWN_KEY" | "MISSING" | "VALUE" | "DUPLICATE" | "UNRESOLVED" | "UNAUTHORIZED" | "OUT_OF_SCOPE"; message: string; } export declare class ArtifactValidationError extends Error { readonly issues: readonly ValidationIssue[]; constructor(issues: readonly ValidationIssue[]); } /** Paths in contracts and patches are always root-relative POSIX paths. */ export declare function isSafeRelativePath(path: string, allowPattern?: boolean): boolean; export declare function validateChangeContractV1(value: unknown): ChangeContractV1; /** Paths that no reviewed contract is allowed to expose or mutate. */ export declare function isHardProtectedPatchPath(path: string): boolean; /** Conservative, deterministic risk inference for patch authorization. */ export declare function inferPatchRisks(operation: PatchOperationV1): RiskCategory[]; export declare function validatePatchSetV1(value: unknown, contract?: ChangeContractV1): PatchSetV1; export declare function validateValidationPlanV1(value: unknown): ValidationPlanV1; export declare function validateValidationReportV1(value: unknown): ValidationReportV1; export declare function validateRunRecordV1(value: unknown): RunRecordV1; //# sourceMappingURL=contracts.d.ts.map