/** * What a quick capture has actually achieved, derived from facts. * * A capture moves through six stages, and every one of them is READ rather than * written down: the shaping session exists and has spoken, a Todo carries that * session as its creator, a Dispatcher is linked to that Todo, a workflow run or * a delegated employee is linked to it. Nothing here consults a stored stage * string, and that is the point — a written stage drifts from what happened, and * cannot survive a gateway restart or a browser reload. A derived one is right * by construction, recovers on reload for free, and makes the honesty contract * fall out of the shape: if the fact is absent the stage is not claimed, so the * UI can never show progress the system has not made. * * The module is deliberately HTTP-free and takes a plain facts record. The rules * are the part worth testing, and they are testable here without a gateway. */ /** Ordered. A capture moves forward through the first five, and then settles on * exactly one of three terminals: `routed` (its own Todo is moving), `landed` * (it restated a Todo that already existed) or `failed`. */ export declare const TODO_CAPTURE_STAGES: readonly ["starting", "shaping", "created", "dispatching", "routed", "landed", "failed"]; export type TodoCaptureStage = (typeof TODO_CAPTURE_STAGES)[number]; export interface TodoCaptureSessionFact { id: string; status: "idle" | "running" | "error" | "waiting" | "interrupted"; /** True once the engine has produced anything at all for this session. */ spoke: boolean; attemptOutcome?: "succeeded" | "failed" | "interrupted" | null; lastError?: string | null; } export interface TodoCaptureLinkedSessionFact { id: string; employee: string | null; workflowId?: string | null; workflowName?: string | null; workflowRunId?: string | null; } export interface TodoCaptureTodoFact { id: string; title: string; /** Sessions linked to this Todo, in link order. */ linked: TodoCaptureLinkedSessionFact[]; } export interface TodoCaptureFacts { captureId: string; /** The shaping session, or null once it is gone. */ session: TodoCaptureSessionFact | null; /** Todos whose creator is the shaping session, oldest first. */ todos: TodoCaptureTodoFact[]; /** The Todo this capture recorded itself as landing ON — a Todo that already * existed and already covered it. Read from the shaping session's own * work-item link, which `land_on_work_item` is the only thing that writes. * Null when the capture never claimed to restate anything. */ landedWorkItem: { id: string; title: string; } | null; /** The employee name the Dispatcher runs as, so a linked Dispatcher is not * mistaken for the delegate it goes on to choose. */ dispatcherEmployee: string; /** The Shaper's own employee name, for the same reason. */ shaperEmployee: string; } export type TodoCaptureRoute = { kind: "workflow"; workflowId: string; workflowName: string | null; runId: string | null; } | { kind: "employee"; employee: string; sessionId: string; }; export interface TodoCaptureState { captureId: string; sessionId: string | null; stage: TodoCaptureStage; /** On `landed` this is the Todo the capture landed on, not one it created — * which is the point: the operator is being shown where their sentence went, * and that is the same question either way. */ workItemId: string | null; workItemTitle: string | null; routedTo: TodoCaptureRoute | null; /** A capture is one Todo. Extras are surfaced rather than hidden, because a * Shaper that minted a board full of items from one sentence is a fact the * operator needs, not one the pipeline should quietly drop. */ extraWorkItemIds: string[]; /** Set only on `failed`, and always the real reason. */ error: string | null; /** Why an in-flight capture is parked rather than working — the rate limiter's * own sentence while the Shaper's session is `waiting`. Never a failure: the * gateway retries on its own, so the stage is still true and this only stops * a deliberate sleep from reading as a hang. Null on every other status. */ waitingReason: string | null; } export declare function deriveTodoCaptureState(facts: TodoCaptureFacts): TodoCaptureState; //# sourceMappingURL=todo-capture-stage.d.ts.map