← Back to Pull requests

remove postcard, make `id` calculations explicit and stable #1369

Closed
unknown closed this pull request without merging on Nov 19, 2026 10:31 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 15:15 UTC
Author

We used to use postcard as a serialization format, we replaced with CBOR. Can simplify the dependency tree by removing it from id() calculations, and arguably we should be deliberate about these as they need to remain stable indefinitely as they are persisted in dumps.

I decided to add a macro which we can use to enforce explicit numbering and checksum on enums which will affect dump contents. This adds a bit of bloat and ceremony but seemed on balance possibly worth it given we don't want these to change unknowingly ever.

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

Summary by cubic


Removes the postcard dependency and makes persisted id() identity codes explicit so variant reordering or insertion no longer silently renumbers existing identities.

  • Replaces postcard-based identity payloads with hand-written LEB128 encoders in identity/payload.rs; old numbers stay stable so previously dumped id() values keep matching.

  • Adds #[explicit_discriminants(checksum = ...)], which requires an explicit integer on every variant of identity-bearing enums and rejects implicit or computed codes; a checksum mismatch reports the replacement attribute.

  • Adds explicit discriminants to BuiltinsFunctions, ExcType, and all module-function enums, plus a fixed identity_index table for BuiltinType that keeps the reserved gap left by the removed Type::Instance slot.

  • Pins legacy identity numbers with insta snapshot tests.
  • <sup>Written for commit 30fa0126d1cc7949f2413c9785175c9dcbaf1d1e. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1369?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/1369?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1369&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: 334 lines (+250 / -84) across 4 files Reviewer: rewitt94 Review duration: 4036m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 334 lines diff across 4 files
    0.47
    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.348
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1369"
    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: 47.2% (MEDIUM) · Higher = larger blast radius
    47.2%
    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: 18.6% · Safe to merge
    18.6%
    Repository