Repository navigation
Feat(publish): Gate pre-commit config edits - #229
ModeSevenIndustrialSolutions merged 3 commits into
Conversation
There was a problem hiding this comment.
🔵 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_editsthrough 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
There was a problem hiding this comment.
🤖 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.
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>
8117897 to
c4becac
Compare
There was a problem hiding this comment.
🤖 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.
d4caabe
into
lfreleng-actions:main
Closes #227
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLI81ecac69abef9c6559ee750bda44bdfff3872898uv run python -B -m unittest tests.test_workflow.PrecommitConfigSwitchContractsuv 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)uv run python -B -m unittest discover -s testsprek run --files tests/test_workflow.pyuvx zizmor --persona auditor .github/workflows/git log --raw --format=%h 81ecac69abef9c6559ee750bda44bdfff3872898..HEADThe
github-code-monkey-botworkflow 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.yamlbehind a new operator switch,allow_precommit_config_edits(defaultfalse). It works the same way #143 gated workflow edits.- 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 aschanges_precommit_configincheck.jsonand 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.scripts/workflow_gate.pynow handles a set of gated paths (workflow files plus this one) instead of workflow files alone.README.mdanddocs/DESIGN.mddescribe 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 croncontinuejob never forwardsallow_precommit_config_editsorallow_workflow_edits, so both switches stay operator-only. I checked that the test fails when-f allow_workflow_edits=trueis added to the dispatch. The test is amended into the feature commit.Checks run
uv run python -B -m unittest discover -s tests: passprek run --files tests/test_workflow.py(aislop included): passzizmor --persona auditor .github/workflows/: no findingsFor 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.