Wave 7 close-out: the embedding ledger seam dies; notes birth via mapping lines
Part 1 — the ledger + remnants interlude (master-dispatched, owner ruling 2026-09-23: nothing configures the graph beyond chat models): - The embedding ledger surface is gone: readEmbeddings/writeEmbeddings ports, the EmbeddingsLedger contract, EMBEDDINGS_FILE (config, store impls, graphRevision source list), and graph-deletion's vector-pruning step. On-disk data files stay untouched (inert history). - The extraction embedder seam dies wholesale: ExtractionPipelineDeps drops the embedder dep (chat-handler + backfill/import-notes stubs go with it), the 'embedding' phase leaves ExtractionPhase, the usage capture/persist helpers die, and stages.embedding leaves ExtractionRunUsage (historical records keep their shape — reads are lenient). Extraction is two stages again, like the local-embedder era. - Consumer-less remnants: latestQuizOutcomes + QUIZ_EVENT_KINDS, clusterContentId, matchClusterLabelings + Community + ClusterLabeling, the readClusterLabels/appendClusterLabel port seams + store impls + LEDGER_FILES.clusterLabels. NamingRunUsage/readNamingRuns STAY (standing ruling — the cost pill renders historical naming spend); clusterHue + MIN_CLUSTER_SIZE stay (live). - The 'labeler' role dies: BACKGROUND_MODEL_ROLES, ROLE_SLOT, ModelRole, the catalog pin projections, and the UI roster strings. RolePins keys shrink with the union. The notes birth fallback (owner-approved 2026-09-23, surfaced by the interlude's live smoke: production notes imports create provenance-EMPTY nodes (importNotes passes messages: null — the file's anchor is the mapping line), so the provenance-only birth rule left every imported file unclustered and invisible to the prober's session list, against the locked file-birth ruling. A provenance-empty node now births under its FIRST mapping line's chatId (ledger order); only notes-born nodes ever hit the fallback (chat nodes always carry provenance; a re-encountered node's link-append re-opens the provenance rule). Deletion-safe: mapping lines of deleted chats are stripped alongside their provenance. Live-verified on port 3004: a fresh notes import clusters under its src_ id with the file path as the label, end to end with no embedder. 845/845 tests, typecheck/lint/build green. EOF )
This commit is contained in:
@@ -21,14 +21,24 @@
|
||||
*
|
||||
* Notes imports are birth-sessions too (owner ruling 2026-09-23): their
|
||||
* nodes carry a "src_…" source id instead of a chat id; the caller labels
|
||||
* them with the file's path (kind: file in the session views).
|
||||
* them with the file's path (kind: file in the session views). The
|
||||
* mapping-line fallback (owner-approved 2026-09-23, surfaced by the
|
||||
* interlude's live smoke): production notes imports create provenance-
|
||||
* EMPTY nodes (the notes front door passes messages: null — the file's
|
||||
* anchor is the mapping line), so a provenance-empty node's birth session
|
||||
* is its FIRST mapping line's chatId in ledger order. Only notes-born
|
||||
* nodes ever hit the fallback — chat extraction always writes provenance
|
||||
* points, and a re-encountered node's link-append adds one, which
|
||||
* re-opens the provenance rule above. Deletion-safe: a deleted chat's
|
||||
* mapping lines are stripped alongside its provenance; notes mappings
|
||||
* survive because files are never deleted.
|
||||
*
|
||||
* Browser-safe pure logic (no node builtins, no fs): same contract style
|
||||
* as the rest of the core graph derivation. Not re-exported through the
|
||||
* core barrel — the shell reads clusters from the snapshot; only the
|
||||
* server-side derivations (snapshot, settle) and tests import this.
|
||||
*/
|
||||
import type { GraphNode } from "./contracts.ts";
|
||||
import type { GraphNode, NodeMapping } from "./contracts.ts";
|
||||
|
||||
/** One birth-session cluster: the session id + the SORTED member node
|
||||
* ids born in it. The shape is deliberately the { members } contract
|
||||
@@ -41,11 +51,23 @@ export interface BirthSessionCluster {
|
||||
members: string[];
|
||||
}
|
||||
|
||||
/** A node's birth session: its first surviving provenance point's chatId,
|
||||
* or null when the node carries no provenance at all (unclustered). */
|
||||
export function birthSessionOf(node: GraphNode): string | null {
|
||||
/** A node's birth session: its first surviving provenance point's chatId;
|
||||
* for a provenance-empty node, its first mapping line's chatId (the notes
|
||||
* fallback — see the module doc). null when neither exists. */
|
||||
export function birthSessionOf(node: GraphNode, mappingFallback?: ReadonlyMap<string, string>): string | null {
|
||||
const first = node.provenance[0];
|
||||
return first === undefined ? null : first.chatId;
|
||||
if (first !== undefined) return first.chatId;
|
||||
return mappingFallback?.get(node.id) ?? null;
|
||||
}
|
||||
|
||||
/** The notes fallback index: nodeId → the chatId of the node's FIRST
|
||||
* mapping line in ledger order. */
|
||||
export function birthMappingIndex(mappings: readonly NodeMapping[]): Map<string, string> {
|
||||
const index = new Map<string, string>();
|
||||
for (const mapping of mappings) {
|
||||
if (!index.has(mapping.graphNodeId)) index.set(mapping.graphNodeId, mapping.chatId);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,15 +75,20 @@ export function birthSessionOf(node: GraphNode): string | null {
|
||||
* (first line defines — the getGraph rule), groups by birth session, and
|
||||
* returns the groups size-desc with members sorted (deterministic output:
|
||||
* ties break by session id ascending). Nodes with no surviving provenance
|
||||
* are left unclustered — they belong to no session the graph can name.
|
||||
* fall back to their first mapping line (notes-born); a node with neither
|
||||
* is left unclustered — it belongs to no session the graph can name.
|
||||
*/
|
||||
export function birthSessionPartition(nodes: readonly GraphNode[]): BirthSessionCluster[] {
|
||||
export function birthSessionPartition(
|
||||
nodes: readonly GraphNode[],
|
||||
mappings: readonly NodeMapping[] = [],
|
||||
): BirthSessionCluster[] {
|
||||
const mappingFallback = birthMappingIndex(mappings);
|
||||
const members = new Map<string, string[]>();
|
||||
const seen = new Set<string>();
|
||||
for (const node of nodes) {
|
||||
if (seen.has(node.id)) continue;
|
||||
seen.add(node.id);
|
||||
const birth = birthSessionOf(node);
|
||||
const birth = birthSessionOf(node, mappingFallback);
|
||||
if (birth === null) continue;
|
||||
const bucket = members.get(birth);
|
||||
if (bucket) bucket.push(node.id);
|
||||
|
||||
Reference in New Issue
Block a user