Repository navigation
Commit b343754
function_storage_cf_do: idempotent attempt_id, aggregate state, hardening
Make the Cloudflare Durable Object storage backend safe for retry and
feature-complete for VGI's aggregate test suite.
Server (cloudflare/vgi-storage/src/index.ts):
- Every destructive endpoint requires a client-generated attempt_id
(32-hex). Replay path returns the original response: worker_collect
and queue_pop use UPDATE...RETURNING with soft-delete tombstones
(collected_by_attempt, popped_by_attempt); worker_put / scan_worker_put
/ transaction_state_put / aggregate_state_put / aggregate_window_partition_put
short-circuit on last_attempt_id match.
- Add scan_worker_state, aggregate_state, aggregate_window_partitions
tables + handlers. scan_worker_* endpoints were missing in the DO
switch entirely; aggregates raised NotImplementedError client-side.
- Wrap multi-statement writes in ctx.storage.transactionSync() (the DO
runtime forbids raw BEGIN/COMMIT/SAVEPOINT).
- Switch alarm to activity-based TTL (last_activity_at) plus a short
5-min sweep for soft-delete tombstones.
- Constant-time bearer compare; ensureTables + alarm-init moved into
the constructor via blockConcurrencyWhile; 500 stack traces gated on
VGI_STORAGE_DEBUG=1.
- Extend the abstract DurableObject<Env> base class so the
DurableObjectNamespace<VgiStorageDO> binding type-checks.
Client (vgi/function_storage_cf_do.py):
- _post accepts attempt_id kwarg, spliced into the body before the
retry loop so all retries of one logical call carry the same id.
- 400 -> ValueError (contract violation, not retried).
- Narrow httpx.HTTPError catch to httpx.RequestError so InvalidURL etc.
aren't accidentally swallowed.
- Implement scan_worker_put/scan, aggregate_state_get/put/clear, and
aggregate_window_partition_put/get/delete/clear (previously
NotImplementedError).
- Documented the workflow-contract assumption that makes the
column-only replay model sound: per-execution_id lockstep via
_post's synchronous retry loop, terminal ops never reused.
Tests:
- 50 mocked tests (tests/test_function_storage_cf_do.py): attempt_id
presence on every destructive call, stable across retries, absent on
read-only; aggregate / scan-worker / 400 paths.
- 23 live tests (tests/test_function_storage_cf_do_integration.py,
gated on VGI_CF_DO_INTEGRATION_URL): end-to-end replay semantics
against wrangler dev for the soft-delete tombstone paths, 60-thread
concurrent pop without duplicates.
Verified against the C++ integration suite via
`VGI_WORKER_SHARED_STORAGE=cloudflare-do VGI_CF_DO_URL=... make test_launcher`:
137/141 pass, zero CF-DO-induced regressions vs. baseline sqlite. The 4
remaining failures are pre-existing on baseline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d470e73 commit b343754
6 files changed
Lines changed: 2157 additions & 799 deletions
File tree
- cloudflare/vgi-storage
- src
- tests
- vgi
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments