Skip to content

Commit cecd599

Browse files
author
DavidQ
committed
Enforce schema-only validation and visible tool input errors - PR 11.110
1 parent fadd096 commit cecd599

26 files changed

Lines changed: 1070 additions & 99 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,62 @@
33
Model: GPT-5.3-codex
44
Reasoning: medium
55

6-
1. Scan all tool references after PR 11.105 cleanup
6+
## PR
7+
BUILD_PR_LEVEL_11_110_SCHEMA_ONLY_VALIDATION_SCREEN_ERRORS
78

8-
2. For each tool:
9-
- verify input JSON exists
10-
- verify schema matches
11-
- verify tool loads actual data (not defaults)
9+
## Execute
1210

13-
3. Remove tool reference if:
14-
- input missing
15-
- loads defaults
16-
- invalid structure
17-
- no visible usable output
11+
1. Extend the PR 11.109 direct JSON contract:
12+
- JSON is loaded directly.
13+
- The only validation is schema validation.
14+
- Invalid data must show a visible screen error.
1815

19-
4. Do NOT:
20-
- create placeholder data
21-
- use fallback/default values
22-
- loosen schema
16+
2. Inspect tool input/loading paths only.
2317

24-
5. Validate updated manifests
18+
3. Remove or bypass custom validation outside schema validation, except:
19+
- file exists
20+
- JSON parse
2521

26-
6. Output:
27-
docs/dev/reports/runtime_contract_enforcement_11_108.txt
22+
4. Ensure every schema validation failure renders a clear UI error.
23+
24+
5. Error must include when available:
25+
- tool id/name
26+
- JSON source path
27+
- schema path/name
28+
- failed field/path
29+
- validation summary
30+
31+
6. Do not:
32+
- normalize
33+
- transform
34+
- convert
35+
- repair
36+
- infer
37+
- inject defaults
38+
- fallback to sample/demo data
39+
- accept aliases
40+
- add custom validation rules outside schema
41+
42+
7. If a validation rule is needed, put it in schema, not runtime code.
43+
44+
8. Preserve compact primitive-array formatting.
45+
46+
9. Validate targeted cases:
47+
- valid JSON input renders
48+
- invalid schema JSON shows screen error
49+
- missing file shows screen error
50+
- malformed JSON shows screen error
51+
- invalid JSON does not fallback to defaults
52+
53+
10. Write reports:
54+
- docs/dev/reports/schema_only_validation_11_110.txt
55+
- docs/dev/reports/screen_error_contract_11_110.txt
56+
- docs/dev/reports/non_schema_validation_paths_11_110.txt
57+
58+
11. Roadmap:
59+
- status-only update if execution-backed
60+
- do not rewrite roadmap text
61+
- do not delete roadmap text
62+
63+
12. Package Codex output ZIP at:
64+
tmp/PR_11_110_SCHEMA_ONLY_VALIDATION_SCREEN_ERRORS.zip

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Enforce runtime input contracts so all remaining tools are real and working - PR 11.108
1+
Enforce schema-only validation and visible tool input errors - PR 11.110

docs/dev/reports/launch_smoke_report.md

Lines changed: 278 additions & 3 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
PR 11.110 - Non-schema validation paths review
2+
3+
Scope reviewed:
4+
- Tool JSON input/loading boundaries in updated sample-preset loaders.
5+
- Shared loaded-boundary diagnostics gate.
6+
7+
Allowed non-schema checks retained:
8+
1) Input path presence check
9+
- samplePresetPath missing -> visible status warning/error.
10+
- Rationale: allowed pre-schema boundary (input exists check).
11+
12+
2) File fetch availability check
13+
- HTTP response.ok required before JSON parse.
14+
- Rationale: allowed pre-schema boundary (file exists / fetch success check).
15+
16+
3) JSON parse check
17+
- response.json() parse failures surface as visible load failure text.
18+
- Rationale: allowed pre-schema boundary (JSON parse check).
19+
20+
Remaining post-schema custom checks still present in changed loader paths:
21+
- tools/Sprite Editor/modules/spriteEditorApp.js
22+
- throw new Error("Preset payload did not include a sprite project.")
23+
- tools/SVG Asset Studio/main.js
24+
- throw new Error("Preset did not include a vector SVG payload.")
25+
- tools/Tilemap Studio/main.js
26+
- throw new Error("Preset payload did not include a tilemap document or tilemap document path.")
27+
- throw new Error("Preset payload did not include a tilemap document.")
28+
29+
Why these remain in this PR:
30+
- These three tools currently have multi-step payload/document resolution paths and runtime dependencies not fully represented by current schema required fields.
31+
- Removing those checks without simultaneous schema hardening for those tool-specific runtime document contracts would risk loading undefined documents into editor state flows.
32+
33+
What was removed/bypassed in this PR (post-schema custom load throws removed):
34+
- 3D Asset Viewer (payload presence/vertex-count throw removed from preset-load path)
35+
- 3D Camera Path Editor (payload presence/waypoint-count throw removed from preset-load path)
36+
- 3D JSON Payload (payload presence/point-count throw removed from preset-load path)
37+
- Asset Browser (preset field throw removed from preset-load path)
38+
- Asset Pipeline (pipeline-options presence throw removed from preset-load path)
39+
- Palette Browser (palette presence throw removed from preset-load path)
40+
- Performance Profiler (profileSettings presence throw removed from preset-load path)
41+
- Physics Sandbox (physicsBody presence throw removed from preset-load path)
42+
- Replay Visualizer (replay events presence throw removed from preset-load path)
43+
- State Inspector (snapshot presence throw removed from preset-load path)
44+
- Tile Model Converter (candidate/conversion presence throw removed from preset-load path)
45+
- Vector Map Editor (vector map document presence throw removed from preset-load path)
46+
47+
Conclusion:
48+
- Schema-only validation is now enforced at the shared loaded boundary for updated loaders.
49+
- Allowed non-schema checks are restricted to file-exists and JSON-parse boundaries.
50+
- Three complex editor loaders retain targeted post-schema checks and are explicitly documented above.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
PR 11.110 - Schema-only validation boundary enforcement
2+
3+
Purpose implemented:
4+
- Tool sample preset JSON is validated against the tool schema at load-time.
5+
- Schema failures now surface as visible on-screen load errors through existing status-text paths.
6+
7+
Validation path changes:
8+
1) Added shared schema-only validator
9+
- tools/shared/schemaOnlyToolPresetValidation.js
10+
- Loads canonical schema by tool id: /tools/schemas/tools/<toolId>.schema.json
11+
- Validates loaded JSON value against schema (strict object/array/type/required/additionalProperties checks)
12+
- Throws a formatted contract error with:
13+
- tool id/name
14+
- JSON source path
15+
- schema path
16+
- failed field/path
17+
- validation summary
18+
19+
2) Wired schema gate into shared loaded boundary
20+
- tools/shared/toolLoadDiagnostics.js
21+
- logToolLoadLoaded is now async.
22+
- When loadedDocument is provided, schema validation runs before boundary emission.
23+
- Invalid schema now throws before tool-specific extraction/normalization path continues.
24+
25+
3) Updated active sample-preset load callers to await loaded-boundary schema validation and pass loadedDocument
26+
- tools/3D Asset Viewer/main.js
27+
- tools/3D Camera Path Editor/main.js
28+
- tools/3D JSON Payload/main.js
29+
- tools/Asset Browser/main.js
30+
- tools/Asset Pipeline/main.js
31+
- tools/Palette Browser/main.js
32+
- tools/Parallax Scene Studio/main.js
33+
- tools/Performance Profiler/main.js
34+
- tools/Physics Sandbox/main.js
35+
- tools/Replay Visualizer/main.js
36+
- tools/SVG Asset Studio/main.js
37+
- tools/Sprite Editor/modules/spriteEditorApp.js
38+
- tools/State Inspector/main.js
39+
- tools/Tile Model Converter/main.js
40+
- tools/Tilemap Studio/main.js
41+
- tools/Vector Map Editor/editor/VectorMapEditorApp.js
42+
43+
Schema-only load-path simplifications applied in this PR:
44+
- Removed several post-load custom required-field throws and switched to canonical payload access in:
45+
- 3D Asset Viewer
46+
- 3D Camera Path Editor
47+
- 3D JSON Payload
48+
- Asset Browser
49+
- Asset Pipeline
50+
- Palette Browser
51+
- Performance Profiler
52+
- Physics Sandbox
53+
- Replay Visualizer
54+
- State Inspector
55+
- Tile Model Converter
56+
- Vector Map Editor
57+
58+
Targeted validation executed:
59+
1) Syntax checks
60+
- node --check on changed JS files
61+
- Result: PASS for all changed JS files, including tools/shared/schemaOnlyToolPresetValidation.js
62+
63+
2) Schema gate behavior sanity (targeted runtime helper check)
64+
- Ran a targeted Node ESM script invoking enforceToolPresetSchemaOnlyContract with mocked fetch.
65+
- Evidence:
66+
- PASS valid payload accepted
67+
- PASS invalid payload rejected with contract details
68+
- PASS cached schema path remains operational for repeated validation
69+
70+
3) Screen-error path wiring checks
71+
- Verified changed load paths contain:
72+
- awaited schema gate at loaded boundary
73+
- visible load-failed status text path
74+
- Result: PASS for updated loader files.
75+
76+
4) Launch smoke regression check
77+
- npm run test:launch-smoke -- --tools
78+
- Result: PASS=287 FAIL=0 TOTAL=287
79+
- Report regenerated at docs/dev/reports/launch_smoke_report.md
80+
81+
Acceptance summary:
82+
- Schema validation is now a first-class load boundary for updated tool preset loaders.
83+
- Invalid schema data is rejected before downstream tool loading logic.
84+
- Rejections surface as visible on-screen load errors through existing tool status text outputs.
85+
- Missing file and malformed JSON still surface as visible load failures via existing catch/status paths.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PR 11.110 - Screen error contract
2+
3+
Error contract implemented for schema validation failures:
4+
- Source formatter: tools/shared/schemaOnlyToolPresetValidation.js
5+
- Message format (single visible status line):
6+
Input validation failed. tool=<toolId> (<toolName>); source=<jsonPath>; schema=<schemaPath>; failed=<failedField>; summary=<validationSummary>
7+
8+
Contract fields included when available:
9+
- tool id/name: always provided from loader call context
10+
- JSON source path: requestedPath/samplePresetPath from loader context
11+
- schema path/name: /tools/schemas/tools/<toolId>.schema.json
12+
- failed field/path: derived from first validator error pointer
13+
- validation summary: first validation errors joined in message
14+
15+
Visible UI error locations (status elements updated by existing tool setStatus paths):
16+
- 3D Asset Viewer: #asset3dStatus
17+
- 3D Camera Path Editor: #cameraPathStatus
18+
- 3D JSON Payload: #jsonPayloadStatus
19+
- Asset Browser: #importStatusText
20+
- Asset Pipeline: #assetPipelineStatus
21+
- Palette Browser: #paletteSelectionText
22+
- Parallax Scene Studio: #statusText
23+
- Performance Profiler: #performanceStatusText
24+
- Physics Sandbox: #physicsSandboxStatus
25+
- Replay Visualizer: #replayStatusText
26+
- SVG Asset Studio: #statusText
27+
- Sprite Editor: sprite editor status line via setStatus(state, ...)
28+
- State Inspector: #stateStatusText
29+
- Tile Model Converter: #tileModelStatus
30+
- Tilemap Studio: tilemap status line via updateStatus(...)
31+
- Vector Map Editor: vector map status line via setStatus(...)
32+
33+
Missing file / malformed JSON visibility:
34+
- Missing file path (HTTP !ok) remains surfaced as Preset load failed: Preset request failed (<status>).
35+
- Malformed JSON parse failures remain surfaced through catch blocks as Preset load failed: <parse error>.
36+
- These are preserved as allowed pre-schema failures (file exists + JSON parse boundary).
37+
38+
No fallback/default behavior introduced for invalid schema payloads in updated load boundaries:
39+
- Schema failure throws before downstream payload extraction path in updated loaders.

docs/dev/restart_notes_11_110.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Restart Notes — PR 11.110
2+
3+
Caveat added:
4+
- The only validation is schema validation.
5+
- If JSON does not match schema, show the error on screen.
6+
- Runtime must not normalize, transform, convert, repair, infer, or fallback.
7+
- Missing file and malformed JSON are allowed pre-schema errors and must also be visible.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# BUILD_PR_LEVEL_11_110_SCHEMA_ONLY_VALIDATION_SCREEN_ERRORS
2+
3+
## Purpose
4+
Enforce schema-only validation for tool JSON inputs and require visible on-screen errors when input does not match schema.
5+
6+
## Scope
7+
- docs-first
8+
- no implementation code
9+
- direct JSON contract refinement
10+
- no schema lock yet
11+
- no feature expansion
12+
- no fallback behavior
13+
14+
## Core Rule
15+
16+
The ONLY validation allowed is schema validation.
17+
18+
If the JSON does not match the schema, the tool must show an error on screen.
19+
20+
## Required Behavior
21+
22+
For every tool input load:
23+
24+
1. Load the explicitly referenced JSON file.
25+
2. Validate it against the matching JSON schema.
26+
3. If valid:
27+
- render the tool using the JSON as-is.
28+
4. If invalid:
29+
- do not normalize
30+
- do not transform
31+
- do not convert
32+
- do not repair
33+
- do not infer missing fields
34+
- do not inject defaults
35+
- do not fallback to sample data
36+
- show a clear on-screen schema validation error.
37+
38+
## Error Display Requirement
39+
40+
Schema errors must be visible in the tool UI.
41+
42+
Minimum on-screen error must include:
43+
- tool id/name
44+
- JSON file/source path if available
45+
- schema name/path if available
46+
- validation failure summary
47+
- failed field/path if available
48+
49+
## Disallowed Validation
50+
51+
Do not add custom validation rules outside the schema.
52+
53+
Disallowed:
54+
- manual required-field checks outside schema
55+
- special-case tool validation
56+
- compatibility checks
57+
- alias acceptance
58+
- legacy shape detection
59+
- runtime coercion
60+
- runtime type conversion
61+
- default substitution
62+
63+
If a rule is required, it belongs in the schema.
64+
65+
## Allowed Non-Schema Checks
66+
67+
Only these are allowed before schema validation:
68+
- file exists
69+
- JSON parses
70+
71+
If file is missing or JSON parse fails, show a clear on-screen error.
72+
73+
## Required Reports
74+
75+
Codex must write:
76+
77+
- docs/dev/reports/schema_only_validation_11_110.txt
78+
- docs/dev/reports/screen_error_contract_11_110.txt
79+
- docs/dev/reports/non_schema_validation_paths_11_110.txt
80+
81+
Reports must identify:
82+
- validation paths changed
83+
- remaining non-schema checks
84+
- why any remaining check is allowed
85+
- UI error locations updated
86+
87+
## Validation
88+
89+
Targeted validation only.
90+
91+
Required:
92+
- valid JSON renders
93+
- invalid schema JSON shows visible screen error
94+
- no fallback/default/normalization path handles invalid JSON
95+
- no custom validation remains in changed paths except file exists / JSON parse
96+
97+
## Full Samples Smoke Test
98+
99+
Skipped.
100+
101+
Reason:
102+
- targeted validation-contract cleanup
103+
- no broad sample smoke test unless shared loader behavior changes require it
104+
- full samples smoke test takes approximately 20 minutes
105+
106+
## Acceptance
107+
108+
- Schema is the only validation gate.
109+
- Invalid schema data produces visible screen errors.
110+
- Tools do not repair invalid input.
111+
- Missing file and JSON parse errors are visible.
112+
- No new fallback/default behavior is introduced.

0 commit comments

Comments
 (0)