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: StringDirectory name.
workspace_id: Stringowner/repo/name, the workspace’s view identity.
change_id: StringStable logical change id, unique per external unit of work.
idempotency_key: StringOwner-scoped create retry identity.
fingerprint: StringFull hex fingerprint, under Scheme::FromExternal only. Empty
under Scheme::FromName, where the name carries the identity.
scheme: SchemeWhich 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
impl Identity
Sourcepub fn from_name(
namespace: &str,
repo: &str,
workspace_name: &str,
) -> Result<Self, Failure>
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.
Sourcepub fn from_external(
namespace: &str,
repo: &str,
workspace_key: &str,
external_id: &str,
generation: &str,
) -> Result<Self, Failure>
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.