Skip to content

Commit 0dde791

Browse files
author
DavidQ
committed
BUILD_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE
- authoritative state handoff implementation - payload validation improvements - targeted tests for invalid payload rejection validation: - handoff test - score test - syntax check scope: - src/advanced/state/* - targeted tests only
1 parent c5d0e69 commit 0dde791

6 files changed

Lines changed: 101 additions & 53 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
MODEL: GPT-5.4-codex
1+
MODEL: GPT-5.3-codex
22
REASONING: high
33

44
COMMAND:
5-
Create a small test-only patch for the current Asteroids failure.
5+
Create BUILD_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE implementation from provided payload.
66

7-
Primary target:
8-
- `tests/games/AsteroidsValidation.test.mjs`
7+
INPUT:
8+
Use provided ZIP payload.
99

10-
Do the following:
11-
1. Inspect the real file around the current failing call:
12-
- stack shows `tests/games/AsteroidsValidation.test.mjs:152:37`
13-
2. Preserve the existing structure and assertions.
14-
3. Ensure the file exports the named `run` function expected by `tests/run-tests.mjs`.
15-
4. Immediately before the failing `bootAsteroidsNew(...)` path, install the minimum Node-safe DOM/canvas shim so:
16-
- `globalThis.document` exists for this test scope
17-
- `document.getElementById('game')` returns a canvas-like object
18-
- the returned object supports the canvas methods/properties Asteroids boot actually uses
19-
5. Restore globals after the test scope finishes.
20-
6. Do not use a browser-only approach that assumes a full DOM implementation.
21-
7. Do not edit `games/Asteroids/index.js`.
10+
REQUIREMENTS:
11+
- Implement authoritative state handoff per PR intent
12+
- Maintain strict separation engine/game
13+
- Use approved selectors/events only
14+
- No engine core API changes unless required
15+
- Preserve backward compatibility
16+
- Add contract validation
2217

23-
Secondary target, only if still failing in the current branch:
24-
- `tests/tools/VectorNativeTemplate.test.mjs`
25-
- update expected path from `templates/vector-native-arcade/` to `tools/templates/vector-native-arcade/`
18+
CONSTRAINTS:
19+
- Minimal, surgical changes only
20+
- No unrelated modifications
2621

27-
Success criteria:
28-
- `npm test --ignore-scripts > output.txt`
29-
- the first failure is no longer `Missing #game canvas element`
30-
- `PASS AsteroidsValidation` appears
31-
- stop after the first new failure, if any, and report it
22+
OUTPUT (CRITICAL):
23+
- Provide ONE download ZIP (delta only)
24+
- Repo-structured
25+
- Only changed/added files
26+
- No full repo copies
27+
28+
ALSO INCLUDE:
29+
- docs/dev/commit_comment.txt
30+
- docs/dev/next_command.txt

docs/dev/COMMIT_COMMENT.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
Fix AsteroidsValidation test canvas shim for Node runner
1+
BUILD_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE
22

3-
- preserve named run export contract
4-
- add minimal node-safe #game canvas shim before bootAsteroidsNew
5-
- restore globals after test scope
6-
- optionally align VectorNativeTemplate path assertion if still stale
3+
- authoritative state handoff implementation
4+
- payload validation improvements
5+
- targeted tests for invalid payload rejection
6+
7+
validation:
8+
- handoff test
9+
- score test
10+
- syntax check
11+
12+
scope:
13+
- src/advanced/state/*
14+
- targeted tests only

docs/dev/NEXT_COMMAND.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
After Codex completes and validation passes:
2-
APPLY_PR_ENGINE_IMPORT_BASELINE_AND_CONTRACT_VALIDATE
1+
MODEL: GPT-5.3-codex
2+
REASONING: high
3+
4+
COMMAND:
5+
Create APPLY_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE docs-only closeout.
6+
7+
REQUIREMENTS:
8+
- summarize implementation
9+
- confirm validation
10+
- no code changes
11+
12+
OUTPUT:
13+
- repo-structured delta ZIP
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
Purpose:
2-
- eliminate the current Asteroids test blocker in plain Node
3-
4-
Current blocker:
5-
- `Missing #game canvas element`
6-
- thrown by `bootAsteroidsNew(...)`
7-
- invoked from `tests/games/AsteroidsValidation.test.mjs`
8-
9-
Expected patch style:
10-
- test-only
11-
- minimum diff
12-
- no production game code changes
13-
- no full-file replacement
1+
Level 11.1 authoritative handoff minimal scoped implementation.
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
[ ] `tests/games/AsteroidsValidation.test.mjs` updated with minimum shim
2-
[ ] named `run` export preserved
3-
[ ] globals restored after test
4-
[ ] `games/Asteroids/index.js` unchanged
5-
[ ] `npm test --ignore-scripts > output.txt` run
6-
[ ] no `Missing #game canvas element`
7-
[ ] `PASS AsteroidsValidation`
8-
[ ] if a new failure appears, capture only the first new failure
1+
All targeted tests passed.
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
Enforced 11.1 authoritative handoff candidate.
1+
# BUILD_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE
2+
3+
## Purpose
4+
Implement the Level 11.1 authoritative state handoff candidate with the smallest possible surgical scope. Keep the work limited to authoritative-state transition validation and targeted test coverage needed for this PR purpose.
5+
6+
## Scope
7+
Primary target files:
8+
- `src/advanced/state/transitions.js`
9+
- `tests/world/WorldGameStateAuthoritativeHandoff.test.mjs`
10+
11+
Allowed nearby reads:
12+
- `src/advanced/state/*`
13+
- `tests/world/*Authoritative*.mjs`
14+
15+
## Required implementation
16+
Add strict validation for `updateObjectiveProgress` transition payloads:
17+
- reject non-numeric `currentValue` when provided
18+
- reject non-numeric `targetValue` when provided
19+
- reject non-boolean `isComplete` when provided
20+
21+
Add targeted test coverage proving invalid objective progress payloads are rejected in the authoritative handoff flow:
22+
- request `updateObjectiveProgress` with invalid payload
23+
- assert rejection is returned
24+
- assert rejection code is `INVALID_PAYLOAD`
25+
- assert rejection event type is `WORLD_GAME_STATE_EVENT_TYPES.TRANSITION_REJECTED`
26+
- assert no invalid objective snapshot is stored
27+
28+
## Acceptance criteria
29+
- invalid `updateObjectiveProgress` payloads are rejected deterministically
30+
- no new engine/game coupling is introduced
31+
- no unrelated state transitions are changed
32+
- no unrelated tests are edited
33+
- passive and authoritative modes continue to coexist without regression
34+
35+
## Validation
36+
Run only:
37+
- `node tests/world/WorldGameStateAuthoritativeHandoff.test.mjs`
38+
- `node tests/world/WorldGameStateAuthoritativeScore.test.mjs`
39+
- `node --check src/advanced/state/transitions.js`
40+
41+
## Non-goals
42+
- no repo-wide cleanup
43+
- no roadmap wording changes
44+
- no script/tooling changes
45+
- no start_of_day changes
46+
- no broad refactor
47+
- no engine core API redesign
48+
49+
## Working tree rule
50+
If the tree is already dirty, ignore unrelated files and modify only the scoped implementation files for this PR purpose.

0 commit comments

Comments
 (0)