Documentation
¶
Overview ¶
Package syncfs provides native, held-root observations and publication for reviewed sync actions. It does not grant authority, journal an operation, or confirm a reconciliation baseline.
Index ¶
- Constants
- Variables
- func BuildSourceManifest(ctx context.Context, source, manifest *Root, plan syncreconcile.Plan, ...) ([]DirectoryMetadata, StageCharge, error)
- func FinalizeStageDirectories(ctx context.Context, receiver, stage *Root, plan syncreconcile.Plan, ...) error
- func VerifyPlanRoot(plan syncreconcile.Plan, side syncreconcile.Side, root *Root) error
- type BackingHeadroom
- type CompleteScopeProof
- type DirectoryMetadata
- type EnrollmentRecord
- type ExclusiveScopeOwner
- type Journal
- type Metadata
- type NamePolicy
- type NativeQuotaEvidence
- func (v NativeQuotaEvidence) HardBytes() uint64
- func (v NativeQuotaEvidence) Mount() string
- func (v NativeQuotaEvidence) ParentRootID() string
- func (v NativeQuotaEvidence) Provider() string
- func (v NativeQuotaEvidence) Scope() string
- func (v NativeQuotaEvidence) SelectedRootID() string
- func (v NativeQuotaEvidence) UsedBytes() uint64
- type PreOpenEnrollmentCandidate
- type Publisher
- type Receipt
- type RecordedEnrollment
- type Reservation
- type Root
- type ScanLimits
- type ScopeBinding
- func (b ScopeBinding) HardBytes() uint64
- func (b ScopeBinding) MountID() string
- func (b ScopeBinding) OwnerEpoch() uint64
- func (b ScopeBinding) OwnershipDigest() string
- func (b ScopeBinding) ParentRootID() string
- func (b ScopeBinding) ProjectID() uint32
- func (b ScopeBinding) ProjectRootID() string
- func (b ScopeBinding) Provider() string
- func (b ScopeBinding) ScopeID() string
- func (b ScopeBinding) SelectedRootID() string
- func (b ScopeBinding) UsedBytes() uint64
- type ScopeClaim
- type ScopeClaimFields
- type StageCharge
- type Workspace
- func CreateWorkspace(receiver, parent *Root, v Reservation) (*Workspace, error)
- func FindWorkspace(ctx context.Context, selected, parent *Root, want Reservation) (*Workspace, error)
- func FindWorkspaces(ctx context.Context, selected, parent *Root, want Reservation) (result []*Workspace, err error)
- func InspectWorkspace(selected, parent *Root, path string, want Reservation) (*Workspace, error)
- type WorkspaceAllocation
Constants ¶
const EnrollmentOwnerLockName = ".arm-sync-owner.lock"
const EnrollmentRecordName = ".arm-sync-enrollment"
EnrollmentRecordName is stored under the held backing anchor, outside the selected project's home. Reading it is not native enrollment authority.
Variables ¶
var ErrBackingHeadroom = errors.New("independent charged-sync backing headroom unavailable")
var ErrChanged = errors.New("sync filesystem binding or entry changed")
var ErrEnrollmentRecord = errors.New("charged sync enrollment record unavailable")
ErrNativeIdentityUnavailable means a persisted baseline cannot safely distinguish root inode reuse on this filesystem.
var ErrPreOpenEnrollment = errors.New("pre-open charged sync enrollment unavailable")
var ErrQuotaUnknown = errors.New("native sync quota status unknown")
var ErrQuotaUnsupported = errors.New("native sync quota unavailable")
var ErrUnknown = errors.New("sync native outcome unknown; retained evidence requires inspection")
Functions ¶
func BuildSourceManifest ¶
func BuildSourceManifest(ctx context.Context, source, manifest *Root, plan syncreconcile.Plan, sourceSide, receiverSide syncreconcile.Side, names NamePolicy, metadata Metadata, byteLimit int64) ([]DirectoryMetadata, StageCharge, error)
BuildSourceManifest copies only reviewed After sources for one source and receiver side into a fresh private tree. The tree can be passed as the entire sender root to rsyncengine.Run without exposing other source paths. The returned directory records must cross the authenticated control stream and be applied to the receiver stage after all transfer batches.
func FinalizeStageDirectories ¶
func FinalizeStageDirectories(ctx context.Context, receiver, stage *Root, plan syncreconcile.Plan, receiverSide syncreconcile.Side, metadata Metadata, records []DirectoryMetadata) error
FinalizeStageDirectories restores reviewed directory modes and mtimes after all rsync batches. Records must cover exactly the receiver's directory After actions, regardless of which endpoint supplied their contents.
func VerifyPlanRoot ¶
func VerifyPlanRoot(plan syncreconcile.Plan, side syncreconcile.Side, root *Root) error
VerifyPlanRoot refuses a stale or different native endpoint before any source materialization or receiver basis copy.
Types ¶
type BackingHeadroom ¶
type BackingHeadroom struct {
// contains filtered or unexported fields
}
BackingHeadroom is a descriptor-bound observation, not disk admission or proof that the recorded project is exclusively owned by this Manager.
func ProbeBackingHeadroom ¶
func ProbeBackingHeadroom(ctx context.Context, backing, project *Root, enrollment *RecordedEnrollment) (BackingHeadroom, error)
ProbeBackingHeadroom reads the held parent of the dedicated project, not statfs(home), whose counters are limited by the project's remaining quota. The record is only an expected tuple; a future opener must separately prove native enrollment and ownership before using this observation for admission. The caller must keep both roots open, with no concurrent Root.Close, until this call has returned.
func (BackingHeadroom) AvailableBytes ¶
func (b BackingHeadroom) AvailableBytes() int64
func (BackingHeadroom) BackingRootID ¶
func (b BackingHeadroom) BackingRootID() string
func (BackingHeadroom) MountID ¶
func (b BackingHeadroom) MountID() string
func (BackingHeadroom) TotalBytes ¶
func (b BackingHeadroom) TotalBytes() int64
type CompleteScopeProof ¶
type CompleteScopeProof struct {
// contains filtered or unexported fields
}
CompleteScopeProof can only be built after an original owner exclusion and the complete platform verification. A copied or zero proof is refused when the owner fence is no longer live. BindingFor returns the cached observation; it does not freshly query quota or rescan the tree, and is not authority to execute work.
func VerifyCompleteScope ¶
func VerifyCompleteScope(ctx context.Context, claim ScopeClaim, owner *ExclusiveScopeOwner, project, selected, parent *Root) (CompleteScopeProof, error)
VerifyCompleteScope reads an existing native limit and complete held trees. A diagnostic ProbeNativeQuota result or caller-supplied claim cannot mint a positive proof: the original exclusive owner must already be live. There is no production owner fence in this patch, so all current callers fail closed.
func (CompleteScopeProof) BindingFor ¶
func (p CompleteScopeProof) BindingFor(ctx context.Context, claim ScopeClaim) (ScopeBinding, error)
func (CompleteScopeProof) VerificationToken ¶
func (p CompleteScopeProof) VerificationToken() *syncscope.Verifier
VerificationToken is only an ordering witness for a subsequent fresh writer. It supplies no execution or quota authority by itself.
type DirectoryMetadata ¶
DirectoryMetadata is a plan-bound sidecar for restoring staged directory metadata after all rsync batches. Child transfer changes directory mtimes.
type EnrollmentRecord ¶
type EnrollmentRecord struct {
Version string `json:"version"`
Provider string `json:"provider"`
MountID string `json:"mount_id"`
ScopeID string `json:"scope_id"`
ProjectID uint32 `json:"project_id"`
ProjectRootID string `json:"project_root_id"`
SelectedRootID string `json:"selected_root_id"`
HomeRootID string `json:"home_root_id"`
BackingRootID string `json:"backing_root_id"`
OwnerUID string `json:"owner_uid"`
OwnerEpoch uint64 `json:"owner_epoch"`
ChargedHardBytes int64 `json:"charged_hard_bytes"`
}
EnrollmentRecord is a canonical, persisted intent for one dedicated XFS project. It cannot grant a scope: the native project, mount, quota and exclusive owner must still be checked before any Manager startup write.
func DecodeEnrollmentRecord ¶
func DecodeEnrollmentRecord(raw []byte) (EnrollmentRecord, error)
DecodeEnrollmentRecord accepts only the one bounded canonical encoding. In particular, aliases, duplicate fields, trailing bytes and unknown fields cannot be normalized into a different ownership claim.
type ExclusiveScopeOwner ¶
type ExclusiveScopeOwner struct {
// contains filtered or unexported fields
}
ExclusiveScopeOwner cannot be populated by a wire field or ordinary caller. Only an in-package provider with a real original-owner fence may construct it. This type alone is not Manager execution or cleanup authority.
func NewBoundOriginalScopeOwner ¶
func NewBoundOriginalScopeOwner(ctx context.Context, claim ScopeClaim, original *syncscope.Original, project, selected, parent *Root) (*ExclusiveScopeOwner, error)
NewBoundOriginalScopeOwner joins a concrete live Manager original to the sealed native verifier. The shared Original keeps the sole SQLite connection and native mutation gate throughout VerifyCompleteScope. No caller-provided boolean or positive callback is accepted here.
type Journal ¶
type Journal interface {
Prepare(context.Context, Receipt) error
Outcome(context.Context, Receipt) error
}
Journal must durably record Prepare before a native effect and Outcome after it. A failed Outcome leaves the same-key operation unknown; the caller must never infer success from a returned nil OS error alone.
type NamePolicy ¶
type NamePolicy struct{ CaseInsensitive bool }
func DetectNamePolicy ¶
func DetectNamePolicy(selected, scratch *Root) (NamePolicy, error)
DetectNamePolicy probes an operation-owned private scratch directory on the selected root's filesystem. Linux per-directory casefold is refused during traversal; Unicode names are conservatively unsupported on both platforms.
type NativeQuotaEvidence ¶
type NativeQuotaEvidence struct {
// contains filtered or unexported fields
}
NativeQuotaEvidence reports a hard limit observed from the operating system for the original held roots. Only ProbeNativeQuota can construct a nonzero value. It does not establish exclusive operation ownership, a durable quota reservation, cleanup authority, or permission to open public sync dispatch.
func ProbeNativeQuota ¶
func ProbeNativeQuota(ctx context.Context, selected, parent *Root) (NativeQuotaEvidence, error)
ProbeNativeQuota reads an existing native hard quota without configuring or changing the host. The zero evidence value always accompanies a refusal. Callers must re-probe at every later authority boundary and compare all identities; this point-in-time report is not a lock on quota configuration.
func (NativeQuotaEvidence) HardBytes ¶
func (v NativeQuotaEvidence) HardBytes() uint64
func (NativeQuotaEvidence) Mount ¶
func (v NativeQuotaEvidence) Mount() string
func (NativeQuotaEvidence) ParentRootID ¶
func (v NativeQuotaEvidence) ParentRootID() string
func (NativeQuotaEvidence) Provider ¶
func (v NativeQuotaEvidence) Provider() string
func (NativeQuotaEvidence) Scope ¶
func (v NativeQuotaEvidence) Scope() string
func (NativeQuotaEvidence) SelectedRootID ¶
func (v NativeQuotaEvidence) SelectedRootID() string
func (NativeQuotaEvidence) UsedBytes ¶
func (v NativeQuotaEvidence) UsedBytes() uint64
type PreOpenEnrollmentCandidate ¶
type PreOpenEnrollmentCandidate struct {
// contains filtered or unexported fields
}
PreOpenEnrollmentCandidate holds a cooperating process owner and fresh native observations before Manager startup writes. It is not admission: complete mount-wide project assignment, writer fencing, schema binding and startup integration remain separate requirements. Close is not concurrent with Check; the caller must join all users before releasing the lock.
func OpenPreOpenEnrollmentCandidate ¶
func OpenPreOpenEnrollmentCandidate(ctx context.Context, backingPath, projectPath, selectedPath, homePath string) (_ *PreOpenEnrollmentCandidate, err error)
OpenPreOpenEnrollmentCandidate never creates or repairs native state. The owner file must be provisioned outside the home before this call. Its nonblocking flock excludes cooperating openers and offline maintenance. A positive result cannot be passed to the ordinary Manager Open path. The returned candidate owns its roots; callers must not concurrently Close it or any borrowed root while a candidate method is running.
func (*PreOpenEnrollmentCandidate) Check ¶
func (c *PreOpenEnrollmentCandidate) Check(ctx context.Context) (NativeQuotaEvidence, BackingHeadroom, error)
Check refreshes both native quota and independent backing observations while the same owner file remains held and named. It rechecks all four roots and the named record after the backing read. This is point-in-time evidence among cooperating owners, not a lock against an uncooperative writer or proof of all project-ID assignments on the mount; it grants no Manager write. The caller must join other candidate users before Close.
func (*PreOpenEnrollmentCandidate) Close ¶
func (c *PreOpenEnrollmentCandidate) Close() error
func (*PreOpenEnrollmentCandidate) EnrollmentDigest ¶
func (c *PreOpenEnrollmentCandidate) EnrollmentDigest() string
func (*PreOpenEnrollmentCandidate) Record ¶
func (c *PreOpenEnrollmentCandidate) Record() EnrollmentRecord
type Publisher ¶
type Publisher struct {
Root *Root
Work *Workspace
Plan syncreconcile.Plan
Metadata Metadata
Names NamePolicy
Exclusions []string
Journal Journal
// contains filtered or unexported fields
}
func NewBoundPublisher ¶
func NewBoundPublisher(root *Root, work *Workspace, plan syncreconcile.Plan, names NamePolicy, metadata Metadata, exclusions []string, journal Journal) (*Publisher, error)
NewBoundPublisher is the sync worker entry for publication. It verifies the receiver's held native root against the reviewed plan before constructing the lower-level publisher.
func NewPublisher ¶
func NewPublisher(root *Root, work *Workspace, plan syncreconcile.Plan, names NamePolicy, metadata Metadata, exclusions []string, j Journal) (*Publisher, error)
type Receipt ¶
type Receipt struct {
Key, PlanDigest string
Generation uint64
Side syncreconcile.Side
Index int
Action syncreconcile.Action
State string // prepared, applied, conflict, or unknown
Preimage, Staged string
Error string
}
type RecordedEnrollment ¶
type RecordedEnrollment struct {
// contains filtered or unexported fields
}
RecordedEnrollment can only come from the held, exact named record read. A zero value or copied JSON fields cannot authorize the backing probe. It still does not establish native quota ownership or Manager admission.
func ReadEnrollmentRecord ¶
func ReadEnrollmentRecord(backing *Root) (*RecordedEnrollment, error)
ReadEnrollmentRecord opens only the fixed no-follow file relative to the held backing anchor. It never creates or repairs enrollment. Its digest is an integrity comparison for a later native verifier, not bearer authority. The caller must keep backing open, with no concurrent Root.Close, until this call has returned.
func (*RecordedEnrollment) Digest ¶
func (e *RecordedEnrollment) Digest() string
func (*RecordedEnrollment) Record ¶
func (e *RecordedEnrollment) Record() EnrollmentRecord
type Reservation ¶
type Reservation struct {
Key, PlanDigest string
Generation uint64
Side syncreconcile.Side
DiskBytes int64
}
Reservation is the caller's durable admission reference. syncfs verifies its shape and enforces DiskBytes during preflight, but only the controller can prove the reservation was actually charged to both endpoint budgets.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root holds every named ancestor from / through the selected directory. Symlinks in that chain are refused. Operations use held descriptors and recheck the entire named binding before and after native cuts.
func (*Root) NativeID ¶
NativeID binds a canonical named root to the held directory, filesystem, and supported native creation evidence. The caller must include effective account/enrollment in Endpoint.ID too. Earlier IDs intentionally do not match, so a baseline with weaker root identity cannot be reused silently.
func (*Root) Scan ¶
func (r *Root) Scan(ctx context.Context, candidates, exclusions []string, policy NamePolicy, metadata Metadata, limits ScanLimits) (syncreconcile.Snapshot, error)
Scan returns selected fingerprints and keys for all observed, candidate and excluded names. Candidate names include absent peer/baseline/resolution paths; exclusion ancestors are always keyed. It never follows symlinks.
type ScanLimits ¶
type ScopeBinding ¶
type ScopeBinding struct {
// contains filtered or unexported fields
}
ScopeBinding is a copied native observation, not Manager execution authority. All fields are private; callers can only inspect its values.
func (ScopeBinding) HardBytes ¶
func (b ScopeBinding) HardBytes() uint64
func (ScopeBinding) MountID ¶
func (b ScopeBinding) MountID() string
func (ScopeBinding) OwnerEpoch ¶
func (b ScopeBinding) OwnerEpoch() uint64
func (ScopeBinding) OwnershipDigest ¶
func (b ScopeBinding) OwnershipDigest() string
func (ScopeBinding) ParentRootID ¶
func (b ScopeBinding) ParentRootID() string
func (ScopeBinding) ProjectID ¶
func (b ScopeBinding) ProjectID() uint32
func (ScopeBinding) ProjectRootID ¶
func (b ScopeBinding) ProjectRootID() string
func (ScopeBinding) Provider ¶
func (b ScopeBinding) Provider() string
func (ScopeBinding) ScopeID ¶
func (b ScopeBinding) ScopeID() string
func (ScopeBinding) SelectedRootID ¶
func (b ScopeBinding) SelectedRootID() string
func (ScopeBinding) UsedBytes ¶
func (b ScopeBinding) UsedBytes() uint64
type ScopeClaim ¶
type ScopeClaim struct {
// contains filtered or unexported fields
}
ScopeClaim is a validated request to inspect one already-enforced native scope. It cannot authorize setup, execution, or native cleanup.
func NewScopeClaim ¶
func NewScopeClaim(fields ScopeClaimFields) (ScopeClaim, error)
type ScopeClaimFields ¶
type ScopeClaimFields struct {
Key, Side, PreparationLease string
Provider, ScopeID, MountID string
ProjectRootID, SelectedRootID, ParentRootID string
OwnershipDigest string
ProjectID uint32
OwnerEpoch uint64
// ChargedHardBytes is the entire immutable native project hard ceiling
// charged to the original Manager lease, not estimated free headroom.
ChargedHardBytes int64
}
ScopeClaimFields are expected identities copied from a durable original preparation record. These caller values are requests, never proof.
type StageCharge ¶
StageCharge is a logical lower bound. The caller must reserve and observe actual filesystem allocation, temporary rsync files, metadata and journals.
func SeedReceiverBasis ¶
func SeedReceiverBasis(ctx context.Context, receiver, stage *Root, plan syncreconcile.Plan, receiverSide syncreconcile.Side, names NamePolicy, metadata Metadata, byteLimit int64) (StageCharge, error)
SeedReceiverBasis copies each reviewed file Before into an empty private receiver stage. It never hard-links a live selected file; rsync may mutate these isolated basis copies while reconstructing the reviewed After.
type Workspace ¶
type Workspace struct {
Reservation Reservation
Parent, Base, Stage, Quarantine *Root
// contains filtered or unexported fields
}
Workspace is operation-owned staging and quarantine on the receiver's filesystem, outside selected contents. Close only closes handles: recovery evidence is retained until a separate confirmed cleanup procedure.
func CreateWorkspace ¶
func CreateWorkspace(receiver, parent *Root, v Reservation) (*Workspace, error)
func FindWorkspace ¶
func FindWorkspace(ctx context.Context, selected, parent *Root, want Reservation) (*Workspace, error)
FindWorkspace is the single-workspace form of FindWorkspaces. It refuses ambiguity; callers inspecting a multi-workspace operation should use the collection form and keep every charged obligation unresolved.
func FindWorkspaces ¶
func FindWorkspaces(ctx context.Context, selected, parent *Root, want Reservation) (result []*Workspace, err error)
FindWorkspaces searches the held private parent for all marked workspaces with the original reservation. One operation can own more than one workspace. The result is read-only recovery evidence, not cleanup or release authority. Incomplete, absent or over-limit evidence leaves the outcome unknown.
func InspectWorkspace ¶
func InspectWorkspace(selected, parent *Root, path string, want Reservation) (*Workspace, error)
InspectWorkspace reopens a named private workspace against the exact selected root, parent, and original reservation. It returns held handles for inspection only. A matching marker never authorizes deletion or proves physical reclamation; the caller must keep the charged lease unresolved.
func (*Workspace) QuarantinePath ¶
type WorkspaceAllocation ¶
WorkspaceAllocation is a bounded observation of st_blocks in one marked private workspace. Hard links, clones and shared filesystem blocks may be counted more than once; this is never exclusive reclamation evidence.
func SurveyWorkspace ¶
func SurveyWorkspace(ctx context.Context, selected, parent *Root, path string, want Reservation) (WorkspaceAllocation, error)
SurveyWorkspace reads one exact marked workspace through held descriptors. It refuses changed entries and crossings of the reported native mount identity: Linux requires STATX_MNT_ID; Darwin pairs Fsid and Mntonname. This is not an atomic snapshot against same-account writers, proof of exclusive blocks, or cleanup authority.
Source Files
¶
- allocation.go
- allocation_linux.go
- backing_headroom.go
- backing_headroom_linux.go
- enforced_scope.go
- enforced_scope_bridge.go
- enforced_scope_linux.go
- enrollment_record.go
- native_linux.go
- preopen_enrollment.go
- publish.go
- quota_probe.go
- quota_probe_linux.go
- root.go
- rootid_linux.go
- scan.go
- staging.go
- workspace.go
- workspace_evidence.go
- workspace_find.go