Skip to content

Targeted custom-lint cleanup: append byte conversion, context propagation, error wrapping, and param-count reduction#43938

Merged
pelikhan merged 10 commits into
mainfrom
copilot/lint-monster-targeted-cleanup-again
Jul 7, 2026
Merged

Targeted custom-lint cleanup: append byte conversion, context propagation, error wrapping, and param-count reduction#43938
pelikhan merged 10 commits into
mainfrom
copilot/lint-monster-targeted-cleanup-again

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the focused lint-monster cleanup set for four files, excluding the broader function-length and process-environment backlogs. It removes low-risk non-functional lint findings around append usage, context handling, error wrapping semantics, and excessive function parameters.

  • Action cache serialization cleanup (pkg/workflow/action_cache.go)

    • Removed unnecessary []byte(...) conversions in append calls when appending string literals/fragments to []byte buffers.
  • Rate-limit context propagation (pkg/cli/logs_rate_limit.go)

    • Updated sleep/cancellation handling to rely on the passed context.Context instead of defaulting to context.Background().
    • Preserved nil-context behavior explicitly while avoiding implicit background-context coupling.
  • Error wrapping semantics (pkg/workflow/compiler_orchestrator_frontmatter.go)

    • Switched read-path error formatting to %w to satisfy wrapping requirements.
    • Kept user-facing behavior that avoids leaking internal os.PathError details through the chain.
  • Parameter-count reduction (pkg/parser/remote_download_file.go)

    • Replaced a 9-parameter helper signature with a small params struct (remoteSymlinkComponentParams) for resolveRemoteSymlinkComponent, without changing resolution logic.
// Before
resolvedPath, found, err := resolveRemoteSymlinkComponent(
    ctx, client, owner, repo, filePath, ref, parts, i, dirPath,
)

// After
resolvedPath, found, err := resolveRemoteSymlinkComponent(ctx, client, remoteSymlinkComponentParams{
    owner: owner, repo: repo, filePath: filePath, ref: ref, parts: parts, index: i, dirPath: dirPath,
})

Generated by 👨‍🍳 PR Sous Chef · 10.8 AIC · ⌖ 4.38 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 5.04 AIC · ⌖ 6.87 AIC · ⊞ 4.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 11.9 AIC · ⌖ 7.75 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 3.94 AIC · ⌖ 7.46 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI linked an issue Jul 7, 2026 that may be closed by this pull request
6 tasks
Copilot AI and others added 2 commits July 7, 2026 06:47
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix targeted custom lint findings in code Targeted custom-lint cleanup: append byte conversion, context propagation, error wrapping, and param-count reduction Jul 7, 2026
Copilot AI requested a review from pelikhan July 7, 2026 06:59
@pelikhan pelikhan marked this pull request as ready for review July 7, 2026 07:23
Copilot AI review requested due to automatic review settings July 7, 2026 07: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

This PR performs a targeted lint-driven cleanup across a few workflow/compiler/CLI/parser helpers, focusing on byte-slice appends, context propagation in sleeps, error wrapping semantics, and reducing helper parameter counts without changing behavior.

Changes:

  • Simplified []byte append usage by appending strings directly in action-cache JSON serialization.
  • Improved context propagation in rate-limit sleeping by relying on the passed context.Context (while preserving nil-context behavior).
  • Adjusted frontmatter file-read error handling to satisfy wrapping requirements without exposing os.PathError via unwrapping.
  • Replaced a large helper parameter list with a small params struct for remote symlink component resolution.
Show a summary per file
File Description
pkg/workflow/action_cache.go Removes unnecessary []byte(...) conversions when appending string fragments to []byte buffers.
pkg/cli/logs_rate_limit.go Uses the provided context for sleep cancellation handling and preserves nil-context behavior.
pkg/workflow/compiler_orchestrator_frontmatter.go Wraps file-read failures using %w while avoiding returning os.PathError in the unwrap chain.
pkg/parser/remote_download_file.go Introduces a params struct to reduce helper parameter count without changing symlink resolution logic.

Review details

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread pkg/cli/logs_rate_limit.go Outdated
Comment on lines 83 to 85
@@ -77,12 +84,15 @@ func fetchRateLimit() (rateLimitResource, error) {
// If ctx is cancelled before the timer expires, it stops the timer and returns
// ctx.Err() so callers can propagate cancellation immediately.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage — §28848998303

Field Value
Category chore
Risk low
Score 42/100 (impact:18 urgency:12 quality:12)
Action 📦 batch_review
Batch pr-batch:lint-fixes

New PR — Targeted lint cleanup: append byte conversion, context propagation, error wrapping (4 files, +60/-27). Non-functional, low-risk. Review with #43939.

Generated by 🔧 PR Triage Agent · 84.1 AIC · ⌖ 6.65 AIC · ⊞ 5.4K ·

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

No ADR enforcement needed: PR #43938 does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (60 additions detected, threshold is 100).

@github-actions

github-actions Bot commented Jul 7, 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 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions github-actions Bot mentioned this pull request Jul 7, 2026

@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 and /tdd — the changes are clean and low-risk; three minor observations are worth a look before merge.

📋 Key Themes & Highlights

Key Themes

  • Stale test description (logs_rate_limit.go): contextCause and the nil-channel approach are correct, but the test assertion string still says the old behaviour (nil

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 72.8 AIC · ⌖ 7.7 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread pkg/cli/logs_rate_limit.go
// Intentionally not wrapping to avoid exposing internal path details
return nil, fmt.Errorf("failed to read file: %v", err) //nolint:errorlint // intentionally not wrapping to avoid exposing os.PathError
// Keep the user-facing message while avoiding exposure of os.PathError internals.
return nil, fmt.Errorf("failed to read file: %w", frontmatterReadError{message: err.Error()})

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.

[/codebase-design] `frontmatterReadError` is a value type (not a pointer), has no exported fields, and is not accessible outside this package — so callers can never do `errors.As(err, &frontmatterReadError{})` to discriminate read failures from parse failures. The wrapping via `%w` satisfies the linter, but the wrapped sentinel adds no practical information over the raw error string.

💡 Alternative to consider

If the goal is lint compliance without an intermediate sentinel, a simple fmt.Errorf around the message string already breaks the os.PathError chain:

return nil, fmt.Errorf("failed to read file: %s", err.Error())

If frontmatterReadError is intended to be testable via errors.As, it needs to be exported and the test in TestParseFrontmatterSection_FileReadError should assert on it. As-is, the type is unreachable by callers.

@copilot please address this.

Comment thread pkg/parser/remote_download_file.go

@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.

Review: Targeted custom-lint cleanup

Clean, well-scoped set of low-risk fixes. Two non-blocking observations below; no blocking issues.

Change-by-change notes

pkg/workflow/action_cache.go — append byte conversion

All []byte("literal") → bare string literal in append calls. Functionally identical; the compiler handles the conversion. ✅

pkg/parser/remote_download_file.go — param-count reduction

The remoteSymlinkComponentParams struct is clean. Field names match the original parameters exactly. ctx and client stay as positional args (correct — they're cross-cutting infra concerns, not domain data). ✅

pkg/cli/logs_rate_limit.go — context propagation

Using a nil-safe done channel is the idiomatic Go pattern for optional cancellation. The contextCause helper is correct. One observation: the doc comment on sleepWithContext still says "returns ctx.Err()" but the function now returns context.Cause(ctx), which is a behavioural difference for WithCancelCause callers. See inline comment.

pkg/workflow/compiler_orchestrator_frontmatter.go — error wrapping

frontmatterReadError wrapper preserves the user-facing message while blocking errors.As from surfacing *os.PathError to callers — the intent is correct. One observation: frontmatterReadError has no Unwrap(), which is intentional but could confuse a future maintainer. See inline comment.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 82.5 AIC · ⌖ 5.97 AIC · ⊞ 4.8K

Comment thread pkg/cli/logs_rate_limit.go
// Intentionally not wrapping to avoid exposing internal path details
return nil, fmt.Errorf("failed to read file: %v", err) //nolint:errorlint // intentionally not wrapping to avoid exposing os.PathError
// Keep the user-facing message while avoiding exposure of os.PathError internals.
return nil, fmt.Errorf("failed to read file: %w", frontmatterReadError{message: err.Error()})

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 %w wrapping of frontmatterReadError means callers can now do errors.As(err, &frontmatterReadError{}) — but frontmatterReadError doesn't implement Unwrap(), so errors.Is/errors.As traversal stops at the outer fmt.Errorf wrapper and won't reach the underlying *os.PathError.

That's the intended behaviour (hiding os.PathError), but it's subtle. Consider adding an explicit // Unwrap is intentionally not implemented comment inside frontmatterReadError, or at minimum a comment on this line noting that the chain stops here. Without it a future maintainer may add Unwrap() thinking it's an oversight.

@copilot please address this.

@pelikhan

pelikhan commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

…targeted-cleanup-again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and recompile

Done. Merged main (d23763d1d5) into the branch and recompiled all 258 workflows (0 errors). make fmt and make agent-report-progress pass cleanly. CI needs a human re-trigger to run on the new HEAD.

@pelikhan

pelikhan commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make sure the branch is up to date with the base branch, and rerun checks.

Generated by 👨‍🍳 PR Sous Chef · 5.04 AIC · ⌖ 6.87 AIC · ⊞ 4.7K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

PR finisher complete. All conditions checked:

  • Reviews — the one unresolved thread (doc comment on sleepWithContext) was fixed in commit 6b00cf9 and replied to.
  • Checks (local)make fmt, make lint, and make test-unit all pass on the current HEAD.
  • Mergeable — branch is up to date with main (merged at f6e6097).
  • CI — stale after agent pushes; needs a human re-trigger (close/reopen or workflow_dispatch) before merge.

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, make sure the branch is up to date with the base branch, and rerun checks.

...

Branch is up to date with main (merge commit 7b95ca7 already in place). make fmt, make lint, and make test-unit all pass cleanly. No unresolved review threads remain. CI needs a human re-trigger (close/reopen or workflow_dispatch) to run on the current HEAD before merge.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage · Run §28868091227

Field Value
Category chore
Risk Low
Score 40 / 100
Action batch_review
Batch pr-batch:lint-fixes

Score breakdown: Impact 15 · Urgency 10 · Quality 15

Rationale: Non-functional lint cleanup (+62/-28, 4 files) — append conversion, context propagation, error wrapping, param-count. CI success (but unstable merge state). Labels unchanged from prior run. Batch with other lint PRs when available.

Labels: pr-type:chore pr-risk:low pr-priority:low pr-action:batch_review pr-batch:lint-fixes

Generated by 🔧 PR Triage Agent · 119.4 AIC · ⌖ 6.65 AIC · ⊞ 5.4K ·

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🛠️ Agentic Maintenance updated this pull request branch.

View workflow run

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 11.9 AIC · ⌖ 7.75 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

...

Branch is up to date with main. make fmt and make lint pass cleanly. No unresolved review threads remain.

The CI failure in run 28878619289 is in the PR Sous Chef workflow's safe_outputs job (Process Safe Outputs step) — this is infrastructure-level and not related to the PR's code changes. The PR's own checks need a human re-trigger (close/reopen or workflow_dispatch) to run on the current HEAD.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 3.94 AIC · ⌖ 7.46 AIC · ⊞ 7.1K ·
Comment /souschef to run again

@pelikhan pelikhan merged commit e880e41 into main Jul 7, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/lint-monster-targeted-cleanup-again branch July 7, 2026 16:44
Copilot stopped work on behalf of gh-aw-bot due to an error July 7, 2026 16:47
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.

[lint-monster] Targeted custom-lint cleanup (2026-07-07)

4 participants