You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0691521
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/ai/simulate/graphs/spec-processing-graph/nodes/extract-instructions/prompts.ts
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,8 @@ Focus on:
104
104
- **players.{{playerId}}.actionRequired**: Set by mechanics ONLY — never by player action stateDelta. The router uses \`currentAction != null\` to detect a submitted action.
105
105
- **players.{{playerId}}.actionsAllowed**: A \`boolean\` — set \`true\` to allow actions, \`false\` to prevent them. Do NOT set it to an array of action IDs or strings. It is not an allowlist; action validation is handled entirely by the \`validation.checks\` in \`playerPhaseInstructions\`. In most transitions simply set it to \`true\` or \`false\` alongside \`actionRequired\`.
106
106
- **Player action stateDelta**: MUST ONLY write \`players.{{playerId}}.currentAction\`. Any other write is stripped at runtime. Persisting player choices into other fields (e.g. a \`submittedData\` or \`selectionMade\` flag) is forbidden — the mechanic in the following automatic transition reads from \`currentAction\` instead.
107
+
- **Validation enum casing**: String literals in \`validation.checks\` allowed-value arrays MUST use the exact same casing as the corresponding field's \`enumValues\` in the state schema. If the schema defines \`["rock", "paper", "scissors"]\` (lowercase), the validation check MUST also use lowercase. Mismatched casing causes every submission to be rejected before the mechanic runs.
108
+
- **No timeout or missing-submission fallback in mechanicsGuidance**: The runtime has no concept of timeouts or time limits. When all players have submitted (guaranteed by \`allPlayersCompletedActions\` precondition), every player's \`currentAction\` will be non-null. Do NOT include instructions like "if a player has no submitted currentAction (timeout), assign a random choice" — this language will be generated into mechanic code that adds unreachable fallback branches and implies the platform supports timeouts, which it does not. Always write mechanicsGuidance as if all required submissions are present.
107
109
- **allPlayersCompletedActions**: A router-computed context field that is \`true\` when every player who has \`actionRequired == true\` has also submitted a non-null \`currentAction\`. For transitions that fire when ALL players have simultaneously submitted, the transitions artifact precondition MUST use \`{{"var": "allPlayersCompletedActions"}}\` — do NOT invent a custom boolean signal field for this purpose. Custom signal fields create a circular dependency: the mechanic can only set them after the transition fires, but the transition won't fire until they're set.
108
110
- **Signal field reset rule**: If a transition fires based on a boolean signal field (e.g. \`bothPlayersSelected: true\`), the mechanic for that transition — or the mechanic for the immediately following transition — MUST reset that signal field back to \`false\` before the game loops back to the phase that sets it. Failure to reset causes the transition to re-fire immediately on the next iteration without waiting for player input, producing an infinite loop. Always include an explicit "reset signal fields to false" step in the computation guidance for any transition that consumes a boolean signal.
109
111
- **Duplicate-submission guard**: Do NOT use \`players.{{playerId}}.currentAction.type != null\` as a validation check to prevent a player from submitting twice. By the time validation runs, \`currentAction.type\` has already been written by the current action — so this guard is always true and rejects every submission including the first. Instead, guard against double submission using a **persistent state field that the automatic mechanic writes** after successfully processing the submission (e.g., a flag or non-null field that only exists in state after the mechanic has run). That field is \`null\`/\`false\` on the first legitimate submission and set on any subsequent attempt.
Copy file name to clipboardExpand all lines: src/ai/simulate/graphs/spec-processing-graph/nodes/extract-transitions/prompts.ts
+37-2Lines changed: 37 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -176,11 +176,17 @@ immediately or never, breaking the game.
176
176
NOT imply a timeout fallback. Do not add \`submission_timeout\` or similar transitions.
177
177
178
178
## 7. Use allPlayersCompletedActions for Simultaneous Submissions
179
-
When a transition fires after ALL players have submitted their action simultaneously, use the computed context field \`allPlayersCompletedActions\` as the precondition — do NOT invent a custom boolean signal field (e.g. \`allActionsSubmitted\`, \`allPlayersReady\`).
179
+
When a transition fires after ALL players have submitted, selected, chosen, or acted simultaneously,
180
+
use the computed context field \`allPlayersCompletedActions\` as the precondition — do NOT invent a
181
+
custom boolean signal field (e.g. \`allActionsSubmitted\`, \`allPlayersReady\`, \`allPlayersSubmitted\`,
182
+
\`allChoicesMade\`, \`everyoneActed\`).
180
183
181
184
Custom signal fields create a **circular dependency**: the mechanic can only set them after the transition fires, but the transition won't fire until they are set → permanent deadlock.
182
185
183
-
\`allPlayersCompletedActions\` is true when every player with \`actionRequired == true\` has submitted a non-null \`currentAction\`. It is computed by the router before each transition evaluation — no mechanic needs to set it.
186
+
\`allPlayersCompletedActions\` is true when every player with \`actionRequired == true\` has submitted
187
+
a non-null \`currentAction\`. This covers all equivalent game-design phrasings: "both players chose",
188
+
"all players selected", "everyone has acted", "all choices are in", "all submissions received".
189
+
It is computed by the router before each transition evaluation — no mechanic needs to set it.
184
190
185
191
\`\`\`json
186
192
// ❌ Wrong — allWeaponsSubmitted is never set before this transition fires
@@ -190,6 +196,35 @@ Custom signal fields create a **circular dependency**: the mechanic can only set
⛔ **CRITICAL: Do NOT use \`allPlayersCompletedActions\` alone on a gate transition.**
200
+
201
+
A "gate transition" goes from a player-input phase to an intermediate automatic phase (e.g. \`choosing → resolving\`) with \`allPlayersCompletedActions\` as its ONLY meaningful precondition. This is a **Rule 4 waypoint violation** AND a **data-destruction bug**:
202
+
203
+
The gate mechanic runs and clears every player's \`currentAction\` field — permanently destroying the submitted data — **before** the actual processing mechanic in the next phase can read it. The processing mechanic then reads \`null\` and crashes. The crash checkpoint persists, and every subsequent player action re-triggers the same crash.
204
+
205
+
**For simultaneous-submission games, processing transitions MUST fire directly from the player-input phase**, combining \`allPlayersCompletedActions == true\` with their game-specific branch conditions. The router's own wait logic already holds until all players have submitted — a gate transition adds nothing and destroys data.
{{"explain": "any player has reached the win threshold OR no more rounds remain"}}
223
+
] }}
224
+
\`\`\`
225
+
226
+
Note: The turn-rotation self-loop pattern in Rule 5 (\`all_players_chose: choosing → resolution\`) is safe because each player's submission is processed by the per-turn self-loop mechanic before \`all_players_chose\` fires — \`currentAction\` is already cleared. The anti-pattern here applies only to **simultaneous submission** where all players act without per-submission mechanics.
227
+
193
228
## 8. Precondition Hint Writing Style
194
229
When writing \`explain\` text, use these patterns so the executor synthesizes correct JsonLogic:
0 commit comments