Add session IDs, forking, ephemeral sessions and auto-resume
A relay that stores sessions names each one in ChildEvent.session_id, set on its first reply to Configure or Load whatever that reply's kind, so a load of a suspended session still carries it. Configure.persistence asks the relay to store a session or not, and Load.fork copies a stored session under a new ID instead of claiming it. Children ignore all three, so PROTOCOL_VERSION does not move.
monty-pool exposes Persistence, ReplConfig::persistence, Checkout::session_id and restore(.., fork, ..). With PoolConfig::auto_resume (default on) a checkout whose relay drains a named session redials, reclaims it by ID and re-sends the request the relay did not run, returning the original Shutdown if the reclaimed session does not match.
pydantic_monty adds checkout(ephemeral=), AsyncMontyWebsocket(auto_resume=), fork= on the async loads and AsyncMontySession.session_id.
Claude-Session: https://claude.ai/code/session_015K5gKCYXr4yxxoKyb6fC19
Summary by cubic
Adds session IDs, forking, ephemeral sessions, and auto-resume for relays that store sessions.
Session storage
- Storing relays name each session in
ChildEvent.session_idand honorConfigure.persistence; loading an ID always starts a fresh session under a new ID, so forking isDumpthen twoLoads. Children ignore all three, soPROTOCOL_VERSIONstays at 5; a relay without a store refusesDump/LoadwithErrorand names nothing on shutdown. monty-poolexposesPersistence,ReplConfig::persistence, andCheckout::session_id. WithPoolConfig::auto_resume(default on) a checkout whose relay answers withShutdownredials, loads the named state into a new session, re-announces the same suspension, and re-sends the request the relay didn't run, returning the originalShutdownif nothing was named or the reload fails. The resumed session keeps its own budget — only the suspension and sleep totals reset for the re-announcement — and takes its ID from theLoadreply. The turn hot path stays a single async layer with the resume as a boxed tail branch and an untouched result, so auto-resume adds no per-turn cost.pydantic_montyaddscheckout(ephemeral=),AsyncMontyWebsocket(auto_resume=), andAsyncMontySession.session_id, reported even when adopted mid-turn;monty.pool.session.resumedrecords each attempt's outcome.- A
Loadthe worker refuses withErrorkeeps the session's prior ID so its parked state stays resumable; an over-budget aborted re-announcement keeps the new session's ID instead. - Datatest now allows 15s (up from 4s) before calling a test hung, since a debug CI timeout exceeded the old limit.