Skip to content

AutoStory: the tile-game step executor and the story JSON readers - #533

Draft
dayfine wants to merge 7 commits into
plza/upstream/s1-04from
plza/upstream/s1-05
Draft

dayfine wants to merge 7 commits into
plza/upstream/s1-04from
plza/upstream/s1-05

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #532

Adds the tile games' step executor (one vocabulary of steps: a route, a fixed walk, a talk, a battle, the nurse, a shop, a save) and the strict JSON readers for poses, steps and checkpoints. Reading story JSON happens only in this layer; a step comes out with its args typed and checked. Tests: the StoryStepExecutor and StoryStepJson 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: 3ed042a

Verdict

NEEDS_REWORK

First-pass review (agent), own diff against plza/upstream/s1-04. Code health job passes; CI at review time: build/no-tabs pass, Fork Draft CI ubuntu / build pending. The JSON reader is strict and well covered (unknown fields, kinds, actions, args, wrong types, both/neither pose kinds); no correctness bug found in the readers or in build_story_checkpoint's wrapping (pause, once-per-save).

Medium

  1. Data/Pokemon_StoryStepJson.cpp DIRECTIONS repeats direction_name() (#529) as a second table, and KINDS is a third spelling of the step kinds beside story_step_kind_name() ("MASH"/"scene", "GAME"/"game_action"). Paired tables that encode one mapping drift (T7). Make one two-way table per enum (the wire name), and derive the log name from it or say why they differ.
  2. Pokemon_StoryStepExecutor.h StoryStepExecutor: the comment says "an interface with no data", but it holds StoryPausePoints* m_pause set through set_pause_points(), a non-owning pointer whose lifetime is a comment. build_story_checkpoint() is the only reader; pass the pause points to it (as it already takes PreparedSteps*) and the executor stays a pure interface.
  3. grid_pose_of(const DeclaredPose&) turns a ZoneDeclared into a GridPose with map = place and silently drops spot and heading; pose_of then gives the run an UNKNOWN pose on a "map" that is really a place. The executor is documented as tile-games-only; either reject a zone pose here (a ParseException-like failure / lint problem) or keep the zone fields. Related: read_declared_pose copies a GridPose field by field into TileDeclared, which is the same struct (see #529 item 2).
  4. read_metadata(const JsonValue&, std::string_view, StoryCheckpoint& checkpoint): output parameter filling two fields of the caller's checkpoint (T4). Return {metadata, postconditions} and assign at the call site.

Low

  1. integer() throws "coordinate exceeds native int" for every int it reads (tiles, leg tiles, timed-leg turn and ms, heading). Say "integer out of range" or pass what it is.
  2. Error messages lose context: read_story_step throws "Empty story step id." and read_story_checkpoint "Empty or duplicate story event id." without source or the id; read_verification / read_metadata call to_string_throw() without source, unlike the rest of the file. A story author gets no file name for these.
  3. lint_story_checkpoint: "once per save with skip_if" is a problem because the added done_from_this_save condition is ANDed with the step's own skip_if; the comment ("skip_if's conditions must all hold; once per save is one more") hints at it. Say the consequence: such a step would never skip.
  4. Test names "old field", "old variant", "old pose" describe our earlier wire formats (T3); name them by what they reject ("may_lose outside args", "variant instead of action", "certainty/where pose").
  5. Include guard PokemonAutomation_StoryStepJson_H drops the Pokemon_ of the file name used by every other guard in the chain.
  6. Header comment claims behavior not in this PR (language fallback via StoryRunOptions, "the story engine's own SAVE action"). Fine once the chain lands; for this PR alone it describes code a reviewer cannot see.

Note for #531: the "pause points pause before each step" case here covers some of StoryPausePoints, but from the executor; OFF/STEPS/LEGS and before_leg are still untested.

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
…one test build

The JSON reader read directions from its own copy of direction_name()'s
table; it uses the shared names now. The step kind table stays, with a note on
why its wire names differ from the log names. The standalone test entry point
is dropped (nothing builds it), rejected-format cases are named by what they
reject, and the executor tests are plain named tests.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Review fixes, tip c63edb197:

Fixed: 1 for directions (read_direction() uses direction_name() over ALL_DIRECTIONS; the copy is gone), 8 (cases named by what they reject), 9 (include guard). Also dropped the standalone test entry point and the PokemonSimulation case-file mention; executor cases are plain named tests.
Declined for kinds in 1: the JSON names differ from the log names on purpose ("scene" for MASH, "game_action" for GAME); a comment on KINDS now says so.
Not changed: 2, 3, 4, 5, 6, 7, 10. The metadata reader cases still sit in #542's suite.

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Second fix round, tip c36984634: the checkpoint metadata reads moved here from #542's StoryEnginePolicy suite as StoryStepJson rows (no metadata is testing, a verified checkpoint's phase and steps hash, unknown phase and unknown metadata field rejected); the postconditions case was already here (commit c369846).

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