/** * The document ↔ run binding as a direct read (wave 6, F-4R2-006 root fix). * * Every interactive seam (draft / edit / chat / demo) answers a document event with ONE governed * run and records that launch in its durable handoff ledger under a key that STARTS with the * document id — `` (draft, the demo's doc-created row), `:v` (edit / demo * handoffs), `:m:` / `:e:` (chat asks). The `:` separator cannot appear * inside a doc name (interactive's DOC_NAME grammar is `^[a-z0-9][a-z0-9-]{0,63}$`), so the prefix * before the first `:` IS the document id — the same fact `InteractiveHandoffLedger.removeDoc` * already relies on for its prefix sweep. * * The studio used to recover the binding by parsing the run's `extra_write_roots` path (the seam's * inbox is `/`), a client-side heuristic over a daemon-internal layout. This index * reads the ledgers — the system of record for "this handoff was answered by this run" — and the * run DTO carries `document_id` (`GET /runs`, `GET /runs/:id`) while `GET /runs?doc=` filters * on it. The sources are the SAME four the doc-delete sweep uses (`server.ts` `dropDocLedgerRows`): * an armed seam's live ledger instance first, its file otherwise, read AT LOOKUP TIME under a short * TTL so a seam that arms later, or a launch that just landed, is seen without a restart. */ import { InteractiveHandoffLedger } from './ledger.js'; /** One seam's ledger — the live instance when the seam is armed, else its file. */ export interface DocRunSource { /** `draft` | `edit` | `chat` | `demo` — names a read failure. */ name: string; ledger?: InteractiveHandoffLedger | undefined; path: string; } /** The document id a handoff-ledger key names (see the module doc). */ export declare function documentIdOfKey(key: string): string; /** * The kind a ledger row names (#785): two seams keep their rows in the EDIT seam's ledger on purpose * (no new state-home entry) — theme learning (`:theme:`, EP-C4) and reviews * (`:review::v:`, EP-C2) — so the key's shape decides, not the file: * a document that was only reviewed must not read as structurally edited. Any other key is the * seam's own kind. */ export declare function kindOfKey(seam: string, key: string): string; /** Default freshness of one ledger read; the ledgers are small JSON files. */ export declare const DOC_RUN_INDEX_TTL_MS = 2000; export declare class DocRunIndex { private readonly sources; private readonly ttlMs; private readonly now; private readonly log; /** Live stamps from seams launching in THIS process — merged over every read. */ private readonly live; private cache; constructor(sources: () => DocRunSource[], opts?: { ttlMs?: number; now?: () => number; log?: (msg: string) => void; }); /** Record a launch the moment a seam makes it (the ledger write lands beside it). */ set(runId: string, documentId: string): void; private refresh; /** The document this run answered, or `undefined` for a run no interactive seam launched. */ documentOf(runId: string): string | undefined; /** Every run launched for this document (ledger order; `[]` when none). */ runsOf(documentId: string): string[]; /** The kinds that answered this document (`draft` | `edit` | `chat` | `demo` | `theme` | `review`, * first-seen order; `[]` when none; {@link kindOfKey}) — the `kinds` a daemon-wide docs listing shows. */ kindsOf(documentId: string): string[]; } //# sourceMappingURL=doc-run-index.d.ts.map