Skip to content

Port distributed triage to the pi harness - #199588

Closed
drisspg wants to merge 27 commits into
gh/drisspg/436/basefrom
gh/drisspg/436/head
Closed

drisspg wants to merge 27 commits into
gh/drisspg/436/basefrom
gh/drisspg/436/head

Conversation

@drisspg

@drisspg drisspg commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Human Note

Agent note

AI-assisted implementation and summary.

This finishes the triage migration by moving the distributed second pass to pi. It uses the same
read-only plan job as issue triage, not a second copy of the model/security setup. Both the normal
handoff and the daily sweep reach the new workflow.

The distributed apply step owns the narrower policy: only distributed labels, no new sub-queue
when one already exists, known comment templates, and no closing issues or removing labels.
A classification whose module label gets filtered out goes to triage review rather than being
marked done. Confident infra and checkpointing routes ask for triaged.

The distributed completion marker is ptd-bot-triaged. It must be separate from bot-triaged,
which the first pass already adds before the handoff. Sharing that marker made the sweep treat
issues as processed before distributed triage had run. Successful no-op routes now get the
distributed marker too; high-priority decisions do not, so the sweep can surface them again.

The daily manifest, usage metrics, and execution-log upload stay in place. Existing comment
footers are preserved so retries recognize responses posted by the old bot instead of duplicating
them. This also removes the remaining triage hook scripts, now that neither triage flow uses them.

For review, focus on apply_distributed_plan.py and its tests, then the workflow handoff and the
cron's marker checks. The model job itself comes from the previous PR.

Test Plan

python3 -m unittest discover -s scripts/issue_triage_pi

All 40 unit/contract tests passed on the full stack, along with actionlint and Python
formatting/lint checks. Coverage includes invalid-module classification, existing sub-queues,
marker behavior, template deduplication, and the shared model job's lockdown.

Six distributed issues copied into ciforge went through issue-opened triage, handoff, and the
second pass. All six matched the originals' sub-oncall; module labels matched on the three
parallelisms cases. A dry run reported effects without writing.

After the marker/shared-workflow changes, two more live copies completed the full chain:
ciforge#682 got distributed infra, triaged, and ptd-bot-triaged; ciforge#683 got parallelisms,
module: dtensor, triaged, and ptd-bot-triaged. These validate the flow, not general model accuracy.

cc @albanD

[ghstack-poisoned]
@drisspg
drisspg requested review from a team, albanD and malfet as code owners October 2, 2026 22:35
@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

🟡 AUTOMATED REVIEW - OUTDATED (earlier commit) - Changes requested:

This PR moves the second distributed-triage pass onto the pi plan/apply split:
it adds apply_distributed_plan.py and distributed-triage-pi.yml, switches the
completion marker to `ptd-bot-triaged`, and deletes the Claude Code workflow and
its hooks. Recommendation: Request Changes. Both of izaitsevfb's comments are
addressed, but once merged the daily cron will act on live issues with two
unresolved problems: high-priority issues get re-run every day and can block the
sweep, and the old bot's backlog gets relabeled and re-triaged after the fact
with no backfill or acknowledgement.

Findings (7):

[major] .github/workflows/claude-distributed-triage-cron.yml:163
High-priority issues are sent back to the model every day, and they can block
the sweep. A `high_priority` result gets neither `ptd-bot-triaged` nor `triaged`
(apply_distributed_plan.py:145), and the Phase 2 jq excludes only those two
labels. So each such issue costs a model run every day until a human adds
`triaged`. Each re-run can only re-add `triage review`, which the issue already
has, and nobody is notified, so "re-surfacing" it (SKILL.md 5) achieves nothing.
This is new: before, the first pass's `bot-triaged` kept these issues out of
Phase 2. Phase 2 also takes `sort | .[:BATCH_SIZE]`, so once 20 lower-numbered
high-priority issues are pending they fill every batch, and newer issues whose
handoff failed are never swept. Fix: exclude `triage review` (and `needs
reproduction`) in the Phase 2 jq, as Phase 1 does at lines 84-87, or give
high-priority issues their own marker. Then update SKILL.md 5 to match.

[major] .github/workflows/claude-distributed-triage-cron.yml:84
Renaming the marker re-processes the old bot's whole open backlog. Every issue
the old distributed bot handled has `bot-triaged`, but no open issue has
`ptd-bot-triaged` yet. On its first run, Phase 1 (`--limit 1000`, no batching)
adds `ptd-bot-triaged` + `triaged` to every open distributed issue that has a
module label and a sub-oncall label but none of `triaged`, `triage review` or
`needs reproduction`. That includes the old bot's infra and checkpointing
routes, which used to stop at `bot-triaged`. Phase 2 (line 163) then re-triages
every open distributed issue without `triaged`, 20 a day, and applies the new
policy to them after the fact, including outcomes the old bot already marked
`triage review` or `needs reproduction`. The PR description does not mention
this. Before the cron runs, either backfill `ptd-bot-triaged` on the issues the
old bot processed, or state how many open issues will be relabeled or re-run and
confirm that is intended.

[minor] scripts/issue_triage_pi/apply_distributed_plan.py:97
A `not_distributed` plan can still add sub-oncall and module labels. For
example, `effects("not_distributed", ["oncall: distributed infra"])` adds
`oncall: distributed infra`, `triage review` and the marker, and posts the "not
distributed" comment. The issue ends up routed to a distributed sub-team while
the bot tells the reporter it is not a distributed issue. Fix: for
`not_distributed`, drop sub-queue and `module:` labels from the plan, and add a
test for that plan.

[minor] .github/workflows/distributed-triage-pi.yml:104
`gh api` failures are silently treated as success. These steps use the default
`bash -e` shell with no `pipefail`. Here, if `gh api .../labels` fails, the
negated `grep` is true, so the job prints "not labeled oncall: distributed;
nothing to do" and exits 0. The handoff is lost and nothing shows as failed. The
same problem is at line 218 (see the separate finding). The artifact lookup in
this job was hardened against exactly this
(`HandoffLookupTest.test_api_failure_is_not_an_absent_handoff`). Fix: capture
the `gh api` output in a variable first, so `-e` fails the step, then test it.

(3 more not shown, see the review run)

Reviewed commit: 1f59378 (NOT the current head 6cbb950)

Review run

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199588

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 6cbb950 with merge base 2ca0da8 (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Trust boundaries and permissions
    • New .github/workflows/distributed-triage-pi.yml grants issues: write to apply and id-token: write with the gha_workflow_claude_code OIDC role to record
    • Deletes validate_issue_target.py and validate_labels.py, the PreToolUse guards that restricted issue mutations to the triage target
  • New production logic
    • Adds scripts/issue_triage_pi/apply_distributed_plan.py, a 200-line policy engine deciding which labels and comments a model plan may write
    • Rewrites claude-distributed-triage-cron.yml Phase 1 skip and finalize conditions and renames the marker to ptd-bot-triaged
  • Scope and socialization
    • Replaces claude-distributed-triage.yml and changes label semantics the distributed oncall relies on, across workflows, skill docs, and CODEOWNERS
    • PR metadata shows a maintainer requested changes and Lint / pr-sanity-checks failing on the 1500 LOC limit

reason: not_trivial
Reviewed commit: 9ad2136 (NOT the current head 6cbb950)

Inference job

🐛 Report a wrong verdict

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the release notes: releng release notes category label Oct 2, 2026
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T22:40:55.549469Z df4f500 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df4f500199

ℹ️ 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".

effects.notes.append(
f"dropped labels outside distributed-labels.json {unknown}"
)
labels = [label for label in dict.fromkeys(requested) if label in valid_labels]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escalate classifications whose module labels are filtered

Because the result schema accepts arbitrary label strings, a schema-valid model plan such as decision: "classify" with labels: ["module: typo", "triaged"] drops the unknown module here but preserves triaged; the later marker logic then also adds bot-triaged. The issue is silently finalized and excluded from future sweeps despite having neither a valid module nor a sub-queue, so filtering that invalidates a classification should instead suppress triaged and add triage review.

Useful? React with 👍 / 👎.

effects.add_labels = [label for label in labels if label not in existing_labels]
if (
decision not in NO_MARKER_DECISIONS
and (effects.mutates or posted)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mark successful no-op routes as bot-triaged

For a backlog issue that already has oncall: distributed infra or oncall: distributed checkpointing but lacks bot-triaged, the revised skill instructs the model to submit decision: "route" with no new sub-queue and stop. Since that valid plan has no other mutation or template, this condition omits the marker; main() still exits successfully with outcome routed, while Phase 2 of .github/workflows/claude-distributed-triage-cron.yml selects the same unmarked issue again on every sweep.

Useful? React with 👍 / 👎.

key
for key in keys
if key in templates
and any(templates[key]["comment"] in body for body in bot_comments)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize comments from the previous template version

On a retry or manual re-dispatch of an issue commented on by the removed Claude workflow, this exact-body substring check does not recognize the existing template: this commit changes both template footers from PTD's claude triage bot to PTD's triage bot. Requesting either template therefore posts the same substantive response again, contrary to the migration's no-repeat behavior; deduplication needs a stable marker/key or explicit recognition of the previous template version.

Useful? React with 👍 / 👎.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 2, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above


ghstack-source-id: d1a8892
Pull-Request: #199588
[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 4, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: 081a8a9
Pull-Request: #199588
[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 5, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: e2b30d6
Pull-Request: #199588
[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 5, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: 46b1ced
Pull-Request: #199588
[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 6, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: 95f7e6a
Pull-Request: #199588
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 16, 2026
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
@drisspg
drisspg requested a review from izaitsevfb October 23, 2026 14:41
drisspg added a commit that referenced this pull request Oct 23, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: a5d8fbb
Pull-Request: #199588
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 26, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: 023bdc1
Pull-Request: #199588
[ghstack-poisoned]
drisspg added a commit that referenced this pull request Oct 30, 2026
Moves second-level triage of `oncall: distributed` issues from Claude Code to
pi, the same way the previous PR moved issue triage. With this, no skill or
workflow in the repo depends on Claude Code hooks.

## What changes

- `claude-distributed-triage.yml` is replaced by `distributed-triage-pi.yml`,
  triggered by the issue-triage hand-off and by dispatch from the daily sweep
  (`claude-distributed-triage-cron.yml`, which now dispatches the new workflow).
- plan: the shared `pi-triage-plan.yml` (bedrock, `issues: read`, egress
  blocked, read-only `gh` tools, no shell) runs the `distributed-triage` skill
  and submits a schema-validated plan.
- apply (`issues: write`, no AWS, no model): `apply_distributed_plan.py` adds
  only labels from `distributed-labels.json`, keeps at most one sub-oncall
  label (an existing one is never replaced; two requested go to
  `triage review`), never pairs `triaged` with `triage review` or
  `needs reproduction` (and sends a `classify` with no allowlisted module to
  `triage review`), posts only the skill's templates without repeats, and
  never closes or removes anything.
- The distributed bot's own marker is `ptd-bot-triaged` again (the old skill's
  marker), added on every processed issue except high priority. Issue triage
  already adds `bot-triaged` before the hand-off, so with a shared marker the
  daily sweep never retried a failed run or re-surfaced a high-priority issue.
  The sweep now checks `ptd-bot-triaged`.
- record (bedrock, no model): appends the result to the daily manifest, as
  before. Usage metrics and the execution log
  (`review-logs/distributed-triage/<issue>.json`) are uploaded as for issue
  triage.
- The skill drops its Claude hooks and MCP tool table and describes the plan.
  Confident infra and checkpointing routes ask for `triaged`, as the skill's
  DO list already said. The hook scripts in
  `.agents/skills/triaging-issues/scripts/` have no users left and are deleted
  (the apply step's rules are in `scripts/issue_triage_pi/labels.py`).
- The workflow contract test now covers both triage workflows.

## Evidence

pytorch/ciforge runs the same files. Six `oncall: distributed` issues copied
from pytorch (#199028, #198880, #198427, #198344, #198140, #197875) went
through the full flow there (opened, issue triage, hand-off, distributed
triage, apply). All six got the same sub-oncall as the originals, and module
labels matched on all three parallelisms issues. #199028 (security report on
DCP) now reaches `oncall: distributed checkpointing` through the parent queue,
which issue triage previously skipped. A dry-run dispatch reported effects
without writing.

## Test plan

- `python3 -m unittest discover -s scripts/issue_triage_pi` (distributed and
  issue plan-to-effects rules, and the lockdown contract for both workflows)
- actionlint, GHA, PYFMT, ruff, and flake8 on the changed files
- End-to-end runs in pytorch/ciforge described above

ghstack-source-id: 00fa1e2
Pull-Request: #199588
@drisspg

drisspg commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 30, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / win-vs2022-cpu-py3 / build

Details for Dev Infra team

Raised by workflow job

@drisspg

drisspg commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
## Human Note

## Agent note

> AI-assisted implementation and summary.
>
> This finishes the triage migration by moving the distributed second pass to pi. It uses the same
> read-only plan job as issue triage, not a second copy of the model/security setup. Both the normal
> handoff and the daily sweep reach the new workflow.
>
> The distributed apply step owns the narrower policy: only distributed labels, no new sub-queue
> when one already exists, known comment templates, and no closing issues or removing labels.
> A classification whose module label gets filtered out goes to `triage review` rather than being
> marked done. Confident infra and checkpointing routes ask for `triaged`.
>
> The distributed completion marker is `ptd-bot-triaged`. It must be separate from `bot-triaged`,
> which the first pass already adds before the handoff. Sharing that marker made the sweep treat
> issues as processed before distributed triage had run. Successful no-op routes now get the
> distributed marker too; high-priority decisions do not, so the sweep can surface them again.
>
> The daily manifest, usage metrics, and execution-log upload stay in place. Existing comment
> footers are preserved so retries recognize responses posted by the old bot instead of duplicating
> them. This also removes the remaining triage hook scripts, now that neither triage flow uses them.
>
> For review, focus on `apply_distributed_plan.py` and its tests, then the workflow handoff and the
> cron's marker checks. The model job itself comes from the previous PR.

## Test Plan

> ```bash
> python3 -m unittest discover -s scripts/issue_triage_pi
> ```
>
> All 40 unit/contract tests passed on the full stack, along with actionlint and Python
> formatting/lint checks. Coverage includes invalid-module classification, existing sub-queues,
> marker behavior, template deduplication, and the shared model job's lockdown.
>
> Six distributed issues copied into ciforge went through issue-opened triage, handoff, and the
> second pass. All six matched the originals' sub-oncall; module labels matched on the three
> parallelisms cases. A dry run reported effects without writing.
>
> After the marker/shared-workflow changes, two more live copies completed the full chain:
> ciforge#682 got distributed infra, `triaged`, and `ptd-bot-triaged`; ciforge#683 got parallelisms,
> `module: dtensor`, `triaged`, and `ptd-bot-triaged`. These validate the flow, not general model accuracy.

Pull Request resolved: pytorch#199588
Approved by: https://github.com/izaitsevfb
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
## Human Note

## Agent note

> AI-assisted implementation and summary.
>
> This finishes the triage migration by moving the distributed second pass to pi. It uses the same
> read-only plan job as issue triage, not a second copy of the model/security setup. Both the normal
> handoff and the daily sweep reach the new workflow.
>
> The distributed apply step owns the narrower policy: only distributed labels, no new sub-queue
> when one already exists, known comment templates, and no closing issues or removing labels.
> A classification whose module label gets filtered out goes to `triage review` rather than being
> marked done. Confident infra and checkpointing routes ask for `triaged`.
>
> The distributed completion marker is `ptd-bot-triaged`. It must be separate from `bot-triaged`,
> which the first pass already adds before the handoff. Sharing that marker made the sweep treat
> issues as processed before distributed triage had run. Successful no-op routes now get the
> distributed marker too; high-priority decisions do not, so the sweep can surface them again.
>
> The daily manifest, usage metrics, and execution-log upload stay in place. Existing comment
> footers are preserved so retries recognize responses posted by the old bot instead of duplicating
> them. This also removes the remaining triage hook scripts, now that neither triage flow uses them.
>
> For review, focus on `apply_distributed_plan.py` and its tests, then the workflow handoff and the
> cron's marker checks. The model job itself comes from the previous PR.

## Test Plan

> ```bash
> python3 -m unittest discover -s scripts/issue_triage_pi
> ```
>
> All 40 unit/contract tests passed on the full stack, along with actionlint and Python
> formatting/lint checks. Coverage includes invalid-module classification, existing sub-queues,
> marker behavior, template deduplication, and the shared model job's lockdown.
>
> Six distributed issues copied into ciforge went through issue-opened triage, handoff, and the
> second pass. All six matched the originals' sub-oncall; module labels matched on the three
> parallelisms cases. A dry run reported effects without writing.
>
> After the marker/shared-workflow changes, two more live copies completed the full chain:
> ciforge#682 got distributed infra, `triaged`, and `ptd-bot-triaged`; ciforge#683 got parallelisms,
> `module: dtensor`, `triaged`, and `ptd-bot-triaged`. These validate the flow, not general model accuracy.

Pull Request resolved: pytorch#199588
Approved by: https://github.com/izaitsevfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request GL/superseded GreenLight review is superseded by changes Merged no automated review Request skipping the automated PR review process ready for review Automated review passed, ready for a final review by a maintainer. release notes: releng release notes category skip-pr-sanity-checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants