/**
 * StrandDescriptorStore — boundary over strand refs and descriptor blobs.
 *
 * Responsible for reading, writing, normalizing, and hydrating strand
 * descriptors. Braid-ref synchronization lives here too.
 *
 * @module domain/services/strand/StrandDescriptorStore
 */
import { type StrandDescriptor as ParsedStrandDescriptor } from '../../utils/parseStrandBlob.ts';
import { type RawBag, type RawValue, type StrandReadOverlayDescriptor, type StrandIntentQueue, type StrandEvolution, type StrandQueuedIntent, type StrandRejectedCounterfactual } from './descriptorNormalization.ts';
import type GraphPersistencePort from '../../../ports/GraphPersistencePort.ts';
import type Patch from '../../types/Patch.ts';
/** Full runtime strand descriptor (overlay + braid + intentQueue + evolution). */
export type StrandDescriptor = ParsedStrandDescriptor & {
    overlay: ParsedStrandDescriptor['overlay'] & {
        writable: boolean;
    };
    braid: {
        readOverlays: StrandReadOverlayDescriptor[];
    };
    intentQueue: StrandIntentQueue;
    evolution: StrandEvolution;
};
type BaseObservation = ParsedStrandDescriptor['baseObservation'];
/**
 * Structural description of the graph-runtime surface the store
 * reaches into. Narrow by design — the store is boundary code, not a
 * handle onto the whole runtime. The patch-chain return type is
 * parameterized over the runtime's Patch carrier shape; the store
 * only takes the length so the detailed carrier is irrelevant.
 */
type StrandDescriptorStoreGraph = {
    _graphName: string;
    _persistence: GraphPersistencePort;
    _loadPatchChainFromSha: (sha: string) => Promise<readonly PatchChainEntry[]>;
};
/**
 * Opaque placeholder for a patch-chain entry. The store treats the
 * chain as length-only; any deeper access lives upstream in the
 * materializer. Kept as an object so the structural check holds
 * without tripping the anti-sludge `unknown`/`Record<string, // nosemgrep: ts-no-unknown-outside-adapters -- 0025B
 * unknown>` rules. // nosemgrep: ts-no-unknown-outside-adapters -- 0025B
 */
type PatchChainEntry = object;
type StoreOptions = {
    graph: StrandDescriptorStoreGraph;
    loadStrandOrThrow: (strandId: string) => Promise<StrandDescriptor>;
    baseObservationsEqual: (left: BaseObservation, right: BaseObservation) => boolean;
};
export default class StrandDescriptorStore {
    private readonly _graph;
    private readonly _loadStrandOrThrow;
    private readonly _baseObservationsEqual;
    constructor({ graph, loadStrandOrThrow, baseObservationsEqual }: StoreOptions);
    buildRef(strandId: string): string;
    buildOverlayRef(strandId: string): string;
    buildBraidPrefix(strandId: string): string;
    buildBraidRef(strandId: string, braidedStrandId: string): string;
    readDescriptorByOid(oid: string, strandId: string): Promise<ParsedStrandDescriptor>;
    writeDescriptor(descriptor: StrandDescriptor): Promise<void>;
    loadBraidedReadOverlays(target: StrandDescriptor, braidedStrandIds: string[]): Promise<StrandReadOverlayDescriptor[]>;
    buildReadOverlayMetadata(descriptor: StrandDescriptor): StrandReadOverlayDescriptor;
    readOverlayMetadata(strandId: string): Promise<{
        headPatchSha: string | null;
        patchCount: number;
    }>;
    hydrateDescriptor(descriptor: ParsedStrandDescriptor): Promise<StrandDescriptor>;
    private _buildNormalizedDescriptor;
    private _matchesHydratedDescriptor;
    private _withOverlayMetadata;
    normalizeIntentQueue(value: RawValue): StrandIntentQueue;
    normalizeEvolution(value: RawValue): StrandEvolution;
    syncBraidRefs(strandId: string, readOverlays: StrandReadOverlayDescriptor[]): Promise<void>;
    private _syncOneBraidRef;
    /** @internal for test seam access */
    _normalizeQueuedIntentEntry(rawEntry: RawValue): StrandQueuedIntent[];
    /** @internal for test seam access */
    _resolveQueuedIntentIdentity(candidate: RawBag): {
        patch: Patch;
        intentId: string;
        enqueuedAt: string;
    } | null;
    /** @internal for test seam access */
    _normalizeQueuedIntents(value: RawValue): StrandQueuedIntent[];
    /** @internal for test seam access */
    _normalizeRejectedCounterfactuals(value: RawValue): StrandRejectedCounterfactual[];
}
export {};
