Skip to content

babysit-pr: deterministic driver CLI and session-owned push chain (PROF-16952) - #1070

Open
jbachorik wants to merge 15 commits into
mainfrom
drydock/jb-patient-cotton-otter
Open

jbachorik wants to merge 15 commits into
mainfrom
drydock/jb-patient-cotton-otter

Conversation

@jbachorik

@jbachorik jbachorik commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?:

Moves every mechanical step of the babysit-pr skill out of LLM prose and into a tested stdlib CLI, utils/babysit-pr.py, with its pure decision logic in utils/babysit_pr_policy.py. The session, not the worker, now owns review, commit, push and replies.

Actor Does
CLI Run state, REST polling, trust gate, CI reruns, Bits triggers, status comment, handoff patch, push, replies
Worker (babysit-pr agent) Triages the events wait returns, fixes code, runs tests, drafts replies. Never commits or pushes
Session Applies the patch as a signed commit, runs pre-pr-review, runs push-and-reply, decides design questions

The skill shrinks from 366 to 132 lines; it now points at CLI commands instead of inline gh/jq recipes.

Motivation:

In a real run, triage and fixes took minutes, but the push chain stalled twice:

  • Marker race. The worker polled for the review marker with sleep 180/300/420 and kept seeing rc=1 after the session had written it.
  • Worker-environment hangs stalled an earlier cycle.

Both come from the same design: a long-lived LLM worker that improvises bash for every step, and a review marker that crosses a session boundary with no synchronous handoff. Now the session that writes the marker also checks it and pushes, so there is nothing to poll.

Additional Notes:

  • Ordering guarantee. push-and-reply posts the queued replies only after git push --force-with-lease against the handoff base succeeds; {commit} in a reply becomes the pushed SHA. A rerun after an interruption does not push twice and posts only the replies GitHub does not hold yet.
  • Fail-closed checks. The worker cannot push: its worktree gets a build/babysit-pr-<n>.json marker with an empty scope, so .githooks/pre-push refuses. A handoff is refused for files outside the scope-guard allowlist or the declared scope. apply-handoff refuses an unsigned commit. review-marker.py and TRUSTED_BOT_IDS are read from origin/main only.
  • CI-safe automation. wait reruns a GitHub Actions run once, only after all its jobs finished, and records it before the request. A cancelled check counts as pending, never as a failure: ci.yml's concurrency group cancels superseded runs, and rerunning one cancels the live run. start adds no label: ci.yml runs on pull_request: labeled, so a label would restart CI on every babysit start.
  • Bounded calls. Every gh/git call has a timeout, and inside wait each call is capped at the time left in the slice; a write starts only with its full timeout left, so it is never cut off mid-flight. wait returns within 8 minutes, below the 600 s bash tool timeout.
  • Label dropped. The dog-sitter label is no longer added or removed; the status comment is the run signal. PRs labelled by the old skill keep the label until removed by hand.
  • Unchanged: .githooks/pre-push, utils/babysit-scope-guard.py, and both create triggers (.claude/hooks/babysit-pr.py, .pi/extensions/babysit-pr.ts).
  • Accepted costs.
    • Every poll re-reads the full comment history of the PR through REST: 10-minute polls, 20 when idle.
    • GitHub calls inside a poll run under the per-PR flock. Each call is bounded by its timeout.
    • A CHANGES_REQUESTED review the worker acks without replying does not block green_done; the acked event is listed in the stop summary.
  • Stale knowledgebase note. .knowledgebase/memories/find-marker-branch-babysit-mismatch.md no longer applies, since the worker no longer pushes. Cairn owns that file; it is left for a cairn update.
  • Review. Sphinx range review, standard effort, on the first candidate: 1 HIGH, 6 MEDIUM, 13 LOW. The HIGH (a push that landed before a crash blocked the replies) and the cheap MEDIUM/LOW findings are fixed in babysit-pr: close crash windows and tighten handoff checks. A Sphinx review of that fix range found no HIGH; its one cheap fix was reviewed by a medium code review: one LOW left open (apply-handoff gives a misleading refusal reason when the patch file is missing). A first babysit run on this PR found that the CLI reran CI per failing job, lost the rerun record on a failed request, and treated cancelled checks as failures; together with the label, that cancelled live CI runs. Fixed in babysit-pr: rerun once per workflow run, ignore cancelled checks, drop the label and two follow-ups, each reviewed by a medium code review. A second babysit run triaged the Bits and Codex findings on fa42f258d and handed them to the session, since they are outside the worker's allowlist. They are fixed in babysit-pr: address review findings on wait budget, completion, signing and rebase and two follow-ups, each reviewed by a medium code review. A third babysit run surfaced a Bits finding (a skipped status write discarded the poll's events); fixed by saving before every status-comment update, which never fails its command, in babysit-pr: save poll results before the status update and four follow-ups, each reviewed by a medium code review. Open LOWs: the misleading refusal reason when the patch file is missing; no test pins the idle backoff while GitHub refuses a rerun; no test covers recovering a landed rebase push after the base moved; fix_rounds_left can read -1 after a manual push of the handoff head; an ambiguous status-comment POST failure can leave a duplicate status comment; the push-and-reply/stage-handoff deferred-update paths have no dedicated test. Findings dismissed with reasons: full-history polling, GitHub calls under the lock, permission cache across a resume, compatibility with state files from an earlier version (none was released).
  • Human review: mandatory. The change decides which public PR comments may steer an automated push, and it moves the push path. A human must check the trust gate and the push-then-reply ordering.

How to test the change?:

bash utils/tests/test_babysit_pr.sh runs 70 hermetic tests against a fake gh (utils/tests/fake_gh.py) and temporary git repos with SSH commit signing. They cover the policy decisions, the trust gate, scope and allowlist refusal, signing, crash adoption, lease rejection, resumed replies, rerun dedupe and retry, cancelled-check handling, the wait-slice budget, completion while events are pending, deferred status-comment updates, the round cap and the fail-closed origin/main reads. CI runs the suite through the utils/tests/*.sh glob in script-tests. A real-PR run is the ticket's production-check criterion.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: PROF-16952

@jbachorik jbachorik added AI human_review:mandatory Human review required — see PR description labels Nov 27, 2026
@jbachorik

Copy link
Copy Markdown
Collaborator Author

@DataDog review

Comment thread utils/tests/fake_gh.py Fixed
Comment thread utils/babysit-pr.py Fixed
@jbachorik jbachorik added the dog-sitter Actively watched by babysit-pr: fixes pushed through the repo gates label Nov 27, 2026
@jbachorik

jbachorik commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

🐶 babysit-pr is watching this PR — CI breakages and mechanical findings are fixed and pushed automatically; design decisions are always brought to you.

This run
  • 17:16 · started · head 3d49e8615
  • 17:19 · stopped · stopped by the session: rerun loop bug found on this PR

✅ stopped 17:19 UTC · stopped by the session: rerun loop bug found on this PR

@jbachorik jbachorik removed the dog-sitter Actively watched by babysit-pr: fixes pushed through the repo gates label Nov 27, 2026

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Pending review events can be skipped when a resumed worker declares success. Retry scheduling and timeout handling also contain paths that interrupt monitoring or strand a staged handoff.

Open Bits AI session

🤖 Bits Code Review · Commit 3d49e86

Comment thread utils/babysit_pr_policy.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved
@dd-octo-sts

dd-octo-sts Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Memory overhead check: ✅ within budget

Profiler 3dd289114, pipeline. Budget: utils/memcheck/budget.txt. NMT and /proc values are profiled minus no-profiler runs on the same runner.

scenario metric value Δ since budget set limit headroom
allocs native_mem_live_bytes 21.71 MiB +20 KiB 21.95 MiB 246 KiB ok
allocs native_mem_max_bytes 22.98 MiB +27 KiB 23.20 MiB 229 KiB ok
allocs nmt.class 302 KiB +5 KiB 563 KiB 261 KiB ok
allocs nmt.internal 369 KiB +0 KiB 666 KiB 297 KiB ok
classesM native_mem_live_bytes (coverage-corrected) 23.30 MiB +22 KiB 23.55 MiB 255 KiB ok
classesM native_mem_max_bytes (coverage-corrected) 25.20 MiB +12 KiB 25.45 MiB 254 KiB ok
classesM nmt.class 2.94 MiB −1 KiB 3.20 MiB 267 KiB ok
classesM nmt.internal 3.20 MiB +0 KiB 3.50 MiB 307 KiB ok
mixed native_mem_live_bytes 23.15 MiB +1 KiB 23.45 MiB 306 KiB ok
mixed native_mem_max_bytes 40.75 MiB +35 KiB 41.00 MiB 252 KiB ok
mixed nmt.class 302 KiB −5 KiB 563 KiB 261 KiB ok
mixed nmt.internal 408 KiB −2 KiB 717 KiB 309 KiB ok
threads native_mem_live_bytes 19.08 MiB −13 KiB 19.35 MiB 279 KiB ok
threads native_mem_max_bytes 20.09 MiB −20 KiB 20.40 MiB 317 KiB ok
threads nmt.class 114 KiB +1 KiB 410 KiB 296 KiB ok
threads nmt.internal 157 KiB −7 KiB 461 KiB 303 KiB ok
traces native_mem_live_bytes 20.23 MiB −0 KiB 20.50 MiB 277 KiB ok
traces native_mem_max_bytes 21.41 MiB +4 KiB 21.70 MiB 293 KiB ok
traces nmt.class 470 KiB −1 KiB 768 KiB 298 KiB ok
traces nmt.internal 607 KiB −8 KiB 870 KiB 264 KiB ok

✅ nmt.tracing absent in every scenario.

Not budgeted (too noisy on shared runners)
scenario nmt.code nmt.gc nmt.total proc.VmRSS proc.RssAnon
allocs 1.58 MiB 7 KiB 2.68 MiB 32.39 MiB 27.91 MiB
classesM 5.19 MiB −62 KiB 14.28 MiB 37.28 MiB 32.83 MiB
mixed 1.69 MiB 5 KiB 2.82 MiB 33.44 MiB 28.70 MiB
threads 5 KiB 0 KiB 503 KiB 24.63 MiB 19.50 MiB
traces 3.98 MiB −14 KiB 5.56 MiB 31.76 MiB 27.21 MiB

@dd-octo-sts

dd-octo-sts Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #46434481811 | Commit: 1670144 | Duration: 22m 32s (longest job)

✅ All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - ✅ - -
8-ibm - ✅ - -
8-j9 ✅ ✅ - -
8-librca - - ✅ ✅
8-orcl - ✅ - -
11 - ✅ - -
11-j9 ✅ ✅ - -
11-librca - - ✅ ✅
17 ✅ ✅ - -
17-graal ✅ ✅ - -
17-j9 ✅ ✅ - -
17-librca - - ✅ ✅
21 ✅ ✅ - -
21-graal ✅ ✅ - -
21-librca - - ✅ ✅
25 ✅ ✅ - -
25-graal ✅ ✅ - -
25-librca - - ✅ ✅

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-11-30 14:27:53 UTC

@dd-octo-sts

dd-octo-sts Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

❌ 29 passed, 1 failed out of 30 expected configurations

Test Matrix

Platform JDK 8 JDK 11 JDK 17 JDK 21 JDK 25
glibc-x64-hotspot ✅ ✅ ✅ ✅ ✅
glibc-x64-openj9 ✅ ✅ ✅ ✅ ✅
glibc-arm64-hotspot ❌ ✅ ✅ ✅ ✅
glibc-arm64-openj9 ✅ ✅ ✅ ✅ ✅
musl-x64-hotspot ✅ ✅ ✅ ✅ ✅
musl-x64-openj9 N/A N/A N/A N/A N/A
musl-arm64-hotspot ✅ ✅ ✅ ✅ ✅
musl-arm64-openj9 N/A N/A N/A N/A N/A

Failure Details

glibc-arm64-hotspot-jdk8

Tracer+profiler:

"  This may indicate tracer is not capturing any requests"
""
"[7/8] Checking for unexpected events..."
"  ? No unexpected events found"
""
"[8/8] Scenario-specific validation (ddprof_with_tracer)..."
"  Validating tracer+profiler scenario..."
"  ? Tracer+profiler scenario checks passed"
""
"=== Validation Summary ==="
"ExecutionSample:            4 events (datadog.ExecutionSample)"
"Stack traces:               4 samples"
"Thread diversity:           2 threads"
"Allocation samples:         0.0 events (jdk.ObjectAllocationSample)"
"ThreadAllocationStatistics: 86 events"
""
"VALIDATION_FAILED: One or more checks did not pass"

Script executed successfully: 425 commands
VALIDATION_FAILED: Validation checks did not pass

Links

10 not applicable (not scheduled): musl-x64-openj9, musl-arm64-openj9. OpenJ9 requires glibc; upstream publishes no musl runtime.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

DataDog/java-profiler | integration-test-arm64-glibc: [hotspot, 8] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/java-profiler | post-pr-comment — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3dd2891 | Docs | View more details | Give us feedback!

@jbachorik
jbachorik marked this pull request as ready for review November 27, 2026 19:49
@jbachorik
jbachorik requested a review from a team as a code owner November 27, 2026 19:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T19:51:48.424947Z fa42f25 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa42f258d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

A resumed worker can stop with trusted feedback still pending, and commit-message text can fool the unsigned-commit check. Feedback truncation, aggregate polling time, and a stale-base rebase instruction also leave concrete failure paths.

Open Bits AI session

🤖 Bits Code Review · Commit fa42f25

Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread utils/babysit_pr_policy.py Resolved
Comment thread utils/babysit-pr.py Resolved
Comment thread .agents/skills/babysit-pr/SKILL.md Resolved
@jbachorik

jbachorik commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

🐶 babysit-pr is watching this PR — CI breakages and mechanical findings are fixed and pushed automatically; design decisions are always brought to you.

This run
  • 20:12 · started · head fa42f258d
  • 20:13 · CI · green on fa42f258d
  • 20:13 · Bits · failure on fa42f258d
  • 20:16 · answered · inline 4722148719
  • 20:16 · answered · inline 4722148739
  • 20:17 · handoff · decision for the session: PR 1070: 11 valid Bits/Codex findings sit outside the scope-guard allowlist (utils/, SKILL.md); the session has to fix t
  • 21:30 · asked · decision resolved by the session: session fixed A-G in beb3c7e, 490343b, 07d7950
  • 21:30 · answered · inline 4722148754
  • 21:31 · answered · inline 4723180661
  • 21:31 · answered · inline 4723226032
  • 21:31 · answered · inline 4722148763
  • 21:31 · answered · inline 4723226016
  • 21:31 · answered · inline 4723180669
  • 21:31 · answered · inline 4722148771
  • 21:31 · answered · inline 4723180676
  • 21:31 · answered · inline 4723226045
  • 21:31 · answered · inline 4723226039
  • 21:31 · answered · inline 4723226051
  • 21:31 · answered · inline 4722081174
  • 21:31 · answered · inline 4722081127
  • 21:32 · resumed · worker relaunched on 07d79500f
  • 21:32 · CI · pending on 07d79500f
  • 21:32 · Bits · pending on 07d79500f
  • 21:42 · Bits · failure on 07d79500f
  • 21:43 · handoff · decision for the session: Decision: Bits P2 on utils/babysit-pr.py:368 (poll_once drops discovered events when publish_status runs out of budget)
  • 10:40 · asked · decision resolved by the session: session fixed 4723807307 in 0456c82..11fe541
  • 10:40 · answered · inline 4723807307
  • 10:40 · stopped · two-hour cap passed; session fixed the last finding

✅ stopped 10:40 UTC · two-hour cap passed; session fixed the last finding

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The PR moves babysitting mechanics into a CLI with session-owned commits, pushes, and replies; signature detection, pending-inbox completion, feedback truncation, polling overruns, and stale-base rebasing are fixed. One issue remains: budget exhaustion during the status update can discard fetched findings and repeatedly prevent their delivery to the worker.

Open Bits AI session

🤖 Bits Code Review · Commit 07d7950

Comment thread utils/babysit-pr.py Resolved
@jbachorik

jbachorik commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

🐶 babysit-pr is watching this PR — CI breakages and mechanical findings are fixed and pushed automatically; design decisions are always brought to you.

This run
  • 10:41 · started · head 11fe541fd
  • 10:41 · CI · pending on 11fe541fd
  • 10:41 · Bits · pending on 11fe541fd
  • 10:51 · Bits · success on 11fe541fd
  • 11:21 · CI · red on 11fe541fd
  • 12:00 · stopped · Tier 3 setup broken on main (jafar-shell 0.30.0); relaunch after the pin lands

✅ stopped 12:00 UTC · Tier 3 setup broken on main (jafar-shell 0.30.0); relaunch after the pin lands

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The PR uses a deterministic babysitting CLI with session-owned commits, pushes, and replies. All findings raised in this session are resolved: signature detection, pending feedback, complete event bodies, polling deadlines, base refresh, and feedback persistence across deferred status updates; no reportable issues remain.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 11fe541

@jbachorik
jbachorik force-pushed the drydock/jb-patient-cotton-otter branch from 11fe541 to 3dd2891 Compare November 30, 2026 14:01
@jbachorik

jbachorik commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

🐶 babysit-pr is watching this PR — CI breakages and mechanical findings are fixed and pushed automatically; design decisions are always brought to you.

This run
  • 14:01 · started · head 3dd289114
  • 14:02 · CI · pending on 3dd289114
  • 14:02 · Bits · pending on 3dd289114
  • 14:03 · answered · issue 6093534140
  • 14:18 · stopped · stopped by the user

✅ stopped 14:18 UTC · stopped by the user

@jbachorik

Copy link
Copy Markdown
Collaborator Author

This finding is already fixed. The last issue ("budget exhaustion during the status update can discard fetched findings and repeatedly prevent their delivery to the worker") was addressed by commit 0afc48fa8 ("babysit-pr: save poll results before the status update"), which saves poll results before the status-comment update and keeps status_dirty set until the update succeeds, so a budget-exhausted update can no longer discard fetched findings or strand them. It is covered by utils/tests/test_babysit_pr.py additions in that commit. A later Bits review in the same session (commit 11fe541) reports all findings resolved: "feedback persistence across deferred status updates ... no reportable issues remain." The earlier FAILs on 3d49e86 and fa42f25 are likewise superseded: 623e50d16 addressed the wait-budget/completion/signing/rebase findings and bc67635c1/8ab58626b the retry-scheduling and cancelled-run findings.

Note: 11fe541 was since amended, so a fresh Bits review is running on the current head.

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The documented Claude Code relaunch reuses an existing worker branch, blocking subsequent babysitting rounds. Reply bookkeeping can also hide unanswered findings, and PR closure can strand queued replies after a push has landed.

Open Bits AI session

🤖 Bits Code Review · Commit 3dd2891

Comment on lines +63 to +64
Then relaunch: `start` (prints `resumed`) and launch the worker again, unless the run
is `stopped`. When the run is stopped, relay the stop summary from `status`: commits

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Refresh the worker checkout before relaunching

After a Claude Code worker hands off a fix, its worktree and <branch>-babysit branch remain. Following the relaunch instructions repeats git worktree add -b with that existing branch and fails. Reusing the old checkout also fails the next handoff because its HEAD remains at the previous base. Each launch needs a fresh checkout of the current PR head and an unused worker branch.

Suggested change
Then relaunch: `start` (prints `resumed`) and launch the worker again, unless the run
is `stopped`. When the run is stopped, relay the stop summary from `status`: commits
Then relaunch unless the run is `stopped`: fetch the current PR branch, run `start`
(prints `resumed`), and launch a fresh worker at `origin/<branch>`. On Claude Code,
use a new worktree path and a unique local branch name for each launch; the exited
worker's worktree still holds its staged patch and old HEAD. When the run is
stopped, relay the stop summary from `status`: commits

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

Comment thread utils/babysit-pr.py
"""Post one signed reply unless GitHub already holds the babysitter's reply to `to`
(a crash between the post and the state save); records `to` in replied either way.
existing is the PR's comments of that kind, fetched when None. The posted id or None."""
if to in st["replied"]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Namespace reply records by GitHub resource type

GitHub reviews, issue comments, and inline comments use separate numeric ID namespaces, but replied stores bare integers. A focused reproduction answered issue comment 42, then polled an unanswered trusted inline root 42: the policy returned green_done without surfacing that finding. Resource-qualified keys are needed throughout reply state, recovery tags, policy checks, and handoff records, including distinguishing reviews from issue comments.

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

Comment thread utils/babysit-pr.py
Comment on lines +702 to +715
if gh_api("repos/%s/pulls/%d" % (REPO, a.pr))["state"] != "open":
raise Refused("PR is no longer open")
if git("symbolic-ref", "-q", "--short", "HEAD", check=False) != st["branch"]:
raise Refused("check out %s in the session checkout first" % st["branch"])
fresh, why = review_marker_fresh(st["branch"])
if not fresh:
raise Refused("review marker not fresh for HEAD; run pre-pr-review first: " + why)
head = git("rev-parse", "HEAD")
if head == h["base_head"]:
raise Refused("HEAD is still the handoff base: nothing to push (not rebased?)")
remote_tip = git("ls-remote", st["remote"], "refs/heads/" + st["branch"], timeout=GH_TIMEOUT_S)
# Equal: pushed before a crash lost the save. The push guards below apply only
# to a push still to make, so recovering the replies works past every cap.
if remote_tip.split("\t")[0] != head:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Recover landed pushes before rejecting closed PRs

If a push lands before a crash loses the phase save, and the PR closes before retrying, this guard rejects recovery before checking the remote tip. Queued replies remain unsent and stop also refuses the committed handoff. A focused in-memory reproduction confirmed the refusal despite a matching remote tip. Apply the open-PR requirement only when a new push is necessary.

Suggested change
if gh_api("repos/%s/pulls/%d" % (REPO, a.pr))["state"] != "open":
raise Refused("PR is no longer open")
if git("symbolic-ref", "-q", "--short", "HEAD", check=False) != st["branch"]:
raise Refused("check out %s in the session checkout first" % st["branch"])
fresh, why = review_marker_fresh(st["branch"])
if not fresh:
raise Refused("review marker not fresh for HEAD; run pre-pr-review first: " + why)
head = git("rev-parse", "HEAD")
if head == h["base_head"]:
raise Refused("HEAD is still the handoff base: nothing to push (not rebased?)")
remote_tip = git("ls-remote", st["remote"], "refs/heads/" + st["branch"], timeout=GH_TIMEOUT_S)
# Equal: pushed before a crash lost the save. The push guards below apply only
# to a push still to make, so recovering the replies works past every cap.
if remote_tip.split("\t")[0] != head:
if git("symbolic-ref", "-q", "--short", "HEAD", check=False) != st["branch"]:
raise Refused("check out %s in the session checkout first" % st["branch"])
fresh, why = review_marker_fresh(st["branch"])
if not fresh:
raise Refused("review marker not fresh for HEAD; run pre-pr-review first: " + why)
head = git("rev-parse", "HEAD")
if head == h["base_head"]:
raise Refused("HEAD is still the handoff base: nothing to push (not rebased?)")
remote_tip = git("ls-remote", st["remote"], "refs/heads/" + st["branch"], timeout=GH_TIMEOUT_S)
# Equal: pushed before a crash lost the save. The push guards below apply only
# to a push still to make, so recovering the replies works past every cap.
if remote_tip.split("\t")[0] != head:
if gh_api("repos/%s/pulls/%d" % (REPO, a.pr))["state"] != "open":
raise Refused("PR is no longer open")

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI human_review:mandatory Human review required — see PR description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant