relations

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package relations is the standard EDB relation catalog, the built-in projectors that turn a check.Model (and a seeded datasheet library) into the query engine's netlist, board and datasheet facts. They register through the same public facts registration an extension uses (facts.RegisterBuiltinFacts, issue 10), as the built-in rules do from stdlib/rules/builtin. The core engine owns no relations, so a binary that omits the blank import runs the query engine with only extension relations.

Index

Constants

View Source
const (
	RelNetMaxVoltage  = "net.max_voltage" // net.max_voltage(net, volts): a net's declared rail voltage. doc: facts/docs/net.max_voltage.md
	RelComponentMPN   = "component.mpn"   // component.mpn(ref_des, mpn): the design-side part identity. doc: facts/docs/component.mpn.md
	RelParam          = "param.max"       // param.max(mpn, symbol, value, conditions): a datasheet parameter. doc: facts/docs/param.max.md
	RelPartAudience   = "part.audience"   // part.audience(mpn, who): a team/license entitled to see a part's datasheet data. doc: facts/docs/part.audience.md
	RelComponentOnNet = "component.net"   // component.net(ref_des, net): a component sits on a net. doc: facts/docs/component.net.md

	// net.nominal_voltage is the nominal a RAIL's name declares (3V3 -> 3.3). Distinct from
	// net.max_voltage, which prefers an explicit max_voltage attribute over the name (WS3-082).
	RelNetNominalVoltage = "net.nominal_voltage" // net.nominal_voltage(net, volts): name-derived rail nominal. doc: facts/docs/net.nominal_voltage.md

	// net.signal_level is the same name-derived number on a net that is NOT a rail, split from
	// net.nominal_voltage so a rule says which set it means (issue 194).
	RelNetSignalLevel = "net.signal_level" // net.signal_level(net, volts): name-derived level on a non-rail net. doc: facts/docs/net.signal_level.md

	// param.range adds the lower bound and the limit kind that param.max(mpn, symbol, max) lacks, so
	// absolute-max and recommended-operating rows on one symbol stay apart (WS3-082).
	RelParamRange = "param.range" // param.range(mpn, symbol, kind, min, max): a two-sided datasheet limit. doc: facts/docs/param.range.md

	// param.typ is its own relation rather than a column on param.range because A TYP IS NOT A
	// BOUND. Comparing a rail against one as though it were a limit gives a confident wrong answer
	// (agni issue 545).
	RelParamTyp = "param.typ" // param.typ(mpn, symbol, typ): a parameter's typical value. doc: facts/docs/param.typ.md

	// param.prov is where a datasheet value was read from, so a datalog rule can carry the citation
	// onto its findings (WS10-012). doc is the resolved SourceDoc title, not the doc_ref id; method
	// and confidence come from check.DatasheetProvFor. THE PAGE BINDS AS A STRING, since a unitless
	// number would unify with a voltage (agni issue 545).
	RelParamProv = "param.prov" // param.prov(mpn, symbol, doc, page, section): a datasheet value's Citation. doc: facts/docs/param.prov.md

	// param.unit is the unit a parameter is PRINTED in, kept queryable because param and param.range
	// publish SI base units (agni issue 165). String-valued, so no ordering comparison binds it.
	RelParamUnit = "param.unit" // param.unit(mpn, symbol, unit): the unit a parameter is printed in. doc: facts/docs/param.unit.md

	// The PIN tier of the datasheet relations (agni issue 189) states limits per TERMINAL rather
	// than per (mpn, symbol). Keyed by the spec-local Pin.id, since a printed name is not unique. Mapping a
	// DESIGN pin onto an id is param.ResolvePin, not a datalog join, because resolution can refuse.
	RelParamPin      = "param.pin"       // param.pin(mpn, pin, name, function): a declared pin of a part. doc: facts/docs/param.pin.md
	RelParamPinRange = "param.pin_range" // param.pin_range(mpn, pin, symbol, kind, min, max): a limit bound to one pin. doc: facts/docs/param.pin_range.md

	// param.pin_relation bounds the DIFFERENCE between two pins of one part. Subject and reference
	// are ordered, since the bound is on subject minus reference.
	RelParamPinRelation = "param.pin_relation" // param.pin_relation(mpn, subject_pin, reference_pin, modality, min, max): a pin-to-pin bound. doc: facts/docs/param.pin_relation.md

	// Board-tier relations (WS1-006) are derived per-net lengths in metres, shown in mm, not raw geometry.
	RelBoardTrackWidth = "board.track_width" // board.track_width(net, mm): the net's MINIMUM copper width. doc: facts/docs/board.track_width.md
	RelBoardViaDrill   = "board.via_drill"   // board.via_drill(net, mm): the net's MINIMUM via drill. doc: facts/docs/board.via_drill.md
	RelBoardLayer      = "board.layer"       // board.layer(net, layer): a layer the net's copper occupies. doc: facts/docs/board.layer.md

	// Pin-level and per-net netlist relations (WS3-038), each a projection of an existing Model
	// method. pin.net is absent for an unconnected pin, so `not pin.net(?r,?p,?_)` reads as
	// "unconnected".
	RelPin               = "component.pin"          // component.pin(ref_des, pin): a part-type pin of a placed component. doc: facts/docs/component.pin.md
	RelPinRole           = "pin.role"               // pin.role(ref_des, pin, role): derived power/ground/anode/cathode. doc: facts/docs/pin.role.md
	RelPinType           = "pin.type"               // pin.type(ref_des, pin, etype): electrical type (power_in, input, ...). doc: facts/docs/pin.type.md
	RelPinNet            = "pin.net"                // pin.net(ref_des, pin, net): the net a pin is on (absent if none). doc: facts/docs/pin.net.md
	RelPinName           = "pin.name"               // pin.name(ref_des, pin, name): the part type's functional name for the pin (absent if unnamed). doc: facts/docs/pin.name.md
	RelNetPinCount       = "net.pin_count"          // net.pin_count(net, count): connections on a net. doc: facts/docs/net.pin_count.md
	RelComponentNetCount = "component.net_count"    // component.net_count(ref_des, count): distinct nets a component touches. doc: facts/docs/component.net_count.md
	RelHasNCChannel      = "design.has_nc_channel"  // design.has_nc_channel(present): one row when the design can express no-connect. doc: facts/docs/design.has_nc_channel.md
	RelTypesPowerOut     = "design.types_power_out" // design.types_power_out(present): one row when the source format types power-output pins (WS3-072). doc: facts/docs/design.types_power_out.md
	RelRail              = "net.rail"               // net.rail(net): the net is a power/ground rail (Model.IsPowerRail). doc: facts/docs/net.rail.md
	RelFeedback          = "net.feedback"           // net.feedback(net): the net is a regulator feedback/sense node (naming lexicon). doc: facts/docs/net.feedback.md
	RelSwitching         = "net.switching"          // net.switching(net): the net is a regulator power-stage node (naming lexicon). doc: facts/docs/net.switching.md
	RelNetRole           = "net.role"               // net.role(net, role): a role the net carries, one row per role. doc: facts/docs/net.role.md
	RelNetAttr           = "net.attr"               // net.attr(net, key, value): a net-level attribute. doc: facts/docs/net.attr.md
	RelComponentAttr     = "component.attr"         // component.attr(ref_des, key, value): a component-level attribute. doc: facts/docs/component.attr.md

	// Device-class and net-attribute relations (WS3-074). component.class has one row per tag in the
	// device_classes SET (WS3-071), so a family tag answers too. net.ground isolates the ground half
	// of net.rail, which covers both.
	RelComponentClass = "component.class" // component.class(ref_des, class): a device class the part is in. doc: facts/docs/component.class.md
	RelNetGround      = "net.ground"      // net.ground(net): the net is a ground rail (name-derived). doc: facts/docs/net.ground.md
	RelNetExternal    = "net.external"    // net.external(net): the net may extend onto an unread sheet. doc: facts/docs/net.external.md

	// component.esd_rated is the credit the esd-protection Go rule gives, from the same
	// EsdRatingLimits extractor, keyed by ref_des (WS3-076). Empty without --params.
	RelEsdRated = "component.esd_rated" // component.esd_rated(ref_des): part carries a floor-clearing ESD rating. doc: facts/docs/component.esd_rated.md

	// component.device_class is the class the part's DATASHEET declares (PartSpec.device_class),
	// joined by MPN (WS10-013). Empty without --params. WithParamProvider also merges it into
	// component.class's set, so HasClass answers from it too.
	RelComponentDNP         = "component.dnp"          // component.dnp(ref_des): the part is marked do-not-populate. doc: facts/docs/component.dnp.md
	RelComponentDeviceClass = "component.device_class" // component.device_class(ref_des, class): the datasheet-declared device class. doc: facts/docs/component.device_class.md

	// bus(label, kind) is a reader-detected bus construct not yet expanded (WS1-034 Phase 1). label
	// is empty for an anonymous wire.
	RelBus = "bus" // doc: facts/docs/bus.md

	// entity(name, kind) is the ENUMERATION relation, the one a search starts from, since every other
	// relation misses whatever it does not reach (a part with no connections). kind uses the
	// check.Kind* vocabulary a finding subject carries. Pins are absent because their identity is two
	// fields; component.pin(ref_des, pin) enumerates them.
	RelEntity = "entity" // entity(name, kind): a component, net or bus exists under this name. doc: facts/docs/entity.md
	// RelUnresolvedSymbol is keyed by ref_des, NOT by the symbol reference, so a query can ask what
	// KIND of parts a missing library cost (WS1-052).
	RelUnresolvedSymbol = "reader.unresolved_symbol" // doc: facts/docs/reader.unresolved_symbol.md

	// Reader-diagnostic relations (WS3-081). A diagnostic earns a query relation only when it carries
	// an entity key to join on; point-geometry ones (dangling endpoints) stay rule-scoped.
	RelRefDesCollision = "reader.ref_des_collision" // reader.ref_des_collision(ref_des): a designator shared by >1 part. doc: facts/docs/reader.ref_des_collision.md
	RelPinNetConflict  = "reader.pin_net_conflict"  // reader.pin_net_conflict(ref_des, pin, net): the read put a pin on >1 net. doc: facts/docs/reader.pin_net_conflict.md

	// net.bus_like is a shared-distribution net, the predicate the series-reach walk stops at
	// (WS3-080). Not bus(label, kind), which is an unmodeled bus LABEL.
	RelNetBusLike = "net.bus_like" // doc: facts/docs/net.bus_like.md

	// net.connector_signal is the SCOPE the ESD rules share (WS3-061). It reads net attributes and
	// the no-connect channel that no relation exposes, so datalog cannot rebuild it, and a dropped
	// guard is a false FAIL on a rail or an unconnected pad.
	RelExternalSignalNet = "net.connector_signal" // net.connector_signal(net): connector-facing signal net, the ESD scope. doc: facts/docs/net.connector_signal.md

	// Derived net properties (WS3-088) say what the DESIGN does, for comparing against an intent
	// declaration.
	RelNetBias      = "net.bias"       // net.bias(net, level): a bias resistor holds the net high or low. doc: facts/docs/net.bias.md
	RelNetACCoupled = "net.ac_coupled" // net.ac_coupled(net): a SERIES capacitor carries the net. doc: facts/docs/net.ac_coupled.md

	// Net-class relations (WS3-105) carry the TOOL-assigned class string. NOT named net.class, which
	// would read as the derived role space and invite a join that matches nothing.
	// design.has_netclass separates "no net in this class" from "this design has no classes" (only
	// KiCad supplies them).
	RelNetNetClass = "net.netclass"        // net.netclass(net, class): the tool-assigned net class. doc: facts/docs/net.netclass.md
	RelHasNetClass = "design.has_netclass" // design.has_netclass(present): one row when the design assigns net classes at all. doc: facts/docs/design.has_netclass.md

	// Net-class DEFINITIONS (WS3-111), keyed by CLASS, in metres like the board tier. These are
	// the raw per-class rows; the cascaded per-NET values are below.
	RelNetClassClearance   = "netclass.clearance"       // netclass.clearance(class, mm). doc: facts/docs/netclass.clearance.md
	RelNetClassTrackWidth  = "netclass.track_width"     // netclass.track_width(class, mm). doc: facts/docs/netclass.track_width.md
	RelNetClassViaDiameter = "netclass.via_diameter"    // netclass.via_diameter(class, mm). doc: facts/docs/netclass.via_diameter.md
	RelNetClassViaDrill    = "netclass.via_drill"       // netclass.via_drill(class, mm). doc: facts/docs/netclass.via_drill.md
	RelHasNetClassDefs     = "design.has_netclass_defs" // design.has_netclass_defs(present). doc: facts/docs/design.has_netclass_defs.md

	// The CASCADED per-net values. A declared-vs-actual rule joins THESE, never the per-class rows,
	// because a net in two classes matches two of those. Only the two quantities with a board-tier
	// counterpart are derived.
	RelNetDeclaredTrackWidth = "net.declared_track_width" // net.declared_track_width(net, mm). doc: facts/docs/net.declared_track_width.md
	RelNetDeclaredViaDrill   = "net.declared_via_drill"   // net.declared_via_drill(net, mm). doc: facts/docs/net.declared_via_drill.md
)

The design fact base (WS3-004) is a set of named, typed, provenanced relations over the IR and its datasheet joins. Rules and ad-hoc queries read the same vocabulary. Facts derives the tuples and nothing here evaluates a query (that is core/query).

The relations are a DERIVED PROJECTION of the Model, regenerated on demand and never a second authoritative schema (C8). Every fact carries provenance (an IR site or a datasheet page) so an answer built from it stays checkable. Names are neutral IR/param concepts, not format specifics (C9). Each relation's full contract is its page under facts/docs/.

View Source
const RelReaches = "net.reaches"

RelReaches is the transitive relation net.reaches(from, to) and net.reaches(from, to, hops), the nets reachable from `from` through series pass elements, bridged to check.Model.Reach. It is a GENERATOR that binds `to` by enumerating from the Model. Every value it emits is a net the design has or a distance the walk measured, which is the obligation any generator takes on, since one inventing values would break the guarantee that evaluation terminates.

View Source
const RelRoute = "net.route"

RelRoute is net.route(from, to, path), the SAME walk reaches makes with the route it found bound as a value instead of discarded. `path` renders as

VBUS -> [R5] -> VBUS_F -> [L1] -> VDD_3V3

which is a string, so every query column stays scalar. It is a separate predicate rather than a fourth argument on reaches because arity 3 there already means hops.

It yields exactly the pairs reaches yields, so a route never ENDS on a rail (the walk excludes bus-like nets); `agni trace` is the pin-to-pin form that does. ONE route per pair, the BFS tree path, so of two resistors bridging the same nets it names one. See docsite/content/reference/relations/net.route.md.

Variables

This section is empty.

Functions

func Facts

func Facts(m check.Model) []facts.Row

Facts projects the Model into the fact base, sorted so two calls on one Model are equal. A relation is empty when the Model lacks its tier (no --params means no param rows); Facts never fabricates.

func RelationDoc

func RelationDoc(name string) string

RelationDoc returns the embedded reference markdown for a query relation, or "" if it has none. Unlike ruleDoc, a missing doc does not panic. Every built-in EDB relation has one (facts_docs_test.go requires it), but a computed predicate may not, so callers treat "" as "fall back to the catalog Summary".

func RelationDocImageHandler

func RelationDocImageHandler() http.Handler

RelationDocImageHandler serves the relation docs' embedded images (.svg and .png under facts/docs/images/) so the Query panel can resolve a Detail's relative image refs, the same way RuleDocImageHandler does for rules. Any other path, including the markdown, a directory or a traversal attempt, is 404. Mount it under a prefix; the handler sees the prefix-stripped path (e.g. "images/net.bus_like.svg"). The SVG content-type is set explicitly because Go's mime table resolves .svg only from the host's mime files, which CI and WASM may lack.

func SpecLibFacts

func SpecLibFacts(specs []*parampb.PartSpec) []facts.Row

SpecLibFacts projects the per-spec datasheet relations of a whole seeded corpus with NO design join (WS10-010), which is what `agni query --speclib` searches. The three pin relations are not included. Rows are sorted as Facts sorts them.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL