Wave 7 chunk B: remove the embeddings machinery — the ladder collapses

The owner's wave-7 ruling: embeddings die entirely (git history is the
stash); clustering is birth-session derived (chunk A, 950ddfd), labels
are session names, and the prober's graph tools replace injection.

- settings: GraphSettings collapses to { enabled } — embedding,
  embeddingModel, clustering, labeling all die. Migration story: stale
  record keys are UNREAD and dropped by the sanitizer's reconstruction;
  the next graph-section PUT (replace-whole) persists the collapsed
  shape. The settings-panel GraphSection renders one master row.
- deleted: src/server/embeddings.ts (adapters, resolveEmbeddingPortFor,
  embedNewNodes, embeddingPort, embeddingModelCatalog), the
  GET /api/models/embeddings route, scripts/embed-graph.ts, tests for
  all three, and the /api/models/embeddings picker surfaces in the UI.
- prices: EMBEDDING_PRICES overlay + callCost fallback die. cost-summary:
  the embedding stage fold dies — back to three stages (extraction/
  audit/naming) per the owner ruling; historical stages.embedding spend
  in old run records is simply not displayed.
- ports: EmbeddingPort/EmbeddingResult/EmbeddingTask die. The embeddings
  LEDGER surface (readEmbeddings/writeEmbeddings + EmbeddingsLedger +
  EMBEDDINGS_FILE + graph-deletion's vector pruning) STAYS — inert data,
  kept only so graph-context.ts compiles until Teacher's pass removes
  it; the seam dies in the follow-up interlude.
- chat-handler (approved cross-lane unwiring, wave-6 precedent): the
  extraction pipeline's embedder becomes a documented no-op (nothing
  embedded, nothing spent, ledger untouched) until Teacher's pass
  removes the phase; the graph-context injection dispatch gate, the
  graphContext deps wiring, the setContextRespawn seam, and
  turn-service's triggerGraphContext are gone — injection is dead
  code pending Teacher's file deletions.
- scripts: backfill-graph/import-notes pass the same no-op embedder;
  replay-layout derives clusters from birthSessionPartition (the same
  partition the real settle uses) instead of the embeddings ledger.
- settings-body: parseGraphSettingsBody reads the master switch only —
  old-shape keys in a body are ignored, not rejected; bad shapes 400.
- next.config: the @huggingface tracing-exclusion guards die with the
  last reference.

Cross-lane flags: extraction.ts/graph-context.ts keep stale embed
comments + the embed phase until Teacher's full pass (their parallel
interlude owns those files — zero overlap kept by design);
semantic-clusters.ts + its test stay one more round (extraction.test.ts,
Teacher's file, still imports it — they delete it with the namer cases);
ChatSettings.graphContextTokens + the graph-context-control UI stay
until Teacher+UI.

Gates: tsc clean, eslint clean, 885/885 tests, build compiles.
Live-verified on the port-3004 dev tree: PUT /api/settings/graph with
dead keys collapses on write, bad shapes 400, GET reads {enabled: true},
/api/models/embeddings 404s.
This commit is contained in:
amosblomqvist
2026-09-23 15:02:55 +03:00
parent 0fcffdffaf
commit c86430e8bf
26 changed files with 120 additions and 1823 deletions
+8 -49
View File
@@ -128,11 +128,15 @@ export interface GraphStore {
/** Replace the whole ledger (the settle is a full-graph computation). */
writePositions(positions: Record<string, Position>): void;
/** The embedding ledger (config.EMBEDDINGS_FILE). WRITTEN ONLY by
* the embedder (server/embeddings.ts) after a merge — read-only for
* clustering consumers (snapshot, settle, namer). */
/** The embeddings ledger (config.EMBEDDINGS_FILE) — INERT DATA since
* wave 7 (owner ruling 2026-09-23: the provider embedder is dead;
* clustering is birth-session, labels are session names). Kept ONLY
* because the graph-context injection (agent band, Teacher's pass
* removes it) still reads it for vector-space staleness — the seam
* dies with it in the follow-up interlude. graph-deletion keeps
* pruning dead vectors meanwhile (harmless housekeeping). */
readEmbeddings(): EmbeddingsLedger;
/** Replace the whole ledger (embedding is a full-batch computation). */
/** Replace the whole ledger (graph-deletion's vector pruning only). */
writeEmbeddings(ledger: EmbeddingsLedger): void;
/** THE DESTRUCTIVE SEAM (session-deletion wave 6, owner 2026-09-22 —
@@ -244,48 +248,3 @@ export interface AuthStore {
deleteAuthVar(name: string): void;
}
// ─── EmbeddingPort — BYOK provider embeddings (wave 6, 2026-09-23) ───────────
/**
* The provider-embedding seam (the local transformers embedder died with
* this wave): vectors come from the user's keyed provider — OpenRouter,
* OpenAI, or Google — named by graph.embeddingModel ("provider:id", null =
* honestly off: embedding/clustering/injection skip with an info log).
*
* Owner decisions (2026-09-23) baked in:
* - The adapters are resolved FRESH per call from the setting + the auth
* store (key rotations land immediately — the search port's treatment).
* - Vectors are stored as the provider returns them (default dims, no
* truncation, no normalization); the ledger is self-describing on
* model + dim, and any model change voids it (full re-embed).
* - Usage (prompt tokens) flows back to the money channel: adapters
* report it, the caller records it as a CallUsage step.
*
* Pure types only (browser-safe): the adapters are server-side
* (src/server/embeddings.ts) and arrive as injected dependencies.
*/
/** Which side of retrieval the text is — providers bill identically but
* quality-optimize differently (OpenRouter's input_type, Gemini's
* taskType); every input in one call shares the task. */
export type EmbeddingTask = "document" | "query";
/** One embedding batch's result: vectors in input order, the model's
* identity + dim (the ledger stamps), and the provider-reported prompt
* token count (undefined = provider didn't report; cost stays honest
* "—" via the existing unpriced path). */
export interface EmbeddingResult {
vectors: number[][];
/** The full "provider:id" slug — ledger/cost keys use it verbatim. */
model: string;
dim: number;
promptTokens?: number;
}
/** A live provider embedding adapter. `embed` throws on failure (adapters
* map HTTP errors to clear Error messages); callers treat failure as
* non-fatal per the extraction contract. */
export interface EmbeddingPort {
model: string;
embed(texts: readonly string[], task: EmbeddingTask): Promise<EmbeddingResult>;
}