Skip to content

Node state-transition model#263

Open
pinodeca wants to merge 2 commits into
mainfrom
node-transition-model
Open

Node state-transition model#263
pinodeca wants to merge 2 commits into
mainfrom
node-transition-model

Conversation

@pinodeca

Copy link
Copy Markdown
Contributor

Summary

Introduces a formal node & instance state-transition model for pg_durable, then implements it. This consolidates two related node-status gaps:

What's here now

The first commit adds the design proposal: docs/node-state-model.md. It defines:

  • Instance and node lifecycle states and their legal transitions (mermaid diagrams).
  • A coarse, stable status set (pending, running, completed, failed, skipped, cancelled) plus a nullable status_reason (upstream_failed, branch_not_taken, race_lost, scope_cancelled) — avoiding an ever-growing enum under the strict schema-upgrade contract.
  • Per-construct outcomes (THEN/IF/LOOP/JOIN/RACE/BREAK).
  • Loop iteration-scoping: how a single mutable df.nodes row behaves across continue_as_new, and the body-subgraph reset that prevents stale terminal marks leaking between iterations.
  • Prior-art alignment with Airflow (TaskInstance states), Temporal (event history + ContinueAsNew), BPMN 2.0 (withdrawn), and AWS Step Functions.
  • How the model resolves No "skipped" indication for downstream steps after a step fails #240 (pending → skipped terminal sweep) and df.instance_nodes leaves race-loser nodes running or pending after race completion #171 (running → cancelled subtree reconciliation at race resolution).

Plan

This PR starts as a design proposal for review. After incorporating colleague feedback, the implementation (status set additions, status_reason column, race-loser reconciliation, and loop-reset) will land on this same PR.

Upgrade & migration

The model is explicit about backward compatibility: new status/status_reason require install + upgrade DDL, and every reconciliation activity must no-op gracefully against schemas that predate the relevant column/status (the schema-probe pattern already used for skipped).

@pinodeca pinodeca changed the title Implement node state-transition model (#171, #240) Node state-transition model Jun 23, 2026
pinodeca added a commit that referenced this pull request Jun 23, 2026
The proposal previously framed the #240 skipped-node work as part of
'this PR'. That work landed earlier in PR #249; this PR (#263) defines
the consolidated state model and adds the remaining implementation
(cancelled, status_reason, race-loser reconciliation, loop reset).
Adds docs/node-state-model.md, a design proposal consolidating the
node-status work for issues #240 (skipped downstream nodes) and #171
(race-loser nodes left running/pending). Defines instance and node
lifecycle states, legal transitions, a coarse status set plus nullable
status_reason, loop iteration-scoping/reset semantics, and prior-art
alignment with Airflow/Temporal/BPMN/Step Functions.

The #240 skipped-node work shipped earlier in PR #249; this PR (#263)
defines the consolidated model and will add the remaining implementation
(cancelled, status_reason, race-loser reconciliation, loop reset) after
review.

Design only; implementation to follow on this PR.
@pinodeca pinodeca force-pushed the node-transition-model branch from 68283e0 to 44c171e Compare June 23, 2026 16:24
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.

df.instance_nodes leaves race-loser nodes running or pending after race completion

1 participant