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:
@@ -55,12 +55,13 @@ export interface GraphCostSummary {
|
||||
totalDollars: number;
|
||||
/** Runs where EVERY stage was unpriced (totalDollars excludes them). */
|
||||
unpricedRuns: number;
|
||||
/** The billable pipeline stages (wave 6: the embedder became one —
|
||||
* provider embeddings cost money; merger is the only free stage). */
|
||||
/** The billable pipeline stages. (Wave 7, owner ruling 2026-09-23:
|
||||
* back to three — the embedding stage is gone with the provider
|
||||
* embedder; historical records' stages.embedding spend is simply not
|
||||
* displayed.) */
|
||||
stages: {
|
||||
extraction: StageCost;
|
||||
audit: StageCost;
|
||||
embedding: StageCost;
|
||||
naming: StageCost;
|
||||
};
|
||||
/** Newest first, capped at `recentCap` (default 10). */
|
||||
@@ -115,7 +116,6 @@ function mergeTokens(into: CallUsage, steps: readonly CallUsage[]): void {
|
||||
export function graphCostSummary(input: CostSummaryInput): GraphCostSummary {
|
||||
const extraction = emptyStage();
|
||||
const audit = emptyStage();
|
||||
const embedding = emptyStage();
|
||||
const naming = emptyStage();
|
||||
const runs: RecentRun[] = [];
|
||||
|
||||
@@ -134,25 +134,12 @@ export function graphCostSummary(input: CostSummaryInput): GraphCostSummary {
|
||||
if (audDollars === null) audit.unpricedRuns++;
|
||||
else audit.dollars += audDollars;
|
||||
|
||||
// Wave 6: the embedding tail — present only when an embedding model
|
||||
// ran (absent stage = the run embedded nothing, never "free").
|
||||
let embDollars: number | null = null;
|
||||
let embSteps: CallUsage[] = [];
|
||||
if (stages.embedding) {
|
||||
embedding.runs++;
|
||||
embSteps = stages.embedding.steps;
|
||||
mergeTokens(embedding.tokens, embSteps);
|
||||
embDollars = stageDollars(stages.embedding.model, embSteps);
|
||||
if (embDollars === null) embedding.unpricedRuns++;
|
||||
else embedding.dollars += embDollars;
|
||||
}
|
||||
|
||||
// Run-level: null only when EVERY stage is unpriced.
|
||||
const allStages: Array<number | null> = [extDollars, audDollars, embDollars];
|
||||
const allStages: Array<number | null> = [extDollars, audDollars];
|
||||
const runDollars = allStages.every((d) => d === null)
|
||||
? null
|
||||
: allStages.reduce<number>((a, d) => a + (d ?? 0), 0);
|
||||
const allSteps = [...stages.extractor.steps, ...stages.auditor.steps, ...embSteps];
|
||||
const allSteps = [...stages.extractor.steps, ...stages.auditor.steps];
|
||||
runs.push({
|
||||
startedAt: run.startedAt,
|
||||
at: run.at,
|
||||
@@ -195,9 +182,9 @@ export function graphCostSummary(input: CostSummaryInput): GraphCostSummary {
|
||||
// A run is "unpriced" when it billed nothing countable at all.
|
||||
const unpricedRuns = runs.filter((r) => r.dollars === null).length;
|
||||
return {
|
||||
totalDollars: extraction.dollars + audit.dollars + embedding.dollars + naming.dollars,
|
||||
totalDollars: extraction.dollars + audit.dollars + naming.dollars,
|
||||
unpricedRuns,
|
||||
stages: { extraction, audit, embedding, naming },
|
||||
stages: { extraction, audit, naming },
|
||||
runs: capped,
|
||||
};
|
||||
}
|
||||
|
||||
+8
-49
@@ -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>;
|
||||
}
|
||||
|
||||
+1
-26
@@ -2752,30 +2752,6 @@ export const CONTEXT_LIMITS: Record<string, number> = {
|
||||
|
||||
// ─── Pure helpers (folds + cost inference) ───────────────────────────────────
|
||||
|
||||
// ─── Embedding prices (wave 6, 2026-09-23) ─────────────────────────────────
|
||||
|
||||
/** Hand-maintained BYOK embedding prices, USD per 1M INPUT tokens — the
|
||||
* sync script never touches this block (pi-ai's catalogs carry no
|
||||
* embedding models, so the generated PRICES table has none of these).
|
||||
* VERIFIED against provider pricing pages 2026-09-23: OpenAI's model
|
||||
* docs ($0.02 3-small / $0.13 3-large / $0.10 ada-002), Google's pricing
|
||||
* page ($0.15 gemini-embedding-001 / $0.20 Gemini Embedding 2 text),
|
||||
* OpenRouter passes provider pricing through. output: 0 — embeddings
|
||||
* emit no output tokens. Unlisted models stay unpriced ("—", never
|
||||
* zero); tokens still get captured. */
|
||||
export const EMBEDDING_PRICES: Record<string, ModelPrice> = {
|
||||
"openai:text-embedding-3-small": { input: 0.02, output: 0 },
|
||||
"openai:text-embedding-3-large": { input: 0.13, output: 0 },
|
||||
"openai:text-embedding-ada-002": { input: 0.1, output: 0 },
|
||||
"google:gemini-embedding-001": { input: 0.15, output: 0 },
|
||||
"google:gemini-embedding-2": { input: 0.2, output: 0 },
|
||||
"openrouter:openai/text-embedding-3-small": { input: 0.02, output: 0 },
|
||||
"openrouter:openai/text-embedding-3-large": { input: 0.13, output: 0 },
|
||||
"openrouter:openai/text-embedding-ada-002": { input: 0.1, output: 0 },
|
||||
"openrouter:google/gemini-embedding-001": { input: 0.15, output: 0 },
|
||||
};
|
||||
|
||||
|
||||
/** Sum a list of per-step usages into one CallUsage. A field stays
|
||||
* undefined when EVERY step left it unreported — absent is not zero. */
|
||||
export function sumSteps(steps: readonly CallUsage[]): CallUsage {
|
||||
@@ -2797,8 +2773,7 @@ export function callCost(
|
||||
usage: { inputTokens?: number; outputTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number },
|
||||
model: string,
|
||||
): number | null {
|
||||
// Wave 6: the hand-maintained embedding overlay backs the lookup too.
|
||||
const price = PRICES[model] ?? EMBEDDING_PRICES[model];
|
||||
const price = PRICES[model];
|
||||
if (!price) return null;
|
||||
if (usage.inputTokens === undefined || usage.outputTokens === undefined) return null;
|
||||
const cacheRead = usage.cacheReadTokens ?? 0;
|
||||
|
||||
@@ -201,13 +201,10 @@ export function resolveSettings(record: UserSettings | null): EffectiveSettings
|
||||
},
|
||||
},
|
||||
graph: {
|
||||
// Wave 7 collapse (owner ruling 2026-09-23): the master switch ONLY —
|
||||
// the embedding/clustering/labeling rungs and the BYOK embeddingModel
|
||||
// are gone (stale record keys are simply never read here).
|
||||
enabled: graph.enabled ?? FACTORY_SETTINGS.graph.enabled,
|
||||
embedding: graph.embedding ?? FACTORY_SETTINGS.graph.embedding,
|
||||
clustering: graph.clustering ?? FACTORY_SETTINGS.graph.clustering,
|
||||
labeling: graph.labeling ?? FACTORY_SETTINGS.graph.labeling,
|
||||
// BYOK (wave 6): null is the factory floor and a VALID resolved
|
||||
// value — ?? only fills the absent case, null passes through.
|
||||
embeddingModel: graph.embeddingModel ?? FACTORY_SETTINGS.graph.embeddingModel,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -216,23 +213,13 @@ export function resolveSettings(record: UserSettings | null): EffectiveSettings
|
||||
|
||||
/**
|
||||
* The WRITE channel gate (extraction + its auditor): dies with the master
|
||||
* switch. Used by the chat-handler's post-turn trigger; deeper pipeline
|
||||
* consumers (embedder, clustering, labeling — later waves) gate on the
|
||||
* deeper rungs the same way.
|
||||
* switch. Used by the chat-handler's post-turn trigger. (Wave 7: the master
|
||||
* switch is the ONLY graph setting left — the section collapsed.)
|
||||
*/
|
||||
export function extractionEnabled(graph: Required<GraphSettings>): boolean {
|
||||
return graph.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The READ channel gate (graph-context injection): needs the master switch
|
||||
* AND the embedding rung — injection is a vector query, so a graph without
|
||||
* embeddings has nothing to inject.
|
||||
*/
|
||||
export function graphContextEnabled(graph: Required<GraphSettings>): boolean {
|
||||
return graph.enabled && graph.embedding;
|
||||
}
|
||||
|
||||
/**
|
||||
* The PROBER GRAPH TOOLS gate (wave 7, owner ruling 2026-09-23): the
|
||||
* toggle is an agent-capability switch (it gates tool registration), but
|
||||
@@ -246,3 +233,5 @@ export function graphToolsEnabled(effective: {
|
||||
}): boolean {
|
||||
return effective.graph.enabled && (effective.agent.graphTools.enabled ?? true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-31
@@ -249,23 +249,14 @@ export interface AppearanceSettings {
|
||||
* meaningful when its parent is on (the UI grays dependents out; stored
|
||||
* values persist but resolve inert). All default true. */
|
||||
export interface GraphSettings {
|
||||
/** MASTER: off = no extraction, no auditor, no embedding, no
|
||||
* graph-context injection, no clustering. Data stays stored. */
|
||||
/** MASTER (and, since wave 7, ONLY): off = no extraction, no auditor.
|
||||
* The wave-7 collapse (owner ruling 2026-09-23) deleted the three
|
||||
* subordinate rungs — embedding/clustering/labeling — and the BYOK
|
||||
* embeddingModel: clustering is the free birth-session partition
|
||||
* derived on read (core/session-clusters.ts), labels ARE session
|
||||
* names, and the prober graph tools read the ledgers directly — there
|
||||
* is nothing left to configure. Data stays stored either way. */
|
||||
enabled?: boolean;
|
||||
/** Vector embedding + graph-context injection (consumes vectors even
|
||||
* without clustering — hence its own rung). */
|
||||
embedding?: boolean;
|
||||
/** Cluster computation + settle (needs embedding). */
|
||||
clustering?: boolean;
|
||||
/** The LLM cluster-namer (needs clustering). */
|
||||
labeling?: boolean;
|
||||
/** BYOK embeddings (wave 6, 2026-09-23): the provider embedding model
|
||||
* as a "provider:id" slug (openrouter:…, openai:…, google:…). null =
|
||||
* no model — embedding/clustering/injection skip honestly (info log,
|
||||
* graph stays textual); no factory floor exists. Keys live in the auth
|
||||
* store, resolved fresh per call. A model CHANGE re-embeds everything
|
||||
* (the ledger's staleness semantics). */
|
||||
embeddingModel?: string | null;
|
||||
}
|
||||
|
||||
/** THE record. Every section optional (delta); unknown top-level keys are
|
||||
@@ -318,7 +309,7 @@ export const FACTORY_SETTINGS: FactorySettings = {
|
||||
sessionNameSerif: true,
|
||||
mdRendering: { headingWeight: 900, boldColor: null, italicColor: null },
|
||||
},
|
||||
graph: { enabled: true, embedding: true, clustering: true, labeling: true, embeddingModel: null },
|
||||
graph: { enabled: true },
|
||||
};
|
||||
|
||||
// ─── Sanitizer ─────────────────────────────────────────────────────────────
|
||||
@@ -467,23 +458,15 @@ function sanitizeAppearance(raw: Record<string, unknown>): AppearanceSettings {
|
||||
}
|
||||
|
||||
function sanitizeGraph(raw: Record<string, unknown>): GraphSettings {
|
||||
// Wave 7 collapse (owner ruling 2026-09-23): the section is the master
|
||||
// switch ONLY. The dead rungs' keys (embedding/clustering/labeling/
|
||||
// embeddingModel) in existing records are simply UNREAD and DROPPED by
|
||||
// this reconstruction — the migration story: the next graph-section
|
||||
// write (PUT is replace-whole) persists the collapsed shape, and no
|
||||
// active code ever looks at the stale fields.
|
||||
const out: GraphSettings = {};
|
||||
const enabled = boolOrDrop(raw.enabled);
|
||||
if (enabled !== undefined) out.enabled = enabled;
|
||||
const embedding = boolOrDrop(raw.embedding);
|
||||
if (embedding !== undefined) out.embedding = embedding;
|
||||
const clustering = boolOrDrop(raw.clustering);
|
||||
if (clustering !== undefined) out.clustering = clustering;
|
||||
const labeling = boolOrDrop(raw.labeling);
|
||||
if (labeling !== undefined) out.labeling = labeling;
|
||||
// BYOK embeddings (wave 6): null or a provider-qualified slug; anything
|
||||
// else (bad type, bad shape) DROPS to absent — an invalid write never
|
||||
// becomes a live model (the PUT parser 400s it first; this is the
|
||||
// read-side belt-and-suspenders for hand-edited files).
|
||||
if (raw.embeddingModel === null) out.embeddingModel = null;
|
||||
else if (typeof raw.embeddingModel === "string" && /^\S+:\S+$/.test(raw.embeddingModel)) {
|
||||
out.embeddingModel = raw.embeddingModel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user