feat: Implement scene rulebook and validation engine
- Added a new SceneRulebook system to manage data-driven validation rules for actions. - Introduced rule checks for actions like "take", "open", "move", "introduce", and "describe". - Created a rulebook engine to evaluate conditions and enforce rules during action validation. - Enhanced action handling with support for scene entry and character descriptions. - Updated the architecture documentation to reflect the new rule-based validation approach. - Added new endpoints and improved the persistence layer for rulebooks.
This commit is contained in:
39
thoughts.md
39
thoughts.md
@@ -14,6 +14,12 @@
|
||||
- `open door` before key -> `locked_requires_key`
|
||||
- `take key` -> success
|
||||
- `open door` after key -> success
|
||||
- Scene-entry support added:
|
||||
- `introduce` is now a first-class action
|
||||
- rooms can declare `is_joinable`
|
||||
- characters can declare `is_social`
|
||||
- successful introduction moves a character from offstage into the actor's current room
|
||||
- `introduce` can also create a new social character when the named target does not already exist
|
||||
|
||||
## Architecture Now
|
||||
- Core contracts in `app/src/contracts/`:
|
||||
@@ -31,7 +37,36 @@
|
||||
- Persistence:
|
||||
- `app/src/db.ts` with tables `turns`, `actions`, `validation_results`, `entities`, `world_states`
|
||||
- App seed domain:
|
||||
- `app/src/app.ts` door/key world (`room_start`, `room_exit`, `player`, `door_1`, `key_1`)
|
||||
- `app/src/app.ts` door/key world (`room_start`, `room_exit`, `room_offstage`, `player`, `groundskeeper`, `door_1`, `key_1`)
|
||||
|
||||
## Scene Entry Rules
|
||||
- `introduce` validates against deterministic affordances:
|
||||
- target must exist
|
||||
- target must be a character
|
||||
- target must have `is_social: true`
|
||||
- actor must be in a valid room
|
||||
- room must have `is_joinable: true`
|
||||
- target must not already be in that room
|
||||
- If no existing target entity is resolved but a character name is present, `introduce` may create a new character directly into the current room.
|
||||
|
||||
## Character Description (NEW)
|
||||
- `describe` action adds traits to characters:
|
||||
- Syntax: `"describe the merchant as shrewd and quick"`
|
||||
- Traits are stored in `character.attributes.traits[]`
|
||||
- Multi-sentence support: `"introduce a merchant. describe the merchant as shrewd and quick."`
|
||||
- Validation rules:
|
||||
- target character must exist (or will be created by introduce in same turn)
|
||||
- actor and target must be in same room (for existing targets)
|
||||
- supports forward-reference to entities created in the same turn
|
||||
- Multi-action parsing:
|
||||
- Sentences split on `/[.!?]+/`
|
||||
- Each sentence becomes a separate action
|
||||
- Validation accounts for entities created by introduce actions in the same turn
|
||||
- On success:
|
||||
- target location becomes the actor's location
|
||||
- `in_scene` is set to `true`
|
||||
- `last_introduced_by` is recorded
|
||||
- newly created characters default to `type: character`, `is_social: true`, `in_scene: true`
|
||||
|
||||
## New Endpoint
|
||||
- Added `POST /api/reset` in `app/src/index.ts`
|
||||
@@ -50,5 +85,5 @@
|
||||
|
||||
## Remaining Checks
|
||||
1. Frontend build pass completed in container (`docker compose exec frontend npm run build`).
|
||||
2. Validate inspector UX manually against the door/key flow.
|
||||
2. Validate inspector UX manually against the door/key plus introduce flow.
|
||||
3. Expand parser coverage only within current clean MVP domain.
|
||||
|
||||
Reference in New Issue
Block a user