|
| 1 | +# PLAN_PR_SAMPLES_METADATA_LAYER |
| 2 | + |
| 3 | +## Objective |
| 4 | +Define a minimal metadata layer for canonical sample paths so generated `samples/index.html` rendering has stable, human-readable titles, descriptions, and tags. |
| 5 | + |
| 6 | +## Scope |
| 7 | +Docs-only planning. |
| 8 | +No implementation code changes. |
| 9 | +No gameplay scope. |
| 10 | +No engine-core scope. |
| 11 | +No start_of_day directory changes. |
| 12 | + |
| 13 | +## Canonical Path Contract (Source of Truth #1) |
| 14 | +- Folder structure remains canonical: `samples/phaseXX/XXYY/index.html` |
| 15 | +- Path shape determines discoverability and link targets. |
| 16 | +- Path shape does not own display copy. |
| 17 | + |
| 18 | +## Minimal Metadata Schema (Source of Truth #2) |
| 19 | +Proposed schema for each sample entry: |
| 20 | +- `id` (string, required): 4-digit sample id, e.g. `1316` |
| 21 | +- `phase` (string, required): 2-digit phase id, e.g. `13` |
| 22 | +- `title` (string, required): stable human-readable sample title |
| 23 | +- `description` (string, required): short tile/section description |
| 24 | +- `tags` (array<string>, required, may be empty): filter/display tags |
| 25 | + |
| 26 | +Derived (not stored) fields: |
| 27 | +- `href`: computed from canonical folders -> `./phaseXX/XXYY/index.html` |
| 28 | + |
| 29 | +## Metadata Location |
| 30 | +Single metadata file, repo-local and minimal: |
| 31 | +- `samples/metadata/samples.index.metadata.json` |
| 32 | + |
| 33 | +Why this location: |
| 34 | +- keeps sample-display content near samples domain |
| 35 | +- avoids engine/tool coupling |
| 36 | +- provides one narrow source for index-render copy |
| 37 | + |
| 38 | +## Source-of-Truth Boundaries |
| 39 | +1. Canonical folder structure (`samples/phaseXX/XXYY/`): |
| 40 | + - owns existence/discovery of runnable sample entrypoints |
| 41 | + - owns path validity |
| 42 | + |
| 43 | +2. Metadata file (`samples.index.metadata.json`): |
| 44 | + - owns titles/descriptions/tags |
| 45 | + - must not define non-canonical paths |
| 46 | + |
| 47 | +3. Generated index rendering (`samples/index.html`): |
| 48 | + - owns final HTML presentation only |
| 49 | + - consumes canonical discovery + metadata |
| 50 | + - must not become a manual content source |
| 51 | + |
| 52 | +## Fail-Fast Rules for Future BUILD |
| 53 | +Stop generation immediately when any of the following occur: |
| 54 | +- duplicate IDs in metadata |
| 55 | +- duplicate metadata entries for same sample id |
| 56 | +- phase/sample mismatch: |
| 57 | + - metadata `phase` does not match `id[:2]` |
| 58 | + - metadata id not found in canonical folder structure |
| 59 | + - canonical sample missing corresponding metadata entry (if strict mode enabled) |
| 60 | +- missing required fields (`id`, `phase`, `title`, `description`, `tags`) |
| 61 | +- non-array `tags` |
| 62 | +- malformed canonical directories (`phaseXX` / `XXYY` violations) |
| 63 | +- missing canonical sample entrypoint `index.html` |
| 64 | + |
| 65 | +## Future BUILD Shape (Narrow + Testable) |
| 66 | +1. Discover canonical samples from `samples/phaseXX/XXYY/`. |
| 67 | +2. Load and validate metadata file with fail-fast checks. |
| 68 | +3. Join canonical set + metadata by sample id. |
| 69 | +4. Generate index sections/tiles from joined data. |
| 70 | +5. Validate representative links and console cleanliness. |
| 71 | + |
| 72 | +## Testability Requirements for Future BUILD |
| 73 | +Minimum testability gates: |
| 74 | +- `samples/index.html` loads after generation |
| 75 | +- representative links open correctly: |
| 76 | + - first sample in first populated phase |
| 77 | + - last sample in last populated phase |
| 78 | + - phase 13 samples: 1316, 1317, 1318 |
| 79 | +- no console errors for tested pages |
| 80 | +- generated output remains deterministic for unchanged inputs |
| 81 | + |
| 82 | +## Out of Scope |
| 83 | +- changing gameplay code |
| 84 | +- changing engine core |
| 85 | +- broad refactors |
| 86 | +- modifying start_of_day instruction directories |
| 87 | + |
| 88 | +## Acceptance Criteria (Planning PR) |
| 89 | +- minimal schema defined |
| 90 | +- metadata location defined |
| 91 | +- source-of-truth boundaries defined |
| 92 | +- fail-fast rules defined |
| 93 | +- future BUILD remains narrowly scoped and testable |
0 commit comments