Skip to content

test(captures): cover retained cleanup lifecycle - #2992

Closed
maxazure wants to merge 4 commits into
morluto:mainfrom
maxazure:fix/capture-cleanup-launch-identity-2656
Closed

maxazure wants to merge 4 commits into
morluto:mainfrom
maxazure:fix/capture-cleanup-launch-identity-2656

Conversation

@maxazure

@maxazure maxazure commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve capture cleanup lifecycle coverage after the production fix was incorporated on main in 599a8ee11, which references this PR. Related: #2656.

Problem and expected behavior

Unresolved process cleanup must retain launch identity and block workspace removal. Once process cleanup succeeds, a remaining workspace failure must report only the workspace and must not retry the settled owner. Successful cleanup must make repeated close harmless, and public pendingPaths must survive failed cleanup and clear after success.

Change and scope

Merged main d9cd239 without rewriting history. The effective diff is only tests/boundary/captures/captureProvider.test.ts: three production-service lifecycle scenarios and one public getter lifecycle test. Production files match that main revision. Retry assertions express ordering and state rather than fixed invocation totals.

Evidence and regression coverage

Main has retained-launch diagnostic coverage but lacks these lifecycle combinations and pendingPaths assertions. This supplement protects the corrected behavior; current main already contains the fix. The capture seam is inert and refuses process signaling.

Validation performed

Verified the exact tree published at head fff9c6d in an assistant-cloud Linux checkout with Node 24.18.0 / npm 11.16.0:

  • npm ci and required runtime build passed.
  • Focused regression tests: 7 files, 89 tests passed, no skips.
  • npm run check and npm run check:fast passed.
  • npm run verify:test-discovery passed (1,291 files); git diff --check passed.
  • The effective test-only diff is byte-for-byte unchanged after merging main.

The previous CI failures were matched by full test name against failing push CI 38505561204 on the exact old base 5830088. This refresh incorporates upstream fixes; Current-head CI completed successfully on 2026-10-14. Source tests, all five boundary shards, portable inventory and CI required passed. The separate PR readiness status has not yet appeared on this head.

Normal local commit hooks ran but auto-fixed two unrelated upstream tests. Those unrelated edits were excluded from publication. The GitHub-published merge tree exactly matches the tree tested above; original branch history is preserved.

Contract and boundary impact

  • Semantic owner: existing production owners are unchanged; only regression tests change.
  • Contribution scope: focused coverage within existing capture/JEB boundaries; a new capability scope decision is not applicable.
  • CLI/MCP, Evidence, provider compatibility and generated metadata: unchanged by the effective diff.
  • Test effects: disposable fixture files and existing fixture Node subprocesses; no caller target, real engine or external service is acquired.

Compatibility, safety, and release

No production, package, installation or breaking change. The tests use injected provider seams; they do not establish real-engine or native-platform behavior. Independent review inspected the final code and validation logs; it did not independently execute tests.

Before merge

  • Focused regression coverage with resolved scope and authority.
  • Related issue linked; effective diff checked for unrelated changes and secrets.
  • Relevant checks passed locally; real-provider verification limits stated.
  • Required CI passes for the current head.

Author readiness

Human owner: @maxazure

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

The human owner confirmed personal review and responsibility on 2026-10-14. The effective test-only diff is unchanged.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 19:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T21:57:29.150738Z 3173fa4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only PR appears safe to merge once required CI passes.

Summary

Adds four regression cases for retained capture cleanup.

  • Capture cleanup tests track unresolved owners until they finish.
  • Pending workspace paths stay listed until cleanup succeeds.

Reviews (5) · Last reviewed commit: "Merge upstream main to refresh CI baseli..." · Reviewed by Greptile

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

6 open findings
What changed in this PR

Updates capture cleanup diagnostics so unresolved retained-process cleanup reports the recorded launch identity (run id, pid, process group) alongside the workspace, and ensures subsequent retries preserve that identity until the process is settled.

Changes:

  • Derive cleanup_incomplete resource labels from retained ownership via ownedCommandResources.
  • Update cleanup error paths to surface process launch identity when still unresolved.
  • Add a boundary test covering unresolved process cleanup vs workspace-only failures and retry behavior.
File Description
tests/​boundary/​captures/​captureProvider.test.ts Adds a regression test ensuring cleanup errors and close() retries report the correct resource set depending on what remains unresolved.
src/​process/​ArtifactAnalysisResources.ts Produces resource labels from retained ownership (runId/pid/process-group) and uses them in cleanup error reporting.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

? [root.path]
: ownedCommandResources(ownership, root.path);
}

Comment on lines +138 to +140
return [...this.#pending.keys()].flatMap((root) =>
this.#resourcesFor(root),
);
Comment on lines +742 to +765
expect(cleanupCalls).toBe(failure !== "workspace" ? 2 : 1);
expect(rootCloses).toBe(failure !== "workspace" ? 0 : 1);
await expect(service.close()).rejects.toMatchObject({
cleanupResources: resources,
});
expect(cleanupCalls).toBe(failure !== "workspace" ? 3 : 1);
if (failure === "process-then-workspace") {
processSettled = true;
await expect(service.close()).rejects.toMatchObject({
cleanupResources: [root],
});
expect(cleanupCalls).toBe(4);
expect(rootCloses).toBe(1);
}
settled = true;
await service.close();
expect(cleanupCalls).toBe(failure !== "workspace" ? 4 : 1);
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
await service.close();
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
Comment on lines +742 to +765
expect(cleanupCalls).toBe(failure !== "workspace" ? 2 : 1);
expect(rootCloses).toBe(failure !== "workspace" ? 0 : 1);
await expect(service.close()).rejects.toMatchObject({
cleanupResources: resources,
});
expect(cleanupCalls).toBe(failure !== "workspace" ? 3 : 1);
if (failure === "process-then-workspace") {
processSettled = true;
await expect(service.close()).rejects.toMatchObject({
cleanupResources: [root],
});
expect(cleanupCalls).toBe(4);
expect(rootCloses).toBe(1);
}
settled = true;
await service.close();
expect(cleanupCalls).toBe(failure !== "workspace" ? 4 : 1);
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
await service.close();
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
Comment on lines +742 to +765
expect(cleanupCalls).toBe(failure !== "workspace" ? 2 : 1);
expect(rootCloses).toBe(failure !== "workspace" ? 0 : 1);
await expect(service.close()).rejects.toMatchObject({
cleanupResources: resources,
});
expect(cleanupCalls).toBe(failure !== "workspace" ? 3 : 1);
if (failure === "process-then-workspace") {
processSettled = true;
await expect(service.close()).rejects.toMatchObject({
cleanupResources: [root],
});
expect(cleanupCalls).toBe(4);
expect(rootCloses).toBe(1);
}
settled = true;
await service.close();
expect(cleanupCalls).toBe(failure !== "workspace" ? 4 : 1);
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
await service.close();
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
Comment on lines +742 to +765
expect(cleanupCalls).toBe(failure !== "workspace" ? 2 : 1);
expect(rootCloses).toBe(failure !== "workspace" ? 0 : 1);
await expect(service.close()).rejects.toMatchObject({
cleanupResources: resources,
});
expect(cleanupCalls).toBe(failure !== "workspace" ? 3 : 1);
if (failure === "process-then-workspace") {
processSettled = true;
await expect(service.close()).rejects.toMatchObject({
cleanupResources: [root],
});
expect(cleanupCalls).toBe(4);
expect(rootCloses).toBe(1);
}
settled = true;
await service.close();
expect(cleanupCalls).toBe(failure !== "workspace" ? 4 : 1);
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
await service.close();
expect(rootCloses).toBe(
failure === "process" ? 1 : failure === "workspace" ? 3 : 2,
);
@morluto morluto added area: runtime Process capture and runtime observation bug Something isn't working labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Retain unresolved process identity and launch evidence through retryable cleanup. Share capture path normalization and preserve failed filesystem observations. Bound child output and drain Windows pipes without one-chunk throttling.

Reviewed fixes include #1628, #2632, #2644, #2784, #2928, #2931, #2965, #2992, and #3011.

Validation: 92 focused source tests passed; four platform-specific skips. Real Windows and Hopper lifecycle coverage was not rerun.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@maxazure maxazure changed the title fix(process): preserve retained capture launch identity test(captures): cover retained cleanup lifecycle Oct 14, 2026
@maxazure maxazure closed this Oct 14, 2026
@maxazure maxazure reopened this Oct 14, 2026
@maxazure
maxazure marked this pull request as draft October 14, 2026 14:06
@maxazure
maxazure marked this pull request as ready for review October 14, 2026 20:06
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@maxazure maxazure closed this Oct 15, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@maxazure, thanks for preserving the lifecycle cases around failed and repeated capture cleanup after the production ownership fix landed. Those boundary cases remain with the process cleanup owner and protect the retry and settled-close behavior (main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants