Repository navigation
Give plays a user-owned enabled switch and persist engine suspensions (closes #3444) - #3489
Conversation
Pragmatic Code Review — PR #3489Review Type: Initial Review (no prior reviews or comments on the PR) SummaryThis is a clear net improvement. The engine's run state is now derived from the play node in one function ( There are no blockers. Two narrow correctness gaps are worth fixing in this PR (findings 1 and 2), and the test suite never runs the subscriber and the rule processor together (finding 3). How I checked. I read the full diff and the surrounding code in Requirements Check
Code Review Findings🟡 Important1. The suspension-field guard and the clear-on-enable rule cover only one write path
Recommendation: put the guard in one helper that create and every update pipeline call, and add a create test next to 2. A rules edit on a subtype of
The engine still catches bad rules afterwards and suspends the play, so nothing invalid runs. The save is accepted where it used to be refused. Core ships no play subtype today, but the engine deliberately treats one as a play ( Recommendation: compute 3. No test runs the subscriber task and the rule processor together Every new engine test calls I traced it and believe it holds. A suspended node takes the park path in Recommendation: one 🟢 Suggestions4. A lagged subscriber leaves the in-memory status stale
5. A transient action failure is now a persistent outage with no in-app signal A version conflict in an 6. Rules of a deleted play still run from a queued work item
7.
8. The issue asks 9. Archiving a seeded invariant play no longer warns This follows ADR-087 §5 literally and a test pins it. ADR-087 §6 also says archiving is how a user turns a seed off, and the consequence is the same as switching it off: the invariant stops being enforced. Worth a product decision; no code change requested. Nit: What is done well
RecommendationAPPROVE No blockers. Findings 1 and 2 are small and should be fixed in this PR; finding 3 is the test I would add with them. I have not confirmed 1 or 2 by running code. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Review addressed (commits
|
| # | Finding | Outcome |
|---|---|---|
| 1 🟡 | Suspension guard and clear-on-enable covered one write path | Fixed. One helper, settle_play_update, runs on all four update pipelines and on bulk update. Create refuses a play that carries a suspension. |
| 2 🟡 | A rules edit on a subtype of play skipped the gate and didn't clear a suspension |
Fixed. The helper runs after re-bucketing, so the rules are read from the bucket they live in. Test with a schema extending play. |
| 3 🟡 | No test ran the subscriber and the rule processor together | Added an_action_failure_in_a_running_engine_suspends_the_play_until_it_is_enabled: real node create, failing action, suspension on the node, no version bump, play stops firing, enable brings it back. |
| 4 🟢 | A lagged subscriber left the run state stale | Fixed. On Lagged the engine reloads plays; a reload forgets plays no longer in the store's load. |
| 5 🟢 | A persistent suspension had no visible signal | Added a warning at load for each suspended play, with reason, time and diagnostic. |
| 6 🟢 | A deleted play's queued rule still ran | Fixed. A rule runs only while its play is known and running (is_running replaces is_parked). |
| 7 🟢 | Rules compiled under the write lock, and twice | Fixed. Compiled once in sync_play, before any lock; park_play and reindex_play take the compiled rules. |
| 8 🟢 | SKILL.md didn't name the switch |
Fixed, in one line: the file was 2 characters under its 5,000-token cap, so the detail stays in references/cli.md. |
| 9 🟢 | Archiving a seeded invariant play no longer warns | Skipped. It follows ADR-087 §5 as written and a test pins it. Whether archive should warn too is a product decision. |
| nit | play.enabled indexed |
Fixed: not indexed. |
One refinement while fixing #1. A write is refused when it would change a suspension field, not when it merely names one. An update that carries a field's stored value back unchanged is accepted. Clearing a recorded suspension by writing null is still refused: enabling the play is how it is cleared. cli.md and the node-types.md play sheet (nodespace-docs b31e7dd) say this.
Tests: the full Rust workspace suite passes (4,394 tests); frontend, scripts and generated-type checks passed in the same test:changed run. quality:fix is clean.
Re-Review Decision
Decision: RE-REVIEW NEEDED
Rationale: Findings 1, 2, 4 and 6 changed logic on the write path and in the engine (a new helper on five pipelines, a reload on lag, a stricter run check in the rule processor).
Pragmatic Code Review — PR #3489 (re-review)Review Type: Re-Review (commits Previous Review Summary: 9 findings plus 1 nit. 8 findings and the nit are addressed, 1 was skipped with a reason that holds. No new Critical or Important issues; 3 new suggestions and 1 nit, none blocking. How I checked. I read the diff Per-finding status
What I checked in the new logic
New FindingsA. 🟢 Suggestion —
Related, and unchanged from main: the three non-version-checked update pipelines and B. 🟢 Suggestion — the
C. 🟢 Suggestion — the refusal message can contradict the write it refuses The guard runs before the clear. A patch on a suspended play that sets Nit: RecommendationAPPROVE The two Important findings are fixed at the right layer, with tests that fail without the fixes. The new suggestions are edge cases that no current caller reaches. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Re-review addressed (commit
|
| Finding | Outcome | |
|---|---|---|
| A 🟢 | bulk_create creates a play with neither the suspension guard nor the rule gate |
Guard added: a batch create refuses a play carrying a suspension, with a test. Rule gate skipped: it was absent before this change, nothing reaches that path for plays, and the engine suspends an invalid play anyway. Revisit if a client ever creates plays in batches. |
| B 🟢 | The Lagged branch has no test; a reload reads a snapshot |
Skipped. A test needs to overflow the 4,096-event channel; the reload it calls is tested directly. The snapshot window heals on the next event, as the review notes. |
| C 🟢 | The refusal message can contradict the write it refuses | Fixed. A write that clears the suspension anyway (enabled: true, or changed rules) may also carry the suspension fields as null. Create has its own message. |
| nit | reenable_play has no production caller |
Removed. |
Tests: the full Rust workspace suite passes (4,394 tests) and quality:fix is clean.
Re-Review Decision
Decision: NO RE-REVIEW NEEDED
Rationale: The changes are a one-line guard on one more create path, a narrower refusal condition with a test for it, and the removal of an unused method. No design or control-flow change.
|
Merge queue: #3489 was taken out of the queue — it conflicts with main in: packages/core/src/services/node_service/schema.rs. Rebase onto origin/main, push, and re-run |
261f2a1 to
d20f859
Compare
…closes #3444) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
d20f859 to
350fde2
Compare
Closes #3444
What changed
A play now has its own user-owned switch,
enabled, and the engine's verdicts are suspensions recorded on the play node. Whether a play runs is one check (ADR-087 §5).Type:
playis a structured core type, category unchanged. No new type, relationship or structural rule.Fields added to the
playschemalocal_onlyenabledtruesuspended_reasonvalidation_failed,action_failed,cycle_limit,schema_drift(closed)suspended_messagesuspended_atPlayNodecarriesenabled,suspendedReason,suspendedMessageandsuspendedAt.PlayNodeUpdategainsenabled; the suspension fields are read-only.PlaySuspensionReasonis a new generated TypeScript type, and promoted fields gain a boolean shape.PlayStatus::of_node(participates, thenenabled, then not suspended) followed by rule validation, in one engine function (sync_play) used at startup, on create and on update. The engine no longer compares a play's lifecycle anywhere.NodeService::record_play_suspensionsets the three fields with no version bump and emits a node-updated event.enabledis never touched.enabled: true(even when it already is) or changesrulesclears the suspension; the engine re-validates and suspends again if the problem remains. A client write that names a suspension field is refused.ruleschange, so a switch-only write succeeds for a play whose rules a schema change has broken.enabledgoestrue → falseor the rules are edited. It no longer fires on other edits or on archive.playbook enable|disablewriteenabledthrough the typed play update.playbook listreports each play as on, off or suspended (with reason, time and diagnostic), with its lifecycle beside it, and addsstateto each node in--json. Archive is not folded into the state: the CLI doesn't interpretlifecycle_status.logsis gone from theplaybookhelp.references/cli.mdteachesenabled, the states and how to clear a suspension, and no longer teaches archiving as a play's switch.SKILL.mdneeded no change; the drift check passes.Found along the way
Schema-drift detection never ran.
handle_schema_updatedread the changed type fromproperties.schema.forNodeType, which nothing writes, so it returned before checking any play. It now uses the schema node's id (which is its type) andschemaVersion. This makes drift suspension live: a schema update that genuinely breaks a play's rules now suspends it withschema_drift. Additive changes still stop nothing.Not covered
A switch-only write still fails for a play whose stored
rulesdon't decode at all (a row written around the service layer), because the play behaviour decodes every field on each write. Rules that decode but no longer validate, which is what a schema change produces, are covered. The engine suspends an undecodable play either way.Docs
nodespace-docs
c6e0c32(direct to main):components/node-types.mdplay sheet (typed update, wire) andarchitecture/playbook-engine.mdschema-drift section. The rest of the playbook docs already described this design.Tests
enabledon, bumps no version and emits an event; enabling or saving fixed rules clears it; a still-broken play is suspended again; a parse failure on update suspends.🤖 Generated with Claude Code