Skip to content

agent-policy: commit to policy branches only, report elsewhere - #475

Merged
DjDeveloperr merged 1 commit into
mainfrom
prfix7/agent-policy-heal-policy-branches-only
Nov 23, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
prfix7/agent-policy-heal-policy-branches-only

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

aurora-agent-policy heals every branch it sees. A push to any branch, and the hourly sweep over all branches, can add a github-actions[bot] commit ("gfya" / "agent-policy: sync assistant instruction files ...") that rewrites AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md. On an open pull request this moves the head a review was pinned to. It adds a commit with no human Signed-off-by, and the PR has to be rebuilt on a clean history before it can merge. This happened on #436, #441, #401, #245 and #451.

Change

  • The push and sweep modes commit only to policy branches (POLICY_BRANCHES, which is the default branch).
  • On any other branch, push mode logs the violations and changes nothing.
  • The sweep visits the policy branches only, and it no longer fetches every branch head.
  • The pull request check is unchanged. It already runs on the merge result, which takes the copies from the default branch unless the branch itself changed them, and it still fails a branch that did. The author then fixes their own branch.

Testing

bash .github/aurora/agent-policy-test.sh: 22/22 ok.

  • New checks: a foreign branch and a symlink branch are left untouched by the sweep. A push to a feature branch changes nothing. A push to the default branch still heals it, with exactly one commit. The unhealed foreign, symlink and feature branches fail their pull request check.
  • Removed checks: the four "foreign branch healed" checks and the two "healed branch merges cleanly" checks, because that behaviour is gone.

Still to run

  • The same script is in the other repositories' .github/aurora/ (mesa, fedora-aurora and others, all at blob 7bb5e7da) and in the open rollout PRs. Once this merges, they need the same two files.
Why not "skip open PR branches" only

A branch can get the bot commit before its PR is opened: #436's base j713/ans-start-reboot got one, and so did #436 itself. Checking for open PRs would also need an API call per branch on every push and sweep. Restricting commits to the policy branches covers both cases with no API calls. Nothing is lost, because the merge result of a branch that never touched the copies already has the default branch's copies.

Assisted-by: LLM (Claude:Opus 5.5)

The push and sweep modes healed every branch in the repository. On a
pull request branch that adds a github-actions[bot] commit under the
author: it moves the head a review was pinned to, it carries no human
Signed-off-by, and the PR then has to be rebuilt on a clean history to
merge. It happened on several open pull requests.

Healing those branches is not needed. The pull request check already
runs on the merge result, which takes the copies from the default
branch unless the branch itself changed them, and it fails a branch
that did. So:

- push mode on a branch that is not in POLICY_BRANCHES reports what it
  finds and commits nothing;
- sweep visits the policy branches only and no longer fetches every
  branch head.

Policy branches (the default branch) are still healed in place as
before. The self-test now checks that feature and symlink branches are
left untouched, that the pull request check fails them instead, and
that a push to the default branch still heals it with one commit.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at e713862.

Nits. This is the right fix. heal() returns before building a commit when policy=0 (agent-policy.sh:167-170), and sweep now fetches and visits only POLICY_BRANCHES. The stray-file cases that healing used to fix on feature branches (sub/CLAUDE.md, .claude, symlinked copies) are still caught, because the new tests check that the foreign, symlink and pushed branches fail pr mode.

  1. aurora-agent-policy.yml still has a bare on: push: with permissions: contents: write. Every push to every branch therefore still queues a runner job that now only logs. Runner time is already short, so restrict the trigger to the default branch (push: branches: [main], or whatever the default is). The job then never runs, and gets no write token, on feature branches. Reporting on a feature branch is redundant with the PR check anyway.
  2. The same script and workflow live at blob 7bb5e7da in mesa, fedora-aurora and the rest. Until those are updated, their PR branches keep getting bot commits. A tracking issue, or one stacked rollout PR per repo opened right after this merges, would keep that from being forgotten.
  3. Nit: log not a policy branch, report only before the violation lines, so a reader of the job log doesn't think the violations are about to be healed.

Rows: 22/22 locally is enough for the script. After merge, push a branch with a junk CLAUDE.md and confirm no bot commit appears, the PR check fails, and the next hourly sweep doesn't touch it.

@DjDeveloperr DjDeveloperr 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.

Formal §1–§6 review at e7138629504d2fcd339e1fcc88d7f154747177a1.

Verdict: COMMENT (0 code/policy blockers; holding approval until the last pending CI job finishes).

Checklist (§1–§6)

  • §1–§3: Pass. Policy script & self-test only; heal() now returns 0 without creating or pushing a commit when policy=0 (.github/aurora/agent-policy.sh:167-170), sweep fetches and visits POLICY_BRANCHES only, and pr mode continues to gate the merge result (falling back to PR head when unmergeable).
  • §4 Clean-room & attribution: Pass. Single commit has human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by only, with disclosure in the PR body.
  • §5 Evidence: Local 22/22 agent-policy-test.sh plus CI selftest and 15/16 non-skipped checks are green; Pytest (macos-26 + llvm-brew) is still IN_PROGRESS.
  • §6 Naming: Pass.

Non-blocking follow-ups / nits

  • .github/workflows/aurora-agent-policy.yml still triggers on: push: for every branch with permissions: contents: write, queuing a runner job on non-policy pushes only to report. Narrowing push: to the default branch (and rolling out the updated files across the other org repos currently on blob 7bb5e7da) is worth doing here or immediately after merge.
  • Minor log-ordering nit: logging not a policy branch, report only before printing individual violation lines makes the report-only intent immediately clear in job logs.

Ready to approve once Pytest (macos-26 + llvm-brew) finishes green.

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr DjDeveloperr 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.

All 17/17 checks (including Pytest (macos-26 + llvm-brew) and selftest) are now green on e7138629504d2fcd339e1fcc88d7f154747177a1. 0 code/policy blockers; approving and merging so feature/PR branches no longer receive bot policy commits.

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr
DjDeveloperr merged commit 038af60 into main Nov 23, 2026
17 checks passed
funkzy pushed a commit to funkzy/mesa that referenced this pull request Nov 24, 2026
Port aurora-silicon/aura#475 (.github/aurora/agent-policy.sh blob af61f90 and .github/aurora/agent-policy-test.sh blob ac2e364) so aurora-agent-policy only commits to policy branches and reports on feature/PR branches without pushing unsigned sync commits.

Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
AxxzyWasTaken pushed a commit to AxxzyWasTaken/fex that referenced this pull request Nov 25, 2026
Port the aurora-silicon/aura#475 agent-policy fix to aurora-silicon/fex:
- Never commit to non-policy branches (feature/PR branches) on push or sweep.
- Guard push and sweep healing to github.repository_owner == 'aurora-silicon' so forks never auto-push heal commits.
- Accept copies matching a branch's own .github/aurora/AGENTS.md on non-policy branches and rewrite (never delete) mismatched copies on policy branches.
- Check the GitHub PR merge ref first in pr mode and run agent-policy-test.sh in CI.

Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
@RyanTheTide
RyanTheTide deleted the prfix7/agent-policy-heal-policy-branches-only branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants