Documentation
¶
Overview ¶
Package relation implements the interaction relation — the primary artifact of extraction (schema/SPEC.md). A flat typed relation of rows plus a companion node table; the algorithm graph and the site feed are pure deterministic projections; canonical form (sorted rows, SHA-256) is defined once, here.
The builder is the schema-discipline chokepoint: unknown kinds, undeclared or missing attributes, illegal enum values, ID collisions, case-only ID clashes, and rows referencing absent nodes are all hard errors. Nothing is coerced, defaulted, or skipped.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalFormOf ¶
CanonicalFormOf renders an arbitrary node/row set canonically, sorting both (the inputs are not modified). The fix verifier uses this to compare span-masked variants, where masking changes the sort order.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates nodes and rows, validating each addition against the vocabulary. Insertion order is irrelevant: Build sorts everything into canonical order, and rows may be added before the nodes they reference (referential integrity is checked at Build).
func (*Builder) AddNode ¶
AddNode validates and inserts a node. Hard errors: unknown kind, invalid ID, attribute violations, ID collision, case-only ID clash.
type NodeID ¶
type NodeID struct {
// Lang is the profile prefix: "py" | "go" | "ts".
Lang string
// Member is the workspace member name, or "_" for a single-project
// (non-workspace) scan.
Member string
// Module is the module's logical name (SPEC.md section 2.2).
Module string
// Chain is the container chain from module scope inward; empty for
// module-kind nodes.
Chain []Segment
}
NodeID is the hierarchical qualified name of a node (schema/SPEC.md section 2). Location is never part of identity. The serialized form is
<lang>:<member>:<module>:<container-chain>
Serialized IDs are opaque strings for consumers; the structured form is authoritative.
type Relation ¶
Relation is the frozen, canonically ordered relation: the node table sorted by (node_kind, id) and the rows sorted by the total key (row_kind, src_id, dst_id, file, span_start, span_end, attr-tuple).
func (*Relation) AlgorithmGraph ¶
AlgorithmGraph projects the distinct (src, dst) pairs of one row kind, in canonical (sorted) order. Algorithms (Tarjan SCC, reachability) consume this; they never see spans or attributes.
func (*Relation) CanonicalForm ¶
CanonicalForm renders the relation deterministically: the version line, the sorted node table, then the sorted rows, one record per line, every free-form field percent-escaped. Equal relations produce equal bytes.
type Row ¶
type Row struct {
Kind vocab.RowKind
Src NodeID
Dst NodeID
File string
Span Span
Attrs map[string]Value
}
Row is one interaction-relation row: (row_kind, src_node, dst_node, file, span, attrs).
type Segment ¶
type Segment struct {
// Name is the unit's name; for anonymous units it is the name hint, or
// "anon" when no hint is syntactically derivable.
Name string
// Overload is the 0-based source-order index among same-name siblings in
// the same container (SPEC.md section 2.4). Serialized as #<n>, omitted
// for 0.
Overload int
// Anonymous marks a synthesized segment (SPEC.md section 2.3):
// <name-hint|anon>~<ordinal>~<fp8>.
Anonymous bool
// Ordinal is the 0-based source-order index among same-hint anonymous
// siblings in the same parent. Anonymous only.
Ordinal int
// Fingerprint is the first 8 hex chars of SHA-256 over the unit's
// normalized signature text. Anonymous only. It exists so ordinal drift
// is detectable, never silently misattributed.
Fingerprint string
}
Segment is one element of the container chain.
type Span ¶
Span is a byte range over the file's LF-normalized UTF-8 bytes (schema/SPEC.md section 3). Line/column are derived at output time, never stored as truth.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is one typed attribute value. Enum-typed attributes carry their value as a string; legality against the vocabulary enum is checked by the relation builder.
func StringValue ¶
StringValue constructs a string (or enum) value.