Support wildcard cached logs files - #60702
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add tests for expired shards deletion. |
There was a problem hiding this comment.
🟡 Changes recommended
Quote wildcard examples and align help/documentation with actual pruning behavior.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds wildcard cached JSONL shard support to gh aw logs, including merging, pruning, and unique output files.
Changes:
- Adds wildcard cache loading, merging, duplicate warnings, and date-range pruning.
- Integrates cache handling across standard, stdin, and multi-target flows.
- Adds the
--cached-logsalias, tests, help text, and documentation.
File summaries
| File | Description |
|---|---|
pkg/cli/logs_orchestrator.go |
Cache lifecycle integration |
pkg/cli/logs_orchestrator_types.go |
Internal cache state fields |
pkg/cli/logs_orchestrator_stdin.go |
Stdin cache integration |
pkg/cli/logs_multi.go |
Multi-target cache finalization |
pkg/cli/logs_command.go |
CLI flag, help, and example updates |
pkg/cli/logs_command_test.go |
CLI flag tests |
pkg/cli/logs_cached_json.go |
Wildcard loading, merging, output, and pruning |
pkg/cli/logs_cached_json_test.go |
Wildcard and pruning tests |
docs/src/content/docs/setup/cli.md |
CLI documentation updates |
Review details
Suppressed comments (2)
docs/src/content/docs/setup/cli.md:520
- The documentation both shows an unquoted shell wildcard and overstates pruning: matching files are not all deleted when they have metadata-only or other non-prunable records. Quote the example and state that only shards containing exclusively out-of-range dated run records are removed.
Pass a trailing wildcard prefix such as `--cached-logs logs-*` to load all matching `logs-*.jsonl` files as the starting cache and write newly downloaded data to a unique `logs-<unix-time>-<random>.jsonl` file. With `--start-date` or `--end-date`, wildcard cache files that contain no in-range run records are deleted.
pkg/cli/logs_command.go:160
- This wording says every wildcard cache file with no in-range run is deleted, but
pruneCachedLogsJSONLWildcardSourcespreserves metadata-only, unknown-schema, undated, and other non-prunable records. Please describe deletion as applying only to files containing exclusively dated run records outside the requested range, so the help text matches the implementation and the PR contract.
cached files with no run records in the requested date range are deleted.
- Files reviewed: 9/9 changed files
- Comments generated: 2
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
| `--cached-jsonl` reuses compatible, schema-versioned run records and workflow-run discovery responses. It writes exactly one JSON value per line, appending every complete `gh run list` payload before downloading artifacts and available GitHub API rate-limit reports after collection. Each enriched `run` record includes job execution data, sanitized MCP tool-call metadata, and available engine, model, runtime, and component versions for downstream dashboards. Raw tool errors, arguments, responses, and artifact bodies are excluded. Discovered runs therefore remain available when a timeout or API limit interrupts processing. Records from incompatible schema versions are ignored. Use `gh aw json-schema logs-jsonl` to generate the schema for each JSON Lines item. | ||
| `--cached-jsonl` and its `--cached-logs` alias reuse compatible, schema-versioned run records and workflow-run discovery responses. They write exactly one JSON value per line, appending every complete `gh run list` payload before downloading artifacts and available GitHub API rate-limit reports after collection. Each enriched `run` record includes job execution data, sanitized MCP tool-call metadata, and available engine, model, runtime, and component versions for downstream dashboards. Raw tool errors, arguments, responses, and artifact bodies are excluded. Discovered runs therefore remain available when a timeout or API limit interrupts processing. Records from incompatible schema versions are ignored. Use `gh aw json-schema logs-jsonl` to generate the schema for each JSON Lines item. | ||
|
|
||
| Pass a trailing wildcard prefix such as `--cached-logs logs-*` to load all matching `logs-*.jsonl` files as the starting cache and write newly downloaded data to a unique `logs-<unix-time>-<random>.jsonl` file. With `--start-date` or `--end-date`, wildcard cache files that contain no in-range run records are deleted. |
There was a problem hiding this comment.
Quoted the wildcard in the setup documentation as --cached-logs 'logs-*' in ab5f905.
| %[1]s logs --json # JSON format (compact by default, use -v for full) | ||
| %[1]s logs --json -v # Full JSON with audit metadata | ||
| %[1]s logs --cached-jsonl logs.jsonl # Reuse matching records and append new results immediately | ||
| %[1]s logs --cached-logs logs-* # Reuse logs-*.jsonl files and write new data to a unique logs-*.jsonl file |
There was a problem hiding this comment.
Quoted the wildcard in the CLI example and matching setup documentation in ab5f905.
|
Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details.
|
|
✅ Ponytail Reviewer completed successfully! Lean already. Ship. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
|
🧠 Matt Pocock Skills Reviewer failed during 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 happenedThe threat detection engine failed to produce results. Review the workflow run logs for details.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff
|
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
ADR required for this implementationI generated a draft ADR at Evidence used
Inferred architectural decisionTreat cached logs as either a single JSONL file or a trailing-wildcard shard prefix, loading all matching shards as cache input while writing new data to a uniquely named shard and pruning fully out-of-range wildcard shards. Next actionPlease review and refine the draft ADR, especially the rationale and trade-offs, before merge.
|
There was a problem hiding this comment.
Reviewed with a normal correctness-focused pass (this PR is CLI/backend logic, not UI, so Impeccable's UX/accessibility modes don't apply — used inline mode guidance's mixed_unclear fallback).
The wildcard cache implementation itself (path resolution, merge, pruning, unique-file naming with crypto/rand) looks correct and is well covered by new tests; build and go test ./pkg/cli/... -run 'CachedLogs|CachedJSONL' pass.
One recurring issue found in three places: the --cached-logs logs-* examples in help text and docs are unquoted, so a user's shell will glob-expand them against files in the current directory before the CLI ever sees the argument, silently breaking the wildcard-cache feature. Left inline comments with the fix (quote the pattern, e.g. 'logs-*').
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 63.7 AIC · ⌖ 13.7 AIC · ⊞ 8.4K
| %[1]s logs --json # JSON format (compact by default, use -v for full) | ||
| %[1]s logs --json -v # Full JSON with audit metadata | ||
| %[1]s logs --cached-jsonl logs.jsonl # Reuse matching records and append new results immediately | ||
| %[1]s logs --cached-logs logs-* # Reuse logs-*.jsonl files and write new data to a unique logs-*.jsonl file |
There was a problem hiding this comment.
This example uses an unquoted shell glob (logs-*). In an interactive shell with any matching files in the CWD, this argument will be expanded by the shell before the program sees it, silently defeating the wildcard cache feature (and potentially passing an unexpected literal filename to --cached-logs). The example should be quoted, e.g. --cached-logs 'logs-*', to correctly demonstrate the intended usage.
@copilot please address this.
There was a problem hiding this comment.
Updated the CLI example to use --cached-logs 'logs-*' in ab5f905.
| Use --cached-jsonl (or --cached-logs) to reuse matching run records without downloading and processing their | ||
| artifacts again. New results are appended immediately as JSON Lines. When a date range is specified, | ||
| cached run records outside that range are removed after collection; other record types are retained. | ||
| Pass a trailing wildcard prefix such as --cached-logs logs-* to load all matching .jsonl files |
There was a problem hiding this comment.
Same unquoted-glob issue as the example above: --cached-logs logs-* will be shell-expanded before reaching the program in typical usage. Please quote the pattern in this help text (e.g. --cached-logs 'logs-*') so users don't unintentionally pass an already-expanded filename or file list.
@copilot please address this.
There was a problem hiding this comment.
Updated the detailed help text to quote 'logs-*' and precisely describe deletion of exclusively dated, out-of-range shards in ab5f905.
| `--cached-jsonl` reuses compatible, schema-versioned run records and workflow-run discovery responses. It writes exactly one JSON value per line, appending every complete `gh run list` payload before downloading artifacts and available GitHub API rate-limit reports after collection. Each enriched `run` record includes job execution data, sanitized MCP tool-call metadata, and available engine, model, runtime, and component versions for downstream dashboards. Raw tool errors, arguments, responses, and artifact bodies are excluded. Discovered runs therefore remain available when a timeout or API limit interrupts processing. Records from incompatible schema versions are ignored. Use `gh aw json-schema logs-jsonl` to generate the schema for each JSON Lines item. | ||
| `--cached-jsonl` and its `--cached-logs` alias reuse compatible, schema-versioned run records and workflow-run discovery responses. They write exactly one JSON value per line, appending every complete `gh run list` payload before downloading artifacts and available GitHub API rate-limit reports after collection. Each enriched `run` record includes job execution data, sanitized MCP tool-call metadata, and available engine, model, runtime, and component versions for downstream dashboards. Raw tool errors, arguments, responses, and artifact bodies are excluded. Discovered runs therefore remain available when a timeout or API limit interrupts processing. Records from incompatible schema versions are ignored. Use `gh aw json-schema logs-jsonl` to generate the schema for each JSON Lines item. | ||
|
|
||
| Pass a trailing wildcard prefix such as `--cached-logs logs-*` to load all matching `logs-*.jsonl` files as the starting cache and write newly downloaded data to a unique `logs-<unix-time>-<random>.jsonl` file. With `--start-date` or `--end-date`, wildcard cache files that contain no in-range run records are deleted. |
There was a problem hiding this comment.
This doc example also has the unquoted-glob problem: `--cached-logs logs-*` will be expanded by the user's shell before the CLI parses it (unless there happen to be zero matching files, or the user manually quotes it themselves). Please update the doc to show the quoted form, `--cached-logs 'logs-*'`, so users copying this example get the intended wildcard-cache behavior instead of a shell-expanded argument.
@copilot please address this.
There was a problem hiding this comment.
Updated the setup documentation to quote 'logs-*' and precisely describe deletion of exclusively dated, out-of-range shards in ab5f905.
|
@copilot reviewers left actionable feedback on the wildcard cache docs/help text for this PR. Please address these items, then run the
Recent review links:
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "github.com"See Network Configuration for more information.
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed all linked help/docs feedback and pushed ab5f905. Wildcards are now quoted, pruning language matches the implementation, validation passed, and the |
|
🎉 This pull request is included in a new release. Release: |
gh aw logs --cached-logsnow supports prefix wildcard cache inputs, allowing runs to reuse all matching JSONL cache shards and write fresh data to a collision-resistant new shard.Wildcard cache input
logs-*.*.jsonlfiles as the starting cache.Unique cache output
Date-range pruning
Cache merge behavior
CLI surface
--cached-logsas an alias for cached JSONL logs.