Skip to content

Feat(publish): Gate pre-commit config edits - #229

Merged
ModeSevenIndustrialSolutions merged 3 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-227
Nov 23, 2026
Merged

ModeSevenIndustrialSolutions merged 3 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-227

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #227

Authored by an AI agent; human review required
Command Exit
uv run python -B -m unittest tests.test_workflow.PrecommitConfigSwitchContracts 0
uv run python -B -m unittest tests.test_workflow.PrecommitConfigSwitchContracts.test_continue_job_forwards_neither_switch (with allow_workflow_edits temporarily added to the continue dispatch) 1
uv run python -B -m unittest discover -s tests 0
prek run --files tests/test_workflow.py 0
uvx zizmor --persona auditor .github/workflows/ 0
git log --raw --format=%h 81ecac69abef9c6559ee750bda44bdfff3872898..HEAD 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
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.

Round 1 of revision, on its base.


Gates edits to the root .pre-commit-config.yaml behind a new operator switch, allow_precommit_config_edits (default false). It works the same way #143 gated workflow edits.

  • New proposals: the switch reaches the trusted selection, the author runtime context (- pre-commit config edits: allowed / not allowed) and both dispatch forms (code-monkey-cron.yaml, testing.yaml). The publisher reads it from the selection alone. With the switch off, a proposal that changes the file is rejected with a reason that names the switch. With it on, the change is accepted and recorded as changes_precommit_config in check.json and the step summary, plus a "Lint gate" line in the provenance block. The switch unlocks only this one path. Every other protected file stays protected.
  • Revision rounds: whatever the switch says, a round may change the file only when its pull request already changes it. scripts/workflow_gate.py now handles a set of gated paths (workflow files plus this one) instead of workflow files alone.
  • The prompts, README.md and docs/DESIGN.md describe the rule.

Commits: refactor (move the provenance block to the model), expected-fail tests, then the feature.

This round

Added test_continue_job_forwards_neither_switch (tests/test_workflow.py), as a maintainer asked. It pins that the cron continue job never forwards allow_precommit_config_edits or allow_workflow_edits, so both switches stay operator-only. I checked that the test fails when -f allow_workflow_edits=true is added to the dispatch. The test is amended into the feature commit.

Checks run

  • uv run python -B -m unittest discover -s tests: pass
  • prek run --files tests/test_workflow.py (aislop included): pass
  • zizmor --persona auditor .github/workflows/: no findings

For the reviewer

Copilot's overview flags a trust tradeoff. The publisher enforces only which file may change. The rule that the agent must not remove or weaken a hook the issue does not name lives in the prompt alone. Check every hook change in a pull request that carries the "Lint gate" provenance line.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A maintainer should assess the trust-boundary tradeoff of permitting edits to executable lint configuration because hook preservation remains a prompt-only constraint rather than a publisher-enforced guarantee.

No open issues 🎉

What changed in this PR

Adds an off-by-default operator switch for editing the root .pre-commit-config.yaml, extending the publisher’s existing workflow-edit gating model. This enables requested hook updates while keeping other protected files locked.

Changes:

  • Passes allow_precommit_config_edits through workflow callers, trusted selection data, and author runtime context.
  • Generalizes the gate to cover pre-commit configuration, with revisions limited to files their pull request already changes.
  • Adds lint-gate disclosure to check output and PR provenance, with corresponding prompt, documentation, and test updates.
File Description
tests/​test_workflow.py Pins input defaults, forwarding, and prompt contracts.
tests/​test_workflow_gate.py Covers path matching, switch enforcement, and revision limits.
tests/​test_select_issues.py Checks selection records the switch.
tests/​test_proposal_policy.py Updates provenance calls and tests lint-gate disclosure.
tests/​test_proposal_check.py Extends fixtures and summary expectations.
scripts/​workflow_gate.py Generalizes authorization to workflow and pre-commit paths.
scripts/​selection_inputs.py Adds the selection command-line switch.
scripts/​selection_document.py Records permission in trusted selection data.
scripts/​proposal_policy.py Names the gated configuration path and relocates provenance rendering.
scripts/​proposal_model.py Adds change tracking, summary output, and provenance rendering.
scripts/​proposal_check.py Reads trusted permission and applies the generalized gate.
README.md Explains operator control and revision restrictions.
prompt/​revise.md Defines revision-only configuration edits and hook-preservation rules.
prompt/​author.md Makes configuration edits conditional on runtime permission.
docs/​DESIGN.md Documents authorization, interfaces, and disclosure behavior.
.github/​workflows/​testing.yaml Exposes the dry-run switch and disables it for plumbing.
.github/​workflows/​code-monkey.yaml Declares the input and forwards it to selection and prompt context.
.github/​workflows/​code-monkey-cron.yaml Exposes and forwards the dispatch switch.

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.

No actionable defects found. The default-off switch is consistently wired through selection and verification, preserves other protected paths, and restricts revision edits to the existing pull request scope; provenance flags lint-gate changes.

Antagonistic round 1 of 3.


Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.

Comment thread tests/test_workflow.py Resolved
lf-releng-code-monkey-bot Bot and others added 3 commits November 23, 2026 01:22
proposal_policy.py holds the rules a proposal must pass, and sits
near the aislop file-size limit. The provenance block is rendering,
like the check summary beside it in proposal_model.py, so move it
there unchanged. The next commits grow it for issue lfreleng-actions#227.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Issue lfreleng-actions#227 asks that edits to the root .pre-commit-config.yaml sit
behind an operator switch, allow_precommit_config_edits, as lfreleng-actions#143 put
workflow edits behind allow_workflow_edits. These tests describe it:
the switch reaches the selection, the prompt and both dispatch forms;
a new proposal changes the file only with the switch on, which
unlocks no other protected file; a revision round changes it only
when its pull request already does; and the provenance block names
the change. They are marked as expected failures until the feature
lands.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
The root .pre-commit-config.yaml decides which checks a repository
runs, so the publisher treated it as protected and rejected every
change to it, even when an issue asked for a hook update. Put it
behind an operator switch, as lfreleng-actions#143 did for workflow files.

A new input, allow_precommit_config_edits, off by default, reaches
the selection, the runtime context and both dispatch forms. The
offline check lets a new proposal change the file when the switch
is on, and rejects it otherwise, naming the switch; the switch
unlocks no other protected file. A revision round may change the
file when its pull request already does, whatever the switch says.
workflow_gate.py holds both rules, now for any gated path.

A proposal that changes the file records changes_precommit_config
in check.json, shows it in the check summary, and says so in the
provenance block's summary line and in a Lint gate line, so a
reviewer reads every hook change. The prompts carry the rule, and
README.md and DESIGN.md describe the switch.

Closes lfreleng-actions#227

Review: a maintainer asked for a contract test that the continue
job's dispatch forwards neither allow_precommit_config_edits nor
allow_workflow_edits, so an unattended continuation cannot widen a
pull request into the lint gate or its workflows. Added
test_continue_job_forwards_neither_switch in tests/test_workflow.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A maintainer should evaluate the trust tradeoff of allowing untrusted authors to modify lint gates when hook preservation and edit scope rely only on prompts rather than trusted validation.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.

No actionable defects found. The default-off switch is consistently wired through selection and verification, preserves other protected paths, and keeps revisions within existing pull request scope; the continuation dispatch forwards neither edit switch.

Antagonistic round 2 of 3.


Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit d4caabe into lfreleng-actions:main Nov 23, 2026
34 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-227 branch November 23, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gate pre-commit config edits behind an operator switch

2 participants