Skip to content

AutoStory: checkpoint attempts and story segments - #535

Draft
dayfine wants to merge 7 commits into
plza/upstream/s1-06from
plza/upstream/s2-01
Draft

dayfine wants to merge 7 commits into
plza/upstream/s1-06from
plza/upstream/s2-01

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #534

Adds the retry loop every AutoStory runs a checkpoint in (CheckpointAttempts) and story segments: a segment as a table of checkpoints, each built fresh per attempt, run in order from a save with a reload when one fails, plus the segment run's policy, range and report types and StorySaveMode, the rule for when a run may save. Tests: the StorySegments and StorySegmentSaves suites (the retry loop's cases, and when a segment and verify mode save), the StoryRunTypes save decision table, and the StoryStepExecutor cases that run segments, built and run by Fork Draft CI. 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: 3d68225

Verdict

NEEDS_REWORK

First-pass review (agent), own diff against plza/upstream/s1-06. Code health job passes; CI at review time: build/no-tabs pass, Fork Draft CI ubuntu / build pending. I traced run_segment / run_row / set_save / verify_checkpoint against story_save_allowed: a failed attempt never saves, a row after the first is not reloaded unless every checkpoint saves, GAME_NOT_RUNNING ends the loop without a reload, and verify saves only after the last run when every earlier run passed. No correctness bug found.

High

  1. Comments that are about our process, not the code (T3): SegmentHooks::status says "once run records land (#132)" (a fork PR number); VerifyPolicy's comment carries the lab rule "a battle lost twice or more gets its own checkpoint, saved right before it". Describe what the hook/policy does; leave the lab policy to the notes.

Medium

  1. Pokemon_CheckpointAttempts.h says "SV's loop (Pokemon_CheckpointRetry.h), the story segments and the story engine all run their checkpoints through it". There is no Pokemon_CheckpointRetry.h in the tree, and at the chain tip (944abe8) only StorySegments and StoryEngine call run_checkpoint_attempts. Drop the SV claim or land the SV change with it.
  2. run_checkpoint_attempts has no direct test: FINAL stops without a reset, a failed reset stops, max_attempts caps, max_attempts == 0 still runs one attempt (is that intended?). It is the shared retry loop the description sells; it should have its own small table here rather than being tested only through segments.
  3. run_row(segment, row, policy, hooks, report, run, state): seven parameters, two of them output parameters (SegmentReport& report for reloads, CheckpointRun& run for attempts/passed), plus the result captured and overwritten by both lambdas (T4). Return {CheckpointReport, CheckpointRun, reloads} and let run_segment fold it in; stop_segment / verify_summary also mutate-and-return their report.

Low

  1. CheckpointAttempts::max_attempts has no initializer while every other field does; a designated initializer that omits it reads garbage (and Windows clang flags missing fields). size_t max_attempts = 1; or = {}.
  2. CheckpointAttempts / CheckpointLogger use std::function while Segment, SegmentHooks and the event model use MoveOnlyFunction; pick one for the chain.
  3. bool add_checkpoint_prefix reappears here as a struct field (same follow-up as #530's defaulted bool: an enum).
  4. SegmentPolicy's comment says "Retry and timeout configuration" - there is no timeout. "The options' default is NONE; the engine's stays the playthrough's" is hard to parse; say which default wins where.
  5. SegmentReport::failed_checkpoint / failed_event use empty strings for "nothing failed" / "not an event" (sentinels); std::optional<std::string> or reuse CheckpointReport's failed-where.
  6. Comment voice: // Collection of ordered checkpoints..., // Summary of checkpoint attempts and pass status., // Execution results and failure diagnostics..., // Verification results for multiple runs of a checkpoint.

No brace-style, tabs, CRLF, Qt, std::filesystem or threading issues; SourceFiles.cmake lists every new file.

# Conflicts:
#	SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h
#	SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp
run_checkpoint_attempts() gets a case table (pass, reset, max_attempts, FINAL,
a failed reset, max_attempts 0). The segment and verify save-mode tests move
here from the save policy suite, beside the runner they test. The segment
tests are plain named tests, max_attempts has a default, the prefix flag is
the CheckpointPrefix enum, and comments describe the code rather than our
records or the SV loop.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip df9f4a9ca:

Fixed: 1 (#132 and the lab rule out of comments), 2 (SV claim dropped), 3 (new StorySegmentSaves suite: run_checkpoint_attempts table incl. FINAL, failed reset, max_attempts cap and 0 still running once; plus the nine segment/verify save-mode tests moved here from #540), 5 (max_attempts = 1), 7 (CheckpointPrefix enum). Segment cases are plain named tests.
Not changed: 4, 6, 8, 9, 10.

StorySaveMode and its save-decision tests left #531; this PR, their first user, keeps them unchanged (conflict in SourceFiles.cmake resolved to this branch's list).
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

StorySaveMode (.h/.cpp) and the StoryRunTypes save decision table moved here from #531, unchanged, since this PR is their first user (merge 96bfe14a0; SourceFiles.cmake conflict resolved to this branch's list, so the tree equals the previous tip 44b68b28d). This PR is now 860 non-test lines.

The story engine is the one runner; a checkpoint that passes saves as its row's execution says. Their tests go with them.
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