clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

main
miau-is-true / openspec / changes / fix-rule-precedence-and-reading / design.md
design.md 3.9K rendered
1## Context23The W6 audit compares current behavior with Baba-style author expectations. The engine already has stable movement and contact phases, but several outcomes depend on incidental occupant or authored object order. The worlds team has settled stacked parsing: choose one token per cell/path, enumerate every valid alternative, and allow a sentence to start at a stacked cell.45## Goals / Non-Goals67**Goals:**89- Make STOP/PUSH, DEFEAT/WIN, and singleton hazard outcomes explicit.10- Make self-transform suppression and competing noun transformations deterministic.11- Preserve one-link transformation semantics within a turn.12- Add regression fixtures that expose event order and resulting nouns.13- Parse stacked cells with one selected token per cell/path and enumerate every valid alternative.1415**Non-Goals:**1617- Permissive combinations of all stacked tokens.18- Reworking Crossword levels before applying the settled parser contract.19- Adding new vocabulary, goals, automata, or contact timing modes.2021## Decisions2223### PUSH wins over STOP when carried by one object2425When the same destination object carries both STOP and PUSH, PUSH allows the object to be pushed rather than treating its STOP as a block. This matches the worlds audit's Baba-compatible semantics; treating STOP first prevents intended `ROCK IS STOP AND PUSH` behavior.2627### Resolve defeat before victory, including singleton entities2829Contact resolution evaluates DEFEAT before WIN. A singleton entity carrying both YOU and DEFEAT is removed and cannot win from its own WIN property. The same ordering applies when distinct entities overlap.3031### Self-transform rules suppress other transforms3233`X IS X` contributes no noun change, but its presence suppresses every other noun transformation for X in that turn. This makes `ROCK IS ROCK` plus `ROCK IS FLAG` stable regardless of parse order and avoids an incidental transform conflict.3435### Choose transformations by spatial rule-reading order and apply one link3637For one noun with multiple valid noun targets, select the first rule by the first word's spatial reading order: first-word row top-to-bottom, then left-to-right, then sentence token order. Apply at most one noun transformation per object per turn; do not recursively apply the result to another noun rule until a later turn. This keeps `A IS B` and `B IS C` as a one-link chain.3839### Enumerate stacked-cell alternatives by path4041For every stacked cell in a candidate sentence path, select one word and enumerate each valid alternative. Sentence scanning may begin at a stacked cell. This yields `ROCK [AND+IS] FLAG` as `ROCK IS FLAG`, `ROCK IS [WIN+PUSH]` as two rules, `[ROCK+FLAG] IS WIN` as two rules, and `ROCK AND [FLAG+IS] IS WIN` as `ROCK IS WIN` plus `FLAG IS WIN`. The permissive combination of all stacked tokens is excluded.4243## Risks / Trade-offs4445- [Risk] Existing levels rely on authored object order for transform conflicts. → Add fixtures and review affected worlds before enabling the new order broadly.46- [Risk] Singleton YOU+DEFEAT changes a loss outcome. → Add explicit event/state assertions and rerun bundled solver checks.47- [Risk] Spatial ordering differs from author expectations. → Expose source rule IDs and axis in settled state and document the ordering.48- [Risk] Stacked alternatives multiply candidate sentences. → Enumerate valid one-token-per-cell paths deterministically and deduplicate semantic rules while retaining physical sources.4950## Migration Plan51521. Add focused engine tests for precedence and deterministic reading.532. Implement parser/contact changes behind the existing deterministic engine path.543. Run bundled solver and browser regression checks.554. Re-run Crossword solver/content checks against the settled stacked-cell grammar.5657## Open Questions5859- Are there additional stacked-cell fixtures beyond the worlds table that need explicit regression coverage?60- Does the worlds team require source-span ordering in the visible rule ledger as well as the engine rule table?