Repository navigation
Description
Follow-up to #1247 (C2). Spun off from architectural-audit #1228. Do not start until #1247 is merged.
Context
#1247 (C2) makes structureTree the single source of truth for hierarchy: it deletes the mirror-only Node.parentId writes, unifies the two sync paths, and demotes parentId to a read-through accessor (getParentId(nodeId) → structureTree.getParent). It deliberately stops short of removing the parentId field from the Node type itself.
This issue finishes that: remove the Node.parentId field entirely.
Why it was deferred from #1247
SharedNodeStore.getNode() returns a live reference into the nodes Map, and Node is a plain serialized object produced in several places (the wire shape from backend-adapter, loadChildrenTree reconstruction, OCC snapshots via { ...node }). So parentId can't become a derived getter without addressing the type boundary and serialization layer — too invasive to combine with the sync-unification work.
Scope
- Remove
parentIdfrom theNodetype definition. - Audit the remaining references (after C2: Make structureTree the single source of truth for hierarchy — unify dual sync paths + invariant check #1247 there should be only the wire/serialization layer + any documented wire-only CREATE write):
backend-adapter.ts, the RPC payload builders,loadChildrenTreereconstruction, OCC snapshot paths. - If the backend CREATE/MOVE RPC genuinely needs a parent on the wire, pass it explicitly as an RPC argument derived from
structureTree.getParent(nodeId)at call time — not as a field carried on the in-memoryNode. - Decide auto-repair: C2: Make structureTree the single source of truth for hierarchy — unify dual sync paths + invariant check #1247's invariant check is detect-and-log/throw only. If we want the init-time check to repair orphan/dual-parent edges rather than just flag them, scope that here (optional — split again if it grows).
Acceptance criteria
-
Nodetype has noparentIdfield;grep -rn "\.parentId" packages/desktop-app/srcreturns only structureTree-internalparentIdparameters (theMap<parentId, ...>API), noNode.parentIdreads/writes. - All hierarchy parent reads go through
structureTree.getParent/getParentId. - Backend create/move payloads derive parent from structureTree at call time.
-
bun run checkclean;bun run test:allgreen (no new failures).
Standard NodeSpace startup / PR sequence
EnterWorktree({name: "issue-<N>-c2b-remove-parentid-field"}); bun install; bun run test baseline; bun run gh:assign/gh:status. createLogger only, no any, bun run test not bun test. Before PR: bun run test:all + bun run check, bun run quality:fix (revert unrelated reformats), bun run gh:pr <N>, /pragmatic-code-review, then ExitWorktree + gh pr merge --squash --delete-branch.
Spun off from #1228 (architectural audit), finding C2 (follow-up C2b). Blocked on #1247.
Activity
malibio commentedon May 30, 2026
Frontend baseline: 132 files, 3922 tests passed
C2b: Remove Node.parentId field — structureTree is single source of t…