Skip to content

fix(voice): reject stale worker readiness probes - #421

Open
Afloat16 wants to merge 1 commit into
simplexai-labs:mainfrom
Afloat16:afloat/voice-readiness-snapshot
Open

Afloat16 wants to merge 1 commit into
simplexai-labs:mainfrom
Afloat16:afloat/voice-readiness-snapshot

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Snapshot the worker child and generation when readiness probes start, then validate the complete snapshot after every probe has settled. A successful health response is stale if its worker exited, its key rotated, or another provider was enabled while any probe was pending.

The current check happens before awaiting the health response. That lets voice readiness succeed for a process that no longer represents the current provider state. The final snapshot validation closes that gap without adding probes or network calls.

How it was verified

  • Base: 77abdcb. Node 26.5.0, pnpm 11.7.0.

  • Before: 4 new regression cases fail while 20 existing cases pass.

  • After: all 24 voice-service tests pass. Cases cover key rotation, child exit, enabling another provider, and invalidating an already completed probe while another probe remains pending. A fresh readiness check can subsequently succeed.

  • Command: pnpm --filter @linger/node-services exec vitest run tests/voice-service.test.ts --maxWorkers=1.

  • Node-services typecheck, changed-file ESLint and diff checks pass. The full owning-app fast gate now passes; see the exact-head validation below.

  • Focused tests for the changed behavior

  • make check BASE=origin/<target-branch> or the fast checks of every touched app

  • No contract regeneration required

Boundary

The nearest node-services guidance records the readiness invariant. Worker startup, key reconciliation, health endpoints and probe count are unchanged; the new validation only reads the existing in-memory worker state.

Validation follow-up

On fdcf914cc5713c3e0c10a3216927e2dc78c95c54, pnpm --filter @linger/node-services check passes with Node 26.5.0 and pnpm 11.7.0: the feature catalog/typecheck and full ESLint gates pass, followed by 268 test files passed, 8 skipped; 2,715 tests passed, 51 skipped. No additional test exclusions, source changes, or lockfile changes were needed.

This establishes the owning app's full fast gate. Unrelated full-repository and optional integration/acceptance suites were not run. Live provider keys, audio hardware and a deployed Voice worker were not used.

@Afloat16
Afloat16 marked this pull request as ready for review November 25, 2026 06:07

@linger-review linger-review 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.

Approve with nits (1 P3)

Scope: base main, merge base 77abdcb3, 1 commit, 3 files reviewed (apps/node-services/src/voice/service.ts, its test, apps/node-services/AGENTS.md). Helper skills loaded: ponytail-review. coderbook and karpathy-guidelines were not loaded this run, so their criteria were applied from the review procedure's summary only. Ran in a separate session.

Findings

P3

  • apps/node-services/src/voice/service.ts:390: the final entry.childGeneration === generation check is redundant. entry.childGeneration is assigned only in spawnWorker, together with entry.child = child (service.ts:273-274). The probe only runs when the snapshot already had entry.childGeneration === generation (service.ts:376). So if entry.child === child still holds at the end, childGeneration cannot have changed. Deleting the line leaves behavior unchanged. Optional: the old comment "a replaced worker may still answer until it exits" explained why the generation check exists, and something like it could go back next to the pre-probe check.

Verified as fine

  • Rotation or removal during the batch: apply bumps entry.generation for every worker whose key digest changes, including when the key is removed (service.ts:290-292). The post-probe entry.generation === generation check therefore rejects a rotated or removed worker even while its old child is still draining.
  • Child exit or restart with the same key: the exit handler clears entry.child (service.ts:281), and a restart assigns a new child object (service.ts:273). In both cases entry.child === child fails.
  • Newly wanted worker: the wantedWorkers().length === checked.length check catches an addition. If one worker is removed and another added during the same batch, the count stays equal, but the removed worker's generation bump still fails the check.
  • Both callers benefit: workersReady feeds both the readiness hook (service.ts:451-454) and reconcileAndWait (service.ts:398-418). A rejected stale result there only causes another poll before the deadline.
  • No extra probes or network calls: probe count and timing are unchanged. The new checks read only in-memory state, as the PR says.
  • Tests: the 4 new cases have no sleeps. They hold the probe promise and release it after the change, which exercises the real race window. I confirmed they fail on the base service.ts (4 failed, 20 passed) and pass on the head (24 passed).
  • Docs: apps/node-services/AGENTS.md records the invariant. No CJK in added lines or the commit message, and the commit follows Conventional Commits.

Process notes

  • The branch is 335 commits behind main. main requires an up-to-date branch, so it needs a rebase before merge.

CI

  • PR CI: changes, repository-gate and check (web) pass. Every other app check was skipped by the path filter. node-services tests do not run in PR CI (they stay local, per .github/workflows/ci.yml).
  • Run locally: pnpm --filter @linger/node-services exec vitest run tests/voice-service.test.ts --maxWorkers=1 passes 24/24 on the head. With the base service.ts it fails the 4 new cases.

Automated review by Claude Code


Automated review of fdcf914 by Claude Code.

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