feat(sdk/workspace): Capabilities + CapabilityReporter#81
Merged
Conversation
Adds an optional interface that Workspace implementations can satisfy to publish their storage characteristics (atomic rename, read-after- write consistency, write durability, distributed access). Adapters that need accurate semantics — e.g. an LSM-style retrieval index relying on atomic rename for manifest swaps, or a coordinator choosing between a process-local mutex and a distributed lock — can read these via [CapabilitiesOf] instead of hard-coding per- implementation assumptions. The contract is "zero value = no guarantees", so workspaces that predate the interface (or third-party impls) fall back to the safe path automatically. Adding a new field is therefore additive. Implementations covered: - MemWorkspace: AtomicRename + ReadAfterWrite (in-memory map under a single mutex; not durable, not distributed). - LocalWorkspace: AtomicRename + ReadAfterWrite + DurableOnWrite (POSIX rename(2) + fs durability; not distributed). - ScopedWorkspace: forwards to inner via CapabilitiesOf so a wrapped non-reporter still resolves to the safe zero value. - ScopedGitWorkspace: inherits via struct embedding. The sdkx-side objstore.objectWorkspace impl is updated in the follow-up PR that pins this tag. Tests cover each impl's reported caps, scoped forwarding (over a reporter and over a non-reporter), nil ws, and the type-assertion fallback. Prep for sdkx/retrieval/workspace (P4) so its Index.Capabilities() can reflect the underlying medium accurately instead of claiming properties the wrapped workspace may not actually satisfy. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Prep for P4 — sdkx/retrieval/workspace.
Adds an optional interface that `Workspace` implementations satisfy to publish their storage characteristics (atomic rename, read-after-write, write durability, distributed access). Higher-layer adapters that need accurate semantics — e.g. the upcoming LSM-style retrieval Index that relies on atomic Rename for manifest swaps — read these via `CapabilitiesOf` instead of hard-coding per-impl assumptions.
Contract: zero value = no guarantees. Adapters that don't bother to type-assert `CapabilityReporter`, or that handle a workspace whose author hasn't implemented it, get the safe path. Adding a new field is therefore additive.
The sdkx-side `objstore.objectWorkspace` will land its `Capabilities()` method on the follow-up sdkx PR that pins the resulting sdk tag.
Test plan
Notes
Made with Cursor