← Back to Pull requests

Trace dump and restore at the pool API boundary #1388

Open
unknown opened this pull request with 526 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 19, 2026 00:50 UTC
Author

Summary

Record dump and restore from the pool API entry point through the reply. Each call uses the active app span when available. The call owns its span across worker replacement, so a failed dump retry stays with the original operation. The spans report success, error, or cancellation with OpenTelemetry status and provider-owned metadata.

The snapshot spans measure individual API calls. The session remains the parent of the run code span, which covers Feed and its resume turns through the final result. This keeps a suspended execution and its callbacks together when the caller resumes under a different app span.

restore closes when the call returns. Its child load span carries any resumed execution and callbacks. Restore failures use the fixed OpenTelemetry status message restore failed to keep host paths and snapshot contents out of the span. Dump failures include bounded error text. Raw forwarding retains turn timing and snapshot size metrics.

Validation

  • 272 Rust pool tests and the build without telemetry.

  • 125 focused Python tests and 11 Node telemetry tests on the final code.

  • The local regressions reproduce the old cancellation panic, the misplaced retry error, and snapshot calls using the checkout's parent.

  • A protocol 8 staging build with the tracing patches verified the app, SDK, and hosted worker span parents.

  • Repository hooks passed, including the Rust, Python, and TypeScript checks.
  • <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Records dump and restore snapshot spans at the pool API boundary, so their duration covers initial session configuration and the relay's durable acknowledgement. The spans parent from the app context active at the call and carry through worker replacement, so a retried dump still reports on the original operation. restore closes when the call returns even if the restored execution suspends; its child load span stays open across suspensions and parents their callback spans.

  • Moves snapshot span ownership from the worker's turn recorder to a shared SnapshotSpan guard that rides the turn and records the outcome on drop; Python and Node snapshot APIs capture the active app span as the parent.

  • Removes the worker-side Dump span and its per-turn attributes; restore errors report a generic message so host paths and payload details stay out of the status. Spans report success, error, or cancellation; errors carry a 64KB-capped status message and worker exception logs stay children of the snapshot span.

  • Monty records only monty.* outcome and truncation attributes; the configured provider owns vendor-specific metadata such as logfire.level_num. Raw forwarding turns create no snapshot span, and monty.turn.duration and monty.snapshot.bytes metrics are unchanged.

  • Adds integration tests covering acknowledged, raw, refused, fatal, and cancelled dumps and restores, including trace parenting, retry errors, and provider-owned metadata.
  • <sup>Written for commit 55d6306ee61558b5056f5d5fb666c80d6c1048ff. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1388?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/pydantic/monty/1388?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1388&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

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

    Diff: 526 lines (+394 / -132) across 6 files Reviewer: davidhewitt Review duration: 5498m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 526 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.375
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1388"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 27.3% · Safe to merge
    27.3%
    Repository