Skip to content

refactor: separate transition evaluation from commit - #224

Merged
rlippmann merged 2 commits into
mainfrom
preview_decouble
Aug 3, 2026
Merged

refactor: separate transition evaluation from commit#224
rlippmann merged 2 commits into
mainfrom
preview_decouble

Conversation

@rlippmann

@rlippmann rlippmann commented Aug 3, 2026

Copy link
Copy Markdown
Owner

What changed

Refactored transition execution so preview and committed execution share the same internal transition evaluation path.

Changes:

  • Added a private engine transition evaluation boundary that computes a proposed next state without mutating the live engine.
  • Updated Engine.step() to evaluate transitions first, then commit the resulting state.
  • Updated preview() to consume the same evaluation path instead of using snapshot, mutate, and restore behavior.
  • Removed preview's dependency on export_json() / import_json() round-tripping.
  • Updated preview tests to verify the intended non-mutating behavior rather than rollback implementation details.

Why the change was needed

preview() previously evaluated transitions by temporarily mutating the engine through the normal execution path and restoring the original state afterward.

Although behavior was preserved, this coupled audit/preview behavior to mutation and persistence mechanisms.

The new structure separates:

  • transition evaluation: determine decision and next state;
  • state commit: install the evaluated state.

This keeps preview non-mutating, ensures preview and execution share the same transition semantics, and creates a cleaner internal boundary for future transition metadata.

Checklist

  • pre-commit run (uv run pre-commit run --all-files)
  • tests pass (uv run pytest)

Closes #220

This refactor establishes the internal transition evaluation boundary that may support future transition metadata/diagnostics (#199), but does not implement diagnostics.

@rlippmann
rlippmann merged commit 1090812 into main Aug 3, 2026
18 checks passed
@rlippmann
rlippmann deleted the preview_decouble branch August 3, 2026 09:18
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.

Decouple preview/audit transition evaluation from mutating engine execution

1 participant