graflo.architecture.schema.context¶
Bounded schema context: the schema graph as a navigable, budgetable object.
Answers "what can I ask?" about a schema without touching a database. Every
export here is layer 2 — pure logical model, no db, no data_source, no
embeddings, no tokenizer.
Eager re-exports (this is a package boundary, not a lazy façade).
Modules:
| Name | Description |
|---|---|
budget |
Budget accounting for schema context payloads. |
card |
Compact orientation card: the cheapest useful thing to hand an agent first. |
elision |
What a bounded projection left out, and how to go and get it. |
graph |
Adjacency index over a schema's vertex types. |
rank |
Ranking vertex types by how useful they are to an agent orienting itself. |
subschema |
Bounded, seeded schema slicing. |
Attributes¶
__all__ = ['BaseCard', 'Budget', 'BudgetAccounting', 'ConnectorCard', 'DatabaseProfileCard', 'EdgeCard', 'ElidedEdge', 'ElidedVertex', 'ElisionReport', 'EntryPoint', 'ManifestCard', 'RankingWeights', 'ResourceCard', 'SchemaCard', 'SchemaGraph', 'SchemaNeighborhood', 'SchemaPath', 'TransformCard', 'VertexCard', 'VertexSignals', 'build_card', 'build_connector_card', 'build_database_profile_card', 'build_edge_card', 'build_manifest_card', 'build_resource_card', 'build_transform_card', 'build_vertex_card', 'estimate_tokens', 'neighborhood_distances', 'score_vertices', 'subschema']
module-attribute
¶
Classes¶
BaseCard
¶
Bases: ConfigBaseModel
Common foundation for all card types.
Source code in graflo/architecture/schema/context/card.py
Budget
¶
Bases: ConfigBaseModel
Caller-requested ceilings on a schema context payload.
Source code in graflo/architecture/schema/context/budget.py
Attributes¶
max_elements = PydanticField(default=60, description='Maximum vertices + edges in the slice. None disables the cap.', ge=1)
class-attribute
instance-attribute
¶
max_properties_per_vertex = PydanticField(default=None, description='Maximum properties retained per vertex. Identity-bearing fields are never counted against this and never dropped.', ge=1)
class-attribute
instance-attribute
¶
max_tokens = PydanticField(default=4000, description='Maximum estimated tokens for the serialized slice. None disables the cap.', ge=1)
class-attribute
instance-attribute
¶
BudgetAccounting
¶
Bases: ConfigBaseModel
What the budget actually cost, measured rather than assumed.
Source code in graflo/architecture/schema/context/budget.py
Attributes¶
elements_used = PydanticField(..., description='Vertices + edges admitted into the slice.')
class-attribute
instance-attribute
¶
estimated_tokens = PydanticField(..., description='Token estimate for the assembled slice.')
class-attribute
instance-attribute
¶
exhausted_by = PydanticField(..., description='Which ceiling stopped admission, if any.')
class-attribute
instance-attribute
¶
requested = PydanticField(..., description='The budget as asked for.')
class-attribute
instance-attribute
¶
serialized_chars = PydanticField(..., description='Exact character count of the compact serialization. Lets a caller re-estimate with a real tokenizer without trusting CHARS_PER_TOKEN.')
class-attribute
instance-attribute
¶
ConnectorCard
¶
Bases: BaseCard
Summary of a data connector (File, Table, etc.).
Source code in graflo/architecture/schema/context/card.py
Attributes¶
name = PydanticField(default=None, description='Authored name.')
class-attribute
instance-attribute
¶
resource_name = PydanticField(default=None, description='Primary resource name bound to this connector.')
class-attribute
instance-attribute
¶
summary = PydanticField(default=None, description='Type-specific summary (e.g. path, table name).')
class-attribute
instance-attribute
¶
type = PydanticField(..., description='Connector class name (FileConnector, etc.).')
class-attribute
instance-attribute
¶
DatabaseProfileCard
¶
Bases: BaseCard
Summary of physical DB features.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
db_flavor = PydanticField(..., description='Target DB flavor.')
class-attribute
instance-attribute
¶
edge_spec_count = PydanticField(default=0, description='Total physical edge specifications.')
class-attribute
instance-attribute
¶
target_namespace = PydanticField(default=None, description='LPG namespace override.')
class-attribute
instance-attribute
¶
vertex_index_count = PydanticField(default=0, description='Total secondary vertex indexes.')
class-attribute
instance-attribute
¶
EdgeCard
¶
Bases: BaseCard
Summary of a single edge type.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
description = PydanticField(default=None, description='Authored description.')
class-attribute
instance-attribute
¶
directed = PydanticField(default=True, description='True if source->target order matters.')
class-attribute
instance-attribute
¶
identity_count = PydanticField(default=0, description='Number of logical uniqueness keys.')
class-attribute
instance-attribute
¶
inverse = PydanticField(default=None, description='Declared inverse relation: the name for reading this edge from its target. Usable in a query whether or not anything is stored under it.')
class-attribute
instance-attribute
¶
inverse_state = PydanticField(default=None, description='State of the declared pair: declared (nothing stored; the inverse reads this edge from its target), native (the database maintains it), materialized (a declared edge of its own), or partial / conflicting.')
class-attribute
instance-attribute
¶
property_count = PydanticField(default=0, description='Total declared properties.')
class-attribute
instance-attribute
¶
relation = PydanticField(default=None, description='Relation type name.')
class-attribute
instance-attribute
¶
source = PydanticField(..., description='Source vertex type name.')
class-attribute
instance-attribute
¶
symmetric = PydanticField(default=False, description='True if the relation is declared its own inverse.')
class-attribute
instance-attribute
¶
target = PydanticField(..., description='Target vertex type name.')
class-attribute
instance-attribute
¶
ElidedEdge
¶
Bases: ConfigBaseModel
An edge left out of the slice.
Source code in graflo/architecture/schema/context/elision.py
Attributes¶
description = PydanticField(default=None, description='Authored description, kept for the same reason.')
class-attribute
instance-attribute
¶
edge_id = PydanticField(..., description='(source, target, relation).')
class-attribute
instance-attribute
¶
reason = PydanticField(..., description='Why it was dropped.')
class-attribute
instance-attribute
¶
ElidedVertex
¶
Bases: ConfigBaseModel
A vertex type left out of the slice.
Source code in graflo/architecture/schema/context/elision.py
Attributes¶
degree = PydanticField(..., description='Incident edges in the full schema.')
class-attribute
instance-attribute
¶
description = PydanticField(default=None, description='Authored description, kept because it may be the reason to drill in.')
class-attribute
instance-attribute
¶
drill_in = PydanticField(..., description='Call that would bring this type into a slice.')
class-attribute
instance-attribute
¶
hop_distance = PydanticField(default=None, description='Hops from the nearest seed; None when unreachable.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Vertex type name.')
class-attribute
instance-attribute
¶
reason = PydanticField(..., description='Why it was dropped.')
class-attribute
instance-attribute
¶
ElisionReport
¶
Bases: ConfigBaseModel
Everything the slice does not contain, plus the budget that caused it.
Source code in graflo/architecture/schema/context/elision.py
Attributes¶
budget = PydanticField(..., description='Measured cost of the slice.')
class-attribute
instance-attribute
¶
elided_edges = PydanticField(default_factory=list, description='Edges not in the slice.')
class-attribute
instance-attribute
¶
elided_properties = PydanticField(default_factory=dict, description='Vertex type -> property names dropped from a surviving type.')
class-attribute
instance-attribute
¶
elided_vertices = PydanticField(default_factory=list, description='Vertex types not in the slice.')
class-attribute
instance-attribute
¶
truncated
property
¶
Whether anything at all was left out.
EntryPoint
¶
Bases: ConfigBaseModel
A vertex type an agent can look up directly.
The single most useful fact about an unfamiliar graph: a type with a natural identity and a secondary index is one you can filter on cheaply, which is where a query should start.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
description = PydanticField(default=None, description='Authored description, if any.')
class-attribute
instance-attribute
¶
identity = PydanticField(..., description='Primary identity field names.')
class-attribute
instance-attribute
¶
identity_mode = PydanticField(..., description='natural / hash / assigned / blank.')
class-attribute
instance-attribute
¶
indexed_fields = PydanticField(default_factory=list, description='Secondary index field-sets on this type.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Vertex type name.')
class-attribute
instance-attribute
¶
secondary_identities = PydanticField(default_factory=list, description='Declared secondary identity names.')
class-attribute
instance-attribute
¶
ManifestCard
¶
Bases: BaseCard
Summary of a whole GraphManifest.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
edge_count = PydanticField(default=None, description='Edge count if schema present.')
class-attribute
instance-attribute
¶
has_bindings = PydanticField(..., description='Presence of bindings block.')
class-attribute
instance-attribute
¶
has_ingestion = PydanticField(..., description='Presence of ingestion block.')
class-attribute
instance-attribute
¶
has_schema = PydanticField(..., description='Presence of schema block.')
class-attribute
instance-attribute
¶
name = PydanticField(default=None, description='Manifest name.')
class-attribute
instance-attribute
¶
resource_count = PydanticField(default=None, description='Resource count if ingestion present.')
class-attribute
instance-attribute
¶
version = PydanticField(default=None, description='Manifest version.')
class-attribute
instance-attribute
¶
vertex_count = PydanticField(default=None, description='Vertex count if schema present.')
class-attribute
instance-attribute
¶
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
¶
ResourceCard
¶
Bases: BaseCard
Summary of an ingestion resource.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
actor_count = PydanticField(default=0, description='Number of pipeline steps.')
class-attribute
instance-attribute
¶
edge_targets = PydanticField(default_factory=list, description='Top edge types this resource writes to.')
class-attribute
instance-attribute
¶
encoding = PydanticField(default='utf-8', description='Character encoding.')
class-attribute
instance-attribute
¶
infer_edges = PydanticField(default=True, description='True if greedy edge inference is enabled.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Resource name.')
class-attribute
instance-attribute
¶
vertex_targets = PydanticField(default_factory=list, description='Top vertex types this resource writes to.')
class-attribute
instance-attribute
¶
SchemaCard
¶
Bases: BaseCard
Bounded orientation summary of a whole schema.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
db_flavor = PydanticField(..., description='Target database flavor from the db profile.')
class-attribute
instance-attribute
¶
description = PydanticField(default=None, description='Authored schema description.')
class-attribute
instance-attribute
¶
edge_count = PydanticField(..., description='Declared edges.')
class-attribute
instance-attribute
¶
entry_points = PydanticField(default_factory=list, description='Types that can be looked up directly.')
class-attribute
instance-attribute
¶
hub_types = PydanticField(default_factory=list, description='Highest-ranked types, most central first.')
class-attribute
instance-attribute
¶
identity_modes = PydanticField(default_factory=dict, description='Histogram of vertex identity modes.')
class-attribute
instance-attribute
¶
isolated_type_count = PydanticField(default=0, description='Total isolated types, including any not listed.')
class-attribute
instance-attribute
¶
isolated_types = PydanticField(default_factory=list, description='Vertex types with no incident edge, truncated to ``max_names``.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Schema name.')
class-attribute
instance-attribute
¶
relation_count = PydanticField(default=0, description='Total distinct relations, including any not listed.')
class-attribute
instance-attribute
¶
relation_vocabulary = PydanticField(default_factory=list, description='Distinct edge relation names, truncated to ``max_names``.')
class-attribute
instance-attribute
¶
total_property_count = PydanticField(..., description='Declared properties across all vertex types.')
class-attribute
instance-attribute
¶
version = PydanticField(default=None, description='Schema version.')
class-attribute
instance-attribute
¶
vertex_count = PydanticField(..., description='Declared vertex types.')
class-attribute
instance-attribute
¶
SchemaGraph
¶
Read-only adjacency index over a :class:Schema's vertex types.
Built once per schema and never mutates it. Plain dicts throughout — no networkx, because this is layer 2 and the whole point is to stay free of heavyweight dependencies.
Source code in graflo/architecture/schema/context/graph.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
Attributes¶
edge_ids
property
¶
Every declared edge id, in deterministic order.
schema
property
¶
The indexed schema. Treat as read-only.
vertex_types
property
¶
Every declared vertex type name.
Methods:¶
__init__(schema)
¶
Source code in graflo/architecture/schema/context/graph.py
degree(vertex_type)
¶
Total incident edge count (out + in), counting self-loops twice.
edge(edge_id)
¶
from_schema(schema)
classmethod
¶
in_edges(vertex_type)
¶
isolated_types()
¶
out_edges(vertex_type)
¶
relation_vocabulary()
¶
Distinct relation names a query over this schema may use.
The names that label declared edges, plus the declared inverse of each: an inverse is a valid name for reading its edge from the target, whether it is stored, maintained by the database, or only declared.
Source code in graflo/architecture/schema/context/graph.py
relations_between(a, b, *, max_len=3, max_paths=20, direction=EdgeDirection.ANY)
¶
Simple paths from vertex type a to b, shortest first.
Bounded breadth-first enumeration: no vertex repeats within a path, so
cycles terminate. Results are ordered by (length, edge ids) and are
therefore reproducible run to run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
str
|
Source vertex type. |
required |
b
|
str
|
Target vertex type. |
required |
max_len
|
int
|
Maximum hops per path. |
3
|
max_paths
|
int
|
Maximum number of paths returned. |
20
|
direction
|
EdgeDirection
|
Orientation followed from each frontier vertex. |
ANY
|
Returns:
| Type | Description |
|---|---|
list[SchemaPath]
|
list[SchemaPath]: paths found, possibly empty. |
Raises:
| Type | Description |
|---|---|
KeyError
|
if either endpoint is not declared in the schema. |
Source code in graflo/architecture/schema/context/graph.py
schema_neighbors(vertex_type, *, hops=1, direction=EdgeDirection.ANY, edge_relations=None, edge_ids=None)
¶
Vertex types adjacent to vertex_type within hops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertex_type
|
str
|
Seed vertex type. Must be declared. |
required |
hops
|
int
|
Maximum hop distance. |
1
|
direction
|
EdgeDirection
|
Orientation followed from each frontier vertex. Defaults to
:attr: |
ANY
|
edge_relations
|
set[str | None] | None
|
Restrict traversal to these relation names ( |
None
|
edge_ids
|
set[EdgeId] | None
|
Restrict traversal to these exact edges. Finer-grained than edge_relations, which cannot separate two dyads sharing one relation name. Both filters apply when both are given. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SchemaNeighborhood |
SchemaNeighborhood
|
distances per reachable type and the edges used. |
Raises:
| Type | Description |
|---|---|
KeyError
|
if vertex_type is not declared in the schema. |
Source code in graflo/architecture/schema/context/graph.py
SchemaNeighborhood
¶
Bases: ConfigBaseModel
Vertex types reachable from a seed within a hop bound.
Source code in graflo/architecture/schema/context/graph.py
Attributes¶
direction = PydanticField(..., description='Orientation followed from each frontier vertex.')
class-attribute
instance-attribute
¶
distances = PydanticField(..., description='Reachable vertex type -> hop distance from origin (origin itself is 0).')
class-attribute
instance-attribute
¶
edges = PydanticField(..., description='Edges traversed to reach the neighbourhood, deduplicated.')
class-attribute
instance-attribute
¶
hops = PydanticField(..., description='Hop bound the walk honoured.')
class-attribute
instance-attribute
¶
origin = PydanticField(..., description='Vertex type the walk started from.')
class-attribute
instance-attribute
¶
vertex_types
property
¶
Reachable vertex types, nearest first then alphabetical.
SchemaPath
¶
Bases: ConfigBaseModel
One path between two vertex types, as an alternating vertex/edge walk.
Source code in graflo/architecture/schema/context/graph.py
Attributes¶
edges = PydanticField(..., description='Edges traversed, one fewer than ``vertices``.')
class-attribute
instance-attribute
¶
length
property
¶
Number of hops (edges) in this path.
vertices = PydanticField(..., description='Vertex types visited, from source to target inclusive.')
class-attribute
instance-attribute
¶
TransformCard
¶
Bases: BaseCard
Summary of a data transform.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
foo = PydanticField(default=None, description='Python function name.')
class-attribute
instance-attribute
¶
functional = PydanticField(..., description='True if it wraps a Python function.')
class-attribute
instance-attribute
¶
input_count = PydanticField(default=0, description='Number of input fields.')
class-attribute
instance-attribute
¶
module = PydanticField(default=None, description='Python module path.')
class-attribute
instance-attribute
¶
name = PydanticField(default=None, description='Transform name.')
class-attribute
instance-attribute
¶
output_count = PydanticField(default=0, description='Number of output fields.')
class-attribute
instance-attribute
¶
strategy = PydanticField(default='single', description='Functional call strategy (single, each, all).')
class-attribute
instance-attribute
¶
VertexCard
¶
Bases: BaseCard
Summary of a single vertex type.
Source code in graflo/architecture/schema/context/card.py
Attributes¶
description = PydanticField(default=None, description='Authored description.')
class-attribute
instance-attribute
¶
identity_fields = PydanticField(default_factory=list, description='Primary identity field names.')
class-attribute
instance-attribute
¶
identity_mode = PydanticField(..., description='natural / hash / blank / assigned.')
class-attribute
instance-attribute
¶
name = PydanticField(..., description='Vertex type name.')
class-attribute
instance-attribute
¶
property_count = PydanticField(..., description='Total declared properties.')
class-attribute
instance-attribute
¶
secondary_identity_count = PydanticField(default=0, description='Number of secondary identity field-sets.')
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:¶
build_card(schema, *, top_n=10, max_names=25, graph=None, id=None)
¶
Summarize schema for an agent's first contact with it.
Every list on the card is bounded, with a count reported alongside. A card whose size grows with the schema is not a card — it is the problem this wave exists to solve, wearing a summary's clothes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Schema
|
Schema to summarize. Never mutated. |
required |
top_n
|
int
|
How many hub types and entry points to list. |
10
|
max_names
|
int
|
How many isolated types and relation names to list. |
25
|
graph
|
SchemaGraph | None
|
Prebuilt index, if the caller already has one. |
None
|
Source code in graflo/architecture/schema/context/card.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
build_connector_card(connector, id=None)
¶
Build a summary card for a data connector.
Source code in graflo/architecture/schema/context/card.py
build_database_profile_card(profile, id=None)
¶
Build a summary card for a database profile.
Source code in graflo/architecture/schema/context/card.py
build_edge_card(edge, id=None, *, schema=None)
¶
Build a summary card for a logical edge type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge
|
Edge
|
The edge to summarize. |
required |
id
|
str | None
|
Identifier carried on the card. |
None
|
schema
|
Schema | None
|
The schema the edge belongs to. With it the card also states the relation's declared inverse and the state of that pair, which an edge alone cannot know; without it those fields stay empty. |
None
|
Source code in graflo/architecture/schema/context/card.py
build_manifest_card(manifest, id=None)
¶
Build a summary card for a full graph manifest.
Source code in graflo/architecture/schema/context/card.py
build_resource_card(resource, id=None, top_n=5)
¶
Build a summary card for an ingestion resource.
Source code in graflo/architecture/schema/context/card.py
build_transform_card(transform, id=None)
¶
Build a summary card for a data transform.
Source code in graflo/architecture/schema/context/card.py
build_vertex_card(vertex, id=None)
¶
Build a summary card for a logical vertex type.
Source code in graflo/architecture/schema/context/card.py
estimate_tokens(payload)
¶
Estimate token count for payload.
Runs over the compact serialization — estimating over a pretty-printed or defaults-included dump overcounts by a factor of two or more, which would make every budget silently pessimistic.
Source code in graflo/architecture/schema/context/budget.py
neighborhood_distances(graph, seeds, *, hops=1, direction=EdgeDirection.ANY, edge_relations=None, edge_ids=None)
¶
Hop distance to every type reachable from any seed, nearest seed winning.
The multi-seed union of :meth:SchemaGraph.schema_neighbors. Both consumers of
"what is near what I asked about" — rank-then-budget schema context and
project_manifest's depth — go through here, so the two cannot drift
apart on direction handling, undirected edges or the treatment of hops=0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
SchemaGraph
|
Adjacency index to walk. |
required |
seeds
|
Iterable[str]
|
Vertex types to start from. Each must be declared. |
required |
hops
|
int
|
Maximum hop distance. |
1
|
direction
|
EdgeDirection
|
Orientation followed from each frontier vertex. |
ANY
|
edge_relations
|
set[str | None] | None
|
Restrict traversal to these relation names. |
None
|
edge_ids
|
set[EdgeId] | None
|
Restrict traversal to these exact edges. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, int]
|
reachable vertex type -> distance from the nearest seed (seeds map |
dict[str, int]
|
to |
Raises:
| Type | Description |
|---|---|
KeyError
|
if a seed is not declared in the schema. |
Source code in graflo/architecture/schema/context/graph.py
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.