Skip to content

Evaluate a write without making it, filter a saved query by what the rules would permit, and sort any enum by its declared order #3559

Closed

Description

@malibio

Overview

A saved query that lists "what can be started" has to restate the conditions the gate Plays already hold, and the two can drift when someone edits a rule. This issue lets a write be evaluated against the rules without being made, and lets a saved query keep only the nodes for which a stated change would not be rejected, so a view follows the rules as they stand. It also makes sorting by an enum follow the schema's declared order for every enum, not only priority.

Problem Statement

  • No dry run. Nothing can ask "would setting this task's status to in_progress be rejected?" The workflow-state read evaluates a node as it stands and cannot take a proposed value.
  • Views restate rules. The seeded "Ready tasks" query states the blocker and plan-approval conditions itself. A user who edits or switches off the gate Play changes what can be started and not what the view shows.
  • Rank sort is hard-coded. Sorting by priority on task and project uses a built-in rank; every other enum sorts alphabetically by stored value, so a status column sorts cancelled, done, in_progress, in_review, open.

Proposed Solution

  • Dry run. A write can be asked for as a dry run. The invariant rules that would run are evaluated against the proposed change, and the result says whether it would be rejected and with what message. Nothing is written.
  • permitted filter. A saved-query filter that keeps the nodes for which a stated property change would not be rejected, evaluated as a dry run per candidate after the query's other filters.
  • Enum order. Sorting by any enum field orders by each value's position in the schema's declared values.

When the filter exists, the seeded "Ready tasks" query drops its restated conditions.

Documentation

  • ADR-094 §9 - the dry run and the permitted filter, what they predict and their limits; rank sort for any enum; Build order steps 6 and 7
  • ADR-060 - invariant rules: synchronous, in the write transaction, originating device only
  • ADR-092 §7 - the Ready query states its conditions until this exists
  • Playbook engine - notes there is no dry-run mode today
  • Updates: architecture/playbook-engine.md and architecture/playbook-system.md (dry run), the saved-query docs (the permitted filter, enum order), packages/skill/references/cli.md

Architecture Impact

Implements ADR-094 §9. No decision changes. ADR-092 §7's interim statement of conditions in the Ready query is removed when the filter lands.

Acceptance Criteria

Dry run

  • nodespace node update and nodespace node set-status accept a dry-run flag; the result says allowed or rejected, and on rejection carries the rule's message, play and rule name; nothing is written and no version changes
  • The dry run evaluates the same rules, with the same condition inputs, as the real write: a property-changed event with the stored value as old and the proposed value as new
  • It uses the one invariant execution path in a conditions-only mode; there is no second implementation of rule matching
  • A condition that cannot be resolved is reported as such and treated as a rejection, as on a real write
  • No action other than reject is executed; the dry run predicts rejections only, and the docs say so
  • The built-in agent's update tool accepts the same flag

permitted filter

  • A saved query can include a filter naming a property and a value; it keeps the nodes for which that change would not be rejected
  • It is evaluated after the query's other filters, and sort and limit apply to what it keeps
  • A candidate whose rules cannot be resolved is excluded and counted in the result, and the query does not fail
  • A Play's scheduled selector refuses a saved query that uses it, as it refuses relative dates
  • Switching off or editing a gate Play changes what the filter keeps, with no change to the query
  • The seeded "Ready tasks" query uses the filter for the change to in_progress and no longer states the blocker or plan conditions; the tests that pinned those conditions now pin the behaviour through the rules

Enum order

  • Sorting by an enum field orders by the position of each value in the schema's declared core values followed by user values, for any enum on any type, ascending and descending
  • priority on task and project sorts as it does today, through the same generic path; the hard-coded rank is removed
  • A value not in the schema's list sorts last

General

  • references/cli.md documents the dry-run flag; bun run skill:check passes
  • Docs updated as listed under Documentation
  • Code passes bun run quality:fix
  • Tests pass (bun run test:changed)

Technical Specifications

Reference Files

  • packages/core/src/services/node_service/invariants.rs - execute_matched_invariant_rules_in_tx, the one invariant execution loop, and how conditions are resolved
  • packages/core/src/playbook/workflow_state.rs - current-state evaluation; trigger.property.* is deliberately absent there
  • packages/core/src/playbook/cel.rs, packages/core/src/playbook/actions.rs - condition inputs and the reject action
  • packages/core/src/playbook/selectors.rs - where a selector refuses query forms it cannot run
  • packages/core/src/services/query_service/mod.rs - filters, and the hard-coded priority rank sort
  • packages/nodespace-types/src/query.rs, packages/nodespace-types/src/priority.rs
  • packages/cli/src/commands/node.rs

Implementation Details

  • Confirm what a real invariant evaluation sees for the trigger node's own row (stored or proposed) and reproduce it exactly in the dry run.
  • The result is a prediction. The graph can change between the dry run and the write, and the rule on the write is what decides; say so in the CLI help.
  • A permitted filter costs a rule evaluation per candidate. Evaluate it last.

Dependencies

Related Issues

Non-Goals

  • Predicting failures of actions other than reject
  • A dry run of reactive or scheduled rules

Activity

  1. malibio commented on Oct 5, 2026

    @malibio
    CollaboratorAuthor

    Baseline — Frontend: 322 test files passed, 5875 tests passed

  2. self-assigned this
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions