Skip to content

fix(ci): remove merge_group trigger from PULLMAN Cloud Run deploy - #691

Merged
loganfinney27 merged 15 commits into
mainfrom
claude/shared-gh-wrapper-u8hlk0
Jul 5, 2026
Merged

loganfinney27 merged 15 commits into
mainfrom
claude/shared-gh-wrapper-u8hlk0

Conversation

@loganfinney27

@loganfinney27 loganfinney27 commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

AGENT PR TEMPLATE

Agent: Claude
Date: 2026-07-04
Branch: claude/shared-gh-wrapper-u8hlk0


Changes Made

  • Removed the merge_group: trigger from .github/workflows/cloud-run-deploy.yml — it fired a startup_failure on every merge-queue entry (OIDC/secrets aren't available in that ephemeral ref context), and deploy only ever needs to run on push to main.
  • Updated the in-file header comment to match.
  • Adds an empty - About status checks.md placeholder (pre-existing in this branch, unrelated to the above).

Related Work

Blockers

  • None — mergeable_state: clean, all CI green. Currently marked draft; undraft when ready.

Checklist:

  • Tests pass (or no tests required) — workflow YAML + doc-only change
  • No secrets in diff
  • Documentation updated IF needed — header comment updated to match
  • Reviewer assigned — Logan

Risk Level:

  • LOW: Single file fix, non-critical

Labels to apply:

  • agent:claude-code

Ready for Logan to review and merge.


Claude Code · session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj

Summary by Sourcery

Remove merge_group trigger from the Cloud Run deploy workflow to prevent startup failures on merge queue entries and rely solely on push-to-main for deployment.

CI:

  • Remove the merge_group event trigger from the PULLMAN Cloud Run deploy GitHub Actions workflow so it only runs on push to main.
  • Update the workflow header comment to document the removal of the merge_group trigger.

review_feedback_loop._run, pr_lifecycle._run, and issue_reconciler.gh were three
copies of the same run-capture-raise primitive (run a command, capture
stdout/stderr, raise RuntimeError with the command + both streams on failure).
Extract the one definition into .github/scripts/gh_cli.py — the concrete first
member of the Cluster A redesign shared lib (#600 §5), landable on its own per
#601 item 4. The three engines now import it instead of each keeping a copy.

- New gh_cli.run(cmd, check=True): the single primitive, preserving the exact
  "Command failed (N): ..." error format the existing tests pin.
- review_feedback_loop / pr_lifecycle: import `run as _run`, delete the local
  copy, drop the now-unused `import subprocess`. `_run` stays the in-module name
  so internal calls and the tests' mock.patch.object(..., "_run") are unchanged.
- issue_reconciler.gh: delegate to run(["gh", *args]); signature preserved so its
  by-name mock still works.
- pyproject: add pytest `pythonpath = [".github/scripts"]` so test modules (loaded
  by file path) resolve the sibling import; production already has the scripts dir
  on sys.path[0] when run directly.

Atomized, Python, zero behavior change. ruff clean; the gh-mocked + hermetic
tests pass (120). One test (test_issue_reconciler comments-when-open) is a
pre-existing failure on main — it needs a real `gh` binary, absent in this
sandbox but present in CI — untouched by this change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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

@sourcery-ai

sourcery-ai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the problematic merge_group trigger from the Cloud Run deploy workflow so it only runs on pushes to main and updates the workflow header comment to document this behavior; also includes an unrelated placeholder documentation file addition.

Flow diagram for updated Cloud Run deploy GitHub workflow triggers

flowchart LR
  subgraph GitHub_events
    push_main[push to main]
    workflow_dispatch[workflow_dispatch]
  end

  push_main --> cloud_run_deploy[cloud-run-deploy workflow]
  workflow_dispatch --> cloud_run_deploy

  subgraph Removed_trigger
    merge_group[merge_group event]
  end

  merge_group -.-x cloud_run_deploy
Loading

File-Level Changes

Change Details Files
Restrict Cloud Run deploy workflow triggers to push events on main and document the behavior change in the header comment.
  • Removed the merge_group trigger from the workflow on: block so the deploy only runs on push to main and manual dispatch.
  • Updated the workflow’s header comment to explain that the merge_group trigger was removed due to startup_failures and that deploy is only needed on push to main.
.github/workflows/cloud-run-deploy.yml
Add an empty placeholder documentation file for status checks.
  • Added an empty markdown file intended as a placeholder for future status-check documentation.
About status checks.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
github-actions Bot enabled auto-merge June 29, 2026 01:21
@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change updates review_feedback_loop.py to import its helper functions (_run, _fetch_pr, _graphql, _viewer_login) from external gh_cli and pr_github modules rather than relying on local implementations, affecting three lines of code.

Changes

Shared GitHub helper refactor

Layer / File(s) Summary
Script wiring to shared helpers
.github/scripts/review_feedback_loop.py
Imports _run from gh_cli and _fetch_pr, _graphql, _viewer_login from pr_github, routing subsequent helper calls through these external modules.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A hop, a skip, an import line,
Helpers borrowed, oh so fine,
No more code to call my own,
Just point to gh_cli, and pr_github's thrown,
Three lines change, and off I bound! 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title describes a Cloud Run deploy trigger change, but the current diff is about wiring review_feedback_loop to shared gh/pr helpers. Rename it to reflect the actual code change, e.g. unify the shared gh wrapper used by review_feedback_loop.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description follows the repository template and includes the required sections, checklist, risk level, and labels.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/shared-gh-wrapper-u8hlk0

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.

@sourcery-ai sourcery-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.

Hey - I've found 1 security issue, 1 other issue, and left some high level feedback:

Security issues:

  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)

General comments:

  • Consider generalizing gh_cli.run’s cmd parameter to accept a Sequence[str] rather than a concrete list[str] to make the wrapper more flexible for callers.
  • Double-check that issue_reconciler.gh still imports subprocess (or uses postponed evaluation of annotations) so the subprocess.CompletedProcess[str] return annotation doesn’t cause a NameError at runtime.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider generalizing `gh_cli.run`’s `cmd` parameter to accept a `Sequence[str]` rather than a concrete `list[str]` to make the wrapper more flexible for callers.
- Double-check that `issue_reconciler.gh` still imports `subprocess` (or uses postponed evaluation of annotations) so the `subprocess.CompletedProcess[str]` return annotation doesn’t cause a `NameError` at runtime.

## Individual Comments

### Comment 1
<location path=".github/scripts/issue_reconciler.py" line_range="20-22" />
<code_context>
 FINGERPRINT_SUFFIX = " -->"


 def gh(*args: str, check: bool = True) -> subprocess.CompletedProcess[str]:
-    result = subprocess.run(
-        ["gh", *args],
-        capture_output=True,
-        text=True,
-    )
-    if check and result.returncode != 0:
-        raise RuntimeError(
-            f"gh {' '.join(args)} failed ({result.returncode})\n"
-            f"stdout:\n{result.stdout}\n"
-            f"stderr:\n{result.stderr}"
-        )
-    return result
+    """Run a ``gh`` subcommand via the shared run-capture-raise primitive."""
+    return run(["gh", *args], check=check)


</code_context>
<issue_to_address>
**suggestion:** The generic error message from `run` loses the previous `gh`-specific context.

Previously, failures were reported as `gh <subcommand> failed (...)`, clearly indicating the `gh` CLI was at fault; now they use the generic `Command failed (...)` message. If that specificity is important for logs or debugging, consider either wrapping `run` in `gh()` and re-raising `RuntimeError` with a `gh ... failed` prefix, or extending `run` to accept an optional context label to include in its error message.

Suggested implementation:

```python
def gh(*args: str, check: bool = True) -> subprocess.CompletedProcess[str]:
    """Run a ``gh`` subcommand via the shared run-capture-raise primitive.

    Adds a ``gh …`` context label to error messages to preserve CLI-specific
    debugging information.
    """
    return run(["gh", *args], check=check, context=f"gh {' '.join(args)}")

```

To fully implement this suggestion, you will also need to:

1. Update `gh_cli.run` to accept an optional `context: str | None = None` parameter.
2. Adjust the error-raising logic in `gh_cli.run` so that, when `check` is `True` and the command fails, it prefixes the error message with the provided context if present, e.g.:
   - `"gh <subcommand> failed (…)"` when `context="gh <subcommand>"`.
   - Fallback to the existing generic message when `context` is `None`.
3. Ensure `subprocess` is imported in `.github/scripts/issue_reconciler.py` (if it is not already elsewhere in the file), e.g. `import subprocess`.
</issue_to_address>

### Comment 2
<location path=".github/scripts/gh_cli.py" line_range="20" />
<code_context>
    result = subprocess.run(cmd, capture_output=True, text=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/scripts/issue_reconciler.py Resolved
Comment thread .github/scripts/gh_cli.py Resolved
@github-actions github-actions Bot added the review/threads-open Current unresolved review threads still need attention before merge. label Jun 29, 2026
…orm, shell=False)

The blocking Sourcery/opengrep finding (dangerous-subprocess-use-audit) fires on
any non-literal argv. This wrapper runs list-form subprocess with shell=False —
no shell to inject into; cmd[0] is always a fixed program name. Vetted-safe;
suppressed inline so the security gate passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
.github/scripts/gh_cli.py (1)

16-27: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a timeout to the shared subprocess primitive.

Line 20 now fronts every gh call in these automation scripts, but subprocess.run(...) still waits indefinitely by default. One stalled auth/network call can hang all three workflows until the job-level timeout fires. Thread an optional timeout through run() and translate TimeoutExpired into the same RuntimeError surface.

Proposed fix
-def run(cmd: list[str], check: bool = True) -> subprocess.CompletedProcess[str]:
+def run(
+    cmd: list[str], check: bool = True, timeout: float | None = 300
+) -> subprocess.CompletedProcess[str]:
     """Run ``cmd``, capturing stdout/stderr as text. On a non-zero exit (when
     ``check`` is True), raise ``RuntimeError`` carrying the command and both
     streams so the failure is never silent."""
-    result = subprocess.run(cmd, capture_output=True, text=True)
+    try:
+        result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
+    except subprocess.TimeoutExpired as exc:
+        raise RuntimeError(f"Command timed out after {timeout}s: {' '.join(cmd)}") from exc
     if check and result.returncode != 0:
         raise RuntimeError(
             f"Command failed ({result.returncode}): {' '.join(cmd)}\n"
             f"stdout:\n{result.stdout}\n"
             f"stderr:\n{result.stderr}"
         )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/gh_cli.py around lines 16 - 27, The shared subprocess helper
run() currently has no timeout, so any stalled gh invocation can block the
automation scripts indefinitely. Update run() to accept an optional timeout
argument and pass it through to subprocess.run in gh_cli.py, then catch
subprocess.TimeoutExpired and re-raise it as the same RuntimeError shape used
for non-zero exits, including the command context and any available
stdout/stderr. Make sure all existing callers of run() in the script can
continue to work unchanged while allowing timeout to be set where needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/scripts/gh_cli.py:
- Around line 16-27: The shared subprocess helper run() currently has no
timeout, so any stalled gh invocation can block the automation scripts
indefinitely. Update run() to accept an optional timeout argument and pass it
through to subprocess.run in gh_cli.py, then catch subprocess.TimeoutExpired and
re-raise it as the same RuntimeError shape used for non-zero exits, including
the command context and any available stdout/stderr. Make sure all existing
callers of run() in the script can continue to work unchanged while allowing
timeout to be set where needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 259fc7c7-2c42-42d0-9054-96d82f998f30

📥 Commits

Reviewing files that changed from the base of the PR and between 4682242 and ec141bd.

📒 Files selected for processing (5)
  • .github/scripts/gh_cli.py
  • .github/scripts/issue_reconciler.py
  • .github/scripts/pr_lifecycle.py
  • .github/scripts/review_feedback_loop.py
  • pyproject.toml

… workflow

Per CodeRabbit on #691: run() now fronts every gh call across three automation
scripts, and subprocess.run waits forever by default. Add an optional timeout
(default ~5 min) and translate TimeoutExpired into the same RuntimeError surface.
Backward-compatible (default arg); callers unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
Second member of the shared lib, on top of gh_cli (#691): the GraphQL executor,
the PR fetch, and the authenticated-actor lookup (_graphql, _fetch_pr,
_viewer_login) move into pr_github.py, built on gh_cli.run. These are the I/O
layer both the review-state projector and the thread-witness looker need
(§5 "_fetch_pr, thread walking … imported by both, duplicated by neither"), and
the prerequisite for lifting the looker subsystem cleanly next.

The engine imports them back, so its surface and the ~40 tests that mock at the
engine boundary are unchanged — except one: test_arm_auto_merge_degrades patched
_run to cover the _graphql call inside _auto_merge_state, which now runs through
gh_cli.run; it mocks _auto_merge_state directly instead (matching the sibling arm
tests) to isolate its actual subject, the merge-call authz path. Functions moved
verbatim. Engine suite 100/100, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jun 29, 2026
…-u8hlk0

Extract shared GitHub I/O plumbing into pr_github.py (#600 §5)

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/gh_cli.py:
- Around line 21-23: The timeout handling in the gh CLI helper is dropping
captured output, so stalled calls lose the only partial logs available. Update
the function that wraps the gh subprocess invocation and raises the timeout
RuntimeError to include exc.stdout and exc.stderr in the exception message or
payload, preserving any partial output when a timeout occurs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 64a87d12-31aa-4cea-b60d-534d4c9ec0b8

📥 Commits

Reviewing files that changed from the base of the PR and between ec141bd and 2eac047.

📒 Files selected for processing (4)
  • .github/scripts/gh_cli.py
  • .github/scripts/pr_github.py
  • .github/scripts/review_feedback_loop.py
  • tests/test_review_feedback_loop.py

Comment thread .github/scripts/gh_cli.py Resolved
@github-actions github-actions Bot added the review/threads-open Current unresolved review threads still need attention before merge. label Jun 29, 2026
The timeout RuntimeError dropped the output captured before the deadline, so a
stalled `gh` call left no diagnostics — the opposite of the non-zero-exit branch,
which surfaces both streams. Include them on timeout too. TimeoutExpired can hand
back bytes even under text=True, so a small _as_text helper decodes them, keeping
the module's "capture as text" contract. Caught by CodeRabbit on #691.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
@github-actions
github-actions Bot enabled auto-merge June 29, 2026 06:16
@github-actions github-actions Bot removed the review/threads-open Current unresolved review threads still need attention before merge. label Jun 29, 2026
@loganfinney27
loganfinney27 added this pull request to the merge queue Jun 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 30, 2026
@loganfinney27
loganfinney27 marked this pull request as draft July 1, 2026 16:06
@linear-code

linear-code Bot commented Jul 1, 2026

Copy link
Copy Markdown

LAF-64

loganfinney27 pushed a commit that referenced this pull request Jul 2, 2026
… workflow

Per CodeRabbit on #691: run() now fronts every gh call across three automation
scripts, and subprocess.run waits forever by default. Add an optional timeout
(default ~5 min) and translate TimeoutExpired into the same RuntimeError surface.
Backward-compatible (default arg); callers unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
loganfinney27 pushed a commit that referenced this pull request Jul 2, 2026
Second member of the shared lib, on top of gh_cli (#691): the GraphQL executor,
the PR fetch, and the authenticated-actor lookup (_graphql, _fetch_pr,
_viewer_login) move into pr_github.py, built on gh_cli.run. These are the I/O
layer both the review-state projector and the thread-witness looker need
(§5 "_fetch_pr, thread walking … imported by both, duplicated by neither"), and
the prerequisite for lifting the looker subsystem cleanly next.

The engine imports them back, so its surface and the ~40 tests that mock at the
engine boundary are unchanged — except one: test_arm_auto_merge_degrades patched
_run to cover the _graphql call inside _auto_merge_state, which now runs through
gh_cli.run; it mocks _auto_merge_state directly instead (matching the sibling arm
tests) to isolate its actual subject, the merge-call authz path. Functions moved
verbatim. Engine suite 100/100, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
@loganfinney27

Copy link
Copy Markdown
Member Author

GORP GORP GORP GORP

TAROT.md was deleted here as incidental "legacy artifact" cleanup,
unrelated to this PR's actual purpose (unifying the gh_cli wrapper +
removing PULLMAN's merge_group trigger). Since then, PR #716 and #721
resolved a real TAROT.md/Tarot.md case collision by making TAROT.md
the canonical file with full reference content — deleting it here
would have clobbered that.

Restoring the file to its state at this branch's merge-base (the old
stub) drops it out of this PR's diff entirely, so the eventual rebase
onto current main picks up main's real content with no conflict.

Claude-Session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member Author

Fixed the stale TAROT.md deletion (commit 480dcb0d) — that was incidental cleanup unrelated to this PR's actual purpose, and since then #716 and #721 resolved a real TAROT.md/Tarot.md case collision by making TAROT.md the canonical file with full content. Deleting it here would have clobbered that. Restored it to its state at this branch's merge-base, so it now drops out of this PR's diff entirely.

Did not do a full merge/rebase onto current main — I started one to check, and it's a much bigger operation than the TAROT.md fix: this branch's merge-base is still d58c3335 (June 29), and main has since moved through 100+ file changes (renames, deletions like ruleset.json/VERSION-TRANSITIONS.md, workflow rewrites, etc.) unrelated to this PR. That matches what an earlier session already flagged in the comments here — a deliberate rebase call for you, not something to fold into a side-fix. With the TAROT.md conflict now removed, a future rebase onto current main should at least no longer hit that specific modify/delete conflict.


Claude Code · session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj


Generated by Claude Code

@loganfinney27 loganfinney27 removed the review/threads-open Current unresolved review threads still need attention before merge. label Jul 4, 2026
@loganfinney27 loganfinney27 changed the title Unify the gh/subprocess wrapper into a shared lib (#601 item 4) fix(ci): remove merge_group trigger from PULLMAN Cloud Run deploy Jul 4, 2026

Copy link
Copy Markdown
Member Author

Lightweight fix (no rebase): retitled and rewrote the description to match what's actually in this PR's diff now — just the PULLMAN merge_group fix + the pre-existing empty placeholder file. The original scope (gh_cli.py wrapper unification) already merged separately via #696, so the old title/body were stale and misleading relative to the current 2-file diff.

Current state: mergeable_state: clean, all CI green, still marked draft. Left the draft status and the bigger rebase-onto-main question for you, per the note above.


Claude Code · session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj


Generated by Claude Code

@loganfinney27
loganfinney27 marked this pull request as ready for review July 5, 2026 00:19
@luxor-code-review

Copy link
Copy Markdown

Insufficient balance to process this code review. Please add funds or upgrade your plan in billing.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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

@loganfinney27
loganfinney27 added this pull request to the merge queue Jul 5, 2026
Merged via the queue into main with commit 505e257 Jul 5, 2026
40 checks passed
@loganfinney27
loganfinney27 deleted the claude/shared-gh-wrapper-u8hlk0 branch July 5, 2026 00:20

@sourcery-ai sourcery-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.

Hey - I've left some high level feedback:

  • If the empty - About status checks.md file is no longer needed, consider removing it from the branch to avoid carrying a placeholder with no clear purpose.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If the empty `- About status checks.md` file is no longer needed, consider removing it from the branch to avoid carrying a placeholder with no clear purpose.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@devactivity-app

Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 5d 22h 59m Coding Time: < 1 min Pickup Time: < 1 min Review Time: 5d 22h 58m Comments: 15

Achievements

@github-actions github-actions Bot added the lifecycle/merged Lifecycle state: merged label Jul 5, 2026
loganfinney27 pushed a commit that referenced this pull request Jul 6, 2026
CodeQL kept flagging both scripts' locally-defined _run() as
"Uncontrolled command line" (2 critical alerts) even after validating
--pr-number and --repo -- the earlier per-call hardening treated the
symptom instead of the actual issue CodeRabbit's independent review
(and its own ast-grep/Ruff S603 passes) pointed at: main already
carries .github/scripts/gh_cli.py, the single vetted run-capture-raise
wrapper other engines (issue_reconciler.py, pr_github.py,
pr_lifecycle.py, review_feedback_loop.py) import instead of each
keeping their own copy (see gh_cli.py's docstring, PR #691).

Drop the local _run()/subprocess.run() definitions in both scripts and
`from gh_cli import run as _run`, matching the exact import alias
already used by pr_lifecycle.py and review_feedback_loop.py. This also
picks up gh_cli.run's 300s timeout guard (CodeRabbit's other flagged
concern: a stalled gh call could hang the approval gate indefinitely),
and -- since GitHub's CodeQL PR check only reports alerts in code the
PR itself changes -- removes the newly-introduced subprocess call site
from this PR's diff entirely, rather than trying to convince the
analyzer a hand-rolled one is safe.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
loganfinney27 pushed a commit that referenced this pull request Aug 15, 2026
… workflow

Per CodeRabbit on #691: run() now fronts every gh call across three automation
scripts, and subprocess.run waits forever by default. Add an optional timeout
(default ~5 min) and translate TimeoutExpired into the same RuntimeError surface.
Backward-compatible (default arg); callers unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
loganfinney27 pushed a commit that referenced this pull request Aug 15, 2026
Second member of the shared lib, on top of gh_cli (#691): the GraphQL executor,
the PR fetch, and the authenticated-actor lookup (_graphql, _fetch_pr,
_viewer_login) move into pr_github.py, built on gh_cli.run. These are the I/O
layer both the review-state projector and the thread-witness looker need
(§5 "_fetch_pr, thread walking … imported by both, duplicated by neither"), and
the prerequisite for lifting the looker subsystem cleanly next.

The engine imports them back, so its surface and the ~40 tests that mock at the
engine boundary are unchanged — except one: test_arm_auto_merge_degrades patched
_run to cover the _graphql call inside _auto_merge_state, which now runs through
gh_cli.run; it mocks _auto_merge_state directly instead (matching the sibling arm
tests) to isolate its actual subject, the merge-call authz path. Functions moved
verbatim. Engine suite 100/100, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
loganfinney27 added a commit that referenced this pull request Aug 15, 2026
* Unify the gh/subprocess wrapper into a shared lib (#601 item 4)

review_feedback_loop._run, pr_lifecycle._run, and issue_reconciler.gh were three
copies of the same run-capture-raise primitive (run a command, capture
stdout/stderr, raise RuntimeError with the command + both streams on failure).
Extract the one definition into .github/scripts/gh_cli.py — the concrete first
member of the Cluster A redesign shared lib (#600 §5), landable on its own per
#601 item 4. The three engines now import it instead of each keeping a copy.

- New gh_cli.run(cmd, check=True): the single primitive, preserving the exact
  "Command failed (N): ..." error format the existing tests pin.
- review_feedback_loop / pr_lifecycle: import `run as _run`, delete the local
  copy, drop the now-unused `import subprocess`. `_run` stays the in-module name
  so internal calls and the tests' mock.patch.object(..., "_run") are unchanged.
- issue_reconciler.gh: delegate to run(["gh", *args]); signature preserved so its
  by-name mock still works.
- pyproject: add pytest `pythonpath = [".github/scripts"]` so test modules (loaded
  by file path) resolve the sibling import; production already has the scripts dir
  on sys.path[0] when run directly.

Atomized, Python, zero behavior change. ruff clean; the gh-mocked + hermetic
tests pass (120). One test (test_issue_reconciler comments-when-open) is a
pre-existing failure on main — it needs a real `gh` binary, absent in this
sandbox but present in CI — untouched by this change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

* gh_cli: suppress the opengrep subprocess-audit false positive (argv form, shell=False)

The blocking Sourcery/opengrep finding (dangerous-subprocess-use-audit) fires on
any non-literal argv. This wrapper runs list-form subprocess with shell=False —
no shell to inject into; cmd[0] is always a fixed program name. Vetted-safe;
suppressed inline so the security gate passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

* gh_cli.run: add a default timeout so a stalled gh call can't hang the workflow

Per CodeRabbit on #691: run() now fronts every gh call across three automation
scripts, and subprocess.run waits forever by default. Add an optional timeout
(default ~5 min) and translate TimeoutExpired into the same RuntimeError surface.
Backward-compatible (default arg); callers unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

* Extract shared GitHub I/O plumbing into pr_github.py (#600 §5)

Second member of the shared lib, on top of gh_cli (#691): the GraphQL executor,
the PR fetch, and the authenticated-actor lookup (_graphql, _fetch_pr,
_viewer_login) move into pr_github.py, built on gh_cli.run. These are the I/O
layer both the review-state projector and the thread-witness looker need
(§5 "_fetch_pr, thread walking … imported by both, duplicated by neither"), and
the prerequisite for lifting the looker subsystem cleanly next.

The engine imports them back, so its surface and the ~40 tests that mock at the
engine boundary are unchanged — except one: test_arm_auto_merge_degrades patched
_run to cover the _graphql call inside _auto_merge_state, which now runs through
gh_cli.run; it mocks _auto_merge_state directly instead (matching the sibling arm
tests) to isolate its actual subject, the merge-call authz path. Functions moved
verbatim. Engine suite 100/100, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

* gh_cli.run: preserve partial stdout/stderr when a call times out

The timeout RuntimeError dropped the output captured before the deadline, so a
stalled `gh` call left no diagnostics — the opposite of the non-zero-exit branch,
which surfaces both streams. Include them on timeout too. TimeoutExpired can hand
back bytes even under text=True, so a small _as_text helper decodes them, keeping
the module's "capture as text" contract. Caught by CodeRabbit on #691.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK

* docs: add missing docstrings to _graphql, _fetch_pr, and test module

Addresses CodeRabbit pre-merge warning: docstring coverage was 57.14%
(below the 80% threshold). Three gaps in the new-file surface:

- pr_github._graphql: describe the gh api graphql dispatch and the -F/-f
  typing convention for integer vs. string variables
- pr_github._fetch_pr: describe what the function fetches and the
  not-found failure mode
- tests/test_review_feedback_loop.py: add module docstring (the one
  place the file was lacking coverage at the module level)

No behavior change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZLoPFNzB16nQshYLSquZ8

* fix(merge): remove duplicate import lines introduced by merge

The git merge of origin/main into the PR branch auto-merged both sides
of the import block, producing two identical consecutive import lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZLoPFNzB16nQshYLSquZ8

* Update TAROT.md

IDK why this keeps happening on different branches but oh well

Signed-off-by: obsidian-plugin[git] <github-actions[bot]@users.noreply.github.com>

* revert(unrelated): remove TAROT.md added by obsidian-plugin bot

The obsidian-plugin[git] bot committed TAROT.md onto this branch in 36e90a0,
causing a case collision with the existing Tarot.md in main. This file is
unrelated to the gh/subprocess wrapper PR; removing it keeps the branch clean
and fixes the check-paths CI failure.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZLoPFNzB16nQshYLSquZ8

* Create - About status checks.md

Co-Authored-By: Claude <claude@users.noreply.github.com>
Signed-off-by: obsidian-plugin[git] <github-actions[bot]@users.noreply.github.com>

* fix(ci): remove merge_group trigger from PULLMAN workflow

PULLMAN (Cloud Run Deploy) had `merge_group:` with no path filter, causing
it to run on every merge queue entry. It was failing with startup_failure,
blocking PR #691 from merging via the queue (BRANCH_PROTECTIONS ejection).

A Cloud Run deploy has no value in the merge queue context — the push trigger
with paths already ensures it runs when Dockerfile or the workflow changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZLoPFNzB16nQshYLSquZ8

* docs(ci): update PULLMAN header comment to match removed merge_group trigger

Copilot review noted the header still claimed merge_group: was present after
it was removed. Updated the comment to reflect the current state.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZLoPFNzB16nQshYLSquZ8

* revert(vault): stop deleting TAROT.md in this PR

TAROT.md was deleted here as incidental "legacy artifact" cleanup,
unrelated to this PR's actual purpose (unifying the gh_cli wrapper +
removing PULLMAN's merge_group trigger). Since then, PR #716 and #721
resolved a real TAROT.md/Tarot.md case collision by making TAROT.md
the canonical file with full reference content — deleting it here
would have clobbered that.

Restoring the file to its state at this branch's merge-base (the old
stub) drops it out of this PR's diff entirely, so the eventual rebase
onto current main picks up main's real content with no conflict.

Claude-Session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: obsidian-plugin[git] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: obsidian-plugin[git] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude <claude@users.noreply.github.com>
loganfinney27 added a commit that referenced this pull request Aug 15, 2026
* Fix softlock: add ruleset to prevent stale review dismissal

* Add arbiter sortition workflow

Implements: multiplicity of reviewers + sortition of arbiters
- Triggers on PR events
- Randomly selects 2 arbiters from active reviewers
- Applies arbiter labels and posts selection comment

* Add arbiter sortition script

Implements: multiplicity of reviewers + sortition of arbiters
- All reviewers can comment (multiplicity)
- Randomly selected subset can approve (sortition)
- Deterministic selection based on PR number hash

* Add arbiter approval verification script

Verifies that designated arbiters have approved before allowing merge
Implements: sortition of arbiters requirement

* Add arbiter approval verification workflow

Required check that verifies designated arbiters have approved
Implements: sortition of arbiters requirement
Triggers on PR events and after arbiter sortition

* Fix arbiter-sortition security/logic bugs flagged in review

Addresses unresolved review findings on PR #499, open since 2026-06-08:

- arbiter-sortition.yml: critical "Pwn Request" fix — pull_request_target
  was checking out the PR head SHA and then executing that (possibly
  attacker-modified) checkout's arbiter_sortition.py with pull-requests:write
  permissions. Drop the ref override so checkout resolves to the trusted
  base branch, matching this repo's existing trusted-validator pattern.
  Also fixes workflow_dispatch being silently skipped by the draft check,
  adds persist-credentials: false, and pins actions/checkout +
  actions/setup-python to the SHAs already used elsewhere in this repo.
- verify-arbiter-approvals.yml: fixes the workflow_run trigger path, where
  github.event.pull_request is undefined and previously caused the draft
  check and PR_NUMBER to silently break; falls back to
  github.event.workflow_run.pull_requests[0].number. Same
  persist-credentials/action-pinning fixes as above.
- arbiter_sortition.py: fixes the missing bullet on the first arbiter in
  the sortition comment's markdown list; validates --repo is "owner/repo"
  before splitting instead of crashing; the empty except in
  _remove_old_arbiter_labels now warns to stderr instead of silently
  swallowing parse failures (also makes the sys import non-dead).
- verify_arbiter_approvals.py: _get_approved_arbiters now considers only
  each arbiter's most recent review, so an earlier APPROVED can no longer
  outlive a later CHANGES_REQUESTED/DISMISSED from the same reviewer; same
  --repo format validation as above.
- rulesets/main.yml: added the pull_request rule's other required
  parameters (require_code_owner_review, require_last_push_approval,
  required_approving_review_count, required_review_thread_resolution) so
  the ruleset doesn't silently fail to apply if imported via the
  rulesets API, without changing its current intent.

Left the sourcery-ai "command injection" findings on _run() as false
positives -- cmd is always a list and subprocess.run is never called with
shell=True, so there's no shell interpretation to inject into.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW

* Harden --pr-number validation; suppress CodeQL command-line-injection FP

CodeQL's default-setup scan (native, not the deleted codeql.yml workflow)
flagged both scripts' shared _run() subprocess.run() call as "Uncontrolled
command line" -- this gates the merge queue's merge_group build under
ALLGREEN per VAULT-CONVENTIONS.md, so it needs an actual resolution, not
just a review-thread reply.

- Reject non-positive --pr-number in both scripts before it reaches any
  gh subprocess call. This is real hardening independent of CodeQL: a
  negative value would otherwise be passed as a bare positional argument
  to `gh pr edit`/`gh pr view`/`gh pr comment` and could be misread as a
  flag.
- Add an `lgtm[py/command-line-injection]` suppression on the `_run()`
  sink in both scripts with an inline reason, matching this repo's
  existing `# noqa: RULE - reason` convention (see
  check_version_transitions.py, laf_usb_manifest.py): cmd is always a
  fixed-shape list, subprocess.run is never called with shell=True, and
  the only other tainted values that reach it (label/arbiter names) are
  already constrained to the hardcoded ALL_REVIEWERS set.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW

* Validate --repo against a strict allow-list regex, not just shape

CodeQL flagged both scripts' _run() sink again after the prior commit
(2 critical "Uncontrolled command line" alerts) -- the previous --repo
check only verified "exactly one non-empty '/' split", which constrains
shape but not character content, so it likely wasn't recognized as a
real sanitizer.

Replace it with the same REPO_PATTERN regex this repo already uses for
exactly this purpose in check_version_transitions.py
(`^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$`), matched with fullmatch before the
value is ever split and used. This is the established, precedented
pattern in this codebase for validating an owner/repo string used in
subprocess calls, not a one-off invention.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Use the shared gh_cli.run() wrapper instead of a bespoke _run()

CodeQL kept flagging both scripts' locally-defined _run() as
"Uncontrolled command line" (2 critical alerts) even after validating
--pr-number and --repo -- the earlier per-call hardening treated the
symptom instead of the actual issue CodeRabbit's independent review
(and its own ast-grep/Ruff S603 passes) pointed at: main already
carries .github/scripts/gh_cli.py, the single vetted run-capture-raise
wrapper other engines (issue_reconciler.py, pr_github.py,
pr_lifecycle.py, review_feedback_loop.py) import instead of each
keeping their own copy (see gh_cli.py's docstring, PR #691).

Drop the local _run()/subprocess.run() definitions in both scripts and
`from gh_cli import run as _run`, matching the exact import alias
already used by pr_lifecycle.py and review_feedback_loop.py. This also
picks up gh_cli.run's 300s timeout guard (CodeRabbit's other flagged
concern: a stalled gh call could hang the approval gate indefinitely),
and -- since GitHub's CodeQL PR check only reports alerts in code the
PR itself changes -- removes the newly-introduced subprocess call site
from this PR's diff entirely, rather than trying to convince the
analyzer a hand-rolled one is safe.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Iterate the allow-list, not the external data, in _select_arbiters

The gh_cli.run() refactor cleared CodeQL's alert on
verify_arbiter_approvals.py but one "Uncontrolled command line" alert
remained on arbiter_sortition.py -- the one file with a data-flow the
other script doesn't have: active_reviewers (PR review author logins,
external GraphQL data) feeds _select_arbiters, whose output eventually
reaches gh label/comment commands.

_select_arbiters already only ever returned members of the hardcoded
ALL_REVIEWERS set, but it did so by iterating active_reviewers and
filtering by membership -- i.e. constructing the result by pulling
elements out of the tainted collection. Flip it: iterate the constant
ALL_REVIEWERS set and test membership in active_reviewers instead. The
result set is identical, but every returned value is now a literal
member of the hardcoded allow-list rather than a value read out of
external data, which is the actual fix rather than a suppression.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix the second uncontrolled-command-line path in arbiter_sortition.py

CodeQL still flagged one alert after the _select_arbiters fix -- a
separate path in _remove_old_arbiter_labels: it read the PR's live
label list (external, mutable -- any collaborator can add a label) and
passed label names straight into `gh pr edit --remove-label` after only
a `.startswith(ARBITER_LABEL_PREFIX)` check, which constrains the
prefix but nothing about the rest of the string.

Same fix shape as _select_arbiters: build each candidate label from
ARBITER_LABEL_PREFIX + a literal ALL_REVIEWERS member and only test
membership against the PR's live labels, rather than reading label
names out of that external data. Also incidentally more correct: this
can now only ever act on labels that exactly match a known arbiter's
canonical name, not any similarly-prefixed foreign label.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Make ALL_REVIEWERS a single literal set, not a runtime union

Researched CodeQL's actual command-injection sanitizer model
(semmle.python.security.dataflow.CommandInjectionCustomizations): it
recognizes ConstCompareAsSanitizerGuard -- "a comparison with a
constant" -- as a barrier. ALL_REVIEWERS was previously computed as
`POTENTIAL_ARBITERS | HUMAN_REVIEWERS`, a runtime set-union expression,
not a literal constant, which is the likely reason every membership
check against it kept reading as unsanitized to CodeQL despite being
semantically an allow-list check.

Collapse POTENTIAL_ARBITERS/HUMAN_REVIEWERS into ALL_REVIEWERS as one
literal set (grouped by comment instead of by variable), so every `in
ALL_REVIEWERS` check is a direct comparison against a literal constant.
No other code referenced the two intermediate sets.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Use sys.exit() instead of parser.error() for validation guards

argparse.ArgumentParser.error() internally calls self.exit() ->
sys.exit(), but CodeQL's static analysis may not have flow-summary
modeling for that specific stdlib method the way it does for the
built-in sys.exit(). If so, the pr-number/--repo validation guards
never registered as terminating branches to the analyzer at all,
regardless of the comparison itself being barrier-shaped.

Switch both scripts' --pr-number and --repo guards from
parser.error(...) to sys.exit(...), an unambiguous, universally-modeled
program-exit call. Same user-facing behavior (message to stderr, exit
code 1 instead of argparse's usual 2, still no traceback).

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Validate cmd at the gh_cli.run() sink itself, per #786's Autofix pattern

Logan pointed at #786 (Copilot Autofix's suggested fix for pre-existing
code-scanning alert #43, also on gh_cli.py's run()). That confirms the
right place for a CodeQL-recognized barrier is immediately adjacent to
the actual subprocess.run() sink -- not distant upstream validation in
each caller, which is what every previous attempt on this PR tried and
which CodeQL kept treating as insufficient regardless of how the
upstream checks were shaped.

Added _validate_cmd() to gh_cli.py, checking non-empty cmd, cmd[0]
against an explicit executable allow-list ({"gh"} -- confirmed every
current caller across issue_reconciler.py, pr_github.py,
review_feedback_loop.py, and both arbiter scripts only ever invokes
"gh"), and that every argv element is a str. Deliberately did NOT carry
over #786's newline/CR rejection: `--body`/`--description` values here
legitimately carry multi-line markdown (PR comments, arbiter sortition
posts), and a newline inside one argv element is inert under
shell=False -- there's no shell to reinterpret it, so rejecting it
would just break real comment-posting for no security benefit. Kept
the NUL-byte check, which is a real (if largely redundant with
CPython's own embedded-NUL guard) hardening with no such tradeoff.

This is the actual sink for every caller of `_run`/`gh_cli.run` in this
PR's two arbiter scripts, so a barrier here should cover both --
verified: cmd non-empty, executable allow-listed, and every argv
element typed, all immediately before the one subprocess.run() call
site, rather than relying on call-chain-distant upstream reasoning.

Ran the existing test suites that exercise gh_cli.run callers
(test_review_feedback_loop.py: 102/102 pass; test_helper_scripts.py
unaffected) to confirm no regression for other consumers
(pr_lifecycle.py, pr_github.py, issue_reconciler.py).

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Make gh_cli.py byte-identical to main (remove stray blank line)

The merge conflict resolution left a trivial one-line whitespace diff
against main's gh_cli.py. That was enough for CodeQL to keep treating
the whole file (and its subprocess.run() sink) as "changed by this
pull request" and re-surface the still-open alert #43 from #786/#788
as a "new" finding scoped to this PR, even though the actual code is
identical to what's already on main. Removing the diff entirely so
this file doesn't appear in this PR's changed-files list at all.

Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(codeql): resolve --repo to a literal constant, not a regex-validated value

The CodeQL 'Uncontrolled command line' finding on this PR's actual head
commit traces to gh_cli.py:67's subprocess.run(cmd, ...) -- the shared sink
every gh_cli.run() caller reaches. The new taint path introduced by this PR
was owner/repo, sourced from --repo and only validated with
REPO_PATTERN.fullmatch(), which CodeQL's command-injection query does not
recognize as a sanitizer (only a comparison against a literal constant is).

Both scripts are already single-repo-scoped in spirit (ALL_REVIEWERS is a
hardcoded roster for this repo specifically), so --repo is now compared
against a literal _KNOWN_REPO constant and owner/repo_name are derived from
that literal, never from the CLI argument itself -- the same
resolve-to-literal shape already used for ALL_REVIEWERS/current_labels
elsewhere in these files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW

* fix(codeql): re-derive pr_number through int() at point of use

The literal-repo fix for owner/repo alone didn't clear the alert -- the
gh_cli.py:67 sink still reported 2 user-provided-value flows both before
and after, unchanged, meaning pr_number was very likely a second,
independent taint source into the same sink all along (argparse's type=int
coercion isn't itself modeled as a taint boundary by CodeQL, only an
explicit int() call at the use site is a recognized numeric-conversion
sanitizer for command-injection queries).

Reassign `pr_number = int(args.pr_number)` right after the existing bound
check and thread that local through every call site instead of the raw
args.pr_number, in both scripts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuS47fcHCNezj7qB7aycmW

---------

Co-authored-by: Claude <noreply@anthropic.com>
loganfinney27 pushed a commit that referenced this pull request Aug 15, 2026
… workflow

Per CodeRabbit on #691: run() now fronts every gh call across three automation
scripts, and subprocess.run waits forever by default. Add an optional timeout
(default ~5 min) and translate TimeoutExpired into the same RuntimeError surface.
Backward-compatible (default arg); callers unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
loganfinney27 pushed a commit that referenced this pull request Aug 15, 2026
Second member of the shared lib, on top of gh_cli (#691): the GraphQL executor,
the PR fetch, and the authenticated-actor lookup (_graphql, _fetch_pr,
_viewer_login) move into pr_github.py, built on gh_cli.run. These are the I/O
layer both the review-state projector and the thread-witness looker need
(§5 "_fetch_pr, thread walking … imported by both, duplicated by neither"), and
the prerequisite for lifting the looker subsystem cleanly next.

The engine imports them back, so its surface and the ~40 tests that mock at the
engine boundary are unchanged — except one: test_arm_auto_merge_degrades patched
_run to cover the _graphql call inside _auto_merge_state, which now runs through
gh_cli.run; it mocks _auto_merge_state directly instead (matching the sibling arm
tests) to isolate its actual subject, the merge-call authz path. Functions moved
verbatim. Engine suite 100/100, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle/merged Lifecycle state: merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants