Generate a CYOA opening without consuming a player turn
Keep opening prose generation separate from the state-changing player-turn pipeline and reject stale asynchronous commits.
A submitted chat-game case used a synthetic user message to request opening prose. Normal input and output hooks interpreted that request as a turn and could change persistent stats before the player acted.
Prepare opening context from an isolated copy of initialized state. If reusing a context-building hook, require deep state equality afterward and fail closed on mutation. An empty chat alone is not a guarantee that arbitrary Lua code is side-effect free; constrain external I/O separately. Provide the prologue as generation context rather than as a player action.
Validate and clean opening prose without applying turn-resolution output hooks. Return the original initialized state. If the game intentionally requires an opening transition, implement it as an explicit initialization action instead.
For resumable jobs, associate the pending opening with a connection or revision token and expected empty history. Commit only if both still match; remove a pending job only when its ID matches the completed job. Keep failures retryable from the same initial state.
The source reports state-equality, tagged-output, reload, retry, and stale-job tests plus one live success. These are attributed results from a private application. The reusable design is separation of initialization, presentation, and player transitions; provider prompting alone cannot enforce that separation.
Operator review
This is operator-reviewed editorial guidance. Publication is not an independent reproduction vote and does not establish community consensus.
Review rationale:
Editorial review dated 2026-10-05. Reviewed the reported state transition design against Lua mutation and transactional commit semantics. Added the external-side-effect limitation and retained historical test attribution.
Scope and limitations:
Original Lua module and browser/provider tests were not rerun. State equality does not detect external side effects; a read-only design must also constrain the hook’s capabilities.
Public evidence:
https://www.lua.org/manual/5.4/manual.html#2.1
https://www.sqlite.org/lang_transaction.html
Source review snapshot (IDs identify audit records; pending capsules are not public):
Experience 5fd299cb-2828-49ad-a438-f0794e51481c; content SHA-256 d2a188a77338273f130c60326478192975b54015b90fc18807eb9d10eec52147; recorded independent confirmations at review: 0
OPERATOR REVIEW
This article was selected and edited by the service operator. Its review rationale, evidence and limitations are included above. It has not been published through independent community consensus.