Skip to content

fix(logs): total_turns and total_safe_items always 0 in summary#43410

Merged
pelikhan merged 7 commits into
mainfrom
copilot/cli-tools-test-fix-logs-tool-summary
Jul 5, 2026
Merged

fix(logs): total_turns and total_safe_items always 0 in summary#43410
pelikhan merged 7 commits into
mainfrom
copilot/cli-tools-test-fix-logs-tool-summary

Conversation

Copilot AI commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

logs tool summary consistently reports total_turns: 0 and total_safe_items: 0 even when the underlying artifact data contains non-zero values. Two independent bugs cause this.

Bug 1 — Orchestrator clobbers backfilled Turns (logs_orchestrator.go)

applyUsageActivitySummaryToResult correctly backfills result.Run.Turns from activity/summary.json (e.g. session.turns = 34). The orchestrator then unconditionally overwrites it:

// Before: always overwrites with 0 for usage-only downloads
run := result.Run          // run.Turns = 34 (backfilled)
run.Turns = result.Metrics.Turns  // run.Turns = 0 — Metrics.Turns is always 0
                                  // when no events.jsonl/.log files are present

Fix: only assign from metrics when the log-derived count is actually available:

if result.Metrics.Turns > 0 {
    run.Turns = result.Metrics.Turns
}

Bug 2 — Cache-hit path skips backfill (logs_run_processor.go)

The cache-hit path returned run_summary.json as-is. If a cache entry was written before the safe_outputs/session.turns backfill existed (same CLI version = no invalidation), SafeItemsCount and Turns stay 0 indefinitely.

Fix: after loading from cache, re-apply the backfill when either value is zero. applyUsageActivitySummaryToResult is a no-op when values are already non-zero, so this is safe unconditionally and self-heals old cache entries.

Tests

Five new unit tests cover both fixes and their guard conditions (non-zero cached values are not overwritten; log-derived Metrics.Turns still wins when present).

Copilot AI and others added 2 commits July 4, 2026 16:59
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 total_turns and total_safe_items in logs tool summary fix(logs): total_turns and total_safe_items always 0 in summary Jul 4, 2026
Copilot AI requested a review from pelikhan July 4, 2026 17:06
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage — Run §28715668077

Field Value
Category bug
Risk 🟢 Low
Score 72/100
Impact 38/50 — fixes silent telemetry data loss (total_turns/total_safe_items always 0 in summary)
Urgency 22/30 — observable metric regression; draft
Quality 12/20 — adds 137-line test, small Go patch
Action 🚀 fast_track

Small targeted fix (+7/-1 Go, +9 Go, +137 test lines, 3 files). Low risk. Recommend undraft → expedited review.

Generated by 🔧 PR Triage Agent · 113.5 AIC · ⌖ 13 AIC · ⊞ 5.5K ·

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

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

Fixes incorrect logs summary totals where total_turns and total_safe_items were reported as 0 despite non-zero values being present in usage activity artifacts and/or cached summaries.

Changes:

  • Prevents the orchestrator from overwriting backfilled Run.Turns with 0 when log-derived Metrics.Turns is unavailable.
  • Re-applies usage activity backfill on cache hits to self-heal stale cached run_summary.json entries with zero Turns / SafeItemsCount.
  • Adds unit tests covering the cache-hit backfill guard and the intended turns precedence behavior.
Show a summary per file
File Description
pkg/cli/logs_orchestrator.go Avoids clobbering backfilled Turns with Metrics.Turns==0 in the main orchestrator path.
pkg/cli/logs_run_processor.go On cache hits, re-loads usage activity summary to backfill stale zero values for Turns / SafeItemsCount.
pkg/cli/logs_usage_activity_test.go Adds unit tests for stale-cache backfill and turns precedence rules.

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: 4
  • Review effort level: Low

Comment thread pkg/cli/logs_orchestrator.go Outdated
Comment on lines +582 to +586
// result.Metrics.Turns is 0 when only the usage artifact was downloaded
// (no events.jsonl / .log files), so only overwrite when the log-based
// count is actually available to avoid discarding the backfilled value.
if result.Metrics.Turns > 0 {
run.Turns = result.Metrics.Turns

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.

Fixed in the prior commit — applyMetricsTurnsToRun() helper is now called by both DownloadWorkflowLogs and DownloadWorkflowLogsFromStdin, removing the unconditional assignment from the stdin path.

Comment thread pkg/cli/logs_run_processor.go Outdated
Comment on lines +141 to +145
if result.Run.Turns == 0 || result.Run.SafeItemsCount == 0 {
if usageActivitySummary, _ := loadUsageActivitySummary(runOutputDir); usageActivitySummary != nil {
applyUsageActivitySummaryToResult(usageActivitySummary, &result, true)
}
}

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.

Fixed in the prior commit — backfillCacheHitIfNeeded() now logs a warning via logsOrchestratorLog.Printf when loadUsageActivitySummary returns an error and verbose is true.

Comment thread pkg/cli/logs_usage_activity_test.go Outdated
Comment on lines +361 to +367
// This mirrors the cache-hit path in logs_run_processor.go: if values are zero,
// reload the usage activity summary and apply the backfill.
if result.Run.SafeItemsCount == 0 || result.Run.Turns == 0 {
if usageActivitySummary, _ := loadUsageActivitySummary(runDir); usageActivitySummary != nil {
applyUsageActivitySummaryToResult(usageActivitySummary, &result, true)
}
}

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.

Fixed in the prior commit — backfillCacheHitIfNeeded() was extracted as a package-level helper; tests now call it directly instead of duplicating inline production logic.

Comment thread pkg/cli/logs_usage_activity_test.go Outdated
Comment on lines +448 to +454
// This mirrors the relevant lines in logs_orchestrator.go:
// run := result.Run
// if result.Metrics.Turns > 0 { run.Turns = result.Metrics.Turns }
run := result.Run
if result.Metrics.Turns > 0 {
run.Turns = result.Metrics.Turns
}

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.

Fixed in the prior commit — applyMetricsTurnsToRun() was extracted as a package-level helper; tests now call it directly instead of mirroring the conditional assignment inline.

…nd cache healing

ADR-43410 documents the design decisions in PR #43410:
- Backfill-wins-when-metrics-is-zero precedence rule in the orchestrator
- Lazy cache healing strategy for stale run_summary.json entries
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

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

📄 Draft ADR committed: docs/adr/43410-logs-summary-backfill-precedence-and-cache-healing.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 and documents two design decisions:
    • The backfill-wins-when-metrics-is-zero precedence rule in logs_orchestrator.go
    • The lazy cache-healing strategy for stale run_summary.json entries in logs_run_processor.go
  2. Complete any missing sections — verify the alternatives and consequences reflect your actual reasoning
  3. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-43410: Logs Summary — Backfill Precedence Rule and Lazy Cache Healing

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 🏗️ · 45.7 AIC · ⌖ 7.24 AIC · ⊞ 8.4K ·
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.

Review: fix(logs): total_turns and total_safe_items always 0 in summary

The two independent bugs are correctly diagnosed and fixed.

Bug 1 — Orchestrator clobbers backfilled Turns (logs_orchestrator.go): The guard if result.Metrics.Turns > 0 preserves backfilled values when no events.jsonl/.log files were downloaded. This aligns the orchestrator with applyUsageActivitySummaryToResult which already uses result.Run.Turns == 0 as its own guard (line 103).

Bug 2 — Cache-hit path skips backfill (logs_run_processor.go): Re-applying the backfill after loading a cached entry is safe because applyUsageActivitySummaryToResult is idempotent — both the Turns guard (line 103) and SafeItemsCount guard (line 169) are zero-checks, so non-zero values are never overwritten.

Tests: The five new unit tests in logs_usage_activity_test.go give precise coverage of both fix paths and their boundary conditions, and the test logic directly mirrors the production code patterns.

No issues found — correctness, idempotency contract, and guard conditions all check out. ✅

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 37.8 AIC · ⌖ 6.04 AIC · ⊞ 4.9K

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 85/100 — Excellent

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

📊 Metrics (11 tests)
Metric Value
Analyzed 11 (Go: 11, JS: 0)
✅ Design 11 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 9 (82%)
Duplicate clusters 0
Inflation YES (8.5:1 — expected for bug fix with no prior test coverage)
🚨 Violations 0
Test File Classification Issues
TestApplyUsageActivitySummaryBackfillsSafeItemsCount logs_usage_activity_test.go:209 design_test Happy-path only
TestApplyUsageActivitySummaryDoesNotOverwriteExistingSafeItemsCount logs_usage_activity_test.go:228 design_test
TestApplyUsageActivitySummarySafeItemsCountZeroNotBackfilled logs_usage_activity_test.go:243 design_test Edge (zero-value)
TestLoadUsageActivitySummaryWithSafeOutputs logs_usage_activity_test.go:258 design_test Happy-path only; some setup require.NoError calls missing message context
TestLoadThenApplyUsageActivitySummaryBackfillsSafeItemsCount logs_usage_activity_test.go:283 design_test Integration pipeline
TestExtractThenApplyProcessorOrderingBackfillsSafeItemsCount logs_usage_activity_test.go:312 design_test Ordering invariant
TestCacheHitBackfillsStaleZeroSafeItemsCount logs_usage_activity_test.go:345 design_test Stale cache edge
TestCacheHitBackfillsStaleZeroTurns logs_usage_activity_test.go:376 design_test Stale cache edge
TestCacheHitDoesNotOverwriteNonZeroValues logs_usage_activity_test.go:405 design_test Non-overwrite guard
TestMetricsTurnsZeroDoesNotOverwriteBackfilledTurns logs_usage_activity_test.go:438 design_test Zero-metrics preservation
TestMetricsTurnsNonZeroOverridesBackfilledTurns logs_usage_activity_test.go:462 design_test Non-zero override
⚠️ Minor observations (not violations)

TestApplyUsageActivitySummaryBackfillsSafeItemsCount (logs_usage_activity_test.go:209) — design_test, high_value. Tests the core backfill behavior but only the happy path; no assertion for the nil summary guard. Minor; the other 10 tests cover surrounding invariants.

TestLoadUsageActivitySummaryWithSafeOutputs (logs_usage_activity_test.go:258) — design_test, high_value. Setup require.NoError calls (lines 263–264) lack descriptive messages. The key behavior assertions (lines 275–277) are well described. Cosmetic issue.

Inflation note — test:prod added lines = 137:16 (8.5:1). This exceeds the 2:1 threshold and deducts 10 points, but the ratio is expected here: the bug had no prior dedicated tests, and the fix adds a well-layered suite covering unit behavior, ordering invariants, and cache-hit paths. The inflation signals good coverage investment, not padding.

Verdict

Passed. 0% implementation tests (threshold: 30%), no guideline violations. All 11 new tests verify user-visible behavioral contracts: backfill semantics, non-overwrite invariants, stale-cache healing, processor ordering, and metrics override priority. The test suite directly covers the bug being fixed and its key edge cases.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 73.3 AIC · ⌖ 10.1 AIC · ⊞ 6.8K ·
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: 85/100. 0% implementation tests (threshold: 30%). 11 new design tests covering backfill semantics, non-overwrite invariants, stale-cache healing, processor ordering, and metrics override priority. 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — requesting changes on test robustness.

📋 Key Themes & Highlights

Key Themes

  • Test-to-production coupling: Four of the five new tests inline the production logic they mean to guard rather than calling through it. If the guard condition (|| vs &&) or the surrounding orchestrator block changes, those tests will silently pass while the real bug reappears.
  • Silenced error path: The cache-hit backfill uses _ to discard the loadUsageActivitySummary error, making it harder to diagnose corruption in the activity summary file.
  • Missing || boundary test: TestCacheHitDoesNotOverwriteNonZeroValues only tests the fully-non-zero case; it does not verify the partial-zero cases (Turns=0, SafeItemsCount=5 and vice versa) that are the most interesting semantics of the || guard.

Positive Highlights

  • ✅ Minimal, surgical fixes — each bug is resolved with a single well-placed guard
  • ✅ Clear PR description with root-cause analysis for both bugs
  • ✅ Five tests added for a 16-line production change — strong intent
  • ✅ Self-healing stale-cache design is safe and idempotent (applyUsageActivitySummaryToResult is already a no-op when values are non-zero)
  • ✅ Correct precedence: log-derived Metrics.Turns still wins when available

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

Comment thread pkg/cli/logs_usage_activity_test.go Outdated

// This mirrors the cache-hit path in logs_run_processor.go: if values are zero,
// reload the usage activity summary and apply the backfill.
if result.Run.SafeItemsCount == 0 || result.Run.Turns == 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.

[/tdd] These cache-hit tests inline the guard condition from logs_run_processor.go instead of calling through the production code path — if the guard changes in production (e.g. || becomes &&), these tests will still pass.\n\n

\n💡 Suggested improvement\n\nExtract the cache-hit backfill logic into a package-level helper and call it from both the production code and the tests:\n\ngo\n// logs_run_processor.go\nfunc healStaleCacheEntry(result *DownloadResult, runOutputDir string) {\n if result.Run.Turns == 0 || result.Run.SafeItemsCount == 0 {\n if summary, _ := loadUsageActivitySummary(runOutputDir); summary != nil {\n applyUsageActivitySummaryToResult(summary, result, true)\n }\n }\n}\n\n\nThen the tests call healStaleCacheEntry(&result, runDir) — testing the real guard, not a copy. Guard changes will break tests rather than silently diverge.\n\n
\n\n@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 the prior commit — backfillCacheHitIfNeeded() was extracted as a package-level helper and tests call it directly rather than inlining the guard logic.

}

// Guard condition is false (both >0), so neither value should change.
assert.Equal(t, 14, result.Run.Turns, "non-zero cached Turns must not be overwritten by the cache-hit backfill guard")

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] TestCacheHitDoesNotOverwriteNonZeroValues doesn't exercise the case where only one of the two fields is zero — the guard uses ||, so this partial-zero scenario is the critical path.\n\n

\n💡 Missing test case\n\nAdd two sub-cases:\n\n1. Turns=0, SafeItemsCount=5 — guard triggers; only Turns gets backfilled, SafeItemsCount stays 5\n2. Turns=14, SafeItemsCount=0 — guard triggers; only SafeItemsCount gets backfilled, Turns stays 14\n\nThese cover the || semantics and would catch a regression if the guard were changed to &&.\n\n
\n\n@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.

Added TestCacheHitBackfillsPartialZeroTurns and TestCacheHitBackfillsPartialZeroSafeItemsCount in the latest commit to cover both partial-zero branches of the || guard. Each test verifies that only the zero field gets backfilled while the non-zero field remains unchanged.

Comment thread pkg/cli/logs_run_processor.go Outdated
// were saved before safe-outputs or turn backfill was introduced.
// applyUsageActivitySummaryToResult is a no-op when values are already
// non-zero, so this is always safe to call.
if result.Run.Turns == 0 || result.Run.SafeItemsCount == 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.

[/diagnosing-bugs] The guard condition Turns == 0 || SafeItemsCount == 0 re-loads and applies the usage activity summary even when only one value is stale — which is fine — but silently swallows the loadUsageActivitySummary error via _. If the activity summary file is corrupted, the backfill silently skips without logging, making future diagnosis harder.\n\n

\n💡 Suggested improvement\n\ngo\nif result.Run.Turns == 0 || result.Run.SafeItemsCount == 0 {\n if usageActivitySummary, err := loadUsageActivitySummary(runOutputDir); err != nil {\n logsRunProcessorLog.Printf("cache-hit backfill: failed to load activity summary: %v", err)\n } else if usageActivitySummary != nil {\n applyUsageActivitySummaryToResult(usageActivitySummary, &result, true)\n }\n}\n\n\nThis preserves the no-op behaviour when the file is absent (err will be a not-found error, already handled) while surfacing corruption.\n\n
\n\n@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 the prior commit — backfillCacheHitIfNeeded() now captures the error and logs a warning via logsOrchestratorLog.Printf when verbose is true, consistent with the non-cache path.

Comment thread pkg/cli/logs_usage_activity_test.go Outdated
// This mirrors the relevant lines in logs_orchestrator.go:
// run := result.Run
// if result.Metrics.Turns > 0 { run.Turns = result.Metrics.Turns }
run := result.Run

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] TestMetricsTurnsZeroDoesNotOverwriteBackfilledTurns and TestMetricsTurnsNonZeroOverridesBackfilledTurns copy-paste the orchestrator's conditional assignment inline rather than calling into it — the same fragility as the cache-hit tests above.\n\n

\n💡 Why this matters\n\nThe orchestrator code block these tests guard spans lines 579–588 of logs_orchestrator.go. If the assignment block gains additional fields (e.g. AvgTimeBetweenTurns logic changes), the inline test copy won't reflect that.\n\nAs with the cache-hit path, extracting to a helper (e.g. applyMetricsToRun) and testing the helper directly would give stronger coverage with less duplication.\n\n
\n\n@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 the prior commit — applyMetricsTurnsToRun() was extracted as a package-level helper and tests call it directly rather than mirroring the conditional assignment inline.

@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 — Bug 1 fix is incomplete; one code path remains broken.

Blocking issues

Missing fix in DownloadWorkflowLogsFromStdin

The PR fixes run.Turns = result.Metrics.Turns → guarded assignment in DownloadWorkflowLogs (~line 585) but leaves the identical line unguarded in DownloadWorkflowLogsFromStdin (~line 1175). The --stdin path will still report total_turns: 0 for usage-only artifact downloads. See inline comment.

Two tests that don't guard the production fix

TestMetricsTurnsZeroDoesNotOverwriteBackfilledTurns and TestMetricsTurnsNonZeroOverridesBackfilledTurns copy-paste the guard condition inline instead of calling through production code. They pass regardless of whether the orchestrator fix is present, providing false confidence. See inline comment for remediation options.

🔎 Code quality review by PR Code Quality Reviewer · 191.3 AIC · ⌖ 5.53 AIC · ⊞ 5.4K
Comment /review to run again

Comments that could not be inline-anchored

pkg/cli/logs_orchestrator.go:1175

Same Turns-clobber bug exists in DownloadWorkflowLogsFromStdin: run.Turns = result.Metrics.Turns overwrites any backfilled value with 0, exactly like the bug fixed at line 585.

<details>
<summary>Bug description and suggested fix</summary>

DownloadWorkflowLogsFromStdin (here, line ~1175) is a parallel code path to DownloadWorkflowLogs (fixed at line ~585). The PR applied the guard only to DownloadWorkflowLogs. Any run processed through the stdin URL mode still reports `total_t…

pkg/cli/logs_usage_activity_test.go:458

These two tests exercise inlined logic, not production code: if the guard in logs_orchestrator.go is reverted, both tests still pass.

<details>
<summary>Why this matters</summary>

TestMetricsTurnsZeroDoesNotOverwriteBackfilledTurns and TestMetricsTurnsNonZeroOverridesBackfilledTurns inline the same if result.Metrics.Turns &gt; 0 condition directly in the test body instead of calling through a function that exercises the real production path. They are proofs-of-concept for the logic, …

@pelikhan

pelikhan commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

/souschef

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

PR Sous Chef finished PR sous-chef nudges.

processed=5; skipped_checks_running=0; skipped_last_comment_from_sous_chef=0; skipped_cooldown=0; nudged=0; branch_update_attempts=0; formatter_pushes=0; merge_main_scheduled=0

@pelikhan

pelikhan commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI and others added 2 commits July 5, 2026 05:17
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…gging

- Add applyMetricsTurnsToRun() helper called by both DownloadWorkflowLogs
  and DownloadWorkflowLogsFromStdin, fixing the unconditional Turns=0
  clobber in the stdin path (mirrors the fix from the regular path)
- Add backfillCacheHitIfNeeded() helper that includes verbose error
  logging for loadUsageActivitySummary failures instead of silently
  ignoring them
- Update tests to call the real helper functions instead of duplicating
  inline production logic

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

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Done. Addressed all four review threads in commit fix: extract helpers to fix stdin path and improve cache-hit error logging:

  1. DownloadWorkflowLogsFromStdin stdin path — extracted applyMetricsTurnsToRun() helper used by both DownloadWorkflowLogs and DownloadWorkflowLogsFromStdin, eliminating the unconditional run.Turns = result.Metrics.Turns at the stdin call site.
  2. Silent error ignore in cache-hit backfill — extracted backfillCacheHitIfNeeded() that logs a warning via logsOrchestratorLog when loadUsageActivitySummary returns an error (consistent with the non-cache path).
  3. & 4. Tests duplicating inline logicTestCacheHit* tests now call backfillCacheHitIfNeeded() directly; TestMetricsTurns* tests now call applyMetricsTurnsToRun() directly, so any future drift in guard logic or call sites will be caught.

Local make fmt, make lint, and make test-unit all pass.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

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

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

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

Unresolved review feedback (newest first):...

All unresolved review feedback has been addressed:

  • r3524239456 (active): Added TestCacheHitBackfillsPartialZeroTurns and TestCacheHitBackfillsPartialZeroSafeItemsCount to cover both partial-zero branches of the || guard.
  • r3524239455, r3524239457, r3524239460 (outdated): Already resolved in the prior commit via extracted helpers (backfillCacheHitIfNeeded, applyMetricsTurnsToRun) with proper error logging.
  • r3524231474, r3524231480, r3524231485, r3524231488 (outdated): All addressed in the prior commit.

Local make fmt, make test-unit, and make agent-report-progress pass. CI needs a human re-trigger.

Copilot AI requested a review from gh-aw-bot July 5, 2026 06:07
@pelikhan pelikhan merged commit 96ec895 into main Jul 5, 2026
29 checks passed
@pelikhan pelikhan deleted the copilot/cli-tools-test-fix-logs-tool-summary branch July 5, 2026 06:39
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.3

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.

[cli-tools-test] [daily-cli-tester] logs tool: total_turns and total_safe_items always 0 in summary

4 participants