Skip to content

Add isPlayRuleRejected frontend branch and toast presentation for rejected writes - #2654

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2648-play-rule-rejected-frontend
Sep 16, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2648-play-rule-rejected-frontend

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

core#2648's own scope was mostly already delivered as a side effect of core#2643/PR#2650 (the update_node invariant wiring): status_to_command_error's PLAY_RULE_REJECTED arm (nodes.rs), errors.ts's PlayRuleRejectedData/isPlayRuleRejected, the 'play-rule-rejected' conflictType + CONFLICT_MESSAGE placeholder, and updateNode()'s catch-block branch were all already on main. This PR closes the remaining gaps:

  • updateTaskNode()'s catch block — the primary path for this feature's own motivating example (a Task node status-change rejection) — had no isPlayRuleRejected branch. Added it, following this method's existing non-rollbackUpdate() recovery pattern (re-notify subscribers with whatever the store currently holds, since this method has no NodeUpdate history to unwind).
  • Audited every other conflictNotifications.add({..., conflictType: 'write-failure'}) call site in shared-node-store.svelte.ts for PlayRuleRejected reachability, documented inline per site:
    • deleteNode() — structurally unreachable: a synchronous invariant reject action only ever fires from create_node's/update_node's write paths (dispatch_invariant_rules_in_tx / dispatch_invariant_rules_for_update_in_tx are the only two callers); delete_node never runs that dispatch.
    • setNode() and persistBatchedChanges()/commitAllBatches() — reachable (both call backendAdapter.updateNode/createNode directly), but deliberately left on their existing generic-failure handling, matching how each site already treats OCC conflicts identically (their own catch (dbError) already strips .code/.conflictData before re-throwing, so there's nothing to branch on without a larger, separately-scoped restructure).
  • Test coverage:
    • dev-proxy-grpc-error-mapping.test.ts — added PLAY_RULE_REJECTED cases for mapGrpcError() (binary metadata mapping, non-ASCII preservation, non-brand on unrelated FAILED_PRECONDITION, malformed-JSON tolerance, precedence vs. SUBTREE_ACCESS_DENIED).
    • backend-adapter.test.ts — added the isPlayRuleRejected-through-HttpAdapter pass-through test, mirroring the existing isSubtreeAccessDenied one.
    • New play-rule-rejected-notification.test.ts — exercises updateNode() and updateTaskNode() end-to-end (mocked backendAdapter rejection → store catch → conflictNotifications), covering the correctly-typed toast with the rule's own message, no duplicate write-failure notification, and (for updateNode()) the rollbackUpdate() bookkeeping call via the rollbackCount metric.

Note for reviewers

NodeService::update_task_node's current backend implementation (schema.rs → SqliteStore::update_task_node) is a direct store write that does not go through update_node_in_tx/dispatch_invariant_rules_for_update_in_tx — so a task status-change rejection is not actually reachable through a real daemon today, only through create_node/update_node's generic path. The new updateTaskNode() branch is added anyway (matches the issue's explicit acceptance criteria and keeps this method's error handling forward-compatible/consistent with updateNode()'s), but wiring update_task_node into the synchronous invariant dispatch is backend work, out of scope here.

Test plan

  • bun run test:all — clean (frontend + skill + full Rust suite, including the pre-existing nodes.rs PLAY_RULE_REJECTED Rust tests)
  • bun run quality:fix — clean (eslint/svelte-check/tsc/cargo fmt/cargo clippy --all-targets -D warnings)
  • Pre-push gate (scripts/test-gate.ts) passed in full, including test:e2e and the Tauri-seam integration suite

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 16, 2026 14:15
… write-failure call sites

updateNode()'s catch block, errors.ts's isPlayRuleRejected, and the
'play-rule-rejected' conflictType were already wired by core#2643/#2650.
updateTaskNode() was missing the equivalent branch even though it is the
primary path for a task status-change rejection — add it, following this
method's existing non-rollbackUpdate() recovery pattern.

Audit the other conflictNotifications.add({..., conflictType:
'write-failure'}) call sites in shared-node-store.svelte.ts and document
each one's reachability inline: deleteNode() is structurally unreachable
(delete_node never dispatches invariant rules); setNode() and
persistBatchedChanges()/commitAllBatches() are reachable but deliberately
keep their existing generic-failure handling, matching how each already
treats OCC conflicts.

Extend dev-proxy-grpc-error-mapping.test.ts, backend-adapter.test.ts, and
add play-rule-rejected-notification.test.ts covering both updateNode() and
updateTaskNode() call sites end to end (backend-adapter mock through to the
surfaced toast).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Both outer-catch comments (updateNode(), updateTaskNode()) described the
shared flag as OCC-only, left stale once the PlayRuleRejected branches
started setting it too. Update the wording to name both cases.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Independent review: APPROVE. The reviewer verified every factual claim in the PR description directly against the pre-PR state of main and the daemon-side Rust source, and mutation-tested the new updateTaskNode() branch (disabled it, reran tests, confirmed exactly the 2 expected assertions fail, then reverted) to confirm the tests are real rather than vacuous. One non-blocking cosmetic nit was raised (a stale comment in updateTaskNode()'s and updateNode()'s outer-catch fallback that described occConflictAlreadyNotified as OCC-only, not mentioning the PlayRuleRejected case that also sets it) — fixed in the latest commit.

Merging.

@mstomar125
mstomar125 merged commit 600a326 into main Sep 16, 2026
@mstomar125
mstomar125 deleted the issue-2648-play-rule-rejected-frontend branch September 16, 2026 12:34
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.

1 participant