Skip to content

AutoStory: read a story from its checkpoint files - #536

Draft
dayfine wants to merge 8 commits into
plza/upstream/s2-01from
plza/upstream/s2-02
Draft

dayfine wants to merge 8 commits into
plza/upstream/s2-01from
plza/upstream/s2-02

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #535

Adds reading a game's story from its checkpoint files: the authored checkpoint envelope (shared checkpoint plus the game's own execution object), the shared execution fields and the rows they mark, and the loader that takes the built-in files and lets a dev file of the same name replace one without a rebuild. load_story_data() has no caller in this chain: Used by the PLZA program PR (batch 2). Tests: the AuthoredCheckpointJson and StoryFiles suites, 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: 67c328b

Verdict

NEEDS_REWORK

First-pass review (agent), own diff against plza/upstream/s2-01. CI at review time: build, code-health, no-tabs and Fork Draft CI ubuntu / build (incl. unit tests) all pass. I traced load_story_data's reload checks (dev-run and user-run predecessors, string_views into data.checkpoints used before the push_back): correct.

High

  1. No caller: load_story_data, StoryDevFile, load_authored_checkpoint and story_rows_for_mode are reached only from tests here and up to the chain tip (944abe8). Pokemon_StoryDevFiles.h itself says "The program passes none; the tests pass their own", while Pokemon_StoryFiles.h sells the dev-file override "so a walk can be retimed on the console without a rebuild" - a lab feature upstream would carry with no way to use it. Name the PR that wires a game to this (and how dev files reach it), or drop the dev-file path until then.
  2. Pokemon_StoryFiles.h points at cmake/EmbedTextFiles.cmake, which does not exist; nothing in the chain embeds checkpoint files. Same for the "built into the program" claim.
  3. read_authored_checkpoint requires "format": "pokesim-authored-checkpoint/1": the wire format of upstream's program is named after our PokemonSimulation tool. If the files are authored here, call the format what it is ("pa-autostory-checkpoint/1"); if they come from that tool, the dependency needs saying in the header.

Medium

  1. ExecutionReader returns void: the game's own execution type can only leave through a captured output variable, and read_authored_checkpoint drops it. Return it (template on the execution type, or return StoryFileRow<...>-like pair) instead of a side-effect callback (T4).
  2. validate_json_fields (exact field set, public in a Pokemon header) duplicates fields() in Pokemon_StoryStepJson.cpp (no field outside a set) with different semantics and messages. One strict-object helper, in one place; a generic JSON check arguably belongs next to Common/Cpp/Json rather than in Pokemon/AutoStory/Data.
  3. Lab words in shared comments (T3): StoryRowExecution "which are for lab runs only", dev_only "a lab walk the story does not need". Upstream has no lab; "developer-mode only" says it.
  4. StoryRunPolicy::attempts_per_checkpoint = 1 here and SegmentPolicy::attempts_per_checkpoint = 3 (#535) are the same knob with two defaults in two structs; and StoryRunPolicy lives in Pokemon_StoryRowExecution.h, a JSON-reading header. Say which one a run uses, or merge them.

Low

  1. EmbeddedJsonFile = std::pair<std::string, std::string> and StoryRows::dev_files as pair<file name, path>: .first/.second at use sites; small structs with named fields read better (T6).
  2. StoryData<Checkpoint> : StoryRows inherits a set of row ids plus dev_files; composition (StoryRows rows;) keeps "which rows" and "where they came from" apart.
  3. read_dev_file re-parses the built-in file only to read its id; the caller already has the text and could pass the id once.
  4. Include guard PokemonAutomation_AuthoredCheckpointJson_H drops Pokemon_ (as in #533).

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
The authored checkpoint tests lose their standalone main(), which nothing
builds. Comments say what the dev-only rows and the format name are for
instead of naming our lab and a cmake file that does not exist; the include
guard gets the Pokemon_ prefix.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip 4d0817631:

Fixed: 1 (description says load_story_data has no caller here: used by the PLZA program PR, batch 2), 2 (EmbedTextFiles.cmake claim dropped), 3 (the header says the format name comes from PokemonSimulation's story tools that write the files), 6 (lab words), 11 (include guard). Standalone test main() dropped.
Not changed: 4, 5, 7, 8, 9, 10. Renaming the format string would break the existing authored files, so I kept it and documented it.

# Conflicts:
#	SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h
"unverified": the row is believed to end on the game's autosave, not yet seen in a run log. A reload does not count on it; StoryRows::unverified_autosaves keeps the rows for a run to report.
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