Repository navigation
lab/server: Slice 2 attach-only read server (#131) - #482
Merged
Merged
Conversation
MCP over Streamable HTTP on 127.0.0.1 (stdlib http.server): bearer token, Host/Origin checks, sessions, size caps, and a config that serves only console B. Resources console://B/state and console://B/save from strict reads of Lab/state.json and Lab/save.json; missing, partial, malformed, unsupported-schema, dead-pid and stale-heartbeat files are explicit unavailable states. Tools: ensure_game (verification only) and shot, which waits for a frame newer than the call before asking the app's read-only shot line. Fake-lab tests cover partial writes, stale files, sequence resets, app restarts, timeouts and concurrent readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
shot now sends `snapshot frame <timeout_ms>` at once and returns the exact frame_seq / captured_at from the `snapshot saved` line. The panel and controller refusals are gone; the app's timeout and unavailable replies map to timeout, video_stale and app_unavailable (evidence.reason), and a reply from another instance is instance_replaced. Only the expected outbox path is opened. The fake app answers snapshot requests as LabChannel does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine
added a commit
that referenced
this pull request
Nov 14, 2026
Moves the seven open questions to settled with their recommended answers, writes the nine answers from the 2026-11-14 implementation review into the resources, lease, tool and slice text, corrects the legacy Lab/state fields and what 7c44e72 does, and records Slices 0-3 as built (#478, #481, #482, #483) and Slice 4 as approved on PokemonAutomation#1881's branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ad body, wait for journal end, public check_object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #478 and #481. Base:
agents-lab-server-slice0; the diff shows only this change.The read-only lab server from #131 Slice 2: an MCP endpoint on 127.0.0.1 that serves console B's state, save,
shotandensure_gamefrom the app'sLab/files, with no lease, no write path and no press.http.server: onePOST /mcp, bearer token from an owner-only file, loopbackHostand own-Originchecks, sessions, 1 MiB cap. The server's own config must list exactlyB.console://B/stateandconsole://B/savefrom strict reads ofLab/state.json(Lab channel: write Lab/state.json for the lab server (#131 Slice 1) #481) andLab/save.json. No file, a partial or malformed file, an unsupported schema, another profile's app, a dead pid and a stale heartbeat (10 s) are eachunavailablewith that reason. A UI Start/Stop is reported as the user lease; there is nothing to enforce it yet.ensure_gamereads the app's observations and only verifies;unknownnever verifies, so it saysgame_unknownuntil detectors exist.shotchecksstate.jsononce, then sends Lab channel: write Lab/state.json for the lab server (#131 Slice 1) #481'ssnapshot frame <timeout_ms>at once and returns the saved frame's exactframe_seqandcaptured_at. It works on any panel with video, whatever the controller. Replies map to refusals:snapshot timeoutistimeout(evidence{instance_id, frame_seq: after}),reason=no_videoisvideo_stale,panel_changed/app_closing/save_failedareapp_unavailablewith thatevidence.reason, and a reply naming another instance isapp_unavailable/instance_replaced. Only the PNG path the server chose is opened, never one read from the journal.Contract gaps for #131's owner:
shotreturns{console, path, instance_id, frame_seq, captured_at, call_started_at, request}beside the image, and the app's reply format is only Lab.md's lines.app_unavailablehas no reason enum:instance_replaced,panel_changed,app_closing,save_failedandunknown(a reason the server does not know) are free text inevidence.reason. App instance replacement also has noavailability.reasonin the v1 state enum.no_videois mapped tovideo_stalefor now.runs://is left for Slice 6.Testing: 46 unit tests in
lab/server/testsfor this slice (65 inlab/server) against a fakeLab/folder and a fake app that answerssnapshotas LabChannel does, in temp dirs: partial writes, stale files, app restarts, each snapshot reply, a journal naming a decoy path, timeouts, and 10 concurrent clients reading and shooting while the app rewrites its state. Run withpython3 -m unittest discover -s lab/server/tests -t lab/server(Python 3.8). Nothing touched console B or the lab-B profile.🤖 Generated with Claude Code
https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss