Skip to content

lab/server: Slice 3 durable control plane (#131) - #483

Merged
dayfine merged 2 commits into
agentsfrom
lab/server-slice3
Nov 14, 2026
Merged

dayfine merged 2 commits into
agentsfrom
lab/server-slice3

Conversation

@dayfine

@dayfine dayfine commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Depends on #482

Base lab/server-slice2; the diff shows only Slice 3 of #131.

The lab server had no memory: a lease was only inferred from the app's last transition, so a user lease was lost on app restart and nothing kept request results or event cursors. This adds the durable control plane in SQLite (stdlib sqlite3): migrations, leases (acquire_console / renew_console / release_console, TTL 1200 s, agent_running never expires), a UI Start/Stop turning into a user lease that only the operator CLI (python3 -m pa_lab lease ... release-user) ends, idempotent request records with request_status, tickets, next_events with durable cursors, restart reconciliation, and compaction that keeps every active cursor and unresolved ticket. Every change is one BEGIN IMMEDIATE transaction, so racing clients or a restarted daemon cannot both win. Tested with python3 -m unittest discover -s lab/server/tests -t lab/server (119 tests: db, control, control_concurrency with racing threads/processes and kills mid-write, control_mcp end to end); no console was touched.

Contract gaps for #131's owner (v1 contracts in #478 left unchanged): lease_changed carries an extra reason field the contract does not name; there is no refusal code for a cursor behind compaction (sent as invalid_arguments, field after_seq) nor for an operator-only action; there is no ticket kind (tickets are pending request records); and the acquire_console result shape (lease_token, expires_at, ttl_s) is not frozen.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

SQLite (stdlib sqlite3) becomes the source of truth for leases, request
records, tickets and events: migrations by PRAGMA user_version, an
owner-only file, and every change in one BEGIN IMMEDIATE transaction.
acquire/renew/release with opaque tokens (TTL 1200 s; agent_running never
expires), a UI Start/Stop in state.json revokes agent leases into a user
lease that only the operator CLI ends, idempotent (client, tool,
request_id) records, next_events with durable cursors, request_status,
restart reconciliation, and compaction that keeps active cursors and
unresolved tickets. Tests cover restarts, racing threads and processes,
kills mid-write, stable retries and gap-free catch-up.

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
…e allowlist, lease column check, roadmap refs out of docstrings
@dayfine
dayfine changed the base branch from lab/server-slice2 to agents November 14, 2026 23:48
@dayfine
dayfine marked this pull request as ready for review November 14, 2026 23:49
@dayfine
dayfine merged commit 0119586 into agents Nov 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant