You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request changes the `gh aw logs` cache behavior in `pkg/cli/` so callers can pass a trailing wildcard cache prefix such as `logs-*` instead of a single JSONL file. The implementation now merges multiple matching cache shards, chooses a collision-resistant output shard name, and prunes wildcard source files that contain only out-of-range dated run records when a date filter is applied. The PR also adds a `--cached-logs` CLI alias, updates user-facing help text, and extends tests around wildcard resolution, shard ordering, and pruning. The architectural question is how the logs command should represent reusable cached run data when repeated collections produce multiple partial cache files over time.
12
+
13
+
### Decision
14
+
15
+
We will treat cached logs JSONL inputs as either a single file or a trailing-wildcard shard prefix, and in wildcard mode we will load all matching `.jsonl` shards as the starting cache while writing fresh results to a new uniquely named shard. We decided to sort matching shards deterministically, let newer shards override duplicate cached run and workflow-list records, and prune fully out-of-range dated shards after collection when a date range is requested. This approach was chosen because the PR evidence shows a need to reuse accumulated cache history safely without overwriting existing shards or keeping obviously stale wildcard cache files forever.
16
+
17
+
### Alternatives Considered
18
+
19
+
#### Alternative 1: Keep a single append-only cached JSONL file
20
+
21
+
The logs command could continue requiring one explicit cache file and append every new record into that same file. This was considered because it is the simplest mental model and avoids wildcard resolution, duplicate handling, and shard cleanup logic. It was not chosen because the PR adds unique shard output names and wildcard loading specifically to avoid collisions and let multiple cache fragments be reused together.
22
+
23
+
#### Alternative 2: Support arbitrary glob patterns for cache discovery
24
+
25
+
Another option would be to accept any glob expression for cache inputs rather than only a trailing prefix wildcard. This was considered because it would give users more flexibility in how they organize cache files. It was not chosen because the implementation intentionally rejects non-trailing wildcard patterns, which keeps discovery rules predictable and allows the writer to derive a safe output prefix for new shard creation.
26
+
27
+
#### Alternative 3: Merge wildcard sources and rewrite one consolidated cache file
28
+
29
+
The command could read several cache shards, combine them in memory, and then rewrite a single consolidated JSONL file as the new cache state. This was considered because it would leave users with one canonical cache artifact after each run. It was not chosen because the diff explicitly preserves existing shards, writes only newly downloaded data to a fresh file, and prunes only shards proven irrelevant to the requested date range.
30
+
31
+
### Consequences
32
+
33
+
#### Positive
34
+
- Users can reuse multiple cached logs shards in one invocation, which makes incremental log collection more resilient across repeated runs.
35
+
- New cache output files avoid name collisions and preserve prior cache artifacts instead of overwriting them.
36
+
- Date-range pruning removes wildcard shards that contain only out-of-range dated run records, reducing stale cache buildup.
37
+
38
+
#### Negative
39
+
- Cache handling becomes more complex because the command now resolves wildcard prefixes, merges shards, sorts them, and warns on duplicate records.
40
+
- Duplicate cached runs or workflow-list payloads are resolved by last-wins behavior, which can hide older conflicting data behind warning messages.
41
+
- Wildcard pruning relies on record structure and timestamps, so unusual or metadata-only files are intentionally preserved and may still accumulate.
42
+
43
+
#### Neutral
44
+
- The CLI surface grows by one alias, `--cached-logs`, while preserving `--cached-jsonl` compatibility.
45
+
- The implementation extends existing JSONL cache mechanisms rather than introducing a new cache format or storage backend.
46
+
- Additional tests now codify shard naming, wildcard validation, deterministic ordering, and date-range cleanup behavior.
47
+
48
+
---
49
+
50
+
*ADR created by [adr-writer agent]. Review and finalize before changing status from Draft to Accepted.*
`logs`defaults `--artifacts` to `usage` for faster, compact downloads. The `--last` flag is an alias for `--count/-c`.
516
516
When multiple targets run concurrently, `--count` limits the combined number of workflow runs and `--timeout` limits the total wall-clock download time across all targets.
517
517
518
-
`--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.
518
+
`--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.
519
+
520
+
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 containing exclusively dated run records outside the requested range are deleted.
0 commit comments