Repository navigation
Description
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_valuesbecomes 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
customerfromproject. 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.titlealongsidenode.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.tsare re-scored as entity-resolution cases rather than schema-selection cases - Tests pass (
bun run test:all), code passesbun 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_THRESHOLDpackages/core/src/ops/context_ops.rs—build_workspace_context, and the ordering constraint that context is assembled before Stage-2 routingpackages/agent/src/local_agent/agent_loop.rs— turn sequencing; where a resolution step would sitpackages/core/src/services/node_service/crud.rs—compute_title(), which writes the column FTS5 does not index
Related
- Make schema and operation selection explicit, recorded decision points with a measured Gemma baseline #2802 — the decision instrumentation that produced this evidence, and the source of real messages for the sizing step
- Laya spike result: NEEDS-FINETUNING; schema selection is separable and deployable, operations are a regression, act-vs-clarify blocks on declarative state-changes #2825 — Laya spike. Relevant because the failing decision here is a lookup, not a judgment: no decision model addresses it. Laya's plausible role is only step 3, the bounded 2-3 candidate residue after resolution, which is where it measured strongest (40/40).
- Give Stage-1 routing a bounded schema/entity-type signal so it stops treating known types as ambiguous #1980 — Stage-1 lacks a bounded schema/entity-type signal. Adjacent and complementary: that issue is about type-level vocabulary, this one about instances.
- ADR-038 — retrieval as a deterministic system step; the trust boundary an extraction turn would breach
- ADR-077 — why
titleis computed and distinct fromcontent
Activity
malibio commentedon Sep 22, 2026
Correction to the prerequisite: index
title, and drop thecontentindex rather than extending itThe issue body proposes adding
titleto the existingnode_ftstable. 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 NULLis 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:dateandschemanodes → alwaysNonetitleTemplate→ the interpolated templatetask/collection→ stripped contentstrip_markdown(content)if the node is a root, otherwiseNone:So
titleis 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
contentis actively wrong for this purpose, not merely incompleteA root node's
contentcan 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:titleandcontentare 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 NULLhas 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:
contenttitleConflating them degrades both.
3. The
contentindex has no production consumerIts only reader is
SqliteStore::bm25_search_roots(packages/core/src/db/sqlite_store/embeddings.rs:628). Greppingpackages/core/src,packages/agent/src,packages/daemon/srcandpackages/cli/srcfinds no production caller — every call site is in tests (packages/core/tests/embedding_service_test.rs, and one connection-lifecycle test atsqlite_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_ftsovercontent→ removed, along with its three triggers and thebm25_search_rootsfunction and tests, unless a production consumer is identified firsttitle, synced by triggers that skip rows wheretitle IS NULLand delete on a non-null → null transitionFTS5 has no partial-index syntax, so the null-skipping is trigger logic, not a
WHEREclause on the table. Getting that wrong silently reintroduces exactly the noise this change exists to remove — anUPDATEthat 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_rootsis 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)
bm25_search_rootshas any production consumer; record the answer herenode.title, with triggers that skip null titles and delete on transition to nullcontentindex, its triggers, andbm25_search_rootsare deleted if no consumer exists (DDL change + database reset, no migration)malibio commentedon Sep 22, 2026
Retraction:
bm25_search_rootsis NOT dead — the content index staysMy 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_rootsis 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:Verified directly:
embedding_service.rs:680-700runssearch_embeddings(KNN) andbm25_search_rootsconcurrently in atokio::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_searchis its only caller, and the reachable-from-a-tool path is two hops further on. I grepped for the function name acrosscore/src,agent/src,daemon/srcandcli/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.rspins 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 reducedsearch_nodesto 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 NULLis 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)A new note worth acting on
search_ops.rsalready has aninclude_title_matchespath, but it is LIKE-based substring matching viatitle_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:
bm25_search_rootshas a production consumer — yes, viasemantic_search's hybrid join; the content index staysnode.title, alongside (not replacing) the content index, with triggers that skip null titles and delete on transition to nullsearch_ops.rs'sinclude_title_matchespath, or whether the existing LIKE-basedtitle_containsstays — noting the two select different setsmalibio commentedon Sep 22, 2026
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
And the measurement behind that rule is directly on point:
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_nodesis 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_nodesis 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 SCHEMASuses, 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
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
malibio commentedon Sep 22, 2026
Better framing: this completes an existing three-tier pattern, it does not invent one
Stated plainly, what a turn should hand the model is:
Two of those three already ship. This issue is the missing tier, not a new mechanism.
context_ops::build_workspace_context→relevant_schemas(semantic, capped atMAX_SEMANTIC_SCHEMAS) +related_schemas(related_one_hop_schemas, one hop, bidirectional)skill_ops::find_skills→routing::stage2_toolsBoth 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:
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_nodesis 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.
malibio commentedon Sep 22, 2026
bm25_search_rootshas a live production consumer — the content index must stayAnswering the first acceptance criterion from the prerequisite correction above ("confirm
bm25_search_rootsis genuinely dead rather than reachable through a path the grep missed"). It is not dead. Verified against source onmain@475b3acc.The call chain
No call site spells
bm25_search_rootsoutside tests, which is why a grep for the name reads as dead. Its single non-test caller is two hops below the tool surface:grep -rn "\.semantic_search_nodes(" packages/*/src/returns exactly those two call sites, both undersrc/, 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 degradesearch_nodesto KNN-only and drop exact-keyword recall.embedding_service.rs:735partitions results into KNN∩BM25 / KNN-only / BM25-only tiers, andtest_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_ftsovercontent, its three triggers, andbm25_search_roots→ retained unchangedtitle, with triggers that skip null titles and delete on a non-null → null transitionThe 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.rsalready has aninclude_title_matchesflag (defaultfalse) whose keyword half istitle_match_nodes(search_ops.rs:382). It isLIKE-based substring matching viaNodeQuery::title_contains, issued once per node type, not an index lookup.That is worth knowing for two reasons:
title_match_nodesshould eventually be backed by the new index is a separate decision, but it means the title index would not be single-purpose, and themerge_keyword_and_semanticordering 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 —titleis null for non-root child nodes — so the null-skipping trigger logic is required, not defensive.Revised acceptance criteria
bm25_search_rootshas any production consumer; record the answer here — yes:semantic_search, the BM25 half of hybrid search behindsearch_nodesand agent context assemblynode.title, with triggers that skip null titles and delete on transition to nullThe— withdrawn; retained, live consumercontentindex, its triggers, andbm25_search_rootsare deletedSequencing note
The sizing measurement depends on #2802's recorded per-turn decisions, which land with #2842 (
bun run eval:decisions,TurnRecord.decisions) — not yet onmain. The measurement has no corpus to run over until that merges.malibio commentedon Sep 22, 2026
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
get_embeddable_contentreturningNonemeans 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 returnNoneunconditionally — includingschemaanddate.User-defined types inherit a content-only default
An unregistered type resolves to
CustomNodeBehavior(node_service/mod.rs:2582), which does not overrideget_embeddable_content(behaviors/mod.rs:2241-2274). It therefore inherits the trait default (behaviors/mod.rs:297):For a schema'd instance, identity lives in
propertiesand the computedtitle;contentis typically empty. So the node producesNoneand is never embedded.The title is gated behind content, which looks unintended
extract_content_for_embedding(embedding_service.rs:197) does prependtitle— at line 218. But line 205 returns early:So
titleis included in an embedding only whencontentwas 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:2584passescontent: "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):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_searchbecause a ranked list destroys the "(if any)" distinction. That is true but secondary. The load-bearing reason is thatsemantic_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 notitleTemplateas the unsolved case. The gap is broader: any user-defined instance with emptycontentis 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.
malibio commentedon Sep 22, 2026
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
contentis "typically empty" for schema'd instances, soCustomNodeBehavior's inherited default returnsNone. The behavior-dispatch chain I described is accurate; the premise aboutcontentis not.create_node's tool contract requires the opposite (packages/agent/src/local_agent/tools.rs:886,:904):So
"Add Northwind Trading…"creates a node withcontent: "Northwind Trading"— non-empty. The trait default (behaviors/mod.rs:297) returnsSome, and the node is embedded.CreateNodeInput.contentis a requiredString(ops/node_ops.rs:23) passed through verbatim (node_ops.rs:183).This holds for
title_templatetypes too: the template governs the displayed title composed fromfield_values, whilecontentis still supplied (tools.rs:890-892).embedding_service.rs:1404-1412asserts the custom-type path directly.What this means for the two claims built on it
My first comment's conclusion is unaffected, because it never depended on this:
bm25_search_rootsis called bysemantic_search(embedding_service.rs:690), which backssearch_nodesand 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 onnode_type. Types returningNoneunconditionally:task(behaviors/mod.rs:692),date(:1183),query(:1596),collection(:1695),ai-chat(:1872),horizontal-line(:1053),database-settings(:2438), plusagent-guidanceviaNON_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:taskandcollectionare non-embeddable, so entities of those types are genuinely KNN-invisible and BM25-only.2.
SearchScope::Knowledgeis a second, independent axis. The default scope matches onlytext | header | code-block | schema | table(embedding_service.rs:871-873). So acompany_sold_tonode 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_embeddingreturns early whenget_embeddable_content()isNone(embedding_service.rs:205) before reaching the code that prependstitle(:218). Less severe than I implied — it bites only whencontentis empty whiletitleis 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.
personis a core schema withtitle_template: "{first_name} {last_name}"and a hand-writtenPersonNodeBehavior::compute_display_namethat must be kept in sync by hand. Both sides say so (behaviors/mod.rs:2285-2291,core_schemas.rs:1216-1222) — the comment notesget_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 bySearchScope.Apologies for the noise — I should have verified what
contentactually holds before reasoning from its absence.malibio commentedon Sep 22, 2026
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:decisionswrites results to/tmp/decisions-<label>-<ts>.jsonby 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.tsandagent-matrix.ts— are hand-authored to exercise routing, andguidance_is_not_contaminated_by_eval_promptsexists 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
titleresolve it to the right node?"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.The first phase (the
titleFTS5 index itself — separate table, content index retained per the retraction above) is unaffected by any of this and is independently useful. It proceeds.malibio commentedon Sep 22, 2026
Baseline (worktree issue-2841-title-fts-index, main @ 700d748): Frontend: 5247 passed (260 files).
Address review: make the title FTS refill atomic, treat '' as untitled (
Fix the title FTS refill predicate so the repair converges (#2841)
Make the title FTS convergence test detect a mismatch in either direc…
Index node.title in its own FTS5 table for entity lookup (#2845)
malibio commentedon Sep 22, 2026
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_schemasis 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_contextis not called from insideagent_loop— it runs in the daemon, atpackages/daemon/src/services/local_agent_service.rs:775, before the turn reaches the loop at all.agent_loopreads the already-assembled result fromsession.dynamic_context(agent_loop.rs:1733), afterroute()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:
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. Changingcompute_titleto synthesise a title for them would alter existing title semantics for every reader —search_nodes's keyword path, ADR-040'sTITLE_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
DecisionRecordalready draws betweenselected: Noneand no record at all (#2802).malibio commentedon Sep 22, 2026
Baseline (worktree issue-2841-entity-tier, main @ 6c89833): Frontend: 5264 passed (262 files).
malibio commentedon Sep 22, 2026
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.tscreate schemas only —setup-companyandsetup-venueeach firecreate_schemaand 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:
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:
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-companybecomes 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.
malibio commentedon Sep 22, 2026
Precision check against the landed
node_title_ftsindexRan the measurement this issue's earlier comment proposed folding into Phase A — "when an entity IS named and DOES exist, does FTS5 over
titleresolve 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
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.
The right node wins by 2x the margin of the next candidate.
2. Bare surname — ambiguity surfaces correctly.
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.
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:
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.
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:
That figure includes amortised
sqlite3process startup, so the in-process cost is lower. Query plan isSCAN node_title_fts VIRTUAL TABLE INDEX 0:M2plus 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:
titlechoiceon MPS (were it used for this)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 5bounds the sort.What this establishes
Caveats, stated plainly
Address review: stop the entity name being truncated out of its own l…
Address review: never render an entity header above an empty list (#2841
Address re-review: document the residual token starvation (#2841)
Add the entity-resolution tier, and the measurement that shows it wor…
malibio commentedon Sep 22, 2026
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
node.title— landed separately in Index node.title in its own FTS5 table for entity lookup #2845quality:fixcleanStill open, and why
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, provenance8932e269.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_contextreceived 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 reportedNoMatch. 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-disambiguates0/3 → 3/3 was a fixture assertion fix (it asserted a schema decision on a turn that correctly callsupdate_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-companyfails 0/3: "Add Northwind Trading to the companies we sell to", with Northwind present, producescreate_nodeand a silent duplicate.This is a MODEL failure, not a mechanism failure, and the run separates the two cleanly:
route_clarifywas on the offered tool surface in all three repsupdate_nodeon the existing node,search_nodesfor it,create_nodeonly when genuinely absent)route_clarifywas called zero times across the entire runSo the deterministic tier supplied the fact and the tool; the model declined to act on either. Guidance prose, the
create_nodetool 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
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.malibio commentedon Sep 22, 2026
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:
That replacement is satisfied, three ways:
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 regressionThe 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:
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.
malibio commentedon Sep 22, 2026
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.
node.titlealongsidenode.content, triggers updated6c89833b). Separatenode_title_ftstable, not a second column; the content index stays (it has a live consumer viasemantic_search's hybrid join). Null-skipping verified on a seeded workspace: 205 nodes, 51 with titles, 51 indexed — no stale or missing rows.d4eaf894).resolve_entitiesincontext_ops.rs, reached from the daemon's existingbuild_workspace_contextcall, 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.Northwind Tradinginstance (the scenarios previously acted on an entity the setup never created) and a newentity-no-match-is-a-createscenario for the other half of the three-state output.quality:fixcleanOne 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
6bc23eb0); it is the residual Laya spike result: NEEDS-FINETUNING; schema selection is separable and deployable, operations are a regression, act-vs-clarify blocks on declarative state-changes #2825 turns on.Closing. The mechanism is live on
main; the remaining question is one measurement cannot answer yet.