Nativa PHP Core

Article

Capability seams ... how DSH abstracts abilities from implementations

Article cover illustration: Architecture, dsh-series, deepseek, architecture

What is a Capability Seam

In traditional frameworks, the filesystem is directly wired to the disk. In DSH, the filesystem is a capability seam ... contract, implementation, and consumer are separated.

Traditionally: [App] → [Concrete FS] → [Disk]
DSH:           [App] → [FS Seam] → [Local FS]  ← replaceable
                         ↓
                      [S3 FS]     ← alternative provider

This pattern repeats across every DSH capability.

Three roles of every seam

1. Service Definition (contract)

Defines the API ... what can be done, not how.

// fs/seam ... defines the API
interface FileSystem {
    read(path: string): Promise<string>
    write(path: string, content: string): Promise<void>
    edit(path: string, patch: string): Promise<void>
    list(dir: string): Promise<string[]>
}

2. Service Provider (implementation)

Implements the contract for a specific environment.

// fs-local ... local filesystem
class LocalFileSystem implements FileSystem {
    async read(path: string) { return fs.readFile(path, 'utf-8') }
    async write(path: string, content: string) { await fs.writeFile(path, content) }
    // ...
}

// fs-e2b ... remote E2B filesystem
class E2BFileSystem implements FileSystem {
    async read(path: string) { return this.e2b.readFile(path) }
    // ...
}

3. Consumer (user)

Uses the API without knowing which provider is running.

// tool-fs ... model-facing tools
class FileSystemTools extends Service {
    async readFile(path: string) {
        // Uses ctx.fs ... doesn't know if it's Local, E2B, or S3
        return this.ctx.fs.read(path)
    }
}

Example: Filesystem seams

DSH has 6 packages for the filesystem:

PackageRoleWhat it does
fs/Service DefinitionContract: read, write, edit, list
fs-local/ProviderLocal filesystem
fs-e2b/ProviderRemote E2B filesystem
fs-sandbox/ProviderSandbox-enforcing filesystem
fs-observation-policy/Policy gateObserved-state + read-before-edit
tool-fs/ConsumerModel-facing read/write/edit tools

Key insight: the policy gate (fs-observation-policy) is a plugin, not a service. Drop it and you get an unconstrained provider instead of a broken tool.

Example: Shell seams

PackageRoleWhat it does
shell/seamService DefinitionBash executor contract
shell/localProviderLocal bash
tool-shellConsumerModel-facing bash tool

Example: Sandbox seams

PackageRoleWhat it does
sandbox/seamService DefinitionProcess confinement contract
sandbox/bwrapProviderBubblewrap (Linux)
sandbox/landlockProviderLandlock (Linux kernel)
sandbox/seatbeltProviderSeatbelt (macOS)

The agent doesn't have access to the entire disk. Only the workspace and temporary files. Which sandbox backend is used depends on the OS.

Why this matters

1. Swap without changing the consumer

// Before: local filesystem
await root.plugin(LocalFS)

// After: remote E2B filesystem
await root.plugin(E2BFS)

// Consumer (tool-fs) hasn't changed a single line

2. Composition

// Sandbox + policy gate + local FS
await root.plugin(LocalFS)
await root.plugin(SandboxFS)     // fences writes
await root.plugin(ObservationPolicy)  // read-before-edit

3. Testing

// In tests: mock filesystem
await root.plugin(MockFS)

// In production: real filesystem
await root.plugin(LocalFS)

How it differs from dependency injection

AspectDI (e.g., Symfony)Capability Seams
DependencyConstructor injectionProxy resolution
SwapNew class in containerNew plugin
LifecycleContainer managesFiber manages
ScopingRequest scopePlugin scope
CompositionAliases, bindingsPlugin stacking

DI tells you "which class is used." Capability seams tell you "which capability is available" ... and leave it to you to implement it.

→ DeepSeek Harness ... 50 packages: architecture overview → Cordis ... a deep dive: plugin framework → The fridge as a P2P server: hardware for P2P nodes

Sources

Comments (0)

No comments yet — be the first to react.

Reader questions (0)

No questions yet — be the first to ask.

Stuck on something in this article? Ask below. Your name is shown publicly; your email is never stored. A question appears here once a moderator approves it.