Skip to content

AutoStory 2D core: story actions and interrupts between steps - #362

Merged
dayfine merged 40 commits into
nav/grid-screen-statefrom
nav/grid-story-steps
Nov 13, 2026
Merged

dayfine merged 40 commits into
nav/grid-screen-statefrom
nav/grid-story-steps

Conversation

@dayfine

@dayfine dayfine commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Depends on #361 (base nav/grid-screen-state; the diff shows only this change). Replaces #122.

Third 2D core PR: brings back #122's story-steps layer unchanged by reverting b305df5: Pokemon_StoryActions (action table and TableExecutor), Pokemon_StoryInterrupts and Pokemon_InterruptHandlers, their suites, and FRLG's screen-event adapter with its test registration. BDSP and FRLG chains that sat on nav/story-steps move here; the engine itself never included these files. The same revert also restores Pokemon_StoryRun, Pokemon_StoryPreflight, Types/Pokemon_StoryStart.h, Pokemon_ConnectedMaps and Pokemon_MoveMechanics with their test registrations. Review fixes on top: a throwing interrupt handler becomes an interrupt_failed outcome, and a HOME menu found after a failed step stops the segment.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

Start preparation, the runner's reload, and the finish of a run or a
verify run, written once for both games. A start at a checkpoint with a
save always loads that save first; a failure leaves the game where it
failed, with the same log lines in both games.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 21 commits November 11, 2026 12:24
Pokemon_AutoStoryShell{,_Tests} -> Pokemon_StoryRun{,_Tests}; include
guards, header titles, test suite name and registration follow. No
behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
AutoStory: shared story-run start and finish for BDSP and FRLG
prepare_story_start() now logs the checkpoint that starts, then runs the
game's preflight (video alive, controller ready, game not on HOME); one
that fails returns precondition_failed with nothing pressed. A shared
console reader lends the same preflight to BDSP and FRLG.
story_first_save_allowed(): only a new game saves at its first
checkpoint's start; after a load the save is there, and from the game
as it is the place is unconfirmed (console B, 2026-11-11 13:32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
StoryStartGate.h mixed the start enum, the preflight reading, its failure
code and two start rules. StoryPreflight is now the one concept in its own
header: the preflight hook's reading, its check() and its FAILURE code.
StoryStart and story_first_save_allowed() go back to Pokemon_StoryRun.h
with the start sequence; story_start_name() is internal to it.
Behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Keeps Pokemon_StoryRun.h at its symbol limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
StoryStart moves to Types/Pokemon_StoryStart.h. The console reader joins
StoryPreflight as StoryPreflight::read(); the picture check is internal.
Behavior unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Tap lengths, tile times per gait and axis, start delay and how open legs
are pressed (BDSP taps, FRLG timed holds on foot), with an entry for BDSP
and one for FRLG and a check of each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Maps joined by their warps and edges, with the player's place as a map
and a tile of it. Where a warp or an edge leads is computed once here;
whether a step is allowed stays per game. connect_by_world() joins maps
placed on one world grid, for BDSP's maps, which have no connections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…edge entry split out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Conflict in PokemonFRLG_Tests.cpp's registration list: kept main's sorted list and added this branch's BagDetector, BattleMoveSelectionArrow and AutoStoryScreenEvents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Conflict in SourceFiles.cmake: kept both file lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…e messages name expected and actual (#402 review)

FRLG's Bicycle taps 40 ms at one per 100 ms, its walk 66 ms with a 700 ms
release, so the step tap moves from MoveMechanics onto Gait. Every scalar
gets a default, and the test reports which gait and which value failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 3 commits November 12, 2026 00:15
…exes, orders MapPlace (#408 review)

The rvalue constructor is deleted, map() throws InternalProgramError past
the last map, and MapPlace gets a defaulted <=> over TilePos's. The test
art matches the maps, the Lake to Route edge has two cases, and stale map
indexes have their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 9 commits November 12, 2026 02:03
Conflict in ComputerPrograms_UnitTestRunner.cpp: kept both
add_tests_ConnectedMaps and add_tests_MoveMechanics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…-map-tests links Pokemon_Direction.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine

dayfine commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

API review (claude-sonnet-5-5) at b681c75: changes_requested

The table executor lets a throwing interrupt handler escape its guard handling, and it drops a GAME_NOT_RUNNING found after a step failed. The rest is comment hygiene, a sentinel in a test input and include order. The PR description also covers only part of what the diff adds.

  • [bug] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp:105 clear_interrupts() runs the game's interrupt handlers (flee, fight, close dialog, wait out a warp) with no try/catch. These drive the console and can throw OperationFailedException. Here the call sits outside the try, so the exception skips on_failure() and the operation_failed outcome and escapes the executor. It also bypasses the interrupt_failed contract in clear_story_interrupt(). When the same call fails inside the try (line 110), the catch runs and calls cleared_after_failure() a second time, which looks at the screen and may run handlers again. Fix: In clear_story_interrupt(), wrap handler->handle() in try/catch (OperationFailedException&) and return outcome_failed("interrupt_failed", ...). Run the post-failure look so it cannot throw into the catch. Add a test with a throwing handler.
  • [bug] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions.cpp:110 cleared_after_failure() discards the outcome of clear_interrupts(). If a step fails and the look afterwards finds the Switch HOME menu, clear_story_interrupt() returns GAME_NOT_RUNNING. That is dropped, and the step's own failure is returned or reported (line 114 for the throw case). The segment can then recover or reload with the game closed, the exact case test_home_menu_stops_the_segment guards against before a step. Only the before-step path propagates it. Fix: Have cleared_after_failure() surface a game_not_running failure so run() returns it instead of the step's own failure. Add a test that fails a step and then shows HOME.
  • [style] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts_Tests.cpp:350 Comments cite lab runs and sweeps ('BDSP fault sweep, 51 steps of 00.01-01.11', 'lab-B 2026-11-09 15:31', 'then X on HOME and a 22-tile walk on it'). That is run history, not a description of the screen or the code. Fix: Describe what the game shows and why the test exists, for example 'the program started with the game closed and the HOME menu showing'. Put the dates and run references in the PR or commit message.
  • [style] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryRun_Tests.cpp:110 Test comments carry console and date references ('Console B, 2026-11-11 ...'), and the same appears in MoveMechanics_Tests ('the user's pick, 2026-11-11'). These are PR and lab context, not code context. Fix: State the behaviour being guarded, such as 'the game left at a later checkpoint must not be walked from', and drop the console and date.
  • [style] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_InterruptHandlers.h:6 The header comment says 'Split out of Pokemon_StoryInterrupts.h, unchanged; it includes this header.' This is refactor history that stops meaning anything after merge. Fix: Remove the line. If a pointer is wanted, say what the file holds and that Pokemon_StoryInterrupts.h builds on it.
  • [nit] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryActions_Tests.h:16 The comment says the suite covers 'the variant parser'. There is no variant parser in this file or the suite. Fix: Reword to 'story action tables, checkpoint lint and the table executor'.
  • [style] SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryScreenEvents_Tests.cpp:32 The test input uint32_t color uses 0 to mean 'no frame', a sentinel in a new API. A transparent black frame (0x00000000) can then never be tested. Fix: Use std::optional<uint32_t> color and build the VideoSnapshot only when it has a value.
  • [nit] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryPreflight.cpp:40 The stripe geometry 0.25, 0.1, 0.5 and the 0.5 width factor are unexplained literals, while the thresholds above them are named. Fix: Name them, for example BAR_INSET, BAR_TOP, BAR_HEIGHT, with a one-line comment that they sample the middle of each stripe and avoid its edges.
  • [nit] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryInterrupts.h:41 , , and are no longer used here now that the table and function types live in Pokemon_InterruptHandlers.h. Pokemon_InterruptHandlers.h is also listed last, out of include order. Pokemon_StoryActions.h includes without using it. Fix: Drop the unused includes and put Pokemon_InterruptHandlers.h in sorted position.
  • [nit] SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h:22 Pokemon_StoryRun_Tests.h is inserted between Pokemon_AutoStorySelect_Tests.h and Pokemon_AutoStoryStats_Tests.h, so the list is no longer sorted. PokemonFRLG_Tests.cpp adds its AutoStory include above Inference/ in the same way. Fix: Place each include in its sorted position.
  • [nit] SerialPrograms/cmake/SourceFiles.cmake:1569 The PR description lists the story-actions layer and the FRLG adapter, but the diff also adds Pokemon_StoryRun, Pokemon_StoryPreflight, Types/Pokemon_StoryStart.h, Pokemon_ConnectedMaps and Pokemon_MoveMechanics, with their test registrations. None are mentioned, and they touch the unit-test runner and the shared Navigation code. Fix: Update the description to list these files and say why they belong to the revert, or split them into their own PR.

dayfine and others added 4 commits November 12, 2026 15:02
… a failed step (red)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… a failed step stops the segment; comment content, include order, named literals, optional frame colour

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

@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: 8e67a91

Verdict

LGTM_with_nits

All four requested changes from the earlier review (b681c75) are fixed at this tip; one nit is left. No bug-level findings. I read the diff and the sources; I did not compile or run the unit tests (CI covers that). Code health (run from the agents checkout against origin/nav/grid-screen-state): 0 failures, advisories only (function lengths, header symbol counts).

Prior findings

  • Throwing interrupt handler: fixed. run_handler() in Pokemon_StoryInterrupts.cpp catches OperationFailedException and clear_story_interrupt() returns interrupt_failed. test_handler_throws checks it does not escape the executor and the step is not run.
  • GAME_NOT_RUNNING after a failed step: fixed. look_after_failure() returns GAME_NOT_RUNNING for both the failed-outcome and the thrown path, and run() returns outcome_game_not_running() without retrying. test_home_menu_after_a_failed_step covers both and asserts the step ran once.
  • Handler throws while looking after a failure: keeps the step's own failure (test_handler_throws_after_a_failure).
  • Sentinel test input: fixed, std::optional<uint32_t> color and the frame is built only when set.
  • Run-history comments: dates and console names are gone from the Interrupts and StoryRun tests, and the PR description now lists the restored files. The empty-frame readers (FrlgScreenObserver::observe, judge_settle, StoryPreflight) handle empty input without crashing.

Nit

  • SerialPrograms/Source/Pokemon/Navigation/Pokemon_MoveMechanics.h:70 still has "(2026-11-09, Jubilife)" in a comment. Say what was measured and drop the date.

dayfine added a commit that referenced this pull request Nov 13, 2026
SourceFiles.cmake and Pokemon_AutoStory_Tests.h: keep both sides' lists.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine merged commit 6d74a59 into nav/grid-screen-state Nov 13, 2026
15 checks passed
dayfine added a commit that referenced this pull request Nov 13, 2026
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