Skip to content

Clear custom-linter findings in pkg/cli logs and audit files - #80186

Merged
elefthei merged 1 commit into
mainfrom
lint-changed-cli-files
Nov 23, 2026
Merged

elefthei merged 1 commit into
mainfrom
lint-changed-cli-files

Conversation

@elefthei

@elefthei elefthei commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

The agent gate (scripts/agent-report-progress.sh) runs the custom Go linters and fails on every finding in a changed file, including findings already on main. Fifteen files in pkg/cli and pkg/workflow carry 39 such findings, so any PR that touches one of them fails the gate. #80174 hits 38 of them. This PR fixes all 39 on main, so later PRs only see their own findings. Behavior is unchanged except where noted below.

Changes

  • Unchecked writes. renderLogsTSVToWriter, renderLogsTSVVerboseToWriter and renderTSVContinuationRequestSummary write through the existing compactLogsWriter and return the first write error. renderLogsTSV and renderLogsTSVVerbose print it the way renderLogsCompact already does. TSV output bytes are unchanged; the existing tests pin them.
  • Long functions split into named helpers:
    • extractLogMetrics: 209 lines to about 47.
    • buildAgentEventsFromProcessedRun: 97 lines.
    • tryLoadCachedRunResult: 69 lines.
    • buildLogsDataWithCollectionCoverage: 66 lines.
    • renderCachedAuditIfAvailable: 62 lines.
    • newRunData, renderAuditReport and assembleAuditData: 61 lines each.
    • The two TSV renderers: 82 and 73 lines.
  • filepath.Walk to filepath.WalkDir in logs_metrics.go (3 calls) and audit_expanded.go. None of the callbacks needed FileInfo. Skip and error handling is unchanged.
  • Discarded errors. Two callers dropped the error from extractContinuationRequestsFromRun. They now log it with the package logger and keep the same control flow. One of them is under a new logger, cli:continuation_requests. readHarnessRoutingOutcomeArtifact logs a failed Close on its read-only file.
  • String-to-byte copies.
    • mcp_tools_privileged.go passes the audit subprocess's stdout bytes straight to decodeAuditReport.
    • extractMCPFailuresFromLogFile splits the file as bytes.
    • safe_outputs_tools.go decodes the embedded JSON with a json.Decoder and requires io.EOF after the value, so trailing data is still rejected.
  • runMCPAuditSubprocess: when the subprocess exits with an *exec.ExitError, it logs the exit code and the stderr length, then returns the error unchanged. Stderr stays out of the error text: buildAuditErrorResult falls back to err.Error() for the MCP message, and stderr carries debug log lines.
  • Smaller fixes:
    • sort.Strings is now slices.Sort in three places.
    • Explicit length guards on workflowPath[0] and on the skill-name regex group.

Validation

  • gh-aw-linters -largefunc.max-lines=60 ./pkg/cli ./pkg/workflow: no findings left in the changed files. Before this change, main had 39 in them.
  • go build ./pkg/cli ./pkg/workflow and gofmt -l on the changed files: clean.
  • BASE_REF=origin/main make agent-report-progress: the custom Go linters, impacted Go tests, schema freshness and sync checks pass. Go lint hit golangci-lint's default timeout after 727s on this loaded host. Replace work-queue protocol v3 with time-free v4 #79748 adds the --timeout 40m that fixes this. Rerun with golangci-lint run --timeout 40m ./pkg/cli ./pkg/workflow: 0 issues.
  • Targeted go test ./pkg/cli runs (TSV, continuation, logs report, metrics, run cache, audit, drain3, MCP) and go test ./pkg/workflow -run 'SafeOutputsTools|SafeOutputsConfig' pass.
  • TestMCPCompileTimeoutReturnsSanitizedPartialResults fails both here and on Route request_continuation to queue successors, approval issues or workflow dispatch #80174's branch. Neither branch changes the files it covers (mcp_tools_readonly.go, mcp_timeout_test.go). It is not related to this change.

- Route TSV and continuation summary writes through compactLogsWriter and surface write errors.
- Split extractLogMetrics, buildAgentEventsFromProcessedRun, tryLoadCachedRunResult and other
  functions over the 60-line limit into named helpers; behavior unchanged.
- filepath.Walk -> WalkDir; log discarded extractContinuationRequestsFromRun errors and a
  read-only Close error; avoid string->[]byte copies; slices.Sort; explicit index guards.
- runMCPAuditSubprocess logs ExitError code/stderr length, returning the error unchanged.

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.

🟡 Changes recommended

Both TSV renderers lack failure-injection tests, leaving write-error propagation, short writes, and stopping after the first error unverified.

1 open issue
What changed in this PR

This PR clears existing custom-linter findings in gh-aw’s logs, audit, and safe-output code, removing gate blockers for follow-up work such as #80174.

Changes:

  • Split large functions into focused helpers while preserving report and cache behavior.
  • Propagate TSV write errors and log previously discarded errors.
  • Replace older traversal and sorting APIs and reduce string-to-byte copies.
File Description
pkg/​workflow/​safe_outputs_tools.go Decode embedded JSON without a string-to-byte copy; reject trailing data.
pkg/​workflow/​safe_outputs_config_generation.go Use slices.Sort for required fields.
pkg/​cli/​mcp_tools_privileged.go Decode audit stdout bytes directly and log subprocess exit details.
pkg/​cli/​mcp_tools_privileged_test.go Adapt tests to byte-based audit error handling.
pkg/​cli/​logs_run_cache.go Extract artifact checks and healed-cache persistence.
pkg/​cli/​logs_run_analysis.go Log continuation extraction errors.
pkg/​cli/​logs_report.go Extract chain metrics and summary aggregation helpers.
pkg/​cli/​logs_metrics.go Split metrics extraction, use WalkDir, and parse log lines as bytes.
pkg/​cli/​logs_format_tsv.go Extract row helpers and return write errors.
pkg/​cli/​logs_format_tsv_test.go Assert successful renderer error returns.
pkg/​cli/​drain3_integration.go Extract helpers for error, tool-result, and finish events.
pkg/​cli/​continuation_requests.go Log backfill errors and use the checked TSV writer.
pkg/​cli/​continuation_requests_test.go Check the TSV renderer’s returned error.
pkg/​cli/​audit_run_pipeline.go Extract cached-artifact eligibility checks.
pkg/​cli/​audit_report.go Extract action-minute fallback calculation.
pkg/​cli/​audit_report_render.go Replace string sorting with slices.Sort.
pkg/​cli/​audit_render_output.go Extract audit cache loading and construction.
pkg/​cli/​audit_expanded.go Log file-close failures and use WalkDir.

Review effort: Balanced (adaptive)

// Line 2: Column headers
// Lines 3+: One line per run with tab-separated fields
func renderLogsTSVToWriter(w io.Writer, data LogsData) {
func renderLogsTSVToWriter(writer io.Writer, data LogsData) error {
@elefthei
elefthei merged commit bc2dd57 into main Nov 23, 2026
84 checks passed
@elefthei
elefthei deleted the lint-changed-cli-files branch November 23, 2026 01:48
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.

2 participants