Repository navigation
Playbooks across devices: cross-device proof tests and the join-point contract test - #4290
Merged
Merged
Conversation
The invariant tests show the persisted depth bounds an exchange of repairs. A reactive rule chain crosses devices through the live write context instead (triggers on, invariants skipped), and nothing proved that path stops. Two services, each with its own engine, and a relay applying each side's local writes on the other now run a flip-flop chain to MAX_CHAIN_DEPTH and suspend the play that would take the next hop. A second test covers derived ids: two devices running the same rule on the same trigger node derive the same id but mint different write nonces. They converge by id, and applying each copy on the other reads as the same one-hop chain and moves nothing further. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…across devices stop A relationship_added rule that adds an edge restarted at depth 0 on every device hop: chain_depth_of_write read only node writes, and the add_relationship actions stamped nothing, so a cycle that crossed devices through relationship triggers never reached MAX_CHAIN_DEPTH. The failing test ran a remove-and-add-back cycle over two devices to over 30000 edge writes. The add paths (plain and in-transaction) now stamp the depth and a fresh write nonce into the edge's properties, and chain_depth_of_write reads them from a RelationshipCreated, which effective_chain_depth already consumes. Edge ids are deterministic, so adding a stored edge again writes nothing and emits no event; a chain stops there by itself, and only a created edge carries a stamp onward. No schema change and no backfill: an edge without the keys reads as depth 0, a fresh chain. Removal chains stay unbounded by this mechanism: a deleted edge leaves no row to carry a depth. That is stated at the removal actions and in chain_depth_of_write. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Which context a pulled write is applied with is the apply layer's decision, made at the join between catching up on history and following live changes. Core only honours the context a service was built with, and that contract was spread over tests that each covered one half. One test now reads it whole: the backlog context fires no reactive rule and runs no invariant, the live context fires reactive rules but runs no invariant in the write's transaction, and an ordinary write is refused by the invariant (control). No behaviour change. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… cycles across devices stop" This reverts commit cf78539.
… state The quiescence window (20 unchanged polls) could fail on a loaded gate machine that was merely slow. The tests now wait up to 30 s for the state the chain must reach (both devices at the depth limit and a suspended play; the derived nodes present; the play active before the writes), and only then check over a short window that no further writes happen. That window can only turn a runaway into a pass on a slow machine, never a pass into a failure. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The comments said the wire facts alone made a cross-device relationship chain impossible. The real reason is that the apply layer applies replicated changes with playbook triggers skipped; the wire facts (edge properties do not cross) matter only if live remote changes ever fire triggers. Comments only. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4285-playbook-depth
branch
from
November 17, 2026 13:18
5d3223e to
1ee8936
Compare
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.
Part of #4285 (the residual core work after the design pass found most of ADR-060 and ADR-073 already built). Tests and comments only; no behaviour change.
Proof tests (all passed on main, no bug found). Two NodeServices over separate databases, each with its own PlaybookEngine, and a relay applying each side's committed writes on the other with the playbook triggers on and invariants skipped:
Contract test. One named test reads the join-point contract in one place: the backlog context (both skips set) fires no reactive rule and runs no invariant, the live context fires reactive rules but runs no invariant in the write's transaction, and an ordinary write is refused (control). Its doc comment says the join-point decision belongs to the apply layer.
The tests wait for a positive terminal state (up to 30 s) and only then check over a short window that no further writes happen, so a loaded machine cannot cause a false failure.
Relationship-event depth is deliberately not built. Today a chain through relationship triggers cannot hop devices, because the apply layer applies replicated changes with playbook triggers skipped. If live remote changes were ever allowed to fire triggers, such a chain would restart at depth 0 on each hop and would not be bounded by this mechanism, because edge properties do not cross the Sync wire (has_child keeps order only, mentions none, member_of permission only, custom relationships do not sync). A first version that stamped the depth on the edge was dropped for that reason, and because its reserved keys would surface in the relationship viewer. chain_depth_of_write and the relationship actions carry a comment stating this.
The ADR-060 and ADR-073 amendments follow in the docs repo.
Verification: bun run test:changed passed (rust and scripts tiers), clippy -D warnings and fmt clean; each new test was mutation-checked and run 15 times with no retries.
🤖 Generated with Claude Code