pub struct MigrationState {
pub format_version: u32,
pub phase: Phase,
pub source_path: PathBuf,
pub source_fingerprint: String,
pub target_model: String,
pub target_dimension: usize,
pub progress: BTreeMap<String, CollectionProgress>,
pub embedder_witness: Option<String>,
}Expand description
What a prepared migration recorded, so a later run can decide whether to resume it.
Emphatically not a crate::migration::DiagnosisReport: a report answers
“what is here”, a
state asserts “a migration is under way and got this far”. A diagnosis never
produces one.
Fields§
§format_version: u32The shape of this state — see STATE_FORMAT_VERSION.
phase: PhaseHow far the migration got.
source_path: PathBufThe store being migrated.
source_fingerprint: StringThe source’s fingerprint when the migration was prepared.
target_model: StringThe model the migration is rebuilding against.
target_dimension: usizeThe width that model produces.
progress: BTreeMap<String, CollectionProgress>How far each collection’s rebuild got — exactly one entry per agent collection, always. A missing key would silently skip a collection’s rebuild; an extra one would journal work nobody will do. Both are refused by validation rather than tolerated.
embedder_witness: Option<String>A digest of what the target embedder actually PRODUCES, not what it is
called — sha256: over the vector it answers for a fixed sentinel
sentence. Some exactly when the resolved regime is reembed, None
under reuse, so the field also records the regime without a second
field to drift from it.
This exists because MigrationState::may_resume’s model check
compares NAMES, and a name is a claim: ollama pull updates a model’s
weights in place under the same identifier. A run resumed across such
an update would collide its replayed batch into run-one vectors and
write run-two vectors after it — one store, one recorded model, two
incompatible vector spaces, which is exactly what the model check says
it prevents. Vectors do not lie about the embedder that made them.
Implementations§
Source§impl MigrationState
impl MigrationState
Sourcepub fn may_resume(
&self,
source_path: &Path,
source_fingerprint: &str,
target_model: &str,
target_dimension: usize,
) -> Result<(), String>
pub fn may_resume( &self, source_path: &Path, source_fingerprint: &str, target_model: &str, target_dimension: usize, ) -> Result<(), String>
Whether this state may be resumed against the source and target now in front of us.
Every refusal names both sides. A resume that silently adapted to a changed fingerprint would rebuild from a store that is no longer the one it inventoried; one that adapted to a changed model would produce a store whose vectors and whose recorded model disagree.
§Errors
A message naming what changed and what the operator can do about it.
Sourcepub fn read(workspace: &Path) -> Result<Option<Self>, String>
pub fn read(workspace: &Path) -> Result<Option<Self>, String>
Read a state from workspace, refusing one this build cannot act on.
The version is read out of the raw JSON BEFORE the state is deserialised, because a newer state may carry fields this build cannot parse — and “cannot parse” would otherwise surface as a corruption error instead of the version refusal it actually is.
§Errors
The file is unreadable, is not JSON, or is stamped with a version newer
from STATE_FORMAT_VERSION.
Sourcepub fn write(
&self,
workspace: &Path,
lock: &MigrationLock,
) -> Result<(), String>
pub fn write( &self, workspace: &Path, lock: &MigrationLock, ) -> Result<(), String>
Atomically and durably replace the state in workspace.
The caller must hold lock. The complete JSON is written to a fixed
sibling staging file, flushed and synced before one atomic promotion.
The promotion is then made durable with the platform’s directory or
write-through barrier. A pre-existing staging file is refused as
evidence of an interrupted writer; it is never overwritten.
§Errors
The lock does not guard this workspace, an existing state is invalid, staging is ambiguous, or any write/durability step fails.
Trait Implementations§
Source§impl Clone for MigrationState
impl Clone for MigrationState
Source§fn clone(&self) -> MigrationState
fn clone(&self) -> MigrationState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MigrationState
impl Debug for MigrationState
Source§impl<'de> Deserialize<'de> for MigrationState
impl<'de> Deserialize<'de> for MigrationState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MigrationState
Source§impl PartialEq for MigrationState
impl PartialEq for MigrationState
Source§impl Serialize for MigrationState
impl Serialize for MigrationState
impl StructuralPartialEq for MigrationState
Auto Trait Implementations§
impl Freeze for MigrationState
impl RefUnwindSafe for MigrationState
impl Send for MigrationState
impl Sync for MigrationState
impl Unpin for MigrationState
impl UnsafeUnpin for MigrationState
impl UnwindSafe for MigrationState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);