Repository navigation
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds crash recovery around Copilot harness startup and resource diagnostics for /reflect.
Changes:
- Retries harness exits 134–139 with bounded backoff.
- Routes generated Copilot commands through the retry launcher.
- Logs memory snapshots around reflect requests and adds regression coverage.
Show a summary per file
| File | Description |
|---|---|
actions/setup/sh/copilot_harness_runner.sh |
Adds bounded crash retries. |
actions/setup/js/awf_reflect.cjs |
Adds reflect memory diagnostics. |
actions/setup/js/copilot_harness.cjs |
Re-exports the diagnostic helper. |
actions/setup/js/copilot_harness.test.cjs |
Tests diagnostics and exit-139 recovery. |
pkg/workflow/copilot_engine_execution.go |
Routes harness execution through the launcher. |
pkg/workflow/copilot_engine_test.go |
Verifies generated launcher commands. |
Review details
Tip
Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Balanced
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #51792 does not have the 'implementation' label and has only 21 new lines of code in business logic directories (threshold: 100).
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Test Quality Sentinel completed test quality analysis.
|
|
✅ PR Code Quality Reviewer completed the code quality 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. 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
- "api.individual.githubcopilot.com"See Network Configuration for more information.
|
🧪 Test Quality Sentinel Report✅ Test Quality Score: 82/100 — Excellent
📊 Metrics (4 tests)
📝 Test Analysis
i️ Inflation Note
Verdict
|
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd — requesting changes on two correctness issues and two test-coverage gaps.
📋 Key Themes & Highlights
Issues
- SIGKILL (exit 137) retry semantics — retrying an OOM-killed process wastes the budget silently; should log a distinct warning or be excluded from the retry range.
- Retry budget exhaustion not tested — the regression test only covers the happy path (1 crash → success); the budget-exhausted path (all retries consumed → exit with crash code) is untested.
- Backoff sleep path untested —
GH_AW_HARNESS_CRASH_DELAY_MS=0skips theprintf -vsleep format; a 1ms test case would catch format regressions. - Three identical runner-path Sprintf calls — extracting a helper would guard against future quoting drift across the three call sites in
copilot_engine_execution.go.
Positive Highlights
- ✅ Shell retry script is clean, bounded, and safe (
set -uo pipefailwithout-eis the right call here) - ✅ cgroup best-effort fallback pattern in
getReflectResourceSnapshotis correct - ✅ Regression test correctly exercises the script as a subprocess via
spawnSync, not a mock - ✅ Constant refactoring (
nodeRuntimeResolutionSetupCommand) cleanly untangles the node-exec setup from the invocation
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 45.2 AIC · ⌖ 7.22 AIC · ⊞ 7.1K
Comment /matt to run again
|
|
||
| case $status in | ||
| 134 | 135 | 136 | 137 | 138 | 139) | ||
| ;; |
There was a problem hiding this comment.
[/diagnosing-bugs] Exit 137 (SIGKILL) is included in the crash-retry range, but it typically means the OOM killer or an external kill -9 terminated the process — retrying immediately will likely exhaust the retry budget without recovering.
💡 Suggested fix
Remove 137 from the retry set, or at least log a distinct warning when retrying a SIGKILL exit:
case $status in
134 | 135 | 136 | 138 | 139)
;;
137)
echo "[copilot-harness-runner] harness killed (exit=137/SIGKILL); this may be OOM — retrying but success is unlikely" >&2
;;
*)
exit "$status"
;;
esacThis prevents silent budget exhaustion when the runner is out of memory.
@copilot please address this.
| @@ -0,0 +1,47 @@ | |||
| #!/usr/bin/env bash | |||
| # Do not enable -e: signal-style harness exits must be inspected and retried. | |||
There was a problem hiding this comment.
[/diagnosing-bugs] set -uo pipefail without -e is correct here, but the comment only says why -e is omitted. Consider also noting that set -u will cause the script to abort if GH_AW_HARNESS_CRASH_RETRIES or GH_AW_HARNESS_CRASH_DELAY_MS are unset and the ${VAR:-default} expansion is removed — the defaults below guard this, so it's fine, but a brief note would help future editors understand the contract.
Minor nit, no action required unless you agree it aids maintainability.
@copilot please address this.
| printf -v delay_seconds '%d.%03d' "$((delay_ms / 1000))" "$((delay_ms % 1000))" | ||
| sleep "$delay_seconds" | ||
| fi | ||
| done |
There was a problem hiding this comment.
[/diagnosing-bugs] The script is missing a final newline — done ends without a trailing \n. Most shells handle this fine, but some CI linters flag it and wc -l will under-count. Run echo '' >> copilot_harness_runner.sh or ensure your editor adds a trailing newline.
@copilot please address this.
| } | ||
| }); | ||
| }); | ||
|
|
There was a problem hiding this comment.
[/tdd] The crash-retry test uses GH_AW_HARNESS_CRASH_DELAY_MS: "0" to skip the sleep, which is great for speed. However it doesn't test the backoff path — a future change could accidentally break the sleep format string (printf -v delay_seconds) without being caught. Consider adding a second case with delay_ms=1 to exercise the sleep branch, even briefly.
💡 Example addition
it("completes with non-zero delay without hanging", () => {
// Just ensure the sleep printf path doesn't crash the script
const result = spawnSync("bash", [runnerPath, "/bin/bash", harnessPath, callsPath], {
env: { ...process.env, GH_AW_HARNESS_CRASH_RETRIES: "1", GH_AW_HARNESS_CRASH_DELAY_MS: "1" },
encoding: "utf8",
timeout: 5000,
});
expect(result.status).toBe(0);
});@copilot please address this.
| external: expect.any(Number), | ||
| cgroupCurrent: expect.any(String), | ||
| cgroupMax: expect.any(String), | ||
| }) |
There was a problem hiding this comment.
[/tdd] The retry test only covers the happy path (1 crash → 1 retry → success). It doesn't cover budget exhaustion (all retries consumed → last crash exit code is forwarded). This is the other half of the recovery contract and a likely regression point.
💡 Suggested additional case
it("exits with crash code when retry budget is exhausted", () => {
// harness always exits 139
fs.writeFileSync(harnessPath, `#!/usr/bin/env bash\nexit 139\n`, { mode: 0o755 });
const result = spawnSync("bash", [runnerPath, "/bin/bash", harnessPath], {
env: { ...process.env, GH_AW_HARNESS_CRASH_RETRIES: "1", GH_AW_HARNESS_CRASH_DELAY_MS: "0" },
encoding: "utf8",
});
expect(result.status).toBe(139);
expect(result.stderr).toContain("crash retry budget exhausted");
});@copilot please address this.
| return fmt.Sprintf(`%s; "%s/copilot_harness_runner.sh" "$GH_AW_NODE_EXEC" %s %s`, runtimeResolutionCommand, SetupActionDestinationShell, harnessScriptPath, commandName) | ||
| } | ||
|
|
||
| func (e *CopilotEngine) buildCopilotSDKExecPrefix(workflowData *WorkflowData, commandName, harnessScriptPath, runtimeResolutionCommand string) string { |
There was a problem hiding this comment.
[/codebase-design] The generated shell fragment now embeds copilot_harness_runner.sh via SetupActionDestinationShell in three separate Sprintf calls (lines 379, 394, 404). If the runner path or quoting convention needs to change, all three sites must be updated in sync. Extracting a small helper — e.g. buildHarnessRunnerPrefix(nodeExec, harnessPath string) string — would make the interface shallower and reduce future drift.
💡 Sketch
func buildHarnessRunnerPrefix(harnessRunnerPath, harnessScriptPath, commandName string) string {
return fmt.Sprintf(`"%s" "$GH_AW_NODE_EXEC" %s %s`, harnessRunnerPath, harnessScriptPath, commandName)
}The three call sites then become single-line delegations, and the quoting lives in one place.
@copilot please address this.
There was a problem hiding this comment.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 47.4 AIC · ⌖ 6.38 AIC · ⊞ 5.4K
| set -uo pipefail | ||
|
|
||
| if (( $# < 3 )); then | ||
| echo "[copilot-harness-runner] usage: <node> <harness> <command> [args...]" >&2 |
There was a problem hiding this comment.
Minor: the usage message says <node> <harness> <command> [args...] but after shift 2 the script passes "$@" directly to node — there is no distinct <command> positional; it is just the first of the pass-through args. Consider usage: <node> <harness> [args...] to avoid confusion.
Non-blocking cosmetic fix. @copilot please address this.
There was a problem hiding this comment.
Generated by ✂️ Ponytail Reviewer for #51792 · auto · 40.3 AIC · ⌖ 7.42 AIC · ⊞ 6.8K
Comment /ponytail to run again
| extractModelIds, | ||
| fetchAWFReflect, | ||
| fetchModelsFromUrl, | ||
| getReflectResourceSnapshot, |
There was a problem hiding this comment.
L71,1490: yagni: getReflectResourceSnapshot re-imported and re-exported here but never invoked in this file. Drop the import/export, keep it only in awf_reflect.cjs.
| return e.buildCopilotSDKExecPrefix(workflowData, commandName, harnessScriptPath, runtimeResolutionCommand) | ||
| } | ||
| return fmt.Sprintf(`%s %s %s`, runtimeResolutionCommand, harnessScriptPath, commandName) | ||
| return fmt.Sprintf(`%s; "%s/copilot_harness_runner.sh" "$GH_AW_NODE_EXEC" %s %s`, runtimeResolutionCommand, SetupActionDestinationShell, harnessScriptPath, commandName) |
There was a problem hiding this comment.
L376,394,404: yagni: same "%s/copilot_harness_runner.sh" "$GH_AW_NODE_EXEC" ... prefix duplicated 3x with varying trailing args. One helper runnerPrefix := fmt.Sprintf("%s; \"%s/copilot_harness_runner.sh\" \"$GH_AW_NODE_EXEC\"", runtimeResolutionCommand, SetupActionDestinationShell) then append args, 1 shared definition.
The Copilot Node harness can terminate with exit 139 during
/reflectpreflight, bypassing its in-process retry loop and failing the workflow before Copilot starts.Crash recovery
Reflect diagnostics
/reflectfetches.Regression coverage
/reflect.