Repository navigation
Description
Overview
NodeService::create_node_in_tx recomputes a node's title with rootness unknown, at a point in the transaction where the parent edge does not exist yet. Every child node created through create_node_with_parent is therefore misclassified as a root and titled with its own body text, when it should have no title at all.
Found while building the entity-resolution tier (#2841), which indexes node.title on the premise that a non-null title marks a nameable thing.
The mechanism
prepare_create_node_with_parent gets this right. It computes the title passing rootness explicitly (crud.rs:558):
// is_root = parent_id.is_none() — avoids a DB lookup at create time
self.compute_title(&temp_node, Some(params.parent_id.is_none())).await?For a child that yields None, which is correct — compute_title returns None for a non-root node of a content-titled type (crud.rs:2793-2807).
But create_node_in_tx then sees a None title and recomputes it (crud.rs:266-267):
if node.title.is_none() {
node.title = self.compute_title(&node, None).await?;
}Passing None for is_root makes compute_title resolve rootness itself, via store.get_parent_id(&node.id). Inside create_node_with_parent's transaction the node is inserted before create_parent_edge_in_tx runs (crud.rs:345-360), so that lookup finds no parent, returns is_root = true, and the node is titled strip_markdown(content).
The correct None from the prepare step is indistinguishable from "not computed yet", so the recompute overwrites a right answer with a wrong one.
Reproduction
packages/core/tests/entity_resolution_test.rs::a_body_node_mentioning_the_name_is_not_an_entity pins the current behaviour:
CHILD TITLE = Some("we should call Northwind Trading about the renewal")
Expected: None.
Impact
node.title is read by several surfaces, all of which treat it as a display identity:
node_title_fts(Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841) — body nodes enter the entity index under their full sentence. The tier degrades rather than breaks: long titles rank poorly under bm25 and the relative cutoff drops them when a real entity is present. But "every row in this index is an entity" is not true today.search_ops::title_match_nodes—title_containsmatches body text as if it were a name.- ADR-040's
TITLE_BOOSTin embedding search. - Mention autocomplete and the UI's display title.
Nothing is visibly broken, which is presumably why it has gone unnoticed; the cost is diffuse noise in every title-keyed surface.
Fix options
- Thread rootness through. Give
create_node_in_txthe caller's knownis_rootrather than letting it re-derive. Most direct; touches the signature and its call sites. - Distinguish "no title" from "not computed". The recompute exists for callers that never computed one; an explicit marker would let it skip nodes whose title was deliberately resolved to
None. - Recompute after the edge write. Moves the lookup to where it would get the right answer, at the cost of a second write.
(1) looks cleanest. Whichever is chosen, the invariant worth asserting is that a node created with a parent_id has a NULL title on commit.
Acceptance criteria
- A node created via
create_node_with_parentwith aparent_idhas a NULL title after commit - The recompute in
create_node_in_txcannot overwrite a deliberately-Nonetitle -
entity_resolution_test::a_body_node_mentioning_the_name_is_not_an_entityis inverted to asserthits.is_empty()(it currently pins the buggy behaviour, with a doc comment saying so) - Existing title-dependent tests still pass — check mention autocomplete and
title_match_nodesin particular, since some may have been written against the current wrong behaviour - Tests pass (
bun run test:all), code passesbun run quality:fix
Reference files
packages/core/src/services/node_service/crud.rs:266-267— the recomputepackages/core/src/services/node_service/crud.rs:558— the correct computation it overwritespackages/core/src/services/node_service/crud.rs:2790-2810—compute_title's rootness branchpackages/core/src/services/node_service/crud.rs:345-360— insert-before-edge orderingpackages/core/tests/entity_resolution_test.rs— the pinning test
Activity
Add the entity-resolution tier, and the measurement that shows it wor…
malibio commentedon Sep 22, 2026
Frontend: 5264 passed (262 files)