Repository navigation
Aggregate children's embedding content with the database's behaviour registry - #3638
Conversation
|
Review Type: Initial Review (medium depth), head Requirements Check
Code Review Findings No 🔴 Critical or 🟡 Important findings. What I checked and found sound:
🟢 Suggestion: one source of truth for the embedding service's registry (follow-up, non-blocking) Recommendation: APPROVE. The change is small and correctly scoped. It makes subtype behaviours decide their contribution to an aggregating parent, as ADR-082 §2.1 already promised. The output without an extension is unchanged by construction, and the test is mutation-checked. The one suggestion is an optional follow-up. |
mstomar125
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.
Address review (round 1)Review: APPROVE, with no Critical or Important findings. One 🟢 suggestion.
⏭️ Skipped: give
|
ff6b63a to
53a3ac9
Compare
…registry (closes #3627) The text, header and schema behaviours aggregated their children through a fresh NodeBehaviorRegistry::new(), which holds core's behaviours only, so a behaviour another build registered for an extends subtype of a core type was ignored when a node of that subtype sat under one of them. NodeAccessor gains behavior_registry(): the registry the database's node service validates with. NodeService returns its own. The aggregation helper resolves each child's contribution through it and no longer takes a registry argument. get_aggregated_content and its callers are unchanged. With no extension the registry is core's, so the output is the same. Tests: a text and a header parent aggregate a child of a subtype whose registered behaviour contributes differently from text's; with no extension, a mixed tree aggregates to the output the previous code gave. Co-Authored-By: Claude Opus 5.5 <[email protected]>
53a3ac9 to
0cfa42b
Compare
Closes #3627
Problem
The text, header and schema behaviours build their embedding content from their children through
aggregate_children_content, and each passed it a freshNodeBehaviorRegistry::new(). That registry holds core's behaviours only. A behaviour another build registers for anextendssubtype of a core type (DataExtensions::behavior, throughNodeService::new_with_extensions) was in the node service's registry but not in this one. So when a node of that subtype sat under a text, header or schema node, the parent asked core's registry for the child's contribution and got the base type's rule, not the subtype's.Change
NodeAccessorgainsbehavior_registry(): the behaviour registry the database's node service validates with, extension behaviours included.NodeServicereturns its own registry.aggregate_children_contentresolves each child's contribution throughaccessor.behavior_registry()and no longer takes a registry argument, so no caller can hand it a different one. The three behaviours call it with the node and accessor they already receive.get_aggregated_content's signature and every caller of it are unchanged: the embedding service and the tests already pass the node service as the accessor.NodeAccessor(inbehaviorsandembedding_servicetests) hold core's registry.With no extension, a database's registry is exactly core's (
DataExtensions::none().behavior_registry(); seeno_extension_gives_exactly_the_core_registry), so aggregation output is byte-for-byte unchanged.No extension-API version bump: ADR-082 §8 versions the registration hooks, and the hook's contract already says the subtype's behaviour decides embedding (§2.1). This change makes aggregation honour it.
NodeAccessoris not on the versioned surface, and the watched fixture (extensions/fixture_tests.rs) is untouched.Tests
New, in
packages/core/src/behaviors/mod.rs(realSqliteStore+NodeService::new_with_extensions, no model):a_subtype_child_contributes_to_its_parent_as_its_registered_behaviour_says: registersFixtureNoteBehaviorforfixture_note extends textthroughDataExtensions. Itsget_parent_contributionlabels the content, unlike text's. A text parent aggregates"Plain line\n\nFixture note: Kept aside", and a header parent aggregates"Fixture note: Under a heading".aggregation_with_no_extension_is_unchanged: no extension. A text page with a nested text line, a header, a task,chore extends taskandfixture_note extends text(no behaviour of their own) aggregates to"Plain line\n\nNested line\n\n## Section\n\nA note". That expected string was recorded by running the test on the code before this change, where it passed.Mutation check, each run on its own (both tests per mutation):
"Plain line\n\nKept aside")NodeService::behavior_registryreturns a static core-only registryHeaderNodeBehavior::get_aggregated_contentreturnsNonechain[..1])A choreleaks in)A task,A choreleak in)Run (CPU only, each under the machine slot, on this head):
cargo nextest run -p nodespace-core --lib --test itfiltered tobehaviors::,extensions::,test_schema_get_aggregated_content,ai_chat_message_test::,schema_embedding_queue_test::,ai_chat_subtypes_test::,extends_subtype_identity_test::,tool_subtypes_test::: 239 passed.cargo clippy -p nodespace-core -p nodespace-daemon --all-targets -- -D warnings -D clippy::unused-async: clean. This compiles thenlp-gatedembedding_servicetest double; those tests are not run here (no model on the shared machine).cargo fmt --check: clean.bun test scripts/: 1448 pass, 0 fail.bun run scripts/check-pro-boundary.ts: clean.Documentation
architecture/extension-points.mddoes not describe aggregation.🤖 Generated with Claude Code