@panproto/core 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -10
- package/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/migration.d.ts +5 -3
- package/dist/migration.d.ts.map +1 -1
- package/dist/msgpack.d.ts.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm.d.ts +4 -0
- package/dist/wasm.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/wasm.ts","../src/msgpack.ts","../src/lens.ts","../src/check.ts","../src/schema.ts","../src/protocol.ts","../src/migration.ts","../src/instance.ts","../src/io.ts","../src/vcs.ts","../src/panproto.ts","../src/gat.ts"],"sourcesContent":["/**\n * Core type definitions for the @panproto/core SDK.\n *\n * These types mirror the Rust-side structures but use JavaScript idioms:\n * - `HashMap<K,V>` becomes `Map<K,V>` or `Record<string, V>` for string keys\n * - `Option<T>` becomes `T | undefined`\n * - `Vec<T>` becomes `T[]`\n * - `Result<T,E>` becomes thrown `PanprotoError` or return value\n *\n * @module\n */\n\n// ---------------------------------------------------------------------------\n// Handle types (opaque wrappers — never expose raw u32)\n// ---------------------------------------------------------------------------\n\n/** Opaque handle to a WASM-side resource. */\nexport interface Handle {\n readonly __brand: unique symbol;\n readonly id: number;\n}\n\n/** Branded handle for a protocol resource. */\nexport interface ProtocolHandle extends Handle {\n readonly __kind: 'protocol';\n}\n\n/** Branded handle for a schema resource. */\nexport interface SchemaHandle extends Handle {\n readonly __kind: 'schema';\n}\n\n/** Branded handle for a compiled migration resource. */\nexport interface MigrationHandle extends Handle {\n readonly __kind: 'migration';\n}\n\n// ---------------------------------------------------------------------------\n// Protocol\n// ---------------------------------------------------------------------------\n\n/** Rule constraining which vertex kinds an edge can connect. */\nexport interface EdgeRule {\n readonly edgeKind: string;\n /** Allowed source vertex kinds. Empty array means any. */\n readonly srcKinds: readonly string[];\n /** Allowed target vertex kinds. Empty array means any. */\n readonly tgtKinds: readonly string[];\n}\n\n/** A protocol specification defining schema/instance theories and validation rules. */\nexport interface ProtocolSpec {\n readonly name: string;\n readonly schemaTheory: string;\n readonly instanceTheory: string;\n readonly edgeRules: readonly EdgeRule[];\n readonly objKinds: readonly string[];\n readonly constraintSorts: readonly string[];\n}\n\n// ---------------------------------------------------------------------------\n// Schema\n// ---------------------------------------------------------------------------\n\n/** Options for vertex creation. */\nexport interface VertexOptions {\n readonly nsid?: string;\n}\n\n/** A vertex in a schema graph. */\nexport interface Vertex {\n readonly id: string;\n readonly kind: string;\n readonly nsid?: string | undefined;\n}\n\n/** A directed edge in a schema graph. */\nexport interface Edge {\n readonly src: string;\n readonly tgt: string;\n readonly kind: string;\n readonly name?: string | undefined;\n}\n\n/** A hyperedge with a labeled signature. */\nexport interface HyperEdge {\n readonly id: string;\n readonly kind: string;\n readonly signature: Readonly<Record<string, string>>;\n readonly parentLabel: string;\n}\n\n/** A constraint on a vertex (sort + value). */\nexport interface Constraint {\n readonly sort: string;\n readonly value: string;\n}\n\n/** A variant in a schema graph (union member). */\nexport interface Variant {\n readonly id: string;\n readonly parent_vertex: string;\n readonly tag?: string | undefined;\n}\n\n/** A recursion point (mu-binding site). */\nexport interface RecursionPoint {\n readonly mu_id: string;\n readonly target_vertex: string;\n}\n\n/** Usage mode for a vertex (structural, linear, or affine). */\nexport type UsageMode = 'structural' | 'linear' | 'affine';\n\n/** A span between two vertices. */\nexport interface Span {\n readonly id: string;\n readonly left: string;\n readonly right: string;\n}\n\n/** Options for edge creation. */\nexport interface EdgeOptions {\n readonly name?: string;\n}\n\n/** Serializable schema representation. */\nexport interface SchemaData {\n readonly protocol: string;\n readonly vertices: Readonly<Record<string, Vertex>>;\n readonly edges: readonly Edge[];\n readonly hyperEdges: Readonly<Record<string, HyperEdge>>;\n readonly constraints: Readonly<Record<string, readonly Constraint[]>>;\n readonly required: Readonly<Record<string, readonly Edge[]>>;\n readonly variants: Readonly<Record<string, readonly Variant[]>>;\n readonly orderings: Readonly<Record<string, number>>;\n readonly recursionPoints: Readonly<Record<string, RecursionPoint>>;\n readonly usageModes: Readonly<Record<string, UsageMode>>;\n readonly spans: Readonly<Record<string, Span>>;\n readonly nominal: Readonly<Record<string, boolean>>;\n}\n\n// ---------------------------------------------------------------------------\n// Migration\n// ---------------------------------------------------------------------------\n\n/** A vertex mapping entry for migration building. */\nexport interface VertexMapping {\n readonly src: string;\n readonly tgt: string;\n}\n\n/** A migration specification (maps between two schemas). */\nexport interface MigrationSpec {\n readonly vertexMap: Readonly<Record<string, string>>;\n readonly edgeMap: readonly [Edge, Edge][];\n readonly resolvers: readonly [[string, string], Edge][];\n}\n\n/** Result of applying a compiled migration to a record. */\nexport interface LiftResult {\n readonly data: unknown;\n}\n\n/** Get result for bidirectional lens operation. */\nexport interface GetResult {\n readonly view: unknown;\n readonly complement: Uint8Array;\n}\n\n// ---------------------------------------------------------------------------\n// Diff / Compatibility\n// ---------------------------------------------------------------------------\n\n/** A single change detected between two schemas. */\nexport interface SchemaChange {\n readonly kind: 'vertex-added' | 'vertex-removed' | 'edge-added' | 'edge-removed'\n | 'constraint-added' | 'constraint-removed' | 'constraint-changed'\n | 'kind-changed' | 'required-added' | 'required-removed';\n readonly path: string;\n readonly detail?: string | undefined;\n}\n\n/** Compatibility classification. */\nexport type Compatibility = 'fully-compatible' | 'backward-compatible' | 'breaking';\n\n/** Schema diff report. */\nexport interface DiffReport {\n readonly compatibility: Compatibility;\n readonly changes: readonly SchemaChange[];\n}\n\n// ---------------------------------------------------------------------------\n// Existence checking\n// ---------------------------------------------------------------------------\n\n/** A structured existence error. */\nexport interface ExistenceError {\n readonly kind: 'edge-missing' | 'kind-inconsistency' | 'label-inconsistency'\n | 'required-field-missing' | 'constraint-tightened' | 'resolver-invalid'\n | 'well-formedness' | 'signature-coherence' | 'simultaneity' | 'reachability-risk';\n readonly message: string;\n readonly detail?: Record<string, unknown> | undefined;\n}\n\n/** Result of existence checking. */\nexport interface ExistenceReport {\n readonly valid: boolean;\n readonly errors: readonly ExistenceError[];\n}\n\n// ---------------------------------------------------------------------------\n// Full Diff / Compatibility (panproto-check)\n// ---------------------------------------------------------------------------\n\n/** A kind change on a vertex. */\nexport interface KindChange {\n readonly vertexId: string;\n readonly oldKind: string;\n readonly newKind: string;\n}\n\n/** A constraint change on a vertex. */\nexport interface ConstraintChange {\n readonly sort: string;\n readonly oldValue: string;\n readonly newValue: string;\n}\n\n/** Constraint diff for a single vertex. */\nexport interface ConstraintDiff {\n readonly added: readonly Constraint[];\n readonly removed: readonly Constraint[];\n readonly changed: readonly ConstraintChange[];\n}\n\n/** Full schema diff with 20+ change categories. */\nexport interface FullSchemaDiff {\n readonly added_vertices: readonly string[];\n readonly removed_vertices: readonly string[];\n readonly kind_changes: readonly KindChange[];\n readonly added_edges: readonly Edge[];\n readonly removed_edges: readonly Edge[];\n readonly modified_constraints: Readonly<Record<string, ConstraintDiff>>;\n readonly added_hyper_edges: readonly string[];\n readonly removed_hyper_edges: readonly string[];\n readonly modified_hyper_edges: readonly Record<string, unknown>[];\n readonly added_required: Readonly<Record<string, readonly Edge[]>>;\n readonly removed_required: Readonly<Record<string, readonly Edge[]>>;\n readonly added_nsids: Readonly<Record<string, string>>;\n readonly removed_nsids: readonly string[];\n readonly changed_nsids: readonly [string, string, string][];\n readonly added_variants: readonly Variant[];\n readonly removed_variants: readonly Variant[];\n readonly modified_variants: readonly Record<string, unknown>[];\n readonly order_changes: readonly [Edge, number | null, number | null][];\n readonly added_recursion_points: readonly RecursionPoint[];\n readonly removed_recursion_points: readonly RecursionPoint[];\n readonly modified_recursion_points: readonly Record<string, unknown>[];\n readonly usage_mode_changes: readonly [Edge, UsageMode, UsageMode][];\n readonly added_spans: readonly string[];\n readonly removed_spans: readonly string[];\n readonly modified_spans: readonly Record<string, unknown>[];\n readonly nominal_changes: readonly [string, boolean, boolean][];\n}\n\n/** A breaking change detected by the compatibility checker. */\nexport interface BreakingChange {\n readonly type: string;\n readonly details: Record<string, unknown>;\n}\n\n/** A non-breaking change detected by the compatibility checker. */\nexport interface NonBreakingChange {\n readonly type: string;\n readonly details: Record<string, unknown>;\n}\n\n/** Compatibility report from classifying a schema diff. */\nexport interface CompatReportData {\n readonly breaking: readonly BreakingChange[];\n readonly non_breaking: readonly NonBreakingChange[];\n readonly compatible: boolean;\n}\n\n/** A schema validation error. */\nexport interface SchemaValidationIssue {\n readonly type: string;\n readonly [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// WASM module interface\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// GAT types\n// ---------------------------------------------------------------------------\n\n/** A parameter of a dependent sort. */\nexport interface SortParam {\n readonly name: string;\n readonly sort: string;\n}\n\n/** A sort declaration in a GAT. */\nexport interface Sort {\n readonly name: string;\n readonly params: readonly SortParam[];\n}\n\n/** A GAT operation (term constructor). */\nexport interface GatOperation {\n readonly name: string;\n readonly inputs: readonly [string, string][];\n readonly output: string;\n}\n\n/** A term in a GAT expression. */\nexport type Term =\n | { readonly Var: string }\n | { readonly App: { readonly op: string; readonly args: readonly Term[] } };\n\n/** An equation (axiom) in a GAT. */\nexport interface Equation {\n readonly name: string;\n readonly lhs: Term;\n readonly rhs: Term;\n}\n\n/** A theory specification. */\nexport interface TheorySpec {\n readonly name: string;\n readonly extends: readonly string[];\n readonly sorts: readonly Sort[];\n readonly ops: readonly GatOperation[];\n readonly eqs: readonly Equation[];\n}\n\n/** A theory morphism (structure-preserving map between theories). */\nexport interface TheoryMorphism {\n readonly name: string;\n readonly domain: string;\n readonly codomain: string;\n readonly sort_map: Readonly<Record<string, string>>;\n readonly op_map: Readonly<Record<string, string>>;\n}\n\n/** Result of checking a morphism. */\nexport interface MorphismCheckResult {\n readonly valid: boolean;\n readonly error: string | null;\n}\n\n/** Branded handle for a theory resource. */\nexport interface TheoryHandle extends Handle {\n readonly __kind: 'theory';\n}\n\n// ---------------------------------------------------------------------------\n// VCS types\n// ---------------------------------------------------------------------------\n\n/** Branded handle for a VCS repository resource. */\nexport interface VcsRepoHandle extends Handle {\n readonly __kind: 'vcs-repo';\n}\n\n/** A VCS commit log entry. */\nexport interface VcsLogEntry {\n readonly message: string;\n readonly author: string;\n readonly timestamp: number;\n readonly protocol: string;\n}\n\n/** VCS repository status. */\nexport interface VcsStatus {\n readonly branch: string | null;\n readonly head_commit: string | null;\n}\n\n/** VCS operation result. */\nexport interface VcsOpResult {\n readonly success: boolean;\n readonly message: string;\n}\n\n/** VCS blame result. */\nexport interface VcsBlameResult {\n readonly commit_id: string;\n readonly author: string;\n readonly timestamp: number;\n readonly message: string;\n}\n\n// ---------------------------------------------------------------------------\n// WASM module interface\n// ---------------------------------------------------------------------------\n\n/** The raw WASM module interface. */\nexport interface WasmExports {\n define_protocol(spec: Uint8Array): number;\n build_schema(proto: number, ops: Uint8Array): number;\n check_existence(proto: number, src: number, tgt: number, mapping: Uint8Array): Uint8Array;\n compile_migration(src: number, tgt: number, mapping: Uint8Array): number;\n lift_record(migration: number, record: Uint8Array): Uint8Array;\n get_record(migration: number, record: Uint8Array): Uint8Array;\n put_record(migration: number, view: Uint8Array, complement: Uint8Array): Uint8Array;\n compose_migrations(m1: number, m2: number): number;\n diff_schemas(s1: number, s2: number): Uint8Array;\n free_handle(handle: number): void;\n diff_schemas_full(s1: number, s2: number): Uint8Array;\n classify_diff(proto: number, diff_bytes: Uint8Array): Uint8Array;\n report_text(report_bytes: Uint8Array): string;\n report_json(report_bytes: Uint8Array): string;\n normalize_schema(schema: number): number;\n validate_schema(schema: number, proto: number): Uint8Array;\n register_io_protocols(): number;\n list_io_protocols(registry: number): Uint8Array;\n parse_instance(registry: number, proto_name: Uint8Array, schema: number, input: Uint8Array): Uint8Array;\n emit_instance(registry: number, proto_name: Uint8Array, schema: number, instance: Uint8Array): Uint8Array;\n validate_instance(schema: number, instance: Uint8Array): Uint8Array;\n instance_to_json(schema: number, instance: Uint8Array): Uint8Array;\n json_to_instance(schema: number, json: Uint8Array): Uint8Array;\n instance_element_count(instance: Uint8Array): number;\n lens_from_combinators(schema: number, proto: number, combinators: Uint8Array): number;\n check_lens_laws(migration: number, instance: Uint8Array): Uint8Array;\n check_get_put(migration: number, instance: Uint8Array): Uint8Array;\n check_put_get(migration: number, instance: Uint8Array): Uint8Array;\n invert_migration(mapping: Uint8Array, src: number, tgt: number): Uint8Array;\n compose_lenses(l1: number, l2: number): number;\n // Phase 4: Protocol registry\n list_builtin_protocols(): Uint8Array;\n get_builtin_protocol(name: Uint8Array): Uint8Array;\n // Phase 5: GAT operations\n create_theory(spec: Uint8Array): number;\n colimit_theories(t1: number, t2: number, shared: number): number;\n check_morphism(morphism: Uint8Array, domain: number, codomain: number): Uint8Array;\n migrate_model(model: Uint8Array, morphism: Uint8Array): Uint8Array;\n // Phase 6: VCS operations\n vcs_init(protocol_name: Uint8Array): number;\n vcs_add(repo: number, schema: number): Uint8Array;\n vcs_commit(repo: number, message: Uint8Array, author: Uint8Array): Uint8Array;\n vcs_log(repo: number, count: number): Uint8Array;\n vcs_status(repo: number): Uint8Array;\n vcs_diff(repo: number): Uint8Array;\n vcs_branch(repo: number, name: Uint8Array): Uint8Array;\n vcs_checkout(repo: number, target: Uint8Array): Uint8Array;\n vcs_merge(repo: number, branch: Uint8Array): Uint8Array;\n vcs_stash(repo: number): Uint8Array;\n vcs_stash_pop(repo: number): Uint8Array;\n vcs_blame(repo: number, vertex: Uint8Array): Uint8Array;\n}\n\n/** Result of checking a lens law (GetPut or PutGet). */\nexport interface LawCheckResult {\n readonly holds: boolean;\n readonly violation: string | null;\n}\n\n/** WASM module wrapper including exports and memory. */\nexport interface WasmModule {\n readonly exports: WasmExports;\n readonly memory: WebAssembly.Memory;\n}\n\n// ---------------------------------------------------------------------------\n// Instance types\n// ---------------------------------------------------------------------------\n\n/** Instance shape discriminator. */\nexport type InstanceShape = 'wtype' | 'functor' | 'graph';\n\n/** Validation result for an instance. */\nexport interface InstanceValidationResult {\n readonly isValid: boolean;\n readonly errors: readonly string[];\n}\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\n/** Base error class for all panproto errors. */\nexport class PanprotoError extends Error {\n override readonly name: string = 'PanprotoError';\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n }\n}\n\n/** Error from WASM boundary. */\nexport class WasmError extends PanprotoError {\n override readonly name = 'WasmError';\n}\n\n/** Error from schema validation. */\nexport class SchemaValidationError extends PanprotoError {\n override readonly name = 'SchemaValidationError';\n\n constructor(\n message: string,\n readonly errors: readonly string[],\n ) {\n super(message);\n }\n}\n\n/** Error from migration compilation. */\nexport class MigrationError extends PanprotoError {\n override readonly name = 'MigrationError';\n}\n\n/** Error from existence checking. */\nexport class ExistenceCheckError extends PanprotoError {\n override readonly name = 'ExistenceCheckError';\n\n constructor(\n message: string,\n readonly report: ExistenceReport,\n ) {\n super(message);\n }\n}\n","/**\n * WASM loading and handle management.\n *\n * Manages the lifecycle of WASM-side resources via opaque handles.\n * Uses `Symbol.dispose` for automatic cleanup and `FinalizationRegistry`\n * as a safety net for leaked handles.\n *\n * @module\n */\n\nimport type { WasmModule, WasmExports } from './types.js';\nimport { WasmError } from './types.js';\n\n/** Default wasm-bindgen glue module URL (relative to package root). */\nconst DEFAULT_GLUE_URL = new URL('./panproto_wasm.js', import.meta.url);\n\n/**\n * Shape of a pre-imported wasm-bindgen glue module.\n *\n * The `default` export is the wasm-bindgen init function. We type it\n * loosely so any wasm-bindgen output module satisfies the interface.\n */\nexport interface WasmGlueModule {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n default: (...args: any[]) => Promise<{ memory: WebAssembly.Memory }>;\n define_protocol: WasmExports['define_protocol'];\n build_schema: WasmExports['build_schema'];\n check_existence: WasmExports['check_existence'];\n compile_migration: WasmExports['compile_migration'];\n lift_record: WasmExports['lift_record'];\n get_record: WasmExports['get_record'];\n put_record: WasmExports['put_record'];\n compose_migrations: WasmExports['compose_migrations'];\n diff_schemas: WasmExports['diff_schemas'];\n free_handle: WasmExports['free_handle'];\n diff_schemas_full: WasmExports['diff_schemas_full'];\n classify_diff: WasmExports['classify_diff'];\n report_text: WasmExports['report_text'];\n report_json: WasmExports['report_json'];\n normalize_schema: WasmExports['normalize_schema'];\n validate_schema: WasmExports['validate_schema'];\n register_io_protocols: WasmExports['register_io_protocols'];\n list_io_protocols: WasmExports['list_io_protocols'];\n parse_instance: WasmExports['parse_instance'];\n emit_instance: WasmExports['emit_instance'];\n validate_instance: WasmExports['validate_instance'];\n instance_to_json: WasmExports['instance_to_json'];\n json_to_instance: WasmExports['json_to_instance'];\n instance_element_count: WasmExports['instance_element_count'];\n lens_from_combinators: WasmExports['lens_from_combinators'];\n check_lens_laws: WasmExports['check_lens_laws'];\n check_get_put: WasmExports['check_get_put'];\n check_put_get: WasmExports['check_put_get'];\n invert_migration: WasmExports['invert_migration'];\n compose_lenses: WasmExports['compose_lenses'];\n // Phase 4: Protocol registry\n list_builtin_protocols: WasmExports['list_builtin_protocols'];\n get_builtin_protocol: WasmExports['get_builtin_protocol'];\n // Phase 5: GAT operations\n create_theory: WasmExports['create_theory'];\n colimit_theories: WasmExports['colimit_theories'];\n check_morphism: WasmExports['check_morphism'];\n migrate_model: WasmExports['migrate_model'];\n // Phase 6: VCS operations\n vcs_init: WasmExports['vcs_init'];\n vcs_add: WasmExports['vcs_add'];\n vcs_commit: WasmExports['vcs_commit'];\n vcs_log: WasmExports['vcs_log'];\n vcs_status: WasmExports['vcs_status'];\n vcs_diff: WasmExports['vcs_diff'];\n vcs_branch: WasmExports['vcs_branch'];\n vcs_checkout: WasmExports['vcs_checkout'];\n vcs_merge: WasmExports['vcs_merge'];\n vcs_stash: WasmExports['vcs_stash'];\n vcs_stash_pop: WasmExports['vcs_stash_pop'];\n vcs_blame: WasmExports['vcs_blame'];\n}\n\n/**\n * Load the panproto WASM module.\n *\n * Accepts either:\n * - A URL to the wasm-bindgen `.js` glue module (loaded via dynamic import)\n * - A pre-imported wasm-bindgen glue module object (for bundler environments like Vite)\n *\n * @param input - URL string, URL object, or pre-imported glue module.\n * Defaults to the bundled glue module URL.\n * @returns The initialized WASM module\n * @throws {@link WasmError} if loading or instantiation fails\n */\nexport async function loadWasm(input?: string | URL | WasmGlueModule): Promise<WasmModule> {\n try {\n let glue: WasmGlueModule;\n\n if (input && typeof input === 'object' && 'default' in input && typeof input.default === 'function') {\n // Pre-imported glue module — used in bundler environments (Vite, webpack)\n glue = input;\n } else {\n // Dynamic import from URL\n const url = (input as string | URL | undefined) ?? DEFAULT_GLUE_URL;\n glue = await import(/* @vite-ignore */ String(url));\n }\n\n const initOutput = await glue.default();\n\n const exports: WasmExports = {\n define_protocol: glue.define_protocol,\n build_schema: glue.build_schema,\n check_existence: glue.check_existence,\n compile_migration: glue.compile_migration,\n lift_record: glue.lift_record,\n get_record: glue.get_record,\n put_record: glue.put_record,\n compose_migrations: glue.compose_migrations,\n diff_schemas: glue.diff_schemas,\n free_handle: glue.free_handle,\n diff_schemas_full: glue.diff_schemas_full,\n classify_diff: glue.classify_diff,\n report_text: glue.report_text,\n report_json: glue.report_json,\n normalize_schema: glue.normalize_schema,\n validate_schema: glue.validate_schema,\n register_io_protocols: glue.register_io_protocols,\n list_io_protocols: glue.list_io_protocols,\n parse_instance: glue.parse_instance,\n emit_instance: glue.emit_instance,\n validate_instance: glue.validate_instance,\n instance_to_json: glue.instance_to_json,\n json_to_instance: glue.json_to_instance,\n instance_element_count: glue.instance_element_count,\n lens_from_combinators: glue.lens_from_combinators,\n check_lens_laws: glue.check_lens_laws,\n check_get_put: glue.check_get_put,\n check_put_get: glue.check_put_get,\n invert_migration: glue.invert_migration,\n compose_lenses: glue.compose_lenses,\n // Phase 4\n list_builtin_protocols: glue.list_builtin_protocols,\n get_builtin_protocol: glue.get_builtin_protocol,\n // Phase 5\n create_theory: glue.create_theory,\n colimit_theories: glue.colimit_theories,\n check_morphism: glue.check_morphism,\n migrate_model: glue.migrate_model,\n // Phase 6\n vcs_init: glue.vcs_init,\n vcs_add: glue.vcs_add,\n vcs_commit: glue.vcs_commit,\n vcs_log: glue.vcs_log,\n vcs_status: glue.vcs_status,\n vcs_diff: glue.vcs_diff,\n vcs_branch: glue.vcs_branch,\n vcs_checkout: glue.vcs_checkout,\n vcs_merge: glue.vcs_merge,\n vcs_stash: glue.vcs_stash,\n vcs_stash_pop: glue.vcs_stash_pop,\n vcs_blame: glue.vcs_blame,\n };\n\n const memory: WebAssembly.Memory = initOutput.memory;\n\n if (!memory) {\n throw new WasmError('WASM module missing memory export');\n }\n\n return { exports, memory };\n } catch (error) {\n if (error instanceof WasmError) throw error;\n throw new WasmError(\n `Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Handle registry — prevents resource leaks\n// ---------------------------------------------------------------------------\n\n/** Weak reference registry for leaked handle detection. */\nconst leakedHandleRegistry = new FinalizationRegistry<CleanupInfo>((info) => {\n // Safety net: if a disposable wrapper is GC'd without being disposed,\n // free the underlying WASM handle.\n try {\n info.freeHandle(info.handle);\n } catch {\n // WASM module may already be torn down; swallow.\n }\n});\n\ninterface CleanupInfo {\n readonly handle: number;\n readonly freeHandle: (h: number) => void;\n}\n\n/**\n * A disposable wrapper around a WASM handle.\n *\n * Implements `Symbol.dispose` for use with `using` declarations.\n * A `FinalizationRegistry` acts as a safety net for handles that\n * are not explicitly disposed.\n */\nexport class WasmHandle implements Disposable {\n #handle: number;\n #disposed = false;\n readonly #freeHandle: (h: number) => void;\n\n constructor(handle: number, freeHandle: (h: number) => void) {\n this.#handle = handle;\n this.#freeHandle = freeHandle;\n\n leakedHandleRegistry.register(this, { handle, freeHandle }, this);\n }\n\n /** The raw WASM handle id. Only for internal use within the SDK. */\n get id(): number {\n if (this.#disposed) {\n throw new WasmError('Attempted to use a disposed handle');\n }\n return this.#handle;\n }\n\n /** Whether this handle has been disposed. */\n get disposed(): boolean {\n return this.#disposed;\n }\n\n /** Release the underlying WASM resource. */\n [Symbol.dispose](): void {\n if (this.#disposed) return;\n this.#disposed = true;\n\n leakedHandleRegistry.unregister(this);\n\n try {\n this.#freeHandle(this.#handle);\n } catch {\n // WASM module may already be torn down; swallow.\n }\n }\n}\n\n/**\n * Create a managed handle that will be freed when disposed.\n *\n * @param rawHandle - The u32 handle from WASM\n * @param wasm - The WASM module for freeing\n * @returns A disposable wrapper\n */\nexport function createHandle(rawHandle: number, wasm: WasmModule): WasmHandle {\n return new WasmHandle(rawHandle, (h) => wasm.exports.free_handle(h));\n}\n","/**\n * MessagePack encode/decode utilities for the WASM boundary.\n *\n * All structured data crossing the WASM boundary is serialized as MessagePack\n * byte slices. This module wraps `@msgpack/msgpack` with typed helpers.\n *\n * @module\n */\n\nimport { encode, decode } from '@msgpack/msgpack';\n\n/**\n * Encode a value to MessagePack bytes for sending to WASM.\n *\n * @param value - The value to encode\n * @returns MessagePack-encoded bytes\n */\nexport function packToWasm(value: unknown): Uint8Array {\n return encode(value);\n}\n\n/**\n * Decode MessagePack bytes received from WASM.\n *\n * @typeParam T - The expected decoded type\n * @param bytes - MessagePack-encoded bytes from WASM\n * @returns The decoded value\n */\nexport function unpackFromWasm<T = unknown>(bytes: Uint8Array): T {\n return decode(bytes) as T;\n}\n\n/**\n * Encode a schema operations list for the `build_schema` entry point.\n *\n * @param ops - Array of builder operations\n * @returns MessagePack-encoded bytes\n */\nexport function packSchemaOps(ops: readonly SchemaOp[]): Uint8Array {\n return encode(ops);\n}\n\n/**\n * Encode a migration mapping for WASM entry points.\n *\n * @param mapping - The migration mapping object\n * @returns MessagePack-encoded bytes\n */\nexport function packMigrationMapping(mapping: MigrationMapping): Uint8Array {\n return encode(mapping);\n}\n\n// ---------------------------------------------------------------------------\n// Internal types for structured WASM messages\n// ---------------------------------------------------------------------------\n\n/**\n * A single schema builder operation sent to WASM.\n *\n * Uses serde internally-tagged format: the `op` field acts as the\n * discriminant and all variant fields sit at the same level.\n */\nexport interface SchemaOp {\n readonly op: 'vertex' | 'edge' | 'hyper_edge' | 'constraint' | 'required';\n readonly [key: string]: unknown;\n}\n\n/** Wire format for an edge (matches Rust serialization). */\nexport interface EdgeWire {\n readonly src: string;\n readonly tgt: string;\n readonly kind: string;\n readonly name: string | null;\n}\n\n/** A migration mapping sent to WASM (matches Rust `Migration` struct). */\nexport interface MigrationMapping {\n readonly vertex_map: Record<string, string>;\n readonly edge_map: Map<EdgeWire, EdgeWire>;\n readonly hyper_edge_map: Record<string, string>;\n readonly label_map: Map<readonly [string, string], string>;\n readonly resolver: Map<readonly [string, string], EdgeWire>;\n}\n","/**\n * Lens and combinator API for bidirectional transformations.\n *\n * Every migration is a lens with `get` (forward projection) and\n * `put` (restore from complement). This module provides Cambria-style\n * combinators that compose into migrations.\n *\n * @module\n */\n\nimport type { WasmModule, LawCheckResult, LiftResult, GetResult } from './types.js';\nimport { WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\nimport type { Protocol } from './protocol.js';\n\n// ---------------------------------------------------------------------------\n// Combinator types\n// ---------------------------------------------------------------------------\n\n/** Rename a field from one name to another. */\nexport interface RenameFieldCombinator {\n readonly type: 'rename-field';\n readonly old: string;\n readonly new: string;\n}\n\n/** Add a new field with a default value. */\nexport interface AddFieldCombinator {\n readonly type: 'add-field';\n readonly name: string;\n readonly vertexKind: string;\n readonly default: unknown;\n}\n\n/** Remove a field from the schema. */\nexport interface RemoveFieldCombinator {\n readonly type: 'remove-field';\n readonly name: string;\n}\n\n/** Wrap a value inside a new object with a given field name. */\nexport interface WrapInObjectCombinator {\n readonly type: 'wrap-in-object';\n readonly fieldName: string;\n}\n\n/** Hoist a nested field up to the host level. */\nexport interface HoistFieldCombinator {\n readonly type: 'hoist-field';\n readonly host: string;\n readonly field: string;\n}\n\n/** Coerce a value from one type to another. */\nexport interface CoerceTypeCombinator {\n readonly type: 'coerce-type';\n readonly fromKind: string;\n readonly toKind: string;\n}\n\n/** Sequential composition of two combinators. */\nexport interface ComposeCombinator {\n readonly type: 'compose';\n readonly first: Combinator;\n readonly second: Combinator;\n}\n\n/** A lens combinator (Cambria-style). */\nexport type Combinator =\n | RenameFieldCombinator\n | AddFieldCombinator\n | RemoveFieldCombinator\n | WrapInObjectCombinator\n | HoistFieldCombinator\n | CoerceTypeCombinator\n | ComposeCombinator;\n\n// ---------------------------------------------------------------------------\n// Combinator constructors\n// ---------------------------------------------------------------------------\n\n/**\n * Create a rename-field combinator.\n *\n * @param oldName - The current field name\n * @param newName - The desired field name\n * @returns A rename-field combinator\n */\nexport function renameField(oldName: string, newName: string): RenameFieldCombinator {\n return { type: 'rename-field', old: oldName, new: newName };\n}\n\n/**\n * Create an add-field combinator.\n *\n * @param name - The field name to add\n * @param vertexKind - The vertex kind for the new field\n * @param defaultValue - The default value for the field\n * @returns An add-field combinator\n */\nexport function addField(name: string, vertexKind: string, defaultValue: unknown): AddFieldCombinator {\n return { type: 'add-field', name, vertexKind, default: defaultValue };\n}\n\n/**\n * Create a remove-field combinator.\n *\n * @param name - The field name to remove\n * @returns A remove-field combinator\n */\nexport function removeField(name: string): RemoveFieldCombinator {\n return { type: 'remove-field', name };\n}\n\n/**\n * Create a wrap-in-object combinator.\n *\n * @param fieldName - The field name for the wrapper object\n * @returns A wrap-in-object combinator\n */\nexport function wrapInObject(fieldName: string): WrapInObjectCombinator {\n return { type: 'wrap-in-object', fieldName };\n}\n\n/**\n * Create a hoist-field combinator.\n *\n * @param host - The host vertex to hoist into\n * @param field - The nested field to hoist\n * @returns A hoist-field combinator\n */\nexport function hoistField(host: string, field: string): HoistFieldCombinator {\n return { type: 'hoist-field', host, field };\n}\n\n/**\n * Create a coerce-type combinator.\n *\n * @param fromKind - The source type kind\n * @param toKind - The target type kind\n * @returns A coerce-type combinator\n */\nexport function coerceType(fromKind: string, toKind: string): CoerceTypeCombinator {\n return { type: 'coerce-type', fromKind, toKind };\n}\n\n/**\n * Compose two combinators sequentially.\n *\n * @param first - The combinator applied first\n * @param second - The combinator applied second\n * @returns A composed combinator\n */\nexport function compose(first: Combinator, second: Combinator): ComposeCombinator {\n return { type: 'compose', first, second };\n}\n\n/**\n * Compose a chain of combinators left-to-right.\n *\n * @param combinators - The combinators to compose (at least one required)\n * @returns The composed combinator\n * @throws If the combinators array is empty\n */\nexport function pipeline(combinators: readonly [Combinator, ...Combinator[]]): Combinator {\n const [first, ...rest] = combinators;\n return rest.reduce<Combinator>((acc, c) => compose(acc, c), first);\n}\n\n// ---------------------------------------------------------------------------\n// LensHandle — disposable wrapper around a WASM migration handle for lenses\n// ---------------------------------------------------------------------------\n\n/**\n * A disposable handle to a WASM-side lens (migration) resource.\n *\n * Wraps a migration handle created via `lens_from_combinators` or\n * `compose_lenses`. Provides `get`, `put`, and law-checking operations.\n *\n * Implements `Symbol.dispose` for use with `using` declarations.\n */\nexport class LensHandle implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this.#handle = handle;\n this.#wasm = wasm;\n }\n\n /** The underlying WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Forward projection: extract the view from a record.\n *\n * @param record - MessagePack-encoded input record\n * @returns The projected view and opaque complement bytes\n * @throws {@link WasmError} if the WASM call fails\n */\n get(record: Uint8Array): GetResult {\n try {\n const outputBytes = this.#wasm.exports.get_record(\n this.#handle.id,\n record,\n );\n const result = unpackFromWasm<{ view: unknown; complement: Uint8Array }>(outputBytes);\n return {\n view: result.view,\n complement: result.complement instanceof Uint8Array\n ? result.complement\n : new Uint8Array(result.complement as ArrayBuffer),\n };\n } catch (error) {\n throw new WasmError(\n `get_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Backward put: restore a full record from a modified view and complement.\n *\n * @param view - MessagePack-encoded (possibly modified) projected view\n * @param complement - The complement from a prior `get()` call\n * @returns The restored full record\n * @throws {@link WasmError} if the WASM call fails\n */\n put(view: Uint8Array, complement: Uint8Array): LiftResult {\n try {\n const outputBytes = this.#wasm.exports.put_record(\n this.#handle.id,\n view,\n complement,\n );\n const data = unpackFromWasm(outputBytes);\n return { data };\n } catch (error) {\n throw new WasmError(\n `put_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check both GetPut and PutGet lens laws for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether both laws hold and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkLaws(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_lens_laws(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_lens_laws failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check the GetPut lens law for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether the law holds and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkGetPut(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_get_put(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_get_put failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check the PutGet lens law for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether the law holds and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkPutGet(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_put_get(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_put_get failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the underlying WASM resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Build a lens from combinators.\n *\n * Serializes the combinators to MessagePack and calls the\n * `lens_from_combinators` WASM entry point.\n *\n * @param schema - The schema to build the lens against\n * @param protocol - The protocol defining the schema theory\n * @param combinators - One or more combinators to compose into a lens\n * @returns A LensHandle wrapping the WASM migration resource\n * @throws {@link WasmError} if the WASM call fails\n */\nexport function fromCombinators(\n schema: BuiltSchema,\n protocol: Protocol,\n wasm: WasmModule,\n ...combinators: Combinator[]\n): LensHandle {\n const wireCombs = combinators.map(combinatorToWire);\n const combBytes = packToWasm(wireCombs);\n\n try {\n const rawHandle = wasm.exports.lens_from_combinators(\n schema._handle.id,\n protocol._handle.id,\n combBytes,\n );\n const handle = createHandle(rawHandle, wasm);\n return new LensHandle(handle, wasm);\n } catch (error) {\n throw new WasmError(\n `lens_from_combinators failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Wire serialization\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize a combinator to a plain object for MessagePack encoding.\n *\n * @param combinator - The combinator to serialize\n * @returns A plain object suitable for MessagePack encoding\n */\nexport function combinatorToWire(combinator: Combinator): Record<string, unknown> {\n switch (combinator.type) {\n case 'rename-field':\n return { RenameField: { old: combinator.old, new: combinator.new } };\n case 'add-field':\n return { AddField: { name: combinator.name, vertex_kind: combinator.vertexKind, default: combinator.default } };\n case 'remove-field':\n return { RemoveField: { name: combinator.name } };\n case 'wrap-in-object':\n return { WrapInObject: { field_name: combinator.fieldName } };\n case 'hoist-field':\n return { HoistField: { host: combinator.host, field: combinator.field } };\n case 'coerce-type':\n return { CoerceType: { from_kind: combinator.fromKind, to_kind: combinator.toKind } };\n case 'compose':\n return { Compose: [combinatorToWire(combinator.first), combinatorToWire(combinator.second)] };\n }\n}\n","/**\n * Breaking-change analysis and compatibility checking.\n *\n * Provides a fluent API for diffing schemas and classifying changes:\n *\n * ```typescript\n * const diff = panproto.diffFull(oldSchema, newSchema);\n * const report = diff.classify(protocol);\n * console.log(report.isBreaking);\n * console.log(report.toText());\n * ```\n *\n * @module\n */\n\nimport type { Protocol } from './protocol.js';\nimport type {\n FullSchemaDiff,\n CompatReportData,\n BreakingChange,\n NonBreakingChange,\n SchemaValidationIssue,\n WasmModule,\n} from './types.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/**\n * A full schema diff with 20+ change categories.\n *\n * Created via `Panproto.diffFull()`. Use `.classify()` to determine\n * compatibility.\n */\nexport class FullDiffReport {\n /** The raw diff data. */\n readonly data: FullSchemaDiff;\n\n /** @internal */\n readonly _reportBytes: Uint8Array;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n /** @internal */\n constructor(data: FullSchemaDiff, reportBytes: Uint8Array, wasm: WasmModule) {\n this.data = data;\n this._reportBytes = reportBytes;\n this._wasm = wasm;\n }\n\n /** Whether there are any changes at all. */\n get hasChanges(): boolean {\n const d = this.data;\n return (\n d.added_vertices.length > 0 ||\n d.removed_vertices.length > 0 ||\n d.kind_changes.length > 0 ||\n d.added_edges.length > 0 ||\n d.removed_edges.length > 0 ||\n Object.keys(d.modified_constraints).length > 0 ||\n d.added_hyper_edges.length > 0 ||\n d.removed_hyper_edges.length > 0 ||\n d.modified_hyper_edges.length > 0 ||\n Object.keys(d.added_required).length > 0 ||\n Object.keys(d.removed_required).length > 0 ||\n Object.keys(d.added_nsids).length > 0 ||\n d.removed_nsids.length > 0 ||\n d.changed_nsids.length > 0 ||\n d.added_variants.length > 0 ||\n d.removed_variants.length > 0 ||\n d.modified_variants.length > 0 ||\n d.order_changes.length > 0 ||\n d.added_recursion_points.length > 0 ||\n d.removed_recursion_points.length > 0 ||\n d.modified_recursion_points.length > 0 ||\n d.usage_mode_changes.length > 0 ||\n d.added_spans.length > 0 ||\n d.removed_spans.length > 0 ||\n d.modified_spans.length > 0 ||\n d.nominal_changes.length > 0\n );\n }\n\n /** Classify the diff against a protocol, producing a compatibility report. */\n classify(protocol: Protocol): CompatReport {\n const rawBytes = this._wasm.exports.classify_diff(\n protocol._handle.id,\n this._reportBytes,\n );\n const data = unpackFromWasm<CompatReportData>(rawBytes);\n return new CompatReport(data, rawBytes, this._wasm);\n }\n}\n\n/**\n * A compatibility report classifying schema changes as breaking or non-breaking.\n *\n * Created via `FullDiffReport.classify()`.\n */\nexport class CompatReport {\n /** The raw report data. */\n readonly data: CompatReportData;\n\n /** @internal */\n readonly _rawBytes: Uint8Array;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n /** @internal */\n constructor(data: CompatReportData, rawBytes: Uint8Array, wasm: WasmModule) {\n this.data = data;\n this._rawBytes = rawBytes;\n this._wasm = wasm;\n }\n\n /** List of breaking changes. */\n get breakingChanges(): readonly BreakingChange[] {\n return this.data.breaking;\n }\n\n /** List of non-breaking changes. */\n get nonBreakingChanges(): readonly NonBreakingChange[] {\n return this.data.non_breaking;\n }\n\n /** Whether the changes are fully compatible (no breaking changes). */\n get isCompatible(): boolean {\n return this.data.compatible;\n }\n\n /** Whether there are any breaking changes. */\n get isBreaking(): boolean {\n return !this.data.compatible;\n }\n\n /** Whether the changes are backward-compatible (additions only, no removals). */\n get isBackwardCompatible(): boolean {\n return this.data.compatible;\n }\n\n /** Render as human-readable text. */\n toText(): string {\n return this._wasm.exports.report_text(this._rawBytes);\n }\n\n /** Render as a JSON string. */\n toJson(): string {\n return this._wasm.exports.report_json(this._rawBytes);\n }\n}\n\n/**\n * Result of schema validation against a protocol.\n */\nexport class ValidationResult {\n /** The list of validation issues found. */\n readonly issues: readonly SchemaValidationIssue[];\n\n constructor(issues: readonly SchemaValidationIssue[]) {\n this.issues = issues;\n }\n\n /** Whether the schema is valid (no issues found). */\n get isValid(): boolean {\n return this.issues.length === 0;\n }\n\n /** The number of validation issues. */\n get errorCount(): number {\n return this.issues.length;\n }\n}\n","/**\n * Fluent schema builder API.\n *\n * Builders are immutable: each method returns a new builder instance.\n * Call `.build()` to validate and produce the final schema.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n Vertex,\n Edge,\n HyperEdge,\n Constraint,\n VertexOptions,\n EdgeOptions,\n SchemaData,\n SchemaValidationIssue,\n} from './types.js';\nimport { SchemaValidationError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport type { SchemaOp } from './msgpack.js';\nimport { packSchemaOps, unpackFromWasm } from './msgpack.js';\nimport type { Protocol } from './protocol.js';\nimport { ValidationResult } from './check.js';\n\n/**\n * Immutable fluent builder for constructing schemas.\n *\n * Each mutation method returns a new `SchemaBuilder` instance,\n * leaving the original unchanged. The builder accumulates operations\n * that are sent to WASM on `.build()`.\n *\n * @example\n * ```typescript\n * const schema = builder\n * .vertex('post', 'record', { nsid: 'app.bsky.feed.post' })\n * .vertex('post:body', 'object')\n * .edge('post', 'post:body', 'record-schema')\n * .build();\n * ```\n */\nexport class SchemaBuilder {\n readonly #protocolName: string;\n readonly #protocolHandle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #ops: readonly SchemaOp[];\n readonly #vertices: ReadonlyMap<string, Vertex>;\n readonly #edges: readonly Edge[];\n readonly #hyperEdges: ReadonlyMap<string, HyperEdge>;\n readonly #constraints: ReadonlyMap<string, readonly Constraint[]>;\n readonly #required: ReadonlyMap<string, readonly Edge[]>;\n\n constructor(\n protocolName: string,\n protocolHandle: WasmHandle,\n wasm: WasmModule,\n ops: readonly SchemaOp[] = [],\n vertices: ReadonlyMap<string, Vertex> = new Map(),\n edges: readonly Edge[] = [],\n hyperEdges: ReadonlyMap<string, HyperEdge> = new Map(),\n constraints: ReadonlyMap<string, readonly Constraint[]> = new Map(),\n required: ReadonlyMap<string, readonly Edge[]> = new Map(),\n ) {\n this.#protocolName = protocolName;\n this.#protocolHandle = protocolHandle;\n this.#wasm = wasm;\n this.#ops = ops;\n this.#vertices = vertices;\n this.#edges = edges;\n this.#hyperEdges = hyperEdges;\n this.#constraints = constraints;\n this.#required = required;\n }\n\n /**\n * Add a vertex to the schema.\n *\n * @param id - Unique vertex identifier\n * @param kind - Vertex kind (e.g., 'record', 'object', 'string')\n * @param options - Optional vertex configuration (nsid, etc.)\n * @returns A new builder with the vertex added\n * @throws {@link SchemaValidationError} if vertex id is already in use\n */\n vertex(id: string, kind: string, options?: VertexOptions): SchemaBuilder {\n if (this.#vertices.has(id)) {\n throw new SchemaValidationError(\n `Vertex \"${id}\" already exists in schema`,\n [`Duplicate vertex id: ${id}`],\n );\n }\n\n const vertex: Vertex = {\n id,\n kind,\n nsid: options?.nsid,\n };\n\n const op: SchemaOp = {\n op: 'vertex',\n id,\n kind,\n nsid: options?.nsid ?? null,\n };\n\n const newVertices = new Map(this.#vertices);\n newVertices.set(id, vertex);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n newVertices,\n this.#edges,\n this.#hyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a directed edge to the schema.\n *\n * @param src - Source vertex id\n * @param tgt - Target vertex id\n * @param kind - Edge kind (e.g., 'record-schema', 'prop')\n * @param options - Optional edge configuration (name, etc.)\n * @returns A new builder with the edge added\n * @throws {@link SchemaValidationError} if source or target vertex does not exist\n */\n edge(src: string, tgt: string, kind: string, options?: EdgeOptions): SchemaBuilder {\n if (!this.#vertices.has(src)) {\n throw new SchemaValidationError(\n `Edge source \"${src}\" does not exist`,\n [`Unknown source vertex: ${src}`],\n );\n }\n if (!this.#vertices.has(tgt)) {\n throw new SchemaValidationError(\n `Edge target \"${tgt}\" does not exist`,\n [`Unknown target vertex: ${tgt}`],\n );\n }\n\n const edge: Edge = {\n src,\n tgt,\n kind,\n name: options?.name,\n };\n\n const op: SchemaOp = {\n op: 'edge',\n src,\n tgt,\n kind,\n name: options?.name ?? null,\n };\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n [...this.#edges, edge],\n this.#hyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a hyperedge to the schema.\n *\n * Only valid if the protocol's schema theory includes ThHypergraph.\n *\n * @param id - Unique hyperedge identifier\n * @param kind - Hyperedge kind\n * @param signature - Label-to-vertex mapping\n * @param parentLabel - The label identifying the parent in the signature\n * @returns A new builder with the hyperedge added\n */\n hyperEdge(\n id: string,\n kind: string,\n signature: Record<string, string>,\n parentLabel: string,\n ): SchemaBuilder {\n const he: HyperEdge = { id, kind, signature, parentLabel };\n\n const op: SchemaOp = {\n op: 'hyper_edge',\n id,\n kind,\n signature,\n parent: parentLabel,\n };\n\n const newHyperEdges = new Map(this.#hyperEdges);\n newHyperEdges.set(id, he);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n newHyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a constraint to a vertex.\n *\n * @param vertexId - The vertex to constrain\n * @param sort - Constraint sort (e.g., 'maxLength')\n * @param value - Constraint value\n * @returns A new builder with the constraint added\n */\n constraint(vertexId: string, sort: string, value: string): SchemaBuilder {\n const c: Constraint = { sort, value };\n\n const op: SchemaOp = {\n op: 'constraint',\n vertex: vertexId,\n sort,\n value,\n };\n\n const existing = this.#constraints.get(vertexId) ?? [];\n const newConstraints = new Map(this.#constraints);\n newConstraints.set(vertexId, [...existing, c]);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n this.#hyperEdges,\n newConstraints,\n this.#required,\n );\n }\n\n /**\n * Mark edges as required for a vertex.\n *\n * @param vertexId - The vertex with required edges\n * @param edges - The edges that are required\n * @returns A new builder with the requirement added\n */\n required(vertexId: string, edges: readonly Edge[]): SchemaBuilder {\n const op: SchemaOp = {\n op: 'required',\n vertex: vertexId,\n edges: edges.map((e) => ({\n src: e.src,\n tgt: e.tgt,\n kind: e.kind,\n name: e.name ?? null,\n })),\n };\n\n const existing = this.#required.get(vertexId) ?? [];\n const newRequired = new Map(this.#required);\n newRequired.set(vertexId, [...existing, ...edges]);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n this.#hyperEdges,\n this.#constraints,\n newRequired,\n );\n }\n\n /**\n * Validate and build the schema.\n *\n * Sends all accumulated operations to WASM for validation and construction.\n * Returns a `BuiltSchema` that holds the WASM handle and local data.\n *\n * @returns The validated, built schema\n * @throws {@link SchemaValidationError} if the schema is invalid\n */\n build(): BuiltSchema {\n const opsBytes = packSchemaOps([...this.#ops]);\n const rawHandle = this.#wasm.exports.build_schema(\n this.#protocolHandle.id,\n opsBytes,\n );\n\n const handle = createHandle(rawHandle, this.#wasm);\n\n const data: SchemaData = {\n protocol: this.#protocolName,\n vertices: Object.fromEntries(this.#vertices),\n edges: [...this.#edges],\n hyperEdges: Object.fromEntries(this.#hyperEdges),\n constraints: Object.fromEntries(\n Array.from(this.#constraints.entries()).map(([k, v]) => [k, [...v]]),\n ),\n required: Object.fromEntries(\n Array.from(this.#required.entries()).map(([k, v]) => [k, [...v]]),\n ),\n variants: {},\n orderings: {},\n recursionPoints: {},\n usageModes: {},\n spans: {},\n nominal: {},\n };\n\n return new BuiltSchema(handle, data, this.#wasm);\n }\n}\n\n/**\n * A validated, built schema with a WASM-side handle.\n *\n * Implements `Disposable` for automatic cleanup of the WASM resource.\n */\nexport class BuiltSchema implements Disposable {\n readonly #handle: WasmHandle;\n readonly #data: SchemaData;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, data: SchemaData, wasm: WasmModule) {\n this.#handle = handle;\n this.#data = data;\n this.#wasm = wasm;\n }\n\n /** The WASM handle for this schema. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** The WASM module reference. Internal use only. */\n get _wasm(): WasmModule {\n return this.#wasm;\n }\n\n /** The schema data (vertices, edges, constraints, etc.). */\n get data(): SchemaData {\n return this.#data;\n }\n\n /** The protocol name this schema belongs to. */\n get protocol(): string {\n return this.#data.protocol;\n }\n\n /** All vertices in the schema. */\n get vertices(): Readonly<Record<string, Vertex>> {\n return this.#data.vertices;\n }\n\n /** All edges in the schema. */\n get edges(): readonly Edge[] {\n return this.#data.edges;\n }\n\n /** @internal Create from raw handle (used by normalize). */\n static _fromHandle(\n handle: number,\n data: SchemaData,\n _protocol: string,\n wasm: WasmModule,\n ): BuiltSchema {\n const wasmHandle = createHandle(handle, wasm);\n return new BuiltSchema(wasmHandle, data, wasm);\n }\n\n /** Normalize this schema by collapsing reference chains. Returns a new BuiltSchema. */\n normalize(): BuiltSchema {\n const handle = this.#wasm.exports.normalize_schema(this.#handle.id);\n return BuiltSchema._fromHandle(handle, this.#data, this.#data.protocol, this.#wasm);\n }\n\n /** Validate this schema against a protocol's rules. */\n validate(protocol: Protocol): ValidationResult {\n const bytes = this.#wasm.exports.validate_schema(\n this.#handle.id,\n protocol._handle.id,\n );\n const issues = unpackFromWasm<SchemaValidationIssue[]>(bytes);\n return new ValidationResult(issues);\n }\n\n /** Release the WASM-side schema resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n","/**\n * Protocol definition helpers.\n *\n * A protocol specifies the schema theory and instance theory used by\n * a family of schemas (e.g., ATProto, SQL, Protobuf). This module\n * provides helpers for defining and looking up protocols.\n *\n * @module\n */\n\nimport type { WasmModule, ProtocolSpec, EdgeRule } from './types.js';\nimport { PanprotoError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\nimport { SchemaBuilder } from './schema.js';\n\n/**\n * A registered protocol with a WASM-side handle.\n *\n * Provides a fluent API for building schemas within this protocol.\n * Implements `Disposable` for automatic cleanup.\n */\nexport class Protocol implements Disposable {\n readonly #handle: WasmHandle;\n readonly #spec: ProtocolSpec;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, spec: ProtocolSpec, wasm: WasmModule) {\n this.#handle = handle;\n this.#spec = spec;\n this.#wasm = wasm;\n }\n\n /** The protocol name. */\n get name(): string {\n return this.#spec.name;\n }\n\n /** The full protocol specification. */\n get spec(): ProtocolSpec {\n return this.#spec;\n }\n\n /** The edge rules for this protocol. */\n get edgeRules(): readonly EdgeRule[] {\n return this.#spec.edgeRules;\n }\n\n /** The constraint sorts for this protocol. */\n get constraintSorts(): readonly string[] {\n return this.#spec.constraintSorts;\n }\n\n /** The object kinds for this protocol. */\n get objectKinds(): readonly string[] {\n return this.#spec.objKinds;\n }\n\n /** The WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Start building a schema within this protocol.\n *\n * @returns A new `SchemaBuilder` bound to this protocol\n */\n schema(): SchemaBuilder {\n return new SchemaBuilder(this.#spec.name, this.#handle, this.#wasm);\n }\n\n /** Release the WASM-side protocol resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Define a protocol by sending its specification to WASM.\n *\n * @param spec - The protocol specification\n * @param wasm - The WASM module\n * @returns A registered protocol with a WASM handle\n * @throws {@link PanprotoError} if the WASM call fails\n */\nexport function defineProtocol(spec: ProtocolSpec, wasm: WasmModule): Protocol {\n const wireSpec = {\n name: spec.name,\n schema_theory: spec.schemaTheory,\n instance_theory: spec.instanceTheory,\n edge_rules: spec.edgeRules.map((r) => ({\n edge_kind: r.edgeKind,\n src_kinds: [...r.srcKinds],\n tgt_kinds: [...r.tgtKinds],\n })),\n obj_kinds: [...spec.objKinds],\n constraint_sorts: [...spec.constraintSorts],\n };\n\n try {\n const bytes = packToWasm(wireSpec);\n const rawHandle = wasm.exports.define_protocol(bytes);\n const handle = createHandle(rawHandle, wasm);\n return new Protocol(handle, spec, wasm);\n } catch (error) {\n throw new PanprotoError(\n `Failed to define protocol \"${spec.name}\": ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Built-in protocol specs\n// ---------------------------------------------------------------------------\n\n/**\n * Built-in ATProto protocol specification.\n *\n * Schema theory: colimit(ThGraph, ThConstraint, ThMulti).\n * Instance theory: ThWType + ThMeta.\n */\nexport const ATPROTO_SPEC: ProtocolSpec = {\n name: 'atproto',\n schemaTheory: 'ThATProtoSchema',\n instanceTheory: 'ThATProtoInstance',\n edgeRules: [\n { edgeKind: 'record-schema', srcKinds: ['record'], tgtKinds: ['object'] },\n { edgeKind: 'prop', srcKinds: ['object', 'query', 'procedure', 'subscription'], tgtKinds: [] },\n { edgeKind: 'items', srcKinds: ['array'], tgtKinds: [] },\n { edgeKind: 'variant', srcKinds: ['union'], tgtKinds: [] },\n { edgeKind: 'ref', srcKinds: [], tgtKinds: [] },\n { edgeKind: 'self-ref', srcKinds: [], tgtKinds: [] },\n ] satisfies EdgeRule[],\n objKinds: [\n 'record', 'object', 'array', 'union', 'string', 'integer', 'boolean',\n 'bytes', 'cid-link', 'blob', 'unknown', 'token', 'query', 'procedure',\n 'subscription', 'ref',\n ],\n constraintSorts: [\n 'minLength', 'maxLength', 'minimum', 'maximum', 'maxGraphemes',\n 'enum', 'const', 'default', 'closed',\n ],\n};\n\n/**\n * Built-in SQL protocol specification.\n *\n * Schema theory: colimit(ThHypergraph, ThConstraint).\n * Instance theory: ThFunctor.\n */\nexport const SQL_SPEC: ProtocolSpec = {\n name: 'sql',\n schemaTheory: 'ThConstrainedHypergraph',\n instanceTheory: 'ThFunctor',\n edgeRules: [\n { edgeKind: 'column', srcKinds: ['table'], tgtKinds: ['type'] },\n { edgeKind: 'fk', srcKinds: ['table'], tgtKinds: ['table'] },\n { edgeKind: 'pk', srcKinds: ['table'], tgtKinds: ['column'] },\n ] satisfies EdgeRule[],\n objKinds: ['table'],\n constraintSorts: ['nullable', 'unique', 'check', 'default'],\n};\n\n/**\n * Built-in Protobuf protocol specification.\n */\nexport const PROTOBUF_SPEC: ProtocolSpec = {\n name: 'protobuf',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'field', srcKinds: ['message'], tgtKinds: [] },\n { edgeKind: 'nested', srcKinds: ['message'], tgtKinds: ['message', 'enum'] },\n { edgeKind: 'value', srcKinds: ['enum'], tgtKinds: ['enum-value'] },\n ] satisfies EdgeRule[],\n objKinds: ['message'],\n constraintSorts: ['field-number', 'repeated', 'optional', 'map-key', 'map-value'],\n};\n\n/**\n * Built-in GraphQL protocol specification.\n */\nexport const GRAPHQL_SPEC: ProtocolSpec = {\n name: 'graphql',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'field', srcKinds: ['type', 'input'], tgtKinds: [] },\n { edgeKind: 'implements', srcKinds: ['type'], tgtKinds: ['interface'] },\n { edgeKind: 'member', srcKinds: ['union'], tgtKinds: ['type'] },\n { edgeKind: 'value', srcKinds: ['enum'], tgtKinds: ['enum-value'] },\n ] satisfies EdgeRule[],\n objKinds: ['type', 'input'],\n constraintSorts: ['non-null', 'list', 'deprecated'],\n};\n\n/**\n * Built-in JSON Schema protocol specification.\n */\nexport const JSON_SCHEMA_SPEC: ProtocolSpec = {\n name: 'json-schema',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'property', srcKinds: ['object'], tgtKinds: [] },\n { edgeKind: 'item', srcKinds: ['array'], tgtKinds: [] },\n { edgeKind: 'variant', srcKinds: ['oneOf', 'anyOf'], tgtKinds: [] },\n ] satisfies EdgeRule[],\n objKinds: ['object'],\n constraintSorts: ['minLength', 'maxLength', 'minimum', 'maximum', 'pattern', 'format', 'required'],\n};\n\n/** Registry of built-in protocol specs, keyed by name. */\nexport const BUILTIN_PROTOCOLS: ReadonlyMap<string, ProtocolSpec> = new Map([\n ['atproto', ATPROTO_SPEC],\n ['sql', SQL_SPEC],\n ['protobuf', PROTOBUF_SPEC],\n ['graphql', GRAPHQL_SPEC],\n ['json-schema', JSON_SCHEMA_SPEC],\n]);\n\n/** Lazily cached list of all 76 built-in protocol names from WASM. */\nlet _protocolNamesCache: readonly string[] | null = null;\n\n/**\n * Get the list of all built-in protocol names.\n *\n * Lazily fetches the full list from WASM on first call and caches it.\n *\n * @param wasm - The WASM module\n * @returns Array of all 76 built-in protocol names\n */\nexport function getProtocolNames(wasm: WasmModule): readonly string[] {\n if (_protocolNamesCache !== null) return _protocolNamesCache;\n const bytes = wasm.exports.list_builtin_protocols();\n _protocolNamesCache = unpackFromWasm<string[]>(bytes);\n return _protocolNamesCache;\n}\n\n/**\n * Get a built-in protocol spec by name from WASM.\n *\n * This fetches the full protocol definition from the WASM layer,\n * which includes all 76 protocols (not just the 5 hardcoded ones).\n *\n * @param name - The protocol name\n * @param wasm - The WASM module\n * @returns The protocol spec, or undefined if not found\n */\nexport function getBuiltinProtocol(name: string, wasm: WasmModule): ProtocolSpec | undefined {\n try {\n const nameBytes = new TextEncoder().encode(name);\n const bytes = wasm.exports.get_builtin_protocol(nameBytes);\n const wire = unpackFromWasm<{\n name: string;\n schema_theory: string;\n instance_theory: string;\n edge_rules: { edge_kind: string; src_kinds: string[]; tgt_kinds: string[] }[];\n obj_kinds: string[];\n constraint_sorts: string[];\n }>(bytes);\n return {\n name: wire.name,\n schemaTheory: wire.schema_theory,\n instanceTheory: wire.instance_theory,\n edgeRules: wire.edge_rules.map((r) => ({\n edgeKind: r.edge_kind,\n srcKinds: r.src_kinds,\n tgtKinds: r.tgt_kinds,\n })),\n objKinds: wire.obj_kinds,\n constraintSorts: wire.constraint_sorts,\n };\n } catch {\n return undefined;\n }\n}\n","/**\n * Migration builder and compiled migration wrapper.\n *\n * Migrations define a mapping between two schemas. Once compiled,\n * they can efficiently transform records via WASM.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n Edge,\n LiftResult,\n GetResult,\n ExistenceReport,\n MigrationSpec,\n} from './types.js';\nimport { MigrationError, WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm, packMigrationMapping } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\n\n/**\n * Fluent builder for constructing migrations between two schemas.\n *\n * Each mutation method returns a new `MigrationBuilder` instance,\n * leaving the original unchanged.\n *\n * @example\n * ```typescript\n * const migration = panproto.migration(oldSchema, newSchema)\n * .map('post', 'post')\n * .map('post:body', 'post:body')\n * .mapEdge(oldEdge, newEdge)\n * .compile();\n * ```\n */\nexport class MigrationBuilder {\n readonly #src: BuiltSchema;\n readonly #tgt: BuiltSchema;\n readonly #wasm: WasmModule;\n readonly #vertexMap: ReadonlyMap<string, string>;\n readonly #edgeMap: readonly [Edge, Edge][];\n readonly #resolvers: readonly [[string, string], Edge][];\n\n constructor(\n src: BuiltSchema,\n tgt: BuiltSchema,\n wasm: WasmModule,\n vertexMap: ReadonlyMap<string, string> = new Map(),\n edgeMap: readonly [Edge, Edge][] = [],\n resolvers: readonly [[string, string], Edge][] = [],\n ) {\n this.#src = src;\n this.#tgt = tgt;\n this.#wasm = wasm;\n this.#vertexMap = vertexMap;\n this.#edgeMap = edgeMap;\n this.#resolvers = resolvers;\n }\n\n /**\n * Map a source vertex to a target vertex.\n *\n * @param srcVertex - Vertex id in the source schema\n * @param tgtVertex - Vertex id in the target schema\n * @returns A new builder with the mapping added\n */\n map(srcVertex: string, tgtVertex: string): MigrationBuilder {\n const newMap = new Map(this.#vertexMap);\n newMap.set(srcVertex, tgtVertex);\n\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n newMap,\n this.#edgeMap,\n this.#resolvers,\n );\n }\n\n /**\n * Map a source edge to a target edge.\n *\n * @param srcEdge - Edge in the source schema\n * @param tgtEdge - Edge in the target schema\n * @returns A new builder with the edge mapping added\n */\n mapEdge(srcEdge: Edge, tgtEdge: Edge): MigrationBuilder {\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n this.#vertexMap,\n [...this.#edgeMap, [srcEdge, tgtEdge]],\n this.#resolvers,\n );\n }\n\n /**\n * Add a resolver for ancestor contraction ambiguity.\n *\n * When a migration contracts nodes and the resulting edge between\n * two vertex kinds is ambiguous, a resolver specifies which edge to use.\n *\n * @param srcKind - Source vertex kind in the contracted pair\n * @param tgtKind - Target vertex kind in the contracted pair\n * @param resolvedEdge - The edge to use for this pair\n * @returns A new builder with the resolver added\n */\n resolve(srcKind: string, tgtKind: string, resolvedEdge: Edge): MigrationBuilder {\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n this.#vertexMap,\n this.#edgeMap,\n [...this.#resolvers, [[srcKind, tgtKind], resolvedEdge]],\n );\n }\n\n /**\n * Get the current migration specification.\n *\n * @returns The migration spec with all accumulated mappings\n */\n toSpec(): MigrationSpec {\n return {\n vertexMap: Object.fromEntries(this.#vertexMap),\n edgeMap: [...this.#edgeMap],\n resolvers: [...this.#resolvers],\n };\n }\n\n /**\n * Invert a bijective migration.\n *\n * Serializes the current mapping to MessagePack and calls the\n * `invert_migration` WASM entry point. Returns a new MigrationSpec\n * representing the inverted migration.\n *\n * @returns The inverted migration specification\n * @throws {@link MigrationError} if the migration is not bijective or inversion fails\n */\n invert(): MigrationSpec {\n const edgeMap = new Map(\n this.#edgeMap.map(([src, tgt]) => [\n { src: src.src, tgt: src.tgt, kind: src.kind, name: src.name ?? null },\n { src: tgt.src, tgt: tgt.tgt, kind: tgt.kind, name: tgt.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n this.#resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: Object.fromEntries(this.#vertexMap),\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n try {\n const resultBytes = this.#wasm.exports.invert_migration(\n mapping,\n this.#src._handle.id,\n this.#tgt._handle.id,\n );\n return unpackFromWasm<MigrationSpec>(resultBytes);\n } catch (error) {\n throw new MigrationError(\n `Failed to invert migration: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Compile the migration for fast per-record application.\n *\n * Sends the migration specification to WASM for compilation.\n * The resulting `CompiledMigration` can be used to transform records.\n *\n * @returns A compiled migration ready for record transformation\n * @throws {@link MigrationError} if compilation fails\n */\n compile(): CompiledMigration {\n const edgeMap = new Map(\n this.#edgeMap.map(([src, tgt]) => [\n { src: src.src, tgt: src.tgt, kind: src.kind, name: src.name ?? null },\n { src: tgt.src, tgt: tgt.tgt, kind: tgt.kind, name: tgt.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n this.#resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: Object.fromEntries(this.#vertexMap),\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n try {\n const rawHandle = this.#wasm.exports.compile_migration(\n this.#src._handle.id,\n this.#tgt._handle.id,\n mapping,\n );\n\n const handle = createHandle(rawHandle, this.#wasm);\n return new CompiledMigration(handle, this.#wasm, this.toSpec());\n } catch (error) {\n throw new MigrationError(\n `Failed to compile migration: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n}\n\n/**\n * A compiled migration that can efficiently transform records via WASM.\n *\n * Implements `Disposable` for automatic cleanup of the WASM resource.\n */\nexport class CompiledMigration implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #spec: MigrationSpec;\n\n constructor(handle: WasmHandle, wasm: WasmModule, spec: MigrationSpec) {\n this.#handle = handle;\n this.#wasm = wasm;\n this.#spec = spec;\n }\n\n /** The WASM handle for this migration. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** The migration specification used to build this migration. */\n get spec(): MigrationSpec {\n return this.#spec;\n }\n\n /**\n * Transform a record using this migration (forward direction).\n *\n * This is the hot path: data goes through WASM as MessagePack bytes\n * with no intermediate JS-heap allocation.\n *\n * @param record - The input record to transform\n * @returns The transformed record\n * @throws {@link WasmError} if the WASM call fails\n */\n lift(record: unknown): LiftResult {\n const inputBytes = packToWasm(record);\n\n try {\n const outputBytes = this.#wasm.exports.lift_record(\n this.#handle.id,\n inputBytes,\n );\n const data = unpackFromWasm(outputBytes);\n return { data };\n } catch (error) {\n throw new WasmError(\n `lift_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Bidirectional get: extract view and complement from a record.\n *\n * The complement captures data discarded by the forward projection,\n * enabling lossless round-tripping via `put()`.\n *\n * @param record - The input record\n * @returns The projected view and opaque complement bytes\n * @throws {@link WasmError} if the WASM call fails\n */\n get(record: unknown): GetResult {\n const inputBytes = packToWasm(record);\n\n try {\n const outputBytes = this.#wasm.exports.get_record(\n this.#handle.id,\n inputBytes,\n );\n const result = unpackFromWasm<{ view: unknown; complement: Uint8Array }>(outputBytes);\n return {\n view: result.view,\n complement: result.complement instanceof Uint8Array\n ? result.complement\n : new Uint8Array(result.complement as ArrayBuffer),\n };\n } catch (error) {\n throw new WasmError(\n `get_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Bidirectional put: restore a full record from a modified view and complement.\n *\n * @param view - The (possibly modified) projected view\n * @param complement - The complement from a prior `get()` call\n * @returns The restored full record\n * @throws {@link WasmError} if the WASM call fails\n */\n put(view: unknown, complement: Uint8Array): LiftResult {\n const viewBytes = packToWasm(view);\n\n try {\n const outputBytes = this.#wasm.exports.put_record(\n this.#handle.id,\n viewBytes,\n complement,\n );\n const data = unpackFromWasm(outputBytes);\n return { data };\n } catch (error) {\n throw new WasmError(\n `put_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the WASM-side compiled migration resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Check existence conditions for a migration between two schemas.\n *\n * @param src - Source schema handle\n * @param tgt - Target schema handle\n * @param spec - The migration specification\n * @param wasm - The WASM module\n * @returns The existence report\n */\nexport function checkExistence(\n protoHandle: number,\n src: BuiltSchema,\n tgt: BuiltSchema,\n spec: MigrationSpec,\n wasm: WasmModule,\n): ExistenceReport {\n const edgeMap = new Map(\n spec.edgeMap.map(([s, t]) => [\n { src: s.src, tgt: s.tgt, kind: s.kind, name: s.name ?? null },\n { src: t.src, tgt: t.tgt, kind: t.kind, name: t.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n spec.resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: spec.vertexMap,\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n const resultBytes = wasm.exports.check_existence(\n protoHandle,\n src._handle.id,\n tgt._handle.id,\n mapping,\n );\n\n return unpackFromWasm<ExistenceReport>(resultBytes);\n}\n\n/**\n * Compose two compiled migrations into a single migration.\n *\n * @param m1 - First migration (applied first)\n * @param m2 - Second migration (applied second)\n * @param wasm - The WASM module\n * @returns A new compiled migration representing m2 . m1\n * @throws {@link MigrationError} if composition fails\n */\nexport function composeMigrations(\n m1: CompiledMigration,\n m2: CompiledMigration,\n wasm: WasmModule,\n): CompiledMigration {\n try {\n const rawHandle = wasm.exports.compose_migrations(\n m1._handle.id,\n m2._handle.id,\n );\n const handle = createHandle(rawHandle, wasm);\n\n // Compose vertex maps: if m1 maps A->B and m2 maps B->C, composed maps A->C.\n // Vertices in m1 whose target is not remapped by m2 pass through unchanged.\n const composedVertexMap: Record<string, string> = {};\n for (const [src, intermediate] of Object.entries(m1.spec.vertexMap)) {\n const final_ = m2.spec.vertexMap[intermediate];\n composedVertexMap[src] = final_ ?? intermediate;\n }\n\n // Concatenate edge maps and resolvers from both migrations. The WASM side\n // performs the actual composition; this spec is a best-effort reconstruction\n // for introspection purposes.\n const composedSpec: MigrationSpec = {\n vertexMap: composedVertexMap,\n edgeMap: [...m1.spec.edgeMap, ...m2.spec.edgeMap],\n resolvers: [...m1.spec.resolvers, ...m2.spec.resolvers],\n };\n\n return new CompiledMigration(handle, wasm, composedSpec);\n } catch (error) {\n throw new MigrationError(\n `Failed to compose migrations: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n","/**\n * Instance wrapper for W-type and functor instances.\n *\n * Wraps raw MessagePack-encoded instance data and provides methods\n * for JSON conversion, validation, and element counting.\n *\n * @module\n */\n\nimport type { WasmModule, InstanceValidationResult } from './types.js';\nimport type { BuiltSchema } from './schema.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/**\n * A panproto instance wrapping raw MsgPack-encoded data.\n *\n * Instances are created by parsing raw format bytes via {@link IoRegistry.parse},\n * or by converting JSON via {@link Instance.fromJson}.\n *\n * @example\n * ```typescript\n * const instance = registry.parse('graphql', schema, inputBytes);\n * console.log(instance.elementCount);\n *\n * const json = instance.toJson();\n * const validation = instance.validate();\n * ```\n */\nexport class Instance {\n /** Raw MsgPack-encoded instance bytes (for passing back to WASM). */\n readonly _bytes: Uint8Array;\n\n /** The schema this instance conforms to. */\n readonly _schema: BuiltSchema;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n constructor(bytes: Uint8Array, schema: BuiltSchema, wasm: WasmModule) {\n this._bytes = bytes;\n this._schema = schema;\n this._wasm = wasm;\n }\n\n /** Convert this instance to JSON bytes. */\n toJson(): Uint8Array {\n return this._wasm.exports.instance_to_json(\n this._schema._handle.id,\n this._bytes,\n );\n }\n\n /** Validate this instance against its schema. */\n validate(): InstanceValidationResult {\n const resultBytes = this._wasm.exports.validate_instance(\n this._schema._handle.id,\n this._bytes,\n );\n const errors = unpackFromWasm<string[]>(resultBytes);\n return {\n isValid: errors.length === 0,\n errors,\n };\n }\n\n /** Get the number of elements in this instance. */\n get elementCount(): number {\n return this._wasm.exports.instance_element_count(this._bytes);\n }\n\n /**\n * Create an Instance from JSON input.\n *\n * @param schema - The schema the JSON data conforms to\n * @param json - JSON bytes\n * @param wasm - The WASM module\n * @returns A new Instance\n */\n static fromJson(schema: BuiltSchema, json: Uint8Array, wasm: WasmModule): Instance {\n const bytes = wasm.exports.json_to_instance(schema._handle.id, json);\n return new Instance(bytes, schema, wasm);\n }\n}\n","/**\n * I/O protocol registry for parsing and emitting instances.\n *\n * Wraps the WASM-side IoRegistry and provides parse/emit operations\n * across 77 protocol codecs organized by category.\n *\n * @module\n */\n\nimport type { WasmModule } from './types.js';\nimport type { WasmHandle } from './wasm.js';\nimport type { BuiltSchema } from './schema.js';\nimport { Instance } from './instance.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/** Protocol names organized by category. */\nexport const PROTOCOL_CATEGORIES: Readonly<Record<string, readonly string[]>> = {\n annotation: [\n 'brat', 'conllu', 'naf', 'uima', 'folia', 'tei', 'timeml', 'elan',\n 'iso_space', 'paula', 'laf_graf', 'decomp', 'ucca', 'fovea', 'bead',\n 'web_annotation', 'amr', 'concrete', 'nif',\n ],\n api: ['graphql', 'openapi', 'asyncapi', 'jsonapi', 'raml'],\n config: ['cloudformation', 'ansible', 'k8s_crd', 'hcl'],\n data_schema: [\n 'json_schema', 'yaml_schema', 'toml_schema', 'cddl', 'bson',\n 'csv_table', 'ini_schema',\n ],\n data_science: ['dataframe', 'parquet', 'arrow'],\n database: ['mongodb', 'dynamodb', 'cassandra', 'neo4j', 'sql', 'redis'],\n domain: ['geojson', 'fhir', 'rss_atom', 'vcard_ical', 'swift_mt', 'edi_x12'],\n serialization: [\n 'protobuf', 'avro', 'thrift', 'capnproto', 'flatbuffers', 'asn1',\n 'bond', 'msgpack_schema',\n ],\n type_system: [\n 'typescript', 'python', 'rust_serde', 'java', 'go_struct', 'kotlin',\n 'csharp', 'swift',\n ],\n web_document: [\n 'atproto', 'jsx', 'vue', 'svelte', 'css', 'html', 'markdown',\n 'xml_xsd', 'docx', 'odf',\n ],\n};\n\n/** Shared TextEncoder for protocol name encoding. */\nconst encoder = new TextEncoder();\n\n/**\n * Registry of I/O protocol codecs for parsing and emitting instances.\n *\n * Wraps a WASM-side IoRegistry handle and provides methods for\n * listing protocols, parsing raw bytes into instances, and emitting\n * instances back to raw format bytes.\n *\n * Implements `Disposable` so it can be used with `using` to automatically\n * clean up the WASM resource.\n *\n * @example\n * ```typescript\n * const panproto = await Panproto.init();\n * using registry = panproto.io();\n *\n * console.log(registry.protocols);\n * const instance = registry.parse('graphql', schema, inputBytes);\n * const output = registry.emit('graphql', schema, instance);\n * ```\n */\nexport class IoRegistry implements Disposable {\n readonly _handle: WasmHandle;\n readonly _wasm: WasmModule;\n private _protocolsCache: string[] | null = null;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this._handle = handle;\n this._wasm = wasm;\n }\n\n /**\n * List all registered protocol names.\n *\n * The result is cached after the first call.\n */\n get protocols(): readonly string[] {\n if (this._protocolsCache === null) {\n const bytes = this._wasm.exports.list_io_protocols(this._handle.id);\n this._protocolsCache = unpackFromWasm<string[]>(bytes);\n }\n return this._protocolsCache;\n }\n\n /** Protocol names organized by category. */\n get categories(): Readonly<Record<string, readonly string[]>> {\n return PROTOCOL_CATEGORIES;\n }\n\n /** Check if a protocol is registered. */\n hasProtocol(name: string): boolean {\n return this.protocols.includes(name);\n }\n\n /**\n * Parse raw format bytes into an Instance.\n *\n * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')\n * @param schema - The schema the data conforms to\n * @param input - Raw format bytes to parse\n * @returns A new Instance wrapping the parsed data\n * @throws {@link PanprotoError} if the protocol is not registered or parsing fails\n */\n parse(protocolName: string, schema: BuiltSchema, input: Uint8Array): Instance {\n const nameBytes = encoder.encode(protocolName);\n const resultBytes = this._wasm.exports.parse_instance(\n this._handle.id,\n nameBytes,\n schema._handle.id,\n input,\n );\n return new Instance(resultBytes, schema, this._wasm);\n }\n\n /**\n * Emit an Instance to raw format bytes.\n *\n * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')\n * @param schema - The schema the instance conforms to\n * @param instance - The instance to emit\n * @returns Raw format bytes\n * @throws {@link PanprotoError} if the protocol is not registered or emission fails\n */\n emit(protocolName: string, schema: BuiltSchema, instance: Instance): Uint8Array {\n const nameBytes = encoder.encode(protocolName);\n return this._wasm.exports.emit_instance(\n this._handle.id,\n nameBytes,\n schema._handle.id,\n instance._bytes,\n );\n }\n\n /** Release the WASM-side IoRegistry resource. */\n [Symbol.dispose](): void {\n this._handle[Symbol.dispose]();\n }\n}\n","/**\n * VCS (Version Control System) for schema evolution.\n *\n * Provides a git-like API for versioning schemas with branches,\n * commits, merges, and blame.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n VcsLogEntry,\n VcsStatus,\n VcsOpResult,\n VcsBlameResult,\n} from './types.js';\nimport { WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { unpackFromWasm } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\n\nconst encoder = new TextEncoder();\n\n/**\n * An in-memory VCS repository for schema evolution.\n *\n * Implements `Disposable` for automatic cleanup of the WASM-side resource.\n *\n * @example\n * ```typescript\n * using repo = Repository.init('atproto', wasm);\n * repo.add(schema);\n * repo.commit('initial schema', 'alice');\n * const log = repo.log();\n * ```\n */\nexport class Repository implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #protocolName: string;\n\n private constructor(handle: WasmHandle, protocolName: string, wasm: WasmModule) {\n this.#handle = handle;\n this.#protocolName = protocolName;\n this.#wasm = wasm;\n }\n\n /**\n * Initialize a new in-memory repository.\n *\n * @param protocolName - The protocol this repository tracks\n * @param wasm - The WASM module\n * @returns A new disposable Repository\n */\n static init(protocolName: string, wasm: WasmModule): Repository {\n const nameBytes = encoder.encode(protocolName);\n const rawHandle = wasm.exports.vcs_init(nameBytes);\n const handle = createHandle(rawHandle, wasm);\n return new Repository(handle, protocolName, wasm);\n }\n\n /** The protocol name this repository tracks. */\n get protocolName(): string {\n return this.#protocolName;\n }\n\n /** The underlying WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Stage a schema for the next commit.\n *\n * @param schema - The built schema to stage\n * @returns An object with the schema's object ID\n */\n add(schema: BuiltSchema): { schemaId: string } {\n try {\n const resultBytes = this.#wasm.exports.vcs_add(\n this.#handle.id,\n schema._handle.id,\n );\n const result = unpackFromWasm<{ schema_id: string }>(resultBytes);\n return { schemaId: result.schema_id };\n } catch (error) {\n throw new WasmError(\n `vcs_add failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Create a commit from the current staging area.\n *\n * @param message - The commit message\n * @param author - The commit author\n * @returns The commit result\n */\n commit(message: string, author: string): Uint8Array {\n try {\n return this.#wasm.exports.vcs_commit(\n this.#handle.id,\n encoder.encode(message),\n encoder.encode(author),\n );\n } catch (error) {\n throw new WasmError(\n `vcs_commit failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Walk the commit log from HEAD.\n *\n * @param count - Maximum number of log entries to return (default: 50)\n * @returns Array of commit log entries\n */\n log(count: number = 50): VcsLogEntry[] {\n try {\n const resultBytes = this.#wasm.exports.vcs_log(this.#handle.id, count);\n return unpackFromWasm<VcsLogEntry[]>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_log failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Get the repository status.\n *\n * @returns Current branch and HEAD commit info\n */\n status(): VcsStatus {\n try {\n const resultBytes = this.#wasm.exports.vcs_status(this.#handle.id);\n return unpackFromWasm<VcsStatus>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_status failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Get diff information for the repository.\n *\n * @returns Diff result with branch info\n */\n diff(): unknown {\n try {\n const resultBytes = this.#wasm.exports.vcs_diff(this.#handle.id);\n return unpackFromWasm(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_diff failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Create a new branch at the current HEAD.\n *\n * @param name - The branch name\n * @returns Operation result\n */\n branch(name: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_branch(\n this.#handle.id,\n encoder.encode(name),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_branch failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Checkout a branch.\n *\n * @param target - The branch name to checkout\n * @returns Operation result\n */\n checkout(target: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_checkout(\n this.#handle.id,\n encoder.encode(target),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_checkout failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Merge a branch into the current branch.\n *\n * @param branchName - The branch to merge\n * @returns Operation result\n */\n merge(branchName: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_merge(\n this.#handle.id,\n encoder.encode(branchName),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_merge failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Stash the current working state.\n *\n * @returns Operation result\n */\n stash(): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_stash(this.#handle.id);\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_stash failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Pop the most recent stash entry.\n *\n * @returns Operation result\n */\n stashPop(): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_stash_pop(this.#handle.id);\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_stash_pop failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Find which commit introduced a vertex.\n *\n * @param vertexId - The vertex ID to blame\n * @returns Blame result with commit info\n */\n blame(vertexId: string): VcsBlameResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_blame(\n this.#handle.id,\n encoder.encode(vertexId),\n );\n return unpackFromWasm<VcsBlameResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_blame failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the WASM-side repository resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n","/**\n * Main Panproto class — the primary entry point for the SDK.\n *\n * Wraps the WASM module and provides the high-level API for working\n * with protocols, schemas, migrations, and diffs.\n *\n * @module\n */\n\nimport type { WasmModule, ProtocolSpec, DiffReport, FullSchemaDiff, SchemaValidationIssue } from './types.js';\nimport { PanprotoError, WasmError } from './types.js';\nimport { loadWasm, type WasmGlueModule, createHandle } from './wasm.js';\nimport { LensHandle } from './lens.js';\nimport {\n Protocol,\n defineProtocol,\n BUILTIN_PROTOCOLS,\n getProtocolNames,\n getBuiltinProtocol,\n} from './protocol.js';\nimport { BuiltSchema } from './schema.js';\nimport {\n MigrationBuilder,\n CompiledMigration,\n checkExistence,\n composeMigrations,\n} from './migration.js';\nimport { unpackFromWasm } from './msgpack.js';\nimport { FullDiffReport, ValidationResult } from './check.js';\nimport { Instance } from './instance.js';\nimport { IoRegistry } from './io.js';\nimport { Repository } from './vcs.js';\n\n/**\n * The main entry point for the panproto SDK.\n *\n * Create an instance with {@link Panproto.init}, then use it to define\n * protocols, build schemas, compile migrations, and diff schemas.\n *\n * Implements `Disposable` so it can be used with `using` to automatically\n * clean up all WASM resources.\n *\n * @example\n * ```typescript\n * const panproto = await Panproto.init();\n * const atproto = panproto.protocol('atproto');\n *\n * const schema = atproto.schema()\n * .vertex('post', 'record', { nsid: 'app.bsky.feed.post' })\n * .vertex('post:body', 'object')\n * .edge('post', 'post:body', 'record-schema')\n * .build();\n *\n * const migration = panproto.migration(oldSchema, newSchema)\n * .map('post', 'post')\n * .compile();\n *\n * const result = migration.lift(inputRecord);\n * ```\n */\nexport class Panproto implements Disposable {\n readonly #wasm: WasmModule;\n readonly #protocols: Map<string, Protocol>;\n\n private constructor(wasm: WasmModule) {\n this.#wasm = wasm;\n this.#protocols = new Map();\n }\n\n /**\n * Initialize the panproto SDK by loading the WASM module.\n *\n * @param input - URL to the wasm-bindgen glue module, or a pre-imported\n * glue module object (for bundler environments like Vite).\n * Defaults to the bundled glue module.\n * @returns An initialized Panproto instance\n * @throws {@link import('./types.js').WasmError} if WASM loading fails\n */\n static async init(input?: string | URL | WasmGlueModule): Promise<Panproto> {\n const wasm = await loadWasm(input);\n return new Panproto(wasm);\n }\n\n /**\n * Get or register a protocol by name.\n *\n * If the protocol is a built-in (e.g., 'atproto', 'sql'), it is\n * automatically registered on first access. Custom protocols must\n * be registered first with {@link Panproto.defineProtocol}.\n *\n * @param name - The protocol name\n * @returns The protocol instance\n * @throws {@link PanprotoError} if the protocol is not found\n */\n protocol(name: string): Protocol {\n const cached = this.#protocols.get(name);\n if (cached) return cached;\n\n // Try hardcoded built-in protocols first (fast path)\n const builtinSpec = BUILTIN_PROTOCOLS.get(name);\n if (builtinSpec) {\n const proto = defineProtocol(builtinSpec, this.#wasm);\n this.#protocols.set(name, proto);\n return proto;\n }\n\n // Try fetching from WASM (supports all 76 protocols)\n const wasmSpec = getBuiltinProtocol(name, this.#wasm);\n if (wasmSpec) {\n const proto = defineProtocol(wasmSpec, this.#wasm);\n this.#protocols.set(name, proto);\n return proto;\n }\n\n throw new PanprotoError(\n `Protocol \"${name}\" not found. Register it with defineProtocol() first.`,\n );\n }\n\n /**\n * Define and register a custom protocol.\n *\n * @param spec - The protocol specification\n * @returns The registered protocol\n * @throws {@link PanprotoError} if registration fails\n */\n defineProtocol(spec: ProtocolSpec): Protocol {\n const proto = defineProtocol(spec, this.#wasm);\n this.#protocols.set(spec.name, proto);\n return proto;\n }\n\n /**\n * Start building a migration between two schemas.\n *\n * @param src - The source schema\n * @param tgt - The target schema\n * @returns A migration builder\n */\n migration(src: BuiltSchema, tgt: BuiltSchema): MigrationBuilder {\n return new MigrationBuilder(src, tgt, this.#wasm);\n }\n\n /**\n * Check existence conditions for a proposed migration.\n *\n * Verifies that the migration specification satisfies all\n * protocol-derived constraints (edge coverage, kind consistency,\n * required fields, etc.).\n *\n * @param src - The source schema\n * @param tgt - The target schema\n * @param builder - The migration builder with mappings\n * @returns The existence report\n */\n checkExistence(\n src: BuiltSchema,\n tgt: BuiltSchema,\n builder: MigrationBuilder,\n ): import('./types.js').ExistenceReport {\n const proto = this.#protocols.get(src.protocol);\n if (!proto) {\n throw new PanprotoError(\n `Protocol \"${src.protocol}\" not registered. Call protocol() first.`,\n );\n }\n return checkExistence(proto._handle.id, src, tgt, builder.toSpec(), this.#wasm);\n }\n\n /**\n * Compose two compiled migrations into a single migration.\n *\n * The resulting migration is equivalent to applying `m1` then `m2`.\n *\n * @param m1 - First migration (applied first)\n * @param m2 - Second migration (applied second)\n * @returns The composed migration\n * @throws {@link import('./types.js').MigrationError} if composition fails\n */\n compose(m1: CompiledMigration, m2: CompiledMigration): CompiledMigration {\n return composeMigrations(m1, m2, this.#wasm);\n }\n\n /**\n * Compose two lenses into a single lens.\n *\n * The resulting lens is equivalent to applying `l1` then `l2`.\n *\n * @param l1 - First lens (applied first)\n * @param l2 - Second lens (applied second)\n * @returns A new LensHandle representing the composition\n * @throws {@link import('./types.js').WasmError} if composition fails\n */\n composeLenses(l1: LensHandle, l2: LensHandle): LensHandle {\n try {\n const rawHandle = this.#wasm.exports.compose_lenses(\n l1._handle.id,\n l2._handle.id,\n );\n const handle = createHandle(rawHandle, this.#wasm);\n return new LensHandle(handle, this.#wasm);\n } catch (error) {\n throw new WasmError(\n `compose_lenses failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Diff two schemas and produce a compatibility report.\n *\n * @param oldSchema - The old/source schema\n * @param newSchema - The new/target schema\n * @returns A diff report with changes and compatibility classification\n */\n diff(oldSchema: BuiltSchema, newSchema: BuiltSchema): DiffReport {\n const resultBytes = this.#wasm.exports.diff_schemas(\n oldSchema._handle.id,\n newSchema._handle.id,\n );\n return unpackFromWasm<DiffReport>(resultBytes);\n }\n\n /** Diff two schemas using the full panproto-check engine (20+ change categories). */\n diffFull(oldSchema: BuiltSchema, newSchema: BuiltSchema): FullDiffReport {\n const bytes = this.#wasm.exports.diff_schemas_full(\n oldSchema._handle.id,\n newSchema._handle.id,\n );\n const data = unpackFromWasm<FullSchemaDiff>(bytes);\n return new FullDiffReport(data, bytes, this.#wasm);\n }\n\n /** Normalize a schema by collapsing reference chains. Returns a new BuiltSchema. */\n normalize(schema: BuiltSchema): BuiltSchema {\n const handle = this.#wasm.exports.normalize_schema(schema._handle.id);\n // Create a new BuiltSchema from the handle\n return BuiltSchema._fromHandle(handle, schema.data, schema.protocol, this.#wasm);\n }\n\n /** Validate a schema against its protocol's rules. */\n validateSchema(schema: BuiltSchema, protocol: Protocol): ValidationResult {\n const bytes = this.#wasm.exports.validate_schema(\n schema._handle.id,\n protocol._handle.id,\n );\n const issues = unpackFromWasm<SchemaValidationIssue[]>(bytes);\n return new ValidationResult(issues);\n }\n\n /**\n * Create an I/O protocol registry for parsing and emitting instances.\n *\n * The returned registry wraps all 77 built-in protocol codecs and\n * implements `Disposable` for automatic cleanup.\n *\n * @returns A new IoRegistry\n */\n io(): IoRegistry {\n const rawHandle = this.#wasm.exports.register_io_protocols();\n const handle = createHandle(rawHandle, this.#wasm);\n return new IoRegistry(handle, this.#wasm);\n }\n\n /**\n * Parse JSON bytes into an Instance.\n *\n * Convenience method that wraps `json_to_instance`.\n *\n * @param schema - The schema the JSON data conforms to\n * @param json - JSON bytes or a JSON string\n * @returns A new Instance\n */\n parseJson(schema: BuiltSchema, json: Uint8Array | string): Instance {\n const jsonBytes = typeof json === 'string'\n ? new TextEncoder().encode(json)\n : json;\n return Instance.fromJson(schema, jsonBytes, this.#wasm);\n }\n\n /**\n * Convert an Instance to JSON bytes.\n *\n * Convenience method that wraps `instance_to_json`.\n *\n * @param schema - The schema the instance conforms to\n * @param instance - The instance to convert\n * @returns JSON bytes\n */\n toJson(schema: BuiltSchema, instance: Instance): Uint8Array {\n return this.#wasm.exports.instance_to_json(\n schema._handle.id,\n instance._bytes,\n );\n }\n\n /**\n * List all built-in protocol names.\n *\n * Returns the names of all 76 built-in protocols supported by the\n * WASM layer.\n *\n * @returns Array of protocol name strings\n */\n listProtocols(): string[] {\n return [...getProtocolNames(this.#wasm)];\n }\n\n /**\n * Initialize an in-memory VCS repository.\n *\n * @param protocolName - The protocol name for this repository\n * @returns A disposable VCS Repository\n */\n initRepo(protocolName: string): Repository {\n return Repository.init(protocolName, this.#wasm);\n }\n\n /**\n * Release all WASM resources held by this instance.\n *\n * Disposes all cached protocols. After disposal, this instance\n * must not be used.\n */\n [Symbol.dispose](): void {\n for (const proto of this.#protocols.values()) {\n proto[Symbol.dispose]();\n }\n this.#protocols.clear();\n }\n}\n","/**\n * GAT (Generalized Algebraic Theory) operations.\n *\n * Provides a fluent API for creating theories, computing colimits,\n * checking morphisms, and migrating models.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n TheorySpec,\n TheoryMorphism,\n MorphismCheckResult,\n Sort,\n GatOperation,\n Equation,\n} from './types.js';\nimport { PanprotoError, WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\n\n/**\n * A disposable handle to a WASM-side Theory resource.\n *\n * Implements `Disposable` for use with `using` declarations.\n */\nexport class TheoryHandle implements Disposable {\n readonly #handle: WasmHandle;\n /** @internal Retained for future sort/op inspection methods. */\n readonly _wasm: WasmModule;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this.#handle = handle;\n this._wasm = wasm;\n }\n\n /** The WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** Release the WASM-side theory resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Fluent builder for constructing a Theory specification.\n *\n * @example\n * ```typescript\n * const monoid = new TheoryBuilder('Monoid')\n * .sort('Carrier')\n * .op('mul', [['a', 'Carrier'], ['b', 'Carrier']], 'Carrier')\n * .op('unit', [], 'Carrier')\n * .build(wasm);\n * ```\n */\nexport class TheoryBuilder {\n readonly #name: string;\n readonly #extends: string[];\n readonly #sorts: Sort[];\n readonly #ops: GatOperation[];\n readonly #eqs: Equation[];\n\n constructor(name: string) {\n this.#name = name;\n this.#extends = [];\n this.#sorts = [];\n this.#ops = [];\n this.#eqs = [];\n }\n\n /** Declare that this theory extends a parent theory. */\n extends(parentName: string): this {\n this.#extends.push(parentName);\n return this;\n }\n\n /** Add a simple sort (no parameters). */\n sort(name: string): this {\n this.#sorts.push({ name, params: [] });\n return this;\n }\n\n /** Add a dependent sort with parameters. */\n dependentSort(name: string, params: { name: string; sort: string }[]): this {\n this.#sorts.push({ name, params });\n return this;\n }\n\n /** Add an operation. */\n op(name: string, inputs: [string, string][], output: string): this {\n this.#ops.push({ name, inputs, output });\n return this;\n }\n\n /** Add an equation (axiom). */\n eq(name: string, lhs: import('./types.js').Term, rhs: import('./types.js').Term): this {\n this.#eqs.push({ name, lhs, rhs });\n return this;\n }\n\n /** Get the theory specification. */\n toSpec(): TheorySpec {\n return {\n name: this.#name,\n extends: this.#extends,\n sorts: this.#sorts,\n ops: this.#ops,\n eqs: this.#eqs,\n };\n }\n\n /**\n * Build the theory and register it in WASM.\n *\n * @param wasm - The WASM module\n * @returns A disposable TheoryHandle\n * @throws {@link PanprotoError} if the WASM call fails\n */\n build(wasm: WasmModule): TheoryHandle {\n return createTheory(this.toSpec(), wasm);\n }\n}\n\n/**\n * Create a theory from a specification.\n *\n * @param spec - The theory specification\n * @param wasm - The WASM module\n * @returns A disposable TheoryHandle\n * @throws {@link PanprotoError} if serialization or WASM fails\n */\nexport function createTheory(spec: TheorySpec, wasm: WasmModule): TheoryHandle {\n try {\n const bytes = packToWasm(spec);\n const rawHandle = wasm.exports.create_theory(bytes);\n const handle = createHandle(rawHandle, wasm);\n return new TheoryHandle(handle, wasm);\n } catch (error) {\n throw new PanprotoError(\n `Failed to create theory \"${spec.name}\": ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n/**\n * Compute the colimit (pushout) of two theories over a shared base.\n *\n * @param t1 - First theory handle\n * @param t2 - Second theory handle\n * @param shared - Shared base theory handle\n * @param wasm - The WASM module\n * @returns A new TheoryHandle for the colimit theory\n * @throws {@link WasmError} if computation fails\n */\nexport function colimit(\n t1: TheoryHandle,\n t2: TheoryHandle,\n shared: TheoryHandle,\n wasm: WasmModule,\n): TheoryHandle {\n try {\n const rawHandle = wasm.exports.colimit_theories(\n t1._handle.id,\n t2._handle.id,\n shared._handle.id,\n );\n const handle = createHandle(rawHandle, wasm);\n return new TheoryHandle(handle, wasm);\n } catch (error) {\n throw new WasmError(\n `colimit_theories failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n/**\n * Check whether a theory morphism is valid.\n *\n * @param morphism - The morphism to check\n * @param domain - Handle to the domain theory\n * @param codomain - Handle to the codomain theory\n * @param wasm - The WASM module\n * @returns A result indicating validity and any error\n */\nexport function checkMorphism(\n morphism: TheoryMorphism,\n domain: TheoryHandle,\n codomain: TheoryHandle,\n wasm: WasmModule,\n): MorphismCheckResult {\n const morphBytes = packToWasm(morphism);\n const resultBytes = wasm.exports.check_morphism(\n morphBytes,\n domain._handle.id,\n codomain._handle.id,\n );\n return unpackFromWasm<MorphismCheckResult>(resultBytes);\n}\n\n/**\n * Migrate a model's sort interpretations through a morphism.\n *\n * Since operation interpretations (functions) cannot cross the WASM\n * boundary, only sort interpretations are migrated.\n *\n * @param sortInterp - Sort interpretations as name-to-values map\n * @param morphism - The theory morphism to migrate along\n * @param wasm - The WASM module\n * @returns Reindexed sort interpretations\n */\nexport function migrateModel(\n sortInterp: Record<string, unknown[]>,\n morphism: TheoryMorphism,\n wasm: WasmModule,\n): Record<string, unknown[]> {\n const modelBytes = packToWasm(sortInterp);\n const morphBytes = packToWasm(morphism);\n const resultBytes = wasm.exports.migrate_model(modelBytes, morphBytes);\n return unpackFromWasm<Record<string, unknown[]>>(resultBytes);\n}\n"],"names":["exports","encoder"],"mappings":";AAqeO,MAAM,sBAAsB,MAAM;AAAA,EACrB,OAAe;AAAA,EAEjC,YAAY,SAAiB,SAAwB;AACnD,UAAM,SAAS,OAAO;AAAA,EACxB;AACF;AAGO,MAAM,kBAAkB,cAAc;AAAA,EACzB,OAAO;AAC3B;AAGO,MAAM,8BAA8B,cAAc;AAAA,EAGvD,YACE,SACS,QACT;AACA,UAAM,OAAO;AAFJ,SAAA,SAAA;AAAA,EAGX;AAAA,EAPkB,OAAO;AAQ3B;AAGO,MAAM,uBAAuB,cAAc;AAAA,EAC9B,OAAO;AAC3B;AAGO,MAAM,4BAA4B,cAAc;AAAA,EAGrD,YACE,SACS,QACT;AACA,UAAM,OAAO;AAFJ,SAAA,SAAA;AAAA,EAGX;AAAA,EAPkB,OAAO;AAQ3B;AC/fA,MAAM,mBAAmB,IAAA,IAAA,sBAAA,YAAA,GAAA;AA4EzB,eAAsB,SAAS,OAA4D;AACzF,MAAI;AACF,QAAI;AAEJ,QAAI,SAAS,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY,YAAY;AAEnG,aAAO;AAAA,IACT,OAAO;AAEL,YAAM,MAAO,SAAsC;AACnD,aAAO,MAAM;AAAA;AAAA,QAA0B,OAAO,GAAG;AAAA;AAAA,IACnD;AAEA,UAAM,aAAa,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AAC;AAAA,MACjG,EAAE,OAAO,MAAA;AAAA,IAAM;AAAA,EAEnB;AACF;AAYO,SAAS,QACd,IACA,IACA,QACA,MACc;AACd,MAAI;AACF,UAAM,YAAY,KAAK,QAAQ;AAAA,MAC7B,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ;AAAA,MACX,OAAO,QAAQ;AAAA,IAAA;AAEjB,UAAM,SAAS,aAAa,WAAW,IAAI;AAC3C,WAAO,IAAI,aAAa,QAAQ,IAAI;AAAA,EACtC,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAClF,EAAE,OAAO,MAAA;AAAA,IAAM;AAAA,EAEnB;AACF;AAWO,SAAS,cACd,UACA,QACA,UACA,MACqB;AACrB,QAAM,aAAa,WAAW,QAAQ;AACtC,QAAM,cAAc,KAAK,QAAQ;AAAA,IAC/B;AAAA,IACA,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ;AAAA,EAAA;AAEnB,SAAO,eAAoC,WAAW;AACxD;AAaO,SAAS,aACd,YACA,UACA,MAC2B;AAC3B,QAAM,aAAa,WAAW,UAAU;AACxC,QAAM,aAAa,WAAW,QAAQ;AACtC,QAAM,cAAc,KAAK,QAAQ,cAAc,YAAY,UAAU;AACrE,SAAO,eAA0C,WAAW;AAC9D;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/wasm.ts","../src/msgpack.ts","../src/lens.ts","../src/check.ts","../src/schema.ts","../src/protocol.ts","../src/migration.ts","../src/instance.ts","../src/io.ts","../src/vcs.ts","../src/panproto.ts","../src/gat.ts"],"sourcesContent":["/**\n * Core type definitions for the @panproto/core SDK.\n *\n * These types mirror the Rust-side structures but use JavaScript idioms:\n * - `HashMap<K,V>` becomes `Map<K,V>` or `Record<string, V>` for string keys\n * - `Option<T>` becomes `T | undefined`\n * - `Vec<T>` becomes `T[]`\n * - `Result<T,E>` becomes thrown `PanprotoError` or return value\n *\n * @module\n */\n\n// ---------------------------------------------------------------------------\n// Handle types (opaque wrappers — never expose raw u32)\n// ---------------------------------------------------------------------------\n\n/** Opaque handle to a WASM-side resource. */\nexport interface Handle {\n readonly __brand: unique symbol;\n readonly id: number;\n}\n\n/** Branded handle for a protocol resource. */\nexport interface ProtocolHandle extends Handle {\n readonly __kind: 'protocol';\n}\n\n/** Branded handle for a schema resource. */\nexport interface SchemaHandle extends Handle {\n readonly __kind: 'schema';\n}\n\n/** Branded handle for a compiled migration resource. */\nexport interface MigrationHandle extends Handle {\n readonly __kind: 'migration';\n}\n\n// ---------------------------------------------------------------------------\n// Protocol\n// ---------------------------------------------------------------------------\n\n/** Rule constraining which vertex kinds an edge can connect. */\nexport interface EdgeRule {\n readonly edgeKind: string;\n /** Allowed source vertex kinds. Empty array means any. */\n readonly srcKinds: readonly string[];\n /** Allowed target vertex kinds. Empty array means any. */\n readonly tgtKinds: readonly string[];\n}\n\n/** A protocol specification defining schema/instance theories and validation rules. */\nexport interface ProtocolSpec {\n readonly name: string;\n readonly schemaTheory: string;\n readonly instanceTheory: string;\n readonly edgeRules: readonly EdgeRule[];\n readonly objKinds: readonly string[];\n readonly constraintSorts: readonly string[];\n}\n\n// ---------------------------------------------------------------------------\n// Schema\n// ---------------------------------------------------------------------------\n\n/** Options for vertex creation. */\nexport interface VertexOptions {\n readonly nsid?: string;\n}\n\n/** A vertex in a schema graph. */\nexport interface Vertex {\n readonly id: string;\n readonly kind: string;\n readonly nsid?: string | undefined;\n}\n\n/** A directed edge in a schema graph. */\nexport interface Edge {\n readonly src: string;\n readonly tgt: string;\n readonly kind: string;\n readonly name?: string | undefined;\n}\n\n/** A hyperedge with a labeled signature. */\nexport interface HyperEdge {\n readonly id: string;\n readonly kind: string;\n readonly signature: Readonly<Record<string, string>>;\n readonly parentLabel: string;\n}\n\n/** A constraint on a vertex (sort + value). */\nexport interface Constraint {\n readonly sort: string;\n readonly value: string;\n}\n\n/** A variant in a schema graph (union member). */\nexport interface Variant {\n readonly id: string;\n readonly parent_vertex: string;\n readonly tag?: string | undefined;\n}\n\n/** A recursion point (mu-binding site). */\nexport interface RecursionPoint {\n readonly mu_id: string;\n readonly target_vertex: string;\n}\n\n/** Usage mode for a vertex (structural, linear, or affine). */\nexport type UsageMode = 'structural' | 'linear' | 'affine';\n\n/** A span between two vertices. */\nexport interface Span {\n readonly id: string;\n readonly left: string;\n readonly right: string;\n}\n\n/** Options for edge creation. */\nexport interface EdgeOptions {\n readonly name?: string;\n}\n\n/** Serializable schema representation. */\nexport interface SchemaData {\n readonly protocol: string;\n readonly vertices: Readonly<Record<string, Vertex>>;\n readonly edges: readonly Edge[];\n readonly hyperEdges: Readonly<Record<string, HyperEdge>>;\n readonly constraints: Readonly<Record<string, readonly Constraint[]>>;\n readonly required: Readonly<Record<string, readonly Edge[]>>;\n readonly variants: Readonly<Record<string, readonly Variant[]>>;\n readonly orderings: Readonly<Record<string, number>>;\n readonly recursionPoints: Readonly<Record<string, RecursionPoint>>;\n readonly usageModes: Readonly<Record<string, UsageMode>>;\n readonly spans: Readonly<Record<string, Span>>;\n readonly nominal: Readonly<Record<string, boolean>>;\n}\n\n// ---------------------------------------------------------------------------\n// Migration\n// ---------------------------------------------------------------------------\n\n/** A vertex mapping entry for migration building. */\nexport interface VertexMapping {\n readonly src: string;\n readonly tgt: string;\n}\n\n/** A migration specification (maps between two schemas). */\nexport interface MigrationSpec {\n readonly vertexMap: Readonly<Record<string, string>>;\n readonly edgeMap: readonly [Edge, Edge][];\n readonly resolvers: readonly [[string, string], Edge][];\n}\n\n/** Result of applying a compiled migration to a record. */\nexport interface LiftResult {\n readonly data: unknown;\n /** Raw msgpack-encoded instance bytes (for passing to instance_to_json). */\n readonly _rawBytes?: Uint8Array;\n}\n\n/** Get result for bidirectional lens operation. */\nexport interface GetResult {\n readonly view: unknown;\n readonly complement: Uint8Array;\n}\n\n// ---------------------------------------------------------------------------\n// Diff / Compatibility\n// ---------------------------------------------------------------------------\n\n/** A single change detected between two schemas. */\nexport interface SchemaChange {\n readonly kind: 'vertex-added' | 'vertex-removed' | 'edge-added' | 'edge-removed'\n | 'constraint-added' | 'constraint-removed' | 'constraint-changed'\n | 'kind-changed' | 'required-added' | 'required-removed';\n readonly path: string;\n readonly detail?: string | undefined;\n}\n\n/** Compatibility classification. */\nexport type Compatibility = 'fully-compatible' | 'backward-compatible' | 'breaking';\n\n/** Schema diff report. */\nexport interface DiffReport {\n readonly compatibility: Compatibility;\n readonly changes: readonly SchemaChange[];\n}\n\n// ---------------------------------------------------------------------------\n// Existence checking\n// ---------------------------------------------------------------------------\n\n/** A structured existence error. */\nexport interface ExistenceError {\n readonly kind: 'edge-missing' | 'kind-inconsistency' | 'label-inconsistency'\n | 'required-field-missing' | 'constraint-tightened' | 'resolver-invalid'\n | 'well-formedness' | 'signature-coherence' | 'simultaneity' | 'reachability-risk';\n readonly message: string;\n readonly detail?: Record<string, unknown> | undefined;\n}\n\n/** Result of existence checking. */\nexport interface ExistenceReport {\n readonly valid: boolean;\n readonly errors: readonly ExistenceError[];\n}\n\n// ---------------------------------------------------------------------------\n// Full Diff / Compatibility (panproto-check)\n// ---------------------------------------------------------------------------\n\n/** A kind change on a vertex. */\nexport interface KindChange {\n readonly vertexId: string;\n readonly oldKind: string;\n readonly newKind: string;\n}\n\n/** A constraint change on a vertex. */\nexport interface ConstraintChange {\n readonly sort: string;\n readonly oldValue: string;\n readonly newValue: string;\n}\n\n/** Constraint diff for a single vertex. */\nexport interface ConstraintDiff {\n readonly added: readonly Constraint[];\n readonly removed: readonly Constraint[];\n readonly changed: readonly ConstraintChange[];\n}\n\n/** Full schema diff with 20+ change categories. */\nexport interface FullSchemaDiff {\n readonly added_vertices: readonly string[];\n readonly removed_vertices: readonly string[];\n readonly kind_changes: readonly KindChange[];\n readonly added_edges: readonly Edge[];\n readonly removed_edges: readonly Edge[];\n readonly modified_constraints: Readonly<Record<string, ConstraintDiff>>;\n readonly added_hyper_edges: readonly string[];\n readonly removed_hyper_edges: readonly string[];\n readonly modified_hyper_edges: readonly Record<string, unknown>[];\n readonly added_required: Readonly<Record<string, readonly Edge[]>>;\n readonly removed_required: Readonly<Record<string, readonly Edge[]>>;\n readonly added_nsids: Readonly<Record<string, string>>;\n readonly removed_nsids: readonly string[];\n readonly changed_nsids: readonly [string, string, string][];\n readonly added_variants: readonly Variant[];\n readonly removed_variants: readonly Variant[];\n readonly modified_variants: readonly Record<string, unknown>[];\n readonly order_changes: readonly [Edge, number | null, number | null][];\n readonly added_recursion_points: readonly RecursionPoint[];\n readonly removed_recursion_points: readonly RecursionPoint[];\n readonly modified_recursion_points: readonly Record<string, unknown>[];\n readonly usage_mode_changes: readonly [Edge, UsageMode, UsageMode][];\n readonly added_spans: readonly string[];\n readonly removed_spans: readonly string[];\n readonly modified_spans: readonly Record<string, unknown>[];\n readonly nominal_changes: readonly [string, boolean, boolean][];\n}\n\n/** A breaking change detected by the compatibility checker. */\nexport interface BreakingChange {\n readonly type: string;\n readonly details: Record<string, unknown>;\n}\n\n/** A non-breaking change detected by the compatibility checker. */\nexport interface NonBreakingChange {\n readonly type: string;\n readonly details: Record<string, unknown>;\n}\n\n/** Compatibility report from classifying a schema diff. */\nexport interface CompatReportData {\n readonly breaking: readonly BreakingChange[];\n readonly non_breaking: readonly NonBreakingChange[];\n readonly compatible: boolean;\n}\n\n/** A schema validation error. */\nexport interface SchemaValidationIssue {\n readonly type: string;\n readonly [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// WASM module interface\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// GAT types\n// ---------------------------------------------------------------------------\n\n/** A parameter of a dependent sort. */\nexport interface SortParam {\n readonly name: string;\n readonly sort: string;\n}\n\n/** A sort declaration in a GAT. */\nexport interface Sort {\n readonly name: string;\n readonly params: readonly SortParam[];\n}\n\n/** A GAT operation (term constructor). */\nexport interface GatOperation {\n readonly name: string;\n readonly inputs: readonly [string, string][];\n readonly output: string;\n}\n\n/** A term in a GAT expression. */\nexport type Term =\n | { readonly Var: string }\n | { readonly App: { readonly op: string; readonly args: readonly Term[] } };\n\n/** An equation (axiom) in a GAT. */\nexport interface Equation {\n readonly name: string;\n readonly lhs: Term;\n readonly rhs: Term;\n}\n\n/** A theory specification. */\nexport interface TheorySpec {\n readonly name: string;\n readonly extends: readonly string[];\n readonly sorts: readonly Sort[];\n readonly ops: readonly GatOperation[];\n readonly eqs: readonly Equation[];\n}\n\n/** A theory morphism (structure-preserving map between theories). */\nexport interface TheoryMorphism {\n readonly name: string;\n readonly domain: string;\n readonly codomain: string;\n readonly sort_map: Readonly<Record<string, string>>;\n readonly op_map: Readonly<Record<string, string>>;\n}\n\n/** Result of checking a morphism. */\nexport interface MorphismCheckResult {\n readonly valid: boolean;\n readonly error: string | null;\n}\n\n/** Branded handle for a theory resource. */\nexport interface TheoryHandle extends Handle {\n readonly __kind: 'theory';\n}\n\n// ---------------------------------------------------------------------------\n// VCS types\n// ---------------------------------------------------------------------------\n\n/** Branded handle for a VCS repository resource. */\nexport interface VcsRepoHandle extends Handle {\n readonly __kind: 'vcs-repo';\n}\n\n/** A VCS commit log entry. */\nexport interface VcsLogEntry {\n readonly message: string;\n readonly author: string;\n readonly timestamp: number;\n readonly protocol: string;\n}\n\n/** VCS repository status. */\nexport interface VcsStatus {\n readonly branch: string | null;\n readonly head_commit: string | null;\n}\n\n/** VCS operation result. */\nexport interface VcsOpResult {\n readonly success: boolean;\n readonly message: string;\n}\n\n/** VCS blame result. */\nexport interface VcsBlameResult {\n readonly commit_id: string;\n readonly author: string;\n readonly timestamp: number;\n readonly message: string;\n}\n\n// ---------------------------------------------------------------------------\n// WASM module interface\n// ---------------------------------------------------------------------------\n\n/** The raw WASM module interface. */\nexport interface WasmExports {\n define_protocol(spec: Uint8Array): number;\n build_schema(proto: number, ops: Uint8Array): number;\n check_existence(proto: number, src: number, tgt: number, mapping: Uint8Array): Uint8Array;\n compile_migration(src: number, tgt: number, mapping: Uint8Array): number;\n lift_record(migration: number, record: Uint8Array): Uint8Array;\n get_record(migration: number, record: Uint8Array): Uint8Array;\n put_record(migration: number, view: Uint8Array, complement: Uint8Array): Uint8Array;\n compose_migrations(m1: number, m2: number): number;\n diff_schemas(s1: number, s2: number): Uint8Array;\n free_handle(handle: number): void;\n diff_schemas_full(s1: number, s2: number): Uint8Array;\n classify_diff(proto: number, diff_bytes: Uint8Array): Uint8Array;\n report_text(report_bytes: Uint8Array): string;\n report_json(report_bytes: Uint8Array): string;\n normalize_schema(schema: number): number;\n validate_schema(schema: number, proto: number): Uint8Array;\n register_io_protocols(): number;\n list_io_protocols(registry: number): Uint8Array;\n parse_instance(registry: number, proto_name: Uint8Array, schema: number, input: Uint8Array): Uint8Array;\n emit_instance(registry: number, proto_name: Uint8Array, schema: number, instance: Uint8Array): Uint8Array;\n validate_instance(schema: number, instance: Uint8Array): Uint8Array;\n instance_to_json(schema: number, instance: Uint8Array): Uint8Array;\n json_to_instance(schema: number, json: Uint8Array): Uint8Array;\n json_to_instance_with_root(schema: number, json: Uint8Array, root_vertex: string): Uint8Array;\n lift_json(migration: number, json: Uint8Array, root_vertex: string): Uint8Array;\n get_json(migration: number, json: Uint8Array, root_vertex: string): Uint8Array;\n put_json(migration: number, view_json: Uint8Array, complement: Uint8Array, root_vertex: string): Uint8Array;\n instance_element_count(instance: Uint8Array): number;\n lens_from_combinators(schema: number, proto: number, combinators: Uint8Array): number;\n check_lens_laws(migration: number, instance: Uint8Array): Uint8Array;\n check_get_put(migration: number, instance: Uint8Array): Uint8Array;\n check_put_get(migration: number, instance: Uint8Array): Uint8Array;\n invert_migration(mapping: Uint8Array, src: number, tgt: number): Uint8Array;\n compose_lenses(l1: number, l2: number): number;\n // Phase 4: Protocol registry\n list_builtin_protocols(): Uint8Array;\n get_builtin_protocol(name: Uint8Array): Uint8Array;\n // Phase 5: GAT operations\n create_theory(spec: Uint8Array): number;\n colimit_theories(t1: number, t2: number, shared: number): number;\n check_morphism(morphism: Uint8Array, domain: number, codomain: number): Uint8Array;\n migrate_model(model: Uint8Array, morphism: Uint8Array): Uint8Array;\n // Phase 6: VCS operations\n vcs_init(protocol_name: Uint8Array): number;\n vcs_add(repo: number, schema: number): Uint8Array;\n vcs_commit(repo: number, message: Uint8Array, author: Uint8Array): Uint8Array;\n vcs_log(repo: number, count: number): Uint8Array;\n vcs_status(repo: number): Uint8Array;\n vcs_diff(repo: number): Uint8Array;\n vcs_branch(repo: number, name: Uint8Array): Uint8Array;\n vcs_checkout(repo: number, target: Uint8Array): Uint8Array;\n vcs_merge(repo: number, branch: Uint8Array): Uint8Array;\n vcs_stash(repo: number): Uint8Array;\n vcs_stash_pop(repo: number): Uint8Array;\n vcs_blame(repo: number, vertex: Uint8Array): Uint8Array;\n}\n\n/** Result of checking a lens law (GetPut or PutGet). */\nexport interface LawCheckResult {\n readonly holds: boolean;\n readonly violation: string | null;\n}\n\n/** WASM module wrapper including exports and memory. */\nexport interface WasmModule {\n readonly exports: WasmExports;\n readonly memory: WebAssembly.Memory;\n}\n\n// ---------------------------------------------------------------------------\n// Instance types\n// ---------------------------------------------------------------------------\n\n/** Instance shape discriminator. */\nexport type InstanceShape = 'wtype' | 'functor' | 'graph';\n\n/** Validation result for an instance. */\nexport interface InstanceValidationResult {\n readonly isValid: boolean;\n readonly errors: readonly string[];\n}\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\n/** Base error class for all panproto errors. */\nexport class PanprotoError extends Error {\n override readonly name: string = 'PanprotoError';\n\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n }\n}\n\n/** Error from WASM boundary. */\nexport class WasmError extends PanprotoError {\n override readonly name = 'WasmError';\n}\n\n/** Error from schema validation. */\nexport class SchemaValidationError extends PanprotoError {\n override readonly name = 'SchemaValidationError';\n\n constructor(\n message: string,\n readonly errors: readonly string[],\n ) {\n super(message);\n }\n}\n\n/** Error from migration compilation. */\nexport class MigrationError extends PanprotoError {\n override readonly name = 'MigrationError';\n}\n\n/** Error from existence checking. */\nexport class ExistenceCheckError extends PanprotoError {\n override readonly name = 'ExistenceCheckError';\n\n constructor(\n message: string,\n readonly report: ExistenceReport,\n ) {\n super(message);\n }\n}\n","/**\n * WASM loading and handle management.\n *\n * Manages the lifecycle of WASM-side resources via opaque handles.\n * Uses `Symbol.dispose` for automatic cleanup and `FinalizationRegistry`\n * as a safety net for leaked handles.\n *\n * @module\n */\n\nimport type { WasmModule, WasmExports } from './types.js';\nimport { WasmError } from './types.js';\n\n/** Default wasm-bindgen glue module URL (relative to package root). */\nconst DEFAULT_GLUE_URL = new URL('./panproto_wasm.js', import.meta.url);\n\n/**\n * Shape of a pre-imported wasm-bindgen glue module.\n *\n * The `default` export is the wasm-bindgen init function. We type it\n * loosely so any wasm-bindgen output module satisfies the interface.\n */\nexport interface WasmGlueModule {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n default: (...args: any[]) => Promise<{ memory: WebAssembly.Memory }>;\n define_protocol: WasmExports['define_protocol'];\n build_schema: WasmExports['build_schema'];\n check_existence: WasmExports['check_existence'];\n compile_migration: WasmExports['compile_migration'];\n lift_record: WasmExports['lift_record'];\n get_record: WasmExports['get_record'];\n put_record: WasmExports['put_record'];\n compose_migrations: WasmExports['compose_migrations'];\n diff_schemas: WasmExports['diff_schemas'];\n free_handle: WasmExports['free_handle'];\n diff_schemas_full: WasmExports['diff_schemas_full'];\n classify_diff: WasmExports['classify_diff'];\n report_text: WasmExports['report_text'];\n report_json: WasmExports['report_json'];\n normalize_schema: WasmExports['normalize_schema'];\n validate_schema: WasmExports['validate_schema'];\n register_io_protocols: WasmExports['register_io_protocols'];\n list_io_protocols: WasmExports['list_io_protocols'];\n parse_instance: WasmExports['parse_instance'];\n emit_instance: WasmExports['emit_instance'];\n validate_instance: WasmExports['validate_instance'];\n instance_to_json: WasmExports['instance_to_json'];\n json_to_instance: WasmExports['json_to_instance'];\n json_to_instance_with_root: WasmExports['json_to_instance_with_root'];\n lift_json: WasmExports['lift_json'];\n get_json: WasmExports['get_json'];\n put_json: WasmExports['put_json'];\n instance_element_count: WasmExports['instance_element_count'];\n lens_from_combinators: WasmExports['lens_from_combinators'];\n check_lens_laws: WasmExports['check_lens_laws'];\n check_get_put: WasmExports['check_get_put'];\n check_put_get: WasmExports['check_put_get'];\n invert_migration: WasmExports['invert_migration'];\n compose_lenses: WasmExports['compose_lenses'];\n // Phase 4: Protocol registry\n list_builtin_protocols: WasmExports['list_builtin_protocols'];\n get_builtin_protocol: WasmExports['get_builtin_protocol'];\n // Phase 5: GAT operations\n create_theory: WasmExports['create_theory'];\n colimit_theories: WasmExports['colimit_theories'];\n check_morphism: WasmExports['check_morphism'];\n migrate_model: WasmExports['migrate_model'];\n // Phase 6: VCS operations\n vcs_init: WasmExports['vcs_init'];\n vcs_add: WasmExports['vcs_add'];\n vcs_commit: WasmExports['vcs_commit'];\n vcs_log: WasmExports['vcs_log'];\n vcs_status: WasmExports['vcs_status'];\n vcs_diff: WasmExports['vcs_diff'];\n vcs_branch: WasmExports['vcs_branch'];\n vcs_checkout: WasmExports['vcs_checkout'];\n vcs_merge: WasmExports['vcs_merge'];\n vcs_stash: WasmExports['vcs_stash'];\n vcs_stash_pop: WasmExports['vcs_stash_pop'];\n vcs_blame: WasmExports['vcs_blame'];\n}\n\n/**\n * Load the panproto WASM module.\n *\n * Accepts either:\n * - A URL to the wasm-bindgen `.js` glue module (loaded via dynamic import)\n * - A pre-imported wasm-bindgen glue module object (for bundler environments like Vite)\n *\n * @param input - URL string, URL object, or pre-imported glue module.\n * Defaults to the bundled glue module URL.\n * @returns The initialized WASM module\n * @throws {@link WasmError} if loading or instantiation fails\n */\nexport async function loadWasm(input?: string | URL | WasmGlueModule): Promise<WasmModule> {\n try {\n let glue: WasmGlueModule;\n\n if (input && typeof input === 'object' && 'default' in input && typeof input.default === 'function') {\n // Pre-imported glue module — used in bundler environments (Vite, webpack)\n glue = input;\n } else {\n // Dynamic import from URL\n const url = (input as string | URL | undefined) ?? DEFAULT_GLUE_URL;\n glue = await import(/* @vite-ignore */ String(url));\n }\n\n const initOutput = await glue.default();\n\n const exports: WasmExports = {\n define_protocol: glue.define_protocol,\n build_schema: glue.build_schema,\n check_existence: glue.check_existence,\n compile_migration: glue.compile_migration,\n lift_record: glue.lift_record,\n get_record: glue.get_record,\n put_record: glue.put_record,\n compose_migrations: glue.compose_migrations,\n diff_schemas: glue.diff_schemas,\n free_handle: glue.free_handle,\n diff_schemas_full: glue.diff_schemas_full,\n classify_diff: glue.classify_diff,\n report_text: glue.report_text,\n report_json: glue.report_json,\n normalize_schema: glue.normalize_schema,\n validate_schema: glue.validate_schema,\n register_io_protocols: glue.register_io_protocols,\n list_io_protocols: glue.list_io_protocols,\n parse_instance: glue.parse_instance,\n emit_instance: glue.emit_instance,\n validate_instance: glue.validate_instance,\n instance_to_json: glue.instance_to_json,\n json_to_instance: glue.json_to_instance,\n json_to_instance_with_root: glue.json_to_instance_with_root,\n lift_json: glue.lift_json,\n get_json: glue.get_json,\n put_json: glue.put_json,\n instance_element_count: glue.instance_element_count,\n lens_from_combinators: glue.lens_from_combinators,\n check_lens_laws: glue.check_lens_laws,\n check_get_put: glue.check_get_put,\n check_put_get: glue.check_put_get,\n invert_migration: glue.invert_migration,\n compose_lenses: glue.compose_lenses,\n // Phase 4\n list_builtin_protocols: glue.list_builtin_protocols,\n get_builtin_protocol: glue.get_builtin_protocol,\n // Phase 5\n create_theory: glue.create_theory,\n colimit_theories: glue.colimit_theories,\n check_morphism: glue.check_morphism,\n migrate_model: glue.migrate_model,\n // Phase 6\n vcs_init: glue.vcs_init,\n vcs_add: glue.vcs_add,\n vcs_commit: glue.vcs_commit,\n vcs_log: glue.vcs_log,\n vcs_status: glue.vcs_status,\n vcs_diff: glue.vcs_diff,\n vcs_branch: glue.vcs_branch,\n vcs_checkout: glue.vcs_checkout,\n vcs_merge: glue.vcs_merge,\n vcs_stash: glue.vcs_stash,\n vcs_stash_pop: glue.vcs_stash_pop,\n vcs_blame: glue.vcs_blame,\n };\n\n const memory: WebAssembly.Memory = initOutput.memory;\n\n if (!memory) {\n throw new WasmError('WASM module missing memory export');\n }\n\n return { exports, memory };\n } catch (error) {\n if (error instanceof WasmError) throw error;\n throw new WasmError(\n `Failed to load WASM module: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Handle registry — prevents resource leaks\n// ---------------------------------------------------------------------------\n\n/** Weak reference registry for leaked handle detection. */\nconst leakedHandleRegistry = new FinalizationRegistry<CleanupInfo>((info) => {\n // Safety net: if a disposable wrapper is GC'd without being disposed,\n // free the underlying WASM handle.\n try {\n info.freeHandle(info.handle);\n } catch {\n // WASM module may already be torn down; swallow.\n }\n});\n\ninterface CleanupInfo {\n readonly handle: number;\n readonly freeHandle: (h: number) => void;\n}\n\n/**\n * A disposable wrapper around a WASM handle.\n *\n * Implements `Symbol.dispose` for use with `using` declarations.\n * A `FinalizationRegistry` acts as a safety net for handles that\n * are not explicitly disposed.\n */\nexport class WasmHandle implements Disposable {\n #handle: number;\n #disposed = false;\n readonly #freeHandle: (h: number) => void;\n\n constructor(handle: number, freeHandle: (h: number) => void) {\n this.#handle = handle;\n this.#freeHandle = freeHandle;\n\n leakedHandleRegistry.register(this, { handle, freeHandle }, this);\n }\n\n /** The raw WASM handle id. Only for internal use within the SDK. */\n get id(): number {\n if (this.#disposed) {\n throw new WasmError('Attempted to use a disposed handle');\n }\n return this.#handle;\n }\n\n /** Whether this handle has been disposed. */\n get disposed(): boolean {\n return this.#disposed;\n }\n\n /** Release the underlying WASM resource. */\n [Symbol.dispose](): void {\n if (this.#disposed) return;\n this.#disposed = true;\n\n leakedHandleRegistry.unregister(this);\n\n try {\n this.#freeHandle(this.#handle);\n } catch {\n // WASM module may already be torn down; swallow.\n }\n }\n}\n\n/**\n * Create a managed handle that will be freed when disposed.\n *\n * @param rawHandle - The u32 handle from WASM\n * @param wasm - The WASM module for freeing\n * @returns A disposable wrapper\n */\nexport function createHandle(rawHandle: number, wasm: WasmModule): WasmHandle {\n return new WasmHandle(rawHandle, (h) => wasm.exports.free_handle(h));\n}\n","/**\n * MessagePack encode/decode utilities for the WASM boundary.\n *\n * All structured data crossing the WASM boundary is serialized as MessagePack\n * byte slices. This module wraps `@msgpack/msgpack` with typed helpers.\n *\n * @module\n */\n\nimport { encode, decode } from '@msgpack/msgpack';\n\n/**\n * Encode a value to MessagePack bytes for sending to WASM.\n *\n * @param value - The value to encode\n * @returns MessagePack-encoded bytes\n */\nexport function packToWasm(value: unknown): Uint8Array {\n return encode(value);\n}\n\n/**\n * Decode MessagePack bytes received from WASM.\n *\n * @typeParam T - The expected decoded type\n * @param bytes - MessagePack-encoded bytes from WASM\n * @returns The decoded value\n */\nexport function unpackFromWasm<T = unknown>(bytes: Uint8Array): T {\n return decode(bytes) as T;\n}\n\n/**\n * Encode a schema operations list for the `build_schema` entry point.\n *\n * @param ops - Array of builder operations\n * @returns MessagePack-encoded bytes\n */\nexport function packSchemaOps(ops: readonly SchemaOp[]): Uint8Array {\n return encode(ops);\n}\n\n/**\n * Encode a migration mapping for WASM entry points.\n *\n * @param mapping - The migration mapping object\n * @returns MessagePack-encoded bytes\n */\nexport function packMigrationMapping(mapping: MigrationMapping): Uint8Array {\n // The Rust Migration struct uses `map_as_vec` for fields with non-string keys,\n // which deserializes from a sequence of [key, value] pairs, not a map.\n // Convert JS Maps to arrays before encoding.\n return encode({\n vertex_map: mapping.vertex_map,\n edge_map: Array.from(mapping.edge_map.entries()),\n hyper_edge_map: mapping.hyper_edge_map,\n label_map: Array.from(mapping.label_map.entries()),\n resolver: Array.from(mapping.resolver.entries()),\n hyper_resolver: [],\n });\n}\n\n// ---------------------------------------------------------------------------\n// Internal types for structured WASM messages\n// ---------------------------------------------------------------------------\n\n/**\n * A single schema builder operation sent to WASM.\n *\n * Uses serde internally-tagged format: the `op` field acts as the\n * discriminant and all variant fields sit at the same level.\n */\nexport interface SchemaOp {\n readonly op: 'vertex' | 'edge' | 'hyper_edge' | 'constraint' | 'required';\n readonly [key: string]: unknown;\n}\n\n/** Wire format for an edge (matches Rust serialization). */\nexport interface EdgeWire {\n readonly src: string;\n readonly tgt: string;\n readonly kind: string;\n readonly name: string | null;\n}\n\n/** A migration mapping sent to WASM (matches Rust `Migration` struct). */\nexport interface MigrationMapping {\n readonly vertex_map: Record<string, string>;\n readonly edge_map: Map<EdgeWire, EdgeWire>;\n readonly hyper_edge_map: Record<string, string>;\n readonly label_map: Map<readonly [string, string], string>;\n readonly resolver: Map<readonly [string, string], EdgeWire>;\n}\n","/**\n * Lens and combinator API for bidirectional transformations.\n *\n * Every migration is a lens with `get` (forward projection) and\n * `put` (restore from complement). This module provides Cambria-style\n * combinators that compose into migrations.\n *\n * @module\n */\n\nimport type { WasmModule, LawCheckResult, LiftResult, GetResult } from './types.js';\nimport { WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\nimport type { Protocol } from './protocol.js';\n\n// ---------------------------------------------------------------------------\n// Combinator types\n// ---------------------------------------------------------------------------\n\n/** Rename a field from one name to another. */\nexport interface RenameFieldCombinator {\n readonly type: 'rename-field';\n readonly old: string;\n readonly new: string;\n}\n\n/** Add a new field with a default value. */\nexport interface AddFieldCombinator {\n readonly type: 'add-field';\n readonly name: string;\n readonly vertexKind: string;\n readonly default: unknown;\n}\n\n/** Remove a field from the schema. */\nexport interface RemoveFieldCombinator {\n readonly type: 'remove-field';\n readonly name: string;\n}\n\n/** Wrap a value inside a new object with a given field name. */\nexport interface WrapInObjectCombinator {\n readonly type: 'wrap-in-object';\n readonly fieldName: string;\n}\n\n/** Hoist a nested field up to the host level. */\nexport interface HoistFieldCombinator {\n readonly type: 'hoist-field';\n readonly host: string;\n readonly field: string;\n}\n\n/** Coerce a value from one type to another. */\nexport interface CoerceTypeCombinator {\n readonly type: 'coerce-type';\n readonly fromKind: string;\n readonly toKind: string;\n}\n\n/** Sequential composition of two combinators. */\nexport interface ComposeCombinator {\n readonly type: 'compose';\n readonly first: Combinator;\n readonly second: Combinator;\n}\n\n/** A lens combinator (Cambria-style). */\nexport type Combinator =\n | RenameFieldCombinator\n | AddFieldCombinator\n | RemoveFieldCombinator\n | WrapInObjectCombinator\n | HoistFieldCombinator\n | CoerceTypeCombinator\n | ComposeCombinator;\n\n// ---------------------------------------------------------------------------\n// Combinator constructors\n// ---------------------------------------------------------------------------\n\n/**\n * Create a rename-field combinator.\n *\n * @param oldName - The current field name\n * @param newName - The desired field name\n * @returns A rename-field combinator\n */\nexport function renameField(oldName: string, newName: string): RenameFieldCombinator {\n return { type: 'rename-field', old: oldName, new: newName };\n}\n\n/**\n * Create an add-field combinator.\n *\n * @param name - The field name to add\n * @param vertexKind - The vertex kind for the new field\n * @param defaultValue - The default value for the field\n * @returns An add-field combinator\n */\nexport function addField(name: string, vertexKind: string, defaultValue: unknown): AddFieldCombinator {\n return { type: 'add-field', name, vertexKind, default: defaultValue };\n}\n\n/**\n * Create a remove-field combinator.\n *\n * @param name - The field name to remove\n * @returns A remove-field combinator\n */\nexport function removeField(name: string): RemoveFieldCombinator {\n return { type: 'remove-field', name };\n}\n\n/**\n * Create a wrap-in-object combinator.\n *\n * @param fieldName - The field name for the wrapper object\n * @returns A wrap-in-object combinator\n */\nexport function wrapInObject(fieldName: string): WrapInObjectCombinator {\n return { type: 'wrap-in-object', fieldName };\n}\n\n/**\n * Create a hoist-field combinator.\n *\n * @param host - The host vertex to hoist into\n * @param field - The nested field to hoist\n * @returns A hoist-field combinator\n */\nexport function hoistField(host: string, field: string): HoistFieldCombinator {\n return { type: 'hoist-field', host, field };\n}\n\n/**\n * Create a coerce-type combinator.\n *\n * @param fromKind - The source type kind\n * @param toKind - The target type kind\n * @returns A coerce-type combinator\n */\nexport function coerceType(fromKind: string, toKind: string): CoerceTypeCombinator {\n return { type: 'coerce-type', fromKind, toKind };\n}\n\n/**\n * Compose two combinators sequentially.\n *\n * @param first - The combinator applied first\n * @param second - The combinator applied second\n * @returns A composed combinator\n */\nexport function compose(first: Combinator, second: Combinator): ComposeCombinator {\n return { type: 'compose', first, second };\n}\n\n/**\n * Compose a chain of combinators left-to-right.\n *\n * @param combinators - The combinators to compose (at least one required)\n * @returns The composed combinator\n * @throws If the combinators array is empty\n */\nexport function pipeline(combinators: readonly [Combinator, ...Combinator[]]): Combinator {\n const [first, ...rest] = combinators;\n return rest.reduce<Combinator>((acc, c) => compose(acc, c), first);\n}\n\n// ---------------------------------------------------------------------------\n// LensHandle — disposable wrapper around a WASM migration handle for lenses\n// ---------------------------------------------------------------------------\n\n/**\n * A disposable handle to a WASM-side lens (migration) resource.\n *\n * Wraps a migration handle created via `lens_from_combinators` or\n * `compose_lenses`. Provides `get`, `put`, and law-checking operations.\n *\n * Implements `Symbol.dispose` for use with `using` declarations.\n */\nexport class LensHandle implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this.#handle = handle;\n this.#wasm = wasm;\n }\n\n /** The underlying WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Forward projection: extract the view from a record.\n *\n * @param record - MessagePack-encoded input record\n * @returns The projected view and opaque complement bytes\n * @throws {@link WasmError} if the WASM call fails\n */\n get(record: Uint8Array): GetResult {\n try {\n const outputBytes = this.#wasm.exports.get_record(\n this.#handle.id,\n record,\n );\n const result = unpackFromWasm<{ view: unknown; complement: Uint8Array }>(outputBytes);\n return {\n view: result.view,\n complement: result.complement instanceof Uint8Array\n ? result.complement\n : new Uint8Array(result.complement as ArrayBuffer),\n };\n } catch (error) {\n throw new WasmError(\n `get_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Backward put: restore a full record from a modified view and complement.\n *\n * @param view - MessagePack-encoded (possibly modified) projected view\n * @param complement - The complement from a prior `get()` call\n * @returns The restored full record\n * @throws {@link WasmError} if the WASM call fails\n */\n put(view: Uint8Array, complement: Uint8Array): LiftResult {\n try {\n const outputBytes = this.#wasm.exports.put_record(\n this.#handle.id,\n view,\n complement,\n );\n const data = unpackFromWasm(outputBytes);\n return { data };\n } catch (error) {\n throw new WasmError(\n `put_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check both GetPut and PutGet lens laws for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether both laws hold and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkLaws(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_lens_laws(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_lens_laws failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check the GetPut lens law for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether the law holds and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkGetPut(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_get_put(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_get_put failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Check the PutGet lens law for an instance.\n *\n * @param instance - MessagePack-encoded instance data\n * @returns Whether the law holds and any violation message\n * @throws {@link WasmError} if the WASM call fails\n */\n checkPutGet(instance: Uint8Array): LawCheckResult {\n try {\n const resultBytes = this.#wasm.exports.check_put_get(\n this.#handle.id,\n instance,\n );\n return unpackFromWasm<LawCheckResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `check_put_get failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the underlying WASM resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Build a lens from combinators.\n *\n * Serializes the combinators to MessagePack and calls the\n * `lens_from_combinators` WASM entry point.\n *\n * @param schema - The schema to build the lens against\n * @param protocol - The protocol defining the schema theory\n * @param combinators - One or more combinators to compose into a lens\n * @returns A LensHandle wrapping the WASM migration resource\n * @throws {@link WasmError} if the WASM call fails\n */\nexport function fromCombinators(\n schema: BuiltSchema,\n protocol: Protocol,\n wasm: WasmModule,\n ...combinators: Combinator[]\n): LensHandle {\n const wireCombs = combinators.map(combinatorToWire);\n const combBytes = packToWasm(wireCombs);\n\n try {\n const rawHandle = wasm.exports.lens_from_combinators(\n schema._handle.id,\n protocol._handle.id,\n combBytes,\n );\n const handle = createHandle(rawHandle, wasm);\n return new LensHandle(handle, wasm);\n } catch (error) {\n throw new WasmError(\n `lens_from_combinators failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Wire serialization\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize a combinator to a plain object for MessagePack encoding.\n *\n * @param combinator - The combinator to serialize\n * @returns A plain object suitable for MessagePack encoding\n */\nexport function combinatorToWire(combinator: Combinator): Record<string, unknown> {\n switch (combinator.type) {\n case 'rename-field':\n return { RenameField: { old: combinator.old, new: combinator.new } };\n case 'add-field':\n return { AddField: { name: combinator.name, vertex_kind: combinator.vertexKind, default: combinator.default } };\n case 'remove-field':\n return { RemoveField: { name: combinator.name } };\n case 'wrap-in-object':\n return { WrapInObject: { field_name: combinator.fieldName } };\n case 'hoist-field':\n return { HoistField: { host: combinator.host, field: combinator.field } };\n case 'coerce-type':\n return { CoerceType: { from_kind: combinator.fromKind, to_kind: combinator.toKind } };\n case 'compose':\n return { Compose: [combinatorToWire(combinator.first), combinatorToWire(combinator.second)] };\n }\n}\n","/**\n * Breaking-change analysis and compatibility checking.\n *\n * Provides a fluent API for diffing schemas and classifying changes:\n *\n * ```typescript\n * const diff = panproto.diffFull(oldSchema, newSchema);\n * const report = diff.classify(protocol);\n * console.log(report.isBreaking);\n * console.log(report.toText());\n * ```\n *\n * @module\n */\n\nimport type { Protocol } from './protocol.js';\nimport type {\n FullSchemaDiff,\n CompatReportData,\n BreakingChange,\n NonBreakingChange,\n SchemaValidationIssue,\n WasmModule,\n} from './types.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/**\n * A full schema diff with 20+ change categories.\n *\n * Created via `Panproto.diffFull()`. Use `.classify()` to determine\n * compatibility.\n */\nexport class FullDiffReport {\n /** The raw diff data. */\n readonly data: FullSchemaDiff;\n\n /** @internal */\n readonly _reportBytes: Uint8Array;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n /** @internal */\n constructor(data: FullSchemaDiff, reportBytes: Uint8Array, wasm: WasmModule) {\n this.data = data;\n this._reportBytes = reportBytes;\n this._wasm = wasm;\n }\n\n /** Whether there are any changes at all. */\n get hasChanges(): boolean {\n const d = this.data;\n return (\n d.added_vertices.length > 0 ||\n d.removed_vertices.length > 0 ||\n d.kind_changes.length > 0 ||\n d.added_edges.length > 0 ||\n d.removed_edges.length > 0 ||\n Object.keys(d.modified_constraints).length > 0 ||\n d.added_hyper_edges.length > 0 ||\n d.removed_hyper_edges.length > 0 ||\n d.modified_hyper_edges.length > 0 ||\n Object.keys(d.added_required).length > 0 ||\n Object.keys(d.removed_required).length > 0 ||\n Object.keys(d.added_nsids).length > 0 ||\n d.removed_nsids.length > 0 ||\n d.changed_nsids.length > 0 ||\n d.added_variants.length > 0 ||\n d.removed_variants.length > 0 ||\n d.modified_variants.length > 0 ||\n d.order_changes.length > 0 ||\n d.added_recursion_points.length > 0 ||\n d.removed_recursion_points.length > 0 ||\n d.modified_recursion_points.length > 0 ||\n d.usage_mode_changes.length > 0 ||\n d.added_spans.length > 0 ||\n d.removed_spans.length > 0 ||\n d.modified_spans.length > 0 ||\n d.nominal_changes.length > 0\n );\n }\n\n /** Classify the diff against a protocol, producing a compatibility report. */\n classify(protocol: Protocol): CompatReport {\n const rawBytes = this._wasm.exports.classify_diff(\n protocol._handle.id,\n this._reportBytes,\n );\n const data = unpackFromWasm<CompatReportData>(rawBytes);\n return new CompatReport(data, rawBytes, this._wasm);\n }\n}\n\n/**\n * A compatibility report classifying schema changes as breaking or non-breaking.\n *\n * Created via `FullDiffReport.classify()`.\n */\nexport class CompatReport {\n /** The raw report data. */\n readonly data: CompatReportData;\n\n /** @internal */\n readonly _rawBytes: Uint8Array;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n /** @internal */\n constructor(data: CompatReportData, rawBytes: Uint8Array, wasm: WasmModule) {\n this.data = data;\n this._rawBytes = rawBytes;\n this._wasm = wasm;\n }\n\n /** List of breaking changes. */\n get breakingChanges(): readonly BreakingChange[] {\n return this.data.breaking;\n }\n\n /** List of non-breaking changes. */\n get nonBreakingChanges(): readonly NonBreakingChange[] {\n return this.data.non_breaking;\n }\n\n /** Whether the changes are fully compatible (no breaking changes). */\n get isCompatible(): boolean {\n return this.data.compatible;\n }\n\n /** Whether there are any breaking changes. */\n get isBreaking(): boolean {\n return !this.data.compatible;\n }\n\n /** Whether the changes are backward-compatible (additions only, no removals). */\n get isBackwardCompatible(): boolean {\n return this.data.compatible;\n }\n\n /** Render as human-readable text. */\n toText(): string {\n return this._wasm.exports.report_text(this._rawBytes);\n }\n\n /** Render as a JSON string. */\n toJson(): string {\n return this._wasm.exports.report_json(this._rawBytes);\n }\n}\n\n/**\n * Result of schema validation against a protocol.\n */\nexport class ValidationResult {\n /** The list of validation issues found. */\n readonly issues: readonly SchemaValidationIssue[];\n\n constructor(issues: readonly SchemaValidationIssue[]) {\n this.issues = issues;\n }\n\n /** Whether the schema is valid (no issues found). */\n get isValid(): boolean {\n return this.issues.length === 0;\n }\n\n /** The number of validation issues. */\n get errorCount(): number {\n return this.issues.length;\n }\n}\n","/**\n * Fluent schema builder API.\n *\n * Builders are immutable: each method returns a new builder instance.\n * Call `.build()` to validate and produce the final schema.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n Vertex,\n Edge,\n HyperEdge,\n Constraint,\n VertexOptions,\n EdgeOptions,\n SchemaData,\n SchemaValidationIssue,\n} from './types.js';\nimport { SchemaValidationError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport type { SchemaOp } from './msgpack.js';\nimport { packSchemaOps, unpackFromWasm } from './msgpack.js';\nimport type { Protocol } from './protocol.js';\nimport { ValidationResult } from './check.js';\n\n/**\n * Immutable fluent builder for constructing schemas.\n *\n * Each mutation method returns a new `SchemaBuilder` instance,\n * leaving the original unchanged. The builder accumulates operations\n * that are sent to WASM on `.build()`.\n *\n * @example\n * ```typescript\n * const schema = builder\n * .vertex('post', 'record', { nsid: 'app.bsky.feed.post' })\n * .vertex('post:body', 'object')\n * .edge('post', 'post:body', 'record-schema')\n * .build();\n * ```\n */\nexport class SchemaBuilder {\n readonly #protocolName: string;\n readonly #protocolHandle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #ops: readonly SchemaOp[];\n readonly #vertices: ReadonlyMap<string, Vertex>;\n readonly #edges: readonly Edge[];\n readonly #hyperEdges: ReadonlyMap<string, HyperEdge>;\n readonly #constraints: ReadonlyMap<string, readonly Constraint[]>;\n readonly #required: ReadonlyMap<string, readonly Edge[]>;\n\n constructor(\n protocolName: string,\n protocolHandle: WasmHandle,\n wasm: WasmModule,\n ops: readonly SchemaOp[] = [],\n vertices: ReadonlyMap<string, Vertex> = new Map(),\n edges: readonly Edge[] = [],\n hyperEdges: ReadonlyMap<string, HyperEdge> = new Map(),\n constraints: ReadonlyMap<string, readonly Constraint[]> = new Map(),\n required: ReadonlyMap<string, readonly Edge[]> = new Map(),\n ) {\n this.#protocolName = protocolName;\n this.#protocolHandle = protocolHandle;\n this.#wasm = wasm;\n this.#ops = ops;\n this.#vertices = vertices;\n this.#edges = edges;\n this.#hyperEdges = hyperEdges;\n this.#constraints = constraints;\n this.#required = required;\n }\n\n /**\n * Add a vertex to the schema.\n *\n * @param id - Unique vertex identifier\n * @param kind - Vertex kind (e.g., 'record', 'object', 'string')\n * @param options - Optional vertex configuration (nsid, etc.)\n * @returns A new builder with the vertex added\n * @throws {@link SchemaValidationError} if vertex id is already in use\n */\n vertex(id: string, kind: string, options?: VertexOptions): SchemaBuilder {\n if (this.#vertices.has(id)) {\n throw new SchemaValidationError(\n `Vertex \"${id}\" already exists in schema`,\n [`Duplicate vertex id: ${id}`],\n );\n }\n\n const vertex: Vertex = {\n id,\n kind,\n nsid: options?.nsid,\n };\n\n const op: SchemaOp = {\n op: 'vertex',\n id,\n kind,\n nsid: options?.nsid ?? null,\n };\n\n const newVertices = new Map(this.#vertices);\n newVertices.set(id, vertex);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n newVertices,\n this.#edges,\n this.#hyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a directed edge to the schema.\n *\n * @param src - Source vertex id\n * @param tgt - Target vertex id\n * @param kind - Edge kind (e.g., 'record-schema', 'prop')\n * @param options - Optional edge configuration (name, etc.)\n * @returns A new builder with the edge added\n * @throws {@link SchemaValidationError} if source or target vertex does not exist\n */\n edge(src: string, tgt: string, kind: string, options?: EdgeOptions): SchemaBuilder {\n if (!this.#vertices.has(src)) {\n throw new SchemaValidationError(\n `Edge source \"${src}\" does not exist`,\n [`Unknown source vertex: ${src}`],\n );\n }\n if (!this.#vertices.has(tgt)) {\n throw new SchemaValidationError(\n `Edge target \"${tgt}\" does not exist`,\n [`Unknown target vertex: ${tgt}`],\n );\n }\n\n const edge: Edge = {\n src,\n tgt,\n kind,\n name: options?.name,\n };\n\n const op: SchemaOp = {\n op: 'edge',\n src,\n tgt,\n kind,\n name: options?.name ?? null,\n };\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n [...this.#edges, edge],\n this.#hyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a hyperedge to the schema.\n *\n * Only valid if the protocol's schema theory includes ThHypergraph.\n *\n * @param id - Unique hyperedge identifier\n * @param kind - Hyperedge kind\n * @param signature - Label-to-vertex mapping\n * @param parentLabel - The label identifying the parent in the signature\n * @returns A new builder with the hyperedge added\n */\n hyperEdge(\n id: string,\n kind: string,\n signature: Record<string, string>,\n parentLabel: string,\n ): SchemaBuilder {\n const he: HyperEdge = { id, kind, signature, parentLabel };\n\n const op: SchemaOp = {\n op: 'hyper_edge',\n id,\n kind,\n signature,\n parent: parentLabel,\n };\n\n const newHyperEdges = new Map(this.#hyperEdges);\n newHyperEdges.set(id, he);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n newHyperEdges,\n this.#constraints,\n this.#required,\n );\n }\n\n /**\n * Add a constraint to a vertex.\n *\n * @param vertexId - The vertex to constrain\n * @param sort - Constraint sort (e.g., 'maxLength')\n * @param value - Constraint value\n * @returns A new builder with the constraint added\n */\n constraint(vertexId: string, sort: string, value: string): SchemaBuilder {\n const c: Constraint = { sort, value };\n\n const op: SchemaOp = {\n op: 'constraint',\n vertex: vertexId,\n sort,\n value,\n };\n\n const existing = this.#constraints.get(vertexId) ?? [];\n const newConstraints = new Map(this.#constraints);\n newConstraints.set(vertexId, [...existing, c]);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n this.#hyperEdges,\n newConstraints,\n this.#required,\n );\n }\n\n /**\n * Mark edges as required for a vertex.\n *\n * @param vertexId - The vertex with required edges\n * @param edges - The edges that are required\n * @returns A new builder with the requirement added\n */\n required(vertexId: string, edges: readonly Edge[]): SchemaBuilder {\n const op: SchemaOp = {\n op: 'required',\n vertex: vertexId,\n edges: edges.map((e) => ({\n src: e.src,\n tgt: e.tgt,\n kind: e.kind,\n name: e.name ?? null,\n })),\n };\n\n const existing = this.#required.get(vertexId) ?? [];\n const newRequired = new Map(this.#required);\n newRequired.set(vertexId, [...existing, ...edges]);\n\n return new SchemaBuilder(\n this.#protocolName,\n this.#protocolHandle,\n this.#wasm,\n [...this.#ops, op],\n this.#vertices,\n this.#edges,\n this.#hyperEdges,\n this.#constraints,\n newRequired,\n );\n }\n\n /**\n * Validate and build the schema.\n *\n * Sends all accumulated operations to WASM for validation and construction.\n * Returns a `BuiltSchema` that holds the WASM handle and local data.\n *\n * @returns The validated, built schema\n * @throws {@link SchemaValidationError} if the schema is invalid\n */\n build(): BuiltSchema {\n const opsBytes = packSchemaOps([...this.#ops]);\n const rawHandle = this.#wasm.exports.build_schema(\n this.#protocolHandle.id,\n opsBytes,\n );\n\n const handle = createHandle(rawHandle, this.#wasm);\n\n const data: SchemaData = {\n protocol: this.#protocolName,\n vertices: Object.fromEntries(this.#vertices),\n edges: [...this.#edges],\n hyperEdges: Object.fromEntries(this.#hyperEdges),\n constraints: Object.fromEntries(\n Array.from(this.#constraints.entries()).map(([k, v]) => [k, [...v]]),\n ),\n required: Object.fromEntries(\n Array.from(this.#required.entries()).map(([k, v]) => [k, [...v]]),\n ),\n variants: {},\n orderings: {},\n recursionPoints: {},\n usageModes: {},\n spans: {},\n nominal: {},\n };\n\n return new BuiltSchema(handle, data, this.#wasm);\n }\n}\n\n/**\n * A validated, built schema with a WASM-side handle.\n *\n * Implements `Disposable` for automatic cleanup of the WASM resource.\n */\nexport class BuiltSchema implements Disposable {\n readonly #handle: WasmHandle;\n readonly #data: SchemaData;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, data: SchemaData, wasm: WasmModule) {\n this.#handle = handle;\n this.#data = data;\n this.#wasm = wasm;\n }\n\n /** The WASM handle for this schema. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** The WASM module reference. Internal use only. */\n get _wasm(): WasmModule {\n return this.#wasm;\n }\n\n /** The schema data (vertices, edges, constraints, etc.). */\n get data(): SchemaData {\n return this.#data;\n }\n\n /** The protocol name this schema belongs to. */\n get protocol(): string {\n return this.#data.protocol;\n }\n\n /** All vertices in the schema. */\n get vertices(): Readonly<Record<string, Vertex>> {\n return this.#data.vertices;\n }\n\n /** All edges in the schema. */\n get edges(): readonly Edge[] {\n return this.#data.edges;\n }\n\n /** @internal Create from raw handle (used by normalize). */\n static _fromHandle(\n handle: number,\n data: SchemaData,\n _protocol: string,\n wasm: WasmModule,\n ): BuiltSchema {\n const wasmHandle = createHandle(handle, wasm);\n return new BuiltSchema(wasmHandle, data, wasm);\n }\n\n /** Normalize this schema by collapsing reference chains. Returns a new BuiltSchema. */\n normalize(): BuiltSchema {\n const handle = this.#wasm.exports.normalize_schema(this.#handle.id);\n return BuiltSchema._fromHandle(handle, this.#data, this.#data.protocol, this.#wasm);\n }\n\n /** Validate this schema against a protocol's rules. */\n validate(protocol: Protocol): ValidationResult {\n const bytes = this.#wasm.exports.validate_schema(\n this.#handle.id,\n protocol._handle.id,\n );\n const issues = unpackFromWasm<SchemaValidationIssue[]>(bytes);\n return new ValidationResult(issues);\n }\n\n /** Release the WASM-side schema resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n","/**\n * Protocol definition helpers.\n *\n * A protocol specifies the schema theory and instance theory used by\n * a family of schemas (e.g., ATProto, SQL, Protobuf). This module\n * provides helpers for defining and looking up protocols.\n *\n * @module\n */\n\nimport type { WasmModule, ProtocolSpec, EdgeRule } from './types.js';\nimport { PanprotoError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\nimport { SchemaBuilder } from './schema.js';\n\n/**\n * A registered protocol with a WASM-side handle.\n *\n * Provides a fluent API for building schemas within this protocol.\n * Implements `Disposable` for automatic cleanup.\n */\nexport class Protocol implements Disposable {\n readonly #handle: WasmHandle;\n readonly #spec: ProtocolSpec;\n readonly #wasm: WasmModule;\n\n constructor(handle: WasmHandle, spec: ProtocolSpec, wasm: WasmModule) {\n this.#handle = handle;\n this.#spec = spec;\n this.#wasm = wasm;\n }\n\n /** The protocol name. */\n get name(): string {\n return this.#spec.name;\n }\n\n /** The full protocol specification. */\n get spec(): ProtocolSpec {\n return this.#spec;\n }\n\n /** The edge rules for this protocol. */\n get edgeRules(): readonly EdgeRule[] {\n return this.#spec.edgeRules;\n }\n\n /** The constraint sorts for this protocol. */\n get constraintSorts(): readonly string[] {\n return this.#spec.constraintSorts;\n }\n\n /** The object kinds for this protocol. */\n get objectKinds(): readonly string[] {\n return this.#spec.objKinds;\n }\n\n /** The WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Start building a schema within this protocol.\n *\n * @returns A new `SchemaBuilder` bound to this protocol\n */\n schema(): SchemaBuilder {\n return new SchemaBuilder(this.#spec.name, this.#handle, this.#wasm);\n }\n\n /** Release the WASM-side protocol resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Define a protocol by sending its specification to WASM.\n *\n * @param spec - The protocol specification\n * @param wasm - The WASM module\n * @returns A registered protocol with a WASM handle\n * @throws {@link PanprotoError} if the WASM call fails\n */\nexport function defineProtocol(spec: ProtocolSpec, wasm: WasmModule): Protocol {\n const wireSpec = {\n name: spec.name,\n schema_theory: spec.schemaTheory,\n instance_theory: spec.instanceTheory,\n edge_rules: spec.edgeRules.map((r) => ({\n edge_kind: r.edgeKind,\n src_kinds: [...r.srcKinds],\n tgt_kinds: [...r.tgtKinds],\n })),\n obj_kinds: [...spec.objKinds],\n constraint_sorts: [...spec.constraintSorts],\n };\n\n try {\n const bytes = packToWasm(wireSpec);\n const rawHandle = wasm.exports.define_protocol(bytes);\n const handle = createHandle(rawHandle, wasm);\n return new Protocol(handle, spec, wasm);\n } catch (error) {\n throw new PanprotoError(\n `Failed to define protocol \"${spec.name}\": ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Built-in protocol specs\n// ---------------------------------------------------------------------------\n\n/**\n * Built-in ATProto protocol specification.\n *\n * Schema theory: colimit(ThGraph, ThConstraint, ThMulti).\n * Instance theory: ThWType + ThMeta.\n */\nexport const ATPROTO_SPEC: ProtocolSpec = {\n name: 'atproto',\n schemaTheory: 'ThATProtoSchema',\n instanceTheory: 'ThATProtoInstance',\n edgeRules: [\n { edgeKind: 'record-schema', srcKinds: ['record'], tgtKinds: ['object'] },\n { edgeKind: 'prop', srcKinds: ['object', 'query', 'procedure', 'subscription'], tgtKinds: [] },\n { edgeKind: 'items', srcKinds: ['array'], tgtKinds: [] },\n { edgeKind: 'variant', srcKinds: ['union'], tgtKinds: [] },\n { edgeKind: 'ref', srcKinds: [], tgtKinds: [] },\n { edgeKind: 'self-ref', srcKinds: [], tgtKinds: [] },\n ] satisfies EdgeRule[],\n objKinds: [\n 'record', 'object', 'array', 'union', 'string', 'integer', 'boolean',\n 'bytes', 'cid-link', 'blob', 'unknown', 'token', 'query', 'procedure',\n 'subscription', 'ref',\n ],\n constraintSorts: [\n 'minLength', 'maxLength', 'minimum', 'maximum', 'maxGraphemes',\n 'enum', 'const', 'default', 'closed',\n ],\n};\n\n/**\n * Built-in SQL protocol specification.\n *\n * Schema theory: colimit(ThHypergraph, ThConstraint).\n * Instance theory: ThFunctor.\n */\nexport const SQL_SPEC: ProtocolSpec = {\n name: 'sql',\n schemaTheory: 'ThConstrainedHypergraph',\n instanceTheory: 'ThFunctor',\n edgeRules: [\n { edgeKind: 'column', srcKinds: ['table'], tgtKinds: ['type'] },\n { edgeKind: 'fk', srcKinds: ['table'], tgtKinds: ['table'] },\n { edgeKind: 'pk', srcKinds: ['table'], tgtKinds: ['column'] },\n ] satisfies EdgeRule[],\n objKinds: ['table'],\n constraintSorts: ['nullable', 'unique', 'check', 'default'],\n};\n\n/**\n * Built-in Protobuf protocol specification.\n */\nexport const PROTOBUF_SPEC: ProtocolSpec = {\n name: 'protobuf',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'field', srcKinds: ['message'], tgtKinds: [] },\n { edgeKind: 'nested', srcKinds: ['message'], tgtKinds: ['message', 'enum'] },\n { edgeKind: 'value', srcKinds: ['enum'], tgtKinds: ['enum-value'] },\n ] satisfies EdgeRule[],\n objKinds: ['message'],\n constraintSorts: ['field-number', 'repeated', 'optional', 'map-key', 'map-value'],\n};\n\n/**\n * Built-in GraphQL protocol specification.\n */\nexport const GRAPHQL_SPEC: ProtocolSpec = {\n name: 'graphql',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'field', srcKinds: ['type', 'input'], tgtKinds: [] },\n { edgeKind: 'implements', srcKinds: ['type'], tgtKinds: ['interface'] },\n { edgeKind: 'member', srcKinds: ['union'], tgtKinds: ['type'] },\n { edgeKind: 'value', srcKinds: ['enum'], tgtKinds: ['enum-value'] },\n ] satisfies EdgeRule[],\n objKinds: ['type', 'input'],\n constraintSorts: ['non-null', 'list', 'deprecated'],\n};\n\n/**\n * Built-in JSON Schema protocol specification.\n */\nexport const JSON_SCHEMA_SPEC: ProtocolSpec = {\n name: 'json-schema',\n schemaTheory: 'ThConstrainedGraph',\n instanceTheory: 'ThWType',\n edgeRules: [\n { edgeKind: 'property', srcKinds: ['object'], tgtKinds: [] },\n { edgeKind: 'item', srcKinds: ['array'], tgtKinds: [] },\n { edgeKind: 'variant', srcKinds: ['oneOf', 'anyOf'], tgtKinds: [] },\n ] satisfies EdgeRule[],\n objKinds: ['object'],\n constraintSorts: ['minLength', 'maxLength', 'minimum', 'maximum', 'pattern', 'format', 'required'],\n};\n\n/** Registry of built-in protocol specs, keyed by name. */\nexport const BUILTIN_PROTOCOLS: ReadonlyMap<string, ProtocolSpec> = new Map([\n ['atproto', ATPROTO_SPEC],\n ['sql', SQL_SPEC],\n ['protobuf', PROTOBUF_SPEC],\n ['graphql', GRAPHQL_SPEC],\n ['json-schema', JSON_SCHEMA_SPEC],\n]);\n\n/** Lazily cached list of all 76 built-in protocol names from WASM. */\nlet _protocolNamesCache: readonly string[] | null = null;\n\n/**\n * Get the list of all built-in protocol names.\n *\n * Lazily fetches the full list from WASM on first call and caches it.\n *\n * @param wasm - The WASM module\n * @returns Array of all 76 built-in protocol names\n */\nexport function getProtocolNames(wasm: WasmModule): readonly string[] {\n if (_protocolNamesCache !== null) return _protocolNamesCache;\n const bytes = wasm.exports.list_builtin_protocols();\n _protocolNamesCache = unpackFromWasm<string[]>(bytes);\n return _protocolNamesCache;\n}\n\n/**\n * Get a built-in protocol spec by name from WASM.\n *\n * This fetches the full protocol definition from the WASM layer,\n * which includes all 76 protocols (not just the 5 hardcoded ones).\n *\n * @param name - The protocol name\n * @param wasm - The WASM module\n * @returns The protocol spec, or undefined if not found\n */\nexport function getBuiltinProtocol(name: string, wasm: WasmModule): ProtocolSpec | undefined {\n try {\n const nameBytes = new TextEncoder().encode(name);\n const bytes = wasm.exports.get_builtin_protocol(nameBytes);\n const wire = unpackFromWasm<{\n name: string;\n schema_theory: string;\n instance_theory: string;\n edge_rules: { edge_kind: string; src_kinds: string[]; tgt_kinds: string[] }[];\n obj_kinds: string[];\n constraint_sorts: string[];\n }>(bytes);\n return {\n name: wire.name,\n schemaTheory: wire.schema_theory,\n instanceTheory: wire.instance_theory,\n edgeRules: wire.edge_rules.map((r) => ({\n edgeKind: r.edge_kind,\n srcKinds: r.src_kinds,\n tgtKinds: r.tgt_kinds,\n })),\n objKinds: wire.obj_kinds,\n constraintSorts: wire.constraint_sorts,\n };\n } catch {\n return undefined;\n }\n}\n","/**\n * Migration builder and compiled migration wrapper.\n *\n * Migrations define a mapping between two schemas. Once compiled,\n * they can efficiently transform records via WASM.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n Edge,\n LiftResult,\n GetResult,\n ExistenceReport,\n MigrationSpec,\n} from './types.js';\nimport { MigrationError, WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm, packMigrationMapping } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\n\n/**\n * Fluent builder for constructing migrations between two schemas.\n *\n * Each mutation method returns a new `MigrationBuilder` instance,\n * leaving the original unchanged.\n *\n * @example\n * ```typescript\n * const migration = panproto.migration(oldSchema, newSchema)\n * .map('post', 'post')\n * .map('post:body', 'post:body')\n * .mapEdge(oldEdge, newEdge)\n * .compile();\n * ```\n */\nexport class MigrationBuilder {\n readonly #src: BuiltSchema;\n readonly #tgt: BuiltSchema;\n readonly #wasm: WasmModule;\n readonly #vertexMap: ReadonlyMap<string, string>;\n readonly #edgeMap: readonly [Edge, Edge][];\n readonly #resolvers: readonly [[string, string], Edge][];\n\n constructor(\n src: BuiltSchema,\n tgt: BuiltSchema,\n wasm: WasmModule,\n vertexMap: ReadonlyMap<string, string> = new Map(),\n edgeMap: readonly [Edge, Edge][] = [],\n resolvers: readonly [[string, string], Edge][] = [],\n ) {\n this.#src = src;\n this.#tgt = tgt;\n this.#wasm = wasm;\n this.#vertexMap = vertexMap;\n this.#edgeMap = edgeMap;\n this.#resolvers = resolvers;\n }\n\n /**\n * Map a source vertex to a target vertex.\n *\n * @param srcVertex - Vertex id in the source schema\n * @param tgtVertex - Vertex id in the target schema\n * @returns A new builder with the mapping added\n */\n map(srcVertex: string, tgtVertex: string): MigrationBuilder {\n const newMap = new Map(this.#vertexMap);\n newMap.set(srcVertex, tgtVertex);\n\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n newMap,\n this.#edgeMap,\n this.#resolvers,\n );\n }\n\n /**\n * Map a source edge to a target edge.\n *\n * @param srcEdge - Edge in the source schema\n * @param tgtEdge - Edge in the target schema\n * @returns A new builder with the edge mapping added\n */\n mapEdge(srcEdge: Edge, tgtEdge: Edge): MigrationBuilder {\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n this.#vertexMap,\n [...this.#edgeMap, [srcEdge, tgtEdge]],\n this.#resolvers,\n );\n }\n\n /**\n * Add a resolver for ancestor contraction ambiguity.\n *\n * When a migration contracts nodes and the resulting edge between\n * two vertex kinds is ambiguous, a resolver specifies which edge to use.\n *\n * @param srcKind - Source vertex kind in the contracted pair\n * @param tgtKind - Target vertex kind in the contracted pair\n * @param resolvedEdge - The edge to use for this pair\n * @returns A new builder with the resolver added\n */\n resolve(srcKind: string, tgtKind: string, resolvedEdge: Edge): MigrationBuilder {\n return new MigrationBuilder(\n this.#src,\n this.#tgt,\n this.#wasm,\n this.#vertexMap,\n this.#edgeMap,\n [...this.#resolvers, [[srcKind, tgtKind], resolvedEdge]],\n );\n }\n\n /**\n * Get the current migration specification.\n *\n * @returns The migration spec with all accumulated mappings\n */\n toSpec(): MigrationSpec {\n return {\n vertexMap: Object.fromEntries(this.#vertexMap),\n edgeMap: [...this.#edgeMap],\n resolvers: [...this.#resolvers],\n };\n }\n\n /**\n * Invert a bijective migration.\n *\n * Serializes the current mapping to MessagePack and calls the\n * `invert_migration` WASM entry point. Returns a new MigrationSpec\n * representing the inverted migration.\n *\n * @returns The inverted migration specification\n * @throws {@link MigrationError} if the migration is not bijective or inversion fails\n */\n invert(): MigrationSpec {\n const edgeMap = new Map(\n this.#edgeMap.map(([src, tgt]) => [\n { src: src.src, tgt: src.tgt, kind: src.kind, name: src.name ?? null },\n { src: tgt.src, tgt: tgt.tgt, kind: tgt.kind, name: tgt.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n this.#resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: Object.fromEntries(this.#vertexMap),\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n try {\n const resultBytes = this.#wasm.exports.invert_migration(\n mapping,\n this.#src._handle.id,\n this.#tgt._handle.id,\n );\n return unpackFromWasm<MigrationSpec>(resultBytes);\n } catch (error) {\n throw new MigrationError(\n `Failed to invert migration: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Compile the migration for fast per-record application.\n *\n * Sends the migration specification to WASM for compilation.\n * The resulting `CompiledMigration` can be used to transform records.\n *\n * @returns A compiled migration ready for record transformation\n * @throws {@link MigrationError} if compilation fails\n */\n compile(): CompiledMigration {\n const edgeMap = new Map(\n this.#edgeMap.map(([src, tgt]) => [\n { src: src.src, tgt: src.tgt, kind: src.kind, name: src.name ?? null },\n { src: tgt.src, tgt: tgt.tgt, kind: tgt.kind, name: tgt.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n this.#resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: Object.fromEntries(this.#vertexMap),\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n try {\n const rawHandle = this.#wasm.exports.compile_migration(\n this.#src._handle.id,\n this.#tgt._handle.id,\n mapping,\n );\n\n const handle = createHandle(rawHandle, this.#wasm);\n return new CompiledMigration(handle, this.#wasm, this.toSpec());\n } catch (error) {\n throw new MigrationError(\n `Failed to compile migration: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n}\n\n/**\n * A compiled migration that can efficiently transform records via WASM.\n *\n * Implements `Disposable` for automatic cleanup of the WASM resource.\n */\nexport class CompiledMigration implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #spec: MigrationSpec;\n\n constructor(handle: WasmHandle, wasm: WasmModule, spec: MigrationSpec) {\n this.#handle = handle;\n this.#wasm = wasm;\n this.#spec = spec;\n }\n\n /** The WASM handle for this migration. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** The WASM module. Internal use only. */\n get _wasm(): WasmModule {\n return this.#wasm;\n }\n\n /** The migration specification used to build this migration. */\n get spec(): MigrationSpec {\n return this.#spec;\n }\n\n /**\n * Transform a record using this migration (forward direction).\n *\n * Accepts either a raw JS object (which will be msgpack-encoded) or\n * an `Instance` (whose pre-encoded bytes are passed directly to WASM).\n *\n * @param record - The input record or Instance to transform\n * @returns The transformed record\n * @throws {@link WasmError} if the WASM call fails\n */\n lift(record: unknown): LiftResult {\n // If record has _bytes, treat it as an Instance and pass bytes directly\n const inputBytes = (record && typeof record === 'object' && '_bytes' in record)\n ? (record as { _bytes: Uint8Array })._bytes\n : packToWasm(record);\n\n try {\n const outputBytes = this.#wasm.exports.lift_record(\n this.#handle.id,\n inputBytes,\n );\n const data = unpackFromWasm(outputBytes);\n return { data, _rawBytes: outputBytes };\n } catch (error) {\n throw new WasmError(\n `lift_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Bidirectional get: extract view and complement from a record.\n *\n * The complement captures data discarded by the forward projection,\n * enabling lossless round-tripping via `put()`.\n *\n * @param record - The input record\n * @returns The projected view and opaque complement bytes\n * @throws {@link WasmError} if the WASM call fails\n */\n get(record: unknown): GetResult {\n const inputBytes = (record && typeof record === 'object' && '_bytes' in record)\n ? (record as { _bytes: Uint8Array })._bytes\n : packToWasm(record);\n\n try {\n const outputBytes = this.#wasm.exports.get_record(\n this.#handle.id,\n inputBytes,\n );\n const result = unpackFromWasm<{ view: unknown; complement: Uint8Array }>(outputBytes);\n return {\n view: result.view,\n complement: result.complement instanceof Uint8Array\n ? result.complement\n : new Uint8Array(result.complement as ArrayBuffer),\n };\n } catch (error) {\n throw new WasmError(\n `get_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Bidirectional put: restore a full record from a modified view and complement.\n *\n * @param view - The (possibly modified) projected view\n * @param complement - The complement from a prior `get()` call\n * @returns The restored full record\n * @throws {@link WasmError} if the WASM call fails\n */\n put(view: unknown, complement: Uint8Array): LiftResult {\n const viewBytes = (view && typeof view === 'object' && '_bytes' in view)\n ? (view as { _bytes: Uint8Array })._bytes\n : packToWasm(view);\n\n try {\n const outputBytes = this.#wasm.exports.put_record(\n this.#handle.id,\n viewBytes,\n complement,\n );\n const data = unpackFromWasm(outputBytes);\n return { data };\n } catch (error) {\n throw new WasmError(\n `put_record failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the WASM-side compiled migration resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Check existence conditions for a migration between two schemas.\n *\n * @param src - Source schema handle\n * @param tgt - Target schema handle\n * @param spec - The migration specification\n * @param wasm - The WASM module\n * @returns The existence report\n */\nexport function checkExistence(\n protoHandle: number,\n src: BuiltSchema,\n tgt: BuiltSchema,\n spec: MigrationSpec,\n wasm: WasmModule,\n): ExistenceReport {\n const edgeMap = new Map(\n spec.edgeMap.map(([s, t]) => [\n { src: s.src, tgt: s.tgt, kind: s.kind, name: s.name ?? null },\n { src: t.src, tgt: t.tgt, kind: t.kind, name: t.name ?? null },\n ] as const),\n );\n const resolver = new Map(\n spec.resolvers.map(([[s, t], e]) => [\n [s, t] as const,\n { src: e.src, tgt: e.tgt, kind: e.kind, name: e.name ?? null },\n ] as const),\n );\n const mapping = packMigrationMapping({\n vertex_map: spec.vertexMap,\n edge_map: edgeMap,\n hyper_edge_map: {},\n label_map: new Map(),\n resolver,\n });\n\n const resultBytes = wasm.exports.check_existence(\n protoHandle,\n src._handle.id,\n tgt._handle.id,\n mapping,\n );\n\n return unpackFromWasm<ExistenceReport>(resultBytes);\n}\n\n/**\n * Compose two compiled migrations into a single migration.\n *\n * @param m1 - First migration (applied first)\n * @param m2 - Second migration (applied second)\n * @param wasm - The WASM module\n * @returns A new compiled migration representing m2 . m1\n * @throws {@link MigrationError} if composition fails\n */\nexport function composeMigrations(\n m1: CompiledMigration,\n m2: CompiledMigration,\n wasm: WasmModule,\n): CompiledMigration {\n try {\n const rawHandle = wasm.exports.compose_migrations(\n m1._handle.id,\n m2._handle.id,\n );\n const handle = createHandle(rawHandle, wasm);\n\n // Compose vertex maps: if m1 maps A->B and m2 maps B->C, composed maps A->C.\n // Vertices in m1 whose target is not remapped by m2 pass through unchanged.\n const composedVertexMap: Record<string, string> = {};\n for (const [src, intermediate] of Object.entries(m1.spec.vertexMap)) {\n const final_ = m2.spec.vertexMap[intermediate];\n composedVertexMap[src] = final_ ?? intermediate;\n }\n\n // Concatenate edge maps and resolvers from both migrations. The WASM side\n // performs the actual composition; this spec is a best-effort reconstruction\n // for introspection purposes.\n const composedSpec: MigrationSpec = {\n vertexMap: composedVertexMap,\n edgeMap: [...m1.spec.edgeMap, ...m2.spec.edgeMap],\n resolvers: [...m1.spec.resolvers, ...m2.spec.resolvers],\n };\n\n return new CompiledMigration(handle, wasm, composedSpec);\n } catch (error) {\n throw new MigrationError(\n `Failed to compose migrations: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n","/**\n * Instance wrapper for W-type and functor instances.\n *\n * Wraps raw MessagePack-encoded instance data and provides methods\n * for JSON conversion, validation, and element counting.\n *\n * @module\n */\n\nimport type { WasmModule, InstanceValidationResult } from './types.js';\nimport type { BuiltSchema } from './schema.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/**\n * A panproto instance wrapping raw MsgPack-encoded data.\n *\n * Instances are created by parsing raw format bytes via {@link IoRegistry.parse},\n * or by converting JSON via {@link Instance.fromJson}.\n *\n * @example\n * ```typescript\n * const instance = registry.parse('graphql', schema, inputBytes);\n * console.log(instance.elementCount);\n *\n * const json = instance.toJson();\n * const validation = instance.validate();\n * ```\n */\nexport class Instance {\n /** Raw MsgPack-encoded instance bytes (for passing back to WASM). */\n readonly _bytes: Uint8Array;\n\n /** The schema this instance conforms to. */\n readonly _schema: BuiltSchema;\n\n /** @internal */\n readonly _wasm: WasmModule;\n\n constructor(bytes: Uint8Array, schema: BuiltSchema, wasm: WasmModule) {\n this._bytes = bytes;\n this._schema = schema;\n this._wasm = wasm;\n }\n\n /** Convert this instance to JSON bytes. */\n toJson(): Uint8Array {\n return this._wasm.exports.instance_to_json(\n this._schema._handle.id,\n this._bytes,\n );\n }\n\n /** Validate this instance against its schema. */\n validate(): InstanceValidationResult {\n const resultBytes = this._wasm.exports.validate_instance(\n this._schema._handle.id,\n this._bytes,\n );\n const errors = unpackFromWasm<string[]>(resultBytes);\n return {\n isValid: errors.length === 0,\n errors,\n };\n }\n\n /** Get the number of elements in this instance. */\n get elementCount(): number {\n return this._wasm.exports.instance_element_count(this._bytes);\n }\n\n /**\n * Create an Instance from JSON input.\n *\n * @param schema - The schema the JSON data conforms to\n * @param json - JSON bytes\n * @param wasm - The WASM module\n * @returns A new Instance\n */\n static fromJson(schema: BuiltSchema, json: Uint8Array, wasm: WasmModule): Instance {\n const bytes = wasm.exports.json_to_instance(schema._handle.id, json);\n return new Instance(bytes, schema, wasm);\n }\n}\n","/**\n * I/O protocol registry for parsing and emitting instances.\n *\n * Wraps the WASM-side IoRegistry and provides parse/emit operations\n * across 77 protocol codecs organized by category.\n *\n * @module\n */\n\nimport type { WasmModule } from './types.js';\nimport type { WasmHandle } from './wasm.js';\nimport type { BuiltSchema } from './schema.js';\nimport { Instance } from './instance.js';\nimport { unpackFromWasm } from './msgpack.js';\n\n/** Protocol names organized by category. */\nexport const PROTOCOL_CATEGORIES: Readonly<Record<string, readonly string[]>> = {\n annotation: [\n 'brat', 'conllu', 'naf', 'uima', 'folia', 'tei', 'timeml', 'elan',\n 'iso_space', 'paula', 'laf_graf', 'decomp', 'ucca', 'fovea', 'bead',\n 'web_annotation', 'amr', 'concrete', 'nif',\n ],\n api: ['graphql', 'openapi', 'asyncapi', 'jsonapi', 'raml'],\n config: ['cloudformation', 'ansible', 'k8s_crd', 'hcl'],\n data_schema: [\n 'json_schema', 'yaml_schema', 'toml_schema', 'cddl', 'bson',\n 'csv_table', 'ini_schema',\n ],\n data_science: ['dataframe', 'parquet', 'arrow'],\n database: ['mongodb', 'dynamodb', 'cassandra', 'neo4j', 'sql', 'redis'],\n domain: ['geojson', 'fhir', 'rss_atom', 'vcard_ical', 'swift_mt', 'edi_x12'],\n serialization: [\n 'protobuf', 'avro', 'thrift', 'capnproto', 'flatbuffers', 'asn1',\n 'bond', 'msgpack_schema',\n ],\n type_system: [\n 'typescript', 'python', 'rust_serde', 'java', 'go_struct', 'kotlin',\n 'csharp', 'swift',\n ],\n web_document: [\n 'atproto', 'jsx', 'vue', 'svelte', 'css', 'html', 'markdown',\n 'xml_xsd', 'docx', 'odf',\n ],\n};\n\n/** Shared TextEncoder for protocol name encoding. */\nconst encoder = new TextEncoder();\n\n/**\n * Registry of I/O protocol codecs for parsing and emitting instances.\n *\n * Wraps a WASM-side IoRegistry handle and provides methods for\n * listing protocols, parsing raw bytes into instances, and emitting\n * instances back to raw format bytes.\n *\n * Implements `Disposable` so it can be used with `using` to automatically\n * clean up the WASM resource.\n *\n * @example\n * ```typescript\n * const panproto = await Panproto.init();\n * using registry = panproto.io();\n *\n * console.log(registry.protocols);\n * const instance = registry.parse('graphql', schema, inputBytes);\n * const output = registry.emit('graphql', schema, instance);\n * ```\n */\nexport class IoRegistry implements Disposable {\n readonly _handle: WasmHandle;\n readonly _wasm: WasmModule;\n private _protocolsCache: string[] | null = null;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this._handle = handle;\n this._wasm = wasm;\n }\n\n /**\n * List all registered protocol names.\n *\n * The result is cached after the first call.\n */\n get protocols(): readonly string[] {\n if (this._protocolsCache === null) {\n const bytes = this._wasm.exports.list_io_protocols(this._handle.id);\n this._protocolsCache = unpackFromWasm<string[]>(bytes);\n }\n return this._protocolsCache;\n }\n\n /** Protocol names organized by category. */\n get categories(): Readonly<Record<string, readonly string[]>> {\n return PROTOCOL_CATEGORIES;\n }\n\n /** Check if a protocol is registered. */\n hasProtocol(name: string): boolean {\n return this.protocols.includes(name);\n }\n\n /**\n * Parse raw format bytes into an Instance.\n *\n * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')\n * @param schema - The schema the data conforms to\n * @param input - Raw format bytes to parse\n * @returns A new Instance wrapping the parsed data\n * @throws {@link PanprotoError} if the protocol is not registered or parsing fails\n */\n parse(protocolName: string, schema: BuiltSchema, input: Uint8Array): Instance {\n const nameBytes = encoder.encode(protocolName);\n const resultBytes = this._wasm.exports.parse_instance(\n this._handle.id,\n nameBytes,\n schema._handle.id,\n input,\n );\n return new Instance(resultBytes, schema, this._wasm);\n }\n\n /**\n * Emit an Instance to raw format bytes.\n *\n * @param protocolName - The protocol codec name (e.g., 'graphql', 'protobuf')\n * @param schema - The schema the instance conforms to\n * @param instance - The instance to emit\n * @returns Raw format bytes\n * @throws {@link PanprotoError} if the protocol is not registered or emission fails\n */\n emit(protocolName: string, schema: BuiltSchema, instance: Instance): Uint8Array {\n const nameBytes = encoder.encode(protocolName);\n return this._wasm.exports.emit_instance(\n this._handle.id,\n nameBytes,\n schema._handle.id,\n instance._bytes,\n );\n }\n\n /** Release the WASM-side IoRegistry resource. */\n [Symbol.dispose](): void {\n this._handle[Symbol.dispose]();\n }\n}\n","/**\n * VCS (Version Control System) for schema evolution.\n *\n * Provides a git-like API for versioning schemas with branches,\n * commits, merges, and blame.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n VcsLogEntry,\n VcsStatus,\n VcsOpResult,\n VcsBlameResult,\n} from './types.js';\nimport { WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { unpackFromWasm } from './msgpack.js';\nimport type { BuiltSchema } from './schema.js';\n\nconst encoder = new TextEncoder();\n\n/**\n * An in-memory VCS repository for schema evolution.\n *\n * Implements `Disposable` for automatic cleanup of the WASM-side resource.\n *\n * @example\n * ```typescript\n * using repo = Repository.init('atproto', wasm);\n * repo.add(schema);\n * repo.commit('initial schema', 'alice');\n * const log = repo.log();\n * ```\n */\nexport class Repository implements Disposable {\n readonly #handle: WasmHandle;\n readonly #wasm: WasmModule;\n readonly #protocolName: string;\n\n private constructor(handle: WasmHandle, protocolName: string, wasm: WasmModule) {\n this.#handle = handle;\n this.#protocolName = protocolName;\n this.#wasm = wasm;\n }\n\n /**\n * Initialize a new in-memory repository.\n *\n * @param protocolName - The protocol this repository tracks\n * @param wasm - The WASM module\n * @returns A new disposable Repository\n */\n static init(protocolName: string, wasm: WasmModule): Repository {\n const nameBytes = encoder.encode(protocolName);\n const rawHandle = wasm.exports.vcs_init(nameBytes);\n const handle = createHandle(rawHandle, wasm);\n return new Repository(handle, protocolName, wasm);\n }\n\n /** The protocol name this repository tracks. */\n get protocolName(): string {\n return this.#protocolName;\n }\n\n /** The underlying WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /**\n * Stage a schema for the next commit.\n *\n * @param schema - The built schema to stage\n * @returns An object with the schema's object ID\n */\n add(schema: BuiltSchema): { schemaId: string } {\n try {\n const resultBytes = this.#wasm.exports.vcs_add(\n this.#handle.id,\n schema._handle.id,\n );\n const result = unpackFromWasm<{ schema_id: string }>(resultBytes);\n return { schemaId: result.schema_id };\n } catch (error) {\n throw new WasmError(\n `vcs_add failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Create a commit from the current staging area.\n *\n * @param message - The commit message\n * @param author - The commit author\n * @returns The commit result\n */\n commit(message: string, author: string): Uint8Array {\n try {\n return this.#wasm.exports.vcs_commit(\n this.#handle.id,\n encoder.encode(message),\n encoder.encode(author),\n );\n } catch (error) {\n throw new WasmError(\n `vcs_commit failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Walk the commit log from HEAD.\n *\n * @param count - Maximum number of log entries to return (default: 50)\n * @returns Array of commit log entries\n */\n log(count: number = 50): VcsLogEntry[] {\n try {\n const resultBytes = this.#wasm.exports.vcs_log(this.#handle.id, count);\n return unpackFromWasm<VcsLogEntry[]>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_log failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Get the repository status.\n *\n * @returns Current branch and HEAD commit info\n */\n status(): VcsStatus {\n try {\n const resultBytes = this.#wasm.exports.vcs_status(this.#handle.id);\n return unpackFromWasm<VcsStatus>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_status failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Get diff information for the repository.\n *\n * @returns Diff result with branch info\n */\n diff(): unknown {\n try {\n const resultBytes = this.#wasm.exports.vcs_diff(this.#handle.id);\n return unpackFromWasm(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_diff failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Create a new branch at the current HEAD.\n *\n * @param name - The branch name\n * @returns Operation result\n */\n branch(name: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_branch(\n this.#handle.id,\n encoder.encode(name),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_branch failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Checkout a branch.\n *\n * @param target - The branch name to checkout\n * @returns Operation result\n */\n checkout(target: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_checkout(\n this.#handle.id,\n encoder.encode(target),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_checkout failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Merge a branch into the current branch.\n *\n * @param branchName - The branch to merge\n * @returns Operation result\n */\n merge(branchName: string): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_merge(\n this.#handle.id,\n encoder.encode(branchName),\n );\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_merge failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Stash the current working state.\n *\n * @returns Operation result\n */\n stash(): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_stash(this.#handle.id);\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_stash failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Pop the most recent stash entry.\n *\n * @returns Operation result\n */\n stashPop(): VcsOpResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_stash_pop(this.#handle.id);\n return unpackFromWasm<VcsOpResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_stash_pop failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Find which commit introduced a vertex.\n *\n * @param vertexId - The vertex ID to blame\n * @returns Blame result with commit info\n */\n blame(vertexId: string): VcsBlameResult {\n try {\n const resultBytes = this.#wasm.exports.vcs_blame(\n this.#handle.id,\n encoder.encode(vertexId),\n );\n return unpackFromWasm<VcsBlameResult>(resultBytes);\n } catch (error) {\n throw new WasmError(\n `vcs_blame failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /** Release the WASM-side repository resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n","/**\n * Main Panproto class — the primary entry point for the SDK.\n *\n * Wraps the WASM module and provides the high-level API for working\n * with protocols, schemas, migrations, and diffs.\n *\n * @module\n */\n\nimport type { WasmModule, ProtocolSpec, DiffReport, FullSchemaDiff, SchemaValidationIssue } from './types.js';\nimport { PanprotoError, WasmError } from './types.js';\nimport { loadWasm, type WasmGlueModule, createHandle } from './wasm.js';\nimport { LensHandle } from './lens.js';\nimport {\n Protocol,\n defineProtocol,\n BUILTIN_PROTOCOLS,\n getProtocolNames,\n getBuiltinProtocol,\n} from './protocol.js';\nimport { BuiltSchema } from './schema.js';\nimport {\n MigrationBuilder,\n CompiledMigration,\n checkExistence,\n composeMigrations,\n} from './migration.js';\nimport { unpackFromWasm } from './msgpack.js';\nimport { FullDiffReport, ValidationResult } from './check.js';\nimport { Instance } from './instance.js';\nimport { IoRegistry } from './io.js';\nimport { Repository } from './vcs.js';\n\n/**\n * The main entry point for the panproto SDK.\n *\n * Create an instance with {@link Panproto.init}, then use it to define\n * protocols, build schemas, compile migrations, and diff schemas.\n *\n * Implements `Disposable` so it can be used with `using` to automatically\n * clean up all WASM resources.\n *\n * @example\n * ```typescript\n * const panproto = await Panproto.init();\n * const atproto = panproto.protocol('atproto');\n *\n * const schema = atproto.schema()\n * .vertex('post', 'record', { nsid: 'app.bsky.feed.post' })\n * .vertex('post:body', 'object')\n * .edge('post', 'post:body', 'record-schema')\n * .build();\n *\n * const migration = panproto.migration(oldSchema, newSchema)\n * .map('post', 'post')\n * .compile();\n *\n * const result = migration.lift(inputRecord);\n * ```\n */\nexport class Panproto implements Disposable {\n readonly #wasm: WasmModule;\n readonly #protocols: Map<string, Protocol>;\n\n private constructor(wasm: WasmModule) {\n this.#wasm = wasm;\n this.#protocols = new Map();\n }\n\n /**\n * Initialize the panproto SDK by loading the WASM module.\n *\n * @param input - URL to the wasm-bindgen glue module, or a pre-imported\n * glue module object (for bundler environments like Vite).\n * Defaults to the bundled glue module.\n * @returns An initialized Panproto instance\n * @throws {@link import('./types.js').WasmError} if WASM loading fails\n */\n static async init(input?: string | URL | WasmGlueModule): Promise<Panproto> {\n const wasm = await loadWasm(input);\n return new Panproto(wasm);\n }\n\n /**\n * Get or register a protocol by name.\n *\n * If the protocol is a built-in (e.g., 'atproto', 'sql'), it is\n * automatically registered on first access. Custom protocols must\n * be registered first with {@link Panproto.defineProtocol}.\n *\n * @param name - The protocol name\n * @returns The protocol instance\n * @throws {@link PanprotoError} if the protocol is not found\n */\n protocol(name: string): Protocol {\n const cached = this.#protocols.get(name);\n if (cached) return cached;\n\n // Try hardcoded built-in protocols first (fast path)\n const builtinSpec = BUILTIN_PROTOCOLS.get(name);\n if (builtinSpec) {\n const proto = defineProtocol(builtinSpec, this.#wasm);\n this.#protocols.set(name, proto);\n return proto;\n }\n\n // Try fetching from WASM (supports all 76 protocols)\n const wasmSpec = getBuiltinProtocol(name, this.#wasm);\n if (wasmSpec) {\n const proto = defineProtocol(wasmSpec, this.#wasm);\n this.#protocols.set(name, proto);\n return proto;\n }\n\n throw new PanprotoError(\n `Protocol \"${name}\" not found. Register it with defineProtocol() first.`,\n );\n }\n\n /**\n * Define and register a custom protocol.\n *\n * @param spec - The protocol specification\n * @returns The registered protocol\n * @throws {@link PanprotoError} if registration fails\n */\n defineProtocol(spec: ProtocolSpec): Protocol {\n const proto = defineProtocol(spec, this.#wasm);\n this.#protocols.set(spec.name, proto);\n return proto;\n }\n\n /**\n * Start building a migration between two schemas.\n *\n * @param src - The source schema\n * @param tgt - The target schema\n * @returns A migration builder\n */\n migration(src: BuiltSchema, tgt: BuiltSchema): MigrationBuilder {\n return new MigrationBuilder(src, tgt, this.#wasm);\n }\n\n /**\n * Check existence conditions for a proposed migration.\n *\n * Verifies that the migration specification satisfies all\n * protocol-derived constraints (edge coverage, kind consistency,\n * required fields, etc.).\n *\n * @param src - The source schema\n * @param tgt - The target schema\n * @param builder - The migration builder with mappings\n * @returns The existence report\n */\n checkExistence(\n src: BuiltSchema,\n tgt: BuiltSchema,\n builder: MigrationBuilder,\n ): import('./types.js').ExistenceReport {\n const proto = this.#protocols.get(src.protocol);\n if (!proto) {\n throw new PanprotoError(\n `Protocol \"${src.protocol}\" not registered. Call protocol() first.`,\n );\n }\n return checkExistence(proto._handle.id, src, tgt, builder.toSpec(), this.#wasm);\n }\n\n /**\n * Compose two compiled migrations into a single migration.\n *\n * The resulting migration is equivalent to applying `m1` then `m2`.\n *\n * @param m1 - First migration (applied first)\n * @param m2 - Second migration (applied second)\n * @returns The composed migration\n * @throws {@link import('./types.js').MigrationError} if composition fails\n */\n compose(m1: CompiledMigration, m2: CompiledMigration): CompiledMigration {\n return composeMigrations(m1, m2, this.#wasm);\n }\n\n /**\n * Compose two lenses into a single lens.\n *\n * The resulting lens is equivalent to applying `l1` then `l2`.\n *\n * @param l1 - First lens (applied first)\n * @param l2 - Second lens (applied second)\n * @returns A new LensHandle representing the composition\n * @throws {@link import('./types.js').WasmError} if composition fails\n */\n composeLenses(l1: LensHandle, l2: LensHandle): LensHandle {\n try {\n const rawHandle = this.#wasm.exports.compose_lenses(\n l1._handle.id,\n l2._handle.id,\n );\n const handle = createHandle(rawHandle, this.#wasm);\n return new LensHandle(handle, this.#wasm);\n } catch (error) {\n throw new WasmError(\n `compose_lenses failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n }\n\n /**\n * Diff two schemas and produce a compatibility report.\n *\n * @param oldSchema - The old/source schema\n * @param newSchema - The new/target schema\n * @returns A diff report with changes and compatibility classification\n */\n diff(oldSchema: BuiltSchema, newSchema: BuiltSchema): DiffReport {\n const resultBytes = this.#wasm.exports.diff_schemas(\n oldSchema._handle.id,\n newSchema._handle.id,\n );\n return unpackFromWasm<DiffReport>(resultBytes);\n }\n\n /** Diff two schemas using the full panproto-check engine (20+ change categories). */\n diffFull(oldSchema: BuiltSchema, newSchema: BuiltSchema): FullDiffReport {\n const bytes = this.#wasm.exports.diff_schemas_full(\n oldSchema._handle.id,\n newSchema._handle.id,\n );\n const data = unpackFromWasm<FullSchemaDiff>(bytes);\n return new FullDiffReport(data, bytes, this.#wasm);\n }\n\n /** Normalize a schema by collapsing reference chains. Returns a new BuiltSchema. */\n normalize(schema: BuiltSchema): BuiltSchema {\n const handle = this.#wasm.exports.normalize_schema(schema._handle.id);\n // Create a new BuiltSchema from the handle\n return BuiltSchema._fromHandle(handle, schema.data, schema.protocol, this.#wasm);\n }\n\n /** Validate a schema against its protocol's rules. */\n validateSchema(schema: BuiltSchema, protocol: Protocol): ValidationResult {\n const bytes = this.#wasm.exports.validate_schema(\n schema._handle.id,\n protocol._handle.id,\n );\n const issues = unpackFromWasm<SchemaValidationIssue[]>(bytes);\n return new ValidationResult(issues);\n }\n\n /**\n * Create an I/O protocol registry for parsing and emitting instances.\n *\n * The returned registry wraps all 77 built-in protocol codecs and\n * implements `Disposable` for automatic cleanup.\n *\n * @returns A new IoRegistry\n */\n io(): IoRegistry {\n const rawHandle = this.#wasm.exports.register_io_protocols();\n const handle = createHandle(rawHandle, this.#wasm);\n return new IoRegistry(handle, this.#wasm);\n }\n\n /**\n * Parse JSON bytes into an Instance.\n *\n * Convenience method that wraps `json_to_instance`.\n *\n * @param schema - The schema the JSON data conforms to\n * @param json - JSON bytes or a JSON string\n * @returns A new Instance\n */\n parseJson(schema: BuiltSchema, json: Uint8Array | string): Instance {\n const jsonBytes = typeof json === 'string'\n ? new TextEncoder().encode(json)\n : json;\n return Instance.fromJson(schema, jsonBytes, this.#wasm);\n }\n\n /**\n * Convert an Instance to JSON bytes.\n *\n * Convenience method that wraps `instance_to_json`.\n *\n * @param schema - The schema the instance conforms to\n * @param instance - The instance to convert\n * @returns JSON bytes\n */\n toJson(schema: BuiltSchema, instance: Instance): Uint8Array {\n return this.#wasm.exports.instance_to_json(\n schema._handle.id,\n instance._bytes,\n );\n }\n\n /**\n * List all built-in protocol names.\n *\n * Returns the names of all 76 built-in protocols supported by the\n * WASM layer.\n *\n * @returns Array of protocol name strings\n */\n listProtocols(): string[] {\n return [...getProtocolNames(this.#wasm)];\n }\n\n /**\n * Initialize an in-memory VCS repository.\n *\n * @param protocolName - The protocol name for this repository\n * @returns A disposable VCS Repository\n */\n initRepo(protocolName: string): Repository {\n return Repository.init(protocolName, this.#wasm);\n }\n\n /**\n * Release all WASM resources held by this instance.\n *\n * Disposes all cached protocols. After disposal, this instance\n * must not be used.\n */\n [Symbol.dispose](): void {\n for (const proto of this.#protocols.values()) {\n proto[Symbol.dispose]();\n }\n this.#protocols.clear();\n }\n}\n","/**\n * GAT (Generalized Algebraic Theory) operations.\n *\n * Provides a fluent API for creating theories, computing colimits,\n * checking morphisms, and migrating models.\n *\n * @module\n */\n\nimport type {\n WasmModule,\n TheorySpec,\n TheoryMorphism,\n MorphismCheckResult,\n Sort,\n GatOperation,\n Equation,\n} from './types.js';\nimport { PanprotoError, WasmError } from './types.js';\nimport { WasmHandle, createHandle } from './wasm.js';\nimport { packToWasm, unpackFromWasm } from './msgpack.js';\n\n/**\n * A disposable handle to a WASM-side Theory resource.\n *\n * Implements `Disposable` for use with `using` declarations.\n */\nexport class TheoryHandle implements Disposable {\n readonly #handle: WasmHandle;\n /** @internal Retained for future sort/op inspection methods. */\n readonly _wasm: WasmModule;\n\n constructor(handle: WasmHandle, wasm: WasmModule) {\n this.#handle = handle;\n this._wasm = wasm;\n }\n\n /** The WASM handle. Internal use only. */\n get _handle(): WasmHandle {\n return this.#handle;\n }\n\n /** Release the WASM-side theory resource. */\n [Symbol.dispose](): void {\n this.#handle[Symbol.dispose]();\n }\n}\n\n/**\n * Fluent builder for constructing a Theory specification.\n *\n * @example\n * ```typescript\n * const monoid = new TheoryBuilder('Monoid')\n * .sort('Carrier')\n * .op('mul', [['a', 'Carrier'], ['b', 'Carrier']], 'Carrier')\n * .op('unit', [], 'Carrier')\n * .build(wasm);\n * ```\n */\nexport class TheoryBuilder {\n readonly #name: string;\n readonly #extends: string[];\n readonly #sorts: Sort[];\n readonly #ops: GatOperation[];\n readonly #eqs: Equation[];\n\n constructor(name: string) {\n this.#name = name;\n this.#extends = [];\n this.#sorts = [];\n this.#ops = [];\n this.#eqs = [];\n }\n\n /** Declare that this theory extends a parent theory. */\n extends(parentName: string): this {\n this.#extends.push(parentName);\n return this;\n }\n\n /** Add a simple sort (no parameters). */\n sort(name: string): this {\n this.#sorts.push({ name, params: [] });\n return this;\n }\n\n /** Add a dependent sort with parameters. */\n dependentSort(name: string, params: { name: string; sort: string }[]): this {\n this.#sorts.push({ name, params });\n return this;\n }\n\n /** Add an operation. */\n op(name: string, inputs: [string, string][], output: string): this {\n this.#ops.push({ name, inputs, output });\n return this;\n }\n\n /** Add an equation (axiom). */\n eq(name: string, lhs: import('./types.js').Term, rhs: import('./types.js').Term): this {\n this.#eqs.push({ name, lhs, rhs });\n return this;\n }\n\n /** Get the theory specification. */\n toSpec(): TheorySpec {\n return {\n name: this.#name,\n extends: this.#extends,\n sorts: this.#sorts,\n ops: this.#ops,\n eqs: this.#eqs,\n };\n }\n\n /**\n * Build the theory and register it in WASM.\n *\n * @param wasm - The WASM module\n * @returns A disposable TheoryHandle\n * @throws {@link PanprotoError} if the WASM call fails\n */\n build(wasm: WasmModule): TheoryHandle {\n return createTheory(this.toSpec(), wasm);\n }\n}\n\n/**\n * Create a theory from a specification.\n *\n * @param spec - The theory specification\n * @param wasm - The WASM module\n * @returns A disposable TheoryHandle\n * @throws {@link PanprotoError} if serialization or WASM fails\n */\nexport function createTheory(spec: TheorySpec, wasm: WasmModule): TheoryHandle {\n try {\n const bytes = packToWasm(spec);\n const rawHandle = wasm.exports.create_theory(bytes);\n const handle = createHandle(rawHandle, wasm);\n return new TheoryHandle(handle, wasm);\n } catch (error) {\n throw new PanprotoError(\n `Failed to create theory \"${spec.name}\": ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n/**\n * Compute the colimit (pushout) of two theories over a shared base.\n *\n * @param t1 - First theory handle\n * @param t2 - Second theory handle\n * @param shared - Shared base theory handle\n * @param wasm - The WASM module\n * @returns A new TheoryHandle for the colimit theory\n * @throws {@link WasmError} if computation fails\n */\nexport function colimit(\n t1: TheoryHandle,\n t2: TheoryHandle,\n shared: TheoryHandle,\n wasm: WasmModule,\n): TheoryHandle {\n try {\n const rawHandle = wasm.exports.colimit_theories(\n t1._handle.id,\n t2._handle.id,\n shared._handle.id,\n );\n const handle = createHandle(rawHandle, wasm);\n return new TheoryHandle(handle, wasm);\n } catch (error) {\n throw new WasmError(\n `colimit_theories failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\n/**\n * Check whether a theory morphism is valid.\n *\n * @param morphism - The morphism to check\n * @param domain - Handle to the domain theory\n * @param codomain - Handle to the codomain theory\n * @param wasm - The WASM module\n * @returns A result indicating validity and any error\n */\nexport function checkMorphism(\n morphism: TheoryMorphism,\n domain: TheoryHandle,\n codomain: TheoryHandle,\n wasm: WasmModule,\n): MorphismCheckResult {\n const morphBytes = packToWasm(morphism);\n const resultBytes = wasm.exports.check_morphism(\n morphBytes,\n domain._handle.id,\n codomain._handle.id,\n );\n return unpackFromWasm<MorphismCheckResult>(resultBytes);\n}\n\n/**\n * Migrate a model's sort interpretations through a morphism.\n *\n * Since operation interpretations (functions) cannot cross the WASM\n * boundary, only sort interpretations are migrated.\n *\n * @param sortInterp - Sort interpretations as name-to-values map\n * @param morphism - The theory morphism to migrate along\n * @param wasm - The WASM module\n * @returns Reindexed sort interpretations\n */\nexport function migrateModel(\n sortInterp: Record<string, unknown[]>,\n morphism: TheoryMorphism,\n wasm: WasmModule,\n): Record<string, unknown[]> {\n const modelBytes = packToWasm(sortInterp);\n const morphBytes = packToWasm(morphism);\n const resultBytes = wasm.exports.migrate_model(modelBytes, morphBytes);\n return unpackFromWasm<Record<string, unknown[]>>(resultBytes);\n}\n"],"names":["exports","encoder"],"mappings":";AA2eO,MAAM,sBAAsB,MAAM;AAAA,EACrB,OAAe;AAAA,EAEjC,YAAY,SAAiB,SAAwB;AACnD,UAAM,SAAS,OAAO;AAAA,EACxB;AACF;AAGO,MAAM,kBAAkB,cAAc;AAAA,EACzB,OAAO;AAC3B;AAGO,MAAM,8BAA8B,cAAc;AAAA,EAGvD,YACE,SACS,QACT;AACA,UAAM,OAAO;AAFJ,SAAA,SAAA;AAAA,EAGX;AAAA,EAPkB,OAAO;AAQ3B;AAGO,MAAM,uBAAuB,cAAc;AAAA,EAC9B,OAAO;AAC3B;AAGO,MAAM,4BAA4B,cAAc;AAAA,EAGrD,YACE,SACS,QACT;AACA,UAAM,OAAO;AAFJ,SAAA,SAAA;AAAA,EAGX;AAAA,EAPkB,OAAO;AAQ3B;ACrgBA,MAAM,mBAAmB,IAAA,IAAA,sBAAA,YAAA,GAAA;AAgFzB,eAAsB,SAAS,OAA4D;AACzF,MAAI;AACF,QAAI;AAEJ,QAAI,SAAS,OAAO,UAAU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