design-b D1b/c: context harness + the bounded-and-measured memory gate

Doc 20 §6 D1, second slice: the dedicated test app D1 calls for, plus
the doc 20 §7 risk-1 gate.

tests/apps/standalone/sched-context/ drives the primitives with no wx
linked (a failure can only be the contexts layer) and assertions ON —
unlike the races harness, an emscripten "cannot start an async
operation" state here IS the bug, not a tolerated state. Nine
scenarios, each pinning one invariant; the load-bearing ones:
- parked_does_not_block: a parked context does not stop others running.
  This is doc 19's freeze made unrepresentable — there a parked activity
  held a global interlock and the UI died; here "parked" simply means
  "not runnable", and three workers run past it before it resumes.
- one_transition_in_flight: a context calling drain() gets a no-op, with
  a second ready context queued so a buggy nested drain would actually
  run something and be caught.
- async_wake: a real macrotask hop (setTimeout → mark_ready → drain),
  the shape every production bridge has.
- deep_park_sizing: parks 64 live frames deep to measure what a park
  actually costs.

The memory gate asserts the ceiling (peak live contexts, peak bytes),
that nothing leaked (live=0, bytes=0, created==finished), that nothing
was left mid-transition, and that refusals occurred (zero would mean the
illegal-operation scenarios stopped provoking).

Measured here: ~34 B/frame, 2200 B for a 64-frame park, 1 MB peak for 4
concurrent contexts. Recorded with the caveat that the harness's frames
carry three locals each, so this is a FLOOR — real bridges save far more
per frame (libcontext runs 512 K after a 64 K buffer silently
overflowed). The apparatus and its units are validated; the sizing
DECISION needs deep-park numbers from real bridges at D3/D4.

playwright.config: asyncify-firefox now matches every spec in ./asyncify
instead of only asyncify-races* — a new harness there is covered by
construction rather than by remembering to widen the pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEHGiiXMShNXbBr7gSJ7iz
This commit is contained in:
Gergő Törcsvári 2026-08-05 21:41:24 +02:00
commit 7dbc9fb36e
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322
4 changed files with 716 additions and 3 deletions

View file

@ -184,11 +184,13 @@ export default defineConfig({
},
},
{
// Asyncify race-condition red-green harness. One heavy WASM app at a
// time within the (single) spec file.
// Asyncify-layer harnesses: the race-condition red-green battery and
// the Design-B scheduler-context gate. One heavy WASM app at a time.
// Matches EVERY spec in ./asyncify — a new harness here is covered by
// construction rather than by remembering to widen this pattern.
name: 'asyncify-firefox',
testDir: './asyncify',
testMatch: /asyncify-races.*\.spec\.ts$/,
testMatch: /\.spec\.ts$/,
fullyParallel: false,
timeout: 120000,
use: {