pub struct RelationshipGraph<'a> { /* private fields */ }Expand description
The in-memory relationship graph: one adjacency build, every derived read.
The struct is built once per read from an in-memory issue set — no
filesystem access — and answers relationships_for, blocks,
blocked_by, duplicates_of, related_to, dependency_chain,
blocked_state, and validate_snapshot from the same indices.
Implementations§
Source§impl<'a> RelationshipGraph<'a>
impl<'a> RelationshipGraph<'a>
Sourcepub fn validation_passes(&self) -> usize
pub fn validation_passes(&self) -> usize
How many validation passes this graph has run. See
RelationshipGraph::validation_passes for why this exists.
Sourcepub fn new(issues: &[IssueView<'a>], done_column: &str) -> Self
pub fn new(issues: &[IssueView<'a>], done_column: &str) -> Self
Build the graph from an in-memory issue set.
done_column is the board’s configured completion column, used by the
resolution predicate in RelationshipGraph::blocked_state. Pass the
configured value (BoardConfiguration::effective_done_column), never a
hard-coded "done".
An empty done_column is accepted and means no column marks
completion, so nothing is treated as done. Config validation keeps
columns non-empty in practice, but a caller that passes "" must not
silently get “an empty status counts as completed”.
Sourcepub fn done_column(&self) -> &str
pub fn done_column(&self) -> &str
The configured completion column used by the resolution predicate.
Sourcepub fn issue_count(&self) -> usize
pub fn issue_count(&self) -> usize
How many issues are in the graph.
Sourcepub fn identity_index_size(&self) -> usize
pub fn identity_index_size(&self) -> usize
How many records the one alias index owns.
Sourcepub fn identity_nodes_scanned(&self) -> usize
pub fn identity_nodes_scanned(&self) -> usize
How many issue records the single alias-index pass examined.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
How many stored edges are in the graph.
Sourcepub fn issue_numbers(&self) -> &[u32]
pub fn issue_numbers(&self) -> &[u32]
The issue numbers, ascending.
Sourcepub fn find_relationship(&self, id: &str) -> Option<&Relationship>
pub fn find_relationship(&self, id: &str) -> Option<&Relationship>
The stored relationship with this stable id, if any.
Sourcepub fn find_canonical(
&self,
from: u32,
to: u32,
kind: RelationKind,
) -> Option<&Relationship>
pub fn find_canonical( &self, from: u32, to: u32, kind: RelationKind, ) -> Option<&Relationship>
The stored relationship for this canonical (from, to, kind), if any.
This is the service’s answer to “are these the same relationship?”
A write path must use it rather than comparing endpoints itself, because
the comparison is domain logic and getting it wrong silently breaks
idempotency. tix link 1 2 --type blocked_by and tix link 2 1 --type blocks name one edge; a caller comparing the authored
endpoints would see two and append a second row.
from, to and kind are the authored values. Canonicalization
happens here, so the caller cannot get the direction convention wrong:
blocked_byis normalized to the equivalentblocksedge with the endpoints swapped;relatedis order-normalized, so either orientation finds the row.
When redundant rows exist for one canonical triple — a hand-edited file can hold two spellings of one association — the lowest-id row is returned, so the answer is stable across builds.
Sourcepub fn all_relationships(&self) -> &[Relationship]
pub fn all_relationships(&self) -> &[Relationship]
Every stored relationship, in deterministic order.
Sourcepub fn relationships_for(&self, number: u32) -> Vec<&Relationship>
pub fn relationships_for(&self, number: u32) -> Vec<&Relationship>
Every relationship touching number from either endpoint, in
deterministic (kind, target) order.
An unknown issue yields an empty vector rather than an error; callers
that need an unknown_issue signal check
RelationshipGraph::has_issue.
Sourcepub fn relationships_of_kind(
&self,
number: u32,
kind: RelationKind,
) -> Vec<&Relationship>
pub fn relationships_of_kind( &self, number: u32, kind: RelationKind, ) -> Vec<&Relationship>
Relationships authored by number with the given kind.
Sourcepub fn blocked_by(&self, number: u32) -> &[u32]
pub fn blocked_by(&self, number: u32) -> &[u32]
Issues blocking number, ascending.
This is the raw inbound adjacency. It is not the open-blocker set —
use RelationshipGraph::blocked_state for that, which applies the
resolution predicate.
Sourcepub fn duplicates_of(&self, number: u32) -> Vec<u32>
pub fn duplicates_of(&self, number: u32) -> Vec<u32>
Issues duplicated by number, ascending.
duplicates is directional (data-model.md section 1), so this is
deliberately one-directional: it reports the targets of the edges
number declares and ignores edges that merely point at number. On
a stored 2 duplicates 1 edge the answer is therefore empty — the claim
is “2 duplicates 1”, not “1 duplicates 2”. Reading r.to over every
edge touching the subject instead reports the subject itself (P4).
Issues associated with number by a related edge, ascending.
related is the one non-directional kind, so both endpoints are
equivalent. relationships_for returns edges from both sides, so the
other side of each edge is projected explicitly — reading r.to
directly reports the subject itself for an edge authored from the far
side (P3).
Redundant rows collapse here rather than in the stored edge set: two spellings of one association are one relationship to the user, and discarding a row at build time would silently invalidate an id the user still holds (round 3, finding A).
Sourcepub fn open_blockers(&self, number: u32) -> Vec<ChainNode>
pub fn open_blockers(&self, number: u32) -> Vec<ChainNode>
The open blockers of number, per the resolution predicate.
An inbound blocks edge counts iff the blocker is a different
existing issue and its status is not the configured done_column. A
dangling edge is excluded here (validation reports it as
missing_target) so invalid data cannot permanently freeze an issue.
Sourcepub fn blocked_state(&self, number: u32) -> BlockedState
pub fn blocked_state(&self, number: u32) -> BlockedState
The derived blocked state for number.
reason is the text the move warning and the detail view both display,
so the two surfaces cannot drift.
Sourcepub fn dependency_chain(&self, root: u32) -> DependencyChain
pub fn dependency_chain(&self, root: u32) -> DependencyChain
The transitive dependency chain of root, walking outbound blocks
edges: the issues this one blocks, and what they block in turn.
Direction note: data-model.md §9 specifies the chain is derived “from
outbound blocks edges”, so this follows blocks_out and answers “what
does this issue hold up?”. The opposite question — “what blocks this
issue?” — is what the move guard needs, and is answered by
RelationshipGraph::open_blockers over the inbound adjacency.
The traversal is iterative and marks visited nodes, so a hand-edited cyclic file terminates instead of hanging the TUI.
Sourcepub fn validate_snapshot(&self) -> RelationshipValidationResult
pub fn validate_snapshot(&self) -> RelationshipValidationResult
Sweep every stored edge and every issue, reporting every problem.
A single O(V + E) pass, never an Err: tix lint consumes the
returned value. Cycle detection reuses the blocks adjacency built at
construction, so it is not a second scan.
Sourcepub fn validate_create(
&self,
from: u32,
to: u32,
kind: RelationKind,
) -> RelationshipValidationResult
pub fn validate_create( &self, from: u32, to: u32, kind: RelationKind, ) -> RelationshipValidationResult
Validate a proposed relationship creation.
Runs every per-edge rule plus the cycle check, so the caller gets one blocking verdict before touching any file (SC-005).
Sourcepub fn validate_create_ref(
&self,
from: IssueRef,
to: IssueRef,
kind: RelationKind,
) -> RelationshipValidationResult
pub fn validate_create_ref( &self, from: IssueRef, to: IssueRef, kind: RelationKind, ) -> RelationshipValidationResult
Canonical-reference form of Self::validate_create.
Sourcepub fn validate_edit(
&self,
id: &str,
new_to: Option<u32>,
new_kind: Option<RelationKind>,
) -> RelationshipValidationResult
pub fn validate_edit( &self, id: &str, new_to: Option<u32>, new_kind: Option<RelationKind>, ) -> RelationshipValidationResult
Validate a proposed edit of an existing relationship.
An edit naming its own current target and kind is the identity, not a
duplicate — and nothing else is forgiven. The edit must still agree with
the graph as it already stands, so validate_edit never returns a
cleaner verdict than validate_snapshot for the same stored data.
Trait Implementations§
Source§impl Clone for RelationshipGraph<'_>
impl Clone for RelationshipGraph<'_>
Auto Trait Implementations§
impl<'a> !Freeze for RelationshipGraph<'a>
impl<'a> RefUnwindSafe for RelationshipGraph<'a>
impl<'a> Send for RelationshipGraph<'a>
impl<'a> Sync for RelationshipGraph<'a>
impl<'a> Unpin for RelationshipGraph<'a>
impl<'a> UnsafeUnpin for RelationshipGraph<'a>
impl<'a> UnwindSafe for RelationshipGraph<'a>
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,
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 more