Skip to main content

Identity

Struct Identity 

Source
pub struct Identity {
    pub workspace_name: String,
    pub workspace_id: String,
    pub change_id: String,
    pub idempotency_key: String,
    pub fingerprint: String,
    pub scheme: Scheme,
}
Expand description

The four identifiers one writing attempt is bound to.

Built together and never separately, because their whole value is that they agree: the workspace a change is bound to, the change a checkpoint advances, and the idempotency key that makes a lost create response converge rather than fork.

Fields§

§workspace_name: String

Directory name.

§workspace_id: String

owner/repo/name, the workspace’s view identity.

§change_id: String

Stable logical change id, unique per external unit of work.

§idempotency_key: String

Owner-scoped create retry identity.

§fingerprint: String

Full hex fingerprint, under Scheme::FromExternal only. Empty under Scheme::FromName, where the name carries the identity.

§scheme: Scheme

Which rule produced this binding. Recorded so an adapter reading durable state written by another scheme refuses it rather than deriving a second change for work that already has one.

Implementations§

Source§

impl Identity

Source

pub fn from_name( namespace: &str, repo: &str, workspace_name: &str, ) -> Result<Self, Failure>

Derives the binding from the workspace name, under Scheme::FromName.

The inverse is what makes this scheme worth having: given only repo and a directory name, the change and idempotency key come back exactly, so teardown needs no stored state. Claude Code’s WorktreeRemove is handed a path and nothing else, and this is the property that lets it archive the right change.

§Errors

Returns a Failure when the repo or the name is not a safe path component.

Source

pub fn from_external( namespace: &str, repo: &str, workspace_key: &str, external_id: &str, generation: &str, ) -> Result<Self, Failure>

Derives the binding by fingerprinting external identity, under Scheme::FromExternal.

namespace separates orchestrators, so two of them driving the same repository cannot collide on a name or, worse, converge onto one another’s change. external_id and generation are whatever the orchestrator means by “this unit of work” and “this attempt at it”: a tracker issue and a retry counter.

Two workers racing the same (external_id, generation) derive the same change and the same idempotency key, which is what makes one of them reuse the other’s workspace instead of forking the work in two. That convergence is the whole reason to pay for durable state.

The fingerprint covers the scheme tag, repo, external_id and generation, each length-prefixed, so no choice of separators inside a field can make two different tuples hash alike.

§Errors

Returns a Failure when any input is empty, over-long, or unsafe as a path component.

Trait Implementations§

Source§

impl Clone for Identity

Source§

fn clone(&self) -> Identity

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Identity

Source§

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

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

impl PartialEq for Identity

Source§

fn eq(&self, other: &Identity) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Identity

Source§

impl StructuralPartialEq for Identity

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, 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> 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.