Per-unit, tamper-evident records of where a unit's firmware was integrated and where it was tested, written by the factory station as a side effect of its normal work.
A programming or test station appends one record per unit per step to its own append-only, hash-chained ledger. A coverage report then checks every serial number in a shipment against a cited catalog of the steps a rule requires to happen in the United States, and exits non-zero if any unit falls short, so it can gate shipments.
No runtime dependencies. Works with OpenHTF as an output callback, and with anything else (Ansible, shell, another test executive) through a one-line CLI call. Apache-2.0.
Status: v0.1, early. The record format is versioned, but field names may change before v1.0. The most useful contribution right now is feedback from people who run programming or test stations on US production lines; please open an issue.
The BEAD program's Build America, Buy America waiver waives the domestic-content requirement for most broadband electronics, but not for four categories: OLTs and remote OLTs, OLT line cards, optic pluggables, and standalone ONTs/ONUs (W; S1, footnote 16). For those four, the waiver lists manufacturing processes that must be performed in the United States. For every one of the four, that list includes software integration (firmware integration, installation of licensed software, and customer-specific configuration) and testing and quality assurance (S2, pp. 4-5).
Those two processes are what a programming station and a test station do. They are also the two processes a factory's own software can witness, unit by unit, as they happen.
The paperwork, meanwhile, works at the product level. A manufacturer's certification letter names a product, a quantity, and a location of manufacturing, and is signed at risk of penalty (S1, pp. 11-12). Recipients must be able to produce BABA compliance documentation whenever the Department asks, including during desk reviews, site visits, and closeout, and corrective action can include removing and replacing improperly purchased goods (S1, p. 10).
When a product is built on more than one line, for example a new US line alongside an existing line in another country, a letter naming a location of manufacturing does not by itself say where a given serial number's firmware was integrated or where it was tested. This project records exactly that, per serial number, on the station that did the work, at the time it did it.
Full citations, and which requirement each part of the code rests on, are in docs/sources.md. Nothing about federal requirements is asserted here on this project's own authority.
- Records. Each step on each unit becomes one record: serial and part number, the step, pass or fail, start and end time in UTC, the station and its declared site and country, digests of the station's profile and of the software it runs, the calibration state of its instruments, and digests of artifacts such as the firmware image.
- Chains. Records are appended to one JSON Lines file per station. Each carries the SHA-256 of its own canonical JSON and the previous record's digest, so editing, deleting, inserting, or reordering an earlier record is detectable.
- Checks.
coveragereads the ledgers, refuses evidence from any file that fails verification, and reports for each unit whether each required step's most recent passing record ran at a US site. Exit code 1 means some unit did not.
Read this before relying on the output for anything.
- It does not determine compliance with BABA or any other rule, and nothing here is legal advice. It reports what stations recorded.
- Site and country are self-declared by each station's profile. The ledger makes later edits detectable; it cannot make the first statement true. Keep profiles under the same change control as the rest of the station configuration.
- A hash chain is not a signature. Someone with write access can rewrite a whole
ledger and recompute every digest. To make that detectable, copy the head digest
(
factory-step-ledger head) somewhere the station cannot rewrite, such as the shipment record or the MES, at each shipment. Signed records are on the roadmap. no_evidenceis not a finding. Steps such as PCB assembly are usually recorded in other systems; if they are not in these ledgers, the report says so and nothing more. The gate only judges the steps it is told to require, by default the two a station can record.- It does not address the component-cost test. A station ledger cannot evidence where components came from or what they cost.
- Concurrent writers are serialized with POSIX
flock. On Windows, run one writer per ledger. - The per-category process lists were taken from the Illinois Office of Broadband's reproduction of the waiver (S2), because this project could not extract text from the waiver PDF itself. Confirm against the waiver (W) before relying on them.
Requires Python 3.11 or newer.
git clone https://github.com/yichenglieng-code/factory-step-ledger.git
cd factory-step-ledger
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
python examples/demo.pyThe demo builds five OLT line cards on two fictional lines and prints the coverage report, with a per-unit table showing where each required step last passed. Its summary and problem list:
**3 of 5 unit(s) pass the gate.** 0 ledger file(s) failed integrity checks.
## Problems
- **LC16-0003**: testing_and_quality_assurance: outside_us
- **LC16-0005**: no records in any trusted ledger
LC16-0002 passes: it failed its first test and passed a retest in the US, and the
latest passing record decides. Run python examples/demo.py --tamper to rewrite that first failure as a pass
in the ledger file and watch verification reject the file.
from factory_step_ledger.openhtf_output import LedgerOutput
test = htf.Test(*phases, test_name="olt_line_card_final", part_number="EX-LC-16")
test.add_output_callbacks(
LedgerOutput("/etc/factory-step-ledger/station.toml", "/var/lib/factory-step-ledger")
)The test code does not change. The callback takes the serial from OpenHTF's dut_id,
the part number from the test's metadata, and records a measurement named
firmware_sha256, if the test has one, as the firmware artifact. A complete runnable
station is in examples/openhtf_station.py
(pip install -e ".[openhtf]").
factory-step-ledger record \
--profile /etc/factory-step-ledger/station.toml \
--ledger /var/lib/factory-step-ledger \
--serial LC16-0001 --part-number EX-LC-16 \
--step software_integration --outcome pass \
--artifact firmware=/images/olt-lc-5.2.1.bin--artifact takes a file (hashed for you) or a SHA-256. An Ansible playbook that
programs a unit and records the step whether programming passes or fails is in
examples/ansible/flash_and_record.yml.
station_id = "us-plant1-test-01" # also names the ledger file
steps = ["testing_and_quality_assurance"] # steps this station may record
[site]
site_id = "example-ems-us-plant1"
name = "Example EMS, Plant 1"
address = "100 Example Parkway, Springfield, ST 00000, United States"
country = "US" # ISO 3166-1 alpha-2
operator_org = "Example EMS, Inc."
[[software]] # hashed into every record
name = "final test sequence"
path = "/opt/station/sequences/final" # a file or a directory
[[instruments]] # calibration state goes into every record
model = "Example Optical Power Meter OPM-200"
serial = "OPM-0042"
calibration_due = 2028-06-30Unknown keys are errors, so a typo cannot silently drop a field. A station refuses to record a step its profile does not declare.
factory-step-ledger verify /var/lib/factory-step-ledger
factory-step-ledger coverage /var/lib/factory-step-ledger \
--parts parts.csv --units shipment.csv -o coverage.mdparts.csv maps part numbers to catalog categories (part_number,category);
shipment.csv lists the serials going out (serial). --format json gives the same
report for machines. factory-step-ledger catalog prints the built-in catalog and its
sources; --catalog path.json uses your own catalog in the same shape, for another
program or a customer's rule.
| Exit code | Meaning |
|---|---|
| 0 | Every ledger verifies and every unit passes the gate |
| 1 | Readable input, but a ledger failed verification or a unit failed the gate |
| 2 | The input could not be used at all (bad profile, missing file, unknown step) |
One record per line, in canonical JSON: UTF-8, keys sorted, no insignificant
whitespace. record_sha256 is the SHA-256 of that encoding with record_sha256
removed, so any implementation in any language can re-verify a ledger. The normative
definition is schemas/v0/step_record.schema.json
(JSON Schema 2020-12); the tests check every record the code writes against it.
The provenance block has the same shape as the one in
bead-compliance-toolkit,
which defines the evidence that manufacturers, internet service providers, and state
broadband offices exchange. This project sits one level below that, on the factory
floor: it produces the per-unit facts a manufacturer would want in hand before signing
a certification letter.
pip install -e ".[dev,openhtf]"
pytest -q
ruff check . && ruff format --check .Apache-2.0; see LICENSE and NOTICE. This is an independent project. It is not affiliated with, endorsed by, or sponsored by NTIA, the U.S. Department of Commerce, the State of Illinois, the OpenHTF project, or any manufacturer. Station, site, and company names in the examples are fictional.