/** * DocumentGraph addressing + validation kernel. * * The ONLY mint site for DocumentGraph node and graph ids — exactly as * `makeEntityId` (composable.ts) is the only mint site for `EntityId`. Routes * through the shared `content-address.ts` kernel so the fnv1a identity law * cannot diverge from the EntityId/BoundaryDef law. The graph-level integrity * digest is the paired `AddressedDigest` (sha256) over the SAME bytes, so the * two laws (identity vs receipt) cannot disagree. * * Structural validation (cycle + dangling-edge integrity) and topological * linearization REUSE `Plan.validate` / `Plan.topoSort` by lifting the graph to * a synthetic `PlanIR` over node-id endpoints — no reimplementation. * * @module */ import type { ContentAddress, AddressedDigest } from './brands.js'; import type { PlanValidationError } from './plan.js'; import type { DocumentGraph as DocGraph, DocumentGraphNode, DocumentGraphEdge } from './document-graph.js'; /** * Mint the content address for a node: `fnv1a` over the canonical CBOR of the * payload, EXCLUDING the `id` (derived) and the volatile `meta` (HLC/version). * Structurally-equal nodes therefore dedup across graphs and over time. */ export declare function addressNode(node: DocumentGraphNode): ContentAddress; /** Return a copy of the node with its `id` set to the correct content address. */ export declare function sealNode(node: N): N; /** Authoring parts for a {@link DocumentGraphNode} before addressing — `id` is ignored. */ export type DocumentGraphNodeParts = Omit & { readonly id?: ContentAddress; }; /** * Build a sealed {@link DocumentGraphNode} from authoring parts — mints `id` via * `addressNode` / {@link sealNode}. Graph-level `digest` is minted by * {@link sealGraph}, not here. */ export declare function nodeFromParts(parts: DocumentGraphNodeParts): N; /** * Mint the graph identity (`id`, fnv1a) + integrity digest (`digest`, * fnv1a+sha256) over the SAME canonical bytes: the sorted node ids + sorted * edges. Re-ordering authoring does not fork identity (the graph is a canonical * multiset); node payloads are covered transitively because each node id is * itself a content address of its payload. */ export declare function addressDocumentGraph(graph: { readonly nodes: readonly DocumentGraphNode[]; readonly edges: readonly DocumentGraphEdge[]; }): { readonly id: ContentAddress; readonly digest: AddressedDigest; }; /** Return a copy of the graph with `id` + `digest` set to the correct addresses. */ export declare function sealGraph(graph: Omit): DocGraph; /** Validate structural integrity: no cycles, every edge endpoint references an existing node. Reuses `Plan.validate`. */ export declare function validateGraph(graph: { readonly nodes: readonly DocumentGraphNode[]; readonly edges: readonly DocumentGraphEdge[]; }): { readonly ok: true; } | { readonly ok: false; readonly errors: readonly PlanValidationError[]; }; /** * Topologically order the node ids (Kahn's algorithm via `Plan.topoSort`). * `cycle` is populated with the participating node ids when the graph is cyclic. */ export declare function linearizeGraph(graph: { readonly nodes: readonly DocumentGraphNode[]; readonly edges: readonly DocumentGraphEdge[]; }): { readonly sorted: readonly ContentAddress[]; readonly cycle?: readonly ContentAddress[]; }; /** * VERSION-AWARE, FAIL-CLOSED reader for an UNTRUSTED DocumentGraph value (a graph * lowered from persisted JSON / a wire payload). `sealGraph` only re-mints ids; it * does NOT verify the envelope `_tag`/`_version` or that every node is well-formed. * A host that reconstructs a graph from outside the program must run it through * THIS gate first, so a future-version (`_version: 2`) or malformed graph is * rejected with ONE canonical tagged `ParseError` — never silently misparsed * into a v1 shape. "Written data needs a reader": this is the graph envelope's * fail-closed reader, the twin of {@link isWellFormedNode}'s per-node gate. * * @throws `ParseError` (`source: 'DocumentGraph'`) when the value is not a * record, carries the wrong `_tag`, an unsupported `_version`, or a node that * fails the {@link isWellFormedNode} trust gate. */ export declare function decodeDocumentGraph(value: unknown): DocGraph; //# sourceMappingURL=document-graph-address.d.ts.map