Skip to content

Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841

Closed

Description

@malibio

Overview

The agent cannot resolve a named entity in a message to a node in the graph. Retrieval matches the message against skill descriptions and schema descriptions — both type-level text — and nothing matches against instances. So "Northwind Trading" is just tokens, and a turn that depends on knowing which node that is stalls and asks the user for a node ID.

This is a design issue: it proposes a direction and a first measurement, not an implementation.

Evidence

Measured on gemma-4-e4b-q4km, 3 reps, clean database per rep, via bun run eval:decisions (#2802). Three scenarios failed identically in all three reps — zero variance — and all three are the same failure:

"Add Northwind Trading to the companies we sell to."
  skill=Node Creation      candidates=company_sold_to, event_venue, sponsor, sponsorship_deal
  operation=none  schema=none  tools called: []
  → "Could you confirm what you'd like me to do?"

"Northwind can seat 200 people now."
  skill=Schema Creation    candidates=(same four)
  → "I need a Node ID to update the capacity for Northwind Trading."

"When did we sign Northwind?"
  → "I do not have a specific node ID for Northwind Trading, so I cannot tell
     you the signing date."

Skill routing was correct in each case and four schema candidates were on offer. The model called no tool at all — it could not get from the name to a node, so it deferred.

Note what this is not: it is not a schema-selection failure. The model never reached a choice among the candidates. It failed one layer upstream.

Why this is high-leverage

Resolving one entity name constrains three decisions at once. If the graph contains a node titled "Contoso Ltd" of type company_sold_to:

  • it is an instance request, not a type request → Node Creation, not Schema Creation
  • the schema is determined → no selection needed
  • the operation is a create/update on an existing type → not create_schema
  • the type's field list is known → field_values becomes checkable

Today each of those is decided independently from type-level text. That is why the failures cluster: a single missing lookup leaves three decisions under-determined.

It also explains a recurring shape in the routing measurements — find_skills scores like Schema Creation=0.655, Node Creation=0.640 decide instance-vs-type on a 0.015 cosine margin, when an entity lookup would answer it as a fact.

Prerequisite: FTS5 does not index the column that matters

There is already an FTS5 index over node text, trigger-maintained (packages/core/src/db/schema.rs):

CREATE VIRTUAL TABLE node_fts USING fts5(id UNINDEXED, content, content='node', content_rowid='rowid')

It indexes node.content only — not node.title. All three triggers reference new.content/old.content.

That is the wrong column for exactly the nodes this feature needs to find. For a schema'd node with a titleTemplate, the display identity is computed from properties into the title column (ADR-077; NodeService::compute_title()), while content may be empty or unrelated. So a naive "query FTS5 with the message" approach would find text nodes and notes and silently miss every title-templated instance — the structured entities the agent most often acts on.

Closing this is DDL, not a data migration: add title to the FTS5 table and the three triggers, then reset the database per this repo's pre-release stance. It is a prerequisite for anything below, and worth doing as its own change so the index gap is fixed independently of the routing design.

A harder related case, not solved by indexing title: an entity whose identity lives in property values with no assembled title (e.g. {first_name: "Jane", last_name: "Doe"} and no template) is not searchable as "Jane Doe" in either column.

Proposed direction

Deterministic lookup first, model judgment only for what genuinely remains ambiguous:

1. FTS5 over the message           → deterministic, indexed, no model call
2. Resolved entity → its type      → constrains skill, schema and operation jointly
3. Still ambiguous across types?   → a small typed decision (2-3 candidates)
4. No match at all?                → existing path, unchanged

Why not LLM extraction as the primary mechanism. Asking the model to name the entities costs a generative pass (~1.7-1.9 s measured for Stage-1 alone), and ADR-038 deliberately keeps retrieval out of the model's hands so the system can bound K and enforce the trust boundary. An extraction turn reintroduces exactly that. Worth holding in reserve for cases the index misses, not as step 1.

Why not tokenize-and-match-known-names. That is how the existing schema backstop works (skill_ops::mentions_phrase), and it works there because the needle set is small and known — it iterates schemas and tests each. For instances there is no known needle set; testing every node title against the message is O(graph). FTS5 inverts this correctly: query the index with the message and let it return ranked matches.

Known weaknesses of the FTS5-first approach

  • Bare names with no other signal — "Acme" alone matches but does not disambiguate customer from project. This is the residue that genuinely needs step 3.
  • Noise words — "companies" would match many nodes. Needs a rank cutoff, and probably a proper-noun bias (capitalisation, multi-word runs).
  • Spelling and partial variants — "the Northwind deal" vs stored "Northwind Trading". Token overlap helps; spelling variants are not handled.
  • Genuinely new entities — "Add Contoso Ltd" where Contoso does not exist is a miss, and a miss is currently indistinguishable from a spelling failure. The former should route to a create; the latter should not.

First step: size the problem before designing further

Run FTS5 (with title indexed) over a corpus of real recorded messages offline — no agent changes, no model, no turn cost — and measure:

  • what fraction of messages contain a resolvable entity name at all
  • of those, how many resolve to exactly one node vs several
  • of the several-case, how often the candidates span more than one type (the residue needing step 3)

If most messages carry a resolvable entity, this is high-leverage and worth building properly. If it is a minority, it is a special case and should be scoped as one. That distinction should be settled by measurement before any routing change lands.

#2802's recorded per-turn decisions are the source of real messages for this.

Acceptance criteria

  • FTS5 indexes node.title alongside node.content, with all three triggers updated (DDL change + database reset, no migration)
  • The offline sizing measurement above is run and its numbers recorded on this issue
  • A decision is made and written down: general mechanism vs scoped special case, based on those numbers
  • If it proceeds: entity resolution runs as a deterministic system step before Stage-1 routing, consistent with ADR-038's trust boundary
  • The three failing scenarios in scripts/eval/fixtures/decisions.ts are re-scored as entity-resolution cases rather than schema-selection cases
  • Tests pass (bun run test:all), code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/core/src/db/schema.rs — the FTS5 table and its three triggers (the prerequisite)
  • packages/core/src/ops/skill_ops.rs — find_skills, mentions_phrase (the existing lexical backstop for schema names), SKILL_SEARCH_THRESHOLD
  • packages/core/src/ops/context_ops.rs — build_workspace_context, and the ordering constraint that context is assembled before Stage-2 routing
  • packages/agent/src/local_agent/agent_loop.rs — turn sequencing; where a resolution step would sit
  • packages/core/src/services/node_service/crud.rs — compute_title(), which writes the column FTS5 does not index

Related

Activity

  1. added
    enhancement
    on Sep 22, 2026
  2. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Correction to the prerequisite: index title, and drop the content index rather than extending it

    The issue body proposes adding title to the existing node_fts table. That is the wrong shape, and the current content index looks like it should be removed rather than widened. Two findings, both verified against source.

    1. title IS NOT NULL is already the system's own predicate for "this node is a nameable thing"

    NodeService::compute_title() (packages/core/src/services/node_service/crud.rs:2752) decides this explicitly:

    • date and schema nodes → always None
    • a type with a titleTemplate → the interpolated template
    • task / collection → stripped content
    • everything else → strip_markdown(content) if the node is a root, otherwise None:
    if root { Some(strip_markdown(&node.content)) } else { None }

    So title is non-null exactly for title-templated schema instances, tasks, collections, and root nodes — and null for child/body nodes. That is not a proxy for "entity"; it is the system's maintained answer to the question, and it is the predicate entity resolution wants.

    2. Indexing content is actively wrong for this purpose, not merely incomplete

    A root node's content can be an entire document, and it is indexed as one FTS5 row. Searching "Northwind" over content therefore returns every node whose body mentions Northwind, not the Northwind node — the entity's own identity is buried among every passing reference to it. For title-templated nodes it is worse: title and content are different strings (ADR-077), so a content match can return a node whose identity has nothing to do with the query term.

    An index over title WHERE title IS NOT NULL has the opposite shape: every row is an entity and its text is that entity's name. One short row per nameable node, rather than one long row per node.

    These answer different questions and should not share a table:

    Index Question Consumer
    over content "which nodes discuss X?" full-text search
    over title "which node is X?" entity resolution

    Conflating them degrades both.

    3. The content index has no production consumer

    Its only reader is SqliteStore::bm25_search_roots (packages/core/src/db/sqlite_store/embeddings.rs:628). Grepping packages/core/src, packages/agent/src, packages/daemon/src and packages/cli/src finds no production caller — every call site is in tests (packages/core/tests/embedding_service_test.rs, and one connection-lifecycle test at sqlite_store/mod.rs:2227).

    So today the content index costs: a row per node duplicating the full body text, three triggers on every insert/update/delete, and an integrity/rebuild path (sqlite_store/mod.rs:309-342) — to serve a function nothing in production calls.

    Revised prerequisite

    Replace the content index with a title index, rather than adding a column to it:

    • node_fts over content → removed, along with its three triggers and the bm25_search_roots function and tests, unless a production consumer is identified first
    • a new FTS5 table over title, synced by triggers that skip rows where title IS NULL and delete on a non-null → null transition

    FTS5 has no partial-index syntax, so the null-skipping is trigger logic, not a WHERE clause on the table. Getting that wrong silently reintroduces exactly the noise this change exists to remove — an UPDATE that nulls a title must delete the row, not leave a stale one.

    Per this repo's pre-release stance this is DDL plus a database reset — no migration, no dual-index transition.

    Check before deleting: confirm bm25_search_roots is genuinely dead rather than reachable through a path the grep missed (a trait object, a daemon RPC, the CLI). If it turns out to have a live consumer, the content index stays and the title index is added alongside it — but as a separate table either way, not as a second column.

    Acceptance criteria (replacing the FTS5 line in the issue body)

    • Confirm whether bm25_search_roots has any production consumer; record the answer here
    • A new FTS5 table indexes node.title, with triggers that skip null titles and delete on transition to null
    • The content index, its triggers, and bm25_search_roots are deleted if no consumer exists (DDL change + database reset, no migration)
    • A test pins the null-skipping behaviour: a child node with a null title must not appear in the index, and a node whose title becomes null must be removed from it
  3. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Retraction: bm25_search_roots is NOT dead — the content index stays

    My previous comment claimed the FTS5 content index has no production consumer and proposed deleting it. That is wrong. The gating clause in that comment ("confirm bm25_search_roots is genuinely dead rather than reachable through a path the grep missed") is exactly what it failed, and the answer is that it has a live consumer two hops from the tool surface:

    bm25_search_roots                embeddings.rs:628
      └─ semantic_search             embedding_service.rs:690   (tokio::join! — the BM25 half of hybrid BM25+KNN)
          └─ semantic_search_nodes   embedding_service.rs:905
              ├─ search_ops.rs:632           → backs the search_nodes tool
              └─ context_assembly.rs:319     → agent context assembly
    

    Verified directly: embedding_service.rs:680-700 runs search_embeddings (KNN) and bm25_search_roots concurrently in a tokio::join! and consumes both results. It is a real hybrid retrieval path, not dead code.

    Why my grep missed it: no call site outside tests spells bm25_search_roots — semantic_search is its only caller, and the reachable-from-a-tool path is two hops further on. I grepped for the function name across core/src, agent/src, daemon/src and cli/src, saw only test hits, and concluded it was unreachable. That was the wrong search: a single-caller private-ish function reached through a public wrapper looks identical to dead code under a name grep. The correct check was to follow the caller chain outward, which I did not do.

    packages/core/tests/embedding_service_test.rs pins this tier explicitly (test_hybrid_bm25_only_tier_has_no_knn_score), so deleting the index would have failed tests — but it would also have silently reduced search_nodes to KNN-only, losing exact-keyword recall, which is the more serious consequence.

    What this changes, and what it does not

    Changed: the content index and its triggers stay. This falls back to the alternative my own comment specified: "If it turns out to have a live consumer, the content index stays and the title index is added alongside it — but as a separate table either way, not as a second column."

    Unchanged: everything else in that comment holds, and the fallback was the right shape to have written down.

    • title IS NOT NULL is still the system's own predicate for "this node is a nameable thing" (compute_title(), crud.rs:2752 — confirmed null for non-root child nodes)
    • the two indexes still answer different questions ("which nodes discuss X?" vs "which node is X?") and should not share a table
    • the null-skipping trigger logic is still required, since FTS5 has no partial-index syntax

    A new note worth acting on

    search_ops.rs already has an include_title_matches path, but it is LIKE-based substring matching via title_contains / title_match_nodes (search_ops.rs:382), not FTS5. So a title FTS index is genuine new capability rather than a duplicate — and it raises a design question this issue should settle: should the title FTS index eventually back that path too, replacing the LIKE scan, or do the two coexist? A LIKE substring scan and a tokenised FTS match select different sets (substring vs word-boundary), so consolidating them is a behaviour change, not a pure optimisation.

    Revised acceptance criteria

    Replacing the FTS5 items in the issue body and my previous comment:

    • Confirm whether bm25_search_roots has a production consumer — yes, via semantic_search's hybrid join; the content index stays
    • A new FTS5 table indexes node.title, alongside (not replacing) the content index, with triggers that skip null titles and delete on transition to null
    • A test pins the null-skipping behaviour: a child node with a null title must not appear in the index, and a node whose title becomes null must be removed from it
    • Decide whether the title FTS index should back search_ops.rs's include_title_matches path, or whether the existing LIKE-based title_contains stays — noting the two select different sets
  4. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Sharpening the proposal: pre-resolve and hand over the fact — don't leave it as a tool the model must choose to call

    The issue body says a resolved entity "constrains skill, schema and operation jointly" but never says how. That verb is the load-bearing part and it was left unspecified. Naming it now.

    The resolution should already be done by the time the model sees the turn. The model should not have to decide to call search_nodes, decide what to search for, and then interpret a ranked list. It should be handed the resolved fact.

    This is not a new argument — ADR-064 rule 4 already decided it

    "Where a tool currently returns arguments for the model to feed into a second call, it should perform that call itself and return the outcome."

    And the measurement behind that rule is directly on point:

    "A resolution sub-step returning a resolved node produced a successful write in 100% of trials across three request phrasings; the same step returning query fragments for the model to route produced 0%."

    100% vs 0%, on exactly this shape: resolution delivered as a fact versus as work the model must do.

    The current design contradicts that rule for entity names

    search_nodes is on the offered tool surface — the model could resolve "Northwind" itself. Across 3 reps of the decision eval (#2802) it called no tool at all and asked the user for a node ID instead. So the capability being available is demonstrably not sufficient; the decision to use it is one the model does not reliably make.

    That is three judgments (call it? with what query? which result?) where rule 4 says there should be none.

    A second reason, independent of the doctrine

    search_nodes is lossy as a resolution mechanism. Even when called, it returns a ranked list the model must interpret. Pre-resolution yields a determinate answer — this name, this node, this type — or an honest no-match, which is itself decisive: no match means create, not "search harder." That distinction is invisible in a ranked list that simply came back weak.

    Which channel it arrives on

    Resolution happens before any tool call, so this is not a tool result. ADR-064 rule 4 reserves that channel for facts returned by executed tools; this is closer to the context block — the same channel EXISTING SCHEMAS uses, which already carries per-turn resolved state into the prompt.

    That placement has a known constraint worth stating: the context block is assembled before Stage-2 routing runs (the same ordering that makes EXISTING_SCHEMAS_HEADER's contamination residual hard to fix deterministically). Entity resolution would need to run early enough to feed both the retrieval query and the block.

    Revised proposal shape

    1. FTS5 over the message (title-indexed)          → deterministic, no model call
    2. Resolve name → {node id, type}                  → a fact, not a candidate list
    3a. feed the resolved TYPE into the retrieval query → skill/schema routing sees it
    3b. render the resolved ENTITY into the context block → the model is told, not asked
    4. ambiguous across types?                          → a small typed decision (2-3 candidates)
    5. no match?                                        → existing path; a miss means "create"
    

    Steps 3a and 3b are separable and answer different failures. 3a fixes routing picking the wrong skill on a 0.015 cosine margin. 3b is what fixes today's eval failure — the model asked for a node ID because nothing told it one existed.

    Open question this still leaves

    Whether the resolved type should also act as a hard filter on skill/schema candidates, rather than only as query text and prompt content. That is the strongest version and the most invasive — it changes what ADR-038 calls the trust boundary, since retrieval would no longer be the sole thing bounding the candidate set. Not proposing it; naming it so the choice is explicit rather than defaulted.

    Added acceptance criteria

    • Entity resolution runs before Stage-1 routing and its result reaches both the retrieval query and the context block — the model is never required to call a tool to learn what the message refers to
    • A no-match is represented distinctly from a weak match, so "this entity does not exist" can drive a create path rather than a retry
    • Decide explicitly whether the resolved type hard-filters candidates or only informs them; record the choice and its effect on ADR-038's trust boundary
  5. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Better framing: this completes an existing three-tier pattern, it does not invent one

    Stated plainly, what a turn should hand the model is:

    • here are the most relevant entities (if any)
    • here are the most relevant schemas, and the relationships they have
    • here are the tools/skills you might need

    Two of those three already ship. This issue is the missing tier, not a new mechanism.

    Tier Status Mechanism
    Entities missing —
    Schemas + relationships shipped context_ops::build_workspace_context → relevant_schemas (semantic, capped at MAX_SEMANTIC_SCHEMAS) + related_schemas (related_one_hop_schemas, one hop, bidirectional)
    Skills / tools shipped skill_ops::find_skills → routing::stage2_tools

    Both existing tiers already have the shape this issue wants: bounded retrieval, deterministic, rendered into the prompt as fact — not offered as something the model must decide to go fetch. So the design question is not "what should this look like" but "why is the top tier absent."

    That matters for how the work is scoped: the pattern is proven twice in this codebase, so entity resolution should follow it rather than inventing a parallel mechanism.

    The three tiers are a dependency chain, not parallel lists

    This is the part the issue body under-states. Each tier narrows the next:

    "Add Northwind Trading to the companies we sell to"
    
      entity   Northwind Trading → node abc123, type company_sold_to
                 ↓ (determines)
      schema   company_sold_to — no semantic retrieval needed, it is known
                 ↓ (determines)
      skill    an existing instance of an existing type → Node Creation, not Schema Creation
    

    Today the bottom two run independently of any entity knowledge, which is why they decide instance-vs-type on a 0.015 cosine margin (Schema Creation=0.655, Node Creation=0.640) when an entity lookup would settle it as a fact. The missing top tier is why the other two are guessing.

    "(if any)" carries weight

    A no-match is informative rather than a failure: it means create, not "search harder." That distinction vanishes in a ranked list that merely came back weak, which is one more reason search_nodes is lossy as a resolution mechanism even when the model does call it.

    The one way this tier differs from the other two

    It is unbounded. Skills are ~11 nodes and schemas are capped at 5; a workspace can hold any number of instances. So rank cutoff and precision matter more here than for either existing tier, and a naive "return everything that matches" would flood the context block the other two tiers deliberately keep short.

    That asymmetry is the reason this issue's first step is a measurement (how often does a real message contain a resolvable entity name, and how many nodes does it resolve to?) rather than an implementation. Sizing that answers whether a bounded entity tier is even possible at the precision the pattern needs.

  6. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    bm25_search_roots has a live production consumer — the content index must stay

    Answering the first acceptance criterion from the prerequisite correction above ("confirm bm25_search_roots is genuinely dead rather than reachable through a path the grep missed"). It is not dead. Verified against source on main @ 475b3acc.

    The call chain

    No call site spells bm25_search_roots outside tests, which is why a grep for the name reads as dead. Its single non-test caller is two hops below the tool surface:

    bm25_search_roots                embeddings.rs:628
      └─ semantic_search             embedding_service.rs:690   ← tokio::join!, the BM25 half of hybrid BM25+KNN
          └─ semantic_search_nodes   embedding_service.rs:905
              ├─ search_ops.rs:632            → backs the search_nodes tool
              └─ context_assembly.rs:319      → agent context assembly
    

    grep -rn "\.semantic_search_nodes(" packages/*/src/ returns exactly those two call sites, both under src/, neither in tests.

    So the content index is not serving only tests — it is one half of the hybrid retrieval behind search_nodes. Deleting it would silently degrade search_nodes to KNN-only and drop exact-keyword recall. embedding_service.rs:735 partitions results into KNN∩BM25 / KNN-only / BM25-only tiers, and test_hybrid_bm25_only_tier_has_no_knn_score (embedding_service_test.rs:1510) pins the BM25-only tier specifically — that tier is documented as surfacing keyword matches that carry no semantic relevance, which is exactly what a KNN-only search cannot recover.

    Consequence for the prerequisite

    Per the correction's own fallback clause — "If it turns out to have a live consumer, the content index stays and the title index is added alongside it — but as a separate table either way" — the revised prerequisite becomes:

    • node_fts over content, its three triggers, and bm25_search_roots → retained unchanged
    • a new, separate FTS5 table over title, with triggers that skip null titles and delete on a non-null → null transition

    The rest of the correction's reasoning is unaffected, and the separate-table conclusion is reinforced rather than weakened: the two indexes answer different questions ("which nodes discuss X?" vs "which node is X?") and now demonstrably have different consumers.

    The three-tier framing gives an independent reason not to fold the title tier into semantic_search: that path returns a weak ranked list, which destroys the "(if any)" distinction — a no-match must read as create, not as a low-scoring hit.

    Related: a title-matching path already exists, and it is not FTS5

    search_ops.rs already has an include_title_matches flag (default false) whose keyword half is title_match_nodes (search_ops.rs:382). It is LIKE-based substring matching via NodeQuery::title_contains, issued once per node type, not an index lookup.

    That is worth knowing for two reasons:

    1. A title FTS5 index is genuine new capability, not a duplicate of an existing one.
    2. It is a candidate second consumer. Whether title_match_nodes should eventually be backed by the new index is a separate decision, but it means the title index would not be single-purpose, and the merge_keyword_and_semantic ordering contract (search_ops.rs:302 — a keyword hit always precedes a semantic one) is prior art for the precision concern the unboundedness point raises.

    Confirmed incidentally

    compute_title() (crud.rs:2752) behaves as described — title is null for non-root child nodes — so the null-skipping trigger logic is required, not defensive.

    Revised acceptance criteria

    • Confirm whether bm25_search_roots has any production consumer; record the answer here — yes: semantic_search, the BM25 half of hybrid search behind search_nodes and agent context assembly
    • A new, separate FTS5 table indexes node.title, with triggers that skip null titles and delete on transition to null
    • The content index, its triggers, and bm25_search_roots are deleted — withdrawn; retained, live consumer
    • A test pins the null-skipping behaviour: a child node with a null title must not appear in the index, and a node whose title becomes null must be removed from it

    Sequencing note

    The sizing measurement depends on #2802's recorded per-turn decisions, which land with #2842 (bun run eval:decisions, TurnRecord.decisions) — not yet on main. The measurement has no corpus to run over until that merges.

  7. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Correction to my previous comment: embeddings are per-type optional, which makes BM25 the only path to many entities

    My comment above justified retaining the content index on "exact-keyword recall." That understates it, and one of my conclusions was wrong. Embedding generation is opt-in per node type, and the types this issue needs to resolve are largely opted out. Verified on main @ 475b3acc.

    Embeddability is a behavior decision, not a property of every node

    is_embeddable_type                node_service/mod.rs:2303
      └─ behavior_is_embeddable       node_service/mod.rs:2577
           └─ behavior.get_embeddable_content(&probe).is_some()
    

    get_embeddable_content returning None means no embedding row is written at all (node_service/embedding.rs:173, embedding_service.rs:561), and an existing one is actively deleted (embedding_service.rs:385). Seven built-in behaviors return None unconditionally — including schema and date.

    User-defined types inherit a content-only default

    An unregistered type resolves to CustomNodeBehavior (node_service/mod.rs:2582), which does not override get_embeddable_content (behaviors/mod.rs:2241-2274). It therefore inherits the trait default (behaviors/mod.rs:297):

    fn get_embeddable_content(&self, node: &Node) -> Option<String> {
        if node.content.trim().is_empty() { None } else { Some(node.content.clone()) }
    }

    For a schema'd instance, identity lives in properties and the computed title; content is typically empty. So the node produces None and is never embedded.

    The title is gated behind content, which looks unintended

    extract_content_for_embedding (embedding_service.rs:197) does prepend title — at line 218. But line 205 returns early:

    let own_content = behavior.get_embeddable_content(node);
    if own_content.is_none() {
        return Ok(None);          // ← line 205: title at line 218 is never reached
    }
    ...
    if let Some(ref title) = node.title { parts.push(title.clone()); }   // ← line 218

    So title is included in an embedding only when content was already non-empty. A title-templated node with empty content is gated out before its title is considered. The intent at 218 is defeated by the precedence at 205 for exactly the nodes whose identity is the title.

    (Note the probe at mod.rs:2584 passes content: "probe content", so such a type registers as embeddable while its real instances still skip. Type-level embeddability and instance-level embedding disagree here.)

    Consequence: this strengthens the case for retaining the content index, and corrects my reasoning on the title tier

    Tier 3 of hybrid search states the situation in its own words (embedding_service.rs:729):

    Tier 3: roots in BM25 only → keyword match only (no KNN embedding yet, or below threshold)

    For a node with no embedding, BM25 is not a ranking improvement — it is the only retrieval path. Deleting the content index would not degrade these nodes' position in results; it would make them unfindable by any means. That is a firmer reason to retain it than the one I gave.

    It also corrects my second point. I argued the title tier shouldn't reuse semantic_search because a ranked list destroys the "(if any)" distinction. That is true but secondary. The load-bearing reason is that semantic_search's KNN half is structurally blind to these nodes — they have no vectors. A title FTS5 index is not an optimisation over the semantic path for title-templated user-defined instances; it is the only mechanism that can reach them.

    This widens the issue's "harder related case"

    The issue body frames {first_name: "Jane", last_name: "Doe"} with no titleTemplate as the unsolved case. The gap is broader: any user-defined instance with empty content is absent from the vector index, templated or not. A title index closes the templated case. The untemplated case remains genuinely open, because neither indexed column holds the name.

    It also sharpens the unboundedness concern from the three-tier framing: the entity tier cannot be "semantic retrieval with a tighter cutoff," because semantic retrieval does not see these nodes. That makes the deterministic FTS5-first direction correct on capability grounds, not merely on cost.

    Open question worth settling before implementing

    Is the line-205-before-218 ordering intended, or a latent bug? If title-bearing nodes should embed, fixing that precedence is a smaller change than a new index and would give the entity tier a semantic path too. If they intentionally should not embed (cost, noise, churn on every property edit), then the title index is the mechanism and this ordering should be documented as deliberate rather than left looking accidental.

    Either way it should be a conscious decision, since it determines whether the entity tier is FTS-only or hybrid.

  8. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Retraction: the previous comment's central claim is wrong — user-defined instances do embed

    My comment immediately above asserted that user-defined schema instances are never embedded, and reasoned from there that BM25 is their only retrieval path. That is incorrect and I am withdrawing it. The error was an unverified empirical premise, not a misreading of the mechanism.

    What I got wrong

    I claimed content is "typically empty" for schema'd instances, so CustomNodeBehavior's inherited default returns None. The behavior-dispatch chain I described is accurate; the premise about content is not.

    create_node's tool contract requires the opposite (packages/agent/src/local_agent/tools.rs:886, :904):

    Always pass 'content' as the record's title and nothing else … "The record's title and nothing else: the shortest phrase naming what this record IS."

    So "Add Northwind Trading…" creates a node with content: "Northwind Trading" — non-empty. The trait default (behaviors/mod.rs:297) returns Some, and the node is embedded. CreateNodeInput.content is a required String (ops/node_ops.rs:23) passed through verbatim (node_ops.rs:183).

    This holds for title_template types too: the template governs the displayed title composed from field_values, while content is still supplied (tools.rs:890-892). embedding_service.rs:1404-1412 asserts the custom-type path directly.

    What this means for the two claims built on it

    • "BM25 is the only path to these nodes" — withdrawn. They have embeddings and are reachable by KNN. Tier 3 still describes real nodes (un-embedded types, or below threshold), but user-defined instances are not normally among them.
    • "A title FTS5 index is the only mechanism that can reach them" — withdrawn. Semantic retrieval does reach them.

    My first comment's conclusion is unaffected, because it never depended on this: bm25_search_roots is called by semantic_search (embedding_service.rs:690), which backs search_nodes and agent context assembly. The content index is retained because it is half of live hybrid search. That stands on its own evidence.

    What survives, and is worth keeping

    1. Embeddability is per-type and opt-out-able in Rust, not declarable per schema. The control is NodeBehavior::get_embeddable_content(), dispatched on node_type. Types returning None unconditionally: task (behaviors/mod.rs:692), date (:1183), query (:1596), collection (:1695), ai-chat (:1872), horizontal-line (:1053), database-settings (:2438), plus agent-guidance via NON_EMBEDDABLE_CONTAINER_TYPES (:153).

    A schema author cannot opt instances out or declare which fields embed — that requires a Rust behavior registered in NodeBehaviorRegistry::new(). Worth knowing for the entity tier: task and collection are non-embeddable, so entities of those types are genuinely KNN-invisible and BM25-only.

    2. SearchScope::Knowledge is a second, independent axis. The default scope matches only text | header | code-block | schema | table (embedding_service.rs:871-873). So a company_sold_to node can be embedded and still be filtered out of a default-scope search. For entity resolution this may matter more than embeddability — worth checking which scope the resolution step would run under.

    3. The line-205-before-218 ordering still looks unintended. extract_content_for_embedding returns early when get_embeddable_content() is None (embedding_service.rs:205) before reaching the code that prepends title (:218). Less severe than I implied — it bites only when content is empty while title is set, which the tool contract makes uncommon rather than normal. Still reachable via direct API or import paths that bypass the agent tool. Low priority; recording it rather than pressing it.

    4. The codebase already wants a schema-level embedding template. person is a core schema with title_template: "{first_name} {last_name}" and a hand-written PersonNodeBehavior::compute_display_name that must be kept in sync by hand. Both sides say so (behaviors/mod.rs:2285-2291, core_schemas.rs:1216-1222) — the comment notes get_embeddable_content "needs a display string without a schema/template lookup in hand." That is the untemplated-identity gap the issue body raises, already present in a core type.

    Net effect on the issue

    Smaller than my previous comment implied. The entity tier is not forced to be FTS-only on capability grounds — semantic retrieval does see these nodes. The case for FTS5-first rests where the issue body originally put it: determinism, cost, and the "(if any)" present/absent distinction that a ranked list blurs. The genuine KNN-blind spots are narrower than I claimed: non-embeddable types (task, collection) and anything filtered out by SearchScope.

    Apologies for the noise — I should have verified what content actually holds before reasoning from its absence.

  9. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Correction: the sizing step's corpus does not exist, and #2802 is not a substitute

    The issue body says the first step is to measure, offline, "what fraction of messages contain a resolvable entity name," and names #2802's recorded per-turn decisions as the source of real messages. That is wrong on two counts, found while scoping the work.

    1. No corpus exists on disk. eval:decisions writes results to /tmp/decisions-<label>-<ts>.json by default and nothing is committed. The 3-rep baseline recorded on #2802 is already gone.

    2. Regenerating it would not produce real messages. The eval's prompts — ~55 across decisions.ts, routing.ts and agent-matrix.ts — are hand-authored to exercise routing, and guidance_is_not_contaminated_by_eval_prompts exists specifically to keep them synthetic and independent of guidance wording. Measuring entity prevalence against prompts written to test routing would mostly measure the fixture author's choices.

    Worse, and the part that makes this actively misleading rather than merely weak: the entity names in those fixtures (Northwind, Contoso) are absent from the graph by design. An FTS5 pass over them would largely measure misses. That is an inverted signal, not a noisy one.

    Since this number is the single input to the general-mechanism-vs-scoped-special-case decision, a figure that cannot be trusted is worse than no figure — it gets cited as evidence. ADR-056 makes exactly this complaint about its own matrix scores ("describe the harness as much as the model"). Seeding a corpus ourselves has the same defect one layer down: we would be authoring the messages, so we would be choosing the answer.

    Revised plan

    Prevalence is deferred until real usage produces messages. Not a blocker — nothing downstream waits on it, and the two decisions it feeds (is this general or special-case; how strongly should the resolved type constrain routing) can stay open.

    Precision is measurable now, and is the question that could actually sink the design. Rather than "what fraction of real messages carry a resolvable entity" (needs real traffic), ask: "when an entity is named and does exist, does FTS5 over title resolve it to the right node?"

    • Prevalence decides whether the mechanism is worth building.
    • Precision decides whether it can be built.

    The second is answerable against a seeded workspace without pretending the messages are representative, and it belongs in the title-index work as validation of the index rather than as a separate phase.

    Acceptance criteria — amended

    Replacing the sizing item in the issue body:

    • Run the offline sizing measurement and record its numbers here — deferred; no legitimate corpus exists, and fixture prompts would invert the signal. Revisit when real usage has produced messages.
    • Validate resolution precision against a seeded workspace: entities that exist and are named in a message resolve to the correct node, with the rank cutoff that a real message's noise words demand
    • The general-vs-special-case decision stays open pending a prevalence figure from real traffic; do not close it against synthetic data

    The first phase (the title FTS5 index itself — separate table, content index retained per the retraction above) is unaffected by any of this and is independently useful. It proceeds.

  10. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-2841-title-fts-index, main @ 700d748): Frontend: 5247 passed (260 files).

  11. self-assigned this
    on Sep 22, 2026
  12. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Design decisions for the entity tier

    Answering the open scope questions. Where a default was proposed and I agree, I say so; where I override it, the reasoning is given.


    1. Precision policy — cap + BM25 cutoff, not unique-match

    Unique-match is the tempting default and it is wrong here: it makes the tier go silent exactly when it is most needed. The motivating case for this whole design is a name resolving to more than one node ("is Acme a customer or a project?"). Dropping ambiguity means the tier renders nothing precisely on the turns that need disambiguating.

    Render the top N above a score cutoff. Ambiguity is information, not noise.

    Proper-noun filtering is a good idea, but as a ranking input rather than a pre-filter — a pre-filter loses an entity named in lowercase, which real messages contain. Type-scoping against relevant_schemas is also rejected as a gate: it inverts the dependency chain this issue argues for (entity should constrain schema, not the reverse), and it cannot resolve an entity whose type the schema tier failed to retrieve.

    2. Where resolution runs — before Stage 1, and it is less invasive than it looks

    This is correctly identified as the real architectural decision: the issue's "one lookup constrains three decisions" claim only holds if resolution precedes Stage 1.

    One correction to the framing, which changes the cost. build_workspace_context is not called from inside agent_loop — it runs in the daemon, at packages/daemon/src/services/local_agent_service.rs:775, before the turn reaches the loop at all. agent_loop reads the already-assembled result from session.dynamic_context (agent_loop.rs:1733), after route() at :1590.

    So "resolution before Stage 1" does not mean relocating context assembly relative to routing. It means resolving in the daemon path where context is already built. That is a smaller change than option B implies, and it is the only option supporting the dependency chain.

    3. What the tier renders — name + type + node id

    The failing scenarios stalled asking the user for a node ID:

    "I need a Node ID to update the capacity for Northwind Trading."

    Withholding the id would preserve the exact failure the tier exists to remove. Field values are premature — add them only if a measurement shows they are needed; the schema tier already carries field definitions.

    4. Ambiguity handling — render all candidates

    Follows from (1); dropping silently would contradict choosing cap + cutoff.

    The typed clarification ("step 3" in the issue body) stays out of scope — that is the Laya slice, and it is gated on #2825, which is in turn gated on this issue. Do not build it here.

    5. Scope of the PR — resolution + tier + re-scoring + the Gemma eval run

    Agreed with the proposed default. The fifth acceptance criterion (re-score the three schema scenarios as entity-resolution cases) is meaningless without a run to re-score against, so the eval run is part of this work, not a follow-up.

    6. Phase B — skip the offline sizing measurement

    Agreed. The fixture-based variant was already rejected (see the corpus-correction comment above: fixture entity names are absent from the graph by design, so the signal is inverted rather than weak). Post-hoc precision measurement of the built tier is the honest version, and it folds into (5) rather than standing alone.

    Prevalence stays deferred until real usage produces messages. See #2825's corpus comment for the same constraint applied there.

    7. Untemplated entities — out of scope, documented as a known gap

    Nodes whose identity lives only in property values ({first_name: "Jane", last_name: "Doe"} with no template) sit in neither indexed column. Changing compute_title to synthesise a title for them would alter existing title semantics for every reader — search_nodes's keyword path, ADR-040's TITLE_BOOST, mention autocomplete, and the UI's display title. That is a separate decision with its own blast radius, not a sub-task of this one.

    Document it as a known limitation of the tier.


    One addition to the acceptance criteria

    A no-match must render distinctly from an absent tier. "Northwind resolved to nothing" means create; "no entity tier present" means the mechanism did not run. Collapsing the two reintroduces exactly the ambiguity this design removes, and it is the same distinction DecisionRecord already draws between selected: None and no record at all (#2802).

    • The rendered tier distinguishes "resolved to nothing" from "did not run"
  13. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-2841-entity-tier, main @ 6c89833): Frontend: 5264 passed (262 files).

  14. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Re-scoring the three schema scenarios: seed the instance, and keep a no-match case

    The re-scoring criterion cannot be satisfied as literally worded, and the reason is a flaw in the fixture I wrote. Confirmed against source: both setup turns in scripts/eval/fixtures/decisions.ts create schemas only — setup-company and setup-venue each fire create_schema and nothing else. No Northwind instance has ever existed in that workspace.

    So the three scenarios ask the agent to act on an entity that was never created:

    • schema-on-menu-company — "Add Northwind Trading to the companies we sell to"
    • schema-field-disambiguates — "Northwind can seat 200 people now"
    • schema-shared-name-signed — "When did we sign Northwind?"

    Scenarios 2 and 3 are an update and a read of a node that does not exist. They cannot be entity-resolution successes; there is nothing to resolve.

    Decision: seed the instance (option A), plus one addition

    Seed a Northwind instance in setup. The scenarios are written in the voice of someone referring to an existing company — "When did we sign Northwind?" is only a sensible question if Northwind exists — and the measured failure is exactly what happens when a model is asked to act on something it cannot find:

    "I need a Node ID to update the capacity for Northwind Trading."

    Seeding it makes the fixture measure what it was written to measure. That is a correction of my own fixture error, not a change of intent.

    Addition: keep a no-match scenario. Do not lose that case by seeding everything. "Resolved to nothing → create" is a distinct, valuable signal and it needs a scenario of its own — it is the criterion added earlier in this issue:

    A no-match must render distinctly from an absent tier. "Northwind resolved to nothing" means create; "no entity tier present" means the mechanism did not run.

    So: seed Northwind, and add one scenario naming an entity that deliberately does not exist, asserting the tier renders the no-match distinctly. That recovers most of option C's coverage at option A's cost, because the no-match case already has a home in the acceptance criteria.

    Two consequences worth stating in the PR

    1. schema-on-menu-company becomes genuinely ambiguous once Northwind exists. "Add Northwind Trading to the companies we sell to" could mean create this or you already have this. That is not a defect — it is the disambiguation case, and it is worth keeping precisely because it is ambiguous. But its assertion needs rewriting to state what the right answer now is, rather than silently inheriting the old one.

    2. The new numbers are not comparable to the recorded 5/8 baseline. With a seeded instance the fixture measures a different workspace, so a reader diffing the two would be comparing different experiments. Say so in the PR rather than leaving the earlier baseline comment to be read as the predecessor of the new run.

    Note on the eval run in scope

    Including the Gemma eval run in this PR still stands — the re-scoring is meaningless without a run to re-score against. But per (2), record it as a new baseline rather than a delta against the old one.

  15. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Precision check against the landed node_title_fts index

    Ran the measurement this issue's earlier comment proposed folding into Phase A — "when an entity IS named and DOES exist, does FTS5 over title resolve it to the right node?" — now that #2845 has landed. No model involved, no corpus needed: a seeded workspace and direct queries against the index.

    Verdict: the index behaves well enough for the tier to be built on, and the rank cutoff has a clear empirical basis.

    Setup

    Fresh database, daemon at 6c89833b. Seeded 8 entity nodes whose titles are the thing to resolve (Northwind Trading, Northwind Logistics, Contoso Ltd, Riverside Hall, …) plus 5 deliberate decoys whose titles contain the noise words a real message carries (The companies we sell to, and how we track them, Notes on venue capacity and seating, Signed contracts and renewal dates, …). The decoys are the point: they are what a rank cutoff has to discriminate against.

    Null-skipping works exactly as specified

    nodes total            205
    nodes with a title      51
    rows in node_title_fts  51
    

    Not one stale or missing row. The delete-then-conditionally-reinsert trigger handles the non-NULL → NULL transition correctly, and nullif(title,'') catches the empty-string case too.

    Results

    Queries mirror how a resolution step would work: tokenise the message, OR the terms, rank by bm25. Lower is better.

    1. Exact name — clean separation.

    "Northwind" OR "Trading"      -6.53  Northwind Trading
                                  -3.27  Northwind Logistics
                                  -2.13  Trading terms for new customers
    "Contoso"                     -3.85  Contoso Ltd          (only hit)
    

    The right node wins by 2x the margin of the next candidate.

    2. Bare surname — ambiguity surfaces correctly.

    "Northwind"                   -3.27  Northwind Trading
                                  -3.27  Northwind Logistics
    

    Exactly tied, which is the correct answer — the message genuinely does not distinguish them. This is the case that argues against the unique-match precision policy: a unique-match rule would render nothing here, precisely when disambiguation is needed.

    3. Noise words — the load-bearing case.

    "add" OR "northwind" OR "trading" OR "companies" OR "sell"
                                  -6.53  Northwind Trading
                                  -3.27  Northwind Logistics
                                  -3.18  The companies we sell to, and how we track them
                                  -2.13  Trading terms for new customers
    

    The decoy stuffed with every noise word in the message scores -3.18 against the entity's -6.53. BM25's IDF weighting does the work: "northwind" is rare, "companies"/"sell" are not.

    Two other full messages behaved the same way, with one instructive leak:

    "when" OR "did" OR "sign" OR "northwind"
                                  -3.27  Northwind Trading
                                  -3.27  Northwind Logistics
                                  -1.59  Complete a parent task when all its children are done
    

    A seeded guidance node matched on the stopword "when" at -1.59 — comfortably below any sane cutoff, but it confirms that stopword filtering is still worth doing rather than relying on ranking alone.

    4. No match — returns empty.

    "Zephyr" OR "Dynamics"        (no rows)
    

    Clean. The tier can distinguish "resolved to nothing" from "did not run" on this signal, which is the criterion added earlier in this issue.

    Latency — the number that justifies doing this deterministically

    200 iterations of the noise-word query (the most expensive shape probed), timed in aggregate:

    200 queries in 24.4 ms  ->  0.122 ms/query
    

    That figure includes amortised sqlite3 process startup, so the in-process cost is lower. Query plan is SCAN node_title_fts VIRTUAL TABLE INDEX 0:M2 plus a temp B-tree for the ORDER BY — the FTS index is doing the work, not a table scan.

    For scale, against the two alternatives this tier replaces:

    Approach Cost per turn
    FTS5 over title ~0.12 ms
    Stage-1 routing (one generative pass, 3-way choice) 1602–1933 ms (measured, #2802)
    Laya choice on MPS (were it used for this) ~25 ms (measured)

    So resolution is roughly four orders of magnitude cheaper than the generative turn it informs, and ~200x cheaper than the fastest decision-model option. It is free at the scale of an agent turn.

    Caveat: 51 rows. Cost grows with index size, but FTS5 is an inverted index — lookup is by term, not by scan — so it grows with matching rows rather than total rows. A workspace with thousands of nodes would need re-measuring, but nothing here suggests a scaling problem, and the LIMIT 5 bounds the sort.

    What this establishes

    • A cutoff around -2.5 to -3.0 separates entities from noise-word decoys in every probe run. That is an empirical starting point rather than a guess, which is why this was worth running before the resolution step is written.
    • Ties are real and meaningful. Two entities sharing a token tie exactly, supporting "render all candidates" over unique-match.
    • Stopword filtering is still needed. Ranking alone lets a stopword match leak in at low score; filtering removes the noise rather than relying on the cutoff to catch it.

    Caveats, stated plainly

    • This measures the index, not the tier. No resolution logic exists yet; this says the mechanism can work, not that the eventual implementation does.
    • The entities and decoys are authored by me, so this is a precision result, not a prevalence one. It says nothing about how often real messages contain a resolvable name — that remains deferred until real usage produces messages.
    • 8 entities and 5 decoys is a small corpus. The separation margins are large enough to be convincing at this size, but a workspace with hundreds of similarly-named nodes would be a different test.
  16. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    The entity tier has landed (#2856, merged as d4eaf894). What remains on this issue.

    Status moved back to Todo rather than Done: the implementation criteria are met, the two measurement-gated ones are not, and they were deferred by decision rather than completed.

    Done

    • FTS5 indexes node.title — landed separately in Index node.title in its own FTS5 table for entity lookup #2845
    • Entity resolution runs as a deterministic system step before Stage-1 routing, consistent with ADR-038's trust boundary
    • The three failing scenarios are re-scored as entity-resolution cases (plus a fourth, for the no-match signal)
    • Tests pass, quality:fix clean

    Still open, and why

    • Prevalence — what fraction of real messages name a resolvable entity. Deferred per the corpus correction earlier in this issue: no legitimate corpus exists, and fixture prompts invert the signal because their entity names are absent from the graph by design. Needs real usage.
    • General mechanism vs scoped special case — depends on prevalence, so it stays open with it.

    Precision, the half that was answerable, is measured: the index probe recorded on this issue, and the tier's own 3-rep eval below.

    Final measurement

    3 reps, gemma-4-e4b-q4km, purged between reps, provenance 8932e269.

    8/9 pass^3, Entity resolution 3/4, Flipped 0/9.

    An earlier run reported 7/9 and 2/4; those were withdrawn. They were measured while the entity was being truncated out of its own lookup — build_workspace_context received the blended retrieval query while the resolver kept only the first 6 tokens, so on any turn with a prior turn the name never reached the index and the tier reported NoMatch. That bug is fixed in the merged PR, at both the call site and the resolver.

    Attribution, since three things changed between the two runs: schema-field-disambiguates 0/3 → 3/3 was a fixture assertion fix (it asserted a schema decision on a turn that correctly calls update_node, which records none); Entity resolution 2/4 → 3/4 tracks the truncation fix.

    The one failing scenario, and what it establishes

    schema-on-menu-company fails 0/3: "Add Northwind Trading to the companies we sell to", with Northwind present, produces create_node and a silent duplicate.

    This is a MODEL failure, not a mechanism failure, and the run separates the two cleanly:

    • route_clarify was on the offered tool surface in all three reps
    • The entity was resolved and rendered — three sibling scenarios in the same run used it correctly (update_node on the existing node, search_nodes for it, create_node only when genuinely absent)
    • route_clarify was called zero times across the entire run

    So the deterministic tier supplied the fact and the tool; the model declined to act on either. Guidance prose, the create_node tool description, and both together were each measured and each failed. ADR-064 measured the tool-schema channel at 100% compliance for output-shape constraints; a conditional suppression — "do not take the obvious action when a condition holds" — appears to be a materially harder ask, and that is the useful finding here.

    Tracked as its own issue, with a deterministic write-path guard as the proposed direction: the system already holds the resolved entity, so the collision is detectable before the write with no model judgment involved.

    Filed along the way

    • Child nodes are titled with their own body text and so enter the entity index — a create-path defect where the title is recomputed with rootness unknown, before the parent edge exists. Pinned by a test that documents current behaviour and says to invert it when fixed.
    • The duplicate-create guard described above.

    Known limitation recorded in the code

    The token-selection bias keeps capitalised tokens in preference, which fixes the case where competing filler is lowercase. It does not help when the competing tokens are capitalised too — a Title Case sentence can still push the entity out of the budget. Left unfixed deliberately: "prefer the longest run of adjacent capitalised tokens" was tried and gives no discrimination there, since such a sentence is one long run. It degrades to a weak match rather than to NoMatch, so it cannot produce the false "does not exist" claim that licenses a duplicate.

  17. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Correction to the status comment above: one of the two "open" items has a completed replacement

    My summary listed both prevalence and the scope decision as simply "deferred". That understates the first one and is worth stating precisely, because the body's checklist and the amended checklist disagree and a future reader will hit the body first.

    Criterion: "The offline sizing measurement above is run and its numbers recorded on this issue" (body line 96) — struck and replaced, not merely deferred. The amendment earlier in this issue replaced it with:

    Validate resolution precision against a seeded workspace: entities that exist and are named in a message resolve to the correct node, with the rank cutoff that a real message's noise words demand

    That replacement is satisfied, three ways:

    • The index probe recorded on this issue (8 entities + 5 noise-word decoys; clean separation, and the source of the -2.5/-3.0 band)
    • packages/core/tests/entity_resolution_test.rs — 12 cases against a real database, covering exact/partial/bare names, ambiguity, archived exclusion, stop-words-only, and the token-budget regression
    • The 3-rep eval: entity resolution 3/4, zero variance

    The cutoff those numbers calibrate is pinned by a test that fails at the previous value. So precision is measured, not outstanding.

    Criterion: "A decision is made and written down: general mechanism vs scoped special case, based on those numbers" (body line 97) — genuinely open, and deliberately so. The amendment says:

    The general-vs-special-case decision stays open pending a prevalence figure from real traffic; do not close it against synthetic data

    Leaving it unchecked is compliance with that instruction, not an omission. It depends on prevalence, which depends on real usage.

    So what is actually outstanding on this issue

    One thing: prevalence, and the scope decision that waits on it. Everything else is either landed or has a satisfied replacement.

    That is why the status is Todo rather than Done — but the remaining work is a measurement that cannot be taken yet, not implementation.

  18. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Closing: the tier shipped, and what remains is a question rather than work

    Disposition of every acceptance criterion, since several need striking rather than ticking.

    Criterion Status
    FTS5 indexes node.title alongside node.content, triggers updated ✅ Done — #2845 (6c89833b). Separate node_title_fts table, not a second column; the content index stays (it has a live consumer via semantic_search's hybrid join). Null-skipping verified on a seeded workspace: 205 nodes, 51 with titles, 51 indexed — no stale or missing rows.
    The offline sizing measurement is run ❌ Struck, not done. No legitimate corpus exists, and the eval's fixture prompts would invert the signal rather than weaken it (their entity names are absent from the graph by design). Replaced by a precision measurement, which did run — see the probe comment above.
    A decision on general mechanism vs scoped special case ❌ Still open, and correctly so. It needs a prevalence figure from real traffic, which only usage produces. Carried forward below.
    Entity resolution runs as a deterministic system step before Stage-1 routing ✅ Done — #2856 (d4eaf894). resolve_entities in context_ops.rs, reached from the daemon's existing build_workspace_context call, so it lands before Stage 1 without relocating context assembly. No model call, consistent with ADR-038 keeping retrieval out of the model's hands.
    The three failing scenarios are re-scored as entity-resolution cases ✅ Done — #2856, plus a seeded Northwind Trading instance (the scenarios previously acted on an entity the setup never created) and a new entity-no-match-is-a-create scenario for the other half of the three-state output.
    Tests pass, quality:fix clean ✅ Both PRs cleared the pre-push gate.

    One design decision worth recording, because it overrode this issue's own guidance

    The probe comment above proposed an absolute bm25 cutoff of -2.5 to -3.0. The implementation correctly rejected that for a relative one (ENTITY_SCORE_CUTOFF_FACTOR = 0.45): bm25 scores are corpus-dependent, so a threshold calibrated on 51 indexed rows drifts as the workspace grows, while "is this candidate comparable to the best match" is scale-free. The probe calibrated the factor, not the raw score — which is the right use of that measurement.

    A detail found by testing rather than reasoning: an earlier factor of 0.55 put the bar at -3.59 and dropped Northwind Logistics, collapsing exactly the ambiguity the render-all-candidates policy exists to preserve.

    Carried forward, not lost

    Closing. The mechanism is live on main; the remaining question is one measurement cannot answer yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions