← Back to Pull requests

Work clock #1376

Open
unknown opened this pull request with 418 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 17, 2026 15:42 UTC
Author

"clock" that uses instructions, not the OS clock.

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

Summary by cubic


Adds a third execution clock, Work, that counts executed work instead of reading the OS clock, so duration limits work on every platform — including WebAssembly, where clocks stand still during compute and which previously accepted only wall time. The VM charges units per bytecode instruction, Opcode::extra_work weights costlier ones, native operations (big-int arithmetic, regex, JSON, string scans, sorts, allocations) charge per cost, and monty-alloc counts allocated bytes as a floor. Units convert to time at a fixed per-build rate, so budgets and reported durations are deterministic across runs rather than wall-clock estimates.

Work sessions arm no wall duration backstop, like CPU sessions: counted time doesn't predict how long a turn takes, so a wall backstop would end healthy turns. request_timeout stays the only wall bound. execution_clock='work' / executionClock: 'work' select it on the Python, JS and WASM pools; workers that predate the protocol refuse work sessions, and dumps still require the saved clock on load.

Charges also cover work that produces no result: failed regex matches, re.split without groups and with a negative maxsplit, three-argument pow's base reduction, a raising json.dumps, non-ASCII character-offset searches, and print separators and ends. Short dividends are not charged, and the wasm pool rejects executionClock: null.

Calibration

  • make fit-work-clock fits every weight at once from opcode and work-event counts and measured wasm time, regenerating op_weights.rs and work_weights.rs; no weight is written by hand.

  • make calibrate-work-clock measures per-category, per-construct and corpus scripts on the work and wall clocks, natively and in WASM, failing on more than 3× category drift; CI runs the reports without the timing check.

  • Native and WASM builds get separate NANOS_PER_UNIT rates.

  • re.sub expands into a scratch string instead of revalidating the result per replacement, fixing quadratic behavior.
  • <sup>Written for commit 0154653fba9f189ced0e5d8111dd4c81b09e001b. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1376?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/1376?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1376&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: 418 lines (+313 / -105) across 5 files Reviewer: samuelcolvin Review duration: 18721m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 418 lines diff across 5 files
    0.50
    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%
    46%
    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.361
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1376"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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.0% (MEDIUM) · Higher = larger blast radius
    50.0%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 26.6% · Safe to merge
    26.6%
    Repository