Skip to content

test(desktop): wait for synthetic application children readiness before exercising sigterm release - #10455

Closed
LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/desktop-cleanup-test-10366
Closed

LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/desktop-cleanup-test-10366

Conversation

@LexLuthorPrimero

@LexLuthorPrimero LexLuthorPrimero commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #10366.

The synthetic Linux desktop cleanup test sent SIGTERM at 1.5 seconds after state.ini was written, but it never verified that the fake application's child processes (the same-group trap child and the setsid child) had installed their TERM handlers by the time the signal arrived. One CI job observed a flake where setsid-term was absent even though the cleanup contract was fulfilled and the same test succeeded on a retry of the same run.

Change and scope

  • The fake application now waits for both children to install their traps before writing state.ini and before entering its main loop. Both children touch a *-ready marker immediately after installing their trap; a bounded for i in $(seq 1 100) loop in the parent waits for both markers (≤ ~1 s, typically ≤ 20 ms).
  • The nextRequest callback in the stop test now returns { kind: "stop" } only when state.ini shows count=1 AND both readiness markers exist — so captureDesktopApplication never exercises termination before the children are ready to terminate.
  • Strength of assertions is unchanged: both group-term and setsid-term markers are still required after the process release, and { verified: true, reason: null } is still required.

Evidence and regression coverage

  • npx vitest run src/application/desktop/DesktopApplicationCapture.test.ts — 32 passed.
  • npm run typecheck — passed. npm run format:check — passed. npm run lint — passed.
  • This does not affect any production path; the fixture and test were the only files modified.

Remaining proof gaps

  • The GitHub CI flake was not reproducible on this host, so the fix is prevention by construction; no repeat observation of the exact CI failure exists.
  • No statement is made about the cause of observed failures beyond the narrow readiness/scheduling race already documented in the issue.

Compatibility, safety, and release

  • Breaking changes: none. Test fixture change only.

Author readiness

Human owner: @LexLuthorPrimero

  • 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T02:48:22.759718Z e026edf PR opened
ℹ️ 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 Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] No new blocking issue was found; the earlier non-blocking readiness finding remains open.

Findings

  1. P2 Readiness wait can fall through ▶
Fix with agent prompt
### Issue 1
src/application/desktop/DesktopApplicationCapture.test.ts:147-148
The loop writes `count=1` after 100 attempts even when a child is not ready. The other `installProcessFamily` caller-the session-failure test-still starts cleanup based only on `count=1`. If child startup takes longer than this wait on a busy runner, cleanup can send `SIGTERM` before the child's trap is installed, leaving the same missing-marker flake.

Require both markers before publishing `count=1`, and report a clear startup failure if the wait expires.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This test-only change adds readiness markers so the synthetic application's children can install their TERM traps before the stop test requests cleanup.

  • The process-release test waits until both children are ready before stopping.

Reviews (2) · Last reviewed commit: "test(desktop): wait for synthetic applic..." · Reviewed by Greptile

Comment on lines +147 to +148
`for i in $(seq 1 100); do [ -f "${join(root, "group-ready")}" ] && [ -f "${join(root, "setsid-ready")}" ] && break; sleep 0.01; done`,
'printf "count=1\n" > "$HOME/.config/fakeapp/state.ini"',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Readiness wait can fall through

The loop writes count=1 after 100 attempts even when a child is not ready. The other installProcessFamily caller—the session-failure test—still starts cleanup based only on count=1. If child startup takes longer than this wait on a busy runner, cleanup can send SIGTERM before the child's trap is installed, leaving the same missing-marker flake.

Require both markers before publishing count=1, and report a clear startup failure if the wait expires.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/desktop/DesktopApplicationCapture.test.ts
Line: 147-148

Comment:
**Readiness wait can fall through**

The loop writes `count=1` after 100 attempts even when a child is not ready. The other `installProcessFamily` caller—the session-failure test—still starts cleanup based only on `count=1`. If child startup takes longer than this wait on a busy runner, cleanup can send `SIGTERM` before the child's trap is installed, leaving the same missing-marker flake.

Require both markers before publishing `count=1`, and report a clear startup failure if the wait expires.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e026edf19a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +665 to +667
!fileExists(join(root, "group-ready")) ||
!fileExists(join(root, "setsid-ready"))
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail promptly when the readiness handshake is absent

On the Linux source-test path, if either child never creates its readiness marker (for example, the setsid launch fails), this callback keeps returning undefined while fakeapp loops. The capture's 60-second duration exceeds the source Vitest deadline of 30 seconds, so the test times out before reaching its cleanup assertions. Add a bounded failure or stop outcome for a missing marker instead of polling until the test runner kills the case.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
…re exercising sigterm release

Fixes #10366
Supersedes #10455

Co-Authored-By: gensokyo-dev <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
…re exercising sigterm release

Fixes #10366
Supersedes #10455

Co-Authored-By: gensokyo-dev <[email protected]>
@N0zoM1z0

N0zoM1z0 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you! Your readiness wait landed in #10568 as 97c7582 (rebase-merged, authorship kept), which fixes #10366. Follow-ups a422353 and 1ba93b4 make the synthetic app fail visibly, and the test fail promptly, when its children never get ready instead of the wait giving up silently. Closing as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added the area: tests Test suite and verification label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Linux desktop cleanup test misses detached-child SIGTERM marker in CI

3 participants