clone

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

main
miau-is-true / openspec / changes / add-declarative-mechanic-state-contract / tasks.md
tasks.md 2.6K source

1. Contract and validation

  • [ ] 1.1 Define the normalized level mechanics schema with stable IDs, host-supported types, versions, static configuration, and either a derived no-state contract or a stateful scalar schema.
  • [ ] 1.2 Validate mechanic IDs, duplicate definitions, authored references, unsupported types, unsupported fields, and executable values in src/mods.js and the engine boundary.
  • [ ] 1.3 Normalize and clone mechanic metadata consistently in CommonJS, catalog, pack service, export, and data-only share paths.
  • [ ] 1.4 Add diagnostics that identify an unsupported mechanic feature and the path that declared it.

2. Engine lifecycle and snapshots

  • [ ] 2.1 Initialize state.mechanics from stateful normalized definitions during reset and expose a cloned settled envelope from getState(); derived projections remain recomputable and are not duplicated in the envelope.
  • [ ] 2.2 Add host-owned deterministic phase adapters for before movement, after movement, after transforms, before contacts, after contacts, and settled finalization.
  • [ ] 2.3 Include mechanic state in accepted-turn transactions and restore the previous state on blocked, invalid, or rule-complexity-rejected turns.
  • [ ] 2.4 Preserve and validate mechanic state through Undo, reset, and restore(); prove restored state does not advance transformations or phases.
  • [ ] 2.5 Add bounded, cloned mechanic transition records to settled events without changing existing events for levels with no mechanics.

3. Solver and replay contract

  • [ ] 3.1 Derive a deterministic stateful mechanic codec registry from normalized level definitions and pass it to createStateCodec() and solveLevel(); require derived mechanics to declare their projection inputs and no-hidden-state assertion.
  • [ ] 3.2 Reject unknown mechanic IDs, fields, missing registrations, invalid values, and unsupported schema versions before search expands a state.
  • [ ] 3.3 Round-trip mechanic state through encode/decode/restore and compare the next public and fast transitions.
  • [ ] 3.4 Add a same-board/different-mechanic-state key fixture and confirm unregistered state cannot be silently merged.
  • [ ] 3.5 Preserve solver shortest-path, BYPASS, HANDS-OFF, cap, and replay behavior for levels without mechanics.

4. Verification and handoff

  • [ ] 4.1 Add focused engine, mod, pack/share, codec, and solver parity tests.
  • [ ] 4.2 Run the full Node suite and production build.
  • [ ] 4.3 Run strict OpenSpec validation for this change.
  • [ ] 4.4 Send the foundation contract and open semantic questions to the worlds team before beginning gate or FRAIL behavior specs.