← Back to Pull requests

feat(babysit): open a revert pull request for a bad deploy #470

Closed
unknown closed this pull request without merging on Nov 22, 2026 20:50 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 20:43 UTC
Author

Summary

A deploy that leaves the box unhealthy now gets a revert pull request as well as the revert issue. This is the piece of the rollback watch from #467 that was left as an issue only.

What changes

  • hands/lib/teeny_hands/babysit/rollback.py: after the revert issue, the babysitter builds one commit on main whose tree is the tree the box ran before the deploy (the deploy row's from), on the branch teeny/revert-<n>-<sha>, pushes it and opens the pull request through hands/gh (the guard, the secret scan, the gh ledger).

  • It is built with git plumbing (commit-tree, update-ref) in the git directory of Teeny's own clone (state/self/brain.git), under the self-clone lock. The builder's working tree is never touched.

  • Only when origin/main is still the deployed commit. Once main has moved, putting the old tree back would drop what came after, so the issue stands alone.

  • A reason that will not change (no clone on the box, main moved, the deploy row has no previous commit, the deploy changed no file) is recorded once as deploy_revert_pr_skipped. A push or an open that failed is tried again on the next run. A success is deploy_revert_pr, once.

  • The deploy_bad row now keeps the commit the deploy came from (base).

  • docs/mind.md and docs/hands.md say the same.
  • What it does not do

    The babysitter does not merge the revert. It touches the paths the bad deploy changed, which are held for 24 hours (recently_rolled_back), so it waits for the operator like any other change to them. The box is already on last-good by then; deploys stay paused until state/spine-fallback.json is cleared.

    Tests

  • hands/tests/babysit/test_revert_pr.py (7 tests, against a local bare origin and the fake GitHub): the branch is one commit on main with the pre-deploy tree; opened once; main moved, no clone, and no previous commit each leave the issue only; a failed push is retried; the paths stay held.

  • babysit.test_revert_pr, babysit.test_rollback, test_charter and test_watchers pass on this branch (45 tests). The whole babysit directory (187 tests) passed on the branch these commits were cherry-picked from. The full hands suite was not run locally.
  • <!-- greptile_comment -->

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=115949307&amp;sig=a2b85f29cbc5c52e893f9a5213bd09d1485f54c850c27f4360e283eebd4b7dc0"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=teeny&amp;next=%2Fteenydroid%2Fbrain%2Fpull%2F470&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>

    <!-- greptile-risk -->

    Fix the retry path before merging so a temporary GitHub failure does not leave the revert unfinished.

    <h2>Findings</h2>

    1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;Revert retries get stuck <a href="https://github.com/teenydroid/brain/pull/470#discussion_r4659946899">▶</a>

    <details><summary><h3>Summary</h3></summary>

    The babysitter now opens a revert pull request for an unhealthy deploy when main still points to that deploy.

  • Bad deploys can get a pull request that restores the earlier tree.

  • </details>

    <!-- greptile_confidence_score:4 -->

    <sub>Reviews (1) · Last reviewed commit: "docs: document automatic revert pull req..." · Reviewed by Greptile</sub>

    <!-- /greptile_comment -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    When a deployment fails and the deployed commit is still on the main branch, rollback now opens a pull request to restore the previously deployed state.
    The pull request is created once and held for operator review. If the main branch has moved on or required rollback information is unavailable, the existing rollback issue remains the only rollback artifact.
    Temporary push or pull request failures can be retried.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 640 lines (+480 / -160) across 8 files Reviewer: greptile-apps[bot] Review duration: 6m
    All Vouch review confidence checks passed
    Residual risk 0.46 = Change Risk (0.75) × (1 − Review Confidence (0.39)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 640 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 43% · Reviewer familiarity: 35%
    39%
    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.387
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #470"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 39.2% reviewed sensitive_module
    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: 75.1% (HIGH) · Higher = larger blast radius
    75.1%
    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: 39.2% · Lower = rushed or shallow review
    39.2%
    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: 45.6% · Moderate risk
    45.6%