Skip to main content

Module program_graph

Module program_graph 

Source
Expand description

Canonical 5-buffer ProgramGraph ABI (CSR wire format, shared by every graph primitive). Canonical ProgramGraph ABI - the 5-buffer CSR bundle every graph primitive in Tier 2.5 consumes.

Downstream analyzers emit a ProgramGraph from their native ASTs. Every vyre graph primitive takes exactly this buffer shape so a new primitive is “here’s the transfer body,” not “redeclare the four buffers you want.” One ABI makes the primitives composable - csr_forward_traverse into bitset_fixpoint into reduce_count with no glue.

§Wire shape

+----------------------------------------------------------+
| nodes:            u32 buffer    (count = node_count)     |
|                   each word = NodeKind tag               |
| edge_offsets:     u32 buffer    (count = node_count+1)   |
|                   edge_offsets[i]..edge_offsets[i+1]     |
|                   is the range into edge_targets for     |
|                   outgoing edges of node `i`             |
| edge_targets:     u32 buffer    (count = edge_count)     |
|                   each word = destination node index     |
| edge_kind_mask:   u32 buffer    (count = edge_count)     |
|                   each word = bitmask over EdgeKind      |
| node_tags:        u32 buffer    (count = node_count)     |
|                   each word = bitmask over TagFamily     |
+----------------------------------------------------------+

Edge-kind masks let a single csr_forward_traverse restrict to (say) just Assignment + CallArg edges by AND-ing against the per-edge mask. Node tags let label_family_to_nodeset emit a frontier bitset without touching the edges.

§Invariants

  • edge_offsets.len() == node_count + 1
  • edge_targets.len() == edge_count == edge_offsets[node_count]
  • edge_kind_mask.len() == edge_count
  • node_tags.len() == node_count
  • nodes.len() == node_count
  • Every edge_targets[i] must satisfy < node_count or the primitive raises Node::Trap.

These invariants are checked by validate_program_graph at registration / dispatch time and by the frozen wire format in vyre-spec.

Structs§

ProgramGraphShape
Statically-sized CSR dimensions baked into a primitive’s BufferDecl counts so the backend can allocate + layout-validate up front.

Enums§

GraphValidationError
Error kinds surfaced by validate_program_graph.

Constants§

BINDING_EDGE_KIND_MASK
Binding index for the per-edge kind mask.
BINDING_EDGE_OFFSETS
Binding index for the CSR row-pointer array.
BINDING_EDGE_TARGETS
Binding index for the CSR column array.
BINDING_NODES
Binding index for the node-kind array.
BINDING_NODE_TAGS
Binding index for the per-node tag mask.
BINDING_PRIMITIVE_START
First binding index a primitive is free to use for primitive- specific buffers (frontier bitsets, output arrays, scratch).
NAME_EDGE_KIND_MASK
Canonical name for edge_kind_mask.
NAME_EDGE_OFFSETS
Canonical name for edge_offsets.
NAME_EDGE_TARGETS
Canonical name for edge_targets.
NAME_NODES
Canonical buffer name constants - primitives refer to these so every graph-consuming Program shares a single ABI symbol set. Downstream analysis paths emit CSR blobs under the same names.
NAME_NODE_TAGS
Canonical name for node_tags.

Functions§

validate_program_graph
Validate an in-memory ProgramGraph against the wire invariants.