Documentation
¶
Overview ¶
Package core provides authorized file management over prepared storage mounts.
Call Stat, List, or Open with an explicit Principal. Close every returned content Body. The creator closes a rejected Driver; Install transfers ownership only on success. The embedding application eventually calls Core.Close with its chosen wait context. Drivers keep physical paths, provider IDs and temporary URLs private.
Addresses and queries ¶
All file operations accept Address: Path("/files/a") selects the tree view; Key("/cloud", "a//b") selects an exact key in that installed binding. Space is an existing mount/alias prefix, not a second registry or a credential owner. Constructors preserve bytes; admission validates their namespace. Authorization receives the full Address and must distinguish tree paths, keys and prefixes. Entry.Address retains that distinction; a key Entry.Name is the visible key.
ListRequest.Query is Children(Path(...)) or Keys(space, prefix, delimiter). Query.After is a literal native start-after key, not a Core cursor. PrefixGroup entries carry Prefix addresses and are listing selectors, never directories or file mutation targets. Delimiter/ordering semantics belong to the Driver. Native keys do not pass through path normalization or tree ancestor checks. Tree-only drivers reject key addresses before consuming input or making effects.
Drivers receive NativeAddress/NativeQuery after root projection. NamespaceSupport advertises key support; optional KeyProjection conservatively describes overlap between tree and key views without native I/O. Both views retain the same mount, budget, mutation revision, authorization and retirement owner. These addresses name execution-time resources, not immutable content or persistent object IDs.
ListRequest.CursorTTL supplies an absolute lifetime on the first enumeration request. A continuation inherits it when zero, or must match it when supplied. Stat and Open need no enumeration policy. MaxCursors and OpenTimeout are optional runtime policies. Hosts choose values; there are no benchmark defaults. Continuations bind principal, the complete Query, mount generation and limit. The latest continuation response is replayable until advancement; competing advancement returns 429 instead of queuing. ReleaseCursor explicitly releases one enumeration. Cursors do not survive process restart.
Mount.Retire rejects new uses, invalidates enumerations and requests cancellation. Its context limits the wait, not unfinished work. Cleanup failures preserve the cause and owned resource; no automatic replacement or retry is claimed.
Directory aliases ¶
BindAlias(ctx, prefix, mount, base) exposes an existing mount-relative directory under a fixed prefix. Ordinary mount entries and aliases share namespace lookup. All entry prefixes must be unique and non-nested. Targets are real installed Mount handles, so aliases cannot chain or merge storage. The base is a path mapping, not a pinned directory-object version.
An alias owns no Driver, connection or credentials. Every action checks both its visible path and corresponding primary path through the same Authorizer. Tree mutations reject alias roots just like mount roots. Explicit aliases share mount revisions and retirement; equivalent resolved Copy/Move endpoints are rejected. No implicit physical-alias discovery across independent mounts is promised.
UnbindAlias removes the entry and invalidates its cursors, waiting for their cleanup within the supplied context. Already opened bodies retain their original mount use. A replacement mount requires explicit rebinding; queued work captured on an old binding cannot silently switch to the replacement. Hosts own alias persistence and control-plane authorization, just as they own prepared Install.
Optional mutations ¶
Core.Mkdir and default Core.Write/Core.Create require CreateAction on the target; explicit replacement requires WriteAction, which permits creation or replacement at that name. Core.Remove requires RemoveAction. Policies granting only StatAction, ListAction and ReadAction remain read-only. An authorizer that ignores the action and returns nil for everything is a wildcard grant.
DirectoryMaker, Remover, FileCreator and FilePublisher are independent optional interfaces. The required Driver and Iterator interfaces are unchanged. Unsupported mounts return UnsupportedOperation with Unchanged before target effects or input reads. There is no second writer runtime, permission table or provider registry.
Create borrows an io.Reader until it returns. The caller retains ownership and closes owned input afterward. A nil length permits unknown input length; a nonnegative length describes the entire input, including normal EOF. Short, overlong and failed input cannot report successful completion. The operation does not seek, replay or close the input. A blocking reader may keep retirement unfinished even after cancellation.
Change.Effect is independent of error: Unknown (the zero value), Unchanged, Applied or Incomplete. Check both. Confirmed effects survive cancellation and cleanup failure; do not automatically retry or delete a failed target by path.
Default new-file creation may be visible while being written, and failed input can leave an incomplete file. This mode has no complete-publication or append guarantee. Explicit complete publication is described below. Failed native cleanup remains owned by the Driver and prevents successful retirement.
WriteOptions.Continuation optionally supplies protected native recovery records for an immutable Replayable input. It preserves the selected write policy: ordinary creation may report Incomplete; explicit Publish retains complete publication guarantees. Cancellation pauses the attempt, while Abort requests native cleanup without undoing published content. Durable input retention and intent persistence remain with the caller or optional transfer package.
A possible mutation invalidates existing cursors for that mount before its result returns, including EOF replay. Other mounts and opened content are not invalidated by this coordination. Already-admitted reads may finish with an earlier observation; enumeration is not a snapshot.
Protocol delivery belongs to the packages under protocols/. The JSON HTTP wire contract is maintained by protocols/httpapi and api/openapi.json.
Bound file reading ¶
OpenOptions{Mode: BoundRead} uses the same Core/Driver.Open and returns Content.File (*BoundFile), exclusively of Body. Its native port is ReadFile: ReadAt(context.Context, []byte, int64), Stat(context.Context) and Close(). Core Stat returns Entry; native Stat returns Metadata for the original opened name. Each logical call renews ReadAction or StatAction and checks its original binding generation, without resolving that name or borrowing another use.
The opening context bounds construction only. Once adopted, File owns one use until Close or retirement. ReadAt follows io.ReaderAt byte/EOF rules; EOF and per-call cancellation do not close File. Calls on one File are serial; waits are cancelable, and different files are independent. Close needs no permission, stops admission, cancels active work and joins both native Close and calls. A failed Close keeps the original cleanup owner and prevents successful retirement. The host bounds retained files and concurrent callers; no global handle table or task queue is introduced. StreamRead/zero OpenOptions keeps ordinary Body and WriterTo, including its request lifetime and EOF cleanup.
OpenOptions.Binding requests minimum strength; zero means BoundObject. Content.Binding reports the supplied strength. BoundObject fixes resource identity, allowing in-place content changes; PinnedVersion also fixes contents. Local holds its fd and refuses PinnedVersion. Pool holds its immutable generation pin and reuses the stripe decoder, returning window credits after every ReadAt. S3 requires a non-null VersionId obtained at open; each Range and Stat uses that version directly. External deletion fails instead of reopening the current key. Alipan refuses BoundRead until equivalent native lifetime can be established. Range is a stream selection and cannot be combined with a File mode; offsets belong to ReadAt. No HTTP handle route is added here.
Visible editing and receive order ¶
OpenOptions{Mode: LiveEdit} opens an existing file for WriteAction. Read: true additionally requires ReadAction before any opening effect. Creation selects OpenExisting (zero), OpenOrCreate or exclusive OpenNew; Truncate acts during Open. Content.Change retains known opening effects even when adoption or cleanup fails. This mode requires BoundObject and refuses immutable version selection.
The same BoundFile provides WriteAt(ctx, bytes, offset), Append(ctx, bytes), Truncate(ctx, size) and Sync(ctx). Native Opened.File implements EditFile, selected once at adoption. Byte methods return n, Change and error independently; short writes retain their visible prefix. AppendOnly permits Append and refuses WriteAt, using native end-of-file writes rather than Stat followed by WriteAt. Sync explicitly requests native file durability, not a parent-name transaction. Close is cleanup, not publication. Local supplies Windows/Linux editing; object upload adapters refuse the mode without attempting a read/reupload emulation.
Optional NewOrderScope(capacity) bounds active plus waiting operations. Reserve turns in trusted receive order before concurrent dispatch, then pass each turn.Context() to the same Core or File API. Defer turn.Cancel() for abandoned reservations. Internal compositions enter once, preserving existing finite-batch concurrency. A scoped File requires fresh turns of its opening scope. Stream bodies retain the turn through real completion; persistent Open releases it after handoff. No goroutine lock race is advertised as receive order.
Unknown effects stop that scope; known partial effects do not. Stop cancels contexts but leaves native acknowledgments with their original owners. Close and ReleaseCursor bypass ordering so cleanup cannot wait behind itself. Each turn covers one Core operation, not an arbitrary protocol transaction; protocol request framing and waiting before a requested CLOSE remain host-owned. Other scopes, unscoped calls and external writes are independent. There are no new task records, worker pools, distributed locks or HTTP routes.
Complete file publication ¶
Core.Write(ctx, principal, target, input, length, options...) is the common body write entry. Core.Create remains its default new-file shorthand. Supply at most one WriteOptions. Its zero policy directly creates a new file and may leave partial new content on failure. Policy: Publish() creates or replaces a file; Publish(IfAbsent()) publishes exclusively. Both validate complete input, including normal EOF and any declared length, before publication. Input is never replayed or closed by the operation. CopyOptions separates Source ReadSelection from Target WriteOptions; each CopyRequest retains these options for CopyBatch. CopyTree accepts WriteOptions through DirectoryCopyOptions independently of whole-tree target policy. Move defaults to no replacement; explicit Replace records target removal separately from its final exclusive native relocation. ObserveTarget requests Change.Before for response classification. This is a native observation, not a CAS guarantee; ordinary publication need not add a HEAD for it. The exclusive predicate itself is enforced by native commit.
FilePublisher is a narrow optional Driver capability, separate from FileCreator. Unsupported capability or known Local configuration/volume mismatch is refused before reading input. Preparation and input failures leave the target Unchanged. A confirmed native publication reports Applied even with a subsequent cancellation or cleanup error. Unconfirmed publication stays Unknown; partial-publication receipts violate the capability and are reported conservatively. There is no automatic retry, rollback or power-loss durability.
Evidence keeps Validator comparison and immutable Version selection distinct. IfMatch is a strong comparison; IfNotMatch uses weak comparison. IfPresent and IfAbsent test presence. All combines at most one positive and one negative test, without an expression tree. Tag sets are canonical comparable values. Publish(When) enforces the predicate at the actual native commit. A failure reports PreconditionFailed and an Unchanged target; native private cleanup may still be owed. Unsupported conditions are not treated as failed comparisons. Local has no strong validator; S3 uses native ETags and supported SDK guards; Pool compares generations in its transaction. Ordinary reads add no hash/HEAD. OpenOptions holds Range and ReadSelection; Stat accepts an optional selection. Source copy conditions apply to the actual open, target conditions to commit. RemoveOptions and MoveOptions use these same predicates. RemoveOptions.Target constrains the native Remove effect to a non-directory name or empty directory. Single removal needs only Remover; tree operations reuse ChildRemover on their bound parents. Move keeps source and target evidence and receipts distinct. Tree policies do not broadcast one file validator over all members.
Native staging configuration, byte budgets and commit limits belong to the Driver. See package github.com/nostalume/mountweave/drivers/local for the filesystem implementation's publication and cleanup requirements.
A write retains its captured mount and parent through transfer, publication and cleanup. If the parent is moved meanwhile, the bound original directory remains the destination; new requests resolve the current namespace independently. Alias rebinding never redirects started work, and queued work rechecks its binding. Cancellation requests stop; the call still waits for borrowed input and cleanup acknowledgments. Cancellation can race with native publication, so inspect both Change and error.
Existing batch conflict ranges cover source reads and target writes for the whole operation. They preserve call-local order and the started result prefix. Separate calls have no shared path lock: writes, removes and parent moves may compete. A confirmed effect does not promise the current path still holds that result. Concurrency defaults to one. With W in-flight publications, stream buffers grow with W, and unpublished bytes are additionally bounded by the configured instance budget. Native filesystem work can reject publication after transfer; there is no truncation, copy/delete or delayed-success fallback.
Copy files ¶
Core.Copy(ctx, principal, source, target, options...) writes the complete source body to a new target by default. It uses ReadAction and CreateAction, without requiring Stat or List grants. Explicit WriteOptions{Policy: Publish()} instead uses WriteAction and the same complete-publication path as Core.Write. The target parent must exist; source and target paths must differ. Distinct paths within one mount or across mounts are supported. Copy does not remove source or copy metadata.
Copy borrows the opened Body and Length to the common write path, waits for that call to return, then closes the source and preserves observed cancellation. Check both Change.Effect and error. Default copies may leave incomplete targets; explicit replacement follows the complete-publication contract above. Source opening can independently refresh credentials. Neither mode promises a source snapshot, hard native-I/O cancellation deadline or durable job. Copy is included in the root test command and needs no additional module.
Rename and move entries ¶
Core.Move(ctx, principal, source, target) unifies renaming, moving and changing both parent and name. It requires RemoveAction at source and CreateAction at target. MoveResult contains Source and Target changes: confirmed source-name removal and complete target creation. Both must be Applied and error must be nil for completion without errors. Applied can coexist with cancellation or cleanup errors; inspect receipts and error together and do not automatically replay. MoveOptions.Existing defaults to CreateNew. Replace first tries the same exclusive native relocation, then removes an existing target only on a proven unchanged conflict. MoveResult.Removed preserves that separately confirmed phase; the final relocation stays exclusive and never removes a later peer. Tree budgets must be positive if target removal encounters a directory.
Same-mount moves use Relocator and map the native receipt to both endpoints. Same-mount directory moves transfer the directory entry without walking its children. NoCopy requires this path. Mount and alias roots, equivalent resolved endpoints and targets inside the source path are rejected.
A cross-mount move requires an absent target. MoveSource ties the opened file version to a native conditional removal. The target publishes complete input exclusively before Core reauthorizes and removes that exact source. A failed or uncertain publication retains the source. An error can leave a confirmed target, so use the two endpoint receipts to decide what remains.
Cross-mount directories require positive Tree budgets and source directory identities. MoveDirectoryWriter enforces target parent identities at creation and publication. Core discovers bounded names, checks descendant grants, and publishes a group of files before removing their source names. Source directories are then removed from the bottom up, only if still the same directory and empty. MoveResult.Tree retains the attempted phases. These receipts describe this operation's effects amid independent mutations.
Native relocation guarantees and platform support belong to each Driver.
Batch file operations ¶
Core.RemoveBatch(ctx, principal, targets, options...), Core.CopyBatch(ctx, principal, requests, options...) and Core.MoveBatch(ctx, principal, requests, options...) retain input order and duplicates. MoveBatch takes []MoveRequest with Source and Target paths. Supply at most one ExecutionOptions. Concurrency zero or one is serial; negative values are invalid. Existing calls without options preserve serial behavior.
Explicit concurrency uses a shared, call-scoped executor. It resolves known aliases to mount generations and relative paths, and preserves read/write conflicts on equal or ancestor paths. Copy includes its source read and target write; Remove includes its target write; Move includes both endpoint writes. A blocked next item is not bypassed. Unknown locations act as conservative barriers. This orders known namespace conflicts within the call, without providing cross-request locks, physical-alias discovery or protection from external writers.
RemoveBatch and CopyBatch return []ItemResult with Change and Err; MoveBatch returns []MoveItemResult embedding MoveResult (Source and Target) plus Err. Each result slice is the started input prefix, in input order. Captured endpoint bindings are checked again at admission, so queued work cannot switch to a recreated alias or replacement mount. The first observed item error stops dispatch, including Applied with an error. With concurrency, later items may already have started; all in-flight items finish under their original contexts and keep their actual receipts. User cancellation requests cancellation of native work. The call waits for its resource handoffs before returning, without a hard native-I/O deadline. The overall error also retains cancellation observed between items or after the last success, without rewriting recorded item errors.
Empty input performs no authorization or native work, but reports observed cancellation. Results grow with K attempted items, and executor state is bounded by the chosen concurrency. Calls do not retain input lists, retry, roll back or create durable jobs.
Directory copy ¶
Core.CopyTree(ctx, principal, source, target, TreeOptions, directoryOptions...) copies a file leaf or selected directory into its corresponding target, whose parent must exist. It uses ListAction on source directories and ReadAction on copied files. Target directories and default file creation use CreateAction; explicit file publication uses WriteAction. The default requires new target names. It preserves empty directories without metadata preservation or source deletion.
Supply at most one DirectoryCopyOptions. Existing: Merge reuses existing directories and creates missing ones. Only an unchanged existence conflict followed by successful no-follow directory confirmation and cleanup is accepted. Reused directories report Unchanged with no error; this receipt does not summarize their descendants. File names still conflict by default, and type collisions fail; extra target entries are retained. Ordinary Mkdir keeps its rule. Merge requires DirectoryReader on the target, checked before mutation; native confirmation can still fail later after earlier directory effects. Confirmation uses CreateAction without additional Stat/List grants or consuming the returned target iterator. Native path resolution remains driver-specific.
Existing: Replace removes all old target membership after bounded discovery and known admission checks, then creates the new root exclusively. It is not Merge: target-only names are removed, including type conflicts. Failed later work retains confirmed removal receipts without rollback. Source and old-target plans are bounded separately; both their plans/receipts contribute memory cost. Depth defaults to Recursive; Self creates only the directory shell. File leaves ignore depth, reuse no-follow Open and accept zero traversal budgets. Root kind observation adds no StatAction grant. Actual file reads retain Source conditions; directory roots refuse version/finite validator predicates before child effects.
DirectoryCopyOptions embeds WriteOptions independently of Existing. Explicit WriteOptions{Policy: Publish()} publishes each complete file at its target name, creating missing files or replacing existing ones. It uses WriteAction on files and requires FilePublisher rather than FileCreator. Directories still use CreateAction and do not merge unless Existing: Merge is explicit. A new tree can also select complete file publication without directory merging.
The default retains ordinary Create semantics, including possible Incomplete effects on failure. Explicit publication reuses the single-file contract and Local staging budget/commit capacity. Failed input preserves that file's old target; confirmed earlier files and directories remain. This is not a whole-tree transaction. Known missing interfaces are refused before target mutation; driver configuration, per-file authorization and native submission failures can still occur after earlier effects. Input is not replayed, and publication never falls back to default creation. Inspect per-item Change and error on failure. The target tree is resolved by name per operation, without a physical-tree pin or transaction. Observed target links/redirects are refused during confirmation; external replacements afterward can change later path resolution. Confirmation does not supply parent-relative writes or a lasting link-free guarantee.
TreeOptions embeds ExecutionOptions and requires positive MaxEntries and MaxPlanBytes chosen by the caller. The root counts as an entry; the byte budget counts relative-path UTF-8 bytes in the plan, not content or native responses. Source scans also bound empty nonterminal advances with MaxEntries. Budget exhaustion is an error, never successful truncation. TreeCopyOptions remains a type alias for existing callers.
Discovery completes and closes all enumerations before target mutation. Directories are created parent-first and serially. File groups prepare bounded batches of at most W source directory scopes, each with a completed membership scan, then share one executor budget of at most W file operations. W is the requested concurrency, defaulting to one. Dispatch and results retain contiguous group order; adjacent groups can overlap without a worker pool per directory. Scopes close only after all started bodies finish. Membership scans retain their per-directory budgets; explicit concurrency can retain up to W directories' lookup state. A preparation failure leaves that batch unstarted; earlier effects remain. File bodies retain the existing Open/write ownership, length and cleanup contracts. Core adds no extra content staging or shared directory cache; explicit publication uses the Driver's configured private storage.
DirectoryReader is optional and leaves the required Driver unchanged. DirectoryScope reuses Iterator and adds OpenFile for an observed child name, available after normal enumeration EOF. OpenFile may run concurrently; Next has one caller, and all returned bodies must finish before Close. Source scopes reject native links/redirects at actual opens. Local supports this on Windows and Linux; Windows reparse points are refused, and unsupported platforms refuse before target mutation. S3 and alipan also provide source scopes. Destination capabilities remain independent: Local and Pool supply directory creation; see each Driver for its capabilities.
TreeResult reports whole Change and ordered Items. Each TreeItemResult keeps RelativePath ("/" for the root), Side, Phase, ErrorSide, Change and Err. Target removal precedes creation, followed by file groups. Preparation/read/cleanup failures retain their provenance; successful cleanup has no separate row. Applied means the selected operation completed, not that every item changed. Discovery, budget or discovery-close failure leaves the target untouched. Execution or later source preparation failure can leave a partial target; inspect both returned rows and the overall error. Confirmed effects survive cancellation or cleanup faults. Only discovered entries are included, without a directory/content snapshot, stable versions or a promise about undeclared physical overlap. Resolved same-mount source/target containment is refused.
Directory removal ¶
Core.RemoveTree(ctx, principal, target, TreeOptions, DirectoryRemoveOptions...) defaults to Discovered: remove a file leaf or directory using a finite name plan. Core.Remove remains nonrecursive. Mount, alias and virtual roots require ContentsOnly and are preserved by it. Positive directory budgets have the same meaning as CopyTree. Discovery, name validation, known capability checks, authorization preflight and enumeration cleanup finish before any deletion.
Discovery requires ListAction on directories and RemoveAction on every planned entry, including the root. Per-entry discovery authorization does not register a runtime mount use and does not reserve future permission. Each deletion is admitted again against the captured binding and borrows its own runtime use. It requires no content ReadAction and does not enumerate the target's outside parent. Discovery accepts ordinary files and directories; observed links, redirects or special objects are refused before effects.
Selection means names, not discovered object versions. A compatible same-name replacement can be removed, including a file whose content has changed. Unlisted new names are not chased. Nonempty directories return DirectoryNotEmpty; missing planned entries return Unchanged with NotFound and stop execution. An execution parent is opened without following redirects and then remains bound for its group. Final links are never followed; a non-directory unlink can remove the link itself. External renames are not transactionally isolated.
Parent groups execute deepest-first, retaining discovery order within each depth and group. Children finish and their parent scope closes before that directory can be removed; the target root is last. Within each depth, batches prepare at most W parent scopes and share one executor budget of W in-flight deletions, using the same ExecutionOptions and defaulting to serial execution. Dispatch and results keep contiguous group order; adjacent independent parents can overlap. A preparation failure leaves that batch unstarted and closes its prepared scopes. All started items finish and all batch scopes close before another batch starts. There is no worker pool per directory or global lock.
The optional ChildRemover capability belongs to DirectoryScope. RemoveChild takes one child name and the same RemoveOptions, including type and native conditions. It needs no enumeration first. Calls can overlap each other, but not Next, OpenFile or Close. Local implements it with parent-relative unlinkat on Linux and parent-relative DELETE handles with POSIX disposition on Windows. A successful Windows delete-handle close confirms namespace removal; pending deletion alone is not reported as Applied. Unsupported native modes have no recursive or delayed-success fallback. S3 and Alipan read scopes remain read-only; their default Discovered removal is unsupported. Pool supplies ChildRemover.
Core.Remove accepts a disposition for one entry. RemoveTrash requires a confirmed move to the source's Trash. RemovePermanent requests direct removal without a Trash entry and requires PurgeAction. Explicit calls require the optional DispositionRemover and preserve native type and condition constraints. With no disposition, Remove uses the source's ordinary behavior. RemoveTree and protocol removal use that ordinary behavior.
Explicit DirectoryRemoveOptions{Scope: Subtree} requires RemoveTreeAction on the target, including its physical alias target. That grant authorizes subtree traversal and deletion, including newly added descendants; an entry's ordinary RemoveAction alone is insufficient. The optional Driver SubtreeRemover supplies native deletion with one root receipt. Without it, Core reuses the finite planner and executor, renewing the root subtree grant for client steps instead of requiring child ListAction/RemoveAction. Native execution need not enumerate descendants or return invented per-child results. TreeOptions bounds client discovery/planning, not total native affected entries or provider concurrency. S3 uses finite key discovery and batches of at most 1,000, removes its marker after acknowledged child batches, then observes prefix absence. New remaining keys return DirectoryNotEmpty with retained effects. Alipan captures a directory ID and waits for synchronous confirmation or native deletion-task success. Task acceptance alone is not Applied. Canceling a native wait may leave remote deletion running and reports Unknown; it does not undo deletion. No strategy automatically broadens scope, continually chases additions or prevents later recreation. Frontend confirmation belongs to the caller.
RemoveTree also accepts file leaves with zero traversal budgets, reusing Remove authority and its native predicate. DirectoryRemoveOptions.When is a file-root predicate; nonempty directory guards without commit proof are refused before child effects and never broadcast to descendants. RemoveTree returns TreeResult in started execution order, with "/" for the root. Every item keeps its Change and Err; cancellation, preparation and cleanup errors are also retained by the overall error. Already confirmed effects are not rolled back or rewritten. Applied describes this operation's name removal, not storage reclamation or protection against later recreation. Failed cleanup stays owned by its original scope/Driver. There are no retries, durable jobs or cross-mount Move guarantees.
Captured access routes preserve the alias used by the caller and the installed generation's rooted address together. Read/write composition and owned directory scopes retain that same location; a retired route never resolves to a replacement. Each child operation renews its current grant, including the primary path grant for aliases. Returned entry paths project from the admitted access route. These captured addresses do not identify immutable file content or persistent objects.
Index ¶
- Constants
- Variables
- func Fail(code Code, cause error) error
- func ValidName(s string) bool
- func ValidatePath(p string) error
- func Within(p, root string) bool
- type Action
- type Address
- type AddressAccess
- type Authorizer
- type BindingInfo
- type BoundFile
- func (f *BoundFile) Append(ctx context.Context, p []byte) (int, Change, error)
- func (f *BoundFile) Close() error
- func (f *BoundFile) ReadAt(ctx context.Context, p []byte, offset int64) (int, error)
- func (f *BoundFile) Stat(ctx context.Context) (Entry, error)
- func (f *BoundFile) Sync(ctx context.Context) error
- func (f *BoundFile) Truncate(ctx context.Context, size int64) (change Change, err error)
- func (f *BoundFile) WriteAt(ctx context.Context, p []byte, offset int64) (int, Change, error)
- type Change
- type ChildRemover
- type Code
- type Condition
- func (c Condition) Check(e Evidence, exists bool) error
- func (c Condition) Domain() string
- func (c Condition) Empty() bool
- func (c Condition) ForDomain(domain string) error
- func (c Condition) IsAbsent() bool
- func (c Condition) IsPresent() bool
- func (c Condition) MarshalJSON() ([]byte, error)
- func (c Condition) Match() string
- func (c Condition) NotMatch() string
- func (c *Condition) UnmarshalJSON(data []byte) error
- func (c Condition) Validate() error
- type ConditionFailure
- type Content
- type ContentRange
- type ContinuableWriter
- type CopyOptions
- type CopyRequest
- type Core
- func (c *Core) BindAlias(ctx context.Context, prefix string, mount *Mount, base string) error
- func (c *Core) Binding(prefix string) (BindingInfo, bool)
- func (c *Core) Capture(ctx context.Context, accesses ...AddressAccess) (*Selection, error)
- func (c *Core) CheckCursor(ctx context.Context, p Principal, r ListRequest) error
- func (c *Core) Close(ctx context.Context) error
- func (c *Core) Copy(ctx context.Context, principal Principal, source, target Address, ...) (change Change, err error)
- func (c *Core) CopyBatch(ctx context.Context, p Principal, requests []CopyRequest, ...) ([]ItemResult, error)
- func (c *Core) CopyInto(ctx context.Context, p Principal, source, directory Address) (destination Address, change Change, err error)
- func (c *Core) CopyTree(ctx context.Context, p Principal, sourceAddress, targetAddress Address, ...) (result TreeResult, err error)
- func (c *Core) CopyTreeInto(ctx context.Context, p Principal, source, directory Address, ...) (destination Address, tree TreeResult, err error)
- func (c *Core) Create(ctx context.Context, p Principal, target Address, input io.Reader, ...) (Change, error)
- func (c *Core) Inspect(ctx context.Context, p Principal, action Action, target Address, ...) (Entry, error)
- func (c *Core) Install(p string, d Driver) (*Mount, error)
- func (c *Core) List(ctx context.Context, p Principal, r ListRequest) (Page, error)
- func (c *Core) Lstat(ctx context.Context, p Principal, target Address) (Entry, error)
- func (c *Core) Mkdir(ctx context.Context, p Principal, target Address) (result Change, err error)
- func (c *Core) Move(ctx context.Context, p Principal, source, target Address, ...) (result MoveResult, err error)
- func (c *Core) MoveBatch(ctx context.Context, p Principal, requests []MoveRequest, ...) ([]MoveItemResult, error)
- func (c *Core) MoveInto(ctx context.Context, p Principal, source, directory Address, ...) (result MoveResult, err error)
- func (c *Core) Open(ctx context.Context, p Principal, target Address, options OpenOptions) (result Content, err error)
- func (c *Core) ReleaseCursor(ctx context.Context, p Principal, token string) error
- func (c *Core) Remove(ctx context.Context, p Principal, target Address, policies ...RemoveOptions) (result Change, err error)
- func (c *Core) RemoveBatch(ctx context.Context, p Principal, targets []Address, ...) ([]ItemResult, error)
- func (c *Core) RemoveTree(ctx context.Context, p Principal, targetAddress Address, options TreeOptions, ...) (result TreeResult, err error)
- func (c *Core) Stat(ctx context.Context, p Principal, target Address, selections ...ReadSelection) (Entry, error)
- func (c *Core) UnbindAlias(ctx context.Context, prefix string) error
- func (c *Core) Write(ctx context.Context, p Principal, target Address, input io.Reader, ...) (result Change, err error)
- func (c *Core) WriteInto(ctx context.Context, p Principal, directory Address, name string, ...) (destination Address, change Change, err error)
- type DirectoryCopyOptions
- type DirectoryIdentity
- type DirectoryMaker
- type DirectoryReader
- type DirectoryRelocator
- type DirectoryRemoveOptions
- type DirectoryScope
- type DispositionRemover
- type Driver
- type EditFile
- type Effect
- type Entry
- type Error
- type Evidence
- type ExecutionOptions
- type FileBinding
- type FileCreation
- type FileCreator
- type FilePublisher
- type ItemResult
- type Iterator
- type KeyExtent
- type KeyProjection
- type Kind
- type LeafStatter
- type ListRequest
- type Metadata
- type Mount
- type MountStatus
- type MoveDirectoryWriter
- type MoveItemResult
- type MoveOptions
- type MoveRequest
- type MoveResult
- type MoveSource
- type Namespace
- type NamespaceSupport
- type NativeAddress
- type NativeQuery
- type OpenMode
- type OpenOptions
- type Opened
- type OperationError
- type OperationPhase
- type Options
- type OrderScope
- type OrderTurn
- type Page
- type Principal
- type PublicationOptions
- type Query
- type Range
- type ReadFile
- type ReadSelection
- type Relocator
- type RemovalScope
- type RemoveDisposition
- type RemoveOptions
- type RemoveTarget
- type Remover
- type Replayable
- type ResultSide
- type Selection
- type SubtreeRemover
- type TargetPolicy
- type TargetPresence
- type TreeCopyOptions
- type TreeDepth
- type TreeItemResult
- type TreeOptions
- type TreeResult
- type Validator
- type Version
- type WriteContinuation
- type WriteOptions
- type WritePolicy
Constants ¶
const ( DefaultPage = 100 MaxPage = 200 MaxPathBytes = 4096 MaxPathSegments = 64 )
Variables ¶
var ErrOrderStopped = errors.New("order scope stopped")
var ErrOrderUncertain = errors.New("order scope has an unconfirmed operation")
Functions ¶
func ValidatePath ¶
Types ¶
type Action ¶
type Action string
const ( StatAction Action = "stat" ListAction Action = "list" ReadAction Action = "read" CreateAction Action = "create" CreateChildAction Action = "create_child" // Grants creation of a new direct child under this directory. WriteAction Action = "write" // Explicit create-or-replace permission. RemoveAction Action = "remove" PurgeAction Action = "purge" // Explicit permanent removal of one entry. RemoveTreeAction Action = "remove_tree" // Grants deletion and traversal of a whole subtree. )
type Address ¶ added in v0.2.0
type Address struct {
// contains filtered or unexported fields
}
Address is a visible tree path, an exact key in a binding, or a key prefix. Constructors preserve bytes. Core validates at admission; prefixes select listings/ranges and cannot be used as file mutation targets.
func (Address) MarshalJSON ¶ added in v0.2.0
func (*Address) UnmarshalJSON ¶ added in v0.2.0
type AddressAccess ¶ added in v0.2.0
AddressAccess describes a logical range for capture and optional conflict checks. Write is scheduling metadata, not an authorization grant.
type BindingInfo ¶
BindingInfo is an observation, never an execution credential.
type BoundFile ¶ added in v0.2.0
type BoundFile struct {
// contains filtered or unexported fields
}
BoundFile owns a bound resource and one mount use. Calls renew the original address's authority/generation without resolving its current object. Calls on one File are serial and waiting respects the call context; different files are independent. An EOF or canceled call does not close the File.
func (*BoundFile) Append ¶ added in v0.2.0
Append requires the AppendOnly mode admitted at Open. It never derives an append position from Stat and never replaces the opened object by name.
func (*BoundFile) Close ¶ added in v0.2.0
Close stops admission, cancels calls and closes the native resource. It waits for both native Close and all started calls before releasing the mount use. A failed close remains owned by the original mount and cannot acknowledge retirement. Close is idempotent and needs no remaining file permission.
type Change ¶
type Change struct {
Effect Effect
Before TargetPresence
Evidence Evidence
}
type ChildRemover ¶
ChildRemover is an optional capability of a DirectoryScope, not of Driver. It removes one exact current child name without resolving the parent again. The target and condition must hold at the native effect point. Removal never follows a final link. An unsupported combination fails before effects. No enumeration is required. Calls may overlap each other, but must not overlap Next, OpenFile or Close. Native work finishes before return; failed cleanup stays owned by the scope/Driver. Applied confirms name removal, not storage reclamation.
type Code ¶
type Code string
const ( UnsupportedOperation Code = "unsupported_operation" PreconditionFailed Code = "precondition_failed" AlreadyExists Code = "already_exists" DirectoryNotEmpty Code = "directory_not_empty" InvalidRequest Code = "invalid_request" InvalidPath Code = "invalid_path" InvalidRange Code = "invalid_range" Unauthenticated Code = "unauthenticated" PermissionDenied Code = "permission_denied" NotFound Code = "not_found" PathAmbiguous Code = "path_ambiguous" NotDirectory Code = "not_directory" NotFile Code = "not_file" UnrepresentableName Code = "unrepresentable_name" RangeNotSatisfiable Code = "range_not_satisfiable" CapacityExceeded Code = "capacity_exceeded" InvalidUpstreamResponse Code = "invalid_upstream_response" UpstreamFailure Code = "upstream_failure" UpstreamAccessDenied Code = "upstream_access_denied" UpstreamTimeout Code = "upstream_timeout" InternalError Code = "internal_error" ResolutionBudgetExceeded Code = "resolution_budget_exceeded" ResponseBudgetExceeded Code = "response_budget_exceeded" UpstreamThrottled Code = "upstream_throttled" )
type Condition ¶ added in v0.2.0
type Condition struct {
// contains filtered or unexported fields
}
Condition holds at most one positive and one negative tag/presence test. Canonical strings keep it immutable, comparable and allocation-free for a single tag. Its zero value is unconditional; it is not an expression tree.
func All ¶ added in v0.2.0
All combines the positive and negative tests; different duplicate tests are rejected instead of creating a general-purpose predicate language.
func IfNotMatch ¶ added in v0.2.0
func (Condition) MarshalJSON ¶ added in v0.2.0
func (*Condition) UnmarshalJSON ¶ added in v0.2.0
type ConditionFailure ¶ added in v0.2.0
ConditionFailure preserves which test failed and its actual observation. Protocols may project a negative GET/HEAD failure as 304; mutations use 412.
func (*ConditionFailure) Error ¶ added in v0.2.0
func (*ConditionFailure) Error() string
type Content ¶
type Content struct {
Change Change
Entry Entry
Body io.ReadCloser
File *BoundFile
Binding FileBinding
Length *int64
Range *ContentRange
}
type ContentRange ¶
type ContentRange struct{ Start, End, Total int64 }
type ContinuableWriter ¶ added in v0.2.0
type ContinuableWriter interface {
ContinueWrite(context.Context, NativeAddress, Replayable, int64, WriteOptions) (Change, error)
}
ContinuableWriter is an optional Driver mode reached through the same Write admission, authority, binding and resource lifetime. It must bind checkpoints to the native destination, source version, length and write policy, retain uncertain effects, and join all source/native activity before returning. It cannot close or retain source. Options.Continuation is always non-nil. Confirmed Abort may return Unchanged with nil; other results follow the selected policy, including possible Incomplete effects for ordinary creation.
type CopyOptions ¶ added in v0.2.0
type CopyOptions struct {
Source ReadSelection `json:"source"`
Target WriteOptions `json:"target"`
}
CopyOptions keeps the actual source read and target publication independent.
type CopyRequest ¶
type CopyRequest struct {
Source Address
Target Address
Options CopyOptions
}
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func (*Core) BindAlias ¶
BindAlias exposes a directory of an installed mount under a new, non-nested prefix. It owns no Driver and grants no permission beyond the primary path.
func (*Core) Capture ¶
Capture selects real bindings or a virtual hierarchy and its existing members. New bindings never join this selection. Real paths need not exist yet. Authorization remains mandatory when the normal operation executes.
func (*Core) CheckCursor ¶
CheckCursor validates a continuation without advancing it. No I/O or extra enumeration is performed.
func (*Core) Copy ¶
func (c *Core) Copy(ctx context.Context, principal Principal, source, target Address, options ...CopyOptions) (change Change, err error)
Copy synchronously writes target from the complete source body. The parent must exist; replacement is explicit. It does not remove source. The returned Change describes the target even when error is non-nil.
func (*Core) CopyBatch ¶
func (c *Core) CopyBatch(ctx context.Context, p Principal, requests []CopyRequest, options ...ExecutionOptions) ([]ItemResult, error)
CopyBatch follows RemoveBatch's prefix and stop contract. Its conflict ranges include both source reads and target writes after explicit alias resolution. Unknown physical aliases and external mutations are not transactionally locked.
func (*Core) CopyInto ¶ added in v0.4.0
func (c *Core) CopyInto(ctx context.Context, p Principal, source, directory Address) (destination Address, change Change, err error)
CopyInto copies one file to an existing mounted directory using its source name or an available numbered variant. The chosen child is created exclusively.
func (*Core) CopyTree ¶
func (c *Core) CopyTree(ctx context.Context, p Principal, sourceAddress, targetAddress Address, options TreeOptions, policies ...DirectoryCopyOptions) (result TreeResult, err error)
CopyTree selects a file leaf, directory itself, or finite recursive tree. Existing defaults to CreateNew; Merge retains extra members, whereas Replace discovers/adopts the source before target removal. Files use WriteOptions. There is no source deletion, snapshot, automatic replay or rollback. A virtual source traverses its captured bindings and aliases by visible names.
func (*Core) CopyTreeInto ¶ added in v0.4.0
func (c *Core) CopyTreeInto(ctx context.Context, p Principal, source, directory Address, options TreeOptions) (destination Address, tree TreeResult, err error)
CopyTreeInto selects an exclusive child for a recursive copy. Its receipt retains the same item effects as CopyTree.
func (*Core) Create ¶
func (c *Core) Create(ctx context.Context, p Principal, target Address, input io.Reader, length *int64) (Change, error)
Create writes a new file without replacing an existing target. The caller owns input and keeps it valid until this synchronous call returns.
func (*Core) Inspect ¶
func (c *Core) Inspect(ctx context.Context, p Principal, action Action, target Address, selections ...ReadSelection) (Entry, error)
Inspect checks metadata under the requested action without opening content.
func (*Core) Lstat ¶ added in v0.2.0
Lstat observes the final entry of a tree path without following a link. Intermediate links are refused. It uses the same authority as Stat and does not bind the entry for later operations.
func (*Core) Move ¶
func (c *Core) Move(ctx context.Context, p Principal, source, target Address, policies ...MoveOptions) (result MoveResult, err error)
Move renames or moves a file or directory. The zero policy never replaces. Explicit Replace may first remove a target, recorded separately in Removed. Tree budgets are required if that phase encounters a directory. Directory admission authorizes the whole native relocation, without descendant checks. Both receipts must be Applied and error must be nil for completion without errors. A failed later relocation does not undo Removed. A cross-mount move publishes exclusively before removing the exact source version. Directories require positive Tree budgets. NoCopy retains the native relocation path.
func (*Core) MoveBatch ¶
func (c *Core) MoveBatch(ctx context.Context, p Principal, requests []MoveRequest, options ...ExecutionOptions) ([]MoveItemResult, error)
MoveBatch follows the same prefix and stop contract as CopyBatch. Both endpoints are writes, including their descendants, within this finite call.
func (*Core) MoveInto ¶ added in v0.4.0
func (c *Core) MoveInto(ctx context.Context, p Principal, source, directory Address, trees ...TreeOptions) (result MoveResult, err error)
MoveInto moves one item into a mounted directory. The requested directory stays fixed; the resulting leaf name is returned in Destination. Cross-mount directory moves use the optional tree budgets, as in Move.
func (*Core) ReleaseCursor ¶
ReleaseCursor closes an owned enumeration, including in-flight work. A revoked read grant does not prevent cleanup of the principal's existing resource.
func (*Core) RemoveBatch ¶
func (c *Core) RemoveBatch(ctx context.Context, p Principal, targets []Address, options ...ExecutionOptions) ([]ItemResult, error)
RemoveBatch retains input order and duplicates. Execution is serial unless an explicit concurrency option is supplied. On failure no more items start; already started items finish and retain their receipts in the returned prefix.
func (*Core) RemoveTree ¶
func (c *Core) RemoveTree(ctx context.Context, p Principal, targetAddress Address, options TreeOptions, policies ...DirectoryRemoveOptions) (result TreeResult, err error)
RemoveTree discovers selected names before effects. ContentsOnly leaves the operation root and all virtual/binding anchors in place. Subtree permits native recursive effects beneath removable names and requires RemoveTreeAction. Results describe attempted mutations, never the preserved structure. Neither policy promises a snapshot, rollback or protection against later recreation. A file leaf reuses Remove and accepts zero traversal budgets. When is a root file predicate, never broadcast to descendants; nonempty directory predicates without a native commit proof are refused before child effects.
func (*Core) UnbindAlias ¶
UnbindAlias removes only an alias and its cursors. Open bodies keep their captured mount use. Context bounds cleanup waiting, not native cleanup work.
func (*Core) Write ¶
func (c *Core) Write(ctx context.Context, p Principal, target Address, input io.Reader, length *int64, options ...WriteOptions) (result Change, err error)
Write shares Create's input ownership. The default creates a new file; Publish() requires WriteAction; Publish(IfAbsent()) retains CreateAction.
func (*Core) WriteInto ¶ added in v0.4.0
func (c *Core) WriteInto(ctx context.Context, p Principal, directory Address, name string, input io.Reader, length *int64) (destination Address, change Change, err error)
WriteInto creates a new file inside an existing mounted directory. It uses the preferred name or an available numbered variant. A concurrent occupant is an exclusive-creation conflict. The caller retains input ownership.
type DirectoryCopyOptions ¶
type DirectoryCopyOptions struct {
WriteOptions
Existing TargetPolicy
Depth TreeDepth
Source ReadSelection
}
DirectoryCopyOptions selects directory and file policies independently. Existing controls the root/namespace policy. WriteOptions governs each file.
type DirectoryIdentity ¶ added in v0.2.0
type DirectoryIdentity interface {
DirectoryValidator() Validator
}
DirectoryIdentity is optional on a DirectoryScope. Its validator identifies the directory independently of its contents. Remove must accept it for exact, atomic empty-directory removal.
type DirectoryMaker ¶
type DirectoryMaker interface {
Mkdir(context.Context, NativeAddress) (Change, error)
}
Optional capabilities share the installed Driver's lifetime. An unsupported mode must be refused before consuming input or changing the target.
type DirectoryReader ¶
type DirectoryReader interface {
OpenDirectory(context.Context, NativeAddress) (DirectoryScope, error)
}
DirectoryReader opens a bound directory. Every path component is opened without following native links or redirects; "/" is the prepared root. Opening does not require Next. The returned scope is owned even on error.
type DirectoryRelocator ¶ added in v0.4.0
type DirectoryRelocator interface {
RelocateInto(context.Context, NativeAddress, NativeAddress) (string, Change, error)
}
DirectoryRelocator atomically moves one item into an existing directory. The driver binds the source and parent at commit, prefers the source name, preserves existing children, and returns the confirmed direct-child name with Applied. It reports unsupported modes before changing either side.
type DirectoryRemoveOptions ¶ added in v0.2.0
type DirectoryRemoveOptions struct {
Scope RemovalScope
ContentsOnly bool
When Condition
}
DirectoryRemoveOptions defaults to Discovered when omitted or empty. ContentsOnly preserves the requested root and namespace binding anchors while removing selected mutable contents. It also accepts mount and virtual roots.
type DirectoryScope ¶
DirectoryScope enumerates one bound directory. Only after normal EOF may OpenFile open an observed, unambiguous regular child by a single name. OpenFile may run concurrently; Next has one caller. Bodies must finish before Close. Neither the directory nor file content is promised to be a snapshot.
type DispositionRemover ¶ added in v0.4.0
type DispositionRemover interface {
RemoveWithDisposition(context.Context, NativeAddress, RemoveOptions) (Change, error)
}
DispositionRemover opts into explicit removal. It obeys the Remover contract and rejects unsupported dispositions before changing the target.
type Driver ¶
type Driver interface {
Stat(context.Context, NativeAddress, ...ReadSelection) (Metadata, error)
Enumerate(context.Context, NativeQuery) (Iterator, error)
Open(context.Context, NativeAddress, OpenOptions) (Opened, error)
Close() error
}
Driver is rooted when constructed. Tree addresses start at /; key addresses preserve literal keys. Metadata.Name is a child name for tree listings and a complete root-relative key for key listings/reads. PrefixGroup is listing-only. Provider IDs and physical paths remain inside it. Tree operations use exact names in the service's exported namespace, without client-invented aliases or redirects. Ordinary access does not prove how the service implements a name. Explicit leaf observation and NoFollow retain their stronger native promises. Open transfers every returned Body/File to the caller, including on error. BoundRead/LiveEdit return File only. They must not retain the opening call's context; subsequent calls and Close own the resource lifetime. LiveEdit must report opening Change even on error. StreamRead keeps Body. NoFollow must reject native links/redirects in every component; a Driver unable to guarantee that mode refuses it rather than silently following one.
type EditFile ¶ added in v0.2.0
type EditFile interface {
ReadFile
WriteAt(context.Context, []byte, int64) (int, Change, error)
Append(context.Context, []byte) (int, Change, error)
Truncate(context.Context, int64) (Change, error)
Sync(context.Context) error
}
EditFile is optional on a LiveEdit result, selected once at Open. Byte writes retain confirmed n and Change independently of error; no complete-publication or durability is implied. Append must use a native append mode, not Stat+WriteAt. Sync explicitly requests native file durability, separately from visible effects.
type Effect ¶
type Effect uint8
Effect describes target mutation independently of an operation's error. The zero value is conservative: no absence of effects has been established.
type Evidence ¶ added in v0.2.0
type Evidence struct {
Validator Validator `json:"validator,omitzero"`
Version Version `json:"version,omitempty"`
}
Evidence contains only observations the native operation actually returned.
type ExecutionOptions ¶
type ExecutionOptions struct {
Concurrency int `json:"concurrency,omitempty"`
}
ExecutionOptions applies within one finite call, not across independent requests or external writers. Zero and one select serial execution.
type FileBinding ¶ added in v0.2.0
type FileBinding string
const ( BoundObject FileBinding = "bound_object" PinnedVersion FileBinding = "pinned_version" )
BoundObject fixes resource identity, permitting in-place edits. PinnedVersion also fixes contents, but does not guarantee perpetual native availability.
type FileCreation ¶ added in v0.2.0
type FileCreation string
const ( OpenExisting FileCreation = "" OpenOrCreate FileCreation = "open_or_create" OpenNew FileCreation = "open_new" )
type FileCreator ¶
type FilePublisher ¶
type FilePublisher interface {
Publish(context.Context, NativeAddress, io.Reader, *int64, PublicationOptions) (Change, error)
}
FilePublisher is optional. Publish validates complete input before changing the target name and enforces options.When at publication. ObserveTarget must produce a known Before on success, or be refused before input is consumed. Input is borrowed only until return. When is enforced at the native commit; observation alone does not imply a version guard or durability.
type ItemResult ¶
ItemResult records one attempted input occurrence, including repeated inputs. An error does not erase a confirmed or uncertain Change.
type Iterator ¶
Iterator owns a native enumeration. Next has one caller; its positive size is a hint, not a required batch length. An empty batch without io.EOF continues the enumeration. Final entries may accompany io.EOF. Context applies only to the current call, not to the lifetime of the iterator.
type KeyExtent ¶ added in v0.2.0
KeyExtent maps a tree view to exact native keys and/or a literal prefix. This pure projection lets shared views schedule together without metadata I/O. Exact, when present, is this name's canonical native key, not a conservative extra point. Prefix may overapproximate its affected descendants. Extents cover possible effects, not authorization, persistent object identity or content versions. Missing/empty projection is conservative.
type KeyProjection ¶ added in v0.2.0
type KeyProjection interface {
// KeyRoot gives the exact key prefix for a tree directory's contents.
// False refuses key access through that alias; an overlap extent alone
// is not sufficient evidence for routing or authorization projection.
KeyRoot(NativeAddress) (string, bool)
KeyExtent(NativeAddress) KeyExtent
}
type LeafStatter ¶ added in v0.2.0
type LeafStatter interface {
Lstat(context.Context, NativeAddress) (Metadata, error)
}
LeafStatter optionally observes the entry itself at a rooted tree address. It must refuse intermediate links/redirects and may report SymbolicLink for the final entry without inspecting its target. A namespace with no links can use the same lookup as Stat. No native handles are transferred.
type ListRequest ¶
type Mount ¶
type Mount struct {
// contains filtered or unexported fields
}
Mount is the identity of one installed generation. Retiring an old handle never retires a later replacement installed at the same virtual path.
func (*Mount) Retire ¶
Retire stops admission and requests cancellation immediately. Its context bounds this wait, not the lifetime of unfinished work or Driver.Close.
func (*Mount) Status ¶
func (m *Mount) Status() MountStatus
Status observes this exact generation, even after its prefix is replaced.
type MountStatus ¶
type MoveDirectoryWriter ¶ added in v0.2.0
type MoveDirectoryWriter interface {
MkdirForMove(context.Context, NativeAddress, Validator) (Change, error)
PublishForMove(context.Context, NativeAddress, Validator, io.Reader, *int64) (Change, error)
}
MoveDirectoryWriter creates directories and publishes files exclusively. A nonzero validator must match the current target parent at the native commit. MkdirForMove returns the new directory identity in Change.Evidence.
type MoveItemResult ¶
type MoveItemResult struct {
MoveResult
Err error
}
MoveItemResult retains both endpoint receipts for one attempted occurrence.
type MoveOptions ¶ added in v0.2.0
type MoveOptions struct {
Source Condition `json:"source"`
Target Condition `json:"target"`
Existing TargetPolicy `json:"existing,omitempty"`
Tree TreeOptions `json:"tree,omitzero"`
NoCopy bool `json:"-"` // Require the existing relocation path.
}
type MoveRequest ¶
type MoveRequest struct {
Source Address
Target Address
Options MoveOptions
}
type MoveResult ¶
type MoveResult struct {
Source Change
Target Change
// Destination is the confirmed path chosen for a directory-target move.
Destination Address
// Removed records a separately confirmed target-removal phase. It never
// claims that the later source relocation or target creation succeeded.
Removed *TreeResult
Tree *TreeResult // Attempted phases of a cross-mount directory move.
}
MoveResult reports this operation's source removal and target creation. Receipts do not describe changes made by other callers after either effect.
type MoveSource ¶ added in v0.2.0
type MoveSource interface {
Remover
MoveFileValidator(NativeAddress, Evidence) (Validator, error)
}
MoveSource supplies a strong deletion validator for the exact file returned by Open. Remove must enforce it and RemoveNonDirectory against the current source name at the native commit.
type Namespace ¶ added in v0.2.0
type Namespace uint8
Namespace selects name semantics, not a provider or a second resource owner.
type NamespaceSupport ¶ added in v0.2.0
NamespaceSupport is optional. A Driver without it accepts tree names only. Actual operation capabilities, authorization and retirement still apply.
type NativeAddress ¶ added in v0.2.0
type NativeAddress struct {
// contains filtered or unexported fields
}
NativeAddress is rooted in the prepared Driver. It has no public binding ID.
func NativeKey ¶ added in v0.2.0
func NativeKey(value string) NativeAddress
func NativePath ¶ added in v0.2.0
func NativePath(value string) NativeAddress
func (NativeAddress) Namespace ¶ added in v0.2.0
func (a NativeAddress) Namespace() Namespace
func (NativeAddress) Value ¶ added in v0.2.0
func (a NativeAddress) Value() string
type NativeQuery ¶ added in v0.2.0
type NativeQuery struct {
// contains filtered or unexported fields
}
NativeQuery carries the same selection after binding/root projection.
func NativeChildren ¶ added in v0.2.0
func NativeChildren(address NativeAddress) NativeQuery
func NativeKeys ¶ added in v0.2.0
func NativeKeys(prefix, delimiter string) NativeQuery
func (NativeQuery) Address ¶ added in v0.2.0
func (q NativeQuery) Address() NativeAddress
func (NativeQuery) After ¶ added in v0.2.0
func (q NativeQuery) After(key string) NativeQuery
func (NativeQuery) Delimiter ¶ added in v0.2.0
func (q NativeQuery) Delimiter() string
func (NativeQuery) StartAfter ¶ added in v0.2.0
func (q NativeQuery) StartAfter() string
type OpenOptions ¶ added in v0.2.0
type OpenOptions struct {
Mode OpenMode
Binding FileBinding // Minimum File binding; zero means BoundObject.
Range *Range
Selection ReadSelection
// NoFollow requires each native component to be free of links/redirects.
NoFollow bool
// LiveEdit opts into visible mutations; zero Creation opens an existing file.
Read bool
Creation FileCreation
Truncate bool
AppendOnly bool
}
OpenOptions retains the ordinary sequential body path when zero.
func (OpenOptions) Validate ¶ added in v0.2.0
func (o OpenOptions) Validate() error
Validate checks the requested mode, not the Driver's ability to supply it.
type Opened ¶
type Opened struct {
Change Change // LiveEdit opening effects survive errors and cleanup.
Metadata Metadata
Body io.ReadCloser
File ReadFile
Binding FileBinding
Length *int64
Range *ContentRange
}
Opened transfers any returned Body or File even when Open also returns an error. For streams, Metadata.Size is the total object size; Length and Range describe the returned body. Unknown sizes remain nil.
type OperationError ¶ added in v0.2.0
type OperationError struct {
Side ResultSide
Phase OperationPhase
Cause error
}
OperationError preserves failure provenance without changing its domain code or its independent effect receipt. Native causes never enter protocol output.
func (*OperationError) Error ¶ added in v0.2.0
func (e *OperationError) Error() string
func (*OperationError) Unwrap ¶ added in v0.2.0
func (e *OperationError) Unwrap() error
type OperationPhase ¶ added in v0.2.0
type OperationPhase string
const ( ReadPhase OperationPhase = "read" CreatePhase OperationPhase = "create" WritePhase OperationPhase = "write" RemovePhase OperationPhase = "remove" )
type Options ¶
type Options struct {
Authorize Authorizer
MaxCursors int
OpenTimeout time.Duration
}
Options supplies runtime policy, not a configuration-file format. Cursor lifetime belongs to each enumeration request.
type OrderScope ¶ added in v0.2.0
type OrderScope struct {
// contains filtered or unexported fields
}
OrderScope serializes explicitly reserved root operations. The trusted receiver reserves in request-receive order before dispatching goroutines. Capacity bounds active plus waiting turns; there is no worker or task record. Other scopes and calls without a turn are independent, including external I/O.
func NewOrderScope ¶ added in v0.2.0
func NewOrderScope(capacity int) (*OrderScope, error)
func (*OrderScope) Reserve ¶ added in v0.2.0
func (s *OrderScope) Reserve(ctx context.Context) (*OrderTurn, error)
func (*OrderScope) Stop ¶ added in v0.2.0
func (s *OrderScope) Stop()
Stop cancels admission and pending/active call contexts. It does not close Files or acknowledge native I/O; those remain with their original owners.
type OrderTurn ¶ added in v0.2.0
type OrderTurn struct {
// contains filtered or unexported fields
}
OrderTurn is one root call's execution lifetime. Context is passed to the ordinary Core/File API. Cancel abandons an unused turn or requests cancellation of a started call; only that call's resource owner can acknowledge completion.
type PublicationOptions ¶ added in v0.2.0
PublicationOptions constrains native complete publication. ObserveTarget requests a presence observation for response classification. It does not strengthen When; ordinary publication need not perform that I/O.
type Query ¶ added in v0.2.0
type Query struct {
// contains filtered or unexported fields
}
Query selects immediate tree children or native keys/prefix groups. Delimiter and After are literal key-space values; Core cursors bind all fields.
func (Query) StartAfter ¶ added in v0.2.0
type ReadFile ¶ added in v0.2.0
type ReadFile interface {
ReadAt(context.Context, []byte, int64) (int, error)
Stat(context.Context) (Metadata, error)
Close() error
}
ReadFile is an already-bound native resource, never a path-reopening adapter. ReadAt follows io.ReaderAt byte/EOF rules with a per-call context. EOF and call cancellation do not close it. Stat describes this resource, using the original opened name even after a rename. Close must be safe alongside in-flight calls and request their cancellation; Core waits for those calls before releasing use.
type ReadSelection ¶ added in v0.2.0
type ReadSelection struct {
When Condition `json:"when"`
Version Version `json:"version,omitempty"`
}
ReadSelection applies to the metadata or body actually returned by a read.
func (ReadSelection) Check ¶ added in v0.2.0
func (s ReadSelection) Check(e Evidence) error
type Relocator ¶
type Relocator interface {
Relocate(context.Context, NativeAddress, NativeAddress, ...MoveOptions) (Change, error)
}
Relocator atomically moves an admitted regular file or directory without replacement. Unsupported entry kinds must be refused before effects. Paths use the Driver's native execution-time binding. Unsupported options and entry kinds must be refused before reporting an existing-target conflict, so Core can safely distinguish an unavailable mode from explicit replacement policy. Metadata checks do not bind an object version or type against external replacement. Source and target belong to the same installed Driver and an existing parent.
type RemovalScope ¶ added in v0.2.0
type RemovalScope string
RemovalScope selects permitted effects, independently of execution strategy.
const ( Discovered RemovalScope = "discovered" Subtree RemovalScope = "subtree" )
type RemoveDisposition ¶ added in v0.4.0
type RemoveDisposition string
const ( RemoveTrash RemoveDisposition = "trash" RemovePermanent RemoveDisposition = "permanent" )
type RemoveOptions ¶ added in v0.2.0
type RemoveOptions struct {
When Condition `json:"when"`
// Target constrains the native deletion. Zero allows either kind.
Target RemoveTarget `json:"target,omitempty"`
// Disposition selects strict removal. Zero uses the source's ordinary removal.
Disposition RemoveDisposition `json:"disposition,omitempty"`
}
type RemoveTarget ¶ added in v0.2.0
type RemoveTarget string
const ( RemoveNonDirectory RemoveTarget = "non_directory" RemoveEmptyDirectory RemoveTarget = "empty_directory" )
type Remover ¶
type Remover interface {
Remove(context.Context, NativeAddress, ...RemoveOptions) (Change, error)
}
Remover removes one native entry. Tree ancestors must not follow links, and a final link is removed itself. Type and condition constraints must hold at the native effect point; a preceding Stat cannot establish them. Native calls finish before return, and failed cleanup remains owned by the Driver.
type Replayable ¶ added in v0.2.0
type Replayable interface {
io.Reader
SourceVersion() string
OpenRange(context.Context, int64, int64) (io.ReadCloser, error)
}
Replayable is an immutable, versioned input with independent range readers. OpenRange returns exactly length bytes followed by normal EOF, verifies source integrity, and owns only its returned body. The caller closes each body. The source is borrowed only until Write returns; its durable retention is external.
type ResultSide ¶ added in v0.2.0
type ResultSide string
const ( SourceSide ResultSide = "source" TargetSide ResultSide = "target" )
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection records process-local bindings without borrowing their resources. It cannot be restored, grants no permission, and does not freeze file content.
type SubtreeRemover ¶ added in v0.2.0
type SubtreeRemover interface {
RemoveSubtree(context.Context, NativeAddress, TreeOptions) (Change, error)
}
SubtreeRemover optionally removes a directory and its native descendants. It must not follow redirects outside that subtree. Limits bound client discovery and planning, not the number of descendants a native recursive request deletes. They apply to each native invocation. A ContentsOnly operation additionally has one Core-wide visible-name plan budget; it is not a global native I/O quota. Applied requires confirmed completion, not asynchronous task acceptance. On cancellation, stop dispatch and await active client I/O; remote effects may continue and must remain Unknown when completion cannot be established.
type TargetPolicy ¶ added in v0.2.0
type TargetPolicy string
const ( CreateNew TargetPolicy = "create_new" Merge TargetPolicy = "merge" Replace TargetPolicy = "replace" )
type TargetPresence ¶ added in v0.2.0
type TargetPresence uint8
TargetPresence is a native observation made while preparing or committing a mutation. It is not a version guard or a promise about concurrent writers.
const ( TargetUnknown TargetPresence = iota TargetMissing TargetPresent )
type TreeCopyOptions ¶
type TreeCopyOptions = TreeOptions
TreeCopyOptions remains an alias for existing CopyTree callers.
type TreeItemResult ¶
type TreeItemResult struct {
RelativePath string // "/" is the operation root.
Side ResultSide
Phase OperationPhase
// ErrorSide distinguishes a source failure during a target write/cleanup.
ErrorSide ResultSide
Change Change
Err error
}
type TreeOptions ¶
type TreeOptions struct {
ExecutionOptions
// Directory plans require positive caller-selected budgets; a file leaf
// accepts zero. Replacement bounds source and old-target plans separately.
// MaxPlanBytes counts relative-path UTF-8 bytes, not responses or content.
MaxEntries int `json:"max_entries"`
MaxPlanBytes int `json:"max_plan_bytes"`
}
type TreeResult ¶ added in v0.2.0
type TreeResult struct {
Change Change
Items []TreeItemResult
}
TreeResult separates whole-operation effects from attempted phase receipts. Applied means the selected operation completed, not that every item changed.
type Validator ¶ added in v0.2.0
Validator is an opaque entity tag in a declared comparison domain. Tag uses quoted entity-tag syntax; it is not necessarily a hash or an object identity. An empty Domain means comparison at the operation's already selected address.
type Version ¶ added in v0.2.0
type Version string
Version selects an immutable native revision; it is not an entity tag.
type WriteContinuation ¶ added in v0.2.0
type WriteContinuation struct {
Checkpoint []byte
Append func(context.Context, []byte) error
Abort bool
}
WriteContinuation explicitly carries a protected native recovery log. Append must durably append complete records before returning nil, copy retained bytes, and serialize revisions for one executor. Native checkpoints are not untrusted client tokens. Append may receive a context detached from execution cancellation to record an acknowledged effect; it is synchronous and may not outlive Write. Its storage, deadlines and failures belong to the consumer. Canceling Write pauses a native attempt; Abort explicitly requests cleanup, without undoing published content. Checkpoint is the complete committed log for this execution. Append receives only new records; it must never rewrite the accumulated log per append.
type WriteOptions ¶
type WriteOptions struct {
Policy WritePolicy `json:"policy"`
ObserveTarget bool `json:"observe_target,omitempty"`
Continuation *WriteContinuation `json:"-"`
}
WriteOptions defaults to direct exclusive creation. Policy selects complete publication independently of the target's required presence.
type WritePolicy ¶ added in v0.2.0
type WritePolicy struct {
// contains filtered or unexported fields
}
WritePolicy distinguishes direct exclusive creation from complete publication. The zero value retains streaming creation, which may leave partial new content.
func Publish ¶ added in v0.2.0
func Publish(when ...Condition) WritePolicy
Publish selects complete publication, creating or replacing a file by default. At most one predicate is accepted. Invalid policies fail before input is read.
func (WritePolicy) Complete ¶ added in v0.2.0
func (p WritePolicy) Complete() bool
func (WritePolicy) MarshalJSON ¶ added in v0.2.0
func (p WritePolicy) MarshalJSON() ([]byte, error)
func (*WritePolicy) UnmarshalJSON ¶ added in v0.2.0
func (p *WritePolicy) UnmarshalJSON(data []byte) error
func (WritePolicy) Validate ¶ added in v0.2.0
func (p WritePolicy) Validate() error
func (WritePolicy) When ¶ added in v0.2.0
func (p WritePolicy) When() Condition
Source Files
¶
- address.go
- admission.go
- batch.go
- binding.go
- change.go
- condition.go
- content.go
- continuation.go
- copy.go
- copy_tree.go
- core.go
- destination.go
- directory.go
- doc.go
- execution.go
- file.go
- list.go
- metadata.go
- mount.go
- move.go
- move_across.go
- move_tree.go
- open.go
- order.go
- publication.go
- range.go
- remove_tree.go
- selection.go
- tree.go
- tree_result.go
- types.go
- write.go
Directories
¶
| Path | Synopsis |
|---|---|
|
browser
module
|
|
|
Package control manages desired mount definitions using host-owned storage and factories.
|
Package control manages desired mount definitions using host-owned storage and factories. |
|
drivers
|
|
|
internal/childscan
Package childscan works with native directory listings.
|
Package childscan works with native directory listings. |
|
internal/httpcontent
Package httpcontent shares bounded HTTP response decoding and download redirect handling.
|
Package httpcontent shares bounded HTTP response decoding and download redirect handling. |
|
internal/mcptool
Package mcptool encodes stateless MCP tool calls and validates their JSON replies.
|
Package mcptool encodes stateless MCP tool calls and validates their JSON replies. |
|
internal/onedrive
Package onedrive sends bytes through a native OneDrive upload session.
|
Package onedrive sends bytes through a native OneDrive upload session. |
|
internal/upload
Package upload provides bounded input chunking for native Driver uploads.
|
Package upload provides bounded input chunking for native Driver uploads. |
|
local
Package local adapts a prepared filesystem root to file operations.
|
Package local adapts a prepared filesystem root to file operations. |
|
alipan
module
|
|
|
atomgit
module
|
|
|
autoindex
module
|
|
|
azureblob
module
|
|
|
babelbird
module
|
|
|
baidupan
module
|
|
|
baidupan/cdp
module
|
|
|
box
module
|
|
|
bunny
module
|
|
|
cloudreve
module
|
|
|
cnbreleases
module
|
|
|
codeartsrepo
module
|
|
|
dingtalkdrive
module
|
|
|
dropbox
module
|
|
|
emby
module
|
|
|
fangcloud
module
|
|
|
febbox
module
|
|
|
feishudrive
module
|
|
|
ftp
module
|
|
|
githubreleases
module
|
|
|
githubrepo
module
|
|
|
gokuai
module
|
|
|
googledrive
module
|
|
|
googlephotos
module
|
|
|
graphdrive
module
|
|
|
guangyapan
module
|
|
|
huaweidrive
module
|
|
|
imgbed
module
|
|
|
ipfs
module
|
|
|
kdocs
module
|
|
|
koodrive
module
|
|
|
lanzou
module
|
|
|
mediafire
module
|
|
|
misskey
module
|
|
|
mobilepan
module
|
|
|
pan115
module
|
|
|
pan115/cdp
module
|
|
|
pan123
module
|
|
|
pan123/cdp
module
|
|
|
pdsshare
module
|
|
|
pikpak
module
|
|
|
pool
module
|
|
|
quark
module
|
|
|
quark/cdp
module
|
|
|
s3
module
|
|
|
seafile
module
|
|
|
sftp
module
|
|
|
smb
module
|
|
|
teambition
module
|
|
|
teldrive
module
|
|
|
tencentdocs
module
|
|
|
tencentsmh
module
|
|
|
tianyipan
module
|
|
|
uc
module
|
|
|
upyun
module
|
|
|
urltree
module
|
|
|
webdav
module
|
|
|
wecomdrive
module
|
|
|
weiyun
module
|
|
|
wps365
module
|
|
|
wuyingdrive
module
|
|
|
yandex
module
|
|
|
yunpan360
module
|
|
|
Durable sequential input is an optional consumer, not a Driver or a second file-operation API.
|
Durable sequential input is an optional consumer, not a Driver or a second file-operation API. |
|
internal
|
|
|
release
command
Package main prepares and verifies releases of modules in this repository.
|
Package main prepares and verifies releases of modules in this repository. |
|
Package protocols defines observations shared by the file protocol adapters.
|
Package protocols defines observations shared by the file protocol adapters. |
|
ftp
Package ftp serves an explicit FTP profile through Core.
|
Package ftp serves an explicit FTP profile through Core. |
|
httpapi
Package httpapi projects file, mount-control and task contracts onto HTTP.
|
Package httpapi projects file, mount-control and task contracts onto HTTP. |
|
internal/fileview
Package fileview projects a protocol's lexical tree view onto Core addresses.
|
Package fileview projects a protocol's lexical tree view onto Core addresses. |
|
internal/httpwire
Package httpwire contains shared HTTP representation parsing, not file execution.
|
Package httpwire contains shared HTTP representation parsing, not file execution. |
|
webdav
Package webdav exposes bounded tree file workflows through an HTTP handler.
|
Package webdav exposes bounded tree file workflows through an HTTP handler. |
|
s3
module
|
|
|
sftp
module
|
|
|
Package task runs arbitrary process-local work with bounded admission and concurrency.
|
Package task runs arbitrary process-local work with bounded admission and concurrency. |
|
Durable transfer is an optional consumer of input and Core.
|
Durable transfer is an optional consumer of input and Core. |