Repository navigation
Distinguish missing AI credit cost from zero in logs --json - #79904
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
logs --json
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
This comment has been minimized.
This comment has been minimized.
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
🚀 PR Specification Reviewer has started processing this pull request |
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (122 new lines under 📄 Draft ADR committed:
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. 🔍 Gate notes
|
There was a problem hiding this comment.
🟡 Changes recommended
The cached record’s AICCoverage now changes from empty to unavailable, but the preservation test still expects whole-record equality with empty coverage, causing its assertion to fail.
1 open issue
What changed in this PR
This PR addresses #79253 by distinguishing unknown AI credit costs from measured zero costs in gh aw logs --json, while keeping cost fields numeric.
Changes:
- Adds per-run and summary cost coverage, and always emits
summary.total_aic. - Preserves recorded zero costs through caching, with tests and documentation.
- Updates two generated workflows to use hash-verified PageIndex dependencies and include the requirements file in cache keys.
| File | Description |
|---|---|
pkg/cli/token_usage_types.go |
Persists evidence of recorded zero cost. |
pkg/cli/logs_report.go |
Tracks cost coverage and aggregates recorded costs. |
pkg/cli/logs_report_test.go |
Tests missing, zero, and mixed cost coverage. |
pkg/cli/logs_orchestrator_unit_test.go |
Checks coverage across disk and JSONL caches. |
docs/src/content/docs/setup/cli.md |
Documents JSON cost coverage semantics. |
.github/workflows/spec-librarian.lock.yml |
Uses hash-verified PageIndex dependencies and updated cache keys. |
.github/workflows/daily-doc-updater.lock.yml |
Applies the same PageIndex installation and cache changes. |
Review effort: Balanced (adaptive)
| func (agg *logsAggregate) recordCachedRun(runData RunData) RunData { | ||
| // Older cache records cannot distinguish a recorded zero from missing cost. | ||
| if runData.AICCoverage == "" { | ||
| runData.AICCoverage = logsAICUnavailable |
There was a problem hiding this comment.
Updated the expected cached record’s coverage while retaining whole-record equality in d385d69.
There was a problem hiding this comment.
Found two blocking schema-compatibility issues: the new aic_coverage fields and serialized aic_found field are not represented in the strict logs output schemas. Please update the schemas before merging. The specialist pass also identified a legacy-cache test gap, but I did not treat that as a blocking defect.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| CacheEfficiency float64 `json:"cache_efficiency"` | ||
| TotalAIC float64 `json:"total_aic,omitempty"` | ||
| AICFound bool `json:"-"` | ||
| AICFound bool `json:"aic_found,omitempty"` // Preserves recorded zero cost across cache loads. |
There was a problem hiding this comment.
Changing AICFound from json:"-" to a serialized field also changes token_usage_summary output, but schemas/logs.schema.json and schemas/logs-jsonl.schema.json omit aic_found while enforcing additionalProperties: false. Any logs JSON containing this field will fail schema validation. Please update the schemas (and any other affected output contract) with this new property.
| TotalDuration string `json:"total_duration" console:"header:Total Duration"` | ||
| TotalAIC float64 `json:"total_aic,omitempty"` | ||
| TotalAIC float64 `json:"total_aic"` | ||
| AICCoverage string `json:"aic_coverage" console:"-"` |
There was a problem hiding this comment.
aic_coverage is now emitted in both the summary and each run, but the checked-in schemas/logs.schema.json and schemas/logs-jsonl.schema.json do not define this property (their relevant objects use additionalProperties: false). JSON produced by this change will therefore fail the repository schema validation. Please update the output schemas alongside the new fields.
Comment MemoryPeek at saved memory (spec-review-history)History |
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd, /diagnosing-bugs, and /codebase-design. Requesting changes: the PR fails go test ./pkg/cli, and the published JSON schemas do not match the new output.
📋 Key Themes and Highlights
Key Themes
- Failing test:
TestBuildLogsDataPreservesCachedRunRecordexpects an emptyAICCoverageon a legacy zero-cost cache record. The new behavior correctly returnsunavailable, so the test expectation must change. The test is not in this diff. - Schema drift:
aic_coverage(runs[],summary) andaic_found(token_usage_summary) are missing fromschemas/logs.schema.json,schemas/logs-jsonl.schema.json, andschemas/audit.schema.json. All three useadditionalProperties: false. - Episode totals still conflate unknown with zero:
logs_episode_rollup.go(line 22) andlogs_episode.go(line 58) addrun.AICwithout checkingAICCoverage. Theepisodes[].total_aicvalue can still show 0 for runs whose cost is unknown. The PR does not touch these files. - Docs still default missing AIC to 0:
docs/src/content/docs/reference/cost-management.md(lines 75, 128, 133) andglossary.md(line 1517) use// 0in jq examples. The PR updatescli.mdbut not these.
Positive Highlights
- ✅ The coverage state machine in
logs_report.gois clear:recordRunAIC,recordCachedRun, andsummaryagree.totalRunsalways matches the number of recorder calls, because no early return skipsrecordRunAIC. - ✅
TestLogsJSONAICCoveragecovers the no-evidence, recorded-zero, and mixed cases. - ✅ Preserving a measured zero across cache round-trips with
aic_foundis the right fix. - ✅ The
cli.mddescription ofaic_coveragematches the implementation.
🔍 Verification
go test ./pkg/cli -run TestBuildLogsDataPreservesCachedRunRecord: FAIL (AICCoverageexpected"", actual"unavailable").TestLogsJSONAICCoverage,TestBuildLogsDataAggregatesAIC, andTestDownloadWorkflowLogsFromStdinReportsCollectionStatsForJSONLAndDiskCacheHits: PASS.- No runtime test validates
logs --jsonoutput against the schemas, so the drift is not caught by CI.
Next actions
- Update the expectation in
TestBuildLogsDataPreservesCachedRunRecordtounavailable. - Declare
aic_coverageandaic_foundin the three schemas. - Decide whether episode
total_aicshould use the coverage rule. If so, changelogs_episode_rollup.goandlogs_episode.goin this PR or in a follow-up, and update the docs jq examples.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~12 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| CacheEfficiency float64 `json:"cache_efficiency"` | ||
| TotalAIC float64 `json:"total_aic,omitempty"` | ||
| AICFound bool `json:"-"` | ||
| AICFound bool `json:"aic_found,omitempty"` // Preserves recorded zero cost across cache loads. |
There was a problem hiding this comment.
[/codebase-design] Exposing aic_found changes the JSON of every TokenUsageSummary, not only the cache. audit output (firewall_token_usage) also gains the key. schemas/audit.schema.json and schemas/logs.schema.json set additionalProperties: false on token_usage_summary and do not declare aic_found, so schema-conformant consumers will reject it.
💡 Suggested fix
Either declare aic_found in both schemas under token_usage_summary, or keep the cache-only marker out of the public type, for example in a private cache wrapper. Declaring the field is the smaller change.
@copilot please address this.
|
|
||
| func (agg *logsAggregate) recordCachedRun(runData RunData) RunData { | ||
| // Older cache records cannot distinguish a recorded zero from missing cost. | ||
| if runData.AICCoverage == "" { |
There was a problem hiding this comment.
[/tdd] Legacy cache records with AIC == 0 now become unavailable, which matches the PR intent. This breaks TestBuildLogsDataPreservesCachedRunRecord in pkg/cli/logs_cached_json_test.go, which expects an empty AICCoverage. That test is not in this PR, so go test ./pkg/cli fails. Update its expectation to unavailable.
💡 Verified locally
go test ./pkg/cli -run TestBuildLogsDataPreservesCachedRunRecord fails with expected AICCoverage "", actual "unavailable". TestLogsJSONAICCoverage, TestBuildLogsDataAggregatesAIC, and the stdin JSONL/disk-cache test all pass.
@copilot please address this.
There was a problem hiding this comment.
Updated the legacy-cache expectation in d385d69; the focused test passes.
| // discover the field and distinguish "no tokens recorded" from "field absent". | ||
| TokenUsage int `json:"token_usage" console:"header:Tokens,format:number,omitempty"` | ||
| AIC float64 `json:"aic"` | ||
| AICCoverage string `json:"aic_coverage" console:"-"` |
There was a problem hiding this comment.
[/codebase-design] aic_coverage is added to runs[] here and to summary at line 121, but schemas/logs.schema.json sets additionalProperties: false on both objects and does not declare the field. The published contract no longer matches gh aw logs --json output. Declare aic_coverage on summary (available, partial, unavailable) and on runs[] (available, unavailable), and make the same change in schemas/logs-jsonl.schema.json.
💡 Details
I found no test that validates these schemas, so CI will not catch this. The cli.md docs added by this PR already describe the field, so the schema is the remaining gap.
@copilot please address this.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "87bfefb223390cf2ab8758d5e7e17cb0287e16dc",
"kind": "requested",
"schema_version": "1",
"state": "5d295f2a0002a1aa5b9ed7c2167fa0712cb0fbf2c4500fbd4217541565a78765",
"work": [
"1142525aa3933194e37b2f70f28ea8e5955b5a428b1451cf10e81927d7859b3e",
"347b66281611050a0c5d74ede3f95425a58e8234d8e558be349ea05076bf191f",
"872a9eebe8877ceed825d25d80e6e1a78ed25a25e576e90b13025f6c7260025b",
"b969b5b5cb9290b5848e3d4586c35d7d031b521923763799c6b7b3b5e30e3338",
"db13618455d40a01ce338a3842e9979f8571ae1e68e42f33143486986c892088",
"e1a5724d86de6390d49d28b8140f674d7313ee71466a367821febed8fdfd807f"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…-aic-zero-cost Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "d385d697922eb7d0e8aa2c91afbc278330fe309b",
"kind": "requested",
"schema_version": "1",
"state": "e053972f9ce5ef1781717a989ae6b32ced85989300b150d084314c79fa076e10",
"work": [
"00c67337de75cbb14e7e442f3cd0c94ae2f69d353cccd0b2cd3b3a7b77eb9ebc"
],
"workflow": "pr-sous-chef"
}
|
…-aic-zero-cost Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
@copilot fix ci failures |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged |
The prior failure was fixed in |
|
@copilot use null instead? |
Yes: |
|
@copilot become null so client handles it |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

gh aw logs --jsonreports missing AI credit cost as0, indistinguishable from a measured zero. A report with missing costs can therefore understate cost per output.aic_coverageasavailableorunavailable. Keepaicnumeric; ignore it when coverage isunavailable.total_aiceven when zero. It sums only recorded costs, andaic_coverageidentifies whether all (available), some (partial), or none (unavailable) of the returned runs have recorded cost.{ "runs": [ { "run_id": 101, "aic": 0, "aic_coverage": "available" }, { "run_id": 102, "aic": 0, "aic_coverage": "unavailable" } ], "summary": { "total_aic": 0, "aic_coverage": "partial" } }