Repository navigation
Match search's keyword half on root titles; one title rule on every write path (#2867, #2858) - #2875
Conversation
closes #2867) General search's keyword half ran FTS over node.content at every depth and walked hits up to a root, stopping below a hardcoded container list — so a child line came back as if it were a document. It now runs bm25 over node_title_fts, which holds only titled roots, and Tier 3 is ordered by bm25 rank. - Embedding roots are always tree roots: children of a date page or task no longer get their own vectors; those roots are found by title. - Titles follow rootness on every has_child edge write (move, parent edge, relationship create/delete, tx variants, bulk attach), via a title-only store write that bumps neither version nor modified_at. - schema and date roots carry their content as their title; entity resolution excludes schemas (a type is not an entity). - Knowledge scope is an allow-list of user-knowledge core types plus every user-defined type; system types stay out. - Delete NON_EMBEDDABLE_CONTAINER_TYPES + parity test, node_fts + triggers + rebuild, and the unused semantic_search_scoped. - Skill guidance no longer claims search never returns tasks/records. Requires a database reset (no backfill, per the no-migration rule). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…loses #2858) - NodeService::derive_title is the single title definition: template if the type has one; else content for a root and for task/collection at any depth; else none. compute_title wraps it; bulk hierarchy inserts derive titles through it (with_titles, one schema lookup per type) and pass them to the store as BulkNodeRow's title. compute_title_for_bulk_insert, which had its own date/schema/checkbox list and ignored templates, is deleted. - Entity resolution excludes schema (a type is not an entity) and date (ISO titles tokenize to bare numbers). @mention autocomplete excludes schema and keeps date (a date link is a real mention). - Parity test over every core type, root and child. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Pragmatic Code Review — PR #2875Review Type: Initial Review (no prior reviews or comments on the PR) SummaryThis is a clear improvement to the codebase. It removes a whole class of bug: bare child lines coming back from search. The fix goes to the root cause (content FTS at every depth plus a hand-kept container list) and doesn't patch the symptom. It also deletes a lot of machinery: The findings below are ranking and embedding side effects plus a few test gaps. None of them blocks the merge. Requirements Check
Code Review Findings🟡 Important1. Core schemas now get ranking boosts for any query that contains a type name
Example: "project roadmap for Q3" can now rank the Project schema above the user's roadmap note. The decision that schemas are titled and in scope is settled. This ranking consequence is a separate question, and it has no test (see #2858 AC4). 2. The vector half can still return a non-root: a stale embedding survives an indent
Both gaps predate this PR. It is still the natural place to close them, because 3. The non-tx refresh is a separate, unguarded read-modify-write after the edge write
The window is small and the damage limited to a derived column, so this doesn't block the merge. 4. User-defined record title search is untested (#2867 AC3) 🟢 Suggestion5. 6. The per-edge refresh in 7. 8. Not emitting an event from Nitpicks
RecommendationAPPROVE The change is correct and deletes a lot of code. The title-rule unification is structural, not cosmetic, and the rootness refresh covers every production |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
…es, keep schemas out of keyword ranking
- refresh_for_rootness (renamed from refresh_title_for_rootness) now also
drops a node's own embeddings when it becomes a child and queues its tree
root, so the vector half can't return an indented root bare.
- set_title is guarded by the version read, so it loses to a concurrent
content update instead of overwriting it; doc states why it emits no event.
- merge_nodes re-derives the survivor's title after re-pointing edges.
- bm25_search_titles and TITLE_BOOST skip schemas: a type name is a common
word ("project roadmap" ranked the Project schema over the user's roadmap).
- Tests: user-defined record found by title (store + search_semantic),
schemas titled but not keyword hits, indented root drops its embedding.
Skipped: batching the per-edge refresh in bulk_create_has_child_edges (sync
cold-sweep only), narrowing get_all_schemas per search (unmeasured), and the
BulkNodeRow struct / derive_title-signature nits.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review addressed (ca42bd7)✅ Addressed
⏭️ Skipped
TestsThe full core suite passes (38 binaries), and the push went through the pre-push gate (test:all, daemon build, e2e). |
Pragmatic Code Review — PR #2875 (Re-Review of ca42bd7)Review Type: Re-Review Previous Review Summary
Requirements Check (delta)
All other #2867 criteria are unchanged ✅.
All other #2858 criteria are unchanged ✅. Verification of Addressed Findings
Skip Reasons
New Findings🟡 ImportantN1. A derived-index refresh failure now aborts the move after it committed, which skips the OCC bump and the sync events
The steps that can fail are
(a) is the smaller change and covers all seven call sites. 🟢 SuggestionN2. The tree a node leaves keeps its content in its aggregate embedding N3. Move-time cost per keystroke RecommendationAPPROVE All four 🟡 findings from the first review are fixed correctly and pinned by non-vacuous tests. The version guard never blocks the legitimate move path, because |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review of ca42bd7): APPROVE (posted as a comment — GitHub blocks self-approval). All four prior 🟡 findings verified fixed; one new 🟡 (make refresh_for_rootness non-fatal so a derived-index error can't skip the OCC bump/events after a committed move) recommended but non-blocking. Full findings in the comment above.
- refresh_for_rootness now logs and returns () instead of failing: it runs after the edge write has committed, so an error there must not report a committed move as failed and skip the caller's version bump and events. The _in_tx twin stays fallible (a failure rolls back the whole tx). - Only delete embeddings when the node has any, so an ordinary indent doesn't take the write lock for nothing. Skipped: re-queueing the tree a node left (its aggregate keeps the moved content until next edit) — predates this PR, relevance-only. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Re-review addressed (6ef3863)✅ Addressed
⏭️ Skipped
TestsThe full core suite passes (38 binaries), and the push went through the pre-push gate. Re-Review DecisionNO RE-REVIEW NEEDED. Both changes are small and low-risk. N1 turns an error into a log at the call sites; the logic is unchanged. N3 adds one guard. The reviewer already approved and named exactly these fixes. |
A project is a named record found by its title, like a task: its content is only its name, so a vector for it adds nothing the keyword half doesn't already match. ProjectNodeBehavior now returns None for both its own and its parent contribution, matching TaskNodeBehavior. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…title
- Being titled and being embeddable are independent: drop the title-based
justification from ProjectNodeBehavior and get_embedding_root_id.
- A chat is a root, so its title column follows its content ("Untitled",
then the generated name); AiChatNode::into_node's None is overwritten by
compute_title on write.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- PersonNodeBehavior::can_have_children and the frontend person plugin's canHaveChildren are now true: child nodes are notes about the person. - person is no longer embedded (get_embeddable_content returns None, like task and project), so neither the person nor its notes get vectors. compute_display_name existed only to build that embedding and is deleted with its tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Pragmatic Code Review — PR #2875 (Re-Review of ca42bd7..4d3f19a)Review Type: Re-Review Scope:
The project, person and title/embeddability decisions are the user's and are treated as settled. This review checks only that they are implemented correctly and completely. Previous Review Summary
Requirements Check (delta)No acceptance criterion of #2867 or #2858 changes status. All stay ✅, as in the previous re-review. The new commits sit outside both issues' acceptance criteria, and they are consistent with them:
Verification of Addressed Findings
Completeness of the project and person changesI checked backend behaviors, core tests, the frontend plugins and tests, the daemon, agent prompts, skill text and nodespace-docs.
New Findings🟢 SuggestionS1. The frontend/Rust S2. The behavior-driven non-embeddable integration test doesn't cover S3. Manually check person child creation in the UI RecommendationAPPROVE N1 and N3 are fixed correctly. N1's fix is placed right: failures are swallowed only after commit, the queue step still runs, and the in-transaction twin still propagates errors. The project and person changes are consistent across backend, frontend, agent, skill text and docs, and I found no leftover leaf or embeddability assumptions. The remaining items are two one-line test additions and a manual smoke test, none of which block the merge. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review of ca42bd7..4d3f19a): APPROVE (posted as a comment — GitHub blocks self-approval). N1 and N3 verified fixed; project/person changes consistent across backend, frontend, agent, skill and docs. Three 🟢 non-blocking suggestions (add person to the canHaveChildren parity table, add project/person to the non-embeddable integration test, smoke-test person child notes in the UI). Full findings in the comment above.
…e tables - core-plugins.test.ts: RUST_CAN_HAVE_CHILDREN lists person: true, so the frontend side of the flip is pinned. - embedding_service_test.rs: the non-embeddable type list includes project and person. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Re-review addressed (c68da72)✅ Addressed
⏭️ Deferred to the user
TestsBoth updated tests pass. The push went through the full pre-push gate. One retry was needed: Re-Review DecisionNO RE-REVIEW NEEDED. The changes are two test-table additions with no production code changes, and the reviewer already approved. |
Conflict in resolve_entities_by_title: main extracted token selection into select_entity_tokens; took main's version and kept this branch's schema/date exclusion. Updated the stale bm25_search_roots reference in select_entity_tokens' doc and a frontend comment pointing at the deleted compute_display_name. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CbMVLf7z8mBEgn2xPsNLcB
Summary
General search's keyword half now matches root titles (
node_title_fts) instead of running full-text search overnode.contentat every depth. A child line can no longer come back from search as if it were a document.What changed
bm25_search_roots(content FTS + ancestor CTE) is replaced bybm25_search_titles, which runs bm25 overnode_title_ftsand returns(id, bm25)in rank order. Tier 3 (keyword-only) results are now ordered by bm25 rank, notnode_id.get_embedding_root_id(and its spawned-task twin) used to stop below a non-embeddable parent, so every line on a date page or under a task got its own vector and could be returned bare by the vector half. They now walk to the tree root; a date page or task is not embeddable, so nothing under it is vectorized. This matchesdata-layer.md("Only root nodes … get embedded"; "Not embeddable: … child nodes"), which the code had drifted from.NodeService::refresh_for_rootness(+_in_tx, title only) re-derives the title, drops a new child's own embeddings and queues its tree root. It is best-effort after the edge commit (logs, never fails the move). It is called frommove_node,move_node_unchecked,create_parent_edge,bulk_create_has_child_edges, andhas_childcreate/delete increate_relationship,create_relationship_in_tx,delete_relationship,remove_relationship_in_tx, andmerge_nodes. The title write goes through a new title-onlySqliteStore::set_titlethat bumps neitherversionnormodified_at(title is a derived index column) and is guarded by the version read.schemaanddateroots now carry their content as their title (derive_title, andSchemaNode::into_nodefor seeded core schemas).NodeService::derive_titleis the single definition: template if the type has one; else content for a root and fortask/collectionat any depth; else none.compute_titlewraps it. Bulk hierarchy inserts now derive titles through it too (with_titles, one schema lookup per type) and pass them to the store asBulkNodeRow's 7th field.SqliteStore::compute_title_for_bulk_insertis deleted. It had its own list (date/schema/checkbox) and ignored templates, so a bulk-insertedpersongot a content title.schema(a type isn't an entity: "…to the list" resolved to the Ordered List schema) anddate(ISO titles tokenize to bare numbers). @mention autocomplete excludesschemaand keepsdate, since a date link is a real mention. General search's keyword half andTITLE_BOOSTskipschema(a type name is a common word; "project roadmap" ranked the Project schema over the user's roadmap).projectandpersonare not embedded. Both now returnNonefor their own and parent contribution, liketask. (projectembedded its content;personembedded a display name viacompute_display_name, which had no other use and is deleted.) Titledness and embeddability stay independent.personallows children (backend behavior + frontend plugin): child nodes are notes about the person. They get no title and no embedding of their own.Knowledgescope widened, as an allow-list.KNOWLEDGE_CORE_TYPES=text, header, code-block, schema, table, task, date, project, person, plus every user-defined (non-core schema) type, read from the schema list at search time.agent-guidance,skill,tool,play,database-settings,ai-chatstay out.NON_EMBEDDABLE_CONTAINER_TYPESand its parity test; thenode_ftstable, its three triggers, its bootstrap DDL and its rebuild/backfill; the unusedsemantic_search_scoped.SKILL.mdandreferences/cli.mdno longer claim a name search never returns tasks or typed records.node query --title-containsstays the recommended name→ID lookup (it's exact;searchmixes in meaning-similar documents), and the reason is now stated correctly.node_ftsconsumersNone remained.
node query --content-contains, thecontent containsfilter, the skill updater's lookup and the desktop search box'sinclude_title_matchespath all useLOWER(content) LIKEonnode, not the FTS index.Probe anomalies
schemauntitled → fixed (titled + indexed).person"titled but unindexed" did not reproduce: on a current database every titledpersonroot is indexed (the triggers cover every write path).database-settingsis a system singleton outside the default scope, so it needs no title.Database reset required
Existing databases keep old embeddings on date-page/task children and have no titles on schemas/dates. Per the no-migration rule there is no backfill — reset the database.
Docs
Companion edits in
nodespace-docs(committed to main):data-layer.mddrops the content-FTS exception, states the title-only keyword rule, and records the #2858 title decisions (one rule, per-surface opt-outs); ADR-029 gets a revision note on the widenedKnowledgescope and title-only keyword matching, plusproject/personrows in its per-type table;creating-node-types.md's person example allows children;product-features.mddescribes the BM25 leg and chat titles correctly.Tests
test_bm25_search_titles_never_matches_child_lines— a word only in child lines under atextroot, atask, a date page and anagent-guidanceroot matches nothing.test_bm25_search_titles_finds_task_date_and_record_titles,test_core_schemas_are_titled_but_not_keyword_hits,test_user_defined_record_is_found_by_title,test_indented_root_drops_its_embedding,test_bm25_search_titles_ordered_by_rank.test_embedding_root_is_tree_root_under_non_embeddable_roots.test_move_rederives_title_from_rootness,test_has_child_edge_rederives_title_from_rootness— both (and the child-line test) fail with the refresh helper stubbed out.title_rule_agrees_across_write_paths_for_every_core_type: single-node and bulk titles agree for every core type, root and child, and match the decided values.schemas_and_dates_are_not_resolved(fails with thedateexclusion removed),mention_autocomplete_offers_dates_but_not_schemas.test_title_matches_respect_default_knowledge_scopenow asserts a task is returned andagent-guidanceis not;test_knowledge_scope_admits_user_knowledge_and_excludes_system_typespins the allow-list.Closes #2867
Closes #2858
🤖 Generated with Claude Code