GeezerVison is showing github.com — feat(server): batch writes for experimental spaces by kommander · Pull Request #66668 · anomalyco/opencode
Conversation
kommander
commented
Nov 26, 2026
•
edited by opencodejr
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
None; follow-up to #63998.
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Replaces the experimental space PUT/DELETE /api/experimental/space/:space/:key with one POST /api/experimental/space/:space/write (experimental.space.write): { changes: [{ key, value }] }, 1–1024 changes, value: null deletes, values ≤ 1 MiB UTF-8 in total. The batch commits in one transaction under the per-space lock; each change that changes a key gets the next revision in order (a repeated key gets both, last wins) and its own updated/deleted event after commit. Returns { revision, cursor }: the head after the write. Experimental, no flag.
How did you verify your code works?
Updated and added core/server space tests (batches, ordering, events, returned cursor, limits); server suite, space tests 10x, bun run check, typecheck:tsc, check:generated.
Screenshots / recordings
N/A
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Public API: replaces experimental.space.set/delete (PUT/DELETE /api/experimental/space/:space/:key) with experimental.space.write (POST /api/experimental/space/:space/write); breaking for callers of the experimental endpoints
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found nothing that blocks this. I ran opencode serve from this branch and checked the endpoint with curl:
- A mixed batch (a key set twice, a key set then deleted, an unset key deleted) left the space as expected and returned the head and its cursor.
- A batch that changes nothing returned the current head.
- An empty
changes list was rejected.
- The old
PUT route now returns 404.
The server and core space tests and typecheck:tsc for server, core and client pass.
The transaction, the per-space lock, and sending events in revision order after the commit all hold up. Counting several tombstones toward the purge interval at once keeps the existing purge behaviour.
Public API impact. This breaks existing callers, but the endpoints are experimental and nothing else in the repo calls them:
- Removed:
PUT /api/experimental/space/:space/:key (experimental.space.set).
- Removed:
DELETE /api/experimental/space/:space/:key (experimental.space.delete).
- Removed: the matching client methods
experimental.space.set / .delete and their ExperimentalSpaceSet* / ExperimentalSpaceDelete* types.
- Added:
POST /api/experimental/space/:space/write (experimental.space.write, client experimental.space.write).
- Body:
{ changes: [{ key, value: string | null }] }, 1–1024 changes.
- Returns
{ revision, cursor } instead of 204.
- Added: schema exports
Space.Change and Space.MaxChanges.
- Changed: the 1 MiB cap now applies to the total of all values in a write instead of to each single value.
- Event types are unchanged: one
experimental.space.updated / experimental.space.deleted per change that changes a key.
External callers need to move to write: { changes: [{ key, value }] } to set a key, value: null to delete one.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|