Replace polling with game-state events, a startup ready file and process-handle waits #20
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
queue
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens-mcp!20
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/event-driven-waits"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Removes the polling that bridge clients depend on. The bridge now tells them when something happened.
What changes
POST {"action":"wait_for_change","since_version":N,"timeout_ms":M}holds the request until the state version passes N and the game has settled, then returns the state. "Settled" means no game action running or queued, no turn hand-off, no screen transition, no run load in progress. A pending player choice also counts as settled. The version goes up on run, room, act, combat, action-queue, action-executor, overlay-stack, map-screen and hand-mode events. As a catch-all for UI without a model event (event pages, reward buttons), it also goes up on the scene tree'snode_added/node_removed. Everyget_game_stateresponse now carriesstate_version,settledandunsettled_reason; markdown responses put them on the last line.GET /now also reportsready,pid,state_versionandready_file.readyturns true onceNGame.GameStartupCompletefinishes: after the logo, the main menu load and the startup error checks. At that point the bridge writes%APPDATA%\SlayTheSpire2\SpireLensMcpBridge\bridge-ready.json(pid, port, version) and deletes any stale copy when it starts."status": "ok"keeps its old meaning: the listener is up.mcp/server.py):wait_for_game_state_change._wait_for_stateis now built onwait_for_change.start_sts2waits on a directory change notification for the ready file instead of probing every 3 s.stop_sts2waits on the game's process handles instead of checking every 1 s.bridge_healthadds abridge_startingstatus.replace_deckwithpersistnow answers once the save has been written, instead of telling the caller to keep callingvalidate_current_run_save. The HTTP thread waits on the save task; the main thread never blocks.AGENTS.mddrops the "callget_game_statetwice" advice and points agents towait_for_game_state_change.Compatibility
This is additive: old clients see the same fields plus new ones. The romaine-life/spirelens PR that switches the host harness to the ready file has to merge after this one. Glimmung's env-prep rebuilds the bridge from this repo's
main, so once this is merged every run uses the new bridge.Not verified
dotnet build -c Release.server.pypassespy_compile.ActionExecutor/ActionQueueSet/CombatManagercode. If a state never settles,wait_for_changereturns"status": "timeout"withunsettled_reasonrather than hanging.