Skip to content

fix(source-control): keep a person's needs-human removal off at an unchanged escalation - #9512

Merged
kyle-sexton merged 6 commits into
mainfrom
fix/escalation-reapplies-after-human-lift
Oct 23, 2026
Merged

kyle-sexton merged 6 commits into
mainfrom
fix/escalation-reapplies-after-human-lift

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

No related issue: found while tracing why needs-human came back on #9487 after a person removed it; no open issue tracks it.

Summary

The pr-merge lane put needs-human back on a pull request after a person removed it, at the same head and for the same reasons. On #9487 the lanes App escalated at 21:35:48Z with risk:MED (evidence-unbound:claude-security-review: skip-not-no-change) at head 1628ab628e94c61aef97aed6a9a9d0b8abfd35f1. kyle-sexton removed the label at 21:46:31Z and queued the PR at 21:51:39Z. At 21:54:32Z the pr-merge gate (run 40029253237, job merge, step "Run the merge gate on each candidate") added the label again and logged riskEscalation: {"label": "added", "comment": "unchanged"}. ci-status in merge-group run 40029788252 then failed on the label ("Removing the label approves this pull request; re-queue it to merge."), and the queue removed the PR.

Cause: escalate() in babysit_merge.py treated a missing label beside an unchanged escalation comment as a failed label write and retried it on every run. It could not tell a failed write from a person's removal. The pr-unblock-dispatch run that was active at the same time (40029993196) only logged skip #9487: mergeable still UNKNOWN after 5 re-queries and wrote nothing.

Fix

  • escalate() now reads the PR timeline in one case only: the label is absent and the marker comment is unchanged. If the label's newest removal came after that comment last changed and was a person's, the label stays off and the run reports label: lifted. A person here is a User of kind human on the trusted-actor list read at the repository's default branch (never the head or a retargeted base; an unreadable default branch is no lift) who also passes merge_policy.is_human: write or admin access, not the agent identity, not a self-login. A removal by the lanes App, github-actions[bot], an account off the list (a model-driven User with write access included) or anyone without write access lifts nothing.
  • The comment names the head and the reasons, so a new head or new reasons rewrite it and escalate again with no extra read. A failed timeline or comment read, or a time that does not parse, adds the label as before.
  • The read uses the verdict reader's token when one is set. The check covers all four pr-merge escalations: risk, verifier, held-major and shared-copy.
  • Docs: the pr-pipeline README (the risk-escalation paragraph and the verifier-escalation retry sentence), plus changelog fragments for source-control and pr-pipeline.

Verification

  • python3 -m unittest discover -s tests -t . in plugins/source-control/skills/babysit-prs/scripts: 2706 tests, OK.
  • New tests in test_babysit_merge_unattended.py:
    • A person's removal after the escalation keeps the label off, for the risk escalation and the held-major one.
    • The label still goes on when the removal came from the lanes App, github-actions[bot], the agent identity or a read-only user, when it came before the comment's last change, when it removed another label, when the timeline read failed, after a failed label write (no removal), and for a new escalation.
    • The timeline is read under the reader token.
    • With the check disabled, the three positive tests fail. Three mutants (no human check, no time check, no label-name check) each fail at least one test.
  • scripts/run-ruff.sh check on both Python files: all checks passed. scripts/check-affected.sh: 12 passed, 1 skipped.
  • Left out: the CI-only whole-repo scanners check-affected.sh lists, which run in CI.

Related

  • report-escalation.sh (pr-unblock) is unchanged. By its documented contract, when a person removes the label to resume and the lane escalates again, the label comes back. Each such label follows a new lane run's decision; no sweep re-asserts an old escalation.
  • clear-escalations.mjs only removes labels, as the lanes App. That removal is a bot's, so it never counts as a lift.
  • feat(pr-pipeline): hold lanes App human-merge pull requests with a label only a listed human can remove #9437 (a hold label only a listed human can remove) is related but separate.

🤖 Generated with Claude Code

kyle-sexton and others added 6 commits October 23, 2026 18:20
…changed escalation

pr-merge's escalate() treated a missing human-gated label as a failed
label write and added it back on every run while the escalation comment
was unchanged, so a person removing the label to approve a pull request
was undone on the next gate run. It now reads the timeline only in that
case (label absent, comment unchanged) and keeps the label off when a
person with write access removed it after the comment last changed. A
bot's removal, the lanes App included, lifts nothing; a new head or new
reasons rewrite the comment and escalate again; a failed read adds the
label as before. Covers the risk, verifier, held-major and shared-copy
escalations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a lift

Review follow-up. A lift now needs the label's newest removal (not any
removal) to come from a User of kind human on the trusted-actor list
read at the base branch, who also passes is_human (write access, not
the agent identity or a self-login): a model-driven User account with
write access no longer lifts an escalation. escalate() reads the
comments once and hands them to both the upsert and the lift check.
Tests cover an untrusted write User, triage access, the newest removal
deciding, an unparsable comment time and no agent identity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. The trusted-actor list that decides a lift is read at
the repository's default branch, never the pull request's base, so a
retarget to a branch that adds the actor cannot widen who lifts; an
unreadable default branch is no lift. Tests cover a same-second tie
(the later removal decides), an unread default branch, a trusted id on
a Bot account, and reading the list at a default branch other than the
base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…unread lifts

A needs-human removal made through a GitHub App (performed_via_github_app)
no longer counts as the person's lift, matching the package's rule for
label provenance. A lift check that could not read the timeline or the
default branch now reports why as liftUnread beside the added label.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 22:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T23:00:30.128789Z d65523d 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.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed d65523df89252cbc0578c3247dc5638072fcc6bc: 0 finding(s), 0 as inline comments.

No blocking or advisory findings on head d65523d.

I read the full diff and the PR context, then checked the new code against its helpers in babysit_merge.py and babysit_merge_policy.py. I did not run the tests. The 2706-test result in the PR description is the author's claim and is unverified by me.

What I checked:

  • escalate() comment read. It now fetches the comments once and passes them to both upsert_marker_comment and _lifted_by_person. The list is stale after an updated or created write, but the lift check only runs when the comment is unchanged, so that is harmless. The extra read only happens when inputs["comments"] is None, as before.
  • Lift conditions. In _lifted_by_person, the newest removal must be strictly after the marker comment's updated_at (or created_at). It must not carry performed_via_github_app, and its actor must be a User whose id is in the humans list from merge_policy.trusted_actors(repo, default). The default-branch ref and a failed read are handled fail-closed. The actor must also pass merge_policy.is_human, which checks write access and excludes the agent identity, self-logins and [bot] logins. The tie-break max(enumerate(removals), key=(time, index)) picks the later timeline item, and that matches its comment and the tie test.
  • Failure behaviour. Any exception, unparsable time, unreadable default branch or unreadable timeline adds the label as before and reports liftUnread. The except Exception carries a noqa with a reason.
  • Scope of the read. The timeline read happens only when the label is absent and the comment is unchanged. A new head or new reasons rewrite the comment, so they escalate again with no extra read.
  • Tests. They cover the positive lift, the default-branch ref, an unread default branch, an App-performed removal, a bot with a trusted id, ties, an off-list write user, triage and read access, the newest removal deciding, an unparsable comment time, a removal before the comment, another label's removal, an unreadable timeline, the reader token, and a new escalation. They also cover the held-major path.
  • Docs and changelog. The README paragraphs and both fragments (source-control, pr-pipeline) match the code's behaviour. Both use bump: patch, which fits a bug fix.
  • PR context. It has no closing issue and states no acceptance criteria. Nothing in it is an embedded instruction.
  • Hold classes. None apply. The change adds no model call, spend, trusted-actors file, CODEOWNERS or .gitmodules change.

No plugin.json or marketplace.json changes, so there are no manifest lines to report.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d65523df89252cbc0578c3247dc5638072fcc6bc: 0 finding(s), 0 as inline comments.

No security findings.

critical-findings: 0

What I reviewed. All 5 changed files: the escalate() change and the new _lifted_by_person() in babysit_merge.py, its tests, the pr-pipeline README and two changelog fragments. I read the callees merge_policy.is_human, trusted_actors, _newest_marker_comment and upsert_marker_comment. The change touches a merge gate: it lets a person's removal of needs-human stay removed. I judged it on whether anything other than a person can now lift the gate.

Why the lift looks sound:

  • Fail closed. _lifted_by_person runs only when the label is absent and the marker comment is unchanged. Any exception, unreadable timeline or default branch, or unparsable time returns "no lift", so the label is re-added as before. liftUnread reports the reason.
  • The remover must be a trusted person. The newest matching unlabeled event must be strictly later than the comment's updated_at/created_at. It must have no performed_via_github_app, actor.type == "User", and an actor id in the kind: human subset of the trusted-actor list. That list is read at the repository default branch (not the head or the PR base), and the actor must pass is_human (write or admin access, not an automation or self login). A write-access User off the list, a bot, an App-mediated removal, or a read or triage user lifts nothing.
  • The newest removal decides. A later bot removal or re-label overrides an earlier person's removal. I found no way for an earlier removal to be reused.
  • Comment forgery is not possible. The escalation comment is matched on the agent identity's login and marker. A comment from anyone else cannot date or stand in for the escalation.
  • New escalations still escalate. A new head or new reasons change the comment body, so the result is updated or created. The lift check is skipped and the label goes on.
  • Token handling is unchanged. The timeline read uses the verdict reader's token when one is set. No new secret is logged. The error text in liftUnread contains only the exception string.

Accepted residual risks (not findings):

  • A human's own token used by an agent directly, not through an App, is indistinguishable from the person. The README and PR text state this limit.
  • performed_via_github_app is None also passes if the API omitted the key. The REST timeline schema carries that field, so I treated this as theoretical.

No manifest, userConfig, trust-gate path (trusted-actors, check-trusted-trigger, CODEOWNERS, .gitmodules) or workflow file is touched, so there are no manifest <field> lines and no hold. The changed docs add a documented exception to the label re-add rule. They do not delete or soften an instruction a mechanism no longer enforces, so I did not consult the instruction exception register. The PR context contained no embedded directives.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit e9f4709 Oct 23, 2026
53 of 64 checks passed
@kyle-sexton
kyle-sexton deleted the fix/escalation-reapplies-after-human-lift branch October 23, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant