Skip to content

AutoStory: shared story files, dev-folder override and execution keys - #474

Merged
dayfine merged 8 commits into
nav/sharedfrom
autostory/shared-story-data
Nov 14, 2026
Merged

dayfine merged 8 commits into
nav/sharedfrom
autostory/shared-story-data

Conversation

@dayfine

@dayfine dayfine commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Depends on #332

PLZA (#335, #354) built a few AutoStory pieces that don't depend on the game: checkpoint files built into the program with a dev-folder override (<user files>/AutoStoryDev/<game>/), the save / reload_when_chained / dev_only execution keys, the run-row helpers, and StoryActionNotImplemented. This PR adds them to the shared engine as Pokemon/AutoStory/Data/Pokemon_StoryFiles.h, Pokemon_StoryRowExecution.h, Pokemon_StoryDevFiles.h and Engine/Pokemon_StoryActionNotImplemented.h. Each game passes in its slug, its own checkpoint reader, its lint hook and, when it does not play its files in name order, a plays_before order; the loader checks reload_when_chained in that final order. StoryData lives in the data-only Pokemon_StoryRowExecution.h, so a game's table header need not include the loader. No game code changes here. The new Pokemon::StoryFiles unit suite covers loading, dev overrides, the execution keys, rows per mode and reloads. I compiled the touched files locally; CI runs the suite.

Not moved: PLZA's SceneMachine is built around PLZA's own readings (mission banner and complete card, controls hint, autosave badge) and PlzaBackend, and the engine already has the shared settle rule (TalkOver in Pokemon_SceneJudges.h: B while quiet, done after 5 s of quiet overworld). A shared copy would be a second scene judge, so PLZA should move onto TalkOver plus its readings instead. The name / Adoption

  1. PLZA: adopted in PokemonLZA AutoStory: Main Mission 03 (03.01-03.08) and Wild Zone 1 catches #335 (bd665c9). When it merges this tip, PokemonLZA_AutoStoryTable.h can include Pokemon_StoryRowExecution.h for StoryData in place of Pokemon_StoryFiles.h; its reader is unchanged (it keeps requiring "save" and refusing "dev_only" itself).
  2. BDSP: adopted in BDSP AutoStory: run story steps on the shared story engine #353 (ba39c07). When it merges this tip, load_bdsp_story in PokemonBDSP_AutoStory_StoryData.cpp passes .plays_before (id order) to load_story_data and drops its own std::sort; the duplicate-id check stays.
  3. FRLG (FRLG 20.01a to 20.05: Indigo Plateau's Mart, the Elite Four and the Champion #458): not adopted yet. read_story_checkpoint_file's ExecutionReader calls read_story_row_execution(execution, where, {"menu", "supplies", ...}) in place of only_fields, and story_checkpoints() calls load_story_data with the dev files from story_dev_folder("frlg") and in_story_order as plays_before.

FRLG in PokemonBDSP_AutoStory_StoryData.cpp (validate_json_fields → read_story_row_execution(..., {"on_failure", "saves_in"}), load_authored_story → load_story_data and then its sort), with story_dev_folder("bdsp"). About +15 / -10 lines.

A game with a story order sets in_story_order(id) on its reader; a built-in or dev file whose checkpoint id that order does not list is then a load error (ParseException naming the file, or the dev file's path, and the id), not a skipped or misordered row. It is a load error rather than a per-run refusal: built-in files load once and fail the unit tests, and dev files are read at each run's start, so a misnamed override stops that run with the message before it plays anything while a valid override loads as before. Games without a list (BDSP, PLZA) leave it unset.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

dayfine and others added 2 commits November 13, 2026 23:04
PLZA's built-in checkpoint files with a dev-folder override, its shared
execution keys (save autosave/menu, reload_when_chained, dev_only), the
run-row helpers and StoryActionNotImplemented, as game-agnostic engine code
under Pokemon/AutoStory/Data and Engine, parameterized by the game's slug,
checkpoint reader and lint hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Template functions declared before their definitions, add_story_row's
output parameter last, and the allow tag on Exception::name()'s base
signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
dayfine added a commit that referenced this pull request Nov 14, 2026
PLZA's checkpoint files now load through Pokemon::load_story_data()
(#474): PokemonLZA_AutoStoryStoryFiles keeps only PLZA's reader (the
shared execution fields, "save" still required and "dev_only" still
refused), its lint and the starts_without_save hook. StoryData is
Pokemon::StoryData<StoryCheckpoint>; StoryRunPolicy, story_run_rows,
reloads_before, the dev-folder files and StoryActionNotImplemented are
the engine's. The generic dev-override and execution-field cases go to
the shared Pokemon::StoryFiles suite; the production-rows test pins the
rows, autosaves and reloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
Brings in the shared story files and the autostory/engine updates under
them. Adapts BDSP to two moves on that side: the screen events now live in
CommonTools/ScreenEvents (namespace PokemonAutomation, SwitchHomeObserver
in NintendoSwitch_HomeScreenObserver.h), and type_on_system_keyboard is now
FastCodeEntry::type_on_system_keyboard. The system keyboard detector takes
the engine side's version; BDSP calls only its shared API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
load_bdsp_story() reads the embedded checkpoints through
Pokemon::load_story_data (#474), so a BDSP run gets the dev-folder
override (<user files>/AutoStoryDev/bdsp/) and the shared execution
keys: the reader takes "save", "reload_when_chained" and "dev_only"
next to BDSP's "on_failure" and "saves_in". The rows stay in id order.
A run reads the dev files at its start and logs each one it uses; the
dropdowns and the run list dev_only rows only in Developer Mode.
story_checkpoints() stays the built-in rows, so tests never read the
user's dev folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 2 commits November 13, 2026 23:42
…ata moves to StoryRowExecution.h

load_story_data checked reload_when_chained in file-name order, but BDSP
plays its rows in id order (bdsp-mine-01.03 sorts after 01.11 by name).
StoryFileReader::plays_before lets a game give its order; the loader sorts
the rows by it before checking reloads. StoryData moves to the data-only
Pokemon_StoryRowExecution.h, so a game's table header need not include
the file loader.

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

StoryFileReader gains in_story_order(id). When a game sets it,
load_story_data() throws ParseException naming the file (the dev file's
path for an override) and the id of any checkpoint the game's story order
does not list, instead of skipping it or sorting it to the end. Games that
keep no list leave it unset and load as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 14, 2026
…y_order

load_frlg_story() sets #474's StoryFileReader::in_story_order from
STORY_ORDER, so a file whose id it does not list fails naming the file and
the id. Its own check after the load keeps only the duplicate-id test.

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.

Verdict: mergeable on the fork
Reviewed SHA: 2a0c69b

Verdict

APPROVED

Correctness pass on git diff origin/autostory/engine...origin/autostory/shared-story-data, then a style pass. CI green. No existing comments. Nothing on this branch calls the new APIs yet; the PR body names the adopting game PRs. No blocking findings.

Should-fix

  1. Data/Pokemon_StoryFiles.h:191 with Data/Pokemon_StoryFiles.cpp:72 — the reload_when_chained check takes the previous row from the full order, dev-only rows included. story_rows_for_mode(..., USER) (:204) then drops the dev-only rows. So when a dev-only row is the autosave row before a reloading row, a user's run reaches the reload from a row that does not autosave, and the reload loads an older save. That is the case the check is meant to refuse. Either check against the previous non-dev-only row as well, or refuse a dev-only autosave row that a reload depends on.

Nits

  1. Data/Pokemon_StoryFiles.cpp:19 — known |= ... over every built-in file: std::ranges::any_of, or reuse find_dev_file()'s comparison, reads more clearly.
  2. Engine/Pokemon_StoryActionNotImplemented.h:18 — the comment says "a game's backend lets it end the run". On this branch the engine's catch turns it into operation_failed (Pokemon_StoryActions.cpp:133), which reloads and retries. Say that only a game backend that catches it ends the run (PLZA today).
  3. The PR description has a garbled paragraph ("The name / Adoption") and the FRLG adoption note twice; worth a tidy-up before anyone reads it for handoff.

@dayfine
dayfine changed the base branch from autostory/engine to nav/shared November 14, 2026 22:06
@dayfine
dayfine merged commit 9a093ab into nav/shared Nov 14, 2026
16 checks passed
dayfine added a commit that referenced this pull request Nov 14, 2026
AutoStory: review fixes on the shared engine (#312, #313, #332, #474, #479)
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