Skip to content

Commit f176246

Browse files
author
DavidQ
committed
Level 11.1: tighten numeric validation at transition boundary
- enforce finite numeric validation using Number() normalization - prevent NaN / Infinity drift - improve validation clarity Scope: validation only
1 parent e90ca10 commit f176246

7 files changed

Lines changed: 158 additions & 63 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33

4-
TASK:
5-
<PLAN_PR | BUILD_PR | APPLY_PR name>
6-
7-
INPUTS:
8-
- docs/pr/<primary task doc>.md
9-
- docs/pr/<supporting task doc>.md
10-
11-
EXECUTION:
12-
- Follow the referenced PR doc(s) as source of truth
13-
- Read exact target files first
14-
- Keep scope surgical
15-
- Stop and report on ambiguity
16-
- Do not change engine core unless the task explicitly requires it
17-
18-
FINAL STEP:
19-
- Package all created and modified files into a repo-structured delta ZIP
20-
- Write the ZIP to: <project folder>/tmp/<TASK_NAME>_delta.zip
21-
- Preserve exact repo-relative structure inside the ZIP
22-
- Include only files relevant to this PR
23-
- Do not include unrelated files, full-repo copies, dependencies, or build artifacts
4+
COMMAND:
5+
Implement BUILD_PR_LEVEL_11_1_HANDOFF_VALIDATION_TIGHTEN.
6+
7+
Modify ONLY:
8+
src/advanced/state/transitions.js
9+
10+
Apply EXACT replacements:
11+
12+
1. validateApplyScoreDelta:
13+
- Introduce normalizedDelta = Number(payload.delta)
14+
- Enforce Number.isFinite(normalizedDelta)
15+
- Update reason to: applyScoreDelta requires finite numeric payload.delta.
16+
17+
2. validateAdvanceWave:
18+
- Keep validation logic
19+
- Update reason to: advanceWave requires finite amount > 0.
20+
21+
3. validateUpdateObjectiveProgress:
22+
- Replace inline Number(...) checks with:
23+
normalizedCurrent
24+
normalizedTarget
25+
- Enforce Number.isFinite on both
26+
- Update reasons to finite numeric wording
27+
28+
Do NOT:
29+
- change APIs
30+
- modify apply functions
31+
- refactor unrelated code
32+
- scan unrelated files
33+
34+
Validation:
35+
- All existing tests pass
36+
- Handoff test rejects invalid numeric values
37+
38+
Output:
39+
Return exactly one repo-structured ZIP at:
40+
<project folder>/tmp/BUILD_PR_LEVEL_11_1_HANDOFF_VALIDATION_TIGHTEN.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
apply(level11.1): close out authoritative state handoff candidate
1+
Level 11.1: tighten numeric validation at transition boundary
2+
3+
- enforce finite numeric validation using Number() normalization
4+
- prevent NaN / Infinity drift
5+
- improve validation clarity
6+
7+
Scope: validation only

docs/dev/PROJECT_INSTRUCTIONS.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,48 @@ If last = PLAN_PR_LEVEL_11_1_...
4242
NEXT = PLAN_PR_LEVEL_11_2_...
4343

4444
If no prior context exists:
45-
STOP and ask: "What is the base PLAN_PR?"
45+
STOP and ask: "What is the base PLAN_PR?"
46+
47+
One-shot execution rule:
48+
49+
If the user says:
50+
"Run full workflow for <PLAN_PR_NAME>" or "NEXT"
51+
52+
Then:
53+
1. Validate the PLAN
54+
2. Generate a compact BUILD_PR
55+
3. Generate Codex command
56+
4. Package a repo-structured ZIP
57+
5. Return all outputs
58+
59+
Do not ask for confirmation unless ambiguity exists.
60+
61+
OUTPUT FORMAT (STRICT)
62+
63+
When producing BUILD, PLAN, or APPLY results:
64+
65+
- ALWAYS return a downloadable ZIP
66+
- DO NOT output full command text, PR docs, or reports inline
67+
- Keep chat response minimal:
68+
- ZIP download
69+
- short summary (1–3 lines max)
70+
- NEXT step (if applicable)
71+
72+
All detailed content must be placed inside the ZIP, including:
73+
- docs/pr/*
74+
- docs/dev/codex_commands.md
75+
- docs/dev/commit_comment.txt
76+
- docs/dev/reports/*
77+
78+
If a ZIP cannot be produced:
79+
- STOP and explain why
80+
- DO NOT fall back to full inline output
81+
82+
ZIP STANDARD (ENFORCED)
83+
84+
- Exactly one ZIP per request
85+
- ZIP name MUST match PR name
86+
- ZIP path MUST be:
87+
<project folder>/tmp/<PR_NAME>.zip
88+
- Internal structure MUST be repo-relative only
89+
- No extra files outside defined structure
Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
APPLY_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE closeout completed.
1+
Updated transition validation to enforce finite numeric inputs.
22

3-
Implemented BUILD state confirmed:
4-
- strict payload validation for `updateObjectiveProgress` in `src/advanced/state/transitions.js`
5-
- invalid payload rejection coverage in `tests/world/WorldGameStateAuthoritativeHandoff.test.mjs`
3+
Targets:
4+
- applyScoreDelta: normalized + finite check
5+
- advanceWave: clarified finite requirement
6+
- updateObjectiveProgress: explicit normalized finite checks
67

7-
APPLY reporting updates:
8-
- docs/pr/APPLY_PR_LEVEL_11_1_AUTHORITATIVE_STATE_HANDOFF_CANDIDATE.md
9-
- docs/dev/commit_comment.txt
10-
- docs/dev/next_command.txt
11-
- docs/dev/reports/change_summary.txt
12-
- docs/dev/reports/validation_checklist.txt
13-
14-
Scope confirmation:
15-
- no additional implementation files were modified during APPLY closeout
16-
- no engine core API changes
17-
- no repo refactor or unrelated modifications introduced by this closeout step
18-
19-
Risks:
20-
- stricter validation may reject malformed objective payloads that previously passed lenient coercion
21-
22-
Follow-ups:
23-
- verify all objective progress producers send numeric `currentValue`/`targetValue` and boolean `isComplete`
24-
- proceed with `PLAN_PR_LEVEL_11_2_RECONCILIATION_LAYER_FOUNDATION`
8+
No API or structural changes.
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
[x] Confirmed applied BUILD scope (authoritative handoff candidate) is present in repo state.
2-
[x] Confirmed strict `updateObjectiveProgress` payload validation exists for:
3-
- non-numeric `currentValue` rejection
4-
- non-numeric `targetValue` rejection
5-
- non-boolean `isComplete` rejection
6-
[x] Confirmed targeted invalid-payload rejection test coverage exists in authoritative handoff test.
7-
[x] Ran `node tests/world/WorldGameStateAuthoritativeHandoff.test.mjs` -> PASS
8-
[x] Ran `node tests/world/WorldGameStateAuthoritativeScore.test.mjs` -> PASS
9-
[x] Ran `node --check src/advanced/state/transitions.js` -> PASS
10-
[x] Confirmed APPLY closeout remained docs/reporting only.
11-
[x] Confirmed no engine core API modifications for this closeout.
12-
[x] Confirmed no repo-wide refactor or unrelated implementation expansion.
1+
[ ] Only src/advanced/state/transitions.js modified
2+
[ ] No API changes
3+
[ ] No apply function changes
4+
[ ] Number() normalization added
5+
[ ] Number.isFinite enforced
6+
[ ] NaN rejected
7+
[ ] Infinity rejected
8+
[ ] Existing tests pass
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# BUILD PR — Level 11.1 Authoritative Handoff Validation Tighten
2+
3+
## Purpose
4+
Enforce strict finite numeric validation at transition boundary to prevent NaN / Infinity drift.
5+
6+
## Scope
7+
- Validation only
8+
- No API changes
9+
- No state shape changes
10+
11+
## File
12+
- src/advanced/state/transitions.js
13+
14+
## Changes
15+
- Normalize numeric inputs using Number()
16+
- Enforce Number.isFinite checks
17+
- Improve validation error clarity
18+
19+
## Exact file edits
20+
### validateApplyScoreDelta
21+
Replace inline numeric check with:
22+
- `const normalizedDelta = Number(payload.delta);`
23+
- `Number.isFinite(normalizedDelta)`
24+
- reason text: `applyScoreDelta requires finite numeric payload.delta.`
25+
26+
### validateAdvanceWave
27+
Keep logic unchanged except reason text becomes:
28+
- `advanceWave requires finite amount > 0.`
29+
30+
### validateUpdateObjectiveProgress
31+
Replace inline `Number(...)` finite checks with explicit normalized locals:
32+
- `normalizedCurrent`
33+
- `normalizedTarget`
34+
35+
Enforce:
36+
- `updateObjectiveProgress payload.currentValue must be finite numeric when provided.`
37+
- `updateObjectiveProgress payload.targetValue must be finite numeric when provided.`
38+
39+
## Validation
40+
- Existing tests pass
41+
- Invalid numeric payloads rejected
42+
- Valid numeric payloads accepted
43+
44+
## Risk
45+
Low (validation only)

src/advanced/state/transitions.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function validateAdvanceWave(payload) {
4444
}
4545
const amount = payload && payload.amount !== undefined ? Number(payload.amount) : 1;
4646
if (!Number.isFinite(amount) || amount <= 0) {
47-
return { ok: false, reason: 'advanceWave requires amount > 0.' };
47+
return { ok: false, reason: 'advanceWave requires finite amount > 0.' };
4848
}
4949
return { ok: true };
5050
}
@@ -53,8 +53,9 @@ function validateApplyScoreDelta(payload) {
5353
if (!isPlainObject(payload)) {
5454
return { ok: false, reason: 'applyScoreDelta requires an object payload.' };
5555
}
56-
if (!Number.isFinite(Number(payload.delta))) {
57-
return { ok: false, reason: 'applyScoreDelta requires numeric payload.delta.' };
56+
const normalizedDelta = Number(payload.delta);
57+
if (!Number.isFinite(normalizedDelta)) {
58+
return { ok: false, reason: 'applyScoreDelta requires finite numeric payload.delta.' };
5859
}
5960
return { ok: true };
6061
}
@@ -96,11 +97,13 @@ function validateUpdateObjectiveProgress(payload) {
9697
if (!objectiveId) {
9798
return { ok: false, reason: 'updateObjectiveProgress requires payload.objectiveId.' };
9899
}
99-
if (payload.currentValue !== undefined && !Number.isFinite(Number(payload.currentValue))) {
100-
return { ok: false, reason: 'updateObjectiveProgress payload.currentValue must be numeric when provided.' };
100+
const normalizedCurrent = payload.currentValue !== undefined ? Number(payload.currentValue) : null;
101+
if (payload.currentValue !== undefined && !Number.isFinite(normalizedCurrent)) {
102+
return { ok: false, reason: 'updateObjectiveProgress payload.currentValue must be finite numeric when provided.' };
101103
}
102-
if (payload.targetValue !== undefined && !Number.isFinite(Number(payload.targetValue))) {
103-
return { ok: false, reason: 'updateObjectiveProgress payload.targetValue must be numeric when provided.' };
104+
const normalizedTarget = payload.targetValue !== undefined ? Number(payload.targetValue) : null;
105+
if (payload.targetValue !== undefined && !Number.isFinite(normalizedTarget)) {
106+
return { ok: false, reason: 'updateObjectiveProgress payload.targetValue must be finite numeric when provided.' };
104107
}
105108
if (payload.isComplete !== undefined && typeof payload.isComplete !== 'boolean') {
106109
return { ok: false, reason: 'updateObjectiveProgress payload.isComplete must be boolean when provided.' };

0 commit comments

Comments
 (0)