# Prototype: idea validation

A throwaway, dependency-free web page for **one topic, T3 DFA design**: levels T3.1–T3.3 from [docs/03](../docs/03-content-toc.md) are built; T3.4, T3.5, T3.6 and T3.T are shown as TBD. It exists to see and feel the pedagogy, and to put it in front of a few students before building the real engine. It is **not** the planned Rust/WASM engine ([docs/07](../docs/07-architecture.md)), whose skeleton stays deferred.

## Run it
```sh
cd prototype/t3
python3 -m http.server 8000
```
Then open <http://localhost:8000>. Any static file server works (the page uses ES modules, so opening `index.html` directly from disk won't).

To check the grading engine and the learner model: `node test.mjs` (from `prototype/t3`).

Files to copy if you serve it elsewhere: `index.html`, `themes.css`, `style.css`, `app.js`, `levels.js`, `dfa.js`, `model.js`.

Colours: `themes.css` is generated: `python3 tools/themes.py > themes.css`. Background shades are evenly spaced in perceived brightness (CIE L*); everything else is derived from them.

## What it shows
| Spec idea | Where you see it |
|---|---|
| Lesson recipes by Kind (Q38): **N** full lesson, **S** short form | T3.1 and T3.3 open with why → tiny example → questions on it → (explore) → idea → (worked example); T3.2 is a short worked example only |
| Faded worked examples (Q75, Q79, Q82) | T3.1 (3 tables), T3.2 (2, short form), T3.3 (3): a worked example with a self-explanation prompt per step, then three completion tables with less given each time (exactly graded; never counted) |
| Exact grading (language equivalence) | Every DFA you submit |
| Think-first loop (Q18) | Attempt 1: "Not quite"; attempts 2–5: a new counterexample each time; then *another counterexample* / *show the solution* |
| Diverse counterexamples (Q29) | Later counterexamples prefer a different error kind and a different end state |
| Misconception messages | e.g. built "contains" for "ends with", swapped accepting states, naive restart on a mismatch |
| Hints and "I don't know where to start" (Q29) | Nudge → strategy → step; using them makes the item practice |
| Stuck detection (Q29, Q74) | A hint is offered when attempts stop getting closer; the solution is offered early when stuck twice or after ~6 minutes; after 8 items with none counted, a return to the lesson is offered |
| Complete DFA before grading (Q36) | Missing moves are flagged, with an offer to add a dead state |
| Right but unexpected answers (Q34) | A correct DFA with extra states: "Is there a simpler one?" → try or *show me* → compare → why |
| A why for every answer (Q6, Q48, Q68) | W3 "what does each state mean?" (with exactly-checked distractor meanings, accepting marks hidden) or W4 "change one move: give a string whose answer changes" |
| Explain your own mistake (Q32) | After *show the solution*: tap the one cell that would fix the counterexample |
| Mastery rule (Q3, Q45, Q69, Q70) | 4 of the last 5 practice items count, with one harder item and two whys at W3+, plus each problem type covered (T3.1: a "starts with" and a harder "ends with"); shown as provisional until a 1-day review; dots show the last five |
| Report a problem (Q28), guest mode | Link on every item; progress lives in this browser only |
| Unbuilt levels (Q60) | Greyed "TBD" cards on the map |
| Learner model (Q61) | Bayesian Knowledge Tracing in `model.js`: P(CanDo), P(Understands) per level, P(HasMisconception) per recognised slip. Chooses the next problem's band, targets a likely misconception and re-checks it a few items later, and flags "can do, can't explain"; memory grows with spaced success. The rule still decides mastery (Q71–Q73) |
| Debug glide (Q80) | In Inspect mode: ✓ Counted / ✓ With hint / ✓ Why wrong / ✗ then ✓ / ✗ Misconception / +1 day on practice screens, Skip lesson on lessons. They drive the real flows |
| Inspect mode (Q62) | "🔍 Inspect" in the header, `?inspect` in the URL, or the `?` key. **Rationale**: how the model works and why. **Look inside**: live model values, the next-problem decision, the current problem's internals, the event log |

## Not in the prototype
Reviews and the post-miss search, placement, problem-first recipe (no L levels here), confidence ratings, accounts, other topics.

## Simplifications to remember
- The state-meaning why is exact *by construction* here: the reference DFAs are built so that each state's meaning is known. The real engine checks labels with automata, both ways (Q26).
- The learner model's parameters are hand-set guesses, not fitted to data; levels are modelled one by one (linked only through the prior from the levels each one uses).
- Counterexample listing is brute force over strings up to length 8–9. Equivalence itself is an exact product-automaton search (`dfa.js`), checked against brute force in `test.mjs`.
