Repository navigation
Document generated permissions and preserve author comments - #75615
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection results could not be parsed. Review the workflow run logs to troubleshoot the error.
|
|
❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection results could not be parsed. Review the workflow run logs to troubleshoot the error.
|
|
Warning The 🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core workflow-compilation logic (488 new lines in 📄 Draft ADR committed:
📋 Evidence and what to do nextThe gate used the following PR evidence:
Once the ADR is linked in the PR body, this gate will re-run and verify that the implementation matches the decision. ❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does, including the alternatives and trade-offs future contributors need to understand. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
Warning
Threat detection engine error
Threat detection could not complete its analysis due to a tooling error. This is not a security finding.
What happened
The threat detection results could not be parsed.
Review the workflow run logs to troubleshoot the error.
What this change does: This change adds a YAML-node pass that copies author permission comments onto generated permissions and fills missing scope reasons. It also applies that pass to auxiliary workflow generators and adds regression tests for comments and unchanged values.
Should fix:
-
Remove the stranded generated-job name table (
pkg/workflow/compiler_job_annotations.go:L47)- What this is: The old branch that read
generatedJobNameswas removed. - Problem: A repository-wide search now finds only
notify_comment_failed_jobs_test.go:144; the 23-entry map and assertion no longer affect compilation but remain as dead state. - Fix: Delete
generatedJobNamesand the assertion that only protects it. - If we skip it: Future readers will assume the table still controls compiler behavior and will maintain code that cannot run.
- What this is: The old branch that read
Verdict: fix 1 first.
Lean: -24 lines possible.
Generated by ✂️ Ponytail Reviewer for #75615 · codex · routed: gpt56 max · ~7 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| } | ||
| _, generated := generatedJobNames[id] | ||
| if job.PermissionsComment == "" && (generated || len(sourceComments[id]) == 0) { | ||
| if job.PermissionsComment == "" { |
There was a problem hiding this comment.
Lean: Deleting the generated-name branch leaves generatedJobNames with no production callers (only notify_comment_failed_jobs_test.go:144); remove the 23-line map and that assertion, or this dead state will keep looking like compiler behavior.
There was a problem hiding this comment.
Removed the unused generatedJobNames map and its sole remaining assertion in df3f6b4.
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found one correctness issue blocking merge: frontmatter-level permission comments are not passed into the top-level generated permissions block, so the new preservation behavior drops those author comments (and the added regression test should fail). See the inline comment on compiler_permission_comments.go:227.
The specialist pass completed; its other suggestions were not actionable or did not meet the review threshold.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
| edits := permissionCommentEdits{ | ||
| lines: strings.Split(content, "\n"), before: make(map[int][]string), after: make(map[int][]string), | ||
| } | ||
| edits.documentJob(permissionCommentEntry(document.Content[0], "permissions"), permissionCommentSource{}) //nolint:uncheckedsliceindex // The empty-document guard above ensures a root exists. |
There was a problem hiding this comment.
The generated top-level permissions block never receives the source comment mapping, so author comments on frontmatter-level permissions are silently dropped. This contradicts the preservation goal and the added TestDocumentPermissionComments expectation for # Agent permissions / # Agent context. Pass sources[string(constants.AgentJobName)] (or equivalent) here so root permission comments are copied as well.
💡 Why this matters
permissionCommentSources explicitly stores the root permissions comments under the agent job key, but this call supplies an empty source. As a result, the root block is only auto-documented and never inherits author comments, while job-level comments work.
There was a problem hiding this comment.
Root permission comments are now mapped to the generated agent permissions block in df3f6b4.
There was a problem hiding this comment.
🟡 Changes recommended
Reparsing frontmatter without non-breaking-space normalization can break previously accepted workflows, while permission comments are still lost for built-in job aliases and all: read.
3 open issues
What changed in this PR
This PR updates gh-aw’s workflow compiler to document generated permission scopes and preserve author-written permission comments, addressing the zizmor reporting gap in #75581.
Changes:
- Add scope explanations across primary and auxiliary workflow generators.
- Replace text-based comment collection with YAML-aware preservation.
- Add regression coverage for comment placement, permission values, and unchanged scripts.
| File | Description |
|---|---|
pkg/workflow/work_queue_event_workflow.go |
Document work-queue workflow permissions. |
pkg/workflow/side_repo_maintenance.go |
Document side-repository maintenance permissions. |
pkg/workflow/maintenance_workflow_yaml.go |
Document maintenance workflow permissions. |
pkg/workflow/compiler_yaml.go |
Apply permission comments during compilation. |
pkg/workflow/compiler_permission_comments.go |
Preserve author comments and generate scope explanations. |
pkg/workflow/compiler_permission_comments_test.go |
Test preservation, scope explanations, and unchanged YAML semantics. |
pkg/workflow/compiler_job_annotations.go |
Remove the previous text-based comment collector. |
pkg/workflow/compiler_job_annotations_test.go |
Update assertions for preserved comment placement. |
pkg/workflow/central_slash_command_workflow.go |
Document central-command workflow permissions. |
pkg/workflow/auto_update_workflow.go |
Document auto-update workflow permissions. |
Review effort: Balanced (auto)
| func permissionCommentSources(frontmatter string) (map[string]permissionCommentSource, error) { | ||
| result := make(map[string]permissionCommentSource) | ||
| var document yaml.Node | ||
| if err := yaml.Unmarshal([]byte(frontmatter), &document); err != nil { |
| for i := 0; i+1 < len(jobs.Content); i += 2 { | ||
| source := permissionCommentEntry(jobs.Content[i+1], "permissions") //nolint:uncheckedsliceindex // The loop bounds both members of this mapping entry. | ||
| if source.key != nil { | ||
| id := jobs.Content[i].Value //nolint:uncheckedsliceindex // The loop bounds both members of this mapping entry. |
| for current := &source; current != nil; current = current.inherited { | ||
| e.copyComments(perms, *current) | ||
| } |
There was a problem hiding this comment.
Warning
Threat detection engine error
Threat detection could not complete its analysis due to a tooling error. This is not a security finding.
What happened
The threat detection results could not be parsed.
Review the workflow run logs to troubleshoot the error.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /codebase-design. Requesting changes because the new permission-comment pass makes compilation fail on output that previously compiled.
📋 Key Themes & Highlights
Key Themes
- Regression (blocking):
documentPermissionCommentsparses the whole compiled workflow withyaml.Unmarshaland aborts on error. Two inputs now fail:on: "push"produces a barepushline, and adraft: falsepull_request test produces an unquotedGH_AW_CURRENT_WORKFLOW_REFvalue. Roughly 8 tests fail, includingTestPullRequestDraftFilter,TestASCIILogoAlignment,TestOutputCommentJobGeneration, and the WASM golden tests. With this step disabled, those pass. - Lock files out of date: Compiled output changes (new reason comments), but no
.lock.ymlfiles were regenerated. Runmake recompile(AGENTS.md rule 4).ab-testing-advisor.lock.ymlshows drift on recompile. - Dead code:
generatedJobNamesincompiler_job_annotations.gois now only referenced by a test. Remove it, or the test, if it is no longer needed.
Positive Highlights
- ✅
sourceJobPermissionCommentshas no remaining callers, so the removal is clean. - ✅ The reason-text table in
permissionScopeReasonis easy to extend, andcontents: readis skipped deliberately.
Caveats
- Environmental failures in this sandbox (
mktemppermission denied, inheritedGITHUB_TOKEN, and a clock-dependent enclave-expiry assertion) are not caused by this PR. No clean baseline could be built because git fetches of the parent commit fail.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
| return "", err | ||
| } | ||
| var document yaml.Node | ||
| if err := yaml.Unmarshal([]byte(content), &document); err != nil { |
There was a problem hiding this comment.
[/diagnosing-bugs] This new parse turns previously-compiling output into a hard compile error. documentPermissionComments now runs yaml.Unmarshal over the entire generated workflow and returns an error on failure. Any existing rendering quirk now breaks gh aw compile. Examples: the unquoted GH_AW_CURRENT_WORKFLOW_REF line when the test workflow name contains : , and the bare push line produced by on: "push". Disabling this call makes TestPullRequestDraftFilter, TestASCIILogoAlignment, TestOutputCommentJobGeneration, and the WASM golden tests pass again.
💡 Suggested fix
Do not make a best-effort annotation pass fatal. On parse failure, return content, nil and log at debug level, or skip annotations when the document is not valid YAML. Add a regression test that compiles an on: "push" workflow and a pull_request workflow with draft: false and asserts success.
@copilot please address this.
There was a problem hiding this comment.
Permission-comment parsing failures now leave generated YAML unchanged instead of failing compilation in df3f6b4. The reported compile regressions pass locally.
| if err != nil { | ||
| return "", nil, nil, fmt.Errorf("runner temp safety rewriting could not complete; ensure generated run/script steps are valid shell or JavaScript commands: %w", err) | ||
| } | ||
| yamlContent, err = documentPermissionComments(yamlContent, data.FrontmatterYAML) |
There was a problem hiding this comment.
[/codebase-design] This call site applies the new post-processing to every compiled workflow, so any failure in it aborts the whole compile. Keep the annotation pass non-fatal here, or make it a separate step that runs after validation succeeds.
@copilot please address this.
There was a problem hiding this comment.
The annotation pass now logs errors and continues compilation without changing the generated YAML in df3f6b4.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 81a01f4
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Sous-chef requested-head: 81a01f4 Work is underway: merge latest main; address the permission-comment preservation and dead-state review notes; inspect the reported CI failures; then validate, scan, and push the focused fixes. No workflow will be dispatched. |
…ted-permissions Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
@copilot resolve the merge conflicts on this branch. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ted-permissions # Conflicts: # .github/workflows/pr-specification-reviewer.lock.yml Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Resolved and pushed in c479c91. Merged the latest main and regenerated the conflicted workflow lock file, preserving permission-comment changes. All 360 workflows compiled; focused, WASM golden, and sampled impacted tests passed. Existing custom-lint findings and lint/CodeQL timeouts prevent a fully clean validation gate. |
|
🎉 This pull request is included in a new release. Release: |


Compiled workflows lose author permission comments and omit scope-level explanations required by zizmor’s pedantic
undocumented-permissionscheck.contents: readacross agentic, maintenance, central-command, work-queue, and auto-update workflows.Generated permissions now include explanations while retaining author-provided reasons: