Repository navigation
Add --jsonl reporting to update and upgrade - #79083
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
✅ 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.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Specification Reviewer completed successfully!
|
This comment has been minimized.
This comment has been minimized.
|
✅ 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.
|
There was a problem hiding this comment.
Reviewed head 3514f0dce350d8181de8efe9a6c8309a392ac4a4 against the new Update/Upgrade JSONL contract. The specification addition needs revision: (1) it lacks the repository's standard version/status/publication metadata; (2) the issue-event URL requirement is contradicted on API-response decode failures; (3) the net-result/no-duplicate file-event guarantee is not ensured by the snapshot path aggregation. See inline comments for evidence and requested corrections. No tests were run per static-review policy.
Generated by PR Specification Reviewer for #79083 · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review-specs to run again
|
|
||
| File fingerprints represent content unless `metadata_only` is `true`. Metadata-only fingerprints support reporting generated agent artifacts without reading their contents; they are not content-integrity hashes. | ||
|
|
||
| Changes describe the net result of the operation rather than every intermediate write. A file can produce both a file-change message and separate source, compiler, or dependency-pin messages. Consumers MUST NOT count each metadata transition as another changed file. |
There was a problem hiding this comment.
This normative net-result claim is not guaranteed by the implementation: updateJSONLFilePaths appends keys from both snapshots and calls slices.Compact without sorting the combined list, so a path present in both snapshots can be emitted more than once. Please fix the implementation or weaken/clarify this contract; otherwise changed_files and file-event consumers can observe duplicates.
There was a problem hiding this comment.
Fixed in 166d565: changed-file snapshots now emit each unique path once, and changed_files deduplicates by repository and path.
| | `warning` | A phase or per-item diagnostic, with category in `kind` and diagnostic in `error`. The command may continue; its terminal outcome is reported separately. | | ||
| | `codemod` | Codemods applied to `path`, listed in `codemods`. | | ||
| | `pull_request` | A pull request was created: `status` is `created` and `url` identifies it. | | ||
| | `issue` | An issue was created: `status` is `created` and `url` identifies it. | |
There was a problem hiding this comment.
The contract says every issue event has a URL identifying the created issue, but reportCreatedOrgIssue emits this event even when decoding the API response fails, leaving url empty while returning an error. Either make the implementation guarantee this invariant or specify the failure event semantics explicitly; otherwise consumers cannot rely on this requirement.
There was a problem hiding this comment.
Clarified in 166d565: an issue event includes an error when the created issue response lacks a decodable URL, and the command reports the response failure.
| @@ -0,0 +1,115 @@ | |||
| --- | |||
| title: Update and Upgrade JSONL Specification | |||
There was a problem hiding this comment.
This new specification omits the repository's established normative metadata (Version, Status, Publication Date, editor, and version links), so consumers cannot identify the contract revision or status. Please add the standard specification metadata before treating this as the public contract.
There was a problem hiding this comment.
Added the standard version, status, publication date, editor, and version-link metadata in 166d565.
Comment MemoryPeek at saved memory (spec-review-history)History |
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (>100 new lines) but does not have a linked Architecture Decision Record (ADR). 📄 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. ❓ Why ADRs Matter
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 ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found three blocking correctness issues in the JSONL implementation: strict parsing of relaunched stdout can fail after side effects, snapshot setup makes --jsonl alter command execution, and PR creation errors conflate reporting failures with an already-created PR. Please address these before merge. Review was static; no tests or builds were run.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~8 AIC · ⌖ ~2 AIC · ⊞ 1.5K
Comment /review to run again
| if err != nil { | ||
| return nil, err | ||
| } | ||
| before, err := captureUpdatePRFiles(ctx, dir) |
There was a problem hiding this comment.
Because this snapshot is performed only when --jsonl is enabled, failures from git root discovery, file enumeration, or metadata parsing now abort an otherwise runnable update/upgrade solely due to the reporting flag. That makes observability alter execution semantics and prevents consumers from receiving a terminal JSONL result. Consider treating snapshot setup as best-effort: emit a warning (or disable change observation) and continue the underlying command.
There was a problem hiding this comment.
Fixed in 166d565: snapshot setup/finalization failures emit a warning and no longer abort the underlying update or upgrade.
| _ = switchPRBranch(currentBranch, verbose) | ||
| return "", fmt.Errorf("failed to create PR: %w", err) | ||
| } | ||
| outputErr := emitUpdateEvent(ctx, updateJSONLEvent{Event: "pull_request", Status: "created", URL: prURL}) |
There was a problem hiding this comment.
The PR has already been created when this event is written, but a stdout failure is returned as the PR-creation error. Callers can therefore treat an existing PR as failed and retry or abort subsequent handling, risking duplicates or inconsistent state. Please keep reporting failures separate from the remote creation result (for example record them on the command-level reporter) so a successful creation remains successful while the JSONL stream failure is surfaced at the command boundary.
There was a problem hiding this comment.
Fixed in 166d565: PR creation remains successful when event writing fails; the reporter surfaces the write error at command completion.
| line, rest, found := bytes.Cut(w.pending, []byte{'\n'}) | ||
| if !found { | ||
| break | ||
| } |
There was a problem hiding this comment.
This replaces the relaunched process's stdout with a strict JSON parser, so any incidental stdout (for example a legacy diagnostic or library output) makes the forwarder fail before valid events are consumed. Since the child may already have applied changes or created a PR, the parent then reports a failed upgrade for a successful side effect. Please isolate the machine stream (for example a dedicated pipe/FD) or preserve non-event output separately rather than aborting the whole operation on the first non-JSON line.
There was a problem hiding this comment.
Fixed in 166d565: the relaunch forwarder ignores non-event stdout lines and forwards only supported JSONL events, so incidental child output does not fail the upgrade.
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd, requesting changes on one verified defect that breaks the JSONL transport contract.
Note: pr-triage output was unavailable, so skill selection used the fallback heuristic on the changed files.
📋 Key Themes & Highlights
Key Themes
- Stdout routing (blocking): JSONL goes to stderr, so
gh aw update --jsonlandupgrade --jsonlemit nothing on stdout. Verified by running the built binary with stdout and stderr captured separately. - Test gap:
runUpdateJSONLCommandbuilds standalone commands that never inherit the rootSetOut(os.Stderr), so the regression was not caught. A root-command regression test is needed. - Minor:
pkg/cli/pr_command_test.gohas two consecutiveif tc.createFailsblocks that can be merged.
Positive Highlights
- ✅ The
command_started/command_completedlifecycle is correct, including the flag-conflict error path. - ✅ Relaunch keeps
ValidateExecutablePathviaresolveUpgradeRelaunchExecutable, and the nil-context and deferred extensionchangeevent are safe. - ✅ The
repository_completedemitters are mutually exclusive, and thepull_requestevent fires before auto-merge.
@copilot please address the inline review comment above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~11 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| defer func() { s.restore(cmd, originalContext, originalSilenceUsage, runErr) }() | ||
| cmd.SilenceUsage = true | ||
| worker, _ := cmd.Flags().GetBool("rollout-worker") | ||
| reporter := &updateJSONLReporter{writer: cmd.OutOrStdout(), command: cmd.Name(), worker: worker} |
There was a problem hiding this comment.
[/diagnosing-bugs] JSONL events are written to stderr, not stdout, so gh aw update --jsonl > out.jsonl produces an empty file. cmd.OutOrStdout() inherits the root writer, and cmd/gh-aw/main.go calls rootCmd.SetOut(os.Stderr). The spec (Transport section) requires JSON Lines on stdout.
💡 Reproduction and fix
I built the binary and ran gh-aw update --jsonl --no-compile with stdout and stderr captured separately. Stdout had 0 lines and all command_started, human, and command_completed events were on stderr. upgrade --jsonl behaves the same way.
Write to os.Stdout explicitly for the JSONL reporter, and keep the human output path separate. Add a regression test that runs through the root command (with SetOut(os.Stderr)) and asserts the events land on os.Stdout. The current runUpdateJSONLCommand helper builds standalone commands that never inherit the root redirect, which is why this slipped through.
@copilot please address this.
There was a problem hiding this comment.
Fixed in 166d565: JSONL defaults to process stdout even when the configured root routes human output to stderr; added a root-command regression test.
There was a problem hiding this comment.
🟡 Changes recommended
JSONL events are sent to stderr instead of the documented stdout stream, and upgrade cancellation can kill the child process before cleanup completes.
9 open issues
Send JSONL events to stdout by default · New Interrupt relaunched CLI to allow cancellation cleanup · New Separate stdout from stderr when parsing the issue response · New Emit warnings for best-effort container pin failures · New Preserve complete framed worker events beyond the 8 MiB limit · New Allow JSONL updates in directories without a Git checkout · New Include effective package targets in changed-file snapshots · New Emit checkout-relative paths in repository preview events · New Emit repository-relative paths in codemod events · New
What changed in this PR
Adds machine-readable JSON Lines reporting to gh aw update and gh aw upgrade, helping automation track repository changes, outcomes, and created pull requests or issues.
Changes:
- Introduces versioned events for command lifecycles, file changes, dependency transitions, warnings, and delivery URLs.
- Integrates reporting with organization workers, extension relaunches, and partial failures.
- Adds reporting tests and documents the event contract and flag compatibility.
| File | Description |
|---|---|
pkg/cli/upgrade_org.go |
Propagates reporting context through upgrade worker results. |
pkg/cli/upgrade_command.go |
Registers JSONL and reports codemods, warnings, and relaunch events. |
pkg/cli/update_workflows.go |
Emits per-workflow failure warnings. |
pkg/cli/update_pr_summary.go |
Captures source SHAs for transition reporting. |
pkg/cli/update_jsonl.go |
Defines events, command lifecycle handling, and change observation. |
pkg/cli/update_jsonl_transport.go |
Forwards relaunch and organization-worker events. |
pkg/cli/update_jsonl_test.go |
Covers reporting, failures, subprocesses, and command reuse. |
pkg/cli/update_extension_check.go |
Reports extension version changes. |
pkg/cli/update_command.go |
Observes update changes and propagates reporting context. |
pkg/cli/update_actions_lockfile.go |
Reports failed action-version checks. |
pkg/cli/pr_helpers.go |
Emits created PR URLs before later operations. |
pkg/cli/pr_command_test.go |
Verifies PR creation events across failure paths. |
pkg/cli/org_runner.go |
Reports previews and per-repository outcomes. |
pkg/cli/org_rollout.go |
Includes worker events in rollout results. |
pkg/cli/org_rollout_flags.go |
Excludes the continuation flag from worker arguments. |
pkg/cli/org_rollout_discovery.go |
Preserves reporting context for worker outcomes. |
pkg/cli/org_issue_pr_helpers.go |
Emits issue creation events from API responses. |
docs/src/content/docs/specs/update-upgrade-jsonl-specification.md |
Defines the event schema, compatibility, and failure semantics. |
docs/src/content/docs/setup/cli.md |
Documents --jsonl and links the specification. |
Review effort: Max (adaptive)
| defer func() { s.restore(cmd, originalContext, originalSilenceUsage, runErr) }() | ||
| cmd.SilenceUsage = true | ||
| worker, _ := cmd.Flags().GetBool("rollout-worker") | ||
| reporter := &updateJSONLReporter{writer: cmd.OutOrStdout(), command: cmd.Name(), worker: worker} |
There was a problem hiding this comment.
Fixed in 166d565: JSONL uses stdout by default while preserving explicit writer injection, and the test exercises a command attached to a stderr-configured root.
| // plus a hardcoded flag; exec.Command passes arguments directly to execve(2) without | ||
| // invoking a shell, so shell-injection (CWE-78) is not possible regardless of argv content. | ||
| cmd := exec.Command(exe, newArgs...) | ||
| cmd := exec.CommandContext(ctx, exe, newArgs...) |
There was a problem hiding this comment.
Fixed in 166d565: canceled relaunches send an interrupt with a kill fallback and bounded wait; the subprocess test verifies cleanup runs.
| newContainerPins, err = updateContainerPins(ctx, defaultContainerPinUpdateDeps(), opts.WorkflowsDir, opts.Verbose, containerPinUpdateOptions{refreshExisting: true}) | ||
| } | ||
| if err != nil { | ||
| reportUpdateWarning(ctx, "containers", err) |
There was a problem hiding this comment.
Fixed in 166d565: the shared container-pin helper emits a structured warning for best-effort registry resolution failures.
| result.Events = r.events | ||
| runErr = errors.Join(runErr, emitOrgRolloutResult(result)) |
There was a problem hiding this comment.
Fixed in 166d565: worker result frames are retained separately from the bounded diagnostic tail; a regression test covers a frame larger than 8 MiB.
| if dir == "" { | ||
| dir = getWorkflowsDir() | ||
| } | ||
| workflowPrefix, err := updateJSONLWorkflowPrefix(dir) |
There was a problem hiding this comment.
Fixed in 166d565: JSONL snapshots fall back to filesystem enumeration when no Git checkout is available, without blocking local updates.
| if err != nil { | ||
| return nil, err | ||
| } | ||
| before, err := captureUpdatePRFiles(ctx, dir) |
There was a problem hiding this comment.
Fixed in 166d565: package ownership destinations are resolved before snapshots and included in both snapshots; paths are validated within the checkout.
| } | ||
| for _, wf := range preview.Workflows { | ||
| if err := emitUpdateEvent(ctx, updateJSONLEvent{ | ||
| Event: "repository_preview", Repository: preview.Repo, Path: wf.Path, |
There was a problem hiding this comment.
Fixed in 166d565: organization preview paths are now checkout-relative and slash-normalized before the preview is emitted.
| if reporter := updateReporter(opts.ctx); reporter != nil { | ||
| reporter.recordError(emitUpdateEvent(opts.ctx, updateJSONLEvent{Event: "codemod", Path: filepath.ToSlash(file), Codemods: fixes})) | ||
| } |
There was a problem hiding this comment.
Fixed in 166d565: codemod event paths are now repository-relative and slash-normalized.
|
Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error. 🍳 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": "532c45050fb078af6c4473d1145edb9a7b74a706",
"kind": "requested",
"schema_version": "1",
"state": "b4d7780a6cc64c37451c088f05711cdd67326e5b7afb8cb4dceb9df2fae88dad",
"work": [
"0fd6b4391c0617ca4e012c65c10fc047dfb852a959457c0088e28a2691d87a65",
"16b1f9238d7c29235aee299a6a654a2070cf8853425014443c338d019b579dca",
"1843655c147341cc907a24329075e269388e658e995a804cbef3383c46b42b18",
"22585d7bdf5cad548c9327ad80e20f5390a5bdbd8e5a0216cb7557a057233bd5",
"481dde15d3aed727fe247417f7e322b0c1788d1dbd60131741fc3b2b18f69f95",
"6eac98ce7bb2139ead1c6b9f4174b930f6b133c6f2b1c7ff0f0882efac147bd0",
"7566fe9c6f8cd6e00f535e94acf37b0862a68f7c198dc314f3430ce7f3422472",
"7e3d977c483c0dde0339addda9c577282a7c64d36bb2bb6d3ae21314b8ba270f",
"86ddbe9c5bbb91c7b4f4d934f70001eef2f58d6660dac1df14808e464dd42232",
"87af0f36a906d9e3ecab85a341128eda469a9d31030a081fb13ecc151fa4abe1",
"9712af9a3b14535c02b666451a719212faf10f6a6a12c30de8cc286e7e310358",
"9cf4dd6fb9e21dbcaac22e9baf097f0e1ac95d5fa5b24cb3e89225fa897da7d9",
"bbf09f6222a080b6b1f5a1f1652675d68ac419032c7751117362031c06aa3d80",
"c9d9e68c337829156abb138c3cbc2393549d604db55ec263b200c431cc12b720",
"ca8c4034a52d070200b4c5bce4176994fa75ad52129085261b4aee098af53dd7",
"ede0fadb8f8cc110ef19d44028100cb89bdcb4022b3bf50dec8183992674c3b8",
"f7883e8c8105930e955354caa741d783bcca067e66097fe9612fb72b90823998"
],
"workflow": "pr-sous-chef"
}
|
…put-structure Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Completed the requested merge and linked review fixes in |


Add
--jsonltogh aw updateandgh aw upgradeso consumers can reliably identify changes, repository outcomes, and newly created PRs or issues.Extract created PR URLs: