Repository navigation
Description
Problem Statement
rule_id_for(play_id, actions) (packages/core/src/playbook/actions.rs) derives a playbook rule's identity for the ADR-060 §3 / ADR-074 derived-identity formula from (play_id, the rule's own parsed action list) rather than a positional index (see the module doc in actions.rs for why -- the alternative needs an engine.rs call-site change that was off-limits for the PR that introduced this).
A consequence: two DIFFERENT rules in the SAME play with byte-identical action lists collide onto the same rule_id, and therefore the same derived output id for a given (action_index, iteration_path). This is not a narrow edge case -- the realistic trigger is copy-paste rule authoring: duplicate a rule, change its trigger or condition, leave the action list untouched. The two rules don't even need to fire from the same event; they only need to eventually act on the same node (e.g. rule A fires on node_created, rule B fires later on property_changed for that same node, landing on the same iteration_path and action_index).
The failure mode is worse in kind than the bug the derived-identity mechanism itself fixes: not a visible duplicate node and not an error, but a silent incorrect merge. execute_create_node's existing-node-at-derived-id check (the intended convergence path for a genuine re-fire of the same rule) cannot distinguish that case from two different rules colliding, so it treats rule B's output as "already converged" and quietly returns rule A's node -- no error, no log, no visible symptom. See packages/core/src/playbook/actions.rs's two_rules_with_identical_actions_silently_share_one_output_node test (added to make this explicit) for the behavior as it stands today.
Proposed Solution
Add a save-time check in packages/core/src/playbook/validation.rs (the existing home for save-time Play/rule eligibility checks, e.g. invariant-rule eligibility per ADR-060 §2) that detects two rules within the same play whose action lists are byte-identical (same serialized shape rule_id_for would hash) and either:
- rejects the save with a clear error naming the offending rules, or
- warns (surfaced to the user at save time) without blocking the save,
whichever matches the severity bar already used for adjacent save-time checks in that file. Reject is likely more correct given the failure mode is a silent data-loss-adjacent merge, not just a style issue -- but defer to whatever precedent validation.rs already sets for comparable severity.
Acceptance Criteria
- Saving a play with two rules in its
rulesarray whose action lists are byte-identical (sameaction_type,params, andfor_eachsequence) is caught at save time - The check is scoped to rules within the SAME play (cross-play byte-identical action lists are already distinguished by
play_idinrule_id_forand are not part of this gap) - Test: two rules with identical actions but different triggers/conditions in one play is rejected (or warned, per whichever severity is chosen) at save time
- Test: two rules with even slightly different actions (e.g. different
contenttemplate) in one play is allowed -
bun run test:allpasses,bun run quality:fixpasses
Reference Files
packages/core/src/playbook/actions.rs--rule_id_for, module doc section "Derived Identity (ADR-060 §3, ADR-074)", and thetwo_rules_with_identical_actions_silently_share_one_output_nodetest demonstrating today's silent-merge behaviorpackages/core/src/playbook/validation.rs-- existing save-time Play/rule validation (ADR-060 §2 invariant-rule eligibility checks live here already)../nodespace-docs/decisions/060-playbook-execution-under-multi-device-sync.md§3,../nodespace-docs/decisions/074-derived-identity-for-scan-based-triggers.md
Non-Goals
- Changing
rule_id_for's derivation itself (content-hash-based rather than a positional index) -- that is a separate, deliberate choice documented inactions.rs's module doc, made necessary by anengine.rsscope constraint on the PR that introduced derived identity. This issue is about catching the collision at save time, not about avoiding the design that makes it possible.
Activity
mstomar125 commentedon Sep 17, 2026
Frontend baseline: 247 test files / 5085 tests passed.
Fix delimiter-injection hole in action_list_signature
Reject same-play rules with byte-identical action lists at save time (#…