Skip to content

Gate workflow edits behind an operator switch #143

Description

Context

The publisher accepts a proposal that adds, edits or deletes files under .github/workflows/. needs_workflows in scripts/proposal_check.py records the fact for the step summary and gates nothing. Both fork mints grant workflows: write unconditionally (docs/DESIGN.md §4.3 explains why: the fork sync fast-forwards over upstream workflow commits, and GitHub refuses that without the grant).

The fork-organisation design means an agent-written workflow never runs before a maintainer reads it, so the exposure is a merged workflow change rather than an executed one. Against that, workflow changes are the ci category's whole purpose.

Decision

Gate workflow edits behind an operator switch, and bound what a revision round may widen.

1. New proposals: an allow_workflow_edits input

  • Add a boolean reusable-workflow input allow_workflow_edits, default false, to .github/workflows/code-monkey.yaml. Pass it from the select job through to publish.
  • Forward it from the callers: code-monkey-cron.yaml (a workflow_dispatch input; a schedule passes no inputs, so it keeps the default false) and testing.yaml.
  • When the flag is false and a proposal has needs_workflows set, the publisher rejects it. The reason must reach the issue comment.
  • prompt/author.md: when workflow edits are not allowed, the agent abstains and names the workflow file it would have changed, instead of editing it. When the flag is true, the existing rule stands ("Workflow files under .github/workflows/ are fine").

2. Revision rounds: only the workflow files the pull request already changes

This rule is independent of allow_workflow_edits, so scheduled revise-only runs and review-bot hand-backs (which pass no such flag) work without it.

  • A revision round may add, edit or delete a file under .github/workflows/ only if the pull request already changes that same file, relative to the base the round is rebased onto.
  • The trusted publisher decides this from the diff it already walks (walk_diff in scripts/proposal_check.py). It must not take the decision from the agent's output or from review text.
  • A revision that touches any other workflow file is rejected, with a reason that names the file and reaches the issue comment.
  • Review text (Copilot, antagonistic or human comments) is untrusted input. This rule stops a review comment from talking a round into widening a workflow change.
  • prompt/revise.md: tell the agent it may change only workflow files the pull request already changes, and that when a finding needs another workflow file it must say so in its reply and leave that file alone.
  • A rebase that brings in upstream workflow changes does not count as the round editing them. Check how the publisher compares against the rebase base so only the round's own changes are tested.

3. Out of scope

  • No change to the workflows: write grants. Both fork mints keep it, because the fork sync needs it whatever the proposal edits.
  • No change to the review bot (github-code-review-bot). Its hand-back does not forward allow_workflow_edits: a hand-back dispatching something that widens privileges would turn a nomination into a decision, and a schedule could never carry it. Revision rounds are covered by rule 2.
  • No new label. The CI label only places an issue in the ci category; it is not a permission.

Files

.github/workflows/code-monkey.yaml, .github/workflows/code-monkey-cron.yaml, .github/workflows/testing.yaml, scripts/proposal_check.py (and wherever the revision publish path runs the check), prompt/author.md, prompt/revise.md, tests/test_workflow.py (InputContracts), the tests for the new checks, and docs/DESIGN.md §8, §9.1 and §20.3 (edit the existing descriptions in place, including the "Workflow edits" row in §17 and the needs_workflows note in §18.3, which now says no step gates on it).

Acceptance

  • With allow_workflow_edits=false (the default), a new proposal touching .github/workflows/ is rejected, with the reason in the issue comment, and the agent abstains.
  • With allow_workflow_edits=true, it is accepted as today.
  • A revision round touching only workflow files its pull request already changes is accepted whatever the flag says; one touching any other workflow file is rejected.
  • Tests cover each case above, including deletion of a workflow file, and the contract tests pin that the input exists, defaults to false, and is forwarded by every caller.
  • Existing tests, prek (including the aislop gate) and zizmor --persona auditor pass.

Activity

  1. added
    no-agent
    on Nov 6, 2026
  2. changed the title [-]Decide whether workflow edits need an operator switch[/-] [+]Gate workflow edits behind an operator switch[/+] on Nov 12, 2026
  3. removed
    no-agent
    on Nov 12, 2026
  4. lf-releng-code-monkey-bot commented on Nov 12, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 An AI agent has proposed a change for this issue: pull request #188 (head 2de149d). The Copilot review of it has findings (2 unresolved review threads; assessment: changes recommended). Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

  5. lf-releng-code-monkey-bot commented on Nov 12, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 1: an AI agent revised pull request #188 (head f5fbd7e). Round 1: fixed both Copilot findings, no rebase (branch stays on d5881c2; PR mergeable, no maintainer asked). - Inherited workflow commits (workflow_gate.py): a round preserving the PR's own workflow edit and revert was rejected. Such paths now pass only when the chain makes no net change to them and each write matches one the published commits made; new or rewritten writes stay rejected. Regression tests added. - Repeated fetches: the allowed path set is now computed once, not per path; test pins one call. Tests amended into the test commit (expected-fail there), fix into the feature commit. Unit suite and prek (with aislop) pass. No failing checks were reported. Nothing remains open from this review.. The Copilot review of it has findings (2 unresolved review threads; assessment: changes recommended). Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

  6. lf-releng-code-monkey-bot commented on Nov 12, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 2: an AI agent revised pull request #188 (head 16c5f69). Round 2: fixed both Copilot findings on scripts/workflow_gate.py. No rebase: the branch stays on d5881c2 because the PR is mergeable and no maintainer asked. - Repeated edit/revert pairs: the carried-write check used an unordered blob set, so it accepted a replayed edit and revert. It now matches each path's changes in order, with each published change usable once. - Upstream edit to a carried workflow: a rebase changed the blobs, and a README-only round was rejected. Changes are now compared by their zero-context line edits, with hunk positions dropped. Both were reproduced with new regression tests before the fix. The tests are amended into the test commit as expected failures; the fix and the DESIGN.md §20.3 update are in the feature commit. Unit suite (1487), prek (with aislop) and zizmor pass. No failing checks were reported. Nothing from this review is still open.. The Copilot review of it has findings (1 unresolved review thread; assessment: changes recommended). Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

  7. lf-releng-code-monkey-bot commented on Nov 12, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 3: an AI agent revised pull request #188 (head ccee88b). Round 3: fixed the one Copilot finding. No rebase: the branch stays on d5881c2 because the PR is mergeable and no maintainer asked for one. - Lossy patch decoding (scripts/workflow_gate.py): carried-change fingerprints used UTF-8 replacement decoding and splitlines(). That let a rewritten non-UTF-8 edit/revert match the published one, and a CR split a line in two. Patches are now read as bytes and split on LF only. I reproduced both failures with regression tests before the fix. The tests are amended into the test commit as expected failures; the fix and a DESIGN.md §20.3 note are in the feature commit. Unit suite (1491), prek (with aislop) and zizmor pass. No failing checks were reported. Nothing from this review is still open.. The Copilot review of it has findings (2 unresolved review threads; assessment: changes recommended). Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

  8. lf-releng-code-monkey-bot commented on Nov 13, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 4: an AI agent revised pull request #188 (head e1a6d3b). Round 4: fixed both Copilot findings on scripts/workflow_gate.py. No rebase: the branch stays on d5881c2 because the PR is mergeable and no maintainer asked. - Hunkless fingerprints (high): an edit and revert in one job authorized the same pair in another job. The gate now compares exact mode/blob transitions per path, with the published changes replayed onto the chain's base by git merge-file, so location counts. A rebase over an unrelated upstream edit still passes. - Glob pathspec (medium): ci*.yaml also pulled in a sibling file's patch. Transitions now come from diff-tree --raw with no pathspec. Both were reproduced with regression tests before the fix. The tests are amended into the test commit as expected failures, and the fix plus a DESIGN.md §20.3 update into the feature commit. Unit suite (1494), prek (with aislop) and zizmor pass. No failing checks were reported. Nothing from this review is still open.. The Copilot review of it is clean. An antagonistic review was requested from the review bot.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CIfeature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions