Skip to content

AutoStory: story steps, checkpoints, breakpoints and save modes as plain data - #531

Draft
dayfine wants to merge 6 commits into
plza/upstream/s1-02from
plza/upstream/s1-03
Draft

dayfine wants to merge 6 commits into
plza/upstream/s1-02from
plza/upstream/s1-03

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #530

Adds the plain data a checkpoint is made of: a story step, a checkpoint with its metadata and postconditions, debugger breakpoints, the declared pose a step or checkpoint holds, and the StoryEvent and checkpoint types with their few functions. Tests: the StoryRunTypes suite (phase names, pause points and the pause hook). Fork Draft CI builds it. 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: 09e802e

Verdict

NEEDS_REWORK

First-pass review (agent), own diff against plza/upstream/s1-02. Code health: 0 failures. CI at review time: build/code-health/no-tabs pass, Fork Draft CI ubuntu / build pending.

High

  1. Types/Pokemon_StoryBreakpoints.{h,cpp} set_story_pause_wait() / installed_wait(): a mutable process-wide std::function that a "lab build installs", read from the run's thread with no synchronization. Even at the chain tip (944abe8) the only caller of set_story_pause_wait is a unit test, so upstream would get a global knob for a fork-only lab feature. Pass the wait down (an option of the run, or the game's pause_point hook) instead of a global; if a global stays, it needs a Mutex and a why. Also make_story_pause_hook re-reads the global on every pause: if the wait is removed after the hook is made, the hook calls an empty std::function and throws bad_function_call.
  2. Declarations without definitions, as in #530: apply_interrupt_pose (Pokemon_StoryCheckpointTypes.h), condition, pose_known, recovery_name (Pokemon_StoryEvent.h) are defined only later in the chain (Pokemon_StoryEvents.cpp). Move them with their definitions, or add the .cpp here.
  3. Comments about history and our notes branch (T3): "Split out of Pokemon_StoryEvents.h, unchanged; it includes this header." in Pokemon_StoryCheckpointTypes.h and Pokemon_StoryEvent.h; "(autostory/SAVE_POLICY.md on the notes branch)" in Pokemon_StoryCheckpointMetadata.h; "a lab build installs one" in Pokemon_StoryBreakpoints.h. Upstream has neither the notes branch nor a lab build; say what the phase policy is inline instead.

Medium

  1. "No suite of its own" is not quite true: story_save_allowed() (the save policy - the one decision here that can overwrite a user's save), read_story_phase() and StoryPausePoints (mode OFF/STEPS/LEGS, label carry-over) have behavior in this PR. Their tests should be in this PR, per "tests belong to the code in the same PR". A table of mode x verdict x point for story_save_allowed is a few lines.
  2. Pokemon_StoryCheckpointTypes.h CheckpointReport::failed_event: 0 means "start check, end check, save, or nothing failed" - four meanings in one sentinel. std::optional<size_t> plus a small enum for where it failed (START / EVENT / END / SAVE) says it in the type.
  3. Checkpoint::max_interrupts_per_event = 5: why 5? A one-line reason or a named constant (T2).

Low

  1. StoryPausePoints::before_step(const std::string&), before_leg(const std::string&), pause(const std::string&): read-only string params; std::string_view by value per the repo pointer (before_step copies into m_step_label anyway).
  2. Event::when_skipped is std::function while every other callable in these structs is MoveOnlyFunction; pick one or say why.
  3. StoryVerification::runs ("3/3"), date, build are free strings in a model the engine compares; fine as recorded text, but say so (the engine never parses them), or give runs two integers.
  4. Comment accuracy/voice: // Specification of an atomic story task with actions and postconditions. (StoryStep has no postconditions); // Story milestone containing..., // Callback receiver for..., // Predicate callable evaluating current run state., // Returns the readable name... restate types with // instead of the file's // . Several comments point at files and names not in the chain yet at this PR (Pokemon_StoryStepExecutor.h, PreparedSteps, StoryStepExecutor::holds(), Pokemon_StoryPostconditionCheck.h, Engine/Pokemon_StoryEnginePolicy.h, StoryGame::pause_point, StoryRunOptions).

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

…es get tests

condition(), pose_known(), recovery_name() and apply_interrupt_pose() get
their own .cpp files beside the headers that declare them. The pause wait is
passed to make_story_pause_hook() instead of living in a process-wide global,
so a hook keeps the wait it was made with. New suite StoryRunTypes covers the
save decision table, phase names and the pause points. Pokemon_DeclaredPose.h
comes here with the step types that hold one.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip 0550227dc:

Fixed: 1 (no global: make_story_pause_hook(wait, scope) takes the wait and the hook keeps its own copy, so no bad_function_call), 2 (Pokemon_StoryEvent.cpp and Pokemon_StoryCheckpointTypes.cpp), 3 (split, notes-branch and lab-build comments), 4 (new StoryRunTypes suite: save decision table, phase names, pause points OFF/STEPS/LEGS, pause hook, labels), 6 (a reason for max_interrupts_per_event), 7 (string_view), 10 (comment voice in the two event headers). Pokemon_DeclaredPose.h now lands here.
Not changed: 5, 8, 9. Non-test lines are now 913, over the ~800 target, because the definitions and the declared pose moved in.

@dayfine

dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner Author

Second fix round, tip eb0f1b76a: StoryCheckLevel (.h/.cpp, 75 lines) moves to #543, the run options that are its only user (commit eb0f1b7). DeclaredPose.h stays: StoryStep and StoryCheckpoint in this PR hold it, so it cannot move without them. The other pieces with ~100 lines either have this PR's tests (StorySaveMode, StoryBreakpoints) or are used by #533 already. Non-test lines (added lines outside the _Tests files, CMake included): 931 -> 854.

dayfine added a commit that referenced this pull request Nov 15, 2026
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

Third fix round, tip 6203f68f1: StorySaveMode (.h/.cpp, 102 lines) and its save decision tests move to #535, the segment runner that is its first user; nothing in #532-#534 includes or uses it. This PR is now 750 non-test lines (was 852). The merge commits up the chain are clean; #535 keeps the files unchanged.

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