|
| 1 | +# PLAN_PR_SAMPLES_FILTER_AND_SEARCH |
| 2 | + |
| 3 | +## Objective |
| 4 | +Define a narrow, testable filter-and-search layer for `samples/index.html` using canonical sample paths and metadata-driven readable content. |
| 5 | + |
| 6 | +## Scope |
| 7 | +Docs-only planning. |
| 8 | +No implementation code changes. |
| 9 | +No gameplay scope. |
| 10 | +No engine-core scope. |
| 11 | +No path normalization changes. |
| 12 | +No start_of_day directory changes. |
| 13 | + |
| 14 | +## Minimal UX Definition |
| 15 | +### 1) Phase filtering |
| 16 | +- Control: single-select phase dropdown/chips. |
| 17 | +- Default: `All phases`. |
| 18 | +- Behavior: when phase is selected, only samples from that phase are shown. |
| 19 | + |
| 20 | +### 2) Tag filtering |
| 21 | +- Control: multi-select tag chips/checkboxes. |
| 22 | +- Default: no tags selected. |
| 23 | +- Behavior: selected tags apply as AND across tags (sample must include every selected tag). |
| 24 | + |
| 25 | +### 3) Search |
| 26 | +- Control: single text input. |
| 27 | +- Default: empty. |
| 28 | +- Behavior: case-insensitive substring match across: |
| 29 | + - sample title |
| 30 | + - sample description |
| 31 | + - sample tags |
| 32 | + - sample id |
| 33 | + |
| 34 | +## Combined State Behavior |
| 35 | +Result set is computed as: |
| 36 | +1. Canonical discovered sample set (`samples/phaseXX/XXYY/index.html`) |
| 37 | +2. Joined with metadata by sample id |
| 38 | +3. Filtered by phase (if not `All`) |
| 39 | +4. Filtered by selected tags (AND semantics) |
| 40 | +5. Filtered by search query |
| 41 | +6. Rendered in stable ascending sample-id order |
| 42 | + |
| 43 | +Empty state behavior: |
| 44 | +- Show explicit ?No matching samples? message. |
| 45 | +- Preserve controls and current filter/search state. |
| 46 | + |
| 47 | +## Source-of-Truth Boundaries |
| 48 | +1. Canonical folder structure |
| 49 | +- owns existence of runnable samples and link targets |
| 50 | +- owns path validity only |
| 51 | + |
| 52 | +2. Metadata |
| 53 | +- owns human-readable title, description, tags |
| 54 | +- must not override canonical href computation |
| 55 | + |
| 56 | +3. Index UI behavior |
| 57 | +- owns transient filter/search state and rendering of current result set |
| 58 | +- must not become a metadata source |
| 59 | + |
| 60 | +## Validation + Fail-Fast Expectations |
| 61 | +Fail fast (stop generation/render pipeline) on: |
| 62 | +- duplicate sample IDs in metadata |
| 63 | +- duplicate sample entries for same id |
| 64 | +- phase/sample mismatch (`phase` vs `id[:2]`) |
| 65 | +- missing required metadata fields (`id`, `phase`, `title`, `description`, `tags`) |
| 66 | +- malformed canonical phase/sample directories |
| 67 | +- missing canonical sample entrypoints |
| 68 | + |
| 69 | +Validation expectations for future BUILD: |
| 70 | +- generated index loads |
| 71 | +- phase filter reduces visible set correctly |
| 72 | +- tag filter applies AND behavior correctly |
| 73 | +- search filters correctly (case-insensitive) |
| 74 | +- combined state produces deterministic result set |
| 75 | +- representative links still load: |
| 76 | + - first sample in first populated phase |
| 77 | + - last sample in last populated phase |
| 78 | + - phase 13 samples: 1316, 1317, 1318 |
| 79 | +- console clean for tested pages |
| 80 | + |
| 81 | +## Future BUILD Scope Guard (Narrow + Testable) |
| 82 | +In scope: |
| 83 | +- index UI filter/search layer |
| 84 | +- metadata-driven render integration for readable content |
| 85 | +- minimal test harness/report updates needed to validate behavior |
| 86 | + |
| 87 | +Out of scope: |
| 88 | +- gameplay changes |
| 89 | +- engine-core changes |
| 90 | +- path normalization or sample relocation |
| 91 | +- broad UI refactor beyond filter/search controls and result rendering |
| 92 | + |
| 93 | +## Acceptance Criteria (Planning PR) |
| 94 | +- minimal UX contract defined |
| 95 | +- combined-state behavior defined |
| 96 | +- source-of-truth boundaries defined |
| 97 | +- validation + fail-fast expectations defined |
| 98 | +- future BUILD remains narrowly scoped and testable |
0 commit comments