Documentation
¶
Overview ¶
Package workspace provides framework-free workspace state and coordination.
Index ¶
- Variables
- func Contains(root, path string) bool
- func ContainsCanonical(root, path string) bool
- func NormalizeTouchPath(path string) string
- type Ledger
- func (l *Ledger) Forget(sessionID, path string)
- func (l *Ledger) ForgetSession(sessionID string)
- func (l *Ledger) RecordRead(sessionID, path string, size int64, hash [sha256.Size]byte)
- func (l *Ledger) RecordWrite(sessionID, path string, size int64, hash [sha256.Size]byte)
- func (l *Ledger) Verify(sessionID, path string, size int64, hash [sha256.Size]byte) error
- func (l *Ledger) VerifyWrite(sessionID, path string, size int64, hash [sha256.Size]byte, exists bool) error
- type MutationQueue
- type Root
- type Touch
- type TouchBus
- type TouchKind
- type TouchObserver
Constants ¶
This section is empty.
Variables ¶
var ( ErrNeverRead = errors.New("workspace file was never read") ErrStaleRead = errors.New("workspace file changed since it was read") )
var ( ErrPathEmpty = errors.New("workspace path is empty") ErrOutsideRoot = errors.New("workspace path is outside root") ErrNotFound = errors.New("workspace path not found") ErrNotDirectory = errors.New("workspace root is not a directory") ErrIsDirectory = errors.New("workspace path is a directory") ErrNotRegularFile = errors.New("workspace path is not a regular file") ErrTooLarge = errors.New("workspace file is too large") ErrBinaryFile = errors.New("workspace file is binary") )
Functions ¶
func Contains ¶
Contains reports whether path is lexically contained by root. Callers that require symlink-aware containment must resolve both paths first.
func ContainsCanonical ¶
ContainsCanonical reports whether path remains beneath root after resolving symlinks. Missing paths fall back to their absolute lexical identity so the same owner can validate prospective inputs.
func NormalizeTouchPath ¶
NormalizeTouchPath returns the slash-separated workspace-relative form used by every lazy activation observer.
Types ¶
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger records the last full-content read or write for each session and path.
func (*Ledger) ForgetSession ¶
ForgetSession removes all states associated with a session.
func (*Ledger) RecordRead ¶
RecordRead records the full-content state observed by a successful read.
func (*Ledger) RecordWrite ¶
RecordWrite records the full-content state produced by a successful write.
type MutationQueue ¶
type MutationQueue struct {
// contains filtered or unexported fields
}
MutationQueue serializes all workspace mutations.
func NewMutationQueue ¶
func NewMutationQueue() *MutationQueue
NewMutationQueue creates a queue with one global mutation slot.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is an immutable, symlink-resolved workspace directory.
func (*Root) Rel ¶
Rel returns a deterministic slash-separated path relative to the root. Callers should pass paths returned by Resolve, ResolveExisting, or ResolveForWrite.
func (*Root) Resolve ¶
Resolve resolves a path inside the root. It works for existing paths and prospective write paths whose final components do not yet exist.
func (*Root) ResolveExisting ¶
ResolveExisting resolves a path and requires it to exist.
type Touch ¶
type Touch struct {
SessionID string
InvocationID string
Path string
Kind TouchKind
Content []byte
Version int64
At time.Time
}
Touch describes a workspace operation. Content is non-nil only for writes and edits. InvocationID is empty outside a native tool invocation.
type TouchBus ¶
type TouchBus struct {
// contains filtered or unexported fields
}
TouchBus fans out touch events in registration order.
func (*TouchBus) Publish ¶
Publish synchronously notifies a snapshot of subscribers in registration order.
func (*TouchBus) Subscribe ¶
func (b *TouchBus) Subscribe(observer TouchObserver) func()
Subscribe adds an observer and returns an idempotent unsubscribe function.
type TouchKind ¶
type TouchKind int
TouchKind identifies the workspace operation that touched a path.
type TouchObserver ¶
TouchObserver receives synchronous workspace touch events.