Skip to content

test(adoption): handshake real-child waits and size generation budgets for load (HACK-1319) - #551

Merged
roodboi merged 2 commits into
nextfrom
kit/hack-1319-adoption-test-flakes
Nov 3, 2026
Merged

roodboi merged 2 commits into
nextfrom
kit/hack-1319-adoption-test-flakes

Conversation

@roodboi

@roodboi roodboi commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes HACK-1319. This changes tests only: no product timeout or product code changes.

Findings

"moving job snapshot" fails locally (environmental, not a product defect). When the ticket was filed, this case's ordered start had a fixed 20 s deadline and a 30 s test limit. On the pre-#487 test at load average ~100, it timed out after 30 s; at ~58 it finished in 18 s of its 20 s deadline. Each fake Docker query is a cold Bun process, so the start was budgeting host process start-up, not product behavior. #495 (HACK-1452) already sizes that deadline from the counted freshness checks (ORDERED_START_FRESHNESS_CHECKS). On this branch's base, the case passed in every loaded full-file run below. This PR does not change it.

"real child" tests used wall-clock waits.

  • The cancellation tests waited at most 15 s for the hanging fake Docker child to publish its PID. Under load the acquisition alone took ~14 s before its first probe, so the wait expired.
  • The timeout test armed a 150 ms probe deadline. The probe reads Date.now() when it is created and spawns later, so a stall between the two could use up the whole deadline before any child existed (children.length > 0 failed).

Generation v5/v7 (and static7) cases outgrew their 20/30/60 s limits. With every limit lifted at load average ~90 (20 cores), the slowest cases took 27 s (plain saved adoption), 44 s (retained operations) and 60 s (public static7 up/down). The public adopted command gives each operation a 90 s deadline (DEFAULT_COMPOSE_STARTUP_TIMEOUT_MS), but those tests allowed 60 s in total. A Bun timeout leaves the owner running, so the file's settlement guard makes every later case refuse: one timeout produced 118 failures.

Changes

tests/native-compose-adoption-binding.test.ts

  • startedChild(pending) is a handshake: it returns when the child publishes its PID, and fails with a distinct message if the operation settles first. It has no clock of its own. Both cancellation tests give their probe CANCELLED_CHILD_PROBE_DEADLINE_MS (60 s, the largest deadline the product admits), so only the abort ends it.
  • The timeout test pins Date.now() (setSystemTime) while it acquires. The probe then arms its whole EXPIRING_PROBE_DEADLINE_MS (150 ms) as a real timer after the spawn, so there is always a child to reap. The clock is restored in finally, and the reaping assertions are unchanged.

tests/native-compose-adoption-generation.test.ts

  • Named budgets replace the literals:
    • ADOPTION_CASE_TIMEOUT_MS: 120 s, for saved-adoption and CLI cases (~4× the measured worst).
    • RETAINED_OPERATION_DEADLINE_MS: the public command's 90 s deadline, replacing the 16 Date.now() + 20_000 caller deadlines.
    • retainedOperationCaseTimeout(n): adoption budget plus one deadline per operation, so a slow host ends in the product's own refusal before Bun's timeout.
  • Expiry cases name EXPIRING_OPERATION_DEADLINE_MS (15 s, was 5 s, so the pre-callback probes fit) and DEADLINE_REFUSAL_SLACK_MS (5 s, was 1.5 s). The cancelled-effect bound is named CANCELLED_EFFECT_REFUSAL_BOUND_MS (10 s, was 4 s). It stays far below the 60 s fake child and the deadline, so only cancellation can satisfy it.
  • Hanging fake children publish PIDs by rename (the HACK-1452 empty-file race, now fixed in this file too). The cancelled-effect start-up wait is a handshake instead of a 4 s poll.

Verification

  • Linux host, Bun 1.4.2, synthetic CPU load (50 busy loops on 20 cores, plus ambient load): both files 5 consecutive times. In progress; this line will be updated with the results.
  • Biome and tsc --noEmit: clean for both files.
  • No macOS-specific behavior is involved. These fakes run on any host, so no M5 check is needed.

🤖 Generated with Claude Code


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…dgets from load (HACK-1319)

- Binding: the cancellation tests wait for the hanging fake Docker child by
  handshake (PID published, or the operation settled first) instead of a 15 s
  wall-clock wait, and give that probe the largest deadline the product admits.
  The timeout test pins Date.now() so its 150 ms deadline is armed after the
  spawn and always has a child to reap.
- Generation: named budgets replace the 20/30/60/90 s literals. Retained
  operations get the public command's deadline; each case's budget covers its
  adoption work plus one deadline per operation, so a slow host ends in the
  product's own refusal rather than a Bun timeout that blocks every later case.
  Expiry tests name their deadline and refusal slack. Hanging fake children
  publish PIDs by rename, and the cancelled-effect wait is a handshake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 2, 2026

Copy link
Copy Markdown

HACK-1319

@roodboi

roodboi commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Independent review (GPT-6-Astra, codex-dio): VERDICT: CLEAN at 75cf412. Reviewer thread mcp:cc4af3dc-6c8a-4e2e-9932-af0330123e26.

Static review of the exact-head diff against origin/next. GraphQL reviewThreads pagination returned no threads. The ordered signed merge from next and exact-head required test gate remain before READY. No PR merge performed.

@roodboi

roodboi commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Independent review (GPT-6-Astra, codex-dio): VERDICT: CLEAN at 116509d. Reviewer thread mcp:cc4af3dc-6c8a-4e2e-9932-af0330123e26.

Re-reviewed after the verified signed merge of next at 472ec94. No manual conflict-resolution changes. Fresh paginated GraphQL reviewThreads returned zero threads. The independent review is static; hosted exact-head required test remains pending. No READY line until that check is green and the branch remains current. No PR merge performed.

@roodboi
roodboi merged commit cb44175 into next Nov 3, 2026
23 checks passed
@roodboi
roodboi deleted the kit/hack-1319-adoption-test-flakes branch November 3, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant