- commit
- 89dd89f6755a1d2cf013aba653711de62ae09b94
- parent
- 426762f23ac70bff421ee2cdce4f6c8ca2172720
- author
- Dami <dami.etoile@gmail.com>
No content changes.
No content changes.
No content changes.
No content changes.
@@ -1,7 +1,8 @@
11 # rule-engine Specification22 33 ## Purpose4-TBD - created by archiving change build-dynamic-rule-engine. Update Purpose after archive.4+Define deterministic grid state, movable word rules, turn resolution, contact5+effects, undo, and the settled event records consumed by presentation.56 ## Requirements67 ### Requirement: The engine SHALL represent a deterministic stacked grid state78 The engine SHALL represent a level as a bounded rectangular grid containing uniquely identified object and word entities. Multiple entities, including words, SHALL be allowed in one cell, and a turn snapshot SHALL include positions, entity kinds, word text, active rules, move count, win state, and the complete history needed for undo.@@ -79,15 +80,27 @@ The engine SHALL save the complete pre-turn state before each successful movemen
7980 - **THEN** the initial entities and rules are restored, move count is zero, win is false, and undo history is empty8081 8182 ### Requirement: Active rules SHALL identify their source words82-Each active rule SHALL expose the word entity IDs that formed it in reading order and whether the sentence runs horizontally or vertically. Duplicate sentences at different locations SHALL retain deterministic source information.83+Each active semantic rule SHALL expose the word entity IDs that formed it in reading order and whether the sentence runs horizontally or vertically. Duplicate semantic rules at different physical locations SHALL remain deduplicated in the active rule table while retaining deterministic source information. The settled state SHALL additionally expose `sentences`, an ordered list of every physical maximal sentence span as `{ ids, axis }`. A span that is a strict subset of a longer span on the same axis SHALL be omitted; exact duplicate sentences at different locations SHALL both remain.8384 8485 #### Scenario: A horizontal sentence reports its source8586 - **WHEN** adjacent word entities form `MIAU IS YOU` from left to right86-- **THEN** the resulting rule identifies those word IDs in order and reports horizontal axis87+- **THEN** the resulting semantic rule identifies those word IDs in order, reports horizontal axis, and `state.sentences` contains the physical span with those ids and axis `h`8788 8889 #### Scenario: A vertical sentence reports its source8990 - **WHEN** adjacent word entities form `ROCK IS PUSH` from top to bottom90-- **THEN** the resulting rule identifies those word IDs in order and reports vertical axis91+- **THEN** the resulting semantic rule identifies those word IDs in order, reports vertical axis, and `state.sentences` contains the physical span with those ids and axis `v`92+93+#### Scenario: Exact duplicate sentences remain physical spans94+- **WHEN** two separate word runs form the same semantic sentence95+- **THEN** the active rule table contains one semantic rule while `state.sentences` contains both physical spans96+97+#### Scenario: Strict subsets are removed98+- **WHEN** a candidate span is a strict subset of a longer valid span on the same axis99+- **THEN** `state.sentences` contains only the longer maximal span100+101+#### Scenario: Stacked words create separate spans102+- **WHEN** two noun words share a cell and each forms a valid sentence with the same following words103+- **THEN** `state.sentences` contains one span for each physical noun path91104 92105 ### Requirement: Engine actions SHALL return settled turn events93106 `step`, `undo`, and `reset` SHALL return an event record after resolving state. Every record SHALL have `kind: 'step' | 'undo' | 'reset'`, `accepted`, ordered `moved`, full-record `rulesAdded` and `rulesRemoved`, ordered `transformed`, ordered `destroyed`, `controlLost`, and final `won` fields. A blocked or invalid step SHALL retain `kind: 'step'`, report `accepted: false`, and leave state unchanged.