Skip to content

AutoStory: save modes and a postcondition check - #329

Merged
dayfine merged 9 commits into
nav/story-enginefrom
autostory/save-policy
Nov 13, 2026
Merged

dayfine merged 9 commits into
nav/story-enginefrom
autostory/save-policy

Conversation

@dayfine

@dayfine dayfine commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Base: nav/story-engine (#312). The diff shows only this change. FRLG/BDSP wiring follows once their stacks have merged #312.

A checkpoint run used to save at every checkpoint on its own verdict; FRLG 00.31 (2026-11-10) reported a false pass on B4F and its save overwrote the only start save. This adds the save policy from autostory/SAVE_POLICY.md to the shared run code.

  • StorySaveMode none / after_verification / per_checkpoint, with story_save_allowed() as the decision table; a failed checkpoint never saves. StoryRunOptions shows it (default none) plus "Check postconditions only".
  • run_segment: none logs each skipped save; after_verification saves once at the run's end, after the game's postcondition check (SegmentHooks::check_postconditions; a failed check fails the run and refuses the save; no check is logged as "not checked"); per_checkpoint is today's behaviour and stays the engine default. Without per-checkpoint saves only the first checkpoint retries with a reload.
  • verify_checkpoint: after_verification saves at the end of the last run when every run passed.
  • Optional postconditions (position, items with quantities, flags) on the checkpoint JSON, and check_postconditions(): map, tile and facing (end pose from postconditions.position, else the last step's target), item counts and flags, each passed / failed / not checked. Not read is never passed.

Testing: new Pokemon::StorySavePolicy suite (decision table, each mode through run_segment and verify mode, and the postcondition check on 00.31's end state: pass, the B4F false pass, not checked). StorySavePolicy, StorySegments, StoryStepJson, StoryEvents, StoryStepExecutor, AuthoredCheckpointJson and StoryRangeOptions pass in the headless runner; full SerialPrograms build passes on macOS.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

A run's own verdict can be wrong (FRLG 00.31, 2026-11-10: a warp leg
confirmed B3F while still on B4F) and its save overwrote the only save.

- StorySaveMode none / after_verification / per_checkpoint, and
  story_save_allowed() as the decision table. A failed checkpoint never
  saves. SegmentPolicy and VerifyPolicy carry the mode; StoryRunOptions
  shows it (default none) and a "check postconditions only" option.
- run_segment: none skips every save (logged), after_verification saves
  once at the run's end after the game's postcondition check (a failed
  check fails the run, no save), per_checkpoint is today's behaviour.
  Without per-checkpoint saves only the first checkpoint reloads.
- verify_checkpoint: after_verification saves at the end of the last run
  when every run passed.
- StoryPostconditions on the checkpoint (position, items, flags) in the
  checkpoint JSON, and check_postconditions(): what the game can't read
  is "not checked", never passed.

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 10, 2026
What PLZA (#335) had to work around, now in the engine:

- FakeStoryBackend and its script are templated on the pose (GridPose and
  ZonePose instantiated); ZonePose moves into the engine (cherry-picked).
- StoryBackend::stick(degrees, duration, pace) for free-moving games, and
  the "heading" reading (STORY_HEADING, story_heading()).
- ScreenEvent gains CHOICE_BOX and INTERACT_PROMPT.
- run_screen_machine_on_observations(): ScreenMachine states over looks,
  failures returned; ScreenMachineChecks::problem() for observations;
  StepTrace without video (lines to a log, no screenshots).
- Handlers get a StoryActionCall {step, args}; StoryGame::save gets the
  checkpoint.
- StoryEngine::run_segment() and verify_checkpoint(): retries only when a
  reload returns to the checkpoint's start save (#329), no reload for
  lint, console_only or game-not-running failures; verify saves only on
  the last run when every run passed.
- StoryActionSpec::console_only, refused off a console as "console_only";
  StoryBackend::kind().
- StoryPoseTraits: TILE_MOVES (legs/face only for tile games) and
  from_declared() (a checkpoint's start and declared_after read as the
  game's pose; the lint fails what does not fit). A declared pose may
  omit "tiles".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 8 commits November 10, 2026 13:34
…ory/save-policy

StorySegmentTypes.h gets StoryRunCounts from Pokemon_AutoStoryStats.h
now; it no longer needs Pokemon_StoryLog.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
The postcondition checks take their result vector last, set_save takes
the checkpoint last, and SegmentHooks::check_postconditions now takes
(checkpoint id, RunState&). Messages are built with std::format.
Pokemon_StorySavePolicy_Tests.h declares the suite's add_tests function;
the test file includes only that header.

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
Keeps the save-mode logic in Pokemon_StorySegments.cpp with nav/shared's
order: say(line, hooks), and run_row, verify_run and verify_summary take
their inputs first and the RunState or report last. run_segment and
verify_checkpoint calls in the save-policy tests follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine merged commit f3e65fb into nav/story-engine Nov 13, 2026
10 of 13 checks passed
@dayfine
dayfine deleted the autostory/save-policy branch November 13, 2026 03:30
@dayfine

dayfine commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Folded into #312 (merge f3e65fb).

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