Skip to content

feat(sdk/workspace): Capabilities + CapabilityReporter#81

Merged
lIang70 merged 1 commit into
mainfrom
feat/sdk-workspace-capabilities
May 8, 2026
Merged

feat(sdk/workspace): Capabilities + CapabilityReporter#81
lIang70 merged 1 commit into
mainfrom
feat/sdk-workspace-capabilities

Conversation

@lIang70

@lIang70 lIang70 commented May 8, 2026

Copy link
Copy Markdown
Collaborator

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.

Impl AtomicRename RaW Durable Distributed
`MemWorkspace`
`LocalWorkspace`
`ScopedWorkspace` (forwards inner) (forwards inner) (forwards inner) (forwards inner)
`ScopedGitWorkspace` inherits via embedding

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

  • `go test ./workspace/... -count=1` passes
  • Cases: each impl reports the documented caps; `Scoped` forwards a reporter inner; `Scoped` over a non-reporter inner yields zero value; `CapabilitiesOf(nil)` yields zero value; non-reporter `Workspace` yields zero value
  • No behavioural changes for existing callers — purely additive interface

Notes

  • No `[skip-tag:sdk]`. The follow-up sdkx PR will pin this tag immediately, so accumulating with another sdk change would block downstream.
  • Capabilities axis kept deliberately small (4 booleans). Future feature-bearing capabilities (Watch / Snapshot / PresignURL) should be added as sub-interfaces (the same pattern `CapabilityReporter` itself follows), not as bool flags here.

Made with Cursor

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>
@lIang70
lIang70 merged commit f695202 into main May 8, 2026
17 checks passed
@lIang70
lIang70 deleted the feat/sdk-workspace-capabilities branch May 8, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant