Skip to content

Migrate compact logs run tables from tabwriter to console.RenderTable - #50850

Merged
pelikhan merged 7 commits into
mainfrom
copilot/migrate-tabwriter-tables-to-render-table
Aug 6, 2026
Merged

Migrate compact logs run tables from tabwriter to console.RenderTable#50850
pelikhan merged 7 commits into
mainfrom
copilot/migrate-tabwriter-tables-to-render-table

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The two [runs] tables in pkg/cli/logs_format_compact.go were built with text/tabwriter, bypassing the CLI's centralized console.RenderTable styling and TTY-degradation logic used by every other table.

Changes

  • renderLogsCompactToWriter — accumulates [][]string rows and renders through console.RenderTable(console.TableConfig{...}) instead of writing tab-delimited lines to a tabwriter.Writer.
  • renderLogsCompactVerboseToWriter — same migration for the 16-column verbose table.
  • Numeric fields are stringified with strconv (FormatInt for the int64 RunID); all prior fallbacks (- for empty duration/actor/TBT/class), truncation, and the skipped/cancelled filter are unchanged.
  • text/tabwriter import and both tw.Flush() error-logging branches removed — RenderTable returns a string.
  • logs_format_compact_test.go (new) — asserts bordered rendering, absence of ANSI escapes on non-TTY writers, and continued exclusion of skipped/cancelled runs.
rows = append(rows, []string{
    strconv.FormatInt(r.RunID, 10), wfID, r.EngineID, status, dur,
    strconv.Itoa(r.TokenUsage), formatCompactAIC(r.AIC),
    strconv.Itoa(r.Turns), strconv.Itoa(r.ErrorCount),
    r.Event, actor, branch,
})
...
fmt.Fprint(w, console.RenderTable(console.TableConfig{
    Headers: []string{"RUNID", "WORKFLOW", "ENGINE", ...},
    Rows:    rows,
}))

Output shape

Columns and ordering are preserved; alignment now comes from lipgloss borders rather than tab padding:

[runs]
╭───────┬────────┬───────┬─────────┬────┬──────┬────┬─────┬───┬─────┬─────┬──────╮
│RUNID  │WORKFLOW│ENGINE │STATUS   │DUR │TOKENS│AIC │TURNS│ERR│EVENT│ACTOR│BRANCH│
├───────┼────────┼───────┼─────────┼────┼──────┼────┼─────┼───┼─────┼─────┼──────┤
│1234567│logs    │copilot│success  │1m2s│1200  │3.50│4    │0  │push │bob  │main  │
╰───────┴────────┴───────┴─────────┴────┴──────┴────┴─────┴───┴─────┴─────┴──────╯

Note that this format is consumed by agents/LLMs, so the added border glyphs are a deliberate (if minor) increase in token density over the previous whitespace alignment — worth a look if that tradeoff matters here.


Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.9 AIC · ⊞ 5.9K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 6, 2026 12:37
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] Migrate two tabwriter tables to console.RenderTable Migrate compact logs run tables from tabwriter to console.RenderTable Aug 6, 2026
Copilot AI requested a review from pelikhan August 6, 2026 12:44
@pelikhan
pelikhan marked this pull request as ready for review August 6, 2026 12:48
Copilot AI balanced review requested due to automatic review settings August 6, 2026 12:48
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ failed during design decision gate check.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

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

Migrates compact log run tables to centralized console rendering.

Changes:

  • Replaces tabwriter tables with console.RenderTable.
  • Adds compact and verbose rendering tests.
  • Also modifies workflow skill routing outside the stated scope.
Show a summary per file
File Description
pkg/cli/logs_format_compact.go Migrates both run tables.
pkg/cli/logs_format_compact_test.go Tests borders, ANSI degradation, and filtering.
.github/skills/agentic-workflows/SKILL.md Adds an unrelated routing entry.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

- `.github/aw/debug-agentic-workflow.md`
- `.github/aw/dependabot.md`
- `.github/aw/deployment-status.md`
- `.github/aw/designer-mappings.md`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I investigated this while fixing the failures in 5be7228. The workflow-skill source list is currently enforced by sync tests and had to stay aligned with fallback metadata; I applied the generated fallback list sync so tests pass. If you want this routing-list change isolated, I can split it into a dedicated follow-up PR.

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

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Review: Migrate compact logs run tables from tabwriter to console.RenderTable

The migration is well-executed and consistent across both render functions. The new test file provides meaningful coverage.

Confirmed correct:

  • RenderTable uses isTTY() (stdout detection) — correct default for these tables
  • Border characters () always render regardless of TTY; only ANSI color codes are stripped on non-TTY — test assertions are accurate
  • strconv.FormatInt / strconv.Itoa conversions match the field types (int64 RunID, int for others)
  • Filter logic for skipped/cancelled uses Conclusion with Status fallback — test exercises both correctly
  • RenderTable appends a trailing , so fmt.Fprint (not fmt.Fprintln) avoids a double newline

No blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 29.1 AIC · ⊞ 5.3K

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🧪 Test Quality Sentinel Report

Test Quality Score: 80/100 — Excellent

Analyzed 3 test(s): 3 design, 0 implementation, 0 violation(s).

📊 Metrics (3 tests)
Metric Value
Analyzed 3 (Go: 3, JS: 0)
✅ Design 3 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 2 (67%)
Duplicate clusters 0
Inflation Yes — logs_format_compact_test.go: 77 added / 24 prod added = 3.2:1 (threshold 2:1)
🚨 Violations 0
Test File Classification Issues
TestRenderLogsCompactRendersRunsTableWithBorders pkg/cli/logs_format_compact_test.go:35 design_test · behavioral_contract · high_value None
TestRenderLogsCompactVerboseRendersRunsTableWithBorders pkg/cli/logs_format_compact_test.go:49 design_test · behavioral_contract · high_value None
TestRenderLogsCompactSkipsSkippedAndCancelledRuns pkg/cli/logs_format_compact_test.go:62 design_test · behavioral_contract · high_value None
📝 Test Notes

TestRenderLogsCompactRendersRunsTableWithBorders — Verifies user-visible table structure: [runs] section header, border character , RUNID header, correct run ID, workflow ID, and that non-TTY output contains no ANSI escape codes. Strong behavioral contract covering both structure and the TTY-degradation invariant.

TestRenderLogsCompactVerboseRendersRunsTableWithBorders — Mirrors the above for verbose mode, additionally checking for the CLASS column header specific to verbose output. Validates that the two rendering paths produce distinct column sets.

TestRenderLogsCompactSkipsSkippedAndCancelledRuns — Verifies the filtering contract: runs with skipped or cancelled status are excluded, while a valid run appears exactly once. Good edge-case coverage of the status-filtering path.

Inflation note: The file added 77 lines against 24 production lines (3.2:1), above the 2:1 threshold. However, this is a newly added test file covering a refactored function — the ratio reflects thorough initial coverage rather than padding. No score penalty was waived but the flag is noted for transparency.

Verdict

passed. 0% implementation tests (threshold: 30%). No violations.

References: §31102988570

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 37.4 AIC · ⊞ 7.7K ·
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.

✅ Test Quality Sentinel: 80/100. 0% implementation tests (threshold: 30%). No violations.

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

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review 🧠

Applied /tdd and /codebase-design — two focused observations, no blocking issues.

📋 Key Themes & Highlights

Key Themes

  • Test coverage gap: The filter test only exercises Status-fallback; the Conclusion-first branch goes untested.
  • RenderTable trailing-newline contract: fmt.Fprint + the string return value may produce missing blank lines between sections if the contract isn't guaranteed.

Positive Highlights

  • ✅ Clean, surgical refactor — existing filtering and fallback logic is fully preserved.
  • ✅ New test file covers bordered rendering, ANSI degradation on non-TTY, and run filtering — a good baseline.
  • strconv.FormatInt/Itoa correctly replaces format verbs for the type-safe string conversion.
  • ✅ Removes the now-unused tabwriter import cleanly.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 37 AIC · ⊞ 7.1K
Comment /matt to run again

t.Parallel()
data := compactTestData()
data.Runs = append(data.Runs,
RunData{RunID: 222, WorkflowName: "skipped-wf", Status: "skipped", CreatedAt: time.Now()},

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.

[/tdd] The skipped/cancelled filter test only exercises the Status-fallback path — it sets Status: "skipped" but leaves Conclusion empty. The actual code checks Conclusion first; when it is non-empty, Status is never read. A test with Conclusion: "skipped" is needed to cover the primary branch.

💡 Suggested addition

Add two more rows that set Conclusion instead of Status:

RunData{RunID: 444, WorkflowName: "skipped-c", Conclusion: "skipped", CreatedAt: time.Now()},
RunData{RunID: 555, WorkflowName: "cancelled-c", Conclusion: "cancelled", CreatedAt: time.Now()},

Then assert:

assert.NotContains(t, out, "444")
assert.NotContains(t, out, "555")

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 5be7228. The test now adds Conclusion: "skipped" and Conclusion: "cancelled" rows and asserts run IDs 444 and 555 are excluded, covering the primary Conclusion-first branch.

}))

// [errors] — aggregated error/warning messages
if len(data.ErrorsAndWarnings) > 0 {

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] console.RenderTable returns a string that may or may not end with \n; fmt.Fprint is used here, but the section that follows ([errors]) is printed with fmt.Fprintln. If RenderTable already appends a trailing newline the output is correct, but if it doesn't the [errors] header will be run on directly after the closing border with no blank line. Worth adding a guard or verifying the contract in the RenderTable docs.

💡 Suggested guard
out := console.RenderTable(console.TableConfig{...})
if !strings.HasSuffix(out, "\n") {
    out += "\n"
}
fmt.Fprint(w, out)

Or, if RenderTable guarantees a trailing newline, add a comment to that effect so future readers don't have to trace into the package.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 5be7228. I added an explicit comment at both console.RenderTable callsites in pkg/cli/logs_format_compact.go documenting the trailing-newline contract so section headers remain separated without adding extra guards.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (101 new lines in pkg/cli/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/50850-migrate-tabwriter-to-console-rendertable.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 — add context the AI could not infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-50850: Migrate CLI Table Rendering from tabwriter to console.RenderTable

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., 0042-use-postgresql.md for PR #42).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 54 AIC · ⊞ 9.6K ·
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot Please address the unresolved review threads (newest first):

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.5 AIC · ⊞ 8.3K ·
Comment /souschef to run again

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

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

...

Addressed in 5be7228:

  • Added Conclusion-path coverage for skipped/cancelled filtering in pkg/cli/logs_format_compact_test.go.
  • Documented the console.RenderTable trailing-newline contract at both compact table callsites in pkg/cli/logs_format_compact.go.
  • Synced pkg/cli/data/agentic_workflows_fallback_aw_files.json with current .github/aw contents to fix the impacted-go/unit failures.

Investigated the listed failed checks via job logs:

  • verify-integration-build, validate-yaml, lint-go, lint-error-messages: failed on cache restore miss (fail-on-cache-miss), not code errors.
  • impacted-go-tests / Unit tests (D-L): failures included fallback AW file list drift; fixed in this commit. Also verified TestExchangeOTLPWorkloadIdentityScriptInSync passes locally.
  • agent workflow failures were tooling/threat-engine related in logs.

Copilot AI requested a review from gh-aw-bot August 6, 2026 13:46
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot Please address the unresolved review feedback already answered on this PR, verify any remaining unresolved threads are resolved, and investigate the failed checks below before running the pr-finisher skill.
Failed checks to investigate:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.9 AIC · ⊞ 5.9K ·
Comment /souschef to run again

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

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

...

Addressed in 9e3d8ac.

  • Investigated the two failed checks from the linked runs.
  • Confirmed TestFallbackAWFilesMatchesLocalAWDirectory passes on this branch.
  • Fixed TestExchangeOTLPWorkloadIdentityScriptInSync by syncing the missing safe-outputs exemption header in /home/runner/work/gh-aw/gh-aw/pkg/workflow/js/exchange_otlp_workload_identity.cjs to match actions/setup/js.

Validation run:

  • go test ./pkg/cli -run TestFallbackAWFilesMatchesLocalAWDirectory -count=1
  • go test ./pkg/workflow -run TestExchangeOTLPWorkloadIdentityScriptInSync -count=1
  • make agent-report-progress

@pelikhan
pelikhan merged commit cad027a into main Aug 6, 2026
@pelikhan
pelikhan deleted the copilot/migrate-tabwriter-tables-to-render-table branch August 6, 2026 14:47
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.0

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.

[Code Quality] Migrate two tabwriter tables in pkg/cli/logs_format_compact.go to console.RenderTable

4 participants