Files
cleveragents-core/features/decision_persistence_serialization.feature
T
brent.edwards 32b81793a2 refactor(test): rename decision persistence files to avoid conflict with master
Rename our serialization-focused decision persistence suites to
*_serialization to avoid add/add conflicts with the repository-based
decision persistence suites that landed on master independently:

- decision_persistence.feature -> decision_persistence_serialization.feature
- decision_persistence_steps.py -> decision_persistence_serialization_steps.py
- decision_persistence_bench.py -> decision_persistence_serialization_bench.py
- decision_persistence.robot -> decision_persistence_serialization.robot
- helper_decision_persistence.py -> helper_decision_persistence_serialization.py

Updated robot helper path, step docstring, and testing.md references.
2026-02-26 16:13:44 +00:00

154 lines
7.9 KiB
Gherkin

Feature: Decision persistence via serialization round-trips
As a developer
I want decisions to persist correctly through serialization
So that the decision tree can be durably stored and reconstructed
# ------------------------------------------------------------------
# CRUD: Create and retrieve via model_dump / model_validate
# ------------------------------------------------------------------
Scenario: Persist a root decision through model_dump round-trip
Given a decision persistence plan ULID
When I decision persistence create a root prompt_definition with sequence 0
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored decision should match the original
Scenario: Persist a child decision with all fields populated
Given a decision persistence plan ULID
And a decision persistence parent ULID
When I decision persistence create a full strategy_choice child at sequence 1
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored decision should match the original
And the decision persistence restored alternatives should have 3 entries
Scenario: Persist an execute-phase decision with snapshot
Given a decision persistence plan ULID
And a decision persistence parent ULID
And a decision persistence context snapshot with 2 resources
When I decision persistence create an implementation_choice with the snapshot
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored snapshot hash should match
And the decision persistence restored snapshot should have 2 resources
# ------------------------------------------------------------------
# JSON serialization round-trips
# ------------------------------------------------------------------
Scenario: Decision survives JSON serialization round-trip
Given a decision persistence plan ULID
When I decision persistence create a root prompt_definition with sequence 0
And I decision persistence round-trip the decision through JSON
Then the decision persistence restored decision should match the original
Scenario: Full decision with artifacts survives JSON round-trip
Given a decision persistence plan ULID
And a decision persistence parent ULID
When I decision persistence create a decision with 3 artifacts
And I decision persistence round-trip the decision through JSON
Then the decision persistence restored decision should have 3 artifacts
# ------------------------------------------------------------------
# Snapshot persistence
# ------------------------------------------------------------------
Scenario: Empty context snapshot persists correctly
Given a decision persistence plan ULID
When I decision persistence create a root prompt_definition with sequence 0
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored snapshot hash should be empty
And the decision persistence restored snapshot should have 0 resources
Scenario: Context snapshot with actor state ref persists
Given a decision persistence plan ULID
And a decision persistence parent ULID
And a decision persistence snapshot with actor state ref "checkpoint://actor/42"
When I decision persistence create a strategy_choice with the snapshot
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored actor state ref should be "checkpoint://actor/42"
# ------------------------------------------------------------------
# Correction chain persistence
# ------------------------------------------------------------------
Scenario: Correction decision persists correction metadata
Given a decision persistence plan ULID
And a decision persistence corrected decision ULID
When I decision persistence create a correction decision
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored is_correction should be true
And the decision persistence restored corrects_decision_id should match
Scenario: Superseded decision persists superseded_by
Given a decision persistence plan ULID
When I decision persistence create a decision superseded by another
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored is_superseded should be true
Scenario: Correction chain of 3 decisions persists correctly
Given a decision persistence plan ULID
When I decision persistence build a correction chain of 3 decisions
And I decision persistence round-trip all decisions through model_dump
Then the decision persistence correction chain should be reconstructable
# ------------------------------------------------------------------
# Decision tree reconstruction
# ------------------------------------------------------------------
Scenario: Reconstruct a 3-level decision tree from serialized data
Given a decision persistence plan ULID
When I decision persistence build a 3-level decision tree
And I decision persistence serialize and deserialize all tree nodes
Then the decision persistence tree parent links should be intact
And the decision persistence tree should have 7 nodes
Scenario: Decision downstream_decision_ids survive round-trip
Given a decision persistence plan ULID
When I decision persistence create a decision with 4 downstream IDs
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored should have 4 downstream IDs
Scenario: Decision downstream_plan_ids survive round-trip
Given a decision persistence plan ULID
When I decision persistence create a decision with 2 downstream plan IDs
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored should have 2 downstream plan IDs
# ------------------------------------------------------------------
# Edge cases
# ------------------------------------------------------------------
Scenario: Decision with empty alternatives list persists
Given a decision persistence plan ULID
When I decision persistence create a decision with no alternatives
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored alternatives should have 0 entries
Scenario: Decision with max confidence 1.0 persists
Given a decision persistence plan ULID
When I decision persistence create a decision with confidence 1.0
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored confidence should be 1.0
Scenario: Decision with min confidence 0.0 persists
Given a decision persistence plan ULID
When I decision persistence create a decision with confidence 0.0
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored confidence should be 0.0
Scenario: Decision with None confidence persists
Given a decision persistence plan ULID
When I decision persistence create a decision with confidence None
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored confidence should be None
Scenario: All decision types round-trip through model_dump
Given a decision persistence plan ULID
When I decision persistence create and round-trip all decision types
Then all decision persistence round-trips should succeed
Scenario: Decision with long rationale text persists
Given a decision persistence plan ULID
When I decision persistence create a decision with a 2000 character rationale
And I decision persistence round-trip the decision through model_dump
Then the decision persistence restored rationale length should be 2000