Birth-session clustering + the prober graph-tools data seam (wave 7 chunk A)

Embeddings are dying (chunk B removes the machinery); the clusters they
used to carry become the session that created them — derived on read.

- New src/core/session-clusters.ts: birthSessionPartition groups merged
  nodes by their FIRST SURVIVING provenance point's chatId (owner-locked
  2026-09-23). Deletion is self-healing by construction: stripped-birth
  survivors re-attribute to their earliest remaining contributor, and
  empty-provenance nodes stay unclustered. Notes imports are birth-sessions
  too (owner ruling) — their label is the file path.
- graphSnapshot: clusters = the birth partition filtered >= MIN_CLUSTER_SIZE
  (the hull presentation rule), id = session id, label = session name (chat
  title / file path; a deleted record renders unlabeled). The persisted
  cluster-labelings join dies; no LLM naming pass needed anymore.
- settleGraphLayout derives the same partition from readNodes — drops its
  readEmbeddings dep. One cluster concept everywhere.
- Prober data seam (core/graph.ts, pure ports-driven like the snapshot):
  graphSessionIndex (every birth session: id, name, chat|file kind,
  createdAt/updatedAt, birth-proposition count, recency-ordered) and
  graphSessionPropositions (a session's birth propositions with the
  extractor's latest understanding level and THAT event's own timestamp —
  owner ruling: quiz outcomes are ledger evidence, they never move the
  evaluation date). Teacher's tool handlers consume these in-process.
- New agent.graphTools subsection { enabled?: boolean } (owner ruling:
  the toggle gates prober tool REGISTRATION — agent capability, agent
  section, its own subsection, NOT the tool-toggles map; absent = ON).
  Lenient sanitizer, strict settings-body parser, passthrough resolution,
  and graphToolsEnabled(effective) = graph.enabled && toggle for Teacher's
  registry wiring.

Gates: tsc clean, eslint clean, 923/923 tests, next build compiles.
Live-verified on the worktree dev data: 10 nodes → 2 clusters labeled
with their chat titles; session index + propositions carry levels and
their own timestamps.
This commit is contained in:
amosblomqvist
2026-09-23 14:51:37 +03:00
parent fb66606555
commit 0fcffdffaf
12 changed files with 551 additions and 61 deletions
+18
View File
@@ -81,6 +81,9 @@ export interface EffectiveSettings {
* passthrough delta — engine resolution (pin → auto → unavailable)
* lives in server/search.ts, where keys are visible. */
search: { engine?: SearchEngineId };
/** Prober graph tools (wave 7): passthrough delta as stored —
* absent/undefined enabled = ON; consumers use graphToolsEnabled. */
graphTools: { enabled?: boolean };
};
/** The resolved strong/cheap/vision slots: each tier's concrete model or
* NULL when the tier holds no model (no factory floor — BYOK all the
@@ -178,6 +181,7 @@ export function resolveSettings(record: UserSettings | null): EffectiveSettings
tools: agent.tools ?? {},
prompts: agent.prompts ?? {},
search: agent.search ?? {},
graphTools: agent.graphTools ?? {},
},
models: {
strong: resolveSlot(modelsSection.strong),
@@ -228,3 +232,17 @@ export function extractionEnabled(graph: Required<GraphSettings>): boolean {
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
* the tools only mean anything when the graph itself runs — so the
* effective gate composes the graph master switch AND the toggle.
* Teacher's tool factories consume this at registration time.
*/
export function graphToolsEnabled(effective: {
graph: Required<GraphSettings>;
agent: { graphTools: { enabled?: boolean } };
}): boolean {
return effective.graph.enabled && (effective.agent.graphTools.enabled ?? true);
}