Documentation
¶
Overview ¶
Package productfiles supplies native private-file operations for Starmap hosts. The host owns path selection, record schemas, and transactions across directories.
Index ¶
- Constants
- func FileIdentity(file *os.File) (string, error)
- func InspectRetainedPublications(ctx context.Context, files map[string]RetainedFile, read RetainedRecordReader, ...) ([]string, error)
- func PublishDirectory(sourceRoot *os.Root, source string, targetRoot *os.Root, target string) error
- func SyncDirectory(root *os.Root) error
- func ValidateAncestors(path string) error
- type Directory
- func (d *Directory) CheckNoPendingPublications(ctx context.Context) error
- func (d *Directory) Child(name string) (*Directory, error)
- func (d *Directory) CompareAndPublish(ctx context.Context, name string, previous, data []byte) error
- func (d *Directory) CompareAndRemove(ctx context.Context, name string, previous []byte) (bool, error)
- func (d *Directory) CompletePublication(ctx context.Context, name string, previous, data []byte, ...) error
- func (d *Directory) CopyFile(ctx context.Context, name string, output io.Writer, maxBytes int64) (int64, error)
- func (d *Directory) CreateChild(name string) (*Directory, error)
- func (d *Directory) ExistingChild(name string) (*Directory, error)
- func (d *Directory) Identity() (identity string, resultErr error)
- func (d *Directory) InspectPublication(ctx context.Context, name string, previous, data []byte) ([]string, error)
- func (d *Directory) Open() (*os.Root, error)
- func (d *Directory) ReadFile(name string, maxBytes int64) ([]byte, error)
- func (d *Directory) RecoverPublications(ctx context.Context) error
- type RetainedFile
- type RetainedRecordReader
Constants ¶
const PublicationDirectoryName = privatefiles.PublicationDirectoryName
PublicationDirectoryName identifies metadata owned by private-record publication. Callers must preserve this directory and use its owner APIs to inspect or recover it.
Variables ¶
This section is empty.
Functions ¶
func FileIdentity ¶
FileIdentity returns the native volume and file identity for an open file or directory. It does not establish ownership or access policy. The caller owns the handle and its validation.
func InspectRetainedPublications ¶
func InspectRetainedPublications(ctx context.Context, files map[string]RetainedFile, read RetainedRecordReader, accepts func(parent, destination, prefix string) bool) ([]string, error)
InspectRetainedPublications selects matching journals and staging files for inactive retention. The owner callback approves destination names and prefixes within each parent directory. The caller preserves selected files and validates the remaining tree before publication. This check never promotes staged bytes or approves current permission.
func PublishDirectory ¶
PublishDirectory moves one direct child between open directories without replacing a destination. The roots must refer to the same filesystem. The move uses their open handles. Callers must sync the source contents before publication and both parents afterward. Success reports namespace publication. It does not establish durability.
func SyncDirectory ¶
SyncDirectory flushes an open directory through the native filesystem API. Filesystem and hardware qualification remain the host's responsibility.
func ValidateAncestors ¶
ValidateAncestors checks an existing path route without creating files or directories. The final entry requires its own type and access checks.
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory binds a private directory to its filesystem identity. Operations check native ownership and access without changing existing permissions. The zero value is invalid. No directory handle remains open between operations.
func CreateDirectory ¶
CreateDirectory exclusively creates one private directory beneath an existing trusted parent. The path must be clean and absolute. Existing targets retain their contents and permissions.
func ExistingDirectory ¶
ExistingDirectory checks an existing private directory without creating paths.
func NewDirectory ¶
NewDirectory creates missing private directories or checks an existing directory. The path must be absolute. Existing ancestors must pass the native access policy.
func (*Directory) CheckNoPendingPublications ¶
CheckNoPendingPublications refuses retained publication journals without changing files. It checks an existing writer lock but creates no lock or metadata directory. The caller must fence writers before copying or publishing inspected state.
func (*Directory) CompareAndPublish ¶
func (d *Directory) CompareAndPublish(ctx context.Context, name string, previous, data []byte) error
CompareAndPublish atomically publishes data if the current bytes equal previous. A nil previous value requires absence. A non-nil empty value requires an empty file. Publication uses a checked writer lock and durable recovery receipts. A PublicationError reports visible bytes whose durability remains unconfirmed.
func (*Directory) CompareAndRemove ¶
func (d *Directory) CompareAndRemove(ctx context.Context, name string, previous []byte) (bool, error)
CompareAndRemove removes a private record only when its bytes equal previous. Missing records permit an idempotent retry. The previous value must not be nil. A true result reports visible removal, including an unconfirmed durability error.
func (*Directory) CompletePublication ¶
func (d *Directory) CompletePublication(ctx context.Context, name string, previous, data []byte, check func(context.Context) error) error
CompletePublication finishes an exact record after the host checks its original decision and native receipt. It refuses foreign journals, changed native identities, and incomplete staging evidence. The callback runs under the writer lock. It must not publish or recover records in this directory. An already published exact value permits a retry. This operation grants no host transaction authority.
func (*Directory) CopyFile ¶
func (d *Directory) CopyFile(ctx context.Context, name string, output io.Writer, maxBytes int64) (int64, error)
CopyFile streams one private regular child file into a caller-owned writer. It checks native access and identity before and after the bounded copy. A failure can follow partial output. The caller must discard that output. Writers must remain fenced. Content hashes remain the caller's responsibility.
func (*Directory) CreateChild ¶
CreateChild exclusively creates one private direct child directory. An existing child produces an existence error without changing that child.
func (*Directory) ExistingChild ¶
ExistingChild checks one existing direct child without creating paths.
func (*Directory) Identity ¶
Identity returns the native volume and file identity of the bound directory. Hosts can retain this value in a private recovery record to detect replacement.
func (*Directory) InspectPublication ¶
func (d *Directory) InspectPublication(ctx context.Context, name string, previous, data []byte) ([]string, error)
InspectPublication checks an exact pending write without cleanup or publication. Stage names let the host read its original decision while those checked records remain pending. Names grant no completion or transaction authority. CompletePublication rechecks every native receipt.
func (*Directory) Open ¶
Open returns a confined root after checking the original directory identity and access. The caller must close the root. Raw root operations retain their standard library contract.
func (*Directory) ReadFile ¶
ReadFile reads one private regular file within a caller-selected byte limit. It refuses links, changed identities, and invalid native access.
func (*Directory) RecoverPublications ¶
RecoverPublications recovers abandoned private-record writes under the checked writer lock. It preserves unknown entries and entries whose identity, bytes, or access changed. This operation does not recover a host transaction across directories.
type RetainedFile ¶
type RetainedFile = privatefiles.RetainedFile
RetainedFile identifies bytes in a verified backup.
type RetainedRecordReader ¶
type RetainedRecordReader = privatefiles.RetainedRecordReader
RetainedRecordReader reads bounded bytes from a verified backup.