Repository navigation
Add isPlayRuleRejected frontend branch and toast presentation for rejected writes - #2654
Merged
Merged
Conversation
… 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]>
Contributor
Author
|
Independent review: APPROVE. The reviewer verified every factual claim in the PR description directly against the pre-PR state of Merging. |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core#2648's own scope was mostly already delivered as a side effect of core#2643/PR#2650 (the
update_nodeinvariant wiring):status_to_command_error'sPLAY_RULE_REJECTEDarm (nodes.rs),errors.ts'sPlayRuleRejectedData/isPlayRuleRejected, the'play-rule-rejected'conflictType+CONFLICT_MESSAGEplaceholder, andupdateNode()'s catch-block branch were all already onmain. 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 noisPlayRuleRejectedbranch. Added it, following this method's existing non-rollbackUpdate()recovery pattern (re-notify subscribers with whatever the store currently holds, since this method has noNodeUpdatehistory to unwind).conflictNotifications.add({..., conflictType: 'write-failure'})call site inshared-node-store.svelte.tsforPlayRuleRejectedreachability, documented inline per site:deleteNode()— structurally unreachable: a synchronous invariantrejectaction only ever fires fromcreate_node's/update_node's write paths (dispatch_invariant_rules_in_tx/dispatch_invariant_rules_for_update_in_txare the only two callers);delete_nodenever runs that dispatch.setNode()andpersistBatchedChanges()/commitAllBatches()— reachable (both callbackendAdapter.updateNode/createNodedirectly), but deliberately left on their existing generic-failure handling, matching how each site already treats OCC conflicts identically (their owncatch (dbError)already strips.code/.conflictDatabefore re-throwing, so there's nothing to branch on without a larger, separately-scoped restructure).dev-proxy-grpc-error-mapping.test.ts— addedPLAY_RULE_REJECTEDcases formapGrpcError()(binary metadata mapping, non-ASCII preservation, non-brand on unrelatedFAILED_PRECONDITION, malformed-JSON tolerance, precedence vs.SUBTREE_ACCESS_DENIED).backend-adapter.test.ts— added theisPlayRuleRejected-through-HttpAdapterpass-through test, mirroring the existingisSubtreeAccessDeniedone.play-rule-rejected-notification.test.ts— exercisesupdateNode()andupdateTaskNode()end-to-end (mockedbackendAdapterrejection → store catch →conflictNotifications), covering the correctly-typed toast with the rule's own message, no duplicatewrite-failurenotification, and (forupdateNode()) therollbackUpdate()bookkeeping call via therollbackCountmetric.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 throughupdate_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 throughcreate_node/update_node's generic path. The newupdateTaskNode()branch is added anyway (matches the issue's explicit acceptance criteria and keeps this method's error handling forward-compatible/consistent withupdateNode()'s), but wiringupdate_task_nodeinto 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-existingnodes.rsPLAY_RULE_REJECTEDRust tests)bun run quality:fix— clean (eslint/svelte-check/tsc/cargo fmt/cargo clippy--all-targets -D warnings)scripts/test-gate.ts) passed in full, includingtest:e2eand the Tauri-seam integration suite🤖 Generated with Claude Code