Skip to content

Playbooks under multi-device sync: build the core part of ADR-060 and ADR-073 #4285

Closed

Description

@mstomar125

Found while writing the decision nodes (#3729). ADR-060 and ADR-073 decide how playbooks behave under multi-device sync. The core part is not built: join-point suppression, causal depth across devices, and repair of a remote violation (playbook/validation.rs:1764). Election and server-side enforcement belong to Sync and are out of scope here.

Work

  • Read both records against the code and list exactly which core behaviours are missing.
  • Build them, each with a failing test first.
  • Then the decision node and the records state what is built.

Done when

The core part of both records is built and tested, and the records match the code.

Activity

  1. mstomar125 commented on Nov 17, 2026

    @mstomar125
    ContributorAuthor

    Design pass 2026-11-17 (read-only, core and sync origin/main): this issue is largely stale. Most of the core part of ADR-060 and ADR-073 is built and tested on main: invariant and reactive rule classes and the reject action; derived action identity (deterministic_action_output_id, actions.rs:987); stable ordering by play id; causal cycle depth on node writes (_playbookChainDepth and _playbookWriteId stamped by stamp_chain, read by chain_depth_of_write and effective_chain_depth, stopped at MAX_CHAIN_DEPTH = 10, with two-device in-process tests such as contradictory_invariants_ping_pong); repair of remote invariant violations for node create and update (dispatch_invariant_repair); the typed WriteContext { skip_playbook_triggers, skip_invariant_rules } that Sync sets on every pulled apply. validation.rs:1764 is now only a doc comment pointing at the runtime depth guard.

    Residual work (owner decisions taken as recommended unless overruled):

    1. Prove node-level reactive causal depth across two devices with a test (expected to pass; a failure would be a real bug), plus a derived-id convergence test.
    2. BUILD causal depth for relationship ADDS: stamp depth and nonce on the edge properties in the four relationship action paths and read it for RelationshipCreated, so an add/add cycle across devices stops at the limit. Removal chains cannot carry depth (a deleted edge has no surviving row): document that limit.
    3. Core contract test for the join point: a backlog context fires nothing; a live context fires reactive rules but not invariants. The join point itself (the cursor) belongs to Sync: filed in nodespace-sync.
    4. AMEND the records, no build: repair covers node writes only (no shipped Play uses a relationship invariant); the failure record is a tracing line, not a log node; the origin signal is the typed WriteContext, not the client id; ADR-073's 'structurally excluded' holds only for writes made through a service Sync builds with that context; the derived id is over rule, action index and iteration path; election and the non-idempotent declaration are Sync-owned and core has no seam yet.
  2. mstomar125 commented on Nov 17, 2026

    @mstomar125
    ContributorAuthor

    Update 2026-11-17 after the independent review of PR #4290: stage 2 (stamping causal depth on relationship adds) is dropped. It cannot bound a real cross-device chain: on the Sync wire edge properties are not carried (pushable_edge_row in nodespace-sync projects has_child to {order} and mentions to {}, member_of goes through a permission-only body, custom relationships are not pushed at all because the cloud CHECK allows only has_child, member_of and mentions), and the reserved keys would show up as undeclared columns in the relationship viewer. So the PR keeps the node-level proof test and the join-point contract test (no behaviour change), and states in code comments that relationship events carry no depth and cannot form a cross-device chain today. The remaining work for this issue is the ADR-060 and ADR-073 amendments (docs repo). If Sync ever carries edge properties, relationship-event depth can be revisited then.

  3. mstomar125 commented on Nov 17, 2026

    @mstomar125
    ContributorAuthor

    Correction to my previous comment (2026-11-17): it said that on the Sync wire relationship-event depth cannot cross devices and so a cross-device chain cannot occur. The reviewer and a check of the sync code (REPLICATED_APPLY_WRITE_CONTEXT in nodespace-sync src/echo.rs) show the actual reason: Sync applies every pulled change with playbook triggers skipped (skip_playbook_triggers: true, skip_invariant_rules: true), so no relationship trigger fires on a remote edge today. The wire facts (edge properties are not carried: has_child keeps order only, mentions none, member_of permission only, custom relationships do not sync) matter only if live remote changes are later allowed to fire triggers (nodespace-sync#1033): then a chain through relationship triggers would restart at depth 0 on each hop and would not be bounded by the stamp mechanism. That is why the stamp was not built now.

  4. mstomar125 commented on Nov 17, 2026

    @mstomar125
    ContributorAuthor

    Done as re-scoped. Merged: core #4290 (b2f9891): cross-device proof tests (a reactive chain across two in-process devices stops at the cycle limit; two devices deriving the same node converge by id) and the join-point contract test (backlog context fires nothing, live context fires reactive rules but not invariants), all deterministic, mutation-checked, run 15 times plus under load. Records: nodespace-docs#159 (27b9e8032) restates ADR-060 and ADR-073 to what the code does. Not built, by decision: relationship-event causal depth, because it cannot bound a real cross-device chain (Sync applies pulled changes with playbook triggers skipped, and edge properties do not cross the wire). One wording correction owed in the code comments added by #4290: they say relationship events carry no causal depth; the precise statement is 'no persisted depth' (inside one device the in-process context carries it): fix it the next time that file is touched. The open design question (whether live remote changes should fire Play triggers) is nodespace-sync#1033.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions