Skip to content

engine: static validation — unreachable states & dead branches (SPEC §2)#44

Merged
fruwe merged 1 commit into
mainfrom
engine-static-validation
Jul 1, 2026
Merged

engine: static validation — unreachable states & dead branches (SPEC §2)#44
fruwe merged 1 commit into
mainfrom
engine-static-validation

Conversation

@fruwe

@fruwe fruwe commented Jul 1, 2026

Copy link
Copy Markdown
Member

Closes #42. Implements fruwehq/harel#34 (§2); cases fruwehq/harel-conformance#11.

What

  • Unreachable states: collect_errors computes reachability from the root's initial over every initial/region-initial/on_events/after/choice target (conservative, guard-agnostic; entering a state implies its ancestors, whose edges are then also followed) and flags any declared state (≠top) that nothing can reach.
  • Dead branches: a guarded transition list or choice with an unguarded default branch that isn't last (later branches can never be selected). Generalizes the choice else-last rule.
  • Wired into CLI validate + the conformance static mode. Bumps to 0.0.3 (so the fetch picks up cases 26–28 on main).

Verify

  • Conformance: 60 pass incl. 26-unreachable / 27-dead-branch / 28-reachable-ok.
  • Zero false positives across all 28 conformance definitions + examples/* (verified before/after).
  • Unit: tests/test_static_validation.py (6 tests: unreachable, composite-initial-only OK, deep-target ancestors, orthogonal regions, dead branch, unguarded-last OK). Two existing fixtures (test_model, test_validator) had genuinely unreachable states → made reachable. 138 unit, ruff + mypy clean.

Note: 0.0.3 material (with submachines next); tag v0.0.3 once both land.

collect_errors now rejects (a) any declared state unreachable from the root's
initial (conservative, guard-agnostic reachability over initial/region-initial/
on_events/after/choice targets; entering a state implies its ancestors), and
(b) a guarded transition list or choice whose unguarded default branch is not
last (later branches dead). Wired into CLI validate + the conformance static mode.
Verified zero false positives across all 28 conformance definitions + examples.
Two unit fixtures had genuinely unreachable states — made them reachable. Bump 0.0.3.

Closes #42.
@fruwe fruwe merged commit c757422 into main Jul 1, 2026
2 checks passed
@fruwe fruwe deleted the engine-static-validation branch July 1, 2026 16:22
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.

engine: static validation for unreachable states & dead branches

1 participant