- 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.
3.8 KiB
3.8 KiB
thoughts.md
Current Status (clean-break)
- Backend is running the new contract-native API shape:
GET /api/state->{ worldState, turns }POST /api/turn->{ rawText, actions, validation, worldState }
- Runtime blocker is resolved:
- old SQLite schema conflict (
turns.raw_text) was fixed by wiping old DB state - stale legacy files removed from backend source tree:
app/src/types.tsapp/src/latentEntities.tsapp/src/llmAdapter.ts
- old SQLite schema conflict (
- Door/key MVP smoke checks pass:
open doorbefore key ->locked_requires_keytake key-> successopen doorafter key -> success
- Scene-entry support added:
introduceis 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
introducecan also create a new social character when the named target does not already exist
Architecture Now
- Core contracts in
app/src/contracts/:action.tsvalidation.tsturn.tsentity.tsworld.ts
- Deterministic truth engine:
app/src/truthEngine.tswithvalidateActions(actions, worldState)
- Ordered turn pipeline:
app/src/turns/processTurn.tsparse -> validate -> apply -> persist
- World mutation:
app/src/world/applyActions.ts
- Persistence:
app/src/db.tswith tablesturns,actions,validation_results,entities,world_states
- App seed domain:
app/src/app.tsdoor/key world (room_start,room_exit,room_offstage,player,groundskeeper,door_1,key_1)
Scene Entry Rules
introducevalidates 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,
introducemay create a new character directly into the current room.
Character Description (NEW)
describeaction 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."
- Syntax:
- 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
- Sentences split on
- On success:
- target location becomes the actor's location
in_sceneis set totruelast_introduced_byis recorded- newly created characters default to
type: character,is_social: true,in_scene: true
New Endpoint
- Added
POST /api/resetinapp/src/index.ts - App-level reset implementation in
app/src/app.ts - DB wipe support in
app/src/db.ts - Verified reset behavior:
- returns
{ worldState, turns } turnsis empty after resetplayerandkey_1return toroom_start
- returns
Frontend Migration Notes
frontend/src/App.tsxmigrated to consume new backend contracts.- Removed dependencies on old fields (
narration,events,beliefs,summaries,parser_feedback). - Turn submit flow now refreshes snapshot via
GET /api/stateafterPOST /api/turn. - Reset call now sends JSON body/content-type to satisfy Fastify media-type validation.
Remaining Checks
- Frontend build pass completed in container (
docker compose exec frontend npm run build). - Validate inspector UX manually against the door/key plus introduce flow.
- Expand parser coverage only within current clean MVP domain.