local

package
v0.17.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package local provides filesystem and in-memory implementations of the application package's infrastructure ports for local SDD deployments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilesystemGraphStore

type FilesystemGraphStore struct {
	// contains filtered or unexported fields
}

FilesystemGraphStore is the local canonical graph authority. It owns its revision cache and never requires callers to invalidate snapshots.

func NewFilesystemGraphStore

func NewFilesystemGraphStore(options FilesystemGraphStoreOptions) (*FilesystemGraphStore, error)

func (*FilesystemGraphStore) Apply

func (s *FilesystemGraphStore) Apply(ctx context.Context, expectedRevision string, batch app.MutationBatch, blobs app.StagedBlobReader) (app.ApplyResult, error)

func (*FilesystemGraphStore) Current

func (s *FilesystemGraphStore) Current(ctx context.Context) (*app.Snapshot, error)

func (*FilesystemGraphStore) ReadAttachmentPage

func (s *FilesystemGraphStore) ReadAttachmentPage(_ context.Context, entryID, filename string, offset int64, maxBytes int) (app.AttachmentPage, error)

func (*FilesystemGraphStore) Reconcile

func (s *FilesystemGraphStore) Reconcile(_ context.Context, mutationID, batchDigest string) (app.ApplyResult, error)

type FilesystemGraphStoreOptions

type FilesystemGraphStoreOptions struct {
	Project  app.ProjectID
	GraphDir string
}

type FilesystemSessionStore

type FilesystemSessionStore struct {
	// contains filtered or unexported fields
}

FilesystemSessionStore persists each session as an append-only JSONL log. Events stay opaque to the store and every append is version-CAS protected.

It reads across every configured location and appends to whichever one holds the session, so a log written by an earlier version stays live where it lies. New sessions are created in the first location.

func NewFilesystemSessionStore

func NewFilesystemSessionStore(locations ...StoreLocation) (*FilesystemSessionStore, error)

func NewFilesystemSessionStoreAt

func NewFilesystemSessionStoreAt(dir string) (*FilesystemSessionStore, error)

NewFilesystemSessionStoreAt is the single-directory form, for a composition with no location history to resolve across.

func (*FilesystemSessionStore) Append

func (s *FilesystemSessionStore) Append(
	_ context.Context,
	id app.SessionID,
	expectedVersion uint64,
	appendData app.SessionAppend,
) (uint64, error)

func (*FilesystemSessionStore) Create

func (*FilesystemSessionStore) Delete

Delete removes a session's log wherever it lies. A session that is already gone is success: a collection sweep recomputes its target set from scratch every run, so two processes may derive and remove the same one.

func (*FilesystemSessionStore) List

func (*FilesystemSessionStore) Load

type FilesystemStagedBlobStore

type FilesystemStagedBlobStore struct {
	// contains filtered or unexported fields
}

FilesystemStagedBlobStore keeps a session's staged bytes under <subject>/<session>/, so the path itself says whose they are. That is what makes a sweep possible without reading anything: enumeration is a directory walk, and a staging area with nothing in it is still fully identified.

Like the session store it reads across every configured location and writes where it resolved.

func NewFilesystemStagedBlobStore

func NewFilesystemStagedBlobStore(locations ...StoreLocation) (*FilesystemStagedBlobStore, error)

func NewFilesystemStagedBlobStoreAt

func NewFilesystemStagedBlobStoreAt(dir string) (*FilesystemStagedBlobStore, error)

NewFilesystemStagedBlobStoreAt is the single-directory form, for a composition with no location history to resolve across.

func (*FilesystemStagedBlobStore) DeleteStaged

func (s *FilesystemStagedBlobStore) DeleteStaged(_ context.Context, ref app.SessionRef) error

DeleteStaged removes a session's staged blobs and retentions together. An area that is already gone is success, so a sweep is safe to repeat and safe to run concurrently with another.

func (*FilesystemStagedBlobStore) Open

func (*FilesystemStagedBlobStore) Release

func (s *FilesystemStagedBlobStore) Release(_ context.Context, ref app.SessionRef, retentionID string) error

Release drops one retention. A session with nothing staged has nothing to release, so this creates no directory — an empty staging area would be scaffolding that never held anything.

func (*FilesystemStagedBlobStore) Retain

func (s *FilesystemStagedBlobStore) Retain(
	_ context.Context,
	ref app.SessionRef,
	retentionID string,
	ids []string,
) error

func (*FilesystemStagedBlobStore) Stage

func (s *FilesystemStagedBlobStore) Stage(
	_ context.Context,
	ref app.SessionRef,
	filename string,
	content io.Reader,
) (app.StagedBlob, error)

func (*FilesystemStagedBlobStore) StagedSessions

func (s *FilesystemStagedBlobStore) StagedSessions(_ context.Context) ([]app.SessionRef, error)

StagedSessions enumerates every staging area across all locations, read straight from the paths.

func (*FilesystemStagedBlobStore) Stat

type GitFinalizer

type GitFinalizer struct {
	Checkout string
	GraphDir string
	Branch   string
	Timeout  time.Duration
}

GitFinalizer commits only the graph paths in one applied mutation, bound to the acquired checkout rather than process cwd.

func (GitFinalizer) Finalize

func (f GitFinalizer) Finalize(ctx context.Context, mutation app.AppliedMutation) error

func (GitFinalizer) Name

func (GitFinalizer) Name() string

type GitWorktreeAcquirer

type GitWorktreeAcquirer struct {
	// contains filtered or unexported fields
}

GitWorktreeAcquirer rediscoveries one registered checkout for every acquisition. It persists branch authority, never checkout paths.

func NewGitWorktreeAcquirer

func NewGitWorktreeAcquirer(options GitWorktreeAcquirerOptions) (*GitWorktreeAcquirer, error)

func (*GitWorktreeAcquirer) Acquire

func (*GitWorktreeAcquirer) ValidateBranch

func (a *GitWorktreeAcquirer) ValidateBranch(ctx context.Context, target app.MutationTarget) error

ValidateBranch applies the live acquisition rule without opening graph adapters or finalizers.

type GitWorktreeAcquirerOptions

type GitWorktreeAcquirerOptions struct {
	Project        app.ProjectID
	ServerCheckout string
	Factory        TargetRuntimeFactory
}

type MemorySearchIndexStore

type MemorySearchIndexStore struct {
	// contains filtered or unexported fields
}

MemorySearchIndexStore is a process-local mechanical vector index. It is useful for embedded compositions that want root-owned lazy reconciliation without operating a separate persistent index service.

func NewMemorySearchIndexStore

func NewMemorySearchIndexStore() *MemorySearchIndexStore

func (*MemorySearchIndexStore) IndexedEntries added in v0.16.2

func (s *MemorySearchIndexStore) IndexedEntries(_ context.Context, namespace app.IndexNamespace) ([]app.StoredEntryRef, error)

IndexedEntries reports one ref per stored (entry, version) pair — the optional entry-manifest capability the application uses for monotonic, per-version reconciliation. Distinct (entry-id, entry-hash) pairs, sorted for deterministic output.

func (*MemorySearchIndexStore) Manifest

func (*MemorySearchIndexStore) Nearest

func (s *MemorySearchIndexStore) Nearest(_ context.Context, namespaces []app.IndexNamespace, vector []float32, limit int) ([]app.ScoredChunkHit, error)

func (*MemorySearchIndexStore) Reconcile

func (s *MemorySearchIndexStore) Reconcile(_ context.Context, namespace app.IndexNamespace, _ string, upserts []app.IndexedChunk, deletes []string) error

type PersistentSearchIndexStore added in v0.16.2

type PersistentSearchIndexStore struct {
	// contains filtered or unexported fields
}

PersistentSearchIndexStore is the machine-global chromem-backed vector store behind sdd serve — the same content-addressed store the CLI builds and reads (d-cpt-6cq). One store per (repo-key, embedding fingerprint) under the cache root: the request fingerprint selects the final directory at call time, so a lazy embedder that only reports its dimensionality on first use still routes correctly.

Reads hold a generation-checked snapshot cache: each read acquires the shared lock, stats the store's write generation, reuses the held snapshot when it is unchanged, and reloads only after an actual write. Steady state is therefore lock + stat + in-memory query — a full reload happens only when the CLI or another process has written. The cache is guarded by mu (a long-running server serves concurrent reads); the generation check happens under the read lock so a writer between stat and query cannot be missed. Writes still reopen under the exclusive lock (index.WriteStore).

Reconciliation is monotonic: it accumulates chunks for immutable-entry versions and never deletes based on request filters — the sanctioned delete paths are the CLI's explicit rebuild and write-session version GC, not the search path.

func NewPersistentSearchIndexStore added in v0.16.2

func NewPersistentSearchIndexStore(project app.ProjectID, cacheRoot, repoKey string) *PersistentSearchIndexStore

NewPersistentSearchIndexStore builds the adapter for one project. cacheRoot is the machine-global cache root; repoKey is index.RepoKey for the base repo or the connected repo's ID (the existing connected-repository storage contract).

func (*PersistentSearchIndexStore) IndexedEntries added in v0.16.2

func (s *PersistentSearchIndexStore) IndexedEntries(_ context.Context, namespace app.IndexNamespace) ([]app.StoredEntryRef, error)

IndexedEntries reads the manifest and returns one ref per stored (entry, version) pair — no migration, no rebuild, no document embedding. A legacy v1 manifest loads as one version per entry, so an existing store answers its presence immediately. This is the presence source the application reconciles against: a graph entry whose current hash is absent here is embedded as an added version.

func (*PersistentSearchIndexStore) Manifest added in v0.16.2

Manifest reports stored chunk identities across all versions. Kept for the SearchIndexStore contract; the application prefers IndexedEntries for reconciliation.

func (*PersistentSearchIndexStore) Nearest added in v0.16.2

func (s *PersistentSearchIndexStore) Nearest(ctx context.Context, namespaces []app.IndexNamespace, vector []float32, limit int) ([]app.ScoredChunkHit, error)

Nearest opens a fresh read snapshot per operation and maps index hits back to scored chunk hits with complete citation data.

func (*PersistentSearchIndexStore) Reconcile added in v0.16.2

func (s *PersistentSearchIndexStore) Reconcile(ctx context.Context, namespace app.IndexNamespace, _ string, upserts []app.IndexedChunk, deletes []string) error

Reconcile accumulates the given chunks under the exclusive lock. It groups upserts by entry, reopens the latest store inside the lock, adds each entry's rows, and writes the v1 manifest. Graph revision is ignored. Request-driven deletes are refused — deletion is not the search path's job.

type StoreLocation

type StoreLocation struct {
	// Name identifies the location in diagnostics.
	Name        string
	Sessions    string
	StagedBlobs string
	Subject     string
	Project     app.ProjectID
}

StoreLocation is one directory pair sdd has written session material to, together with the identity a log found there is attributed to.

func SessionLocations

func SessionLocations(stateRoot, sddDir, repoID, stableRoot string) ([]StoreLocation, error)

SessionLocations returns every location sdd has ever written sessions to, primary first. Resolution reads across all of them and appends to whichever one answered, so nothing has to move and no home policy is needed.

The order is the write preference: the current repository-identity store, then the identity-less machine-global store earlier versions keyed by stable root hash alone, then the in-tree directory used before the store went machine-global.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL