Documentation
¶
Overview ¶
internal/appstate/lock.go
Package appstate centralises all filesystem state access for the Omniview application, providing a single source of truth for the state directory root.
internal/appstate/scoped.go
Index ¶
- func ResolveRoot() (string, error)
- func SelectedRoot() (string, error)
- func ValidateRoot(root string) (string, error)
- type FilesystemIdentity
- type Option
- type ScopedRoot
- func (s *ScopedRoot) Close() error
- func (s *ScopedRoot) DirectoryIdentity(name string) (FilesystemIdentity, error)
- func (s *ScopedRoot) FS() fs.FS
- func (s *ScopedRoot) MkdirAll(path string, perm fs.FileMode) error
- func (s *ScopedRoot) MkdirTemp(prefix string) (string, error)
- func (s *ScopedRoot) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func (s *ScopedRoot) OpenPrivateFile(name string, flag int) (*os.File, FilesystemIdentity, error)
- func (s *ScopedRoot) ReadDir(name string) ([]fs.DirEntry, error)
- func (s *ScopedRoot) ReadFile(name string) ([]byte, error)
- func (s *ScopedRoot) Remove(name string) error
- func (s *ScopedRoot) RemoveAll(name string) error
- func (s *ScopedRoot) Rename(oldpath, newpath string) error
- func (s *ScopedRoot) RenameDirectoryNoReplace(oldpath, newpath string) error
- func (s *ScopedRoot) ResolvePath(name string) string
- func (s *ScopedRoot) Stat(name string) (fs.FileInfo, error)
- func (s *ScopedRoot) WriteFile(name string, data []byte, perm fs.FileMode) error
- type Service
- func (s *Service) Close() error
- func (s *Service) Logs() *ScopedRoot
- func (s *Service) PluginData(id string) (*ScopedRoot, error)
- func (s *Service) PluginStore(id string) (*ScopedRoot, error)
- func (s *Service) Plugins() *ScopedRoot
- func (s *Service) Root() string
- func (s *Service) RootDir() *ScopedRoot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveRoot ¶
ResolveRoot preserves environment > ldflags > production default outside a workspace. Workspace context fails closed and owns its canonical UUID root.
func SelectedRoot ¶ added in v0.5.0
SelectedRoot returns the explicit environment/build selection, or an empty string. It never supplies the production default to a workspace resolver.
func ValidateRoot ¶ added in v0.5.0
ValidateRoot is also applied to WithRoot: programmatic callers cannot bypass absolute-path, canonical-alias or selected-workspace ownership validation.
Types ¶
type FilesystemIdentity ¶ added in v0.5.0
FilesystemIdentity identifies an owned filesystem object across process restarts. File retains the full Windows FILE_ID_128; Unix stores the inode in its low bytes.
type ScopedRoot ¶
type ScopedRoot struct {
// contains filtered or unexported fields
}
ScopedRoot provides contained filesystem access to a subdirectory. All path arguments are relative to the scope root. The underlying os.Root enforces containment at the kernel level.
func (*ScopedRoot) Close ¶
func (s *ScopedRoot) Close() error
Close releases the underlying os.Root handle.
func (*ScopedRoot) DirectoryIdentity ¶ added in v0.5.0
func (s *ScopedRoot) DirectoryIdentity(name string) (FilesystemIdentity, error)
DirectoryIdentity reads the durable identity of a contained, non-redirected directory owned by the current OS user. The root itself may be inspected as ".".
func (*ScopedRoot) FS ¶
func (s *ScopedRoot) FS() fs.FS
func (*ScopedRoot) MkdirTemp ¶ added in v0.5.0
func (s *ScopedRoot) MkdirTemp(prefix string) (string, error)
MkdirTemp creates a private, exclusive directory through the held root capability, without resolving an absolute pathname outside that capability.
func (*ScopedRoot) OpenPrivateFile ¶ added in v0.5.0
func (s *ScopedRoot) OpenPrivateFile(name string, flag int) (*os.File, FilesystemIdentity, error)
OpenPrivateFile validates a contained regular file and its owner before the caller reads its contents. It returns identity proof for subsequent removal.
func (*ScopedRoot) ReadDir ¶
func (s *ScopedRoot) ReadDir(name string) ([]fs.DirEntry, error)
ReadDir reads the named directory relative to the scoped root. Implemented as Open + (*File).ReadDir since os.Root does not expose ReadDir.
func (*ScopedRoot) Remove ¶
func (s *ScopedRoot) Remove(name string) error
func (*ScopedRoot) RemoveAll ¶
func (s *ScopedRoot) RemoveAll(name string) error
func (*ScopedRoot) Rename ¶
func (s *ScopedRoot) Rename(oldpath, newpath string) error
func (*ScopedRoot) RenameDirectoryNoReplace ¶ added in v0.5.0
func (s *ScopedRoot) RenameDirectoryNoReplace(oldpath, newpath string) error
RenameDirectoryNoReplace atomically moves a contained directory only when the destination does not exist. It never emulates exclusion with check-then-rename or copy/delete; unsupported filesystems and kernels return an error.
func (*ScopedRoot) ResolvePath ¶
func (s *ScopedRoot) ResolvePath(name string) string
ResolvePath returns the absolute path for a relative name within the scoped root. If name is empty, the root path itself is returned. If name fails validation (e.g. absolute path or traversal), the root path is returned as a safe fallback.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the central authority for all application state filesystem access. Create once at startup via New() and inject into subsystems.
func NewTestService ¶
NewTestService creates a Service backed by a temporary directory for use in tests. The service is automatically cleaned up when the test finishes.
func (*Service) Close ¶
Close releases all resources held by the Service. Errors from individual close operations are aggregated and returned together. Close is idempotent; subsequent calls return the result of the first call.
func (*Service) Logs ¶
func (s *Service) Logs() *ScopedRoot
Logs returns the scoped root for the logs directory.
func (*Service) PluginData ¶
func (s *Service) PluginData(id string) (*ScopedRoot, error)
PluginData returns a scoped root for a specific plugin's data directory. The result is cached; subsequent calls for the same id return the cached instance.
func (*Service) PluginStore ¶
func (s *Service) PluginStore(id string) (*ScopedRoot, error)
PluginStore returns a scoped root for a specific plugin's store directory. The result is cached; subsequent calls for the same id return the cached instance.
func (*Service) Plugins ¶
func (s *Service) Plugins() *ScopedRoot
Plugins returns the scoped root for the plugins directory.
func (*Service) RootDir ¶
func (s *Service) RootDir() *ScopedRoot
RootDir returns the scoped root for the top-level state directory.