import type { DefinitionDigest } from "./definitions.ts"; import type { Capability } from "./resolve.ts"; export type JsonPrimitive = string | number | boolean | null; export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue; }; export interface AssuranceScope { type: "entire-run" | "selectors"; selectors: string[]; } /** * Non-authoritative workflow metadata copied onto runtime and ledger events. * * pi-daddy interprets only the pinned correlation wire contract: schema version 1.0 and the closed * assurance-scope shape. Labels, selector meanings, timestamps and sequence floors remain non-authoritative. * In particular, a digest-looking value here never substitutes for a digest computed by the planner. The * snake_case names are the wire vocabulary used by external controllers. */ export interface CorrelationMetadata { schema_version?: string; run_id?: string; task_id?: string; workspace_id?: string; context_id?: string; phase?: string; assurance?: string; assurance_effective?: string; policy_label?: string; assurance_source?: string; assurance_scope?: AssuranceScope; activated_at?: string; plan_digest?: string; definition_digest?: string; task_digest?: string; base_sha?: string; head_sha?: string; tree_sha?: string; event_seq?: number; last_change_seq?: number; last_authority_seq?: number; check_receipt_id?: string; } /** * Snapshot bounded JSON metadata so a caller cannot mutate a record after planning, and so nothing * unbounded or undeclared can reach the ledger through it. * * Refuses with a stable code rather than a bare `Error`: this is reachable from a model-facing tool * parameter on all three delegation tools, and it used to throw outside every try, producing a governed * refusal with no code and no ledger line at all (R-112). */ export declare function normaliseCorrelation(input: CorrelationMetadata | undefined): CorrelationMetadata | undefined; export declare function digestTask(task: string): string; export declare function digestCapabilities(capabilities: readonly Capability[]): string; /** Trusted, internally-computed scope of one gated approval. */ export interface ApprovalBinding { version: "1"; task_sha256: string; requested_sha256: string; effective_sha256: string; requested: Capability[]; effective: Capability[]; definition_sha256?: string; workspace_id?: string; context_id?: string; tree_sha?: string; last_change_seq?: number; parent_id: string; } /** * Builds the binding from TRUSTED values only. It deliberately does not take a `CorrelationMetadata`. * * It used to read `workspace_id` and `context_id` straight out of caller-supplied correlation into what * the comment above calls the trusted scope, and a bound approval could then be spent outside the * workspace it named (R-110): approve a delegation carrying a real, registry-validated `workspace` spec, * then re-issue the identical task with `correlation.workspace_id` set and NO `workspace` field — no * registry lookup, no lease, the parent's own cwd, and every digest still matching. The guard that would * have caught it can only fire when there is a spec to disagree with. * * `workspaceId` must therefore be the id of a workspace that was actually resolved and leased. * `contextId` is a caller-declared label that nothing validates; it is included because it can only * ever NARROW a binding, and a mismatch fails closed. */ export declare function buildApprovalBinding(input: { task: string; requested: readonly Capability[]; effective: readonly Capability[]; definitionSha256?: DefinitionDigest["sha256"] | string; parentId: string; /** Id of a workspace this delegation was actually routed to and holds a lease for. */ workspaceId?: string; /** Caller-declared label. Narrows only; never a claim that anything was enforced. */ contextId?: string; /** Optional upstream tree identity. When supplied, later approval use must match it exactly. */ treeSha?: string; /** Optional upstream change floor. When supplied, later approval use must match it exactly. */ lastChangeSeq?: number; }): ApprovalBinding; export declare function approvalBindingDigest(binding: ApprovalBinding): string; export declare function isApprovalBinding(value: unknown): value is ApprovalBinding; export declare function approvalBindingsEqual(a: ApprovalBinding | undefined, b: ApprovalBinding | undefined): boolean; //# sourceMappingURL=correlation.d.ts.map