Skip to content

test: promote scratch pins — host-owned alarm, runSyncedWrite capture/broadcast seams - #42

Merged
grrowl merged 1 commit into
mainfrom
test/scratch-promotion
Aug 26, 2026
Merged

test: promote scratch pins — host-owned alarm, runSyncedWrite capture/broadcast seams#42
grrowl merged 1 commit into
mainfrom
test/scratch-promotion

Conversation

@grrowl

@grrowl grrowl commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Promotes two scratch verification files into the permanent suite by topic (per the signed-off triage table). The scratch files themselves are not added — this is a by-topic promotion, not a file move. Zero product code changes; tests only.

Row → landed test mapping

Pin Verdict Where it landed
alarm: no alarm armed through a full maybeCompact cycle keep host-matrix.test.ts"a full maybeCompact housekeeping cycle arms no alarm"
alarm: host-owned alarm survives housekeeping keep host-matrix.test.ts"a host-owned alarm survives a maybeCompact housekeeping cycle"
SW-A: callback arg === ctx.storage.sql retire folded as a one-line expect(sql).toBe(state.storage.sql) inside SW-B
SW-B: Drizzle-style direct ctx.storage.sql.exec broadcasts keep server-write.test.ts"a Drizzle-style direct ctx.storage.sql.exec inside runSyncedWrite still broadcasts…"
SW-C: write outside runSyncedWrite captured but not broadcast until next drain keep server-write.test.ts"a write OUTSIDE runSyncedWrite is trigger-captured but NOT broadcast until the next drain"
SW-D: multi-statement write → one wire batch, single uptodate keep (trimmed) server-write.test.ts"a multi-statement runSyncedWrite reaches the client as one batch…"
SW-E: 30 rapid updates → 1 delta retire duplicate of coalesce.test.ts:39; its final-value assertion (coalesce.test.ts:69) already exists, so no strengthening was needed

Why these pin their ADRs

  • Alarm tests (ADR-0015, host-owned alarm slot). The cohosting proof's third leg: tddc defines no alarm() — compaction rides ctx.waitUntil (#maybeCompact), so the DO's single alarm slot stays the host's. Both tests drive a real drain → #maybeCompactwaitUntil cycle over MaintTestDO (compactionEvery=3) and poll for the change-log collapse before asserting the alarm slot. The host-owned-alarm test is the stronger guard: the DO has a single alarm slot, so any tddc use of it would clobber the host's value — its exact survival proves the slot was never touched. (That the housekeeping actually ran is pinned in depth by maybe-compact.test.ts.)
  • Server-write tests (ADR-0006, capture-vs-broadcast). SW-C asserts the "dark half" the suite only stated in prose — a raw sql.exec fires the CDC trigger (row lands in _sync_changes) but is not broadcast until a drain. SW-B proves the sanctioned path works even when a Drizzle driver writes through ctx.storage.sql directly. SW-D pins the wire framing (one batch, single uptodate, shared seq, one delta per key) that the collection abstraction hides.

Idiom / integration notes

  • Rewritten to destination-suite idiom: shared helpers, runInDurableObject, unique-DO-name isolation. SW-B/SW-C reuse the file's existing collection-based helpers; SW-D adds a minimal codec-level socket (the only way to observe the wire boundary).
  • SW-D trimmed per verdict (dropped redundant scratch assertions; kept the load-bearing batch invariants).

Adversarial review

Ran the diff past codex (gpt-5.6-sol) per repo practice; addressed its findings: hardened the batch test with an exact key-set assertion (one delta per key), reordered subscribeRaw to attach its listener before sending, widened the negative-broadcast window to several coalescer ticks, and corrected the alarm block's comment to claim only the observable contract (not the internal mechanism, which maybe-compact.test.ts owns).

Validation

  • npm test: 269 passed (was 264 → +5), 53 files green.
  • npm run typecheck: clean.

🤖 Generated with Claude Code

…/broadcast seams

Promote two scratch verification files into the permanent suite by topic (the
scratch files themselves are not added). Zero product code changes.

host-matrix.test.ts (ADR-0015, host-owned alarm slot):
- a full maybeCompact housekeeping cycle arms no alarm
- a host-owned alarm survives a maybeCompact housekeeping cycle
Both drive a real drain -> #maybeCompact -> waitUntil cycle (MaintTestDO,
compactionEvery=3) and poll for the collapse before asserting the alarm slot.

server-write.test.ts (ADR-0006, runSyncedWrite capture-vs-broadcast):
- a Drizzle-style direct ctx.storage.sql.exec inside runSyncedWrite broadcasts
  (folds the retired handle-identity pin: the callback arg IS ctx.storage.sql)
- a write OUTSIDE runSyncedWrite is trigger-captured but NOT broadcast until the
  next drain (asserts the dark half the suite only stated)
- a multi-statement runSyncedWrite reaches the client as one wire batch: all
  deltas, then a single uptodate at one seq (trimmed)

Retired without promotion: the callback-handle pin (folded above) and the
30-rapid-updates coalescing pin (already covered by coalesce.test.ts, whose
final-value assertion needs no strengthening).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@grrowl
grrowl merged commit 0703a7b into main Aug 26, 2026
1 check passed
@grrowl
grrowl deleted the test/scratch-promotion branch August 26, 2026 05:45
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