Skip to content

AutoStory: postcondition checks and the engine save policy - #540

Draft
dayfine wants to merge 12 commits into
plza/upstream/s2-05from
plza/upstream/s2-06
Draft

dayfine wants to merge 12 commits into
plza/upstream/s2-05from
plza/upstream/s2-06

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #539

Adds the postcondition check (a checkpoint's declared end state checked against what the game read, with an unreadable condition reported as not checked, never passed) and the engine's save policy, which picks when a run may save from the checkpoint's phase and verified step hash. Tests: the StorySavePolicy suite (steps hash, the save decision by phase and recorded hash, the postcondition check); the policy's engine-level cases come with the engine. Fork Draft CI builds and runs them. Part of the re-split of #522/#524/#525 into reviewable steps; review fixes are new commits on the PR that owns each problem, merged up the chain.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: 1f0cd80

Verdict

NEEDS_REWORK

First-pass review of this PR's own diff against plza/upstream/s2-05. Code health: 0 failures, 5 advisories; Pokemon_StorySavePolicy_Tests.cpp is 508 lines. Fork Draft CI build passed; the ubuntu job was still pending when read.

High

  1. The tests here do not test this PR's code, and this PR's code is tested later.

    • decide_story_save() and story_steps_hash() (Engine/Pokemon_StoryEnginePolicy.cpp) have no test in this PR. Their cases are in Engine/Pokemon_StoryEnginePolicy_Tests.cpp, which arrives in #542.
    • Most of the StorySavePolicy suite added here tests code from earlier PRs. test_decision_table covers story_save_allowed() (#531). test_none_never_saves through test_verify_no_save_after_a_failed_run, nine cases, drive Segment and SegmentHooks (#535).

    Move the segment and save-mode cases to the PRs that add that code, and bring the decide_story_save cases (phase × verified hash) here. The postcondition cases (test_postconditions_*, test_end_pose_from_the_plan) do belong here.

  2. A comment points at our notes branch. Engine/Pokemon_StoryEnginePolicy.h:6: "(autostory/SAVE_POLICY.md on the notes branch)". Upstream has no such branch. State the policy in the comment, which the next sentences already do, and drop the reference (user theme T3).

Medium

  1. Engine/Pokemon_StoryEnginePolicy.h:46 StoryEngineReport is the engine's report. Nothing in this PR uses it, and only Pokemon_StoryEngine.{h,cpp} (#542) does. It belongs with the engine.
  2. Engine/Pokemon_StoryEnginePolicy.cpp:53: a checkpoint in phase verification or reproduction with no verified record logs "steps_hash mismatch (recorded none, now ...)". Nothing mismatched; it was never verified. Give that case its own reason, e.g. "never verified: treated as testing".
  3. Lab-run references in comments: Pokemon_StorySavePolicy_Tests.cpp:8 ("FRLG 00.31's end state"), :202 ("FRLG 00.31, 2026-11-10: the run said it passed on the wrong floor"), and :280. Describe the fault (a run that reports success on the wrong floor) instead (T3).

Low

  1. SavePolicyCase is name / input / expectation in shape only: Input is a function pointer and Expectation is a prose description. The table rows in SAVE_DECISIONS are positional. Use designated initializers there (T6).
  2. Pokemon_StoryPostconditionCheck.cpp check_position: map_failed is read from out.back(). That works only because check_map always pushes exactly one result. Have check_map return its verdict instead.

Checked: brace style, no std::filesystem/std::thread/std::mutex, CRLF kept, new files are in SourceFiles.cmake, and the includes resolve against the parents. A position postcondition that cannot be read is reported as not checked, never passed, as the PR body says.

# Conflicts:
#	SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h
#	SerialPrograms/cmake/SourceFiles.cmake
The decision-table and segment save tests now live with the code they test;
this suite gains the steps hash cases and a save decision table (phase by
recorded hash). A checkpoint that was never verified gets its own reason
instead of a hash mismatch against "none". Comments describe the faults,
not our runs or notes.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip 561b49958:

Fixed: 1 (decision table moved to #531, segment/verify save tests to #535; this suite now has the steps hash cases from #542 and a decide_story_save table by phase and recorded hash), 2 (notes-branch reference), 4 (never verified gets its own reason), 5 (lab-run comments), 6 (plain named tests; the positional SAVE_DECISIONS rows are gone).
Not changed: 3 (StoryEngineReport stays with the policy for now), 7.

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.

1 participant