import type { PatchBuilder } from '../PatchBuilder.ts';
import type Patch from '../../types/Patch.ts';
import type { StrandDescriptor, StrandIntentQueue, StrandQueuedIntent, StrandRejectedCounterfactual, StrandTickRecord } from './strandTypes.ts';
type StrandCommittedTickSummary = {
    overlayHeadPatchSha: string | null;
    overlayPatchCount: number;
    overlayPatchShas: string[];
    maxLamport: number;
};
type StrandAdmittedIntent = StrandQueuedIntent & {
    footprint: Set<string>;
};
type WarpRuntime = {
    _patchInProgress: boolean;
    _maxObservedLamport: number;
    _stateDirty: boolean;
    _cachedViewHash: string | null;
    _cachedCeiling: number | null;
    _cachedFrontier: Map<string, string> | null;
};
type ServiceOptions = {
    graph: WarpRuntime;
    loadStrandOrThrow: (strandId: string) => Promise<StrandDescriptor>;
    buildQueuedIntent: (descriptor: StrandDescriptor, build: (p: PatchBuilder) => void | Promise<void>) => Promise<StrandQueuedIntent>;
    writeDescriptor: (descriptor: StrandDescriptor) => Promise<void>;
    commitQueuedPatch: (params: {
        strandId: string;
        overlayId: string;
        parentSha: string | null;
        patch: Patch;
        contentBlobOids: string[];
        lamport: number;
    }) => Promise<{
        sha: string;
        patch: Patch;
    }>;
    collectPatchEntries: (descriptor: StrandDescriptor, options: {
        ceiling: number | null;
    }) => Promise<Array<{
        patch: Patch;
        sha: string;
    }>>;
    buildTickId: (strandId: string, sequence: number) => string;
};
export default class StrandIntentService {
    private readonly _graph;
    private readonly _loadStrandOrThrow;
    private readonly _buildQueuedIntent;
    private readonly _writeDescriptor;
    private readonly _commitQueuedPatch;
    private readonly _collectPatchEntries;
    private readonly _buildTickId;
    private readonly _counterfactualReason;
    /**
     * Create an intent/tick boundary over strand queueing, classification, and drain persistence.
     */
    constructor({ graph, loadStrandOrThrow, buildQueuedIntent, writeDescriptor, commitQueuedPatch, collectPatchEntries, buildTickId, }: ServiceOptions);
    /**
     * Enqueue a new intent onto the strand's intent queue for deferred tick processing.
     */
    queueIntent(strandId: string, build: (p: PatchBuilder) => void | Promise<void>): Promise<StrandQueuedIntent>;
    /**
     * Return all queued intents for a strand as frozen snapshots.
     */
    listIntents(strandId: string): Promise<ReadonlyArray<StrandQueuedIntent>>;
    /**
     * Drain the intent queue, classify and commit admitted intents, and record the tick.
     */
    tick(strandId: string): Promise<StrandTickRecord>;
    /**
     * Partition queued intents into admitted and rejected sets based on footprint overlap.
     */
    classifyQueuedIntents(queuedIntents: StrandQueuedIntent[]): {
        admitted: StrandAdmittedIntent[];
        rejected: StrandRejectedCounterfactual[];
    };
    /**
     * Sequentially commit all admitted intents to the overlay patch chain.
     */
    commitAdmittedQueuedIntents(descriptor: StrandDescriptor, admitted: StrandAdmittedIntent[]): Promise<StrandCommittedTickSummary>;
    /**
     * Persist the tick result by updating the descriptor and graph-side cache flags.
     */
    persistTickResult({ descriptor, intentQueue, tickIndex, now, committed, tickRecord, }: {
        descriptor: StrandDescriptor;
        intentQueue: StrandIntentQueue;
        tickIndex: number;
        now: string;
        committed: StrandCommittedTickSummary;
        tickRecord: StrandTickRecord;
    }): Promise<void>;
    private _assertNotReentrant;
    private _storeQueuedIntent;
    private _freezeQueuedIntentSnapshots;
    private _loadTickContext;
    private _buildRejectedCounterfactual;
    private _findIntentConflicts;
    private _loadCurrentLamport;
    private _buildTickRecord;
    private _buildPersistedTickDescriptor;
    private _updateTickCaches;
}
export {};
