Skip to content

Pare back #1736 to the generic access-gate seam only (#1870) - #1875

Merged
malibio merged 1 commit into
mainfrom
issue-1870-pare-back-access-gate
Aug 1, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-1870-pare-back-access-gate

Conversation

@malibio

@malibio malibio commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

PR #1868 landed the full vertical slice for the access-gated cascade delete: a SubtreeAccessGate trait + AlwaysAllowGate default, plus a complete error-propagation chain (NodeServiceError::InaccessibleDescendants, an OpsError variant, a dedicated gRPC FailedPrecondition status, a Tauri CommandError code, and a terminal frontend refusal modal) for a Denied state no caller in this codebase can produce today.

This PR pares that back to exactly the generic, already-wired seam:

Kept (unchanged in shape):

  • SubtreeAccessGate trait, SubtreeAccessDecision enum, AlwaysAllowGate
  • The OnceLock-based injection point (set_subtree_access_gate / subtree_access_gate()) on NodeService
  • The collect_subtree_ids / delete_subtree_atomic signature refactor (computes the subtree id set once, shared between the gate check and the delete)
  • The delete_node call site still invokes the gate — a Denied decision now maps to the existing NodeServiceError::HierarchyViolation as a placeholder, until a real Pro gate lands with its own typed error and UI treatment

Removed (product-surface plumbing built only against a synthetic test gate):

  • NodeServiceError::InaccessibleDescendants, OpsError::InaccessibleDescendants + conversion
  • The x-inaccessible-descendants gRPC status mapping in packages/daemon/src/services/node_service.rs
  • The INACCESSIBLE_DESCENDANTS CommandError code path in packages/desktop-app/src-tauri/src/commands/nodes.rs
  • The frontend refusal modal state (pendingRefusal, showInaccessibleDescendantsRefusal, the terminal UI in delete-confirmation-modal.svelte, isInaccessibleDescendants in errors.ts)
  • reactive-node-service.svelte.ts's deleteNode reverts to optimistic-for-leaf-nodes behavior (no unconditional await) — that non-optimistic behavior was motivated entirely by the refusal case

The full error/gRPC/frontend wire-up is tracked as part of nodespace-cloud#103's scope, to land together with the real Pro RPC once there's an actual gate to test the refusal path against end-to-end.

Test plan

  • bun run test — 170 files / 4097 tests passing (baseline was 4102; the 5 removed tests were refusal-UI-specific)
  • cargo test --lib --bins --tests --workspace --exclude nodespace-app --exclude nodespace-app-test-support — all passing, including the 4 gate/OCC-precedence tests in node_service/mod.rs (now asserting HierarchyViolation instead of the removed typed error) and the 2 access_gate module tests
  • bun run quality:fix — clean
  • Pre-push gate (test:all + cargo build --bin nodespaced + test:e2e + cargo test -p nodespace-app) — passing

Closes #1870.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DkqjrfV1G6kugsEjvyU9wU

PR #1868 landed the full vertical slice: SubtreeAccessGate trait +
AlwaysAllowGate default, plus a complete error-propagation chain
(NodeServiceError::InaccessibleDescendants, an OpsError variant, a
dedicated gRPC FailedPrecondition status, a Tauri CommandError code,
and a terminal frontend refusal modal) for a Denied state no caller
in this codebase can produce today.

Keeps the generic, already-wired seam: SubtreeAccessGate trait,
AlwaysAllowGate, the NodeService injection point, and the
collect_subtree_ids/delete_subtree_atomic refactor. Removes the
product-surface plumbing built only against a synthetic test gate:
the typed error, gRPC status mapping, Tauri command code, and
frontend refusal modal/state. The delete_node call site keeps
invoking the gate, but a Denied decision now maps to the existing
HierarchyViolation error as a placeholder until a real Pro gate
lands with its own typed error and UI treatment.

reactive-node-service.svelte.ts's deleteNode reverts to
optimistic-for-leaf-nodes behavior (no unconditional await), since
the non-optimistic path existed solely to protect the now-removed
refusal UX.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This is a precise, well-executed pare-back. I independently re-derived the diff against origin/main, cross-checked every removal against issue #1870's acceptance criteria, grepped the whole repo (Rust/TS/Svelte) for orphaned references to the removed feature, byte-diffed the reverted frontend function against its pre-#1868 ancestor, and ran both test suites plus cargo clippy on all three touched Rust crates locally. Everything matches what was asked for, nothing extra was touched, and nothing was left dangling. This is a net positive, low-risk, mechanical revert — clean to merge as-is.

Requirements Check (issue #1870)

  • ✅ SubtreeAccessGate trait, SubtreeAccessDecision, AlwaysAllowGate, and the OnceLock injection point are unchanged — confirmed git diff origin/main...HEAD -- packages/core/src/services/node_service/access_gate.rs is empty.
  • ✅ collect_subtree_ids / delete_subtree_atomic refactor untouched — confirmed git diff origin/main...HEAD -- packages/core/src/db/sqlite_store/nodes.rs is empty.
  • ✅ NodeServiceError::InaccessibleDescendants, OpsError::InaccessibleDescendants + conversion, the x-inaccessible-descendants gRPC metadata mapping, and the INACCESSIBLE_DESCENDANTS Tauri CommandError code path are all removed — verified in error.rs, ops/mod.rs, packages/daemon/src/services/node_service.rs, and packages/desktop-app/src-tauri/src/commands/nodes.rs.
  • ✅ Frontend refusal modal state fully removed: pendingRefusal/showInaccessibleDescendantsRefusal gone from delete-confirmation.svelte.ts, the terminal UI block gone from delete-confirmation-modal.svelte, isInaccessibleDescendants/InaccessibleDescendantsData/InaccessibleDescendantsCommandError gone from errors.ts.
  • ✅ reactive-node-service.svelte.ts's deleteNode reverts to optimistic-for-leaf-nodes behavior — I diffed it directly against git show 3127b79d^:...reactive-node-service.svelte.ts and it is byte-identical to the pre-Gate cascade delete on subtree read access (ADR-041) #1868 version (no unconditional await, sharedNodeStore.deleteNode(nodeId, viewerSource) called without the skipPersistence arg).
  • ✅ The four gate/OCC-precedence tests in node_service/mod.rs (test_delete_node_refused_when_subtree_has_restricted_descendant, test_delete_node_succeeds_when_subtree_fully_readable, test_delete_node_version_conflict_still_wins_over_access_gate, test_delete_node_occ_on_readable_descendant_unaffected_by_gate) are present, still inject the DenyIfPresentGate stub, and assertions were updated to NodeServiceError::HierarchyViolation(_) consistently. All pass locally.
  • ✅ delete_node's call site (packages/core/src/services/node_service/crud.rs) still invokes self.subtree_access_gate().check_subtree_access(&subtree_ids).await and maps Denied to NodeServiceError::hierarchy_violation(format!("subtree contains {N} node(s) not accessible to the current actor")) — a real, pre-existing error variant, not a stub. This is a sensible placeholder choice per the issue's explicit "needs a decision" callout: the gate stays provably wired to something real (not dead), HierarchyViolation already had a From<NodeServiceError> for OpsError mapping before this PR (so nothing new needed at the daemon/ops boundary), and it falls through to the existing generic GRPC_ERROR Tauri code — appropriately generic for a state no caller can produce today.
  • ✅ bun run test: 170 files / 4097 tests passed (matches PR's claimed baseline arithmetic: 4102 − 5 removed = 4097).
  • ✅ cargo test --lib -p nodespace-core node_service: 102 passed, including all four gate tests.
  • ✅ cargo clippy -p nodespace-core, -p nodespace-daemon, -p nodespace-app: all clean, no warnings.

Findings

Critical Issues

None.

Suggested Improvements

None. The doc comment above delete_node in crud.rs was properly rewritten (no long dangling references to the removed InaccessibleDescendants type — it now says "a hierarchy violation error is returned" and explicitly notes "A typed refusal error, wire status, and UI treatment for this case land with the real Pro gate wire-up," which correctly signals the placeholder nature without over-promising). No #[allow(dead_code)], no backward-compat shims, no stray orphaned references anywhere in Rust/TS/Svelte (verified via repo-wide grep for InaccessibleDescendants, inaccessible_descendants, x-inaccessible-descendants, showInaccessibleDescendantsRefusal, isInaccessibleDescendants, pendingRefusal, mockShowInaccessibleDescendantsRefusal — zero hits).

Nitpicks

  • Nit: packages/core/src/services/error.rs's hierarchy_violation message format ("subtree contains {N} node(s) not accessible to the current actor") is a slight behavior change from the old disclosure-conscious copy ("This contains {N} items you don't have access to") — worth noting only because HierarchyViolation's doc comment/other call sites may not all share this same disclosure discipline. Not a blocker since this error currently has no live caller path (AlwaysAllowGate is the only implementation in the codebase today) — just flagging for whoever picks up the real Pro wire-up to re-review the message text against the disclosure rule at that point.

Recommendation: APPROVE

This PR does exactly what issue #1870 asked, verified line-by-line against the acceptance criteria, with zero scope creep (the two untouched files were confirmed to have literal zero diff) and zero orphaned references. Both test suites and clippy are clean. Merge is the user's call, but from a correctness/completeness standpoint this is ready.

@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.

Review complete — recommendation: APPROVE (see detailed report above). Note: could not submit a formal --approve review since this PR is authored by the same account as the reviewer session (GitHub blocks self-approval); posting as --comment instead. Full findings in the PR comment above.

@malibio

malibio commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Review response

Reviewed the findings from the pragmatic-code-review above.

No code changes made — nothing in this review requires a PR update.

@malibio
malibio merged commit c2edd69 into main Aug 1, 2026
2 checks passed
@malibio
malibio deleted the issue-1870-pare-back-access-gate branch August 1, 2026 07:44
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.

Pare back #1736 to the generic access-gate seam only (no Pro-only error/UI plumbing in community core)

1 participant