feat: extraction coverage — message-granular ledger + token-batched runs (d132373 vision)
THE MESSAGE IS THE UNIT OF COVERAGE (vision-extraction-coverage.md): a per-chat append-only ledger (coverage.jsonl) records which messages the pipeline has extracted, by content fingerprint over exactly what the extraction view sees (one shared line builder — core/coverage.ts); the uncovered remainder is DERIVED at read time, never dual-tracked. A quiz answer merging into the asking message re-opens only that message; plan-block data-part attach never re-opens anything. - The trigger (turn-service) replaces every-3-quiz-answers with uncovered-tokens >= EXTRACTION.chunkTokens (4096) — quiz-less sessions extract too, content size is the honest signal. - runExtraction is now chunked: token-budgeted batches of the oldest uncovered consecutive messages (a tool call + result never split), each merged batch checkpointing its messages' coverage atomically — an abort or error loses at most the in-flight batch; merged batches stay covered. - Observation refs are batch-tagged (obs:<batchTag>:<sourceId>): re-runs of the same batch dedupe; a re-opened message's fresh understanding lands as a new event. Fixes the old obs:p1 position-collision. - New API: GET /api/graph/coverage (exact per-session derived coverage + running flags, most-uncovered first) and POST /api/graph/coverage/extract (manual run for one session, 409 while in flight). - Graph view chrome: the coverage button opens a panel with every session's covered/uncovered tokens and a per-session Extract button — the manual answer to aborted runs, errors, and dormant tails. Renders even when the graph is empty: an empty graph with uncovered sessions is exactly when it matters. Polls only while open. - Notes imports keep the whole-file checkpoint path (coverage undefined). - Tests: pure-core coverage suite (11), chunked-pipeline suite (3: multi-batch + no-op, abort-keeps-earlier-batches + remainder re-run, re-open alone + data-part invisibility), panel render suite (5); pendingQuizAnswers and its tests deleted as dead code. 486/486. Live-smoked on real GLM: manual extract of "teach me modal realism" ran one batch, wrote 4 coverage entries, panel flipped to "1.3k covered · complete" with the button disabled, graph refetched (nodes 11), usage persisted with real stats.
This commit is contained in:
@@ -62,7 +62,16 @@ export type ModelRole = keyof typeof MODELS;
|
||||
* (server/turn-service.ts) so it can be swapped without touching the
|
||||
* pipeline.
|
||||
*/
|
||||
export const EXTRACTION = { everyNQuizAnswers: 3 } as const;
|
||||
/**
|
||||
* The extraction trigger (vision-extraction-coverage.md, 2026-09-15): a run
|
||||
* fires when a chat's UNCOVERED transcript tokens reach the chunk budget.
|
||||
* Runs are token-budgeted batches of the oldest uncovered messages — this
|
||||
* knob is the transcript share of the extractor's context (it also carries
|
||||
* the whole graph + instructions), so it bounds both cost and chunk size.
|
||||
* Replaces the old every-3-quiz-answers trigger, which never fired for
|
||||
* quiz-less sessions.
|
||||
*/
|
||||
export const EXTRACTION = { chunkTokens: 4096 } as const;
|
||||
|
||||
/**
|
||||
* The LIVE graph store (src/store/graph.ts) — owned by the app's extraction
|
||||
@@ -74,6 +83,10 @@ export const LEDGER_FILES = {
|
||||
events: path.join(PATHS.graph, "events.jsonl"),
|
||||
mappings: path.join(PATHS.graph, "mappings.jsonl"),
|
||||
sessions: path.join(PATHS.graph, "sessions.jsonl"),
|
||||
/** Per-message extraction coverage (contracts/graph.ts CoverageEntry;
|
||||
* the checkpoint's replacement for chat extractions — notes keep
|
||||
* sessions.jsonl, whole-file as they are). */
|
||||
coverage: path.join(PATHS.graph, "coverage.jsonl"),
|
||||
/** LLM-named community records (contracts/graph.ts ClusterLabeling). */
|
||||
clusterLabels: path.join(PATHS.graph, "cluster-labels.jsonl"),
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user