Repository navigation
Conversation
[ghstack-poisoned]
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". 🟡 AUTOMATED REVIEW - OUTDATED (earlier commit) - Changes requested:
Findings (7): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199566
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 790f75b with merge base 421855c ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ea30e6c56
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
|
@pytorchbot merge |
|
This PR has pending changes requested. Please address the comments and update the PR before merging. |
|
@pytorchbot review I want to keep this scoped to the trusted-checkout triage callers in this stack. I am accepting the remaining generic-action hardening as follow-up work rather than expanding this PR further. Agent details (AI-generated)
Ivan's requested grep/find check is implemented and tested. The current head has no failing CI checks. |
There was a problem hiding this comment.
Automated review of c407f21: changes requested before human review.
This PR adds .github/actions/pi-agent, a composite action that runs one pi session on Bedrock with a tool allowlist and path guard, a schema-checked submit_result tool, pinned rg/fd, a converter to Claude's execution-file format, and offline tests. Recommendation: Request Changes. The .git/config token exposure and the text_or_file path read are security defaults in the action itself, and the guard/result-schema behaviour has no test against the real pinned pi.
🔴 3 blocking findings are attached to the code below.
⚪ 4 non-blocking findings
pytorch/.github/actions/pi-agent/run.sh
Line 68 in c407f21
Low confidence: some pi calls skip the isolation flags. pi update --models (line 68), pi --version (lines 73, 134) and pi --export (line 86) run in the checkout directory without "${isolation\[@\]}". The review couldn't check offline whether pi 0.99.1 loads project .pi/ settings or extensions on these code paths. If it does, a checkout runs code in a step holding AWS credentials. Passing the flags, or running these calls from $out, costs nothing.
The execution-file output doesn't match the README's "same shape" claim. The output is named execution-file, but every claude-code-action consumer reads outputs.execution_file (claude-autorevert-advisor.yml:253,259, hardened-pr-review-run.yml:843-845,1017,1052, auto-pr-triage/action.yml:151,194). It is also inconsistent with this action's own structured_output. In claude-execution.jq:73-74, modelUsage is always {($model): {}}, so the summing at hardened-pr-review-run.yml:1036-1042 yields nothing, and permission_denials is hard-coded to \[\] even though run.sh:113-114 counts blocked calls. Fix: rename the output to execution_file, fill modelUsage\[$model\] from the computed totals, and emit the blocked tool_execution_end entries as permission_denials. Otherwise drop "same shape" from the README.
This line changes PATH for every later step in the job: appending pi-tools/bin to GITHUB_PATH makes the pinned rg/fd shadow the system binaries for all later steps. Prepend it locally in run.sh instead, as run.sh:11 already does for pi-install/node_modules/.bin, and drop the GITHUB_PATH write. That also removes the GITHUB_PATH assertion from test_install_tools.py.
A second invocation in the same job breaks the first one's output. The output directory is hard-coded to $RUNNER_TEMP/pi-run, and rm -rf "$out" (run.sh:9) clears it on every run, while the comment at run.sh:7-8 expects a second invocation. When that happens, the first step's execution-file output points at the second session's file, so an end-of-job usage uploader counts the second run twice. hardened-pr-review-run.yml:839-846 has to work around the same problem for claude-code-action. Fix: use a per-invocation output directory (keyed on artifact-name) or add an output-dir input.
Please address the findings and push; a new commit normally gets a fresh automated review.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
| if (allowed.size === 0) { | ||
| throw new Error("tool-guard: PI_ALLOWED_TOOLS must list the session's tools"); | ||
| } | ||
| const root = realpathSync(process.cwd()); |
There was a problem hiding this comment.
🔴 The path guard lets the model read the job's GitHub token in .git/config. The guard treats the whole working directory as safe and claims this protects "runner secrets". With actions/checkout's default persist-credentials: true, the job token sits inside that directory as http.(link removed) in .git/config (hardened-pr-review-run.yml:568-569already flags this as "a file the model's Read tool is allowed to open"). A prompt-injected issue body can get the model toread .git/config. The token then lands in events.jsonlandtranscript.htmlin the always-uploaded public artifact, and can reachstructured_output. The README usage example sets persist-credentials: false, but the Lockdown section doesn't list it as a requirement and nothing enforces it. Fix: have the guard block .git/config, or fail run.shwhengit config --get-regexp 'http..*.extraheader'matches. Also addpersist-credentials: false` to the Lockdown list.
| fi | ||
|
|
||
| # prompt and result-schema accept literal text or a path to a file. | ||
| text_or_file() { if [[ -f "$1" ]]; then cat "$1"; else printf '%s' "$1"; fi; } |
There was a problem hiding this comment.
🔴 prompt and result-schema read any path that passes \[\[ -f \]\] (advertised at action.yml:14 and README.md:43). action.yml never states the "trusted-caller contract", and the input description invites literal text. Failure: a later caller writes prompt: ${{ github.event.issue.body }}. A body of exactly /proc/self/environ passes -f, so the step's environment, including the AWS session credentials from configure-aws-credentials, is copied into prompt.md. From there it reaches the model and the public artifact, bypassing tool-guard.ts entirely. Once the next PRs in the stack adopt this input shape, changing it becomes a breaking change, so it is cheapest to fix now. Fix: split into prompt/prompt-file and result-schema/result-schema-file, and never infer a file read from -f.
| || echo '{}' > "$out/usage.json" | ||
|
|
||
| # Every tool declared to the model or run successfully must be in the allowlist. | ||
| declared=$(jq -r 'select(.type == "message_end" and .message.role == "system") | .message.toolsAdded[]?.name' "$events" | sort -u) |
There was a problem hiding this comment.
🔴 No test loads tool-guard.ts or submit-result.ts into the real pinned pi. The extension tests use mock ExtensionAPI objects, test_run.py uses a fake pi with a hand-written event stream, and real-tools.mjs calls the tool factories directly, bypassing the guard. So CI never checks that pi 0.99.1 accepts -e tool-guard.ts, honours {block: true} from tool_call, enforces a plain JSON Schema passed as parameters, or emits the message_end/role: "system"/toolsAdded shape the allowlist audit depends on. If that shape differs, declared is empty and the audit at run.sh:115 passes without checking anything. run.sh also never re-validates result.json against the schema. Fix: add CI steps in pi-agent-tests.yml against the lockfile install that run pi --no-extensions -e /tool-guard.ts -e /submit-result.ts --list-models, drive one guarded tool call and one schema-violating submit_result through real pi (a faux/scripted provider is enough), and record a real event stream to replace the hand-written one in test_run.py.
Reviewed the remaining automated findings and accepted them as follow-up work.
|
Starting merge as part of PR stack under #199555 |
[ghstack-poisoned]
|
Starting merge as part of PR stack under #199555 |
## Human Note ## Agent Notes Move issue triage from Claude Code to pi while keeping Sonnet 5 as the default, at medium thinking. Sol remains a manual option. The main change is the trust boundary: the model reads issues and submits a structured plan; a separate job with no model or AWS credentials applies it. The model never holds the GitHub write token. The apply step filters labels, supplies required comment templates, and adds completion labels for complete classifications. Reproduction requests redact download links using a fixed policy and the current issue body, not a model-written replacement. Transfers go to human review; automatic closes are limited to usage questions and expected numerical behavior. Reports show the comments that will actually be posted, including automatic templates and deduplication. Manual replay and dry-run support batches; apply accepts exactly one issue. The reusable read-only Bedrock workflow has blocked egress and short-lived credentials; #199588 reuses it for distributed triage. Model execution artifacts and usage metrics retain their existing formats. Job summaries remain readable Markdown; log copies are JSON-encoded to prevent workflow-command interpretation. For review, start with `issue-triage-pi.yml` and `pi-triage-plan.yml`, then `apply_plan.py` and its tests. `add_bot_triaged.py` is removed here. The two validation hooks remain for the old distributed workflow until #199588 removes their last users. The model still makes triage judgments; these controls limit its effects rather than making those judgments infallible. ## Validation - [20-issue Sonnet replay](https://github.com/pytorch/ciforge/actions/runs/37063139472): oncall routing matched the historical Claude bot on 20/20 issues. This is agreement, not ground truth. - Live ciforge testing exercised issue-opened triage, comments, restricted closing, and the distributed handoff. The handoff testing exposed a subqueue-routing gap, now covered by tests. - Effective-template reporting was checked with deterministic tests for automatic, unknown, and already-posted templates; no new live model run was needed for that reporting-only change. ## Linked issue or supporting maintainer <!-- Author has write access; fill in if an issue or maintainer applies. --> ## BC-breaking? No. ## Summary (human written only) ## Agent details (if applicable) Implementation and validation are described in Agent Notes above. Pull Request resolved: #199555 Approved by: https://github.com/izaitsevfb ghstack dependencies: #199566
## Human Note ## Agent note > AI-assisted implementation and summary. > > This adds the pi runner that the next two PRs use. The point is to make the model runtime > independent of the triage policy, so changing a Bedrock model does not mean rewriting the workflow. > This PR does not switch any workflow over yet. The same action is already running in ciforge. > > The caller picks the model, tools, skill, and optional result schema. The action installs pi from > an integrity-pinned lockfile without install scripts, loads only explicitly supplied configuration, > and enforces the tool allowlist. File tools stay inside the working directory. With a result schema, > the model must call `submit_result` with valid JSON; finishing without a result is a failure. > Provider errors also fail the action, even when pi itself exits zero. > > This is not a sandbox by itself. The caller still owns AWS credentials, GitHub permissions, and > network restrictions. The next PR uses a read-only model job with blocked egress and a separate > write job. Logs retain the Claude execution-file format so the existing inspector and usage > uploader can read them. > > For review, start with `action.yml` and `run.sh`, then the tool guard and result extension. The > large lockfile is dependency pinning, not the main logic. ## Test Plan > The action was exercised locally with a scripted provider: valid result, missing result, > provider error, unknown model, and six path/tool escape attempts. The escape attempts were blocked. > It also ran through the real Bedrock issue-triage flow in ciforge. ShellCheck passed on `run.sh`. > > The latest two-issue replay using this action and the shared workflow completed successfully: > https://github.com/pytorch/ciforge/actions/runs/37075392603 Pull Request resolved: pytorch#199566 Approved by: https://github.com/izaitsevfb
## Human Note ## Agent Notes Move issue triage from Claude Code to pi while keeping Sonnet 5 as the default, at medium thinking. Sol remains a manual option. The main change is the trust boundary: the model reads issues and submits a structured plan; a separate job with no model or AWS credentials applies it. The model never holds the GitHub write token. The apply step filters labels, supplies required comment templates, and adds completion labels for complete classifications. Reproduction requests redact download links using a fixed policy and the current issue body, not a model-written replacement. Transfers go to human review; automatic closes are limited to usage questions and expected numerical behavior. Reports show the comments that will actually be posted, including automatic templates and deduplication. Manual replay and dry-run support batches; apply accepts exactly one issue. The reusable read-only Bedrock workflow has blocked egress and short-lived credentials; pytorch#199588 reuses it for distributed triage. Model execution artifacts and usage metrics retain their existing formats. Job summaries remain readable Markdown; log copies are JSON-encoded to prevent workflow-command interpretation. For review, start with `issue-triage-pi.yml` and `pi-triage-plan.yml`, then `apply_plan.py` and its tests. `add_bot_triaged.py` is removed here. The two validation hooks remain for the old distributed workflow until pytorch#199588 removes their last users. The model still makes triage judgments; these controls limit its effects rather than making those judgments infallible. ## Validation - [20-issue Sonnet replay](https://github.com/pytorch/ciforge/actions/runs/37063139472): oncall routing matched the historical Claude bot on 20/20 issues. This is agreement, not ground truth. - Live ciforge testing exercised issue-opened triage, comments, restricted closing, and the distributed handoff. The handoff testing exposed a subqueue-routing gap, now covered by tests. - Effective-template reporting was checked with deterministic tests for automatic, unknown, and already-posted templates; no new live model run was needed for that reporting-only change. ## Linked issue or supporting maintainer <!-- Author has write access; fill in if an issue or maintainer applies. --> ## BC-breaking? No. ## Summary (human written only) ## Agent details (if applicable) Implementation and validation are described in Agent Notes above. Pull Request resolved: pytorch#199555 Approved by: https://github.com/izaitsevfb ghstack dependencies: pytorch#199566
## Human Note ## Agent note > AI-assisted implementation and summary. > > This adds the pi runner that the next two PRs use. The point is to make the model runtime > independent of the triage policy, so changing a Bedrock model does not mean rewriting the workflow. > This PR does not switch any workflow over yet. The same action is already running in ciforge. > > The caller picks the model, tools, skill, and optional result schema. The action installs pi from > an integrity-pinned lockfile without install scripts, loads only explicitly supplied configuration, > and enforces the tool allowlist. File tools stay inside the working directory. With a result schema, > the model must call `submit_result` with valid JSON; finishing without a result is a failure. > Provider errors also fail the action, even when pi itself exits zero. > > This is not a sandbox by itself. The caller still owns AWS credentials, GitHub permissions, and > network restrictions. The next PR uses a read-only model job with blocked egress and a separate > write job. Logs retain the Claude execution-file format so the existing inspector and usage > uploader can read them. > > For review, start with `action.yml` and `run.sh`, then the tool guard and result extension. The > large lockfile is dependency pinning, not the main logic. ## Test Plan > The action was exercised locally with a scripted provider: valid result, missing result, > provider error, unknown model, and six path/tool escape attempts. The escape attempts were blocked. > It also ran through the real Bedrock issue-triage flow in ciforge. ShellCheck passed on `run.sh`. > > The latest two-issue replay using this action and the shared workflow completed successfully: > https://github.com/pytorch/ciforge/actions/runs/37075392603 Pull Request resolved: pytorch#199566 Approved by: https://github.com/izaitsevfb
## Human Note ## Agent Notes Move issue triage from Claude Code to pi while keeping Sonnet 5 as the default, at medium thinking. Sol remains a manual option. The main change is the trust boundary: the model reads issues and submits a structured plan; a separate job with no model or AWS credentials applies it. The model never holds the GitHub write token. The apply step filters labels, supplies required comment templates, and adds completion labels for complete classifications. Reproduction requests redact download links using a fixed policy and the current issue body, not a model-written replacement. Transfers go to human review; automatic closes are limited to usage questions and expected numerical behavior. Reports show the comments that will actually be posted, including automatic templates and deduplication. Manual replay and dry-run support batches; apply accepts exactly one issue. The reusable read-only Bedrock workflow has blocked egress and short-lived credentials; pytorch#199588 reuses it for distributed triage. Model execution artifacts and usage metrics retain their existing formats. Job summaries remain readable Markdown; log copies are JSON-encoded to prevent workflow-command interpretation. For review, start with `issue-triage-pi.yml` and `pi-triage-plan.yml`, then `apply_plan.py` and its tests. `add_bot_triaged.py` is removed here. The two validation hooks remain for the old distributed workflow until pytorch#199588 removes their last users. The model still makes triage judgments; these controls limit its effects rather than making those judgments infallible. ## Validation - [20-issue Sonnet replay](https://github.com/pytorch/ciforge/actions/runs/37063139472): oncall routing matched the historical Claude bot on 20/20 issues. This is agreement, not ground truth. - Live ciforge testing exercised issue-opened triage, comments, restricted closing, and the distributed handoff. The handoff testing exposed a subqueue-routing gap, now covered by tests. - Effective-template reporting was checked with deterministic tests for automatic, unknown, and already-posted templates; no new live model run was needed for that reporting-only change. ## Linked issue or supporting maintainer <!-- Author has write access; fill in if an issue or maintainer applies. --> ## BC-breaking? No. ## Summary (human written only) ## Agent details (if applicable) Implementation and validation are described in Agent Notes above. Pull Request resolved: pytorch#199555 Approved by: https://github.com/izaitsevfb ghstack dependencies: pytorch#199566
Stack from ghstack (oldest at bottom):
Human Note
Agent note
Test Plan
cc @albanD