Skip to content

M6-T2: window-protocol load harness (local-guarded, extensively tested)#29

Merged
JaamesBond merged 2 commits into
mainfrom
m6/t2-load-harness
Jul 4, 2026
Merged

M6-T2: window-protocol load harness (local-guarded, extensively tested)#29
JaamesBond merged 2 commits into
mainfrom
m6/t2-load-harness

Conversation

@JaamesBond

Copy link
Copy Markdown
Owner

Builds the M6-T2 load harness for the hot path (window_open → window_beat×N → close_window) and validates it end-to-end against a local stack. Prod untouched — a hard guard refuses the prod ref / non-localhost.

What's here

  • scripts/load/lib/hmac-chain.mjs — synthetic-client heartbeat HMAC chain, byte-matched to public.window_beat (msg="seq|prev|activity" keyed by challenge; prev chains to the previous beat's hmac, window_id for beat 1). Pure, node:crypto only.
  • scripts/load/lib/metrics.mjs — pure latency percentiles (nearest-rank), throughput, successful-writes/s, (op,code) error taxonomy.
  • scripts/load/harness.mjs — driver. assertSafeTarget() hard-refuses prod ref prmsonskzrubqsazmpwd or any non-localhost host. Seeds auth.users → publishers → devices (auth_user_id NOT NULL) via GoTrue admin + service-role inserts, mints device JWTs, runs concurrent virtual users at honest cadence (≥600ms beat spacing, full 5s dwell).
  • test/load-harness.test.mjs — +7 hermetic cases; HMAC vectors locked to the server contract (drift → every real beat 400s).
  • docs/ops/load-test-plan.md — methodology, safety guard, ceiling math (~15k writes/s @ ~50k devs), RL tuning, Cloudflare-DO migration trigger, gated run instructions.

Test evidence (local stack)

  • Smoke (2 users, 14s): 30 ops, 0 errors; +6 windows, all 6 credited (credit path fires).
  • Scale (100 concurrent users, 25s): 2500 ops, 0 errors; beats p99 37ms, opens p99 332ms (surfaces window_open's order by random() as the slowest op — a real finding). All 506 honest windows credited (HMAC chain + anti-batch + dwell correct under concurrency).
  • Guards: prod-ref target refused; non-localhost refused without LOAD_ALLOW_NONLOCAL=1.
  • Cleanup: cascade-deleted synthetic data → local DB restored to exact baseline (no residue).
  • Suite: node --test test/*.test.mjs248/248 (+7).

Not shipped to npm. Running against anything shared still DEPENDS-ON M5 (prod is single-owner until the first charge reconciles).

🤖 Generated with Claude Code

JaamesBond and others added 2 commits July 4, 2026 13:37
M6-T2 first slice — the load harness itself. BUILD only; running is a separate
gated step against a LOCAL stack (hard guard refuses the prod ref / non-localhost).

- scripts/load/lib/hmac-chain.mjs: synthetic-client heartbeat HMAC chain, byte-matched
  to public.window_beat (msg = "seq|prev|activity" keyed by challenge; prev chains to
  the previous beat's hmac, window_id for beat 1). Pure, node:crypto only.
- scripts/load/lib/metrics.mjs: pure latency percentiles (nearest-rank), throughput,
  successful-writes/s, and (op,code) error taxonomy.
- scripts/load/harness.mjs: driver. assertSafeTarget() hard-refuses prod ref
  prmsonskzrubqsazmpwd or any non-localhost host (unless LOAD_ALLOW_NONLOCAL=1, and
  prod-ref still refused). Seeds auth.users -> publishers -> devices (auth_user_id is
  NOT NULL) via GoTrue admin + service-role inserts, mints device JWTs, runs concurrent
  virtual users through open -> honest beats (>=600ms spacing) -> close at full dwell,
  summarizes. NOT run here.
- test/load-harness.test.mjs: +7 hermetic cases — HMAC vectors LOCKED to the server
  contract (drift would 400 every real beat) + metrics math.
- docs/ops/load-test-plan.md: methodology, safety guard, ceiling math (~15k writes/s @
  ~50k devs), RL tuning, Cloudflare-DO migration trigger, gated run instructions.

Not shipped to npm. DEPENDS-ON M5 for running against anything shared.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JaamesBond JaamesBond merged commit 0789586 into main Jul 4, 2026
7 checks passed
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