Skip to content

AutoStory: the story engine - #542

Draft
dayfine wants to merge 13 commits into
plza/upstream/s2-07from
plza/upstream/s2-08
Draft

dayfine wants to merge 13 commits into
plza/upstream/s2-07from
plza/upstream/s2-08

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #541

Adds the story engine, the one executor for every game and both backends: it lints a checkpoint's steps against the game's actions, runs them through the event layer with the step runner, checks postconditions and saves by the policy. Nothing in this chain constructs a StoryEngine: Used by the PLZA program PR (batch 2). Tests: the StoryEnginePolicy, StoryEngineRuns and StoryEngineSaveRetry suites over the fake backend, 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: 80eb57e

Verdict

NEEDS_REWORK

First-pass review of this PR's own diff against plza/upstream/s2-07 (#541). Engine logic (Pokemon_StoryEngine.cpp) reads correct: save only on PASSED, retry only while the start save is reachable, saved_part_way stops retries, verify saves only on the last run after all passed, attempts == 0 still runs once. The findings are about where tests live and comments that won't survive upstream. Code health: 0 failures (9 advisories, function length). CRLF kept, no banned APIs, new files listed in SourceFiles.cmake. Fork Draft CI (ubuntu / build) was still pending when I looked.

High

  1. Infra tests live here, not in the infra PR (#541). Pokemon_StoryEngineRuns_Tests.cpp observation_machine_ends, observation_machine_fails, still_states (lines ~255-425) and Pokemon_StoryEnginePolicy_Tests.cpp ScreenObservationTest (lines ~345-415) test run_screen_machine_on_observations() / match_screen_state(): terminal state, "matches none", max_visits, timeout, max_still, the 8-step stall. None of them touch StoryEngine. As split, #541 lands CommonTools infra with no tests for those behaviors. Move them into #541 (and out of the Pokemon::StoryEngine suite names).
  2. Comments about our PR history. Pokemon_StoryEngineRuns_Tests.cpp:5-11 ("the PLZA move, #335", "what PLZA found on the engine"), the "Gap 1".."Gap 10" labels throughout Runs/SaveRetry tests (a list that is not in the repo), Pokemon_StoryEngineSaveRetry_Tests.cpp:224 ("(#329)", a fork PR number that resolves to an unrelated upstream PR), and Pokemon_StoryEngine.cpp:24-26 ("The old executor interface ... Goes once StoryStepExecutor is deleted"). Say what each test checks; drop the gap numbers and PR numbers.

Medium

  1. More tests belong to parent PRs. StoryStepsHashTest tests story_steps_hash() (#540), StoryMetadataTest tests the metadata reader (#533/#540), stick_and_heading / buttons_by_name test FakeStoryBackend (#538), handler_sees_step calls only StoryActionRegistry::dispatch (#539), pause_hook_from_the_installed_wait tests make_story_pause_hook (#531). Each parent ships that code untested until here.
  2. Pokemon_StoryEngine.h:12 points to "MIGRATION.md in this folder", which does not exist at this tip or at the chain tip (#545). Add it or drop the line.

Low

  1. Pokemon_StoryEngine.cpp:72-92 with_gated_save_step() returns results through captured references to engine members (mode, current, saved); it is correct only because StoryEngine is non-copyable and the members are declared before m_game (header comment at the members carries that invariant). Hidden mutation (user theme T4). Consider a small SaveGateState member the handler holds by pointer, built in the constructor body.
  2. Pokemon_StoryEngine.cpp:96 / :216: "lint_failed" is a bare literal in two places while GAME_NOT_RUNNING / CONSOLE_ONLY are named constants; name it too.
  3. No non-test caller of StoryEngine anywhere through #545; the description should say which later PR wires it in, so the engine isn't read as dead code.
  4. RUNS_CASES and the SaveRetry .check table: every .expectation is {} and the check is a function pointer, so the name/input/expectation shape is cosmetic. Fine to keep, but plain named tests would read more honestly.

…istory

The screen machine tests moved to CommonTools::ScreenMachine and the steps
hash cases to the save policy suite; the global pause wait test goes with the
global. The run and retry tables are plain named tests, the never-verified
case expects its own reason, and comments drop the gap numbers, fork PR
numbers and the pointer to a MIGRATION.md that is not in the repo.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip 2b0d9338a:

Fixed: 1 (screen machine tests moved to #541), 2 (#335, Gap labels, #329 and the old-executor comment), 4 (MIGRATION.md pointer), 7 (description names the PLZA program PR, batch 2), 8 (run and retry tables are plain named tests). 3 in part: steps hash cases moved to #540, the pause hook test to #531.
Not changed: the metadata cases (#533), stick_and_heading/buttons_by_name and handler_sees_step (#539) still live here; 5, 6.

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Second fix round, tip 32a0d151e: the metadata cases left for #533's StoryStepJson suite, and stick and heading, buttons by name and handler sees its step left for #539's StoryEngine suite (commit 78c4bb5). StoryEnginePolicy and StoryEngineRuns now test only the engine.

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