Skip to content

chore(workflow): make logger namespaces statically greppable#45721

Merged
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-fix-inline-logger-calls
Jul 15, 2026
Merged

chore(workflow): make logger namespaces statically greppable#45721
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-fix-inline-logger-calls

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Two patterns in the workflow package made the complete set of logger namespaces impossible to discover statically via grep -rn 'var.*= logger.New'.

Changes

  • close_entity_helpers.go: Extract three logger.New(...) calls embedded in the closeEntityRegistry slice literal into named package-level vars (logCloseIssue, logClosePullRequest, logCloseDiscussion).

  • 48 *_validation.go files: Replace every newValidationLogger("domain") call — which built the namespace via runtime string concatenation — with a direct logger.New("workflow:domain_validation") string literal.

  • validation_helpers.go: Remove the now-unused newValidationLogger helper and its doc entry.

  • push_to_pull_request_branch_validation.go: Fix a latent bug exposed by inlining — the original call newValidationLogger("push_to_pull_request_branch_validation") silently produced "workflow:push_to_pull_request_branch_validation_validation" (doubled suffix). Corrected to "workflow:push_to_pull_request_branch_validation".

Before / After

// Before — namespace only knowable at runtime
var agentValidationLog = newValidationLogger("agent")

// After — fully static and greppable
var agentValidationLog = logger.New("workflow:agent_validation")

No behaviour change beyond the one bug fix above.

…kage

- Lift 3 inline logger.New calls in closeEntityRegistry to package-level
  vars (logCloseIssue, logClosePullRequest, logCloseDiscussion)
- Inline all newValidationLogger(domain) call sites (~48 files) with direct
  logger.New("workflow:domain_validation") string literals
- Fix doubled _validation suffix bug in push_to_pull_request_branch_validation.go
- Remove newValidationLogger helper function (no remaining callers)

Fixes #45509

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Lift logger.New calls for greppable logger namespaces chore(workflow): make logger namespaces statically greppable Jul 15, 2026
Copilot AI requested a review from pelikhan July 15, 2026 11:33
@pelikhan
pelikhan marked this pull request as ready for review July 15, 2026 12:23
Copilot AI review requested due to automatic review settings July 15, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Makes workflow logger namespaces statically discoverable while preserving existing behavior.

Changes:

  • Replaces validation logger helper calls with literal logger.New namespaces.
  • Extracts close-entity loggers into package variables.
  • Removes the obsolete helper and fixes the duplicated push-to-PR namespace suffix.
Show a summary per file
File Description
pkg/workflow/validation_helpers.go Removes the obsolete logger helper.
pkg/workflow/tools_validation.go Uses a static tools namespace.
pkg/workflow/template_validation.go Uses a static template namespace.
pkg/workflow/template_injection_validation.go Uses a static template-injection namespace.
pkg/workflow/strict_mode_validation.go Uses a static strict-mode namespace.
pkg/workflow/strict_mode_update_check_validation.go Uses a static update-check namespace.
pkg/workflow/step_shell_validator.go Uses a static shell-validator namespace.
pkg/workflow/step_order_validation.go Uses a static step-order namespace.
pkg/workflow/secrets_validation.go Uses a static secrets namespace.
pkg/workflow/schema_validation.go Uses a static schema namespace.
pkg/workflow/sandbox_validation.go Uses a static sandbox namespace.
pkg/workflow/samples_validation.go Uses a static samples namespace.
pkg/workflow/safe_outputs_validation.go Inlines safe-output logger namespaces.
pkg/workflow/safe_outputs_steps_shell_expansion_validation.go Uses a static shell-expansion namespace.
pkg/workflow/safe_outputs_max_validation.go Uses a static maximum-value namespace.
pkg/workflow/safe_outputs_allowed_labels_validation.go Uses a static allowed-labels namespace.
pkg/workflow/runtime_validation.go Uses a static runtime namespace.
pkg/workflow/runs_on_validation.go Uses a static runner namespace.
pkg/workflow/run_install_scripts_validation.go Uses a static install-scripts namespace.
pkg/workflow/repository_features_validation.go Uses a static repository-features namespace.
pkg/workflow/repo_memory_validation.go Uses a static repository-memory namespace.
pkg/workflow/push_to_pull_request_branch_validation.go Corrects and inlines the logger namespace.
pkg/workflow/pull_request_target_validation.go Uses a static PR-target namespace.
pkg/workflow/pip_validation.go Uses a static pip namespace.
pkg/workflow/permissions_toolset_data.go Uses a static permissions namespace.
pkg/workflow/npm_validation.go Uses a static npm namespace.
pkg/workflow/network_firewall_validation.go Uses a static network-firewall namespace.
pkg/workflow/model_alias_validation.go Uses a static model-alias namespace.
pkg/workflow/mcp_scripts_dependencies_validation.go Uses a static MCP-dependencies namespace.
pkg/workflow/mcp_mount_validation.go Uses a static MCP-mount namespace.
pkg/workflow/mcp_config_validation.go Uses a static MCP-config namespace.
pkg/workflow/labels_validation.go Uses a static labels namespace.
pkg/workflow/imported_steps_validation.go Uses a static imported-steps namespace.
pkg/workflow/github_app_permissions_validation.go Uses a static app-permissions namespace.
pkg/workflow/firewall_validation.go Uses a static firewall namespace.
pkg/workflow/features_validation.go Uses a static features namespace.
pkg/workflow/expression_secrets_serialization_validation.go Uses a static secrets-serialization namespace.
pkg/workflow/expression_safety_validation.go Uses a static expression namespace.
pkg/workflow/event_validation.go Uses a static event namespace.
pkg/workflow/engine_validation.go Uses a static engine namespace.
pkg/workflow/docker_validation.go Uses a static Docker namespace.
pkg/workflow/dispatch_workflow_validation.go Uses a static workflow-dispatch namespace.
pkg/workflow/dispatch_repository_validation.go Uses a static repository-dispatch namespace.
pkg/workflow/dangerous_permissions_validation.go Uses a static dangerous-permissions namespace.
pkg/workflow/concurrency_validation.go Uses a static concurrency namespace.
pkg/workflow/compiler_filters_validation.go Uses a static filter namespace.
pkg/workflow/close_entity_helpers.go Extracts three close-entity logger variables.
pkg/workflow/checkout_path_validation.go Uses a static checkout-path namespace.
pkg/workflow/call_workflow_validation.go Uses a static called-workflow namespace.
pkg/workflow/agent_validation.go Uses a static agent namespace.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 50/50 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design — no blocking issues found. ✅

📋 Summary

This is a clean, mechanical refactor that improves static analysability of the codebase. All changes are consistent:

  • All 48 *_validation.go files correctly inline logger.New("workflow:<domain>_validation") replacing the runtime-concatenating helper.
  • The doubled-suffix bug in push_to_pull_request_branch_validation.go (_validation_validation) is correctly fixed.
  • close_entity_helpers.go extracts the three embedded logger.New calls into named package-level vars, making them greppable.
  • validation_helpers.go cleanly removes the now-unused newValidationLogger function and its doc entry.

Positive Highlights

  • ✅ Namespace strings are now fully static — grep -rn 'logger.New' gives a complete inventory.
  • ✅ The latent doubled-suffix bug is fixed as a well-documented side effect.
  • ✅ No behaviour change beyond the one bug fix, clearly stated in the PR description.
  • ✅ Consistent naming convention maintained across all files.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 21.3 AIC · ⌖ 4.37 AIC · ⊞ 6.7K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes are clean and achieve the stated goal of making logger namespaces statically greppable via grep -rn 'var.*= logger.New'.

All 48 validation files follow a consistent naming scheme (workflow:<domain>_validation), and the three close-entity loggers are correctly extracted from the slice literal into named package-level vars.

One minor note: stepShellValidatorLog gets the namespace workflow:step_shell_validator_validation — the _validator_validation suffix is slightly redundant, but this is non-blocking and consistent with the variable name.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 18.3 AIC · ⌖ 5.38 AIC · ⊞ 5K

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (123 new lines in pkg/ — exceeds the 100-line threshold) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/45721-make-logger-namespaces-statically-greppable.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — confirm the alternatives are the ones you actually weighed, and add any context the AI could not infer
  3. Commit the finalized ADR to docs/adr/ on your branch (or accept the draft as-is)
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-45721: Make Workflow Logger Namespaces Statically Greppable

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 45721-make-logger-namespaces-statically-greppable.md for PR #45721).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · 73.1 AIC · ⌖ 13.2 AIC · ⊞ 8.5K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

REQUEST_CHANGES — The inlining approach is correct, and the push_to_pull_request_branch doubled-suffix fix is a good catch. However, the same doubled-suffix bug and several namespace-to-filename mismatches were introduced or carried forward unchanged.

### Findings summary
File Issue
step_shell_validator.go Doubled _validation suffix — same class of bug as the one explicitly fixed, missed here
expression_safety_validation.go _safety dropped from namespace
compiler_filters_validation.go compiler_ prefix and pluralization dropped
strict_mode_update_check_validation.go strict_mode_ prefix dropped
mcp_scripts_dependencies_validation.go scriptsscript (singular/plural)

All five introduce exactly the namespace-to-filename drift this PR is meant to eliminate. The step_shell_validator.go bug is the most egregious because it was explicitly called out in the PR description as a fixed pattern.

🔎 Code quality review by PR Code Quality Reviewer · 71 AIC · ⌖ 4.78 AIC · ⊞ 5.6K
Comment /review to run again

Comment thread pkg/workflow/step_shell_validator.go Outdated
)

var stepShellValidatorLog = newValidationLogger("step_shell_validator")
var stepShellValidatorLog = logger.New("workflow:step_shell_validator_validation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doubled _validation suffix bug: namespace "workflow:step_shell_validator_validation" has a spurious _validation suffix — the same doubled-suffix class of bug the PR explicitly fixes for push_to_pull_request_branch_validation.go, but left unaddressed here.

💡 Suggested fix

step_shell_validator.go is not a _validation.go file; the old newValidationLogger helper was passed "step_shell_validator" as its domain, then blindly appended "_validation", producing the doubled form. The corrected namespace should be:

var stepShellValidatorLog = logger.New("workflow:step_shell_validator")

This makes the namespace match the file stem exactly, consistent with how close_entity_helpers.go loggers use their own domain names without the _validation suffix.

)

var expressionValidationLog = newValidationLogger("expression")
var expressionValidationLog = logger.New("workflow:expression_validation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Namespace drops _safety component: "workflow:expression_validation" silently discards _safety, making it indistinguishable from a hypothetical expression_validation.go and defeating the static-grep-discoverability goal of this PR.

💡 Suggested fix

The old newValidationLogger("expression") convention predates safety/non-safety split, so the short domain was acceptable. Now that namespaces are inlined and meant to be grep-stable, the namespace should reflect the actual file:

var expressionValidationLog = logger.New("workflow:expression_safety_validation")

Note: you may also want to rename the variable from expressionValidationLog to expressionSafetyValidationLog to stay consistent.

)

var filterValidationLog = newValidationLogger("filter")
var filterValidationLog = logger.New("workflow:filter_validation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Namespace loses compiler_ prefix and pluralization: "workflow:filter_validation" drops both compiler_ and the s in filters, making the static string not grep-discoverable from the filename.

💡 Suggested fix

To satisfy the PR's stated goal — namespace derivable from filename by grep — the namespace should mirror the file stem:

var filterValidationLog = logger.New("workflow:compiler_filters_validation")

Also consider renaming the variable filterValidationLogcompilerFiltersValidationLog for full consistency.

)

var updateCheckValidationLog = newValidationLogger("update_check")
var updateCheckValidationLog = logger.New("workflow:update_check_validation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Namespace drops strict_mode_ prefix: "workflow:update_check_validation" omits the strict_mode_ context present in the filename, weakening the grep-discoverability guarantee this PR is meant to provide.

💡 Suggested fix
var updateCheckValidationLog = logger.New("workflow:strict_mode_update_check_validation")

The strict_mode_ prefix is important — it indicates this check only fires in strict mode. Losing it in the namespace makes log output harder to triage.

)

var mcpScriptDepsValidationLog = newValidationLogger("mcp_script_dependencies")
var mcpScriptDepsValidationLog = logger.New("workflow:mcp_script_dependencies_validation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Singular/plural mismatch: namespace uses mcp_script_dependencies_validation (singular script) while the filename is mcp_scripts_dependencies_validation.go (plural scripts) — one character difference introduced during inlining.

💡 Suggested fix
var mcpScriptDepsValidationLog = logger.New("workflow:mcp_scripts_dependencies_validation")

This is the exact kind of silent drift the PR aims to eliminate.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟢 Low
Priority Score 45/100
Recommended Action 📋 batch_review
Batch refactor-go-pkg (with #45700)

Score breakdown: Impact 20 + Urgency 10 + Quality 15

Rationale: Extracts logger namespace vars to make them statically greppable. Low risk refactor with ADR. CI status unknown (CHANGES_REQUESTED). Can be batch-reviewed alongside #45700.

Generated by 🔧 PR Triage Agent · 35 AIC · ⌖ 7.73 AIC · ⊞ 5.6K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once finished.

Run: https://github.com/github/gh-aw/actions/runs/29420425558

Generated by 👨‍🍳 PR Sous Chef · 10.2 AIC · ⌖ 4.88 AIC · ⊞ 5.1K ·
Comment /souschef to run again

- step_shell_validator.go: remove spurious _validation suffix
  (step_shell_validator_validation → step_shell_validator)
- expression_safety_validation.go: restore dropped _safety component
  (expression_validation → expression_safety_validation)
- compiler_filters_validation.go: restore compiler_ prefix and plural
  (filter_validation → compiler_filters_validation), rename var
- strict_mode_update_check_validation.go: restore strict_mode_ prefix
  (update_check_validation → strict_mode_update_check_validation)
- mcp_scripts_dependencies_validation.go: fix singular/plural mismatch
  (mcp_script_dependencies_validation → mcp_scripts_dependencies_validation),
  rename var

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

pr-sous-chef
@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once finished.
...

All 5 namespace mismatches from the PR Code Quality Reviewer have been fixed in 4ec772f:

  • step_shell_validator.go: step_shell_validator_validationstep_shell_validator (spurious _validation suffix removed; file is not a _validation.go file)
  • expression_safety_validation.go: expression_validationexpression_safety_validation (dropped _safety restored)
  • compiler_filters_validation.go: filter_validationcompiler_filters_validation (dropped compiler_ prefix and plural s restored; var renamed to compilerFiltersValidationLog)
  • strict_mode_update_check_validation.go: update_check_validationstrict_mode_update_check_validation (dropped strict_mode_ prefix restored)
  • mcp_scripts_dependencies_validation.go: mcp_script_dependencies_validationmcp_scripts_dependencies_validation (singular→plural fixed; var renamed to mcpScriptsDepsValidationLog)

make fmt, make lint, and pkg/workflow tests all pass locally. CI needs a human re-trigger to confirm.

Copilot AI requested a review from gh-aw-bot July 15, 2026 14:06
@pelikhan
pelikhan merged commit 594328e into main Jul 15, 2026
20 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-fix-inline-logger-calls branch July 15, 2026 14:10
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.10

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deep-report] Make inline/dynamic logger.New calls greppable in workflow package

4 participants