Skip to content

test(server): pin mutation/command error paths with wire-level tests#4

Closed
grrowl wants to merge 1 commit into
feat/ssrfrom
advisor/001-server-error-path-tests
Closed

test(server): pin mutation/command error paths with wire-level tests#4
grrowl wants to merge 1 commit into
feat/ssrfrom
advisor/001-server-error-path-tests

Conversation

@grrowl

@grrowl grrowl commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Executes plan 001 from the advisor audit (deep audit @ 8e157ef). Tests only — no src changes.

What

9 wire-level tests in tests/error-paths.test.ts (+ a throwing boom command in the test worker) pinning the previously-untested error paths:

  • execute throw mid-transactionSync → rejected, rolled back, no delta leak
  • whole-batch rollback when op 2 of a multi-op mutation throws
  • authorize failure on op 2 rejects before any write
  • unknown mutation type / unknown command (UNKNOWN_COMMAND) rejections
  • retried rejected txId replays the rejection (exactly-once in failure)
  • retention-floor reconnect: reset followed by fresh snapshot, order asserted
  • readSyncSnapshot throws on unknown collection

Review notes

  • Adversarially reviewed: done criteria re-run, scope clean, tests audited as falsifiable.
  • One documented deviation, verified correct on merit: the floor-reset test needed 3 rows/prune-2 (the plan's 2-row setup lands on the since >= floor-1 catch-up branch by design).

Base for the stacked PRs #—(004) and #—(005).

🤖 Generated with Claude Code

Adds 9 tests in tests/error-paths.test.ts covering the server's
previously-uncovered error paths: execute-throw atomicity (single and
multi-op rollback), authorize-fail before any write, unknown mutation/
command rejection, exactly-once replay of a rejected txId, command-boom
execute throw, unknown-command UNKNOWN_COMMAND code, retention-floor
reconnect reset + fresh snapshot, and readSyncSnapshot unknown-collection
throw.

Also adds a `boom` command to tests/test-worker.ts (one defineCommand only).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@grrowl

grrowl commented Jun 13, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #11, which landed plan-001 on main (adapted for main + published @tanstack/db, validated green) as part of the 0.3.2 bug-fix batch.

Not merging into feat/ssr: feat/ssr will receive this via its rebase onto the new main, so merging here would duplicate/conflict with that. Closing as superseded.

The advisor/* branch is retained (not deleted) until the feat/ssr reconciliation is done — it's the source for restoring any feat/ssr-specific bits (e.g. the readSyncSnapshot test case, the extracted scheduleReconnect method) that main's adapted versions intentionally omit.

@grrowl grrowl closed this Jun 13, 2026
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