graflo.architecture.schema.context.rank¶
Ranking vertex types by how useful they are to an agent orienting itself.
Local signals only — degree, identity policy, property count, index presence, hop distance from a seed. No embeddings and no corpus statistics: semantic ranking is the server's business (it has the index), core stays dependency-free.
Attributes¶
IDENTITY_MODE_STRENGTH = {'natural': 1.0, 'hash': 0.75, 'assigned': 0.5, 'blank': 0.1}
module-attribute
¶
Classes¶
RankingWeights
¶
Bases: ConfigBaseModel
Relative weight of each local signal. Weights need not sum to 1.
Source code in graflo/architecture/schema/context/rank.py
Attributes¶
degree = PydanticField(default=0.2, description='Weight of normalized incident-edge count.', ge=0.0)
class-attribute
instance-attribute
¶
hop_decay = PydanticField(default=0.55, description='Score multiplier per hop of distance from the nearest seed.', gt=0.0, le=1.0)
class-attribute
instance-attribute
¶
identity = PydanticField(default=0.15, description='Weight of identity-mode strength.', ge=0.0)
class-attribute
instance-attribute
¶
indexed = PydanticField(default=0.1, description='Weight of secondary-index presence (cheap to filter on).', ge=0.0)
class-attribute
instance-attribute
¶
properties = PydanticField(default=0.1, description='Weight of log-scaled property count.', ge=0.0)
class-attribute
instance-attribute
¶
VertexSignals
¶
Bases: ConfigBaseModel
Per-vertex-type ranking inputs and the score derived from them.
Source code in graflo/architecture/schema/context/rank.py
Attributes¶
degree = PydanticField(..., description='Incident edges (out + in).')
class-attribute
instance-attribute
¶
has_secondary_index = PydanticField(..., description='Whether db_profile declares a secondary index for this type.')
class-attribute
instance-attribute
¶
hop_distance = PydanticField(default=None, description='Hops from the nearest seed; None when unreachable.')
class-attribute
instance-attribute
¶
identity_mode = PydanticField(..., description='One of natural / hash / assigned / blank.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Vertex type name.')
class-attribute
instance-attribute
¶
property_count = PydanticField(..., description='Declared property count.')
class-attribute
instance-attribute
¶
score = PydanticField(..., description='Composite rank; higher is better.')
class-attribute
instance-attribute
¶
Functions:¶
score_vertices(graph, seeds=(), *, weights=None, max_hops=3, direction=EdgeDirection.ANY)
¶
Rank every vertex type in graph, highest score first.
With no seeds, ranking is seed-independent (structure only) and answers "what are the important types here" — which is what the orientation card needs. With seeds, hop distance dominates and answers "what is near what I asked about".
Ties break by vertex name ascending. This is not cosmetic: without a total order the elision report is not reproducible across runs, and the budget tests become flaky.