Skip to content

workflows: Let a label pre-authorize protected-file edits - #20

Merged
cgwalters merged 1 commit into
mainfrom
add-protected-files-override
Jul 30, 2026
Merged

workflows: Let a label pre-authorize protected-file edits#20
cgwalters merged 1 commit into
mainfrom
add-protected-files-override

Conversation

@cgwalters

Copy link
Copy Markdown
Collaborator

Follow-up from #19: the label-standardization drafter run got stuck at
request_review because renaming labels necessarily touches
README.md and the .md/.lock.yml workflow sources, which are all
protected files.

drafter.md and fix.md now key their protected-files.policy off
the agent/workflow-edits-allowed label (a supported gh-aw GitHub
Actions expression string), instead of hardcoding request_review:

  • Present on the issue before drafter.md runs -> that run may
    write protected files without the review gate.
  • Present on the pull request -> fix.md gets the same treatment
    for follow-up commits.

Absent the label, both fall back to request_review exactly as
before, so this changes nothing for ordinary agent-code runs. The
label has to already be on the issue/PR when the triggering event
fires — neither workflow's safe-outputs expose add-labels, and both
hold read-only issues/pull-requests permissions — so an agent
can't grant itself this mid-run.

See "Letting the agent edit protected files" in README.md for the
full writeup.

The agent/workflow-edits-allowed label has already been created on
the repo.

drafter.md and fix.md both fall back to gh-aw's request_review policy
whenever an agent-authored change touches protected files (README.md,
the workflow definitions themselves, actions-lock.json, etc.) -- see
issue #19, where the label-standardization drafter run got stuck there
because renaming labels necessarily touches the .md/.lock.yml sources
and README.md.

Some tasks legitimately need that access (the label rename is a good
example). gh-aw's protected-files.policy field accepts a GitHub
Actions expression string, so instead of hardcoding a literal we key
it off a label:

  agent/workflow-edits-allowed on the issue -> drafter.md may write
  protected files for that run; on the PR -> fix.md may too.

The label has to be present on the triggering issue/PR before the
event fires, so it's a human's decision made ahead of time, not
something the agent can grant itself mid-run: neither workflow's
safe-outputs expose add-labels, and both hold issues:read/
pull-requests:read rather than write. Absent the label, the
expression falls back to request_review, so this changes nothing
for ordinary agent-code runs.

Assisted-by: https://github.com/cgwalters/cgwalters#llms
@cgwalters
cgwalters merged commit 50f91dd into main Jul 30, 2026
7 checks passed
cgwalters added a commit that referenced this pull request Jul 30, 2026
The && ternary idiom (cond && 'allowed' || 'request_review') broke
drafter.lock.yml and fix.lock.yml outright: gh-aw's compiler
JSON-encodes this policy string with Go's default HTML-escaping,
turning the literal && into \u0026\u0026 inside the heredoc-embedded
config blob. GitHub Actions' expression parser can't parse that,
so the whole workflow file was rejected as invalid on push -- see
https://github.com/cgwalters/gh-aw-fullsend-mini/actions/runs/30547055376
(zero jobs even attempted; both drafter.md and fix.md were
effectively disabled since the merge of #20).

Switch to GitHub Actions' case() function, which expresses the same
if/else without &, <, or > -- the only characters Go's json.Marshal
HTML-escapes by default -- so it survives gh-aw's config serialization
intact.

Assisted-by: https://github.com/cgwalters/cgwalters#llms
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.

1 participant