/** * StateCell / ProjectionState — typed authority over the coarse * graph/boundary/quantizer/dirty model (#130 child 5). * * Synchronous snapshots backed by {@link RuntimeCoordinator} dense stores and * explicit generation counters. NOT fine-grained auto-tracking reactivity — * no SolidJS-style tracking, no Effect {@link Cell} subscriptions. * * Discrete cells are replayable (graph patch / receipt chain, #133). Continuous * cells carry ephemeral transients that must NOT replay. * * @module */ import { type StateName } from './brands.js'; import type { RuntimeCoordinatorShape } from './runtime-coordinator.js'; /** Which subsystem owns a cell's value — the authority source. */ export type StateAuthority = 'quantizer' | 'graph' | 'policy' | 'tier' | 'synthetic'; /** Replay discriminator: discrete crossings replay; continuous transients do not. */ export type StateCellKind = 'discrete' | 'continuous'; /** Immutable snapshot of one named state authority cell. */ export interface StateCell { readonly _tag: 'StateCell'; readonly name: string; readonly kind: StateCellKind; readonly authority: StateAuthority; readonly state: StateName; readonly stateIndex: number; readonly dirtyEpoch: number; /** Monotonic generation — increments on discrete state changes (gap-replay ordering). */ readonly generation: number; /** Derived: only discrete cells may enter patch/receipt replay paths (#133). */ readonly replayable: boolean; /** Continuous-only live scalar when {@link kind} is `'continuous'`. */ readonly value?: number; } /** Evidence of which source drove resolution — proto-ProjectionState receipt (#118). */ export interface StateResolutionReceipt { readonly source: StateAuthority; readonly detail?: string; } /** Per-projection typed authority aggregate consumed by emitters. */ export interface ProjectionState { readonly _tag: 'ProjectionState'; readonly projection: string; readonly cells: Readonly>>; /** Composite dirty epoch — max of constituent cells. */ readonly dirtyEpoch: number; /** Primary discrete state for `data-czap-state` / CSS state selectors. */ readonly resolvedState: StateName; readonly resolution?: StateResolutionReceipt; } /** Worker/bootstrap interop — mirrors `ResolvedStateEntry` in `@czap/worker`. */ export interface ResolvedStateSnapshot { readonly name: string; readonly state: StateName; readonly generation: number; } /** Options for {@link StateCellStoreShape.register}. */ export interface StateCellRegisterOptions { readonly authority?: StateAuthority; readonly kind?: StateCellKind; } /** Options for {@link StateCellStoreShape.projectionState}. */ export interface ProjectionStateOptions { readonly quantizerNames?: readonly string[]; readonly resolution?: StateResolutionReceipt; } /** Live store — coarse authority registry over a {@link RuntimeCoordinator}. */ export interface StateCellStoreShape { readonly runtime: RuntimeCoordinatorShape; register(name: string, states: readonly string[], options?: StateCellRegisterOptions): void; unregister(name: string): void; applyDiscrete(name: string, state: string, authority?: StateAuthority): StateCell; writeContinuous(name: string, value: number): StateCell; hydrateDiscrete(name: string, state: string, generation: number, authority?: StateAuthority): StateCell; markDirty(name: string): void; snapshot(name: string): StateCell | undefined; projectionState(projection: string, options?: ProjectionStateOptions): ProjectionState; reset(registrations?: readonly { readonly name: string; readonly states: readonly string[]; }[]): void; } declare function makeCell(name: string, kind: StateCellKind, authority: StateAuthority, state: string, stateIndex: number, dirtyEpoch: number, generation: number, value?: number): StateCell; declare function _createStore(runtime?: RuntimeCoordinatorShape): StateCellStoreShape; /** * StateCell — frozen authority snapshot helpers. */ export declare const StateCell: { /** Build a frozen snapshot directly (tests, hydration, receipts). */ snapshot: typeof makeCell; /** Whether a cell may enter graph patch / receipt replay paths. */ isReplayable: (cell: StateCell) => boolean; /** Build from a worker/bootstrap resolved-state entry. */ fromResolved(entry: ResolvedStateSnapshot, authority?: StateAuthority, states?: readonly string[]): StateCell; }; /** * ProjectionState — per-projection typed authority aggregate. */ export declare const ProjectionState: { /** Build from an explicit cell map. */ fromCells(projection: string, cells: Readonly>, resolution?: StateResolutionReceipt): ProjectionState; }; /** Namespace entry point for the coarse authority store. */ export declare const StateCellStore: { /** Create a store backed by a fresh or supplied {@link RuntimeCoordinator}. */ create: typeof _createStore; }; export declare namespace StateCell { /** Structural shape of a {@link StateCell}. */ type Shape = StateCell; /** Alias for {@link StateAuthority}. */ type Authority = StateAuthority; /** Alias for {@link StateCellKind}. */ type Kind = StateCellKind; } export declare namespace ProjectionState { /** Structural shape of a {@link ProjectionState}. */ type Shape = ProjectionState; /** Alias for {@link StateResolutionReceipt}. */ type ResolutionReceipt = StateResolutionReceipt; } export declare namespace StateCellStore { /** Structural shape of a {@link StateCellStore}. */ type Shape = StateCellStoreShape; } export {}; //# sourceMappingURL=state-cell.d.ts.map