Skip to content

Playbook rule class + save-time invariant eligibility gate (ADR-060 Slice A) - #1773

Merged
mstomar125 merged 1 commit into
mainfrom
issue-1739-rule-class-eligibility
Jul 28, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-1739-rule-class-eligibility

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Part of #1739 — Slice A of 4 implementing ADR-060 (invariant vs reactive playbook rules). This slice is behavior-neutral: it adds the rule class and a save-time validation gate, with no execution change (and no invariant rules are seeded yet).

Change

  • RuleClass { Invariant, Reactive } on the rule model, default Reactive (#[serde(default)]), so every existing rule and stored definition is unchanged.
  • Save-time eligibility gate (validation.rs), run only for invariant rules, rejecting a rule that violates ADR-060 §2 and naming the offending action:
    • Local writes only — exhaustive ActionType::is_local_write() (a future non-local type won't compile until classified, so it can't silently become invariant-eligible).
    • Deterministic — rejects a condition using a wall-clock CEL function; NON_DETERMINISTIC_FUNCTIONS is exactly the set CEL registers (today/days_since/days_until), the only non-deterministic surface (action params are pure {binding} data refs; no random fn exists).
    • Same-graph scope — rejects a literal target node id (addresses an arbitrary, sync-state-dependent node); trigger-derived {binding} targets are in scope.
    • Non-chaining depth-1 — enforces the statically-decidable self-chaining case; the general cross-rule/multi-device case is deferred to the runtime causal-depth guard (ADR-060 §5, Slice B), documented in the validator.

Tests

+16 tests: class parse/default, each rejection path (naming the action/function), a valid invariant rule accepted, and the same rule accepted as Reactive but rejected as Invariant (reactive-unaffected). cargo test -p nodespace-core = 996 lib + integration green; clippy -D warnings + fmt clean.

Next slices (own PRs)

B = synchronous pre-commit invariant execution in the create transaction; C = repair-and-log for remote violations (§7); D = seeded-playbook protection (§8). §6 (DB-side enforcement) is a separate cloud task.

…ibility gate (#1739)

ADR-060 Slice A. Introduce RuleClass { Invariant, Reactive } (default Reactive, so
every existing rule is unchanged and this slice is behavior-neutral — no execution
change, and no invariant rules are seeded yet). Add a save-time gate that rejects an
invariant rule violating ADR-060 §2 eligibility, naming the offending action:
local-writes-only (an exhaustive ActionType classification), deterministic (rejects a
condition using the wall-clock CEL functions — the only non-deterministic surface),
same-graph scope (rejects a literal target node id), and the statically-decidable
self-chaining case of non-chaining depth-1. The general cross-rule / multi-device
chaining case is deferred to the runtime causal-depth guard (Slice B / ADR-060 §5),
documented in the eligibility validator.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mstomar125
mstomar125 merged commit 4e368e7 into main Jul 28, 2026
2 checks passed
@mstomar125
mstomar125 deleted the issue-1739-rule-class-eligibility branch July 28, 2026 11:37
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