/** * Satellite declaration wiring (#591, archetype-③) — the full body behind * `Vault.collection()`'s thin call-site: in-session reconcile (idempotent * identical redeclare / R-S9 divergent refusal), sync validation * (R-S3/R-S5/R-S8), the R-S7 forget-coverage gate, lazy registry + poison * write-gate creation, registration, and the fire-and-forget postRegister * (marker persistence + R-S1 cross-check). Kept dependency-narrow: no * `Vault` import — the kernel supplies a {@link SatelliteDeclareContext}. */ import type { NoydbStore } from '../../kernel/types.js'; import type { EnclaveKey } from '../../kernel/enclave/index.js'; import { SatelliteRegistry } from './registry.js'; /** The narrow slice of Vault that declaration wiring needs. */ export interface SatelliteDeclareContext { readonly adapter: NoydbStore; readonly vaultName: string; /** `forgetStrategy.subjects` — collection → subject field (R-S7 gate input). */ readonly forgetSubjects: Record; readonly getDEK: (collectionName: string) => Promise; /** The base collection's attached Standard Schema validator, if constructed. */ readonly getBaseSchema: (base: string) => unknown; /** The base collection's constructed crdt mode, if any (R-S8 direction i). */ readonly getBaseCrdt: (base: string) => unknown; /** True when `name` is an already-constructed collection (R-S5 joined-name guard). */ readonly collectionExists: (name: string) => boolean; /** Registers the vault-wide poison write-gate; invoked at most once per vault. */ readonly registerPoisonHook: (hook: (e: { readonly vault: string; readonly collection: string; }) => void) => void; /** * Iterates the vault's SyncEngine(s) (#591 Task 11) — used to wire the * live pair-expander (once per vault, alongside `registerPoisonHook`; the * closure captures the registry itself, not a snapshot, so pairs declared * later are still picked up by push/pull filters) and to retroactively * re-mirror conflict resolvers on every successful pair registration. * No-op when sync is not configured. */ readonly forEachSyncEngine: (fn: (engine: PairSyncEngine) => void) => void; } /** The narrow slice of SyncEngine that satellite declaration wiring drives (#591 Task 11). */ interface PairSyncEngine { setPairExpander(expander: (names: readonly string[]) => readonly string[]): void; remirrorPairResolvers(names: readonly string[]): void; } export interface SatelliteDeclarationOptions { readonly satelliteOf: string; readonly fields?: readonly string[] | undefined; readonly joined?: string | undefined; readonly perRecordKeys?: boolean | undefined; readonly crdt?: unknown; } /** * Register `collectionName` as a satellite per `options`. Returns the * (possibly newly created) registry — the caller stores it back on the vault. * A refused declaration throws {@link SatelliteConfigError} and leaves NO * side effect (no registry created, no hook registered). */ export declare function declareSatellite(ctx: SatelliteDeclareContext, collectionName: string, options: SatelliteDeclarationOptions, existingRegistry: SatelliteRegistry | null): SatelliteRegistry; export {};