Repository navigation
fix(ci): remove merge_group trigger from PULLMAN Cloud Run deploy - #691
Conversation
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 reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRemoves 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 triggersflowchart 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
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe 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. ChangesShared GitHub helper refactor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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’scmdparameter to accept aSequence[str]rather than a concretelist[str]to make the wrapper more flexible for callers. - Double-check that
issue_reconciler.ghstill importssubprocess(or uses postponed evaluation of annotations) so thesubprocess.CompletedProcess[str]return annotation doesn’t cause aNameErrorat 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…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
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/scripts/gh_cli.py (1)
16-27: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a timeout to the shared subprocess primitive.
Line 20 now fronts every
ghcall in these automation scripts, butsubprocess.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 throughrun()and translateTimeoutExpiredinto the sameRuntimeErrorsurface.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
📒 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.pypyproject.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
…-u8hlk0 Extract shared GitHub I/O plumbing into pr_github.py (#600 §5)
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
.github/scripts/gh_cli.py.github/scripts/pr_github.py.github/scripts/review_feedback_loop.pytests/test_review_feedback_loop.py
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
… 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
|
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>
|
Fixed the stale Did not do a full merge/rebase onto current Claude Code · session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj Generated by Claude Code |
|
Lightweight fix (no rebase): retitled and rewrote the description to match what's actually in this PR's diff now — just the PULLMAN Current state: Claude Code · session: https://claude.ai/code/session_01HismCgmXWnAWg4362xJ3vj Generated by Claude Code |
|
Insufficient balance to process this code review. Please add funds or upgrade your plan in billing. |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- If the empty
- About status checks.mdfile 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Pull Request Summary by devActivityMetricsAchievements
|
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>
… 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
* 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>
* 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>
… 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
AGENT PR TEMPLATE
Agent: Claude
Date: 2026-07-04
Branch:
claude/shared-gh-wrapper-u8hlk0Changes Made
merge_group:trigger from.github/workflows/cloud-run-deploy.yml— it fired astartup_failureon every merge-queue entry (OIDC/secrets aren't available in that ephemeral ref context), and deploy only ever needs to run on push tomain.- About status checks.mdplaceholder (pre-existing in this branch, unrelated to the above).Related Work
gh/subprocess wrapper intogh_cli.py) already landed onmainvia extract pr github plumbing #696 — that content is no longer part of this PR's diff. Retitled/redescribed to match what's actually left here.PULLMAN — Cloud Run Deploystartup_failurenoise tracked in CI health reports CI Health Audit — 2026-06-20 (06:00–11:48 UTC) #599/CI Health Report — 2026-06-29 (opencode + PULLMAN startup_failures; PR #699 action_required) #700/CI Health Report — 2026-07-01 (opencode ×63, Dependabot Rhythm ×30, PULLMAN ×8 startup_failures; CodeQL + NETWEB block merge queue) #719.TAROT.mdis no longer touched by this branch (see comment history) — a stray deletion from this PR's earlier scope was reverted so it doesn't conflict with Logan/hotfix/hyperagent #716/fix(vault): resolve TAROT.md/Tarot.md case collision #721's resolution of theTAROT.md/Tarot.mdcase collision.Blockers
mergeable_state: clean, all CI green. Currently marked draft; undraft when ready.Checklist:
Risk Level:
Labels to apply:
agent:claude-codeReady 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: