← Back to Pull requests

Add session IDs, forking, ephemeral sessions and auto-resume #933

Closed
unknown closed this pull request without merging on Sep 24, 2026 23:29 UTC
View on GitHub
unknown unknown commented on Sep 24, 2026 17:05 UTC
Author

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

<!-- This is an auto-generated description by cubic. -->
---

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_id and honor Configure.persistence; loading an ID always starts a fresh session under a new ID, so forking is Dump then two Loads. Children ignore all three, so PROTOCOL_VERSION stays at 5; a relay without a store refuses Dump/Load with Error and names nothing on shutdown.

  • monty-pool exposes Persistence, ReplConfig::persistence, and Checkout::session_id. With PoolConfig::auto_resume (default on) a checkout whose relay answers with Shutdown redials, 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 original Shutdown if 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 the Load reply. 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_monty adds checkout(ephemeral=), AsyncMontyWebsocket(auto_resume=), and AsyncMontySession.session_id, reported even when adopted mid-turn; monty.pool.session.resumed records each attempt's outcome.

  • A Load the worker refuses with Error keeps 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.
  • <sup>Written for commit 966086d76e3b158aece6ae69f2997da8334db570. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/933?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 422 lines (+316 / -106) across 5 files Reviewer: samuelcolvin Review duration: 384m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 422 lines diff across 5 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.362
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #933"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50% (MEDIUM) · Higher = larger blast radius
    50%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%
    Repository