← Back to Pull requests

feat: the run state machine, and the verbs wired to it (A13) #3

Open
unknown opened this pull request with 624 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 07, 2026 18:26 UTC
Author

Item A13 of the deploy-queue program (crunchtools/deployer#1). The module that
puts the other twelve in order, plus the three fixes building it turned up.

The order is the design

  • The hold guard is checked before a single ticket is read. If a hold

  • cannot be honoured then a rollback cannot be made to stick, and deploying at
    all would be taking a risk this program has no way to undo.
  • Everything that can refuse refuses before the host is touched. _gate

  • does no I/O: a body that does not parse, a service not in the registry, a
    creator who is not a listed requestor, a repo that disagrees with the
    registry, a revision that already broke this service, a service rolled back
    too often — all decided on information already in hand. None of them is
    recorded as an attempt, because nothing was learned about the image.
  • RT and Nagios are told before the restart. If either cannot be reached

  • the run returns with the host untouched and the ticket still queued, which is
    a much better outcome than a deploy nobody is told about. Past the restart
    their failures are reported and never undo a good deploy.
  • One rollback, then a person. A rollback that does not come back cancels

  • its own maintenance window, because Nagios saying so is the only fix path
    left.

    A correction to the plan

    The plan had a hold gate deploys for that service. It cannot: a held service
    could then never clear its own hold, because clearing it requires verifying a
    later ticket and no later ticket would be allowed through. Only a person could
    ever clear one, and the service would sit outside auto-update indefinitely.

    So a hold is not a gate. The next ticket carries the fix and letting it
    through is the point; verifying it is how the hold clears. What a hold stops is
    podman auto-update putting the broken :latest back overnight. What stops the
    same mistake twice is the attempt log — a revision that was rolled back is never
    deployed to that service again, whatever the ticket says.

    Three fixes found while building it

    RT renders dates in RT's own timezone, and a container's clock is UTC.
    Created arrives as Fri Nov 06 04:00:46 2026 with no zone in the string at
    all; the zone is RT's $Timezone, which on this deployment is
    America/New_York (RT_Config.pm). That is a five-hour error in the one number
    the build deadline is measured from, and the deadline is thirty minutes — read
    one way every ticket is stale the moment it is filed, read the other it never
    goes stale at all, and neither failure mentions a timezone when you are looking
    at it. RT_TIMEZONE is now required and validated at load, and an unreadable
    date is an error rather than a fall back to "now" (which would hand the ticket a
    fresh deadline on every run).

    A failed deploy needs the service's own output. "The health probe returned
    503" does not tell a developer what broke. The podman surface gains one read —
    GET the container's logs — which adds nothing to what this program can do to a
    container; there is still no create, start, run or exec. ALLOWED_OPERATIONS
    names it, so the surface test sees the change rather than it being widened
    quietly. The unit's journal would have said less, since a container that starts
    cleanly and then answers wrongly is a perfectly healthy unit. With logs coming
    from podman, journalctl and its libraries leave the runtime image entirely.

    unhold has to clear the rollback count too. The three-in-24-hours refusal
    comes from the gate rather than from the hold, so clearing only the hold would
    leave a service refused for the rest of the day with nothing on the ticket to
    say why.

    Verbs and exit codes

    holds and unhold read nothing but the state directory, so they work on a
    host where podman, systemd or RT is the thing that is broken. rollback
    honours a rollback = "manual" row by refusing and printing the two commands to
    run by hand — the registry is the thing that knows a service carries
    migrations, and writing it down is pointless if it is then ignored.

    0 for a verb that did what it was asked, including a deploy that failed
    and was rolled back cleanly, and including a second run standing down because
    one is already going. 1 only for a service that needs a person. 2 for could
    not run. A rollback is a success of this program; failing the oneshot unit for
    one would wake a model to be told what the ticket already says.

    Tests

    373, up from 302. The fakes model the host rather than the calls: restart
    moves the running container to whatever :latest currently points at, and the
    probe answers according to which image is running, so "the new image is broken"
    is written as a broken image and the sequence has to be right for the test to
    pass.

    Acceptance against real units waits on B1 installing the unit, which waits on
    the 0.1.0 release this PR unblocks.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01R7Y1jg2DfucoFv7VrzzwVR

    Diff: 624 lines (+468 / -156) across 7 files Reviewer: github-actions[bot] Review duration: 12m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.50) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 624 lines diff across 7 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: 79% · Reviewer familiarity: 35%
    41%
    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.385
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 41.6% 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.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    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: 41.6% · Lower = rushed or shallow review
    41.6%
    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: 29.3% · Safe to merge
    29.3%