Repository navigation
Decompose NodeService god-object into focused sub-services (facade delegation) - #1240
Conversation
Code Review SummaryThis PR successfully executes the mechanical decomposition of the 11,891-line The deferred Phase 4 (hierarchy extraction pending #1237) is clearly documented in a section comment at line 1175 of mod.rs. One acceptance criterion from the issue was partially honored but not fully implemented; the remaining findings are nits or minor improvements. Requirements Check
Testing
FindingsImportant Issues[Improvement] The issue acceptance criterion reads:
The PR changes visibility from The current implementation chose neither — there is no playbook-layer wrapper and no doc comment narrowing the intended audience. Any future developer inside Suggested fix (minimal): rename to [Improvement] The Suggested fix: Update the header to describe the module's actual current role: facade, shared state definition, hierarchy methods (temporary, Phase 4), and test suite. Link to the sub-modules. NitpicksNit:
Nit: All other sub-modules resolve types via Nit:
RecommendationAPPROVE The core decomposition goal is achieved: a 11,891-line god-object is split into six focused sub-modules, all tests pass at baseline, the workspace compiles clean, and no behavior changes were introduced. The Follow-up recommended: open a focused issue for (1) renaming |
|
Addendum — workspace test results
These tests are unchanged in this PR ( All crate-level tests ( |
malibio
left a comment
There was a problem hiding this comment.
Decomposition is mechanically correct and well-executed. All tests pass at baseline (132 doc tests, 47 integration tests in mod.rs). The two findings worth following up: (1) with_execution_context should be renamed scoped_for_playbook with a restricting doc comment to fully satisfy the issue's intent on removing execution context as a first-class public concern — current pub(crate) is a step in the right direction but leaves the method discoverable crate-wide; (2) the mod.rs module-level doc comment still describes the old monolithic file. Neither is a blocker. See full review comment for details. Recommendation: APPROVE.
Review addressed✅ Addressed (3/3 recommendations):
⏭️ Skipped (1 nit):
All tests still green: 866 integration + 132 doc. |
Phases 1-3 and 5 of the decomposition plan. Phase 4 (Hierarchy extraction) is deferred pending #1237 merge to avoid collision on the retry-loop cleanup. `packages/core/src/services/node_service.rs` (11,891 lines) split into: - `node_service/mod.rs` (2,789 lines): struct definition with all fields as `pub(crate)`, construction (`new`, `seed_*`), accessors (`store()`, `behaviors()`, `with_client`), all hierarchy methods (Phase 4 deferred), `NodeAccessor` impl, shared helper fns, all tests unchanged - `node_service/crud.rs` (2,036 lines): create/get/update/delete + all CRUD private helpers (validation, schema defaults, lazy migration, compute_title) - `node_service/relationship.rs` (910 lines): mention ops + typed relationship CRUD + populate_mentions helper - `node_service/schema.rs` (454 lines): schema queries, task-node ops, get_all_schemas, get_schema_with_relationships, check_node_completeness - `node_service/bulk.rs` (596 lines): bulk_create, bulk_create_hierarchy*, bulk_update, bulk_delete - `node_service/query.rs` (322 lines): query_nodes, query_nodes_simple, property filter helpers - `node_service/embedding.rs` (228 lines): embedding waker + queue methods (all behind `#[cfg(feature = "nlp")]`) Phase 5: `with_execution_context` changed from `pub` to `pub(crate)` — the only caller (`playbook/actions.rs`) is in the same crate so no call-site changes needed. All external callers (daemon, agent, cli, playbook) unchanged — facade keeps every `pub async fn` with byte-identical signatures. Co-Authored-By: Claude <[email protected]>
…pdate doc - Rename with_execution_context → scoped_for_playbook with a doc comment restricting use to crate::playbook; update the one call site in actions.rs. Fully closes the acceptance criterion for the playbook-context concern. - Update module-level doc comment in mod.rs to reflect its actual role as facade + deferred hierarchy + tests (not "Core CRUD Operations"). - Add CompletenessResult to the services::mod.rs re-export; it was pub but not exported, leaving check_node_completeness's return type unreachable to external callers. - Fix stale field comment referencing old method name. Co-Authored-By: Claude <[email protected]>
After rebasing onto main (which merged #1237), propagate the SQLite-era cleanup into the decomposed sub-modules: - crud.rs: remove 5×50ms retry loop from create_node_with_parent sibling validation; single check is correct under SQLite ACID semantics - mod.rs (create_parent_edge): remove 10×100ms retry + 20×50ms position-verification loops; replace with a single move_node call and trust the result (SQLite commits before returning) No behavior change — these loops were dead code under SQLite as established by #1237. Co-Authored-By: Claude <[email protected]>
b340e50 to
9ee928a
Compare
…legation) (#1240) * Decompose NodeService god-object into focused sub-modules (closes #1238) Phases 1-3 and 5 of the decomposition plan. Phase 4 (Hierarchy extraction) is deferred pending #1237 merge to avoid collision on the retry-loop cleanup. `packages/core/src/services/node_service.rs` (11,891 lines) split into: - `node_service/mod.rs` (2,789 lines): struct definition with all fields as `pub(crate)`, construction (`new`, `seed_*`), accessors (`store()`, `behaviors()`, `with_client`), all hierarchy methods (Phase 4 deferred), `NodeAccessor` impl, shared helper fns, all tests unchanged - `node_service/crud.rs` (2,036 lines): create/get/update/delete + all CRUD private helpers (validation, schema defaults, lazy migration, compute_title) - `node_service/relationship.rs` (910 lines): mention ops + typed relationship CRUD + populate_mentions helper - `node_service/schema.rs` (454 lines): schema queries, task-node ops, get_all_schemas, get_schema_with_relationships, check_node_completeness - `node_service/bulk.rs` (596 lines): bulk_create, bulk_create_hierarchy*, bulk_update, bulk_delete - `node_service/query.rs` (322 lines): query_nodes, query_nodes_simple, property filter helpers - `node_service/embedding.rs` (228 lines): embedding waker + queue methods (all behind `#[cfg(feature = "nlp")]`) Phase 5: `with_execution_context` changed from `pub` to `pub(crate)` — the only caller (`playbook/actions.rs`) is in the same crate so no call-site changes needed. All external callers (daemon, agent, cli, playbook) unchanged — facade keeps every `pub async fn` with byte-identical signatures. Co-Authored-By: Claude <[email protected]> * Address review: rename scoped_for_playbook, fix CompletenessResult, update doc - Rename with_execution_context → scoped_for_playbook with a doc comment restricting use to crate::playbook; update the one call site in actions.rs. Fully closes the acceptance criterion for the playbook-context concern. - Update module-level doc comment in mod.rs to reflect its actual role as facade + deferred hierarchy + tests (not "Core CRUD Operations"). - Add CompletenessResult to the services::mod.rs re-export; it was pub but not exported, leaving check_node_completeness's return type unreachable to external callers. - Fix stale field comment referencing old method name. Co-Authored-By: Claude <[email protected]> * Post-rebase: apply #1237 retry-loop removal to sub-modules After rebasing onto main (which merged #1237), propagate the SQLite-era cleanup into the decomposed sub-modules: - crud.rs: remove 5×50ms retry loop from create_node_with_parent sibling validation; single check is correct under SQLite ACID semantics - mod.rs (create_parent_edge): remove 10×100ms retry + 20×50ms position-verification loops; replace with a single move_node call and trust the result (SQLite commits before returning) No behavior change — these loops were dead code under SQLite as established by #1237. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1238