NEC-106: awareness-coalescing asserts frame counts after a fixed sleep, and fails under load #170

Merged
nectenda-agent merged 2 commits from worktree-nec-106-awareness-coalescing-asserts-frame-count into main 2026-09-25 14:13:17 +01:00
Collaborator

Task: NEC-106 — https://projectron.nerchure.com/tasks/106

awareness-coalescing.test.ts turned main red on bfbd223, a commit that touched no server code: it sent a burst of cursor moves, slept a fixed 150 ms, and counted frames. The tests now freeze the server's awareness tick and Date with vitest fake timers and replace every sleep with ping/pong barriers (sender first), so no assertion depends on how long anything takes, and 'sent at once' is told apart from 'sent at the next tick' exactly. Seven mutations of ws-server.ts each fail the test named for them. Under 60 busy processes and six suites at once, the old file failed 1 of 24 and the new one 0 of 24. Test-only; SAFE-B4 and WIRE-061 unchanged.

Spec: docs/changes/NEC-106-awareness-coalescing-timing/spec.md

Changelog

NONE

Task: NEC-106 — https://projectron.nerchure.com/tasks/106 awareness-coalescing.test.ts turned main red on bfbd223, a commit that touched no server code: it sent a burst of cursor moves, slept a fixed 150 ms, and counted frames. The tests now freeze the server's awareness tick and Date with vitest fake timers and replace every sleep with ping/pong barriers (sender first), so no assertion depends on how long anything takes, and 'sent at once' is told apart from 'sent at the next tick' exactly. Seven mutations of ws-server.ts each fail the test named for them. Under 60 busy processes and six suites at once, the old file failed 1 of 24 and the new one 0 of 24. Test-only; SAFE-B4 and WIRE-061 unchanged. Spec: `docs/changes/NEC-106-awareness-coalescing-timing/spec.md` ## Changelog NONE
awareness-coalescing.test.ts sent a burst, slept a fixed 150 ms and counted
frames, and turned main red on bfbd223, a commit that touched no server code.
A deadline only makes that rarer, and cannot tell a leading-edge send from
one at the next tick at all.

The awareness tick and Date.now() are now faked, and move only when a test
advances them; every "has it arrived" is a ping/pong barrier. Seven
mutations of ws-server.ts each fail the test named for them. Under 60 busy
processes and six suites at once, the old file failed 1 of 24, the new 0 of 24.

Task: NEC-106

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JmcjZbkbWKeksCw9GbGzkb
Fence presence-test sockets one after another, sender first
All checks were successful
Release note / release-note (pull_request) Successful in 15s
CI / build (pull_request) Successful in 4m33s
CI / e2e (pull_request) Successful in 5m14s
CI / promote (pull_request) Has been skipped
CI / build (push) Successful in 4m51s
CI / e2e (push) Successful in 5m8s
CI / promote (push) Successful in 37s
91f793baa6
Review found that barrier(a, b) pinged both sockets at once. Nothing orders
two connections, so b's pong could be answered before the server had read
a's move, which made the "sent at once" assertions probable rather than
exact. The sender is now fenced first, then the recipient.

Also: waitFor's deadline sits under vitest's timeout so a failure names its
condition, afterEach restores real timers in a finally, and the WIRE-061
comment describes the writer that actually runs. All seven mutations are
still killed.

Task: NEC-106

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JmcjZbkbWKeksCw9GbGzkb
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Nectenda/nectenda!170
No description provided.