census

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 8 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.

README

census, the element-coverage guard (WS6-011)

Readers deliberately drop constructs they do not yet consume. Silkscreen text, silk graphics, buses and net= taps were all dropped silently until someone compared our render to KiCad by eye. This package makes those drops visible and reviewed. For each format it holds a manifest classifying every source construct as consumed or as a known drop, with a reason and, where tracked, a roadmap ticket.

Two tiers

  • The CI gate is census_test.go, which walks the committed */testdata fixtures and fails if a construct is not classified. A new fixture that introduces an unclassified element forces a human to decide (consume it or mark it a known drop) instead of dropping it silently. It runs in make test and make testall.
  • The corpus report is agni census <dir>, which runs the same audit over a local corpus that CI cannot see, and a workspace Makefile can wrap it to sweep your own corpus directories. A clean run means every real-world construct is classified. It reports and never fails the gate.

Both tiers read the same manifest, and it is the one reviewed record of what each reader drops.

Workflow

  • When a reader starts consuming a construct, flip its entry to Consumed in manifests.go, and the diff shows the coverage change.
  • When agni census reports an unclassified construct, classify it in the format's manifest as co (consumed), dc, da or dl (dropped as cosmetic, analysis-gap or correctness-latent, each with a ticket), or dd (dropped by design, for editor and tool metadata).
  • A new corpus file surfaces its new constructs on the next agni census run over it.

What it does NOT do

It asserts classification coverage, not behavioral consumption. It catches "a construct we never decided about appeared", not "the reader extracts it correctly". Behavioral correctness belongs to the conformance harness (check, WS6-004), and the two complement each other.

Documentation

Overview

Package census is the element-coverage guard (WS6-011). For each source format it holds a reviewed MANIFEST classifying every construct the format's files carry as consumed by the reader or a known drop. A test walks the committed fixtures and fails on a construct the manifest does not classify, and `agni census` runs the same audit over a local corpus, report-only.

The census asserts CLASSIFICATION coverage, not behavioral consumption; behavioral correctness is the conformance harness's job (WS6-004). The two tiers and the workflow are in census/README.md.

Index

Constants

View Source
const NumberToken = "<number>"

NumberToken is the sentinel for a numeric s-expr head (KiCad layer-table rows keyed by number, version triples). Collapsing them to one token keeps a manifest from listing every integer.

Variables

This section is empty.

Functions

func Enumerate

func Enumerate(data []byte, kind Kind) []string

Enumerate returns the distinct source constructs present in data, per the extractor Kind. Tokens are the manifest keys: s-expr heads, XML element names, line-type chars, or "@key".

Types

type Entry

type Entry struct {
	Status Status
	Why    string
	Ticket string
}

Entry is one construct's classification. Why is a one-line rationale; Ticket is the roadmap id that tracks closing the gap ("" when none applies, e.g. a Consumed or DroppedByDesign entry).

type Kind

type Kind int

Kind selects the extractor for a format family. The two s-expr kinds differ only in the shared parser's string dialect (KiCad escapes vs EDIF CR/LF drop), which the census needs correct so a quoted string terminates where the reader would find it.

const (
	// KindKiCad enumerates s-expression head atoms with the KiCad string dialect (.kicad_pcb/.kicad_sch).
	KindKiCad Kind = iota
	// KindEDIF enumerates s-expression head atoms with the EDIF string dialect (.edn/.eds).
	KindEDIF
	// KindXML enumerates XML element local names (IPC-2581).
	KindXML
	// KindLine enumerates line-oriented object type chars + "@key" attribute keys (xschem, gEDA).
	KindLine
)

type Manifest

type Manifest struct {
	Format  string // display name, e.g. "kicad-pcb"
	Kind    Kind   // which extractor enumerates this format's files
	Entries map[string]Entry
}

Manifest classifies a format's constructs. Keys are the tokens Enumerate emits (s-expr head atoms, XML element names, line-type chars, or "@key" for a line-format attribute key), and the numeric-head sentinel is NumberToken.

func Lookup

func Lookup(path string, data []byte) (Manifest, bool)

Lookup resolves a design file to the manifest that classifies its constructs, by extension (and, for the ambiguous `.sch`/`.sym`, a light header sniff of data to tell xschem from gEDA from legacy KiCad). ok is false for a file no manifest covers. `agni census` uses it to walk a mixed corpus directory.

func Manifests

func Manifests() []Manifest

Manifests returns every format census, keyed by format name. The CI test and `agni census` both drive it.

func (Manifest) Audit

func (m Manifest) Audit(filesByPath map[string][]byte) []Unclassified

Audit enumerates the constructs in each file (via the manifest's extractor Kind) and returns the tokens absent from the manifest, sorted by token then file. An empty result means full classification coverage. filesByPath maps a display path to its raw bytes.

type Status

type Status string

Status is how a manifest classifies one source construct.

const (
	// Consumed means the reader transforms this construct into the IR.
	Consumed Status = "consumed"
	// DroppedCosmetic is not read, and the only loss is render fidelity.
	DroppedCosmetic Status = "dropped-cosmetic"
	// DroppedAnalysis is not read, and its absence blocks a check or diff (a rule can't be written).
	DroppedAnalysis Status = "dropped-analysis"
	// DroppedLatent is not read, and its absence produces WRONG data when the construct is present
	// (a correctness hole), even if no current corpus/fixture exercises it.
	DroppedLatent Status = "dropped-latent"
	// DroppedByDesign is not read and never will be (editor/tool metadata, 3D models).
	DroppedByDesign Status = "dropped-by-design"
)

type Unclassified

type Unclassified struct {
	Token string
	File  string
}

Unclassified is one construct found in a file that the manifest does not list.

Jump to

Keyboard shortcuts

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