feat(discovery): broadcast transactionalBatch capability bit so clients negotiate atomic batch declaratively (#3298)#3345
Merged
Conversation
fix(list): route remaining system-field groupings through shared classifier (#2706) objectui@3b2e4d98d904d695a8372c394d46b81673011270
…egotiate atomic batch declaratively (#3298) The atomic cross-object batch endpoint (POST {basePath}/batch, #1604 / ADR-0034 item 4) and its typed SDK surface (client.data.batchTransaction, #3271) shipped, but discovery never told a client whether a backend supports it. Consumers had to probe — fire a /batch, read 404/405 (no route) or 501 (no runtime transaction), then fall back to non-atomic client-side simulation. That is "find out by calling", not capability negotiation, and it blocks hard-deleting ObjectUI's non-atomic fallback (objectui#2679). Add a required `transactionalBatch: boolean` to WellKnownCapabilitiesSchema and fill it honestly in every discovery producer (declared === enforced), so it is never a declared-but-unpopulated bit: - metadata-protocol (getDiscovery): true iff the runtime engine can honour a transaction (typeof engine.transaction === 'function'). engine.transaction() degrades to a non-atomic passthrough / 501 without one. - rest-server (/discovery): ANDs that with api.enableBatch — the gate that mounts the /batch route — so batch-disabled servers report false even on a tx-capable engine (never advertise a route that 404s). - plugin-hono-server (standalone discovery): false — this minimal surface mounts CRUD only, not /batch. Under-reporting is the safe direction (client keeps its correct-but-slower fallback). - client: already normalizes hierarchical capabilities → flat booleans, so client.capabilities.transactionalBatch is exposed and now typed. Tests assert the bit across all producers (spec schema required-field, protocol engine-tx true/false, rest enableBatch AND-ing + always-populated, hono false, client hierarchical→flat). Regenerated content/docs/references/api/discovery.mdx. Additive and behavior-preserving; only the discovery payload gains a field. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 6 package(s): 111 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Closes #3298.
Problem
The atomic cross-object batch endpoint (
POST {basePath}/batch, #1604 / ADR-0034 item 4) and its typed SDK surface (client.data.batchTransaction, #3271) already shipped — but discovery never told a client whether a backend supports it. Consumers (notably ObjectUI'sObjectStackAdapter) had to runtime-probe: fire a/batch, read404/405(no route) or501(no runtime transaction), and only then fall back to non-atomic client-side simulation.That is "find out by calling", not declarative capability negotiation — it can't be decided at connect time, and can't serve as the "minimum backend has
/batch" gate that's currently blocking the hard-delete of ObjectUI's non-atomic fallback (objectui#2679).Change
Add a required
transactionalBatch: booleantoWellKnownCapabilitiesSchema, and fill it honestly in every discovery producer (declared === enforced) so it never becomes a declared-but-unpopulated bit — the exact failure mode #3271 avoided by not adding abatchkey with mismatched producers.@objectstack/metadata-protocol(getDiscovery)typeof engine.transaction === 'function'/batchhandler runs insideengine.transaction(), which degrades to a non-atomic passthrough /501without one.@objectstack/rest(/discovery)api.enableBatchfalseeven on a tx-capable engine (never advertise a route that404s).@objectstack/plugin-hono-server(standalone discovery)false/batch(that ships with@objectstack/rest). Under-reporting is the safe direction — the client keeps its correct-but-slower fallback rather than losing atomicity.@objectstack/clientcapabilities→ flat booleans, soclient.capabilities.transactionalBatchis exposed and now typed.Semantics match the existing capability flags:
true⟺ the/batchroute is mounted and the runtime can honour a transaction — precisely when the endpoint returns200rather than404/405/501.Acceptance (from #3298)
WellKnownCapabilitiesSchema.transactionalBatch)GET /discoveryreturns the bit@objectstack/clientexposes the capability for consumers (the optional item)Tests
transactionalBatchis a required field (a payload missing only it fails), described, accepted true/false.protocol-discovery.test.ts) — reports{enabled:true}on the real engine (hastransaction()),{enabled:false}on an engine without one.truewhen runtime supports tx +/batchmounted;falsewhenapi.enableBatchoff;falsewhen the engine can't honour a tx; always populated even if the protocol omitted capabilities.false, and there is genuinely noPOST /batchroute on that surface.{enabled:true}→ flattrue.Regenerated
content/docs/references/api/discovery.mdx(the only committed generated artifact affected;json-schema/is gitignored). Changeset added (minor × 5).Note (out of scope)
pnpm gen:spec-changes/gen:upgrade-guidesurfaced pre-existing drift unrelated to this change — the protocol 15→16DashboardWidgetSchema.strict()migration (dashboard-widget-strict-unknown-keys, from #3251) whose committed projection is stale. I reverted those regenerated files so this PR doesn't absorb #3251's changelog; that drift belongs to #3251's follow-up.🤖 Generated with Claude Code