Skip to content

[CI][CRCR] Update mergebot rule to adapt CRCR L3 - #185612

Closed
KarhouTam wants to merge 4 commits into
pytorch:mainfrom
KarhouTam:crcr-mergebot
Closed

KarhouTam wants to merge 4 commits into
pytorch:mainfrom
KarhouTam:crcr-mergebot

Conversation

@KarhouTam

@KarhouTam KarhouTam commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Update mergebot (trymerge.py) to recognize CRCR L3 out-of-tree CI failures as non-blocking, preventing them from halting merges.

Depends on the Dr.CI + CRCR infrastructure in pytorch/test-infra#8183.

Changes

New classification function: is_crcr_l3

Mirrors the existing is_flaky / is_broken_trunk / is_unstable pattern. Consults the CRCR_L3 category returned by the Dr.CI API and matches on the standard name and id fields of the RecentWorkflowsData schema.

Classification in get_classifications

When a check matches the CRCR_L3 category from Dr.CI, it is classified as "CRCR_L3" and excluded from the unclassified failures pool.

Non-blocking categorization in categorize_checks

CRCR_L3 is added to the list of non-blocking classifications (alongside BROKEN_TRUNK, FLAKY, UNSTABLE). CRCR_L3 failures are intentionally excluded from the flaky_or_broken_trunk threshold logic — L3 failures are definitionally non-blocking regardless of count.

Data Flow

CRCR check run completes (oot_workflow_job)
    ↓
Dr.CI fetches from ClickHouse oot_workflow_job
    ↓
Dr.CI classifies: L3 → CRCR_L3, L4 → FAILED
    ↓
Dr.CI API returns {"CRCR_L3": [...], "FAILED": [...]}
    ↓
trymerge.py reads Dr.CI API response
    ├── CRCR_L3 → non-blocking (treated like FLAKY/BROKEN_TRUNK)
    └── FAILED → blocking (L4 failures land here, naturally stopping merge)

Design Notes

  • L4 failures stay blocking: Dr.CI merges L4 failures into failedJobs, not CRCR_L3. They flow through the normal failure path in trymerge.py and block the merge. No extra L4-specific logic is needed on this side.
  • The classification authority is Dr.CI: trymerge.py does not query the allowlist or check GitHub check run names itself. It trusts the CRCR_L3 category from Dr.CI.
  • Errors fail closed: If Dr.CI is unreachable or returns no classifications, checks remain unclassified and block the merge. This is the same behavior as the other classification categories.

cc @malfet @pytorch/pytorch-dev-infra

@pytorch-bot

pytorch-bot Bot commented May 29, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (4 Unrelated Failures)

As of commit b143677 with merge base e3f5bf0 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label May 29, 2026
atalman pushed a commit to pytorch/test-infra that referenced this pull request Jul 7, 2026
…8119)

# Summary

- The current implementation focuses on L3/L4 levels defined in the RFC:
pytorch/rfcs#90
- For detailed design for L3/L4, please refer to
pytorch/rfcs#93

# Architecture

- `webhook` function:
- [x] Create PR label handling function for L3 repo (refer to the 3
scenario cases mentioned in pytorch/rfcs#93)
- **Scenario 1**: Label arrives before the downstream workflow job is
triggered. So we cached this information in Redis using
`mark_check_run_wanted` and let the `callback` lambda create this check
run.
- **Scenario 2**: Label arrives during the downstream workflow job is
running. The `callback` lambda will cache workflow information
beforehand so it can immediately create the `in_progress` check run.
- **Scenario 3**: Label arrives after the downstream workflow job is
done. If the cached workflow information is still alive in Redis (3 days
by default, could be set by `CRCR_STATUS_TTL`), it will create a
`completed` check run immediately. Otherwise, it will not create a check
run.
- [x] Dispatch function will check for L3 label or L4, and store this
information in Redis for the `callback` to check whether a check run is
needed.
- [x] Create check run and check suite handling functions for the
downstream workflow jobs re-run mechanism within the check run.
- `callback` function:
  - [x] Handle upstream check-run creation/update for L3/L4
- **Scenario 1 & L4**: Check in Redis by calling `is_check_run_wanted`
to see if this PR needs a check run. If so, immediately create one.
- **All Scenarios**: Store workflow information in Redis for check run
creation in the `webhook`.
- [x] Set "in_progress" zombie check-runs to "time_out" through a
sweeper periodically

# Changes
```md
.github/actions/cross-repo-ci-relay
└── action.yml                     # Add a step to capture job-name for re-run
aws/lambda/cross_repo_ci_relay/
├── tests/                         # Add more unit tests
├── allowlist.py                   # Update utils function for L3
├── redis_helper.py                # Set more keys for L3
├── gh_helper.py                   # Update utils function for L3
├── misc.py                        # Update utils function for L3
├── event_handler.py               # Create PR label/check run/check suites handling function
├── cleanup_handler.py             # Handle zombie check-run
└── callback_handler.py            # Handle upstream check-run creation
```

# Verification

We performed the following scenario verification on our AWS Lambda
instance:

- L3:
- [x] L3 labels named `ciflow/crcr/{device}` are added immediately after
the PR is created, and show up in the corresponding check-run on the PR
with the name `crcr/{repo}/{workflow_name}/{job_name}`.
- [x] After clicking into the check-run, the corresponding information
is correct.
- [x] L3 labels are added while the workflow job is running, which
should show up the `in_progress` check-run.
- [x] L3 labels are added after the workflow job is done, which should
show up the `completed` check-run.
- [x] Check run is updated when the PR with L3 labels is reopened or
synchronized.
 
- L4:
  - [x] Check run should be created after the PR is opened.
  - [x] Check run is updated when the PR is reopened or synchronized.

- Re-run
- [x] Clicking the `Re-run` button in each failed check run will trigger
the corresponding downstream workflow failed jobs to re-run and update
the check run status to `in_progress`.
- [x] Clicking the `Re-run all jobs` or `Re-run all failed jobs` button
will trigger the corresponding downstream workflow jobs in the check
suite and update the corresponding check run status to `in_progress`.

# Unit Tests

- [x] Unit Tests (Mock)

# TODO

- Modify PyTorchBot for L3 non-blocking merge:
pytorch/pytorch#185612
- Add a new feature in PyTorchBot that automatically mentions related
on-call maintainers in L3/L4 repos when check-run fails:
#8183


cc @albanD @fffrog @KarhouTam @atalman @huydhn @zxiiro @subinz1
@jewelkm89
@KarhouTam KarhouTam changed the title [WIP][CI][CRCR] Update mergebot rule to adapt CRCR L3 [CI][CRCR] Update mergebot rule to adapt CRCR L3 Jul 9, 2026
@KarhouTam KarhouTam added the module: ci Related to continuous integration label Jul 9, 2026
@KarhouTam
KarhouTam marked this pull request as ready for review July 9, 2026 11:40
@KarhouTam
KarhouTam requested a review from a team as a code owner July 9, 2026 11:40
@jbschlosser jbschlosser added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 10, 2026
@jbschlosser
jbschlosser requested a review from fffrog July 10, 2026 17:25
@huydhn

huydhn commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Could you add a couple of tests for this in test_trymerge.py? Just FYI there is a mock mechanism there, i.e. https://github.com/pytorch/pytorch/blob/main/.github/scripts/gql_mocks.json.gz to support write test for mergebot

@huydhn

huydhn commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@claude Review this change, check if we need to update anything on https://github.com/pytorch/test-infra like dr.ci to support the new OUT_OF_TREE category

@claude

claude Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Claude finished @huydhn's task in 2m 54s —— View job


This change is correct and consistent with the existing FLAKY/BROKEN_TRUNK pattern, but it is missing the tests @huydhn asked for, and it is fully dependent on Dr.CI (test-infra) emitting the new OUT_OF_TREE category — so yes, test-infra needs the matching change (that's test-infra#8183).

Full review

PR Review: #185612

Summary

Adds an OUT_OF_TREE classification so CRCR L3 out-of-tree CI failures are treated as non-blocking in the mergebot. The trymerge.py logic is sound and mirrors the existing patterns; the main gaps are missing tests and a couple of small consistency issues.

Testing

  • No tests added. @huydhn explicitly asked for tests, and the skill guidance treats new functionality without tests as blocking. test_trymerge.py already has the exact harness you need:
    • Add a PR fixture whose Dr.CI response (.github/scripts/drci_mocks.json.gz) contains an OUT_OF_TREE entry, following mocked_drci_classifications (test_trymerge.py:119).
    • Mirror test_get_classifications (test_trymerge.py:641): assert the check gets classification == "OUT_OF_TREE", and that categorize_checks returns it under ignorable["OUT_OF_TREE"] with len(failed) == 0.
    • Add a regression assertion that OUT_OF_TREE failures do not count toward the ok_failed_checks_threshold (set threshold to 0 and confirm the merge still passes) — this is the key behavioral claim in the PR description and is untested.

Code Quality / Observability

  • OUT_OF_TREE is not persisted to the S3 merge record. save_merge_record (trymerge.py:1306) receives broken_trunk_checks, flaky_checks, and unstable_checks from ignorable_checks, but nothing pulls ignorable_checks.get("OUT_OF_TREE", []). Since these failures are now silently ignored at merge time, not recording them anywhere hurts post-hoc debugging of "why did this merge with a red check". Consider threading an out_of_tree_checks field through save_merge_record (and the is_failed path at trymerge.py:2654) for parity with the other ignorable categories.
  • Docstring may over-specify the naming contract. is_out_of_tree_l3 (trymerge.py:1914) states L3 check runs are named crcr/<repo>/<workflow>. The function itself (correctly) does not rely on any name pattern — it trusts Dr.CI's OUT_OF_TREE list by name/id, exactly like is_flaky. If the naming convention drifts, this comment becomes misleading. Recommend dropping the specific name format from the docstring and just describing the Dr.CI-authority contract, matching the terser docstrings on is_flaky/is_broken_trunk.

Correctness (verified, no change needed)

  • categorize_checks (trymerge.py:2331-2347): OUT_OF_TREE is added to the ignorable set and intentionally excluded from flaky_or_broken_trunk, so it never contributes to the threshold. This matches the stated design ("L3 failures are definitionally non-blocking regardless of count").
  • Classification order in get_classifications (trymerge.py:2032) places OUT_OF_TREE after unstable/broken-trunk/flaky/invalid-cancel; a check that also matches one of those keeps the earlier label. That's harmless since all are ignorable.
  • Fail-closed behavior holds: if Dr.CI returns nothing, is_out_of_tree_l3 returns False and the check blocks, same as the other categories.

Recommendation

Request Changes — solely because the requested tests are missing. The implementation itself is ready.


Does test-infra / Dr.CI need updating?

Yes — this PR does not work on its own. trymerge.py is a pure consumer here: is_out_of_tree_l3 reads drci_classifications.get("OUT_OF_TREE", []) and matches each entry's name / id. If Dr.CI never emits that key, the function always returns False and CRCR L3 failures would block merges. That producer-side change is exactly what test-infra#8183 provides, and the PR body correctly lists it as a dependency.

Concretely, on the test-infra side you should confirm:

  1. Dr.CI API shape — the drci endpoint (hud.pytorch.org/api/drci/drci, consumed by get_drci_classifications at trymerge.py:1801) returns a top-level OUT_OF_TREE array whose objects carry both name and id fields. trymerge matches on oot["name"] and oot["id"] (trymerge.py:1928-1931), identical to the FLAKY/BROKEN_TRUNK schema, so anything less will silently fail to match.
  2. L4 stays in FAILED — the design note relies on L4 failures landing in Dr.CI's failedJobs/FAILED, not OUT_OF_TREE. Worth an explicit test/assertion on the Dr.CI side so an L4 accelerator can never be misclassified as non-blocking.
  3. HUD / Dr.CI PR-comment rendering — the Dr.CI comment and HUD group failures by category. A brand-new OUT_OF_TREE category should be rendered somewhere (its own non-blocking section) so devs can see these ignored checks; otherwise they'll be invisible on the PR. Check the frontend classification-grouping code handles the new key rather than dropping it.

So: the trymerge side is complete once tests land, but merging this before the Dr.CI producer + HUD-rendering changes are live is a no-op at best. I'd gate this PR on test-infra#8183 being merged/deployed.

@KarhouTam

Copy link
Copy Markdown
Collaborator Author

Hi @huydhn, I have added the tests and updated the mock data according to your suggestions. Thank you for the feedback! Please take another look when you have a chance.

Comment thread .github/scripts/trymerge.py Resolved
@atalman

atalman commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Suggest renaming the category CRCR_NON_BLOCKING → CRCR_L3

I'd prefer we key off a single classification axis (L1–L4) rather than introducing a parallel blocking/non-blocking vocabulary. The blocking behavior is a property of the level, not a second classification — having both invites the two to drift. CRCR_L3 is also more concise and matches the terminology already used in the allowlist and downstream_repo_level.

Note: this category string is a cross-repo contract with pytorch/test-infra#8183 (drci.ts emits it, trymerge.py reads it), so the rename has to land in lockstep across both PRs — a mismatch silently makes L3 failures fall through to blocking.

Must change in this PR

  • trymerge.py — drci_classifications.get("CRCR_L3", [])
  • trymerge.py — the JobCheckState(... "CRCR_L3" ...) assignment
  • trymerge.py — "CRCR_L3" in the non-blocking tuple in categorize_checks
  • test_trymerge.py — the three CRCR_NON_BLOCKING assertions
  • ⚠️ drci_mocks.json.gz — this binary fixture encodes the category key, so it needs to be regenerated with CRCR_L3 or test_get_classifications_crcr_non_blocking will break. Easy to miss since it isn't greppable.

Also in pytorch/test-infra#8183 (lockstep)

  • drci.ts — failures[pr_info.pr_number].CRCR_L3 = ... (the emit side)

While here (cosmetic, for consistency)

  • Rename the classifier is_crcr_non_blocking → is_crcr_l3 (and its call site).
  • Fix the docstring: check runs are named crcr/<owner>/<repo>/<workflow> (four segments), not crcr/<repo>/<workflow> — matches how fetchOotWorkflows/downstreamRepoFromCheckRunName build/parse them in [ONNX] Fix type_as symbolic #8183.

The human-facing Dr.CI comment text ("... failed but is non-blocking") is fine to keep as-is — that's prose explaining what L3 means to a reader, not a classification key, so it doesn't duplicate the taxonomy.

@can-gaa-hou can-gaa-hou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM overall! Thanks for the PR.

[],
)
oot_check = (
"inductor / cuda11.8-py3.10-gcc7-sm86"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the real case, the check name should start with crcr for the CRCR_L3 category. But it is fine to test with different names here since we classify the check runs in test-infra.

@subinz1 subinz1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@KarhouTam
KarhouTam requested a review from atalman July 14, 2026 08:24

@atalman atalman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@atalman

atalman commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

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

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 0 checks:

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

@KarhouTam KarhouTam self-assigned this Jul 14, 2026
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
## Summary

Update mergebot (`trymerge.py`) to recognize CRCR L3 out-of-tree CI failures as non-blocking, preventing them from halting merges.

Depends on the Dr.CI + CRCR infrastructure in [pytorch/test-infra#8183](pytorch/test-infra#8183).

## Changes

### New classification function: `is_crcr_l3`

Mirrors the existing `is_flaky` / `is_broken_trunk` / `is_unstable` pattern. Consults the `CRCR_L3` category returned by the Dr.CI API and matches on the standard `name` and `id` fields of the `RecentWorkflowsData` schema.

### Classification in `get_classifications`

When a check matches the `CRCR_L3` category from Dr.CI, it is classified as `"CRCR_L3"` and excluded from the unclassified failures pool.

### Non-blocking categorization in `categorize_checks`

`CRCR_L3` is added to the list of non-blocking classifications (alongside `BROKEN_TRUNK`, `FLAKY`, `UNSTABLE`). CRCR_L3 failures are intentionally excluded from the `flaky_or_broken_trunk` threshold logic — L3 failures are definitionally non-blocking regardless of count.

## Data Flow

```
CRCR check run completes (oot_workflow_job)
    ↓
Dr.CI fetches from ClickHouse oot_workflow_job
    ↓
Dr.CI classifies: L3 → CRCR_L3, L4 → FAILED
    ↓
Dr.CI API returns {"CRCR_L3": [...], "FAILED": [...]}
    ↓
trymerge.py reads Dr.CI API response
    ├── CRCR_L3 → non-blocking (treated like FLAKY/BROKEN_TRUNK)
    └── FAILED → blocking (L4 failures land here, naturally stopping merge)
```

## Design Notes

- **L4 failures stay blocking**: Dr.CI merges L4 failures into `failedJobs`, not `CRCR_L3`. They flow through the normal failure path in trymerge.py and block the merge. No extra L4-specific logic is needed on this side.
- **The classification authority is Dr.CI**: trymerge.py does not query the allowlist or check GitHub check run names itself. It trusts the `CRCR_L3` category from Dr.CI.
- **Errors fail closed**: If Dr.CI is unreachable or returns no classifications, checks remain unclassified and block the merge. This is the same behavior as the other classification categories.

Pull Request resolved: pytorch#185612
Approved by: https://github.com/can-gaa-hou, https://github.com/subinz1, https://github.com/atalman
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
## Summary

Update mergebot (`trymerge.py`) to recognize CRCR L3 out-of-tree CI failures as non-blocking, preventing them from halting merges.

Depends on the Dr.CI + CRCR infrastructure in [pytorch/test-infra#8183](pytorch/test-infra#8183).

## Changes

### New classification function: `is_crcr_l3`

Mirrors the existing `is_flaky` / `is_broken_trunk` / `is_unstable` pattern. Consults the `CRCR_L3` category returned by the Dr.CI API and matches on the standard `name` and `id` fields of the `RecentWorkflowsData` schema.

### Classification in `get_classifications`

When a check matches the `CRCR_L3` category from Dr.CI, it is classified as `"CRCR_L3"` and excluded from the unclassified failures pool.

### Non-blocking categorization in `categorize_checks`

`CRCR_L3` is added to the list of non-blocking classifications (alongside `BROKEN_TRUNK`, `FLAKY`, `UNSTABLE`). CRCR_L3 failures are intentionally excluded from the `flaky_or_broken_trunk` threshold logic — L3 failures are definitionally non-blocking regardless of count.

## Data Flow

```
CRCR check run completes (oot_workflow_job)
    ↓
Dr.CI fetches from ClickHouse oot_workflow_job
    ↓
Dr.CI classifies: L3 → CRCR_L3, L4 → FAILED
    ↓
Dr.CI API returns {"CRCR_L3": [...], "FAILED": [...]}
    ↓
trymerge.py reads Dr.CI API response
    ├── CRCR_L3 → non-blocking (treated like FLAKY/BROKEN_TRUNK)
    └── FAILED → blocking (L4 failures land here, naturally stopping merge)
```

## Design Notes

- **L4 failures stay blocking**: Dr.CI merges L4 failures into `failedJobs`, not `CRCR_L3`. They flow through the normal failure path in trymerge.py and block the merge. No extra L4-specific logic is needed on this side.
- **The classification authority is Dr.CI**: trymerge.py does not query the allowlist or check GitHub check run names itself. It trusts the `CRCR_L3` category from Dr.CI.
- **Errors fail closed**: If Dr.CI is unreachable or returns no classifications, checks remain unclassified and block the merge. This is the same behavior as the other classification categories.

Pull Request resolved: pytorch#185612
Approved by: https://github.com/can-gaa-hou, https://github.com/subinz1, https://github.com/atalman
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
## Summary

Update mergebot (`trymerge.py`) to recognize CRCR L3 out-of-tree CI failures as non-blocking, preventing them from halting merges.

Depends on the Dr.CI + CRCR infrastructure in [pytorch/test-infra#8183](pytorch/test-infra#8183).

## Changes

### New classification function: `is_crcr_l3`

Mirrors the existing `is_flaky` / `is_broken_trunk` / `is_unstable` pattern. Consults the `CRCR_L3` category returned by the Dr.CI API and matches on the standard `name` and `id` fields of the `RecentWorkflowsData` schema.

### Classification in `get_classifications`

When a check matches the `CRCR_L3` category from Dr.CI, it is classified as `"CRCR_L3"` and excluded from the unclassified failures pool.

### Non-blocking categorization in `categorize_checks`

`CRCR_L3` is added to the list of non-blocking classifications (alongside `BROKEN_TRUNK`, `FLAKY`, `UNSTABLE`). CRCR_L3 failures are intentionally excluded from the `flaky_or_broken_trunk` threshold logic — L3 failures are definitionally non-blocking regardless of count.

## Data Flow

```
CRCR check run completes (oot_workflow_job)
    ↓
Dr.CI fetches from ClickHouse oot_workflow_job
    ↓
Dr.CI classifies: L3 → CRCR_L3, L4 → FAILED
    ↓
Dr.CI API returns {"CRCR_L3": [...], "FAILED": [...]}
    ↓
trymerge.py reads Dr.CI API response
    ├── CRCR_L3 → non-blocking (treated like FLAKY/BROKEN_TRUNK)
    └── FAILED → blocking (L4 failures land here, naturally stopping merge)
```

## Design Notes

- **L4 failures stay blocking**: Dr.CI merges L4 failures into `failedJobs`, not `CRCR_L3`. They flow through the normal failure path in trymerge.py and block the merge. No extra L4-specific logic is needed on this side.
- **The classification authority is Dr.CI**: trymerge.py does not query the allowlist or check GitHub check run names itself. It trusts the `CRCR_L3` category from Dr.CI.
- **Errors fail closed**: If Dr.CI is unreachable or returns no classifications, checks remain unclassified and block the merge. This is the same behavior as the other classification categories.

Pull Request resolved: pytorch#185612
Approved by: https://github.com/can-gaa-hou, https://github.com/subinz1, https://github.com/atalman
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
## Summary

Update mergebot (`trymerge.py`) to recognize CRCR L3 out-of-tree CI failures as non-blocking, preventing them from halting merges.

Depends on the Dr.CI + CRCR infrastructure in [pytorch/test-infra#8183](pytorch/test-infra#8183).

## Changes

### New classification function: `is_crcr_l3`

Mirrors the existing `is_flaky` / `is_broken_trunk` / `is_unstable` pattern. Consults the `CRCR_L3` category returned by the Dr.CI API and matches on the standard `name` and `id` fields of the `RecentWorkflowsData` schema.

### Classification in `get_classifications`

When a check matches the `CRCR_L3` category from Dr.CI, it is classified as `"CRCR_L3"` and excluded from the unclassified failures pool.

### Non-blocking categorization in `categorize_checks`

`CRCR_L3` is added to the list of non-blocking classifications (alongside `BROKEN_TRUNK`, `FLAKY`, `UNSTABLE`). CRCR_L3 failures are intentionally excluded from the `flaky_or_broken_trunk` threshold logic — L3 failures are definitionally non-blocking regardless of count.

## Data Flow

```
CRCR check run completes (oot_workflow_job)
    ↓
Dr.CI fetches from ClickHouse oot_workflow_job
    ↓
Dr.CI classifies: L3 → CRCR_L3, L4 → FAILED
    ↓
Dr.CI API returns {"CRCR_L3": [...], "FAILED": [...]}
    ↓
trymerge.py reads Dr.CI API response
    ├── CRCR_L3 → non-blocking (treated like FLAKY/BROKEN_TRUNK)
    └── FAILED → blocking (L4 failures land here, naturally stopping merge)
```

## Design Notes

- **L4 failures stay blocking**: Dr.CI merges L4 failures into `failedJobs`, not `CRCR_L3`. They flow through the normal failure path in trymerge.py and block the merge. No extra L4-specific logic is needed on this side.
- **The classification authority is Dr.CI**: trymerge.py does not query the allowlist or check GitHub check run names itself. It trusts the `CRCR_L3` category from Dr.CI.
- **Errors fail closed**: If Dr.CI is unreachable or returns no classifications, checks remain unclassified and block the merge. This is the same behavior as the other classification categories.

Pull Request resolved: pytorch#185612
Approved by: https://github.com/can-gaa-hou, https://github.com/subinz1, https://github.com/atalman
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 Merged module: ci Related to continuous integration open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants