Context
NexusContributionStore.put() currently issues N sequential VFS writes for a single contribution:
- Manifest:
/zones/{zoneId}/contributions/{cid}.json
- One write per relation index entry
- One write per tag index marker
- FTS index:
/zones/{zoneId}/indexes/fts/{cid}.json
These are independent HTTP calls with no atomicity guarantee. A partial failure (e.g. manifest written, FTS not written) leaves the contribution in an inconsistent index state — discoverable by CID but invisible to list() / search().
Blocked on
nexi-lab/nexus#3700 — expose write_batch on the HTTP/SDK client interface.
write_batch provides true atomic multi-file writes (all-or-nothing, single DB transaction, 13× faster than N sequential writes). Once it is available on NexusClient, this follow-up becomes straightforward.
Proposed change
Once NexusClient.writeBatch() is available:
-
NexusContributionStore.put() (src/nexus/nexus-contribution-store.ts) — collapse the manifest + relation + tag + FTS writes into a single writeBatch call. Eliminates the partial-index-write window and the N×RTT cost.
-
Add writeBatch to NexusClient interface (src/nexus/client.ts) — the interface currently only has single-file write().
What this does NOT fix
Cross-store atomicity (e.g. ClaimStore + BountyStore in claimBountyOperation) requires compensating actions regardless of write_batch, because those stores are logically separate systems. The compensation patterns introduced in #227 stay.
Files
src/nexus/nexus-contribution-store.ts — put() method, lines 86–153
src/nexus/client.ts — NexusClient interface, add writeBatch
Context
NexusContributionStore.put()currently issues N sequential VFS writes for a single contribution:/zones/{zoneId}/contributions/{cid}.json/zones/{zoneId}/indexes/fts/{cid}.jsonThese are independent HTTP calls with no atomicity guarantee. A partial failure (e.g. manifest written, FTS not written) leaves the contribution in an inconsistent index state — discoverable by CID but invisible to
list()/search().Blocked on
nexi-lab/nexus#3700 — expose
write_batchon the HTTP/SDK client interface.write_batchprovides true atomic multi-file writes (all-or-nothing, single DB transaction, 13× faster than N sequential writes). Once it is available onNexusClient, this follow-up becomes straightforward.Proposed change
Once
NexusClient.writeBatch()is available:NexusContributionStore.put()(src/nexus/nexus-contribution-store.ts) — collapse the manifest + relation + tag + FTS writes into a singlewriteBatchcall. Eliminates the partial-index-write window and the N×RTT cost.Add
writeBatchtoNexusClientinterface (src/nexus/client.ts) — the interface currently only has single-filewrite().What this does NOT fix
Cross-store atomicity (e.g.
ClaimStore+BountyStoreinclaimBountyOperation) requires compensating actions regardless ofwrite_batch, because those stores are logically separate systems. The compensation patterns introduced in #227 stay.Files
src/nexus/nexus-contribution-store.ts—put()method, lines 86–153src/nexus/client.ts—NexusClientinterface, addwriteBatch