test: promote scratch pins — host-owned alarm, runSyncedWrite capture/broadcast seams - #42
Merged
Merged
Conversation
…/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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
maybeCompactcyclehost-matrix.test.ts→ "a full maybeCompact housekeeping cycle arms no alarm"host-matrix.test.ts→ "a host-owned alarm survives a maybeCompact housekeeping cycle"===ctx.storage.sqlexpect(sql).toBe(state.storage.sql)inside SW-Bctx.storage.sql.execbroadcastsserver-write.test.ts→ "a Drizzle-style direct ctx.storage.sql.exec inside runSyncedWrite still broadcasts…"runSyncedWritecaptured but not broadcast until next drainserver-write.test.ts→ "a write OUTSIDE runSyncedWrite is trigger-captured but NOT broadcast until the next drain"uptodateserver-write.test.ts→ "a multi-statement runSyncedWrite reaches the client as one batch…"coalesce.test.ts:39; its final-value assertion (coalesce.test.ts:69) already exists, so no strengthening was neededWhy these pin their ADRs
alarm()— compaction ridesctx.waitUntil(#maybeCompact), so the DO's single alarm slot stays the host's. Both tests drive a real drain →#maybeCompact→waitUntilcycle overMaintTestDO(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 bymaybe-compact.test.ts.)sql.execfires 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 throughctx.storage.sqldirectly. SW-D pins the wire framing (one batch, singleuptodate, shared seq, one delta per key) that the collection abstraction hides.Idiom / integration notes
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).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), reorderedsubscribeRawto 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, whichmaybe-compact.test.tsowns).Validation
npm test: 269 passed (was 264 → +5), 53 files green.npm run typecheck: clean.🤖 Generated with Claude Code