Skip to main content

SyncOptions

Struct SyncOptions 

Source
#[non_exhaustive]
pub struct SyncOptions {
Show 14 fields pub dry_run: bool, pub validate: bool, pub workspace: Option<PathBuf>, pub ref_override: Option<String>, pub only_patterns: Option<Vec<String>>, pub force: bool, pub parallel: Option<usize>, pub force_prune: bool, pub force_prune_with_ignored: bool, pub quarantine: bool, pub migrate_lockfile: bool, pub recurse: bool, pub max_depth: Option<usize>, pub retain_days: Option<u32>,
}
Expand description

Inputs to run.

Fields are public-writable so call sites can construct with struct literals and ..SyncOptions::default(). Marked #[non_exhaustive] so future knobs (parallelism, filter expressions, additional ref strategies) can land without breaking library consumers who constructed with explicit-literal syntax. Forces callers to use struct-update syntax (..Default::default()).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§dry_run: bool

When true, use PlanExecutor (no filesystem mutations).

§validate: bool

When false, skip plan-phase validators (manifest + graph). Debug escape hatch; production callers should leave this true.

§workspace: Option<PathBuf>

Override workspace directory. None → derived from pack_root (the directory holding .grex/pack.yaml).

v1.2.1 path (iii) semantics: when Some, this path IS the canonical meta directory. Children resolve parent-relatively as <workspace>/<child.path> and <workspace>/.grex/pack.yaml is where the root manifest is read from. The path MUST exist; symlinks are resolved via fs::canonicalize to a single inode-stable form. Pre-v1.2.1 the override only re-anchored children — that legacy split is retired.

§ref_override: Option<String>

Global ref override (grex sync --ref <sha|branch|tag>). When Some, every child pack clone/checkout uses this ref instead of the declared child.ref. Empty strings are rejected at the CLI layer.

§only_patterns: Option<Vec<String>>

Pack-path filter patterns (grex sync --only <glob>). Raw glob strings — compiled internally via an in-crate globset helper so the globset crate version does not leak into the public API. None / empty means every pack runs (M3 semantics). Matching is against the pack’s workspace-relative path normalized to forward-slash form.

§force: bool

Bypass the lockfile hash-match skip (grex sync --force). When true, every pack re-executes even if its actions_hash is unchanged from the prior lockfile.

§parallel: Option<usize>

Max parallel pack ops for this sync run (feat-m6-1).

  • None → callers default to num_cpus::get() at CLI layer. Library callers who construct SyncOptions directly and leave this None get num_cpus::get() semantics too — the sync driver resolves the default in one place so the scheduler slot on every ExecCtx is always populated.
  • Some(0) → unbounded (Semaphore::MAX_PERMITS).
  • Some(1) → serial fast-path.
  • Some(n >= 2) → bounded parallel.
§force_prune: bool

v1.2.0 Stage 1.l prep — when true, walker Phase 2 may drop dirty trees during prune. Still refuses ignored content unless SyncOptions::force_prune_with_ignored is also true. Default false preserves v1.1.1 behavior (refuse all dirty drops).

§force_prune_with_ignored: bool

v1.2.0 Stage 1.l prep — when true (implies SyncOptions::force_prune), walker Phase 2 also drops ignored content. Hard override — the strongest level. Default false preserves v1.1.1 behavior.

§quarantine: bool

v1.2.1 Item 5b — when true AND force_prune (or force_prune_with_ignored) is set, divert Phase 2 prunes through the snapshot-then-unlink quarantine pipeline. The dest’s full subtree is recursively copied to <workspace>/.grex/trash/<ISO8601>/<basename>/ BEFORE unlink(dest) fires. Snapshot or audit-fsync failure aborts the prune (no unlink). Lean theorem quarantine_snapshot_precedes_delete proves the safety contract. Default false preserves v1.2.0 direct-unlink behavior. Has no effect unless one of the force_prune* flags is also set (the CLI enforces this via requires = "force_prune"; library callers who set this with neither flag get a no-op since Phase 2 will not enter the override path at all).

§migrate_lockfile: bool

v1.2.0 Stage 1.h opt-in — when true, the walker rewrites a legacy v1.1.1 lockfile in place to the v1.2.0 shape. When false (default), the walker errors on the legacy shape so migration is always an explicit caller decision.

§recurse: bool

v1.2.0 Stage 1.j prep — when true (default), the walker descends into nested meta-children. doctor --shallow flips this to false so only the immediate workspace is inspected.

§max_depth: Option<usize>

v1.2.0 Stage 1.j prep — pairs with SyncOptions::recurse for --shallow=N. None (default) is unbounded recursion when recurse is true. Some(n) caps depth at n levels of nesting.

§retain_days: Option<u32>

v1.2.5 — when Some(N), every meta sync starts with a best-effort GC sweep over <meta>/.grex/trash/, deleting entries older than N days. None (default) preserves the v1.2.1 indefinite-retention behavior. The CLI surfaces this as grex sync --retain-days N; library callers wire it via SyncOptions::with_retain_days. Sweep failures log via tracing::warn! and DO NOT halt the sync.

Implementations§

Source§

impl SyncOptions

Source

pub fn new() -> Self

Default options: wet-run, validators enabled, default workspace path.

Source

pub fn with_dry_run(self, dry_run: bool) -> Self

Set dry_run.

Source

pub fn with_validate(self, validate: bool) -> Self

Set validate.

Source

pub fn with_workspace(self, workspace: Option<PathBuf>) -> Self

Set workspace override.

Source

pub fn with_ref_override(self, ref_override: Option<String>) -> Self

Set ref_override (--ref).

Source

pub fn with_only_patterns(self, patterns: Option<Vec<String>>) -> Self

Set only_patterns (--only). Empty vector or None disables the filter.

Source

pub fn with_force(self, force: bool) -> Self

Set force (--force).

Source

pub fn with_parallel(self, parallel: Option<usize>) -> Self

Set parallel (--parallel). See SyncOptions::parallel for the None / Some(0) / Some(1) / Some(n) semantics.

Source

pub fn with_force_prune(self, force_prune: bool) -> Self

Set force_prune (--force-prune). See SyncOptions::force_prune for the override matrix.

Source

pub fn with_force_prune_with_ignored( self, force_prune_with_ignored: bool, ) -> Self

Set force_prune_with_ignored (--force-prune-with-ignored). See SyncOptions::force_prune_with_ignored for the override matrix.

Source

pub fn with_quarantine(self, quarantine: bool) -> Self

Set quarantine (--quarantine). See SyncOptions::quarantine for the snapshot-before-delete contract. Has no effect unless SyncOptions::force_prune or SyncOptions::force_prune_with_ignored is also set.

Source

pub fn with_retain_days(self, retain_days: Option<u32>) -> Self

Set retain_days (--retain-days N). See SyncOptions::retain_days for the GC-sweep contract. None preserves v1.2.1 indefinite-retention behavior; Some(N) triggers a best-effort sweep at the start of every meta sync.

Trait Implementations§

Source§

impl Clone for SyncOptions

Source§

fn clone(&self) -> SyncOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyncOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SyncOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more