feat(engine): detect endings on every successful turn

After each state-mutating dispatch, evaluate world.endings in priority
order (true > wrong > bad). The first whose whenFlags are all satisfied
sets state.endedWith and appends a kind:'ending' transcript line. Once
ended, further dispatches return a "story has ended" narration.

Also update test-world fixtures and placeholder ending markdown files
to use whenFlags: { _never: true } instead of {} so that vacuously-true
empty flags don't accidentally fire on every successful turn.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-09 14:53:07 -05:00
parent 0d9db9bb55
commit 19d1efc586
5 changed files with 135 additions and 32 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
---
id: bad
whenFlags: {}
whenFlags:
_never: true
---