Skip to content

[code-infra] Shepherd auditor pull requests to review - #2121

Draft
Janpot wants to merge 19 commits into
masterfrom
code-infra/gh-aw-auditor-shepherd
Draft

Janpot wants to merge 19 commits into
masterfrom
code-infra/gh-aw-auditor-shepherd

Conversation

@Janpot

@Janpot Janpot commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

A reusable gh-aw workflow that looks after the pull requests the auditors open as the Code Infra - Auditor App, and mui-public's hourly caller.

  • A plain job marks a draft ready and requests a review (reviewer_team) once every check the base branch's rulesets require has reported and all its checks pass. A required check still missing two hours after the last commit (check_timeout_minutes) counts as failing.
  • When a check fails or is cancelled, an agent reproduces the failure on the branch, and fixes what the pull request's own changes caused. It comments only when a person needs to act or to know: a failure the pull request didn't cause, one it couldn't fix, or a fix that departs from the pull request's intent; a routine fix leaves only its commit. gh-aw's run-status comments are off. Only then does the rest of the workflow run; it takes one pull request per run, once per commit and three times per pull request at most. A job after the agent records each attempt as an auditor-shepherd commit status linking the run, so a run skipped before the agent leaves the commit to a later one, and nothing notifies anyone.
  • GitHub Actions failure logs are passed in; CircleCI's the agent reads through CircleCI's hosted MCP server (get_job_logs, read tools only). Its read-only token is a CIRCLECI_READ_TOKEN secret in the code-infra-auditor environment that only the MCP gateway gets, so every gh-aw job now runs in that environment. gh-aw rejects sending a secret from a step before the agent (CTR-017), which rules out fetching the logs up front.
  • Smoke-tested on mui-public with a seeded App pull request with a lint error ([code-infra] Skip the separator split on POSIX (auditor shepherd smoke test) #2171, [code-infra] Skip the separator split on POSIX (auditor shepherd smoke test) #2172): the agent fixed and pushed it as the App without a comment, the attempt was recorded as a status, and the next run marked it ready.
  • Pushes and comments target the pull request the scan picked, and pushes require the App as its author (required-author, Restrict push-to-pull-request-branch / update-pull-request to pull requests a given author opened github/gh-aw#81015).

Accepted trade-offs

  • The review request uses the workflow token, which may not be allowed to request a team. It only warns; code owners are requested anyway when a draft becomes ready. Custom gh-aw jobs can't use the environment that holds the App key.
  • A setup failure before the agent starts still counts as an attempt. Otherwise an agent that fails without output would be retried every hour.
  • Every gh-aw job runs in the code-infra-auditor environment, the hourly pre_activation included, though only the agent and safe-output jobs use its secrets. gh-aw binds an environment to all its jobs or to safe outputs only. With deployment: false and a branch rule alone that costs nothing; required reviewers or a wait timer on the environment would stall every run.
  • CircleCI logs don't reach the agent yet. CircleCI's get_job_logs returns the log only as structured content, with a one-line text summary, and Claude Code passes the agent the text. The agent then reproduces the job, as it did in the smoke test. The wiring stays for when CircleCI's server includes the log in its text.
  • Nothing is retried. A flaky failure gets a report, and a person reruns it.
  • The agent sets up Node from package.json, not CI's exact version. The same goes for the other auditors; aligning all three is a separate change.

A reusable gh-aw workflow marks auditor drafts ready once their checks
pass, and has an agent fix one whose checks fail; the auditors label
their pull requests `auditor` for it.
@Janpot Janpot added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). labels Nov 25, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-2121--mui-internal.netlify.app/
QR code for https://deploy-preview-2121--mui-internal.netlify.app/

Bundle size

Total Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%)
Files: 79 total (0 added, 0 removed, 0 changed)

Show details for 79 more bundles

@mui/internal-docs-infra/abstractCreateDemo parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateDemoClient parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateStream parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateTypes parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/ChunkProvider parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/cli parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeControllerContext parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeExternalsContext parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/errors parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeProvider parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/resolvePageUrl parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/routeGroups parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCode parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCodeWindow parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCoordinated parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCopier parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemo parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemoController parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useErrors parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useLocalStorageState parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/usePreference parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useScrollAnchor parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream/types parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useType parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypes parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useUrlHashState parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/withDocsInfra parsed: 0B(0.00%) gzip: 0B(0.00%)
addLineGutters parsed: 0B(0.00%) gzip: 0B(0.00%)
applyCodeTransformWithComments parsed: 0B(0.00%) gzip: 0B(0.00%)
BuildEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeEditor parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterChunk parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterClient parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeInitialSourceLoader parsed: 0B(0.00%) gzip: 0B(0.00%)
CodeSourceLoader parsed: 0B(0.00%) gzip: 0B(0.00%)
compileCssWithPostcss parsed: 0B(0.00%) gzip: 0B(0.00%)
computeHastDeltas parsed: 0B(0.00%) gzip: 0B(0.00%)
createFrame parsed: 0B(0.00%) gzip: 0B(0.00%)
createParseSourceWorkerClient parsed: 0B(0.00%) gzip: 0B(0.00%)
embedTransforms parsed: 0B(0.00%) gzip: 0B(0.00%)
enhanceCodeEmphasis parsed: 0B(0.00%) gzip: 0B(0.00%)
findExpandingRanges parsed: 0B(0.00%) gzip: 0B(0.00%)
frameVisibility parsed: 0B(0.00%) gzip: 0B(0.00%)
getHastTextContent parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarCache parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarLoaders parsed: 0B(0.00%) gzip: 0B(0.00%)
grammarMaps parsed: 0B(0.00%) gzip: 0B(0.00%)
grammars parsed: 0B(0.00%) gzip: 0B(0.00%)
hastUtils parsed: 0B(0.00%) gzip: 0B(0.00%)
isFrameSpan parsed: 0B(0.00%) gzip: 0B(0.00%)
loadCodeFallback parsed: 0B(0.00%) gzip: 0B(0.00%)
loadIsomorphicCodeVariant parsed: 0B(0.00%) gzip: 0B(0.00%)
parseSource parsed: 0B(0.00%) gzip: 0B(0.00%)
rolldown-runtime parsed: 0B(0.00%) gzip: 0B(0.00%)
source.css parsed: 0B(0.00%) gzip: 0B(0.00%)
source.diff parsed: 0B(0.00%) gzip: 0B(0.00%)
source.js parsed: 0B(0.00%) gzip: 0B(0.00%)
source.json parsed: 0B(0.00%) gzip: 0B(0.00%)
source.mdx parsed: 0B(0.00%) gzip: 0B(0.00%)
source.shell parsed: 0B(0.00%) gzip: 0B(0.00%)
source.ts parsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsx parsed: 0B(0.00%) gzip: 0B(0.00%)
source.yaml parsed: 0B(0.00%) gzip: 0B(0.00%)
SourceEditingEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
text.html.basic parsed: 0B(0.00%) gzip: 0B(0.00%)
text.md parsed: 0B(0.00%) gzip: 0B(0.00%)
TransformEngine parsed: 0B(0.00%) gzip: 0B(0.00%)
transpileSource parsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Performance

No regressions in 12 benchmarks · precise to ±19.7% (±40.4% at worst) · ran 1m 24s · details


Check out the code infra dashboard for more information about this PR.

- Count the required checks through gh pr checks, which keeps the latest
  run of each, instead of mapping the status rollup by hand.
- Decide in one jq program which pull requests to mark ready and which
  one to hand over.
- Record fix attempts in the plain job, before the agent runs, so a
  failed or timed-out run still counts; cap them at three per PR.
- Run activation and the agent only when a pull request fails: quiet
  hours are the pre-activation and plain jobs.
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 25, 2026
- Count every check, with cancelled ones as failing, and fail the step
  on a gh error instead of reading it as no checks.
- Record fix attempts in a comment from a job after the agent, so a run
  skipped before it doesn't use one up and description rewrites by the
  auditors don't reset the count; the agent reports in a comment too.
- Let fixes change manifests and the lockfile, which the Dependabot fix
  pull requests need.
- Give the agent the pull request's own diff, keep CircleCI links in its
  report, keep failure logs apart per run and job, and warn instead of
  stopping when a pull request can't be marked ready.
- US spelling in the README, for Vale.
- Skip hours without an open auditor pull request at a search in
  pre-activation, before any runner starts.
- Decide once per pull request in jq, with the attempt limit as an
  input (max_attempts) and cancelled checks blocking in one place.
- Hide earlier attempt comments as outdated, and pass the pull request's
  number and commit to the record job as outputs.
- Drop the agent job's checks and statuses grants, the temp file and
  a prompt sentence on attempts the agent can't act on.
Leaves out the auditor label on mui-public's Dependabot fix workflow: the
security auditors now run from mui-private, which labels their pull requests.
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 4, 2026
…e-infra/gh-aw-auditor-shepherd-update

# Conflicts:
#	.github/workflows/ahrefs-audit-workflow.lock.yml
… label

gh-aw v1.4.1 checks the author of the pull request a push goes to
(required-author), so the auditor label isn't needed to select or guard
pull requests. Pushes and comments also target the scanned pull request.

Also from review: count distinct commits toward max_attempts, wait 15
minutes after a push before marking ready so CircleCI can report, keep
going when GitHub doesn't serve the diff, stop when the branch moved,
fix a lockfile that doesn't match its manifests, and don't try browser
tests.
…marking ready

A draft is ready once every check the base branch's rulesets require has
reported and all checks pass. A required check still missing after
check_timeout_minutes (120) counts as failing, so the agent looks into it.
Also reads the head commit's date per pull request: requesting commits in
the 100-pull-request list exceeds GitHub's GraphQL node limit.
One GraphQL search returns each pull request with its latest commit's checks
and its comments, instead of three gh calls per pull request, and the
decision logic is plain functions instead of a jq program in a shell string.
Run the scan and record jobs on ubuntu-slim, map a check from its conclusion
alone and count skipped checks as passing, read the pull request number from
the scan's output, and drop the agent's setup-node step: gh-aw's own Node.js
setup runs after it and takes precedence.
A CircleCI check links to its job by ID; the branch's recent builds on API
v1.1 give the job's number, and its failed steps' output is the log. Public
projects serve both without a token.
The agent reads a failing CircleCI job's log with the hosted MCP server's
get_job_logs, for private projects too. Its read-only token is a
code-infra-auditor environment secret that only the MCP gateway gets, so
the whole workflow now runs in that environment. The token-free prefetch
for public projects goes: one path for both.
The scan extracts the job ID from a CircleCI check's link, so the agent
passes it to get_job_logs as is, capped at 400 lines like the GitHub
Actions logs. Drops get_job, which only led to the same log, and leftovers
of the CircleCI prefetch.
The agent comments only when a person needs to act; a plain fix's commit
message is its record. gh-aw's run-status comments, such as one per pushed
commit, are off, and each fix attempt is recorded as an auditor-shepherd
commit status, which links the run without notifying anyone, instead of a
comment.
The record job now writes a commit status, and a called workflow can't get
more than its caller grants.
…a PR's intent

Reverting part of a pull request or changing its behavior to make the
checks pass needs a reviewer's attention, so the agent comments on it.
GitHub rejects markPullRequestReadyForReview from an Actions token with
only pull-requests: write (Resource not accessible by integration).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant