relations

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 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. Its built-in projectors turn a check.Model, and a seeded datasheet library, into the query engine's netlist, board and datasheet facts. They register through the public facts registration (facts.RegisterBuiltinFacts, issue 10). An extension registers the same way, and so do the built-in rules 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 a lower bound and a limit kind to what param.max(mpn, symbol, max) has, so
	// absolute-max and recommended-operating rows on one symbol remain separate rows (WS3-082).
	RelParamRange = "param.range" // param.range(mpn, symbol, kind, min, max): a two-sided datasheet limit. doc: facts/docs/param.range.md

	// A TYP IS NOT A BOUND, so param.typ is its own relation rather than a column on param.range.
	// Comparing a rail against a typ 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 names the source of a datasheet value, so a datalog rule can copy 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 names the unit the datasheet PRINTS a parameter in. param and param.range publish
	// SI base units (agni issue 165), so this relation keeps the printed unit queryable. It is
	// 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). It is keyed by the spec-local Pin.id, since a printed name is not
	// unique. param.ResolvePin maps a DESIGN pin onto an id. A datalog join cannot, 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) publish derived per-net lengths in metres, shown in mm. They
	// publish no 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
	RelBoardCopper     = "board.copper"      // board.copper(net, layer, kind): the net has copper of a kind (track, via, pour) on a layer. doc: facts/docs/board.copper.md
	RelBoardZone       = "board.zone"        // board.zone(net, layer): a zone the designer drew for the net on a layer. doc: facts/docs/board.zone.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 holds the esd-protection Go rule's credit. Both read the same
	// EsdRatingLimits extractor. It is keyed by ref_des (WS3-076) and 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 holds the class from the part's DATASHEET (PartSpec.device_class),
	// joined by MPN (WS10-013). It is 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, and a search starts from it. Every other
	// relation misses whatever it does not reach, such as a part with no connections. kind uses the
	// check.Kind* vocabulary of a finding subject. 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. A query can then ask
	// which KIND of parts lost their pins to a missing library (WS1-052).
	RelUnresolvedSymbol = "reader.unresolved_symbol" // doc: facts/docs/reader.unresolved_symbol.md

	// Reader-diagnostic relations (WS3-081). A diagnostic gets a query relation only when it has an
	// entity key to join on. A point-geometry diagnostic, such as a dangling endpoint, is visible to
	// rules alone.
	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 series-reach walk stops at one (WS3-080). It
	// differs from 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 of the ESD rules (WS3-061). It reads net attributes and the
	// no-connect channel, and no relation exposes those, so datalog cannot rebuild it. Dropping one
	// of its guards gives 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) hold the TOOL-assigned class string. They are NOT named
	// net.class, because that name reads as the derived role space and invites a join that matches
	// nothing. design.has_netclass separates "no net in this class" from "this design has no
	// classes". Only KiCad supplies classes.
	RelNetNetClass = "net.netclass"        // net.netclass(net, class): the tool-assigned net class. doc: facts/docs/net.netclass.md
	RelNetGroup    = "net.group"           // net.group(group, kind, net): a pair or match group the design declares. doc: facts/docs/net.group.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 per-class rows. Only two quantities have a board-tier
	// counterpart, and only those two 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. core/query evaluates queries, and nothing here does.

The relations are a DERIVED PROJECTION of the Model, regenerated on demand and never a second authoritative schema (C8). Every fact cites an IR site or a datasheet page, so a reader can check an answer built from it. 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). It holds the nets reachable from `from` through series pass elements, bridged to check.Model.Reach. It is a GENERATOR, and it binds `to` by enumerating from the Model. Every value it emits is a net in the design or a distance the walk measured. Any generator owes that. A generator that invented values would break the guarantee that evaluation terminates.

View Source
const RelRoute = "net.route"

RelRoute is net.route(from, to, path). It makes the SAME walk as reaches, and it binds the route it found as a value instead of discarding it. `path` renders as

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

That value is a string, so every query column is still scalar. Arity 3 on reaches already means hops, so route is a separate predicate rather than a fourth argument on reaches.

It yields exactly the same pairs as reaches. The walk excludes bus-like nets, so a route never ENDS on a rail; `agni trace` is the pin-to-pin form that does. It gives 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). `agni query --speclib` searches these rows. 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