Skip to content

fix(link): warn once when a draining stop holds the lifecycle queue on an exit never seen, and finish the drain wording - #8646

Merged
lidge-jun merged 6 commits into
devfrom
chore/link-drain-warn-lifecycle
Nov 13, 2026
Merged

lidge-jun merged 6 commits into
devfrom
chore/link-drain-warn-lifecycle

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

The last nits from the final review of #8643 (issue #8609).

A stuck drain was silent. A stop from a reload, removal, reconnect or shutdown sends a tunnel child SIGTERM, and the tick sends SIGKILL once 2 s have passed since the stop time (#8640; a child the tick had already stopped keeps the tick's earlier stop time). The stop then awaits the child's exit. If even SIGKILL produced no observed exit, that await held the lifecycle queue for every link and nothing was logged. The tick's drain loop, which already visits every draining child, now logs [link] tunnel exit unconfirmed link=<id> once (link id only) when the exit is still unseen at least 4 s (2 x CANDIDATE_KILL_GRACE_MS) after the drain's stop time. The warning is a separate branch from the SIGKILL, so it needs a tick after the SIGKILL tick. That is the same line the tick logs for a stopped one-route child since #8643. A one-route child the tick already warned about keeps that flag when a stop drains it, so the line is not logged twice for it. A multi-route candidate that route-rounds halted with stop_unconfirmed keeps its own [link] route candidate exit unconfirmed link=<id> line and, once a stop drains it, gets this one too, after a second, harmless SIGKILL. Nothing else changes: the stop still waits, and the SIGKILL timing is as before.

Wording.

  • The drain-loop comment in src/link/supervisor.ts is now a full sentence and also names the fresh grace that a candidate route-rounds already stopped gets when drained.
  • structure/remote-link.md says the tick-branch warning comes "at least 4 s" after the SIGTERM, because it needs a tick after the SIGKILL tick. It also says that a draining stop whose exit is never seen is now warned once: not again for a one-route child the tick already warned about, and as well for a candidate halted with stop_unconfirmed.
  • The comment now says a stopped candidate's fresh stop time comes from stopChild, which is where it is set.

What keeps this inert. The only behaviour change is one warning line, for a stop whose child is still not seen to exit at least 4 s after its stop time, which in practice means it survived SIGKILL. src/link/supervisor.ts grows from 1000 to 1006 lines; the file-size ratchet applies from 2000 lines. No hunk touches the import block or spawnFor.

Verification

In tests/clients/link-route-supervisor.test.ts:

  • a reload whose drained child survives SIGKILL warns once while it holds the lifecycle queue: written first. It asserts no warning at 3.999 s, exactly one at 4 s, and no repeat at 5 s. With src/link/supervisor.ts put back to dev (d6ab332), the final test file gives 84 pass and 1 fail, and this test is the failure: no warning.
  • a drained child the tick already warned about is not warned again by the drain: guards the carried flag. It passes on dev, which has no drain warning at all. A mutation that drops the carried flag (warned: false) makes it fail.

Commands (exit codes). The first two were run on 110a18e, and the head adds only wording:

  • TMPDIR=/tmp bun scripts/test.ts --parallel=2 tests/clients/link-route-supervisor.test.ts tests/clients/link-supervisor.test.ts tests/clients/link-boundary.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/ci-structure-gate.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts: 216 pass, 0 fail (exit 0).
  • bun run typecheck: exit 0. bun run privacy:scan: exit 0. bun run structure:check: exit 0.
  • On b5b1277, the behaviour commit; the one after it changes only the test's assertion points: TMPDIR=/tmp bun scripts/test.ts --parallel=2 tests/clients tests/server/link-management-routes.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/ci-structure-gate.test.ts tests/ci-workflows/file-size-ratchet.test.ts (214 files): 3667 pass, 67 skip, 3 fail (exit 1). The 3 failures are the Rust ocx-child tests (tests/clients/link-ocx-child-e2e.test.ts, two cases, and the Rust case of tests/clients/link-ocx-child-conformance.test.ts). They stop before any test code runs, because cargo on the build machine has no default rustup toolchain. This branch touches no Rust code.

NOT RUN: the full bun run test suite (the build machine allows focused files only; CI covers the rest); the three Rust ocx-child tests above (no toolchain); Windows and macOS (one warning line).

The branch has six commits:

  1. The drain-loop comment.
  2. The "at least 4 s" doc sentence.
  3. The warning and its tests.
  4. A tighter timing assertion.
  5. A doc correction for drained candidates halted with stop_unconfirmed.
  6. The comment correction for where the fresh stop time is set.

The last two change only that doc sentence and that comment. After them, the two supervisor test files (TMPDIR=/tmp bun test tests/clients/link-route-supervisor.test.ts tests/clients/link-supervisor.test.ts: 121 pass, 0 fail, exit 0), bun run typecheck, bun run structure:check and bun run privacy:scan (exit 0 each) were run again on the head.

Review: two read-only rounds by one independent reviewer (gpt-6.1-terra, xhigh effort). Round 1 found one P2: the timing test checked at 5 s, so a warning that first came at 5 s would also have passed. That is fixed in the last commit. Round 1 also confirmed that the drain loop sends SIGKILL before it warns, that the warning carries only the link id, and that the warned flag is carried over. Round 2 found no P0–P2 and ran the test file on the head (85 pass).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

…n an exit never seen

A stop from a reload, removal, reconnect or shutdown whose child survives SIGKILL
awaits an exit that never comes and held the lifecycle queue silently. The tick's
drain loop now logs '[link] tunnel exit unconfirmed link=<id>' once when the exit
is still unseen 4 s after the drain's stop time, unless the tick already warned
for that child.

Refs #8609
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 13, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 05:11
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 05:11
@lidge-jun
lidge-jun merged commit 864108e into dev Nov 13, 2026
28 checks passed
@lidge-jun
lidge-jun deleted the chore/link-drain-warn-lifecycle branch November 13, 2026 05:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T05:13:07.442407Z 9a7a9f3 Draft marked ready
ℹ️ 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.

lidge-jun added a commit that referenced this pull request Nov 13, 2026
Brings in dev through de85cf2, including #8638 (operation journal
follow-ups: strict revoke intents, a link suspended after an uncertain
revoke, journal size bounds, write-only-on-change) and #8646.

Conflict resolution keeps both sides:
- operations-journal: dev's bounded pruning and write-only-on-change,
  with this PR's keep pin honoured by both the retention filter and the
  over-limit prune.
- link-operation: dev's room check, live marks, strict intents and
  cleanupNotRun/release on RevokeJournal, with this PR's pinned writes,
  operationId and beforeReceiptCleared; the resumed retirement journal
  gets no-op cleanupNotRun/release (its link is held for the resume).
- link-routes remove(): the early replay branch resumes the operation's
  own receipt before replaying; dev's 404/409/400 order and plain-force
  open-entry exemption stay, and a plain force still settles and disowns
  an open owner's receipt.
- link-routes removeReserved(): this PR's receipt flow (listed check,
  cleanup evidence, mode check, claim before the locked commit) with
  dev's first intent before stopLink, strict key/record intents (the
  record intent inside the locked step, before the store write), the
  cleanup-failure rule and the live-mark release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant