Skip to main content

SymbolClaimTracker

Struct SymbolClaimTracker 

Source
pub struct SymbolClaimTracker { /* private fields */ }
Expand description

Thread-safe, lock-free tracker for symbol-level claims across sessions.

Key insight: two sessions modifying DIFFERENT symbols in the same file is NOT a conflict. Only same-symbol modifications across sessions are TRUE conflicts. This is dkod’s core differentiator over line-based VCS.

The tracker is keyed by (repo_id, file_path) and stores a Vec<SymbolClaim> for each file. DashMap provides fine-grained per-shard locking so reads are effectively lock-free when not contending on the same shard.

Implementations§

Source§

impl SymbolClaimTracker

Source

pub fn new() -> Self

Create a new, empty tracker.

Source

pub fn record_claim(&self, repo_id: Uuid, file_path: &str, claim: SymbolClaim)

Record a symbol claim. If the same session already claims the same qualified_name in the same file, the existing claim is updated (not duplicated).

Source

pub fn acquire_lock( &self, repo_id: Uuid, file_path: &str, claim: SymbolClaim, ) -> Result<AcquireOutcome, SymbolLocked>

Attempt to acquire a symbol lock. If the symbol is already claimed by another session, returns Err(SymbolLocked) — the write MUST NOT proceed. If claimed by the same session, or unclaimed, acquires and returns Ok(()).

This is the blocking counterpart to record_claim. Use this when writes should be rejected if another agent holds the symbol.

Source

pub fn release_lock( &self, repo_id: Uuid, file_path: &str, session_id: Uuid, qualified_name: &str, )

Release a single symbol lock for a session in a specific file. Used to roll back partially-acquired locks when a batch fails.

Source

pub fn release_locks( &self, repo_id: Uuid, session_id: Uuid, ) -> Vec<ReleasedLock>

Release all locks held by a session and return what was released. Callers should emit symbol.lock.released events for each returned entry.

Source

pub fn check_conflicts( &self, repo_id: Uuid, file_path: &str, session_id: Uuid, qualified_names: &[String], ) -> Vec<ConflictInfo>

Check whether any of the given qualified_names are already claimed by a session other than session_id. Returns a ConflictInfo for each conflicting symbol.

Source

pub fn get_all_conflicts_for_session( &self, repo_id: Uuid, session_id: Uuid, ) -> Vec<(String, ConflictInfo)>

Return all conflicts for a given session across ALL file paths.

This checks every tracked file to find symbols where session_id has a claim AND another session also claims the same symbol.

Source

pub fn clear_session(&self, session_id: Uuid) -> Vec<ReleasedLock>

Remove all claims belonging to a session across ALL repos (e.g. on disconnect or GC). Returns the released locks so callers can emit symbol.lock.released events to unblock waiting agents.

Trait Implementations§

Source§

impl Default for SymbolClaimTracker

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> Fruit for T
where T: Send + Downcast,