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