Skip to content

fix(dev-lead): trusted-author tracker links; no auto-merge after a failed deferral (#2045 follow-up) - #2087

Merged
don-petry merged 6 commits into
mainfrom
claude/gallant-johnson-4a7sox
Oct 9, 2026
Merged

don-petry merged 6 commits into
mainfrom
claude/gallant-johnson-4a7sox

Conversation

@don-petry

@don-petry don-petry commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #2049. It fixes the two major findings from #2049's final pr-review cycle, which were found after the approved head (7bf83ec1) had merged:

  1. Tracker trust model. dtv_verify_tracking_issue accepted a thread link from any author.
    • Now the issue body counts only when the issue's author_association is OWNER, MEMBER or COLLABORATOR, and only comments by those authors count.
    • A link written only by an untrusted author returns untrusted-mention, and the thread stays open.
  2. dev-lead reports status=applied / 'Changes committed and pushed' when the requested review changes were not applied #1567 auto-merge guard. When a pass pushed a commit but its deferred-thread resolution failed, finalize_review_application was skipped and _REVIEW_INCOMPLETE stayed unset. So try_enable_auto_merge still ran.
    • All three deferral-failure branches (fix-reviews, review-changes, fix-bot-comment) now set _REVIEW_INCOMPLETE=1.
    • fix-bot-comment's auto-merge guard now honors the flag too.

Problem

Refs #2045.

  • Before the trust fix, anyone able to open an issue titled dev-lead: deferred review findings, or to comment on it, could authorize auto-resolving a merge-blocking bot review thread.
  • Before the auto-merge fix, a pass that hadn't finished resolving its review items could still turn auto-merge on. Branch protection's required thread resolution usually blocked the merge anyway, but only by coincidence.

Risk

Medium. This changes the dev-lead harness, which runs only after merge and reaches consumers through ring promotion.

Both changes only fail closed:

  • a thread that would have been resolved may now stay open;
  • auto-merge that would have been enabled may now stay off.

The REST issue and comment payloads already carry author_association, so no new API calls are needed.

Test plan

Rollback

Revert this PR. There are no non-revertible side effects.

Monitoring

  • Watch dev-lead run logs for untrusted-mention notices. Seeing one means a tracker link was ignored and the thread left open.
  • Check that deferred threads on PRs whose tracker issue is authored by our account still resolve.

Interaction contract

  • N/A — this PR does not add or change an agentic role.

🤖 Generated with Claude Code

https://claude.ai/code/session_019K6UsD7r25pAcRjJL3G6Kx


Generated by Claude Code

View guided diff Turn on auto-fix

donpetry-bot and others added 4 commits October 9, 2026 01:25
…2034)

FORCE_REVIEW bypasses every review gate, but it was derived from
event_name == repository_dispatch alone. The mention listener also
dispatches for machine-added 'review_requested: donpetry-bot' events, so
automated re-review requests approved past the maintainer-comment gate
and the next event run dismissed the approval, looping until the per-PR
automation budget ran out.

FORCE_REVIEW now requires client_payload.force_review == true. A dispatch
without it runs with every gate armed plus the narrow FORCE_RE_REVIEW
idempotency bypass, so it can neither approve over an open finding nor
re-run a cascade whose verdict already stands at the head.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019K6UsD7r25pAcRjJL3G6Kx
…ct expressions

Test-Change-Justification: file is new in this PR (#2078); review threads asked for yq parsing and full-expression assertions
…iled deferral (#2045 follow-up)

Follow-up to #2049 for the two major findings in its final pr-review cycle.

- deferred-thread-verify: a tracking issue can back a deferral only through
  text a trusted author wrote. The issue body counts only when the issue's
  author_association is OWNER/MEMBER/COLLABORATOR, and only comments by such
  authors count. Previously anyone able to open an issue with the tracker
  title, or comment on it, could authorize resolving a merge-blocking bot
  thread. A link from an untrusted author now reports `untrusted-mention`
  and the thread stays open.
- fix-reviews / review-changes / fix-bot-comment: a failed deferral now sets
  _REVIEW_INCOMPLETE, so try_enable_auto_merge never runs on a pass that
  did not finish resolving its review items (the #1567 guard).
  fix-bot-comment's guard now honors the flag too.
- Tests: untrusted issue body, untrusted comment, trusted comment on an
  untrusted issue, an untrusted tracker leaving the thread open end to end,
  and no auto-merge after a failed deferral on a commit pass. Existing
  tracker fixtures now carry author_association.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019K6UsD7r25pAcRjJL3G6Kx
…via #2078; superseded) — keep main + follow-up tree
@don-petry
don-petry requested a review from a team as a code owner October 9, 2026 04:00
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4a55e4f4-a285-467f-bff5-25c2d3999bdd
📥 Commits

Reviewing files that changed from the base of the PR and between e36fada and 692f8a2.

📒 Files selected for processing (4)
  • scripts/dev-lead-fix-reviews.sh
  • scripts/lib/deferred-thread-verify.sh
  • tests/dev-lead/unit/test_deferred_thread_verify.bats
  • tests/dev-lead/unit/test_fix_reviews.bats
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@don-petry don-petry added the dev-lead:hands-off Exclude from dev-lead agent automation label Oct 9, 2026 — with Claude

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request restricts the authorization of deferred review findings to trusted author associations (OWNER, MEMBER, and COLLABORATOR) to prevent unauthorized users from resolving merge-blocking bot threads. It also ensures that if a deferred review cannot be resolved, the auto-merge feature is not enabled. Unit tests have been updated and added to verify these behaviors. I have no feedback to provide as there are no review comments.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/dev-lead-fix-reviews.sh
Comment thread scripts/dev-lead-fix-reviews.sh
@codeant-ai

codeant-ai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge: failed deferral resolution prevents a success marker and keeps previously enabled auto-merge from being restored.
  • Only tracker links from owners, members, or collaborators authorize thread resolution, and tests cover trusted and untrusted authors.

Assessed commit: c08b4f6f96ee

… the EXIT-trap restore

_REVIEW_INCOMPLETE stopped try_enable_auto_merge, but the EXIT trap's
restore_auto_merge still re-enabled auto-merge that hold_auto_merge had turned
off at the start of the pass. The three deferral-failure branches now also set
_AM_NEEDS_RESTORE=0, matching the existing #2037 path.

Tests: a failed deferral leaves held-off auto-merge off; a successful one still
turns it back on (the stub can now start a PR with auto-merge on).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019K6UsD7r25pAcRjJL3G6Kx
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #2087
No changes were committed, but the PR still can't be marked done: required check CodeQL is still pending. The retry cron will re-attempt automatically. Next attempt after: 2026-10-09T04:45:03Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but I can't mark it done yet: required check CodeQL is still pending. I'll re-check automatically.
Next attempt after: 2026-10-09T04:45:03Z

@don-petry
don-petry enabled auto-merge (squash) October 9, 2026 04:15

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/dev-lead-fix-reviews.sh
@don-petry

Copy link
Copy Markdown
Collaborator Author

dev-lead is withholding action on this item.

It is labeled dev-lead:hands-off (deliberately kept off-limits to dev-lead (e.g. changes to the dev-lead automation itself)), so dev-lead will not pick it up while that label is present. This notice is posted once so the withhold is visible rather than looking like a stalled run.

To re-enable automated pickup: remove the dev-lead:hands-off label.

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@donpetry-bot

Copy link
Copy Markdown
Contributor

No description provided.

@donpetry-bot

Copy link
Copy Markdown
Contributor

No description provided.

@donpetry-bot donpetry-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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 692f8a2e05aaca49479e161e29daaca5d9fadb92
Review mode: triage-approved (single reviewer)

Summary

Follow-up to #2049 that fixes two fail-open gaps in the #2045 deferred-thread flow. (1) dtv_verify_tracking_issue now accepts a thread link only from the tracker issue body when the issue's author_association is OWNER/MEMBER/COLLABORATOR, or from comments by such authors. A link from an untrusted author returns untrusted-mention and the thread stays open. (2) All three deferral-failure branches (fix-reviews, review-changes, fix-bot-comment) now set _REVIEW_INCOMPLETE=1 and _AM_NEEDS_RESTORE=0, and the fix-bot-comment auto-merge guard now honors _REVIEW_INCOMPLETE. A pass whose deferral resolution failed therefore can neither enable auto-merge nor restore it through the EXIT trap. Both changes only fail closed. I confirm the triage-approved assessment, but rate the PR MEDIUM rather than LOW because it changes authorization and auto-merge logic in the dev-lead harness.

Linked issue analysis

Refs #2045 (closed): deferred review threads had no resolvable outcome. This PR does not close an issue. It fixes the two major findings from #2049's final review cycle, which came in after #2049 had already merged. Both findings are addressed: the trust model is tightened, and #1567's "never auto-merge an incomplete pass" guarantee now covers deferral failures, including the EXIT-trap restore path.

Findings

No blocking findings.

  • Trust check (scripts/lib/deferred-thread-verify.sh): author_association is upper-cased and matched against a fixed allow-list. A missing value falls back to "" and is treated as untrusted (fail closed). The issue body is checked only when the issue author is trusted. Comments are filtered one by one, so a trusted comment on an untrusted author's issue still verifies, which is intended and tested. The extra untrusted-mention probe affects only the log reason; the function still returns 1.
  • Auto-merge guard (scripts/dev-lead-fix-reviews.sh): In fix-reviews and review-changes, try_enable_auto_merge was already gated on _REVIEW_INCOMPLETE, so setting the flag in the deferral-failure branch closes the commit-pass gap where finalize_review_application was skipped. For fix-bot-comment, the one-line guard change adds the same check. Setting _AM_NEEDS_RESTORE=0 matches the existing #2037 _DISPOSITIONS_UNRESOLVED handling.
  • Non-blocking, operational: if a tracker issue is ever opened by an identity whose author_association resolves to NONE or CONTRIBUTOR (e.g. a GitHub App token, or a member whose org membership is private and not visible to the token), deferrals against that tracker will never auto-resolve. This fails safe, and the PR's Monitoring section already calls out watching for untrusted-mention.
  • Non-blocking, already discussed: cubic noted that suppressing the restore loses a non-squash auto-merge method across the retry. The author declined with sound reasoning: the behavior matches the existing #2037 path and squash is the repo default. The thread is resolved.
  • Tests: 3 new unit tests (untrusted body, untrusted comment, trusted comment on an untrusted author's issue) and 4 new integration cases (untrusted tracker stays open; failed deferral does not restore auto-merge; successful deferral still restores it; failed deferral on a commit pass never enables auto-merge). Existing fixtures were updated to carry author_association. shellcheck --severity=warning is clean on both changed scripts locally.
  • Secret scan: the MCP run_secret_scanning tool is not available in this run, so it was skipped. The gitleaks CI check is green.
  • All 3 bot review threads are resolved. No human reviewer has asked an unanswered question.

CI status

All required checks pass: bats, unit-tests, unit, shellcheck/ShellCheck, CodeQL, SonarCloud, gitleaks, prompt-coverage, actionlint, AgentShield and the standards checks. The dev-lead / dispatch|ci-relay|resume jobs show CANCELLED; they are dispatch-concurrency noise, consistent with the dev-lead:hands-off label, not test failures. The dependency-audit ecosystem jobs were skipped as not applicable.


Reviewed automatically by the PR-review agent (single-reviewer mode: opus 5.5 [opus 4.8, opus 4.7]). Reply if you need a human review.

@donpetry-bot

Copy link
Copy Markdown
Contributor

pr-review approved on PARTIAL advisory evidence: 4/5 required advisory bots reported before the gate's head-age-timeout fallback proceeded. Recorded for the miss-rate metric (#1596).

@don-petry
don-petry merged commit 6415eab into main Oct 9, 2026
70 of 73 checks passed
@don-petry
don-petry deleted the claude/gallant-johnson-4a7sox branch October 9, 2026 04:42

@donpetry-bot donpetry-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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 692f8a2e05aaca49479e161e29daaca5d9fadb92
Review mode: triage-approved (single reviewer)

Summary

Follow-up to #2049 that closes the two major findings from its last review cycle. Both changes only fail closed. (1) dtv_verify_tracking_issue now accepts a tracker-issue link only from the issue body when the issue's author_association is OWNER, MEMBER or COLLABORATOR, or from comments by those authors. A link written only by an untrusted author returns untrusted-mention and the thread stays open. (2) All three deferral-failure branches (fix-reviews, review-changes, fix-bot-comment) now set _REVIEW_INCOMPLETE=1 and _AM_NEEDS_RESTORE=0, so a pass that failed to resolve a deferral can't enable auto-merge or restore it on exit. fix-bot-comment's auto-merge guard now honors _REVIEW_INCOMPLETE. I agree with the triage tier's low-risk call; I rate it MEDIUM because it changes dev-lead harness logic.

Linked issue analysis

Refs #2045 (closed), the deferred-thread resolution feature first shipped in #2049. This PR fixes the post-merge findings on that feature: the tracker trust model and the #1567 auto-merge guard after a failed deferral. It uses Refs rather than Closes, which is correct for a follow-up to an already-closed issue.

Findings

No blocking findings.

  • Ordering is correct. Each new _REVIEW_INCOMPLETE=1 / _AM_NEEDS_RESTORE=0 assignment runs before that intent's try_enable_auto_merge gate (fix-reviews ~L3256 → L3305, fix-bot-comment ~L3405 → L3430, review-changes ~L3536 → L3575). Clearing _AM_NEEDS_RESTORE follows the existing #2037 _DISPOSITIONS_UNRESOLVED pattern. The P2 thread about losing the merge strategy across the dropped restore was answered with a reasoned won't-fix.
  • The trust filter fails closed. A missing or unknown author_association counts as untrusted. Values are upper-cased before the comparison. The extra untrusted-mention check is diagnostic only and always returns 1.
  • Tests cover the new paths. There are new unit tests for an untrusted body, an untrusted comment, and a trusted comment on an untrusted author's issue. Harness tests cover an untrusted-only tracker, no auto-merge restore after a failed deferral, restore still happening after a successful deferral, and no auto-merge enable on a commit pass with a failed deferral. Existing fixtures were updated with author_association: MEMBER.
  • Non-blocking note: if a tracker issue were created by an identity whose association reads as NONE or CONTRIBUTOR (for example a GitHub App bot token, or concealed org membership), its deferrals would now stay open as untrusted-mention instead of resolving. That is safe, and the PR's Monitoring section already calls out watching for it.

All 3 review threads (cubic, codeant) are resolved. There are no unanswered human questions.

CI status

All required checks pass: shellcheck, bats, unit-tests, CodeQL, SonarCloud (Quality Gate passed), gitleaks, AgentShield, actionlint and the stub/standards gates. A few duplicate dev-lead / dispatch|resume|ci-relay runs show CANCELLED or SKIPPED, but each has a matching SUCCESS run, so this is concurrency noise, not a failure.


Reviewed automatically by the PR-review agent (single-reviewer mode: opus 5.5 [opus 4.8, opus 4.7]). Reply if you need a human review.

@donpetry-bot donpetry-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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 692f8a2e05aaca49479e161e29daaca5d9fadb92
Review mode: triage-approved (single reviewer)

Summary

Follow-up to #2049 that closes the two remaining fail-open gaps in the #2045 deferred-thread flow. Both changes fail closed. (1) dtv_verify_tracking_issue now accepts a thread link only from the tracker issue body when the issue's author_association is OWNER, MEMBER or COLLABORATOR, or from comments by such authors. A link written only by an untrusted author returns untrusted-mention, and the thread stays open. (2) All three deferral-failure branches (fix-reviews, review-changes, fix-bot-comment) now set _REVIEW_INCOMPLETE=1 and _AM_NEEDS_RESTORE=0, and fix-bot-comment's auto-merge guard now checks _REVIEW_INCOMPLETE. A pass whose deferral resolution failed can no longer enable or restore auto-merge (#1567). The triage assessment holds.

Linked issue analysis

Refs #2045 (closed), which added the deferred/out-of-scope outcome for review threads. This PR fixes the two major findings from #2049's final review cycle: an untrusted author could authorize auto-resolving a tracker-linked thread, and auto-merge could be enabled after a deferral failed. Both are addressed directly, with regression tests. No closing references, which is correct for a follow-up.

Findings

No blocking findings.

  • Trust filter (scripts/lib/deferred-thread-verify.sh): $trusted | index($a) is applied to both the issue body (via the issue's author_association) and each comment. A missing or empty association reads as untrusted, so it fails closed. untrusted-mention is computed only after both trusted checks fail, so it is only a diagnostic. The caller (resolve_deferred_bot_threads) treats it like no-mention: it logs a notice, leaves the thread open, and does not count it as a failure. The REST issues/{n} and issues/{n}/comments payloads already carry author_association, so no new API calls are needed.
  • Auto-merge guard (scripts/dev-lead-fix-reviews.sh): fix-reviews and review-changes already gated try_enable_auto_merge on _REVIEW_INCOMPLETE. The new assignment closes the commit-pass gap, where finalize_review_application was skipped. Clearing _AM_NEEDS_RESTORE stops the EXIT trap from re-enabling auto-merge that was held off at the start. Both points were raised by cubic and CodeAnt, and those threads are resolved. fix-bot-comment's one-line guard now matches the other two branches.
  • Tests: 3 new verifier unit tests (untrusted issue body, untrusted comment, trusted comment on an untrusted author's issue). 4 new harness tests (untrusted tracker stays open; a failed deferral does not restore auto-merge; a successful deferral still restores it; a failed deferral on a commit pass never enables auto-merge). Existing fixtures were updated with author_association: MEMBER.
  • Non-blocking note: the tracker issue and its linking comments must now be written by an OWNER, MEMBER or COLLABORATOR account. If dev-lead ever writes to the tracker as a GitHub App or other non-collaborator identity, deferred threads will stay open. That fails closed, and the PR's Monitoring section already says to watch for untrusted-mention.
  • Secret scan: the run_secret_scanning MCP tool was not available in this run. The gitleaks CI check passed.

CI status

All required checks pass: shellcheck, ShellCheck, bats, unit-tests, prompt-coverage, CodeQL (actions and python), SonarCloud quality gate, gitleaks secret scan, AgentShield, actionlint, and the workflow and stub validators. Some dev-lead / dispatch, resume and ci-relay runs show as cancelled, skipped or queued. Those are dev-lead orchestration runs, held by the dev-lead:hands-off label, not code checks, and other runs of the same jobs succeeded. All review threads are resolved, and there are no unanswered human questions.


Reviewed automatically by the PR-review agent (single-reviewer mode: opus 5.5 [opus 4.8, opus 4.7]). Reply if you need a human review.

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

Labels

dev-lead:hands-off Exclude from dev-lead agent automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants