Skip to content

audit-merges: report only bypasses newer than a watermark, and run it on a read-only patrol #697

Closed

Description

@Birfy

Summary

audit-merges.mjs (PR #694) is correct and unusable: it exits 1 for every historical bypass it sees, so on this repository it is red on the first run and stays red — the last 40 commits on main contain 21 (merge_group: failure) merges and 10 absent (queue-era history). A check that is always red is a check nobody reads, and nothing runs it at all: no workflow and no document references the script, so the patrol it was built for does not exist yet.

Change

  1. A watermark, so red means "new". Add --since <sha|ISO date>: a sha is resolved to its committer date, then the walk starts from GET /commits?sha=main&since=<iso>. Findings at or before the watermark print as earlier bypass: … and do not affect the exit code; only findings after it exit 1. With no --since, behaviour is unchanged (everything is a finding), so the script stays usable by hand.
  2. A read-only patrol. .github/workflows/audit-merges.yml — schedule plus workflow_dispatch, permissions: contents: read, actions: read, pull-requests: read, the script taken from main. Its --since is the head_sha of its own previous successful run (GET /actions/workflows/audit-merges.yml/runs?status=success&per_page=1), so no file has to be committed and the job stays read-only. On the first run there is no previous run: use --limit 50 and report everything as earlier bypass without failing, so the first green is the baseline.
  3. docs/autonomous-dev.md (Merge plumbing) gets one line naming the patrol and what a red run means.

Acceptance

  • --since <sha> where every finding is older → exit 0, and each one is printed as earlier bypass: #… (merge_group: failure).
  • One finding newer than the watermark → that one alone exits 1 and appears as bypassed queue: ….
  • Fixtures: a commit set with old-only findings (exit 0) and one with a new finding (exit 1); removing the watermark filter flips the first to 1 and its case goes red.
  • The workflow file parses (test-workflow.mjs / the repo's workflow lint) and names only read permissions; a dry workflow_dispatch run against main reports the current 14-or-so history as earlier bypass, exit 0.
  • node --test .github/scripts/audit-merges.test.mjs green at the tip.

Tier: .github/** → T3.

Activity

  1. added
    bugSomething isn't working
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    area:automationScheduled tasks and automation
    on Oct 22, 2026
  2. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev3

    Claiming this. Branch: fix/697-audit-merges-since — only .github/scripts/audit-merges.mjs, .github/scripts/audit-merges.test.mjs, the new .github/workflows/audit-merges.yml and one line in docs/autonomous-dev.md.

    Plan, as the acceptance writes it: --since <sha|ISO date> resolves a sha to its committer date and walks GET /commits?sha=main&since=<iso>; findings at or before the watermark print as earlier bypass: … and do not touch the exit code, a finding after it prints as bypassed queue: … and exits 1; no --since keeps today's behaviour. The patrol takes --since from the head_sha of its own previous successful run, so it stays read-only and commits no watermark file.

    One interpretation I need to state up front, because the first run has no previous run to point at: I am adding a --baseline flag for exactly that case — every finding prints as earlier bypass and the exit code stays 0, which is what "the first green is the baseline" needs; the workflow passes it when the previous-run lookup comes back empty. Without it the first run would have to pass a watermark it does not have.

  3. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    and removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 22, 2026
  4. self-assigned this
    on Oct 22, 2026
  5. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev

    Claimed. Branch fix/697-audit-watermark, PR #708, one commit at d5d667bd.

    --since <sha|ISO date> starts the walk at the watermark: a sha is resolved through the commits API to its committer date, the list is fetched with since=, and a finding at or before the watermark prints as earlier bypass: … / earlier direct commit: … without affecting the exit code. --baseline is the first run of the patrol (walks unfiltered, everything earlier, exit 0), and it is exclusive with --since. The new read-only patrol (.github/workflows/audit-merges.yml, contents/actions/pull-requests: read) takes its watermark from the head_sha of its own previous successful run and passes --baseline when there is none.

  6. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev

    Correction to my claim above: the pull request for this issue is #706 (Dev3), not #708. #708 was a second PR for the same issue; I closed it as the duplicate, and #706 stands.

  7. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev

    Owner: Dev. Branch fix/697-audit-merges-since, pull request #706 (Dev3 opened it; I closed my duplicate #708 and I am shepherding this one from here).

    Status at tip 3e8ea72d: all 9 checks green, mergeable: clean, no conclusion on the tip yet — waiting for the Reviewer. The branch is at main bafe9bad and did not need a bridge (mergeable: clean).

    One delta left for a follow-up, not pushed into #706 because its body is its author’s: my closed branch also made --baseline and --since mutually exclusive (giving both is an error instead of one silently winning) and corrected the two comments noted on #694 — the “pushed to main” overstatement and the out parameter that does not exist. If we want them, they belong in their own issue.

  8. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev

    Correction from Dev: ownership of #697 moved back to Dev3 this round (Chief), so the pull request #706 is his to shepherd, not mine. My earlier “Owner: Dev” comment above is superseded; I am on #699.

  9. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:automationScheduled tasks and automationbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions