Everything the repository tests runs with one command, locally and in CI, and ends in one report:
scripts/run_tests.sh
open build/test-report/report.html # or read build/test-report/report.md
CI (the workflow CI, .github/workflows/check.yml) runs on every push to main and every pull request, in stages, cheapest first. What changed and Quick, the Kleidos quality kit's first entry workflow (kleidos-dev/.github, called by name at @v3), come first: the kit's policy checks, every pre-commit hook on every file but the five this repository runs in jobs of its own (below), zizmor online, reuse lint with both header lines in every file, gitleaks over the whole history with both configurations, and on a pull request the commit messages. After it, Check (the kit's second: mypy strict in the three groups of pyproject.toml, and OSV-Scanner, failing on any known vulnerability) and this repository's Repository rules (the document paths, the calibration registry, the renders' metadata and the gitleaks rules' planted values; every step runs even when one before it failed); every later job needs the rules, so a failure there skips the rest of the run. Then Tests and coverage report runs the same script as above on every run, keeps build/test-report/ as the test-report artifact and writes the Markdown report into the run's job summary, so the figures are one click from the commit. Beside it, on every run, a draft's included, Host package coverage (for Sonar) runs step 3 again against the native bridge and keeps its Cobertura report, host-coverage.xml, every file named from the repository's root, as the coverage artifact; then Sonar (the kit's third entry workflow, sonar.yml) analyses the host package on SonarQube Cloud (sonar-project.properties, project kleidos-dev_meter) with it. The kit runs the analysis on every pull request and push, so its coverage cannot come from the tests job, which a draft skips. It needs no secret: GitHub's OIDC token buys a token for the one project, and a pull request GitHub gives no such token (from a fork or Dependabot) ends green with a notice. The quality gate is not judged there: SonarQube Cloud's GitHub App reports it on the pull request. The firmware's C++ is not on SonarQube Cloud yet (CodeQL, clang-tidy, cppcheck and the MC/DC gate hold it), and the page's modules show there as uncovered, since Chromium measures them in the panel job against host/js_floors.toml, a report the scanner cannot read. Beside it, and only when What changed finds a path they read: the panel's page in a headless browser, Panel (Playwright) (below; host/ and the registry's schemas run it), and, for what the firmware reads (a change that is all Markdown, docs/, host/, calibration/ or tests/ skips them), Native tests at 32 bits (GCC) (make -C firmware/test/native test32 CXX=g++, below), Device image (meter), and the rig's schematic in KiCad (Rig schematic, which hardware/ changes run). Check, last, needs every other job and fails unless each succeeded, the path-filtered ones, the tests job (on a draft) and Draft (off a draft) alone allowed to be skipped: it is the gate the landing rule reads. Two rulesets guard main: one asks for a pull request and signed commits and forbids deleting it or forcing a push to it, and the other requires Check on the commit, with nobody allowed to bypass it. main takes the owner's signed fast-forward push of a head whose Check is green (the landing rule of AGENTS.md), and that push ignores whether the pull request was a draft. A run by hand, a new branch or a forced push runs everything; a new push cancels the run of the one it supersedes. A draft pull request runs only the cheap stage (the kit's two jobs, What changed, the repository's rules, and the host package's coverage and Sonar): What changed reports every heavy family false while the pull request is a draft and the tests job skips (its only condition is the draft). A draft's run is no verdict, so it ends red on purpose: Draft runs on a draft alone and fails, and Check fails with it, so no draft head carries a green gate that a fast-forward push could be mistaken for a verdict by. The kit holds the gate's name, step and MAY_SKIP word for word, so the gate cannot take another name on a draft as the firmware's verdict does. Marking the pull request ready for review (pull_request includes ready_for_review) runs everything the paths ask for, and so does each later push to a ready pull request, so the aim is one full run per ready head: open the pull request as a draft, run scripts/run_tests.sh and the other gates of AGENTS.md locally, mark it ready when they pass, and push to it again only when something must change (tests/ci/test_draft_runs.py). The kit's own jobs stay on drafts: its check is mypy and OSV-Scanner, minutes, and the kit's gate model has no draft clause. tests/ci/test_workflow_convention.py holds the workflow to that shape, and every workflow's actions to a pinned commit.
Two advisory workflows run beside CI, as the Kleidos firmware repository's do, on the same events and weekly: CodeQL (.github/workflows/codeql.yml) analyses the firmware's C++ as the device image builds it, and the Python, the panel's JavaScript and the workflows, which it reads without a build, and Security scan (.github/workflows/security.yml) runs OSV-Scanner and Trivy over the tree and writes a CycloneDX SBOM. Nothing waits for them, and CodeQL, whose device build is the costliest job here, skips a draft pull request like the heavy jobs of CI and runs when it is marked ready. Each uploads its results to the repository's Security tab (code scanning), under the categories /language:<language>, osv-scanner and trivy; only those jobs may write security events, and the rest of each workflow is read-only. CodeQL is the repository's advanced setup, and GitHub's default setup is off: code scanning refuses an advanced workflow's results while it is on. CodeQL's SARIF is also kept as the codeql-sarif artifact and its result count is in the job summary, and Trivy's SARIF and the SBOM are the security-scan artifact.
Every pytest run turns a warning into an error: scripts/run_tests.sh and the pre-commit hook pass -W error, and tests/pytest.ini says filterwarnings = error for any run that names a path under tests/. The commit hooks (.pre-commit-config.yaml) are the quality kit's (kleidos-kit: the policy checks, the agent files, the no-wrap rule and the header lines; kleidos-commit-msg; kleidos-mypy, mypy strict) and the third-party hooks the kit holds to its canonical list (typos with .typos.toml, gitleaks with .gitleaks.toml and the kit's .gitleaks-mac.toml, reuse, markdownlint, ruff and its formatter with pyproject.toml, actionlint, zizmor, shellcheck), then this repository's own: pre-commit-hooks' hygiene checks, editorconfig-checker (.editorconfig, .ecrc), clang-format, and the local gates. .gitleaks.toml adds rules for a USB serial number in a port name, a USB serial number as macOS prints it and a MAC address, and .gitleaksignore names the three findings the history holds; tests/ci/test_lint_gates.py names the job of check.yml that runs each hook the quick job skips, and tests/ci/test_gitleaks_rules.py holds the rules to samples and to the documents' placeholders.
Pull requests are also read by two review bots, CodeRabbit (.coderabbit.yaml) and Greptile (.greptile/config.json, with the rule documents it reads in .greptile/files.json; .markdownlint.yaml is the Markdown rule set CodeRabbit runs). They post inline comments and suggestions only: neither edits a pull request's title or description, posts a summary, or commits code, and neither is a required check. Both review against AGENTS.md, with the rules per path written in their files; the byte copies and generated files listed there are reviewed at their source.
What runs
| Step | What | Where |
| 1 | The firmware's own sources, compiled unchanged on the host at the device's C++ standard (gnu++26) and with its strict warning set, flag for flag, under AddressSanitizer and UBSan, and LeakSanitizer where the platform has it (Linux); and the native bridge (below), built with the same flags and asked its identity | firmware/test/native/ (make -C firmware/test/native test) |
| 2 | The same tests again under LLVM's coverage instrumentation, for statements, branches and MC/DC | make -C firmware/test/native coverage |
| 3 | The host package, with branch coverage: the client, its simulated instrument, the panel (kleidos-meter serve), the guided calibration and the calibration registry, every --sim command of docs/usage.md and README.md and every simulator example of docs/panel.md run and its output compared with the page, docs/http-api.md held to the schema it is generated from, docs/cli.md to the parsers (its examples run, its statuses read out of each main) and docs/python-api.md to the docstrings, which every public name must have; and the conformance suite on the simulator, through serve's passthrough and on the native bridge step 1 built, which must all answer alike, the pin map's orders and the averaging override byte for byte | host/tests/ (pytest + coverage.py) |
| 4 | The guards over the firmware sources (pins, sdkconfig, relay fail-safe, quality evidence, the I2C bus's one core), the documents (no stale reference or citation of the frozen 0.1.0 design record, every relative Markdown link resolving, every page of docs/ listed in its index, the README's layout drawing every file of firmware/src and its settled questions linking their record, no retired calibration procedure or bypass stated as current, the temporary load of 2026-11-21 never stated as fitted, no photograph listed to take, the relay refusals docs/scpi.md lists composed by the firmware), the schematic and CI (the workflows' convention, the hooks the quick job skips, the gitleaks rules), the command table (docs/scpi.md's command reference, the sweep and the sessions held to it, below), the native bridge, the test runner's choice of a suite, the census script, the bench suite's support without the bench (its lock, its sweep, its expectation file and that file's history), and docs/misra.md's register held to the sources (tests/firmware/test_misra_register.py: the static locals, the constructs C++17 does not have, the tool suppressions, the counts, and no standard integer type named outside a printf format (6.9.2), the formats' names only falling; tests/firmware/test_ast_census.py: the image's translation units read together from clang's AST, no own function unreferenced, the array decays counted and only falling, with the clang of step 2; tests/firmware/test_misra_rules.py: the rules scripts/misra_rules.py holds from the same AST and the sources' text, 5.13.4, 7.0.3, 7.0.5 (with D12's count of narrow operands widened in one step), 8.0.1's conditional operator, 8.1.2, 8.2.2's tick macros, 8.14.1, 8.19.1, 9.4.1, 9.5.1, 19.6.1 and 21.2.2, none found in the image and each failing its planted case) | tests/firmware/, tests/hardware/, tests/ci/, tests/bench/ |
| 5 | The host package's mutants, every one killed (Mutants): all of them where the [browser] extra and its Chromium are installed, those no browser judges where they are not | scripts/run_mutants.sh --host or --package |
| 6 | The report, and its gate | scripts/test_report.py --gate |
The static analysis is a separate command, scripts/run_static_analysis.sh (clang-format, clang-tidy, cppcheck; docs/misra.md), run by pre-commit and by CI's Static analysis job (clang-format also as the quick job's hook). clang-tidy runs twice over every source of firmware/src/CMakeLists.txt: as the device compiles it, from firmware/compile_commands.json (pio run --project-dir firmware -e meter -t compiledb), and as these host tests compile it. Its guards fail the run with exit 2 on another LLVM major than scripts/analysis_toolchain.sh pins, a rejected configuration, a source missing from the compile database and any parse diagnostic; scripts/run_static_analysis.sh selftest plants each fault, and tests/firmware/test_static_analysis_gate.py holds the guards with fake binaries on every run. cppcheck must be the pinned release. The pin is LLVM 23.1.4, which CI installs; the bench Mac's is Homebrew's 23.1.1 (2026-11-25), the same major, which the legs accept with a warning, and it is recorded here rather than changed. The firmware's Doxygen reference is a gate of its own, mkdir -p build && doxygen Doxyfile, which fails on any undocumented symbol or parameter (CI's documentation job, where tests/firmware/test_doxygen_gate.py also plants an undocumented function and requires the gate to fail on it). After it, python3 scripts/check_doc_links.py --html build/doxygen/html reads the finished build for what Doxygen prints no warning on: a link whose page or anchor was never generated, a class with no page, @ref name:, a topic defined twice, outside docs/groups.dox or never joined, a member-group title shown twice on a page, a class copied by a using-declaration, a type or constant an enclosing namespace also names (relay::kChannelCount beside kChannelCount was one; it is relay::kRelayCount), two files of one name, and a warning only the XML writer prints. Three kinds of broken link Doxygen 1.17.0 writes by itself are counted, not failed, each by a rule as narrow as the defect (the script's GENERATOR_CAUSES; in this tree the third is the sidebar index's empty "pages.html":[] key, written although the reference has no related page and so no pages.html). --selftest plants each defect in a small tree and requires the gate to report it; the pre-commit hook runs the gate after the build and CI's documentation job runs both. The Doxyfile expands ESP-IDF's placement attributes (IRAM_ATTR, DRAM_ATTR, EXT_RAM_BSS_ATTR, RTC_NOINIT_ATTR) to nothing, so no member signature of the reference carries one, which the same test file holds.
The gate fails the run when a test failed, when an MC/DC condition is uncovered without a written reason in firmware/test/native/mcdc_exclusions.toml, when more branch sides are left untaken without a written reason in firmware/test/native/branch_exclusions.toml than its baseline allows (the decision-coverage gate, below), when a module of the host package takes a smaller share of its branch sides than its floor in host/branch_floors.toml allows (FW-31, below), and, in CI, when a test was skipped for a reason that names no place where it runs instead.
A skip in CI is a test that runs somewhere else (FW-31). SKIPS in scripts/test_report.py names each reason a test may be skipped for and the job that runs it: the bench suite's cases (the bench), the guards over the device build (the device image and static analysis jobs, which run them with METER_BUILD_REQUIRED=1), Doxygen's (the documentation job), gitleaks' rules (Repository rules), KiCad's (the rig schematic job), the panel's page (the panel job) and the copies held to another repository's checkout. Any other skip fails the gate where CI=true; on a developer's machine it is a note. A case whose need the same run has just built does not skip at all: scripts/run_tests.sh names the bridge it built (KLEIDOS_METER_NATIVE_BRIDGE) and sets METER_BRIDGE_REQUIRED=1, which turns a missing bridge or test binary into a failure, the firmware conformance case's included. tests/ci/test_skips.py holds the reasons, their jobs, the variables and that every guard over a device build runs in a job that has one.
The panel's page (host/tests/test_panel_browser.py, FW-31's CI job): Panel (Playwright) installs the host package's [browser] extra (Playwright 1.65.2, pinned exactly so the cached Chromium is that release's), restores the pinned Chromium from its cache and runs the suite with METER_BROWSER_REQUIRED=1, so that a missing browser fails instead of skipping. scripts/run_tests.sh runs the same suite where the extra is installed, and the module is skipped where it is not. Its last test is the JavaScript coverage gate (HO-09): what the suite ran of every module of the page, as Chromium's precise coverage counts their functions and blocks, must meet host/js_floors.toml. The pure modules (chart-math.js, pins-math.js, no DOM) are held at 100 % of both, or name the block no test can run with its reason; the drawn modules (the other seventeen) are held to two points under the least of two runs of 2026-11-26, since what an event-driven page runs moves a point or three from one run to the next, the gate printing every block they leave (and a block may be named with its reason, as pins.js's and noise.js's are); a floor only rises, and a drawn module's figure over its floor asks nothing of it, since it moves by a few blocks from one run to the next. It judges a run of the whole module and skips on a selection, so the job runs the module whole, writes the figures the test recorded to the run's summary and fails when there is none. The job then kills the mutants of the page's modules (scripts/run_mutants.sh --page). tests/ci/test_host_mutants.py holds all of it, and that a change to the mutant runner runs the job.
The panel's images (docs/images/panel/, DO-01): host/.venv/bin/python scripts/take_panel_shots.py takes every view of the page dark and light at 1280 pixels and dark at 390, and the states the documents explain (the chart with smoothing off and at 100 ms, a pin's menu open, a conflict on a pin, a reverted apply), from serve --sim in a fixed scenario (host/tests/panel_shots.py: a simulator whose DUT draws a stepped current under a noise its sample count decides, a registry made in a temporary directory, one recorded run, the HEALTH sequence done). It refuses a view whose text holds an absolute path and an image over the 512 kB hook limit, stamps each PNG with its metadata record (scripts/media_meta.py, held by scripts/check_metadata.py) and writes manifest.json, the same twice over. The pixels are not what is held, since fonts differ between the Mac and CI: tests/firmware/test_panel_images.py (host-only, every run) holds each image to the SHA-256 of the files that shape its view (the page's skeleton and the view's section of index.html, the stylesheet, the shell's and the view's modules with what they import, schema.py, the pin table for the pin views) and names the image to retake when one changes; the browser half in host/tests/test_panel_browser.py renders every image's view again and holds the signature of what it rendered (the visible text with every figure and digest masked, the layout landmarks' boxes in sixteenths of the width) to the manifest's, and checks that another font leaves it unchanged. A change to scripts/panel_images.py or the manifest runs the panel job (tests/ci/test_changes_filter.py).
The panel's bench images (docs/images/panel/bench/, DO-05): screenshots of the panel over the cable to the meter, which the panel's bench test takes (host/tests/test_panel_bench.py --run-bench --bench-shots) with a record of them (bench-shots.json: the date, the firmware, the image's elf= and ELF SHA-256, the commit, the instrument, the rig, and who checked them by eye for a port name, a USB serial, a MAC address or a path, which gitleaks cannot read in pixels). python3 scripts/file_bench_shots.py <folder> holds each PNG to the SHA-256 and the name (bench-<view or state>-<date>-elf-<elf>.png) its record gives, refuses a record that says nobody looked at the images, stamps each with its metadata record and lists it in manifest.json as kind bench, beside the simulator's, which stay as they were. Nothing retakes a bench image when a view changes; tests/firmware/test_panel_images.py holds every bench entry's form, its name and the SHA-256 of its file, and host/tests/test_panel_doc.py that docs/panel.md ("On the bench") shows each with a caption that names it a bench image with its date and elf=.
The firmware's reference is a gate of its own, beside the tests: mkdir -p build && doxygen Doxyfile exits non-zero on any warning, and the Doxyfile extracts every symbol of firmware/src, private members, file-static and anonymous-namespace symbols and function-local classes included, so an undocumented symbol, parameter or result fails it; scripts/check_doc_links.py --html build/doxygen/html then fails a link to a page Doxygen never wrote and a name an enclosing namespace also declares. Both run in pre-commit and CI's Documentation site and firmware reference job, and tests/firmware/test_doxygen_gate.py (step 4) holds the Doxyfile's settings and plants an undocumented public function, private member and anonymous-namespace function in a copy of the tree, each of which must fail the build.
Requirements
- LLVM 19 or later (clang++, llvm-profdata, llvm-cov) for step 2: MC/DC instrumentation (-fcoverage-mcdc) arrived in LLVM 18 with a limit of six conditions per decision, which isTokenSafe() exceeded with seven until 0.6.0 refused bytes above 0x7E at the line, and 19 raised it; 19 stays the floor so that no decision has to be split to fit. On macOS, Homebrew's llvm; the script finds it in /opt/homebrew/opt/llvm/bin or /usr/local/opt/llvm/bin, or set LLVM_BIN. CI installs the runner's distribution clang and llvm packages.
- Python 3.11 or later (CI runs the version in .python-version, 3.15, and the three jobs that build with ESP-IDF on 3.14, for the reason check.yml gives beside them) with host[dev] installed (pip install -e 'host[dev]', which brings pytest, pytest-cov and ruff 0.17.6, the kit's hook pin); the script prefers host/.venv when it exists. For the page's browser tests, the [browser] extra and its Chromium: pip install -e 'host[dev,browser]', then python -m playwright install chromium.
The build is the device's
tests/firmware/test_host_build_matches_device.py holds the host build to the device's: the Makefile's WARN is build_src_flags of firmware/platformio.ini, flag for flag, and its -std=gnu++2c is the gnu++26 of firmware/CMakeLists.txt (the spelling compilers accept for the draft). A warning fails the object even where -Werror does not reach it: clang 21, CI's, warns of a decision with a boolean expression nested in it ("unsupported MC/DC boolean expression"), leaves it out of the MC/DC coverage and has no flag for it, so the Makefile refuses any object whose compiler printed warning:. A build directory's objects are all made by one compiler: build/compiler holds its version, and another compiler (the commit hook's c++ after run_tests.sh's LLVM) makes them again. Two legs reach what one host compiler cannot:
- 32 bits (make -C firmware/test/native test32, CI's native32 job, GCC with g++-multilib): std::size_t, long and pointers are 32 bits wide, as on the ESP32-S3. Each test thread reserves 512 KiB of stack instead of 8 MiB, because the simulated boards' frozen tasks stay alive for the whole run and a few hundred of them at 8 MiB did not fit the 32-bit address space on CI's runner. From FW-30 each suite runs in a process of its own there (PER_SUITE=1; test_firmware --suites lists them and --suite <name> runs one), because at 370 cases one process no longer fitted; tests/firmware/test_native_runner.py holds that the suites together are the whole run. It adds -malign-double, because i386 aligns a 64-bit integer inside a struct to 4 bytes where Xtensa aligns it to 8, and the calibration record's layout calibration.cpp asserts would otherwise differ from the device's. macOS has no 32-bit target, so the leg runs on Linux only. A change to a host test or to firmware/src runs it before it is pushed, on a Mac in a container of CI's distribution (ubuntu:26.04, GCC 15.2): docker run --rm -v "$PWD":/in:ro ubuntu:26.04 sh -c 'cp -r /in/firmware /in/scripts /tmp && rm -rf /tmp/firmware/test/native/build && apt-get -qq update && apt-get -qq install -y g++-multilib make python3 && make -C /tmp/firmware/test/native -j4 test32 CXX=g++'. A conversion only a 32-bit std::size_t refuses stood in a test from FW-03 to FW-08 of 0.18.0 because no package between them ran the leg.
- GCC: the device's compiler family. It found two -Wformat-truncation warnings clang never gave (a sampler refusal and the block header of TRACe:DATA? could have been cut in buffers too small for the worst case GCC can prove), and a test whose two operands of + it evaluated in the other order.
LeakSanitizer runs on Linux (macOS's AddressSanitizer refuses it), in CI's test job and its 32-bit leg. firmware/test/native/lsan.supp names only the harness's own allocations that live as long as the process by design: the simulated boards and the firmware objects a Bench boots on them (bench::Scope, bench::Bench), and the objects the fake ESP-IDF hands the firmware for good (a bus, a device, a queue or semaphore), all made by one harness function, sim::hold(). No entry names the firmware's code (until FW-08 four did, and a fifth the TRACE ring's allocator, gone since the ring became a static array), so a leak of the firmware's, at boot or while it answers commands, fails the run.
The Python suites run in parallel by default (pytest-xdist, pinned in the dev extra): host/pyproject.toml and tests/pytest.ini say addopts = -n auto --maxprocesses=8 --dist loadfile, so every pytest run under host/ or tests/, scripts/run_tests.sh and CI's jobs included, uses one worker per core up to eight, with a test file kept on one worker (the panel's browser module and its coverage gate, which judges that module's whole run, need that). -n 0 runs serially, for a debugger or a clean traceback; a run that talks to the instrument (--run-bench) is made serial by the conftest files whatever -n says, since the port and the bench lock are one. A test that cannot meet another in a process (a fixed port, a shared path, the bench) must not exist: tests build under tmp_path, serve binds port 0, and the bench is marked bench.
Run one suite on its own while working: make -C firmware/test/native test (all firmware binaries), ./firmware/test/native/build/test_firmware route (the cases whose suite/name contains route), cd host && pytest -q.
Before you commit
Every gate a change meets, with its command; scripts/run_tests.sh and pre-commit run --all-files are the two every change runs, and CI runs them all (What runs).
scripts/run_tests.sh # every test and the report (docs/testing.md): the conformance suite on the simulator and the native bridge, the MC/DC and branch gates, the host floors (host/branch_floors.toml), the host package's mutants
METER_BROWSER_REQUIRED=1 host/.venv/bin/python -m pytest -q -W error host/tests/test_panel_browser.py # the panel's page in Chromium and its modules' coverage (host/js_floors.toml; CI's panel job; needs host[browser] and `python -m playwright install chromium`; also in run_tests.sh where they are installed)
scripts/run_mutants.sh --firmware # by hand and before a release: the firmware's mutants, every one killed (half an hour and more; `--page` is the page's, CI's panel job)
scripts/run_static_analysis.sh # clang-format, clang-tidy (device and harness legs; needs the compile database below), cppcheck
mkdir -p build && doxygen Doxyfile # the documentation site and the firmware reference, zero warnings (Doxygen 1.18.0)
python3 scripts/check_doc_links.py --html build/doxygen/html # after it: every link resolves, no name shadows an outer one (--selftest plants each defect)
python3 scripts/build_reference.py --out <new dir> # the site as it is published, built and guarded (scripts/check_reference.py; --selftest plants each defect)
python3 scripts/preview_reference.py --tree <dir> # look at it, as the host serves it (http://127.0.0.1:8798/meter/)
python3 scripts/misra_register.py --check # docs/misra.md's tables against the sources (also in run_tests.sh)
python3 scripts/ast_census.py # no own function unreferenced, the 7.11.2 decays counted (clang; --leg device after a compile database)
python3 scripts/misra_rules.py # the MISRA rules held by a gate of their own, none found (docs/misra.md, "Held"; clang)
pre-commit run --all-files # every hook: the quality kit's policy checks and mypy strict (pyproject.toml's groups), ruff and its formatter, typos, gitleaks, reuse, markdownlint, actionlint, zizmor, shellcheck, clang-format, EditorConfig, hygiene, the gates above
python3 scripts/check_spdx.py # holder and license in every header
python3 scripts/check_doc_paths.py # every path a document writes is here or names its owner (--selftest plants each case)
python3 scripts/check_metadata.py # the renders and the panel's images carry their metadata (pypdf)
host/.venv/bin/python scripts/take_panel_shots.py # when a view changed: retake the panel's images (docs/images/panel/; host[browser]; oxipng if installed)
python3 scripts/file_bench_shots.py <folder> # after the panel's bench test took its images (--bench-shots), looked at for private bench data: file them (docs/images/panel/bench/)
python3 scripts/check_calibration_registry.py # the registry and its index
python3 scripts/gen_http_api_doc.py --check # docs/http-api.md is the panel's schema (without --check it writes the page)
python3 scripts/gen_cli_doc.py --check # docs/cli.md is the parsers of kleidos-meter
python3 scripts/gen_python_api_doc.py --check # docs/python-api.md is the host package's docstrings
python3 hardware/export_rig.py # when hardware/gen_rig.py or the kit changed (kicad-cli 10.0.8; CI wants its bytes)
pio run --project-dir firmware -e meter # when firmware/ changed (before the static analysis, whose device leg reads the compile database)
pio run --project-dir firmware -e meter -t compiledb && METER_BUILD_REQUIRED=1 host/.venv/bin/python -m pytest -q -W error tests/firmware/test_effective_compile_flags.py tests/firmware/test_meter_sdkconfig_reaches_the_build.py tests/firmware/test_heap_reachability_gate.py tests/firmware/test_misra_rules.py tests/firmware/test_static_analysis_gate.py # after that build: the guards over it, none skipped (CI's firmware and static-analysis jobs)
python3 scripts/check_radio_absent.py --nm <xtensa-esp32s3-elf-nm> firmware/.pio/build/meter/firmware.elf # after that build
python3 scripts/check_drivers_absent.py firmware/.pio/build/meter/kleidos-meter.map # after that build: no retired ESP-IDF driver linked
python3 scripts/check_heap_objects.py --nm <xtensa-esp32s3-elf-nm> --elf firmware/.pio/build/meter/firmware.elf firmware/.pio/build/meter/src/*.o # after that build: no allocator, no C++ allocating runtime, no NVS
python3 scripts/check_heap_reachability.py --elf firmware/.pio/build/meter/firmware.elf firmware/.pio/build/meter/src/*.o # after that build: no allocator reachable from our code (pyelftools 0.33; --selftest plants each case)
host/.venv/bin/python -m pytest -q -W error tests/bench --run-bench --meter-port "$KLEIDOS_METER_PORT" --bench-lock <lock> # after flashing a change that can move a heap count (the bench lock held)
The documentation site
The documents and the firmware's reference are one Doxygen site (Doxyfile): every Markdown page of the repository (docs/, the README files, AGENTS.md, the changelog, the notices and the calibration records) and every symbol of firmware/src, with the index as its main page. The Markdown files stay the one source and read the same on GitHub: Doxygen reads each through scripts/doxygen_md_filter.py, which blanks the comments before the title, names the page after its file (docs/rig-wiring.md is rig_wiring_page) and turns each link into the site's, keeping every line where it was. One link form is written, the form GitHub reads: a path relative to the file, with a heading's anchor where it goes to one ([the pin map](scpi.md#the-pin-map)); the anchors are GitHub's in both (MARKDOWN_ID_STYLE = GITHUB). tests/firmware/test_markdown_links.py holds that every such link resolves to a file and a heading, and tests/firmware/test_doc_link_form.py that a Markdown link goes to a page of the site, that Doxyfile's pages are the filter's, that every image's name is unique across IMAGE_PATH, what the filter makes of each kind of link (a link whose text is its file's path reads as the page's name, LINK_NAMES), and that no page but the History records sends a reader to what a stranger cannot reach (a git-ignored file, a private plan, the bench's computer, a line of an unpublished commit). The gate is the same as the reference's: mkdir -p build && doxygen Doxyfile fails on a warning in a page as in a comment (a command it does not know, a @ref to no target). It fails on a link to a file the repository does not hold, too: the filter writes that link as a @ref Doxygen cannot resolve and says it on stderr at the page's line, so scripts/check_doc_links.py (which reads the run's warnings) and scripts/build_reference.py (which fails on any) fail on it as well. A link to a heading a page does not have is no warning, since the filter writes each page link as an HTML link, which Doxygen does not check; three other gates fail on it: tests/firmware/test_markdown_links.py on the Markdown, scripts/check_doc_links.py on the gate's HTML and scripts/check_reference.py on the published tree. tests/firmware/test_doxygen_gate.py plants a link to a missing file and holds that the gate fails on it.
The site as it is published, at https://api.kleidos.dev/meter/ (the Kleidos firmware repository serves a copy of this build pinned to a commit of main), is built by python3 scripts/build_reference.py --out <new directory>, a port of the Kleidos firmware repository's build of its own reference: Doxyfile.public over the Doxyfile, with that host's header, footer and layout (docs/published-reference/), no source, and no script but that host's own search (../assets/search.js, whose control leads to the page of the search, docs/published-reference/search.md, where no script runs); the tree rewritten for a static host (each page's content in <main>, its title its one heading, an image's caption its text, a heading the filter named after its page also under GitHub's anchor, links without .html and a canonical address), each page's Markdown twin beside it, the site's llms.txt and the search's two lists (search-pages.json, search-members.json: every page, and every member a page documents under an anchor of its own), by four of the firmware repository's modules copied into scripts/published_reference/, byte for byte but for the few lines of typing.patch this repository's strict mypy asks for (SOURCE.json records the commit and each file's SHA-256 there and here, and tests/firmware/test_published_reference_copies.py holds the copies to it and undoes the patch to find the source's bytes: never edit a copy, copy it again). The build ends with scripts/check_reference.py, the guard of what would go out: only pages, twins, the llms.txt, the search's two lists and the documents' images; no script but the search's one tag, no frame, inline style or source; the search's lists in the shape the build writes, within their budgets, naming only pages and anchors the tree holds, with no two entries a reader cannot tell apart (the firmware repository's own rule); every link and anchor in the tree; the note "In development." first in every page; and no private value (the MAC addresses, USB serials and port names .gitleaks.toml and .gitleaks-mac.toml refuse, a private address, a local host name, a path of somebody's computer, an e-mail address other than mail@kleidos.dev, a link to a repository that is not public), in the pages, the twins, the llms.txt and the search's lists alike. python3 scripts/check_reference.py --selftest plants each defect. python3 scripts/preview_reference.py --tree <dir> serves a built tree on this computer as the host would (each page at its address without .html), with the host's sheets, faces and mark fetched once from https://api.kleidos.dev/assets/ into ~/.cache/kleidos-meter/api-assets (--assets <dir> takes them from a checkout instead). CI's documentation job runs all of it.
How the firmware is tested on the host
The firmware is not refactored for the tests: console.cpp, console_commands.cpp, sampler.cpp, ina228.cpp, relay.cpp, calibration.cpp, identity.cpp, scpi.cpp, status_led.cpp, heap_monitor.cpp, interrupt.cpp, watchdog.cpp, uart0.cpp, i2c_bus.cpp, flash_log.cpp, flash_port.cpp, pin_boot.cpp, pin_apply.cpp, pinmap_store.cpp, startup_memory.cpp, brownout.cpp, text.cpp and main.cpp, every source of the image, are compiled as the device compiles them, against a fake ESP-IDF (firmware/test/native/harness/idf/: GPIO and its interrupt registers, the CPU's interrupt lines and the interrupt matrix, a pad's function, output and matrix signal, I2C0's registers, UART0's registers, the SPI flash API's read, write and erase (esp_flash_*, FW-16), the RMT's registers and clock lock, Timer Group 0's watchdog registers, the timer groups' clock and reset and the shared modules' references, Core 0's idle hooks, esp_timer, heap_caps, the interrupt allocator, the eFuse MAC, FreeRTOS tasks, queues and semaphores), and the model of the record logs' flash (firmware/test/native/harness/flash.cpp). Each fake names the ESP-IDF header it restates as 6.0.3's, the tree it was transcribed from; on the move to ESP-IDF 6.1.1 (2026-11-28) every one was compared with 6.1.1's, which adds functions and changes comments and license lines but nothing the firmware calls or reads, so the fakes stand as they are. The fakes run on a simulated board (firmware/test/native/harness/sim.h):
- A deterministic scheduler on virtual time. Every FreeRTOS task is a host thread, but only one runs at a time; time moves only when every task is blocked (to the earliest deadline or interrupt) and by one microsecond at each read of the clock, so a busy-wait ends. A 120 s relay hold or a 10 s null costs milliseconds of real time, and a run is repeatable. A task can be stalled by its name (World::taskStallsUs, FW-29): its next wait first holds it for the time given, as a preemption would, holding nothing meanwhile, which is how a sampler slow to acknowledge a stop and a console that stops reading the stream are modeled. An interrupt that gives a semaphore reports a wake only when a task is blocked taking it, as FreeRTOS does for one that outranks the task interrupted, and each portYIELD_FROM_ISR() is counted (World::isrYields, isrGives).
- The circuit. The relay module's pads decide whether the DUT is fed through the shunt, the bypass, both or neither; the HW-316 is active low and the Relay 2 Click active high, as built. The model counts every transition into "the DUT has no battery", so make-before-break is checked, not assumed. Where the wires land, the INA228's lines and the relays' inputs, is the board's and not the firmware's (sim::RigWires, rev D unless a case moves it; FW-04): the part acknowledges only while the controller's SDA and SCL are on the pads it is wired to, so a pin map that names other pads finds nothing, and each pad keeps the first level it drove (Pad::firstDriven). Faults: a bypass contact that does not close the dry circuit (the bench's real failure), a lead that does not open, a module with no 5 V.
- The INA228 as a register file and a physical model: the true shunt, the sense loop's offset, VBUS, the die temperature, deterministic noise, the ALERT pin as the part behaves (low from a conversion's end until DIAG_ALRT is read, so a conversion that ends while it is low makes no edge, and one that ends while its interrupt is off leaves it low; 0.9.0), or pulsing per conversion whatever reads it, ringing, absent or glitching; its conversions on their own grid from the last ADC_CONFIG write, so enabling the interrupt meets that grid at its phase rather than starting a conversion (0.15.0); CNVRF (set by a conversion since the last DIAG_ALRT read in the realistic model, or a set time after its period, a conversion that ends late; FW-28), CHARGE, a second part on the bus that answers a probe at its own address (FW-28), and a transaction that fails on demand (once, on one register, after n, or every n-th), which the bus shows as a NACK on its register pointer (FW-14), or that stalls its caller.
- One core for the bus (0.16.4, 0.16.5, FW-14): until FW-14 the harness faked ESP-IDF's I2C master, whose bus remembered the core that created it and latched a far-core NACK's completion for the next transaction to take (ESP_OK and zeros, as ESP-IDF 6.0.3's driver did, docs/architecture.md §2.2). From FW-14 the INA228 is reached through I2C0's registers (I2C0, below), which remember the core that clocked them, the one the Bench's boot makes Core 1 as app_main() does; every register call from another core is counted, and every case that boots a Bench fails when that count is not zero, so a console path that reached the bus from Core 0 fails whatever case runs it.
- The CPU's interrupt lines (FW-09): both cores' descriptor tables as ESP-IDF 6.0.3 gives the ESP32-S3's, their handler tables, enables and the interrupt matrix's routes; a driver's interrupt (the I2C master's, until FW-14) takes a line as ESP-IDF's allocator would, the lowest free level-1 line with no handler; and the GPIO's status and enable registers, which the ALERT pin's edges latch on the pin ALE is wired to and which raise the routed line. The line is level-triggered: its handler runs while the status it is routed for is pending, and a handler that leaves it pending is a storm, which fails every Bench and Scope that sees one, as a mask of the core's interrupts left set does.
- The RMT (FW-10): its bus clock and reset, the group's clock and memory, transmit channel 0's registers and raw status, as ESP-IDF's hal/rmt_ll.h reaches them. A start plays the channel's RAM onto the pads the matrix routes to it, half-symbol by half-symbol in picoseconds of the clock the firmware set, once or once per counted pass, and ends when the count does (sim::RmtFrame); a channel the model cannot run (no clock, an endless loop, a pointer or count not reset) sends nothing and never ends, and a stall knob makes any channel never end. Every Bench and Scope fails a case that left the peripheral clock lock held, reached the RMT's clock or reset outside it, wrote to the RMT while it was gated, or left a pad it drives with no idle level.
- Timer Group 0's watchdog (FW-11): the MWDT's write key, enable, four stages, interrupt bits, reset lengths, prescaler, flash boot protection and feed, as ESP-IDF's hal/mwdt_ll.h reaches them, with the group's bus clock and reset (hal/timg_ll.h) and its reference count under the peripheral clock lock. The timer counts the 80 MHz APB divided by its prescaler from its last feed, and a first stage whose hold runs out unfed, with an action set, latches the moment the device would have reset (sim::Mwdt::resetAtUs). Core 0's idle hooks run once a simulated millisecond, from the clock and every jump of time, as its idle task would between its tasks, unless a test starves it. Every Bench and Scope fails a case that wrote to the timer locked or unclocked, reached the group's clock outside the lock, left the key unlocked, or let the timer run out, unless the case provoked the reset (Mwdt::resetExpected); knobs make the timer keep no write and the idle hook table full.
- UART0 (FW-12): its bus clock and reset, clock source and divider, frame, the two 128-byte FIFOs, the receive threshold (a level), the receive time-out and the overflow (latches) and the interrupt enables, as ESP-IDF's hal/uart_ll.h reaches them. A host's bytes arrive in the receive FIFO one at a time (World::send(), sendRaw()), each raising the routed line as the FIFO's level calls for, then the time-out; a byte that finds the FIFO full is lost and latches the overflow. The transmit FIFO empties onto the line at once, unless a knob stalls the line (stallTx()), lets it carry only so many bytes first (Uart::txBudget), or resumes it at a set time (resumeTxAt()). An interrupt raised while the core's interrupts are masked is taken as the mask goes. Every Bench and Scope fails a case that reached the port from Core 1, reached its clock or reset outside the peripheral clock lock, wrote into a full transmit FIFO, read an empty receive one, or left its interrupt pending; knobs refuse the baud rate.
- I2C0 (FW-13, FW-14): its bus clock and reset, its configuration, the timing registers staged and latched (and how often they were written), the two 32-byte FIFOs, the eight command registers and the interrupt status, as ESP-IDF's hal/i2c_ll.h reaches them, with the INA228 model on the far side. A start runs the command list against the model at the latched clock, its NACK, fault and STOP's completion appearing at the bit times they take, and writes the transaction on the wire as text (S 80 01 S 81 r1 n1 P: a START, a byte written, a repeated START, the read address, a byte read and acknowledged, the last not, the STOP). Knobs arm NACKs on an address or a data byte, a time-out that leaves the state machine stuck until a reset, a NACK whose STOP never comes, a device that holds SDA low until a bus clear (or for good), a controller that never answers, and a hook run at the start (a preemption); the INA228 model's own faults become NACKs and stalls of the caller there. Every Bench and Scope fails a case that reached I2C0 from a core other than the one that clocked it, unclocked or its clock and reset outside the lock, started a transaction unconfigured, over another or from a command list the hardware would not run as meant, or overran or underran a FIFO.
- The record logs' flash (FW-15, FW-03): four sectors from 0x9000, the calibration log's two and the pin map log's two (flash_log.h, flash_port.h), as NOR flash behaves, a write clearing bits (old AND new) and an erase setting a whole sector to 0xFF, reached through the device's own port (flash_port.cpp, FW-16) and the harness's fakes of esp_flash_read(), esp_flash_write() and esp_flash_erase_region(), which ask the image's region check first, as ESP-IDF does, and refuse what it refuses with nothing changed (Flash::regionChecked lifts it for a log tested at another address). A power cut makes one write or erase, by its index, the last the flash takes: only its first bytes land, and torn, the next byte of a write takes half its bits and the rest of an erased sector is left with bits set at random; every later call fails until the power is back. Knobs fail a read after so many, fail a write or an erase, make one report success and change nothing, and leave one byte that never takes a write. Every Bench and Scope fails a case that wrote a 1 over a 0, reached the flash outside the window, erased other than one whole sector at a time, or asked for a write or an erase the region check refused. firmware/test/native/test_flash_log.cpp cuts the power at every write and erase of a run of 220 saves that changes sectors more than three times, at ten places in each write and eight in each erase, each whole and torn, and recovers the last complete record each time; it also makes 10,000 saves and holds both sectors consistent and their erases within one of each other. For the two logs (FW-03) it runs each log through 95 saves that move it between its sectors three times, with the other log holding records in both of its own, and cuts the power after every byte of every write and every erase of that run, whole and torn (about 50,000 cuts a log): each time the cut log mounts its last complete record and takes a save after, and the other log's 8 KiB read back byte for byte, and mount to the same newest record at each change's first and last byte; 3,000 saves to both logs in turn keep each one's sectors its own. firmware/test/native/test_pinmap_store.cpp holds the pin map's blob byte for byte, loads back every field it saves, reads as no record (the default map) every record the store refuses (another length, magic, version or table digest, a pull or level byte that names no value, a byte of padding that is not zero, a map pinmap::validate() refuses) and a refused record newer than the stored map, refuses to save such a map, answers each flash failure, cuts a pin save after every byte, and leaves the calibration's sectors alone through 200 pin saves (and the reverse through 120 calibration saves). flash_log.cpp, flash_port.cpp and pinmap_store.cpp are at 100 % of lines, branches and MC/DC conditions (llvm-cov: 22, 5 and 5 conditions); the branch baseline fell to 120 in FW-16.
- The heap, a heap that grants only so much. (NVS left the harness with the firmware's last call of it, FW-16.)
- The brownout detector (FW-18): the configuration brownout_hal_config() was last given and how often, as ESP-IDF's hal/brownout_hal.h reaches it; the boot suite requires one arming, at ESP-IDF's level, with the hardware reset on.
- What ESP-IDF would allocate (FW-08). The fakes do not allocate as ESP-IDF does, so each fake of an entry point that allocates or frees on the device (the interrupt allocator, the SPI flash API's write and erase; NVS until FW-16, the I2C bus and device until FW-14) records its call on the world's ledger (harness/idf_ledger.h). Every Bench and Scope fails a case whose ledger names an entry point that is not on the made-safe list (the calls the image's configuration takes the allocation out of: the flash log's write and erase, with the region check wrapped onto a static table, FW-16; the harness's allow-list, docs/misra.md D1, went empty in FW-16 and was removed in FW-17), so a change that makes the firmware call another allocating driver fails the host tests before it reaches the device. test_heap.cpp shows what the boot (nothing), three clock changes (nothing, from FW-14) and a save (the log's write, and its erase when it changes sectors) ask of ESP-IDF, and that a planted call fails its case (unit::ExpectedFailures keeps the destructor's failure instead of the case's). Its every-command session (FW-19, kEveryCommand and its last word kLastWord) gives every header of the console's command table at least once, the saves, *RST, *TST?, a scan, register reads, the lead cycle, the charge reset, the STATus subsystem and the watchdog's forced reset included, and requires allocs_since_main=0 frees_since_main=0 after each message; tests/firmware/test_heap_session_covers_the_table.py fails a header of kCommands the session never gives and a unit no command matches. The source gate and the object gate hold the same lists by file, and tests/firmware/test_idf_allocation_lists.py holds the three equal, each fake to its record, each made-safe call to its mechanism in the tree, and their history to an allow-list that only shrinks and a deny list that only grows.
- ESP-IDF's main task (FW-17). The console runs on the task ESP-IDF creates to run app_main(), which never returns, so the harness has that task too: sim::World::startMainTask() starts main on Core 0 at priority 1, as ESP-IDF's startup does, and no firmware fault refuses it. Bench boots on the test's thread (the heap monitor armed first, as app_main()'s first line) and runs Console::run() on the main task; the boot suite runs the real app_main() on it and fails a case in which it returned. The fakes of xTaskGetCurrentTaskHandle() and vTaskPrioritySet() keep each task's priority by name (World::taskPriorities), so a case shows the console raised the main task to 5 and created no task of its own.
A test talks to the instrument the way a host does — SCPI over the line (firmware/test/native/harness/bench.h: ask, tell, errors) — or drives a module directly (firmware/test/native/harness/scope.h). Each binary is a unit.h runner that writes JUnit XML: test_scpi (the parser, the character table of chars.h and the bounded writer of text.h alone) and test_firmware (everything else: the one image's firmware and, in the boot suite, app_main() itself). The boot cases had a binary of their own until FW-01 (2026-11-22): in it the inline functions only the tests call at run time (calmath::agreementPpm, relay::finalState, sim::World::ring, seven in all) were never emitted, and their empty coverage records, read beside the firmware binary's, were llvm-cov's "7 functions have mismatched data", coverage the export dropped. make coverage keeps what llvm-profdata and llvm-cov print in build/coverage/llvm-cov.log, and scripts/test_report.py --gate fails on any line of it, and on a missing log. The binaries link with the linker's warnings fatal (-Wl,-fatal_warnings on macOS, -Wl,--fatal-warnings elsewhere); on an x86_64 Mac the coverage link also aligns its segments to 16 KiB, the alignment clang's driver asks of the profile counters' sections.
The golden transcript (FW-24): test_golden.cpp boots simulated instruments and records every byte they write to scripted sessions, the boot included: every query of the command table (tests/firmware/test_golden_session_covers_the_table.py holds the sessions to kCommands), every error the harness can provoke (the command errors, the execution errors, -240 from a refused IPC call, -363, -350, 106 from a flash that will not program, the relay interlocks and checks, the hold's three releases, a warm boot's 116, an absent INA228, a sampler and relays that did not start), every stream record of both formats (samples, marks, threshold marks) and the ring's dumps in both formats, plain and under a level trigger. It compares the whole, byte for byte, with firmware/test/native/golden/console.transcript in every run, under the sanitizers, under coverage and at 32 bits; the world runs on virtual time, so the bytes are the same everywhere. The formatter rewrite (FW-24 to FW-26) is held to it: none of its steps may change a byte. A change that means to change the wire (a version bump changes *IDN?) regenerates the file, METER_GOLDEN_WRITE=1 ./build/test_firmware golden from firmware/test/native, and shows what it changed in the file's diff; the test file's header says how the transcript is written.
The command table's sweep (FW-30): test_sweep.cpp runs every entry of the command table itself, which Console::commands() gives the tests to read and not to write, and holds each to the rules every command keeps. Its long and its short form, in any case, reach that entry and no other; given valid parameters in the state it needs, a query answers exactly one unit and a command none, with no error; one parameter more than it takes is -108 and one required parameter less -109, each alone in the queue and neither changing what the header's query answers; its D, R and C refuse it where they say (no INA228; a capture running; a null window running; a full ring and an ended null not yet closed) and are worded as the page words them, and no other entry is refused so; and no call allocates, frees, or asks ESP-IDF for an entry point that does. kFixtures gives each entry its parameters and its state, in the table's order, so a command added without a fixture fails, and kSweptEntries is the count tests/firmware/test_sweep_covers_the_table.py holds to python3 scripts/scpi_table.py --count.
The pin map's vectors (0.18.0's FW-01): the rules a pin map must keep exist once, as pinmap::validate() (firmware/src/pinmap.h), over the board's table, firmware/src/pin_table.h, which scripts/gen_pin_table.py writes from firmware/board/pins.toml together with the panel's copy, host/kleidos_meter/board_pins.json (--check in the commit hooks and scripts/run_tests.sh; --selftest plants a row changed in one copy, a digest left behind and a terminal missing, and tests/firmware/test_pin_table.py runs both and holds docs/carrier-board.md's two rail tables to the rows, row for row). test_pinmap.cpp calls every rule at run time, so the report sees each decision both ways (pinmap.h is at 100 % of its lines, branches and MC/DC conditions with no exclusion), and prints firmware/test/native/golden/pinmap.vectors, every role on every number from -1 to 50, every pair of roles on one GPIO, every address byte, the clock's edges and 2,000 seeded maps, each with its verdict, which it compares with the file in every run; every other copy of the rules (the simulator's, the panel's) is held to that file. A change of the table or of a rule writes it again, make -C firmware/test/native vectors, and shows its verdicts in the diff.
One reader of the table (FW-30): scripts/scpi_table.py reads kCommands from console.cpp, each entry's header, refusals, most parameters and handler, and refuses a row it cannot read whole rather than skip it. Every guard that needs the command set reads it there: the sweep's, the heap and golden sessions', and tests/firmware/test_scpi_doc_matches_table.py, which expands the notation of docs/scpi.md's command reference ("How the **Command** column is written") and requires the two sets of headers to be equal, flags and parameter counts included; a planted extra header and a planted missing one must fail it.
The native bridge (FW-30): make -C firmware/test/native bridge builds build/bridge (bridge.cpp), a process that boots a Bench with the device's whole TRACE ring and joins its UART0 to the standard input and output, byte for byte, its virtual time following the machine's clock. A host tool talks to the firmware's own console through it where there is no meter, and the host client's conformance suite does (KLEIDOS_METER_NATIVE_BRIDGE names the binary): host/tests/conformance.py asks the simulator and the firmware every query they share, every command that takes a parameter with none, a word, a number past any range, a quoted string and a negative number, and the command errors a client meets first, and, from 0.18.0, a pin map applied, put back (a wrong SDA, a wrong ALERT, an address nothing answers at), refused (a rule, a relay off its rest, a capture) and defaulted, and every count and conversion time of the averaging override on the three profiles that take it at 50 kHz, 400 kHz and 1 MHz, and requires the same answer of both in form, report keys and error codes, and in the pin map's and the override's cases byte for byte, the errors' texts included (FW-08 of 0.18.0, which found the simulator judging an override by one read where the firmware asks for twice a sample's reads, taking one over 200 ms, calling relays moved back to the rig's pins verified and a default map applied with APPLy stored, and wording the boot's two 117s in its own way, all fixed there; FW-31, which found the simulator's reports short of keys, its MEASure closing no capture and 96 of 190 refusals with another code, all fixed there). It is a fresh instrument at each start, ends two virtual seconds after its input does, and exits 1 when one of the checks every host case ends with failed. tests/firmware/test_native_bridge.py holds what that suite relies on; it skips without the binary, and scripts/run_tests.sh, which has just built it, sets METER_BRIDGE_REQUIRED=1 so that it fails instead.
make -C firmware/test/native bridge
printf '*IDN?\n' | firmware/test/native/build/bridge
Reading the report
Suites. One row per suite: the firmware's (one per area: scpi, relay, sampler, console, measure, route, cal, edges, …), the host package's and the guards'. A failed test is listed by name under the table.
Skipped tests. Every reason a test gave for being skipped, how many gave it, and where those tests run instead (above).
Firmware coverage. One row per source file, from LLVM's own figures:
- Lines — statement coverage.
- Branches — every branch of every condition taken both ways. This is the decision coverage, and it is gated (below): LLVM instruments MC/DC only for decisions of two or more conditions, so a single-condition decision is covered by nothing else.
- MC/DC — modified condition/decision coverage, as LLVM implements it (short-circuit, "masking" MC/DC): for every decision of two or more conditions, each condition counts as covered when the tests hold a pair of runs in which that condition alone flips the decision, the conditions short-circuited away being don't-cares. Decisions of a single condition are covered by the branch figure, which the decision-coverage gate holds.
- Justified — uncovered MC/DC conditions that mcdc_exclusions.toml explains, and MC/DC with justified the figure counting them. The target is 100 % in that last column for every module, and the gate holds it there.
ina228_regs.h and the .h rows show lines without MC/DC: their functions are constexpr and mostly evaluated at compile time (each static_assert is a test of its own that the build already ran).
Host coverage. Statements and branches per module of host/kleidos_meter, from coverage.py with branch = true, and each module's floor: the smallest share of its branch sides the gate allows (host/branch_floors.toml, FW-31). The panel's are at 90 % or more, the rest at what was measured; a floor only rises (tests/ci/test_host_floors.py reads the file's history), a module well over its floor is a note that asks for it, and a module with no floor, or a floor with no module, fails the gate. The suite's total has a floor of its own, fail_under in host/pyproject.toml.
MC/DC conditions not shown independent. Every remaining gap: where it is, the decision, which conditions are shown (a check mark in the report) and which are not (a cross), and the written reason. Two kinds are accepted:
- infeasible — no input reaches the missing combination: the operands are coupled, or an earlier guard already decided it;
- defensive — a guard against a state the code never produces, kept because the firmware must not trust its callers there, and untestable by design.
There are none of either since FW-07 (2026-11-25: 504 of 504 MC/DC conditions, 3,174 of 3,174 branch sides and every line of firmware/src, as LLVM 23.1.1 counts them), so a new entry is the first one. Before one is written, the order is: remove the operand or the test an invariant makes dead (the invariant stays, stated where it holds); reach it through a unit-level entry of the harness (a public function called with a value the line cannot give it, as relay::pathName() with one outside the four); and only then keep it, with the static_assert or the harness check that proves the invariant and a reason that cites it. Two of the reasons FW-07 read were wrong or stood for something to fix, which is why a reason is the last resort: "a judged plan starts with K1 closed" hid a lead check that passed with K1 stuck closed (docs/scpi.md, error 104), and "no handler composes a unit that long" kept a second way to write a response that no test had ever run.
A gap with no entry is printed as UNJUSTIFIED, the gate fails, and the fix is a test or, if it truly cannot be reached, a reasoned entry. Entries are matched by file and by the decision's text, so moving a line does not orphan its reason, and rewriting the decision does. Each entry also names the conditions it justifies (conditions, 1-based, left to right as the report's column of marks shows them): a decision that loses the pair of one more condition is a new, unjustified gap, not one the old reason covers. An entry that no gap uses is printed as a note, not a failure, because one LLVM release may not instrument a decision another does.
Branch sides not taken. Every side of every branch no test took (if, a loop's test, ?:, each operand of && and ||), with its reason when branch_exclusions.toml gives one (sides, kind and reason, matched by file and the branch's text as the MC/DC entries are, and by an optional condition that names the one operand of an && or || the reason is about, so the line's other operands keep their own gaps; tests/firmware/test_branch_gate.py holds every entry's decision and condition to a current line of firmware/src). The gate fails when more sides are left without a reason than the file's baseline, which was a ratchet until every side was a test or a reason. The baseline is 0 untaken branch sides: since FW-29 a change that leaves a side untaken adds its test or its reason in the same change, and since FW-07 of 0.18.0 there is no reason either (30 sides by LLVM's count had one). A condition that is the literal true, a task's while ( true ), is no branch: the compiler folds it, LLVM's summary leaves it out of its count, and so does the gate (FOLDED in scripts/test_report.py; its JSON export lists the region with nothing to tell it by but its text). FW-07 removed what could go only one way: the operands a partial response, a begun console, a parsed string or a begun sampler decide (wirePartial_ beside the units counted, relays_ and the sampler's two pointers tested for null, a quote's bound), an acquisition's own flag on the stream it alone consumes, the refusals a command's flags have already made (SENSe:PROFile, and ABORt, which now closes the window it has just halted through Sampler::closeCapture()), and the switches whose implicit default no enumerator reaches (the names are tables, the rest chains that end in an else); it wrote the response buffer as one loop that fills, flushes and goes on, so that a unit of any length is the case every overflow runs; and it took what is left: the names of a value outside their enumeration, the period of a MODE that skips the shunt, a capture whose shunt reads 0, and each class of a sampler refusal (samplerRefusalCode()). FW-29 (firmware/test/native/test_sampler_sides.cpp and the parser's cases in test_scpi.cpp) took the last 24, the sampler's, the driver's and the parser's, each by a test that says by value what the instrument does there: DIAGnostic:REGister? on every register at its own width, the range switch's discard at TRACE's 280 us (a word that converts neither the bus nor the die), the die's age at the instant it is noted, the ALERT interrupt that gives the semaphore to a sampler not waiting for it (the harness's xSemaphoreGiveFromISR() reports a wake only to a task blocked on it, and counts each portYIELD_FROM_ISR()), the pacing probe of *TST? after a stop the sampler did not acknowledge, a null window that cannot start and one whose stop is not acknowledged, a threshold mark that meets a full stream queue, and the parser's leading spaces; the parser's own bound at 2^63 is a static_assert instead, since no path reaches past it (a product past it is refused before, a quotient is no larger than an 18-digit mantissa). A stall of a task by name (World::taskStallsUs, a preemption that holds nothing) is the harness's knob for the sampler that does not acknowledge and the console that stops reading. It was 24 after FW-28, 54 after FW-27, which classified all 88 the tree left untaken, made the ones that could only ever go one way compile-time facts (static_asserts over the profile table in sampler.cpp, that every profile converts the shunt, has a positive period of at most a second and, when it streams, carries every channel inside the stream's share of the line; a constant for DIAGnostic:WATChdog?'s panic; a table for the channels CONFigure streams, which took the dead Function::Charge label with it), and wrote a reason for the 26 that stay, each infeasible (an exhaustive switch's implicit default, a coupling an earlier guard or a command's flags decide) or defensive (a null or a zero the code never produces). FW-28 (firmware/test/native/test_console_sides.cpp) took the console's 12 and its commands' 18, 28 by a test that says by value what the instrument does there and two by a written reason (35 entries in all): the console's (a lead cycle that falls due while the loop works, a stream and a mark behind a partial response, a stream without current, the QUEStionable CURR bit, the OPERation summary in *STB?, *RST without a stop acknowledgement, pace_fallback in SYSTem:STATus?, relay orders with the relays unavailable, a refused relay option; a unit as long as the whole response buffer, which no handler composes, is the reason) and the commands' (a die read that fails at a capture's start, a range switch whose conversion flag comes late, the apertures of the profiles that convert only the shunt, the charge overflow, a sample still queued when a measurement stops, FETCh and FETCh:STATistics? under a running capture, FETCh:HEADer? before any capture, the relays unavailable in a header, nulled_r1, the alert flags each way, a second part on the bus; alatch=0 in a header, which no capture leaves, is the other reason), with an end-to-end case from a blank store to q=cal and then q=stale. It was 88 after FW-26, which moved console_commands.cpp onto the bounded writer and took the last of snprintf's failure and truncation sides with it, and with them the dead conversions (scpi::formatScaled(), scale::formatThousandths()) and the null checks a view made unnecessary (102 after FW-25, which moved console.cpp and took three more; 105 after FW-24, whose bounded writer took the place of the formatting branches snprintf left untaken in four modules and whose golden transcript (its error and fault sessions) took three more sides; 114 after its first commit, 117 after FW-22, whose parser on views and character table left one side fewer untaken; 118 after FW-21, which wrote the reason for a side the rewrite of an && left on its own if (sampler.cpp's null device) and for the constant condition of each while ( true ) that replaced a for ( ;; ); 119 after FW-19, whose every-command session took one more; 120 after FW-16, 122 after FW-12, 123 after FW-11, 126 after 0.16.4, 127 after 0.16.0, 128 after 0.15.0, 129 after 0.12.0, 130 after 0.11.0, 131 after 0.10.0, 132 after 0.9.0, 134 when the gate was added, 161 before the tests that came with it); at 0 it stays there (the gate prints the count a change leaves, and tests/firmware/test_branch_gate.py holds the file and this page equal). A planted untaken branch failing the gate is that test's own case.
What the report cannot see. A region the host build preprocesses out is not instrumented: LLVM leaves it out of the report instead of showing its decisions as untaken sides, and its file reads 100 %. So firmware/src compiles the same on both builds: no #if chooses code by platform, and the census's backtrace walk (heap_monitor.cpp captureCallers()), the one device-only block until the review of 2026-11-24, is built on the host against the harness's walk over frames a test scripts (sim::World::backtrace). tests/firmware/test_host_compiles_every_decision.py lists each conditional left, with what it chooses and why no decision hides behind it, and fails on any other. Nor does it see a function that runs only at compile time: a static_assert or a constexpr variable's initializer evaluates it in the compiler, so its decisions have no regions and its lines read as never run, while a static_assert proves only the result it asserts for the tables of today. Such a function takes its tables as parameters and a host test runs it on planted ones, each refusal shown: relay.h's detail::parkedPinsSound() (a reserved pin parked, a pin twice, a wired relay's pin parked, an unwired one's left floating, in test_relay.cpp, since the review of 2026-11-24). One that can only ever run there is consteval (crc32.h's makeTable(), chars.h's, the command table's Console::takes()), which leaves no run-time code to read as never run (LLVM 22 still lists the last, a class's member, as one function and three lines never run; 23 lists none), and is held by value: every CRC the tests check against a known answer reads the table it built.
The line-by-line view of every decision (which test vectors ran, which conditions are shown) is build/test-report/native-html/index.html, LLVM's own HTML.
The figures of record: 0.18.0
Taken on 2026-11-26 from the release tree (meter-next/integration at 90fafb7 with the run of record's bench images; firmware/src is git tree ca4ba6e5b7c5063b, the one the bench's image of record was built from), on the Mac, LLVM 23.1.1, Python 3.13.5 with host[dev,browser] and its Chromium:
- scripts/run_tests.sh: 4,085 tests, 4,038 passed, 47 skipped, none failed, exit 0: 537 firmware cases in 42 suites on the simulated board, all passed; 2,552 of the host package passed (its panel's page in Chromium included) and 949 guards. Every one skipped names where it runs: 46 that talk to the meter (--run-bench), 45 guards and the host package's one bench test, and one guard that needs the Kleidos firmware repository beside this one; the guards that read a device build ran, the clone's build being there.
- The firmware, as LLVM counts it: 8,599 of 8,599 lines, 4,896 of 4,896 regions, 772 of 772 functions, 3,204 of 3,204 branch sides and 514 of 514 MC/DC conditions, every module of firmware/src at 100 % of each; mcdc_exclusions.toml and branch_exclusions.toml hold no entry, and the branch baseline is 0.
- The host package, as coverage.py counts it: 8,529 of 8,529 statements and 2,474 of 2,474 branch sides, every module at 100 % and at its floor of 100 % (host/branch_floors.toml). The page's pure modules, chart-math.js and pins-math.js, at 100 % of their functions and blocks as Chromium's precise coverage counts them (477 and 178 blocks, host/js_floors.toml, no block named).
- Mutants: the firmware's 108 (scripts/run_mutants.sh --firmware, run under the bench's memory guard: 108 killed, 0 survived, 0 errors) and the host package's 34 (--host, the page's included, in the same run_tests.sh: 34 killed).
What these figures do not reach, and why:
- The page's drawn modules (chart.js, pins.js, live.js and the rest of host/kleidos_meter/panel/static/js/) are measured and held to floors under 100 % (host/js_floors.toml): on 2026-11-26 pins.js 98.06 % of its blocks and noise.js 93.22 %, each block they leave named with why (a guard for an answer or a schema serve never sends, a page event before the first answer); chart.js 85.58 %, live.js 81.82 %, status.js 81.72 %, views.js 94.44 % and the eleven others between 58 % and 94 %, whose untaken blocks (pointer drags, wheel zoom, refused requests, storage that throws, an older image's answers) the gate prints and no test yet reaches. Their logic that can be pure is in the two pure modules.
- What only the device build or the bench can run: the image gates (radio, retired drivers, heap objects and reachability, IRAM hot path), which run in CI's firmware job over the built image; and the hardware, which the bench suite and the run of record cover (The bench suite). Two behaviors of 0.18.0 were never seen on the rig: the boot-time fallback of a stored bus whose probe fails (src=fallback) was provoked once by hand, not by a bench case: on 2026-11-26 (ELF f7e84874d9376d08) a record of the stored map with SDA on GPIO18 was written over the pin log's two sectors (0xB000) with esptool, its encoding first checked byte for byte against the record the instrument had just saved, and the reboot came up src=fallback on the default bus with one 117 (the stored bus (sda=18 scl=5 addr=0x40) did not answer: the default bus is back (the record is kept)), *TST? 0, q=cal, no allocation, the calibration log's sectors unchanged and the record kept, until SYSTem:PINS:DEFault and a reboot brought src=default back; the relays' check after a pin change (verified=1 from check=ok) needs a DUT that draws 2 mA, and the rig's sleeping T-Deck never has; and the LCA717's off-state leakage beside the shunt, stated from its data sheet (the Relay 2 Click guide), was not measured.
- Functions that run only at compile time read through their static_asserts and the host tests that run them on planted tables (What the report cannot see).
Mutants
Coverage says which decisions a test took, not that a test would notice the code there going wrong. scripts/run_mutants.sh asks that directly, of the firmware and, since FW-07 of 0.18.0, of the host package: each scripts/mutants/<name>.patch is one small wrong change to firmware/src (a bound moved by one, a note deleted, a flag that never rises), named and described on its # Mutant line, and the script applies each to a copy of the firmware, rebuilds the two host test binaries there (no sanitizers, warnings off) and runs them. A mutant is killed when a test fails; one that passes has survived, and the script exits 1 on any survivor or any patch that no longer applies or builds. scripts/run_mutants.sh F2b FW29-ese runs those named, --firmware and --host one list, --package and --page the host's that no browser judges and those one does, and no argument both lists; a list named that holds no patch is an error. Each patch of the mutants folder of host/ is a wrong change to host/kleidos_meter, judged by the one command its # Kill: line gives, run with sh -c at the root of a copy of the checkout (its tracked files and the new ones) on the Python that PYTHON names (host/.venv's by default), with no bytecode written: the command must pass on the copy as it is, run once for each different command, and end with exit status 1, tests that failed, with the patch applied. Any other status (pytest's 2, tests that could not even be collected), a command that fails on the unmutated copy and a patch with no # Kill: line or with two are errors, so a kill is always a test that noticed. The runner's self-test (tests/firmware/test_mutants.py) plants a small checkout with a host mutant that is killed, one that survives, one that does not import and each of those faulty patches, and requires each outcome by name. A firmware mutant takes about half a minute a mutant (16 minutes for the list on the Mac it was written on, when it was a third shorter), so it is run by hand and before a release, not by scripts/run_tests.sh, whose mutant step and CI's panel job run the host's in every run; what every test run holds of the firmware's (tests/firmware/test_mutants.py) is that every patch still applies to the sources, changes only firmware/src and says what it breaks, and that the tests audit's firmware mutants (F1 to F11 and F2b, 2026-11-22) are all listed. The list is those, FW-28's (the console's decisions), FW-29's (the sampler's, the driver's and the parser's, and a window bound at its edge) and FW-30's (the rules the sweep holds of every command: a parameter too many, a missing one, a header's short form, flag C) and 0.18.0's FW-01 (the pin map's rules: two roles on one pin, GPIO45 admitted, ALERT on GPIO39; the build's static_asserts refuse GPIO45 for every role, so that mutant hides from constant evaluation and asks whether the run-time tests the vectors rest on catch it too), and FW-02's (the pin map's wire contract: a refused option that leaves its pin staged, SYSTem:PINS:PENDing? judging the live map instead of the staged one, address 0 taken as a scan), and FW-03's (the second record log: both logs sharing one state, a write that runs from one log's sectors into the other's allowed, a record of another board table taken, an older stored map run when the newest record is refused, a flag byte of 2 taken, padding judged by its first byte alone, the pin map log mounted on the calibration's sectors), and FW-07's (what FW-07 rewrote to close the last coverage gaps: a response unit cut by a flush that repeats, loses or overwrites bytes, an ABORt that computes nothing, the class of a refusal, a lead that conducts while open, the half test of the lead check, a doubled or a lone quote in a string, ALATCH read off another bit, a clock change that probes, the sinks' names and which of them streams, the charge reported as the bus functions are, a MODE without the shunt timed as with it, an evidence or a path outside its names), and FW-05's (a map applied: saved before it is proved, not put back, its old pins not parked, a relay's old pin parked toward the level that energizes it, an apply taken under a capture, under a window not closed or with a relay energized, the error queued twice, moved relays left verified, the range or the running clock not put back, ALERT's old pin left with its interrupt or ALERT not moved, DEFault put back when its proof fails or kept when the bus did not move), with FW-04's of the boot from the map; a change that moves a mutant's lines writes its patch again.
The move to ESP-IDF 6.1.1 (2026-11-28) added five, over the static homes of that release's new startup objects (startup_memory.cpp): IDF61-plainthird (a third plain mutex given a slot past the two), IDF61-semitems (a queue of one item of any size taken for a binary semaphore), IDF61-semcount (the binary semaphores' count never rising, so a third is made over a slot in use), IDF61-plainkept (a mutex the kernel refused still spending its slot) and IDF61-onecount (recursive and plain mutexes sharing one count), each killed by test_startup_memory.cpp's slot cases or its wrap sequence.
The review of 2026-11-24 added RV-uartstall (a UART write that kept its stall clock running after the FIFO took bytes, so two short stalls added up and cut the record), killed by test_uart0.cpp's two stalls that each clear inside the budget and together exceed it.
The review of 2026-11-26 added three: RV-closeaddr (a bus closed by a move keeping the old map's pinned address, which a bring-up whose scan finds nothing then reports), killed by test_console_pins.cpp's defaults after a map pinned to 0x41 with no INA228 left, which must read addr=0x40 chip=none; RV-restcheck (an apply that moved a relay never put back for what the shunt reads at rest), killed by the flipped active levels of Relay 1 and Relay 2 on their own wires; and RV-sixteenth (the null path's K2 step judged by its upper bound alone), killed by the relays swapped onto each other's wires with matching levels.
The audit's eight survivors are killed by value: F2b (a TRACE capture's closing boundary no longer notes the die) and F2 by a capture that closes or opens 6 °C warmer and must read q=stale (test_sampler_sides.cpp; tests/firmware/test_meter_quality_has_evidence.py stays as a backstop that reads the code with its comments removed), F3 (READ:TEMPerature? answering the voltage) by READ, FETCh and MEASure checked against the values of the simulated circuit instead of being non-empty, F9 (the shunt's upper end refused) by every window of docs/scpi.md at min-1, min, max and max+1, and F4, F5, F7, F8 and F10 by FW-28's cases.
What the tests found
Writing them turned up three defects, fixed in the same change (and the build legs above, three more):
- scale::integerSqrt() overflowed its first Newton step at UINT64_MAX and divided by zero (UBSan).
- Parameters::unsignedInteger() answered 1E3 with -120 instead of the -104 (data type) the page promises, because the E was taken for a hex digit first.
- relay.h had one energize level for all four inputs, which the Relay 2 Click (active high) cannot share with the HW-316 (active low): now per channel (docs/relay2-click-wiring.md).
- FW-29's window edges: *ESE, *SRE, STATus:OPERation:ENABle, STATus:QUEStionable:ENABle and DIAGnostic:REGister? refused a number past their window, and TRACe:DATA? a count of 0, as an illegal value (-224), where every other window, and docs/scpi.md, says -222; they answer -222 now.
What the host tests do not replace
The bench: the real INA228's conversions and noise, the CH343 line at 6 Mbps, contact bounce and coil timing. The ESP-IDF build itself (pio run --project-dir firmware -e meter, the one image) runs in CI's firmware job and on the bench, and the gates over the image follow it there: the object, IRAM, radio and retired-driver gates, and the reachability gate (FW-19, scripts/check_heap_reachability.py), which builds the linked image's call graph from the relocation records the link keeps (-Wl,--emit-relocs) and fails when any allocator is reachable from a function of ours; its self-test plants each case in an image it writes itself, and tests/firmware/test_heap_reachability_gate.py runs it, holds its decoder to the toolchain's disassembly and, on a built tree, holds the deny list to the graph (each listed entry point the image links reaches an allocator, neither made-safe call does). Reading an image needs pyelftools (0.33, which CI installs; the tests skip without it); the job then changes firmware/version.txt and builds meter again in the same tree, and fails unless the image reports the new version (scripts/app_version.py reads it from firmware.bin): PlatformIO re-runs ESP-IDF's configure step, where the version is read, only through firmware/scripts/meter_version_reconfigure.py (tests/firmware/test_version_reconfigure.py). The relay and calibration procedures in docs/rig-wiring.md, docs/relay2-click-wiring.md and calibration/README.md are the hardware tests, and their results are filed as records.
The bench suite
tests/bench holds the tests that talk to the meter itself (FW-07). They are marked bench and skipped unless --run-bench is given (tests/conftest.py), so scripts/run_tests.sh and CI never reach for hardware; the suite's support (tests/bench/bench_support.py: the bench lock, the line, the sweep and its comparison) is tested without it by tests/bench/test_bench_support.py in every run.
host/.venv/bin/python -m pytest -q -W error tests/bench --run-bench \
--meter-port "$KLEIDOS_METER_PORT" --bench-lock <the bench's lock file> [--bench-record sweep.json]
The port and the lock have no default (--meter-port or KLEIDOS_METER_PORT, --bench-lock or KLEIDOS_METER_LOCK): the suite refuses to guess which device is the meter or whose lock it is. The lock is the bench's convention, a file holding one live process ID: the suite waits up to ten minutes while another live process holds it, takes over a stale one, writes its own and removes it at the end; a caller that already holds it for the run names that process in KLEIDOS_METER_LOCK_PID. Opened without a reset (RTS released before DTR), the line is closed with the instrument back at rest (*RST, FORMat TEXT).
The heap sweep (test_heap_sweep.py) reboots the meter through the carrier's auto-reset, lets the boot settle for 1.5 s and reads DIAGnostic:HEAP?'s four counts by phase, then runs every command family of docs/scpi.md (the common commands and *TST?, SYSTem, STATus, SENSe, a range switch, SAMPle, FORMat and TRIGger, CONFigure to FETCh, a capture on each profile, a mark, a partial ring dump in both formats, two I2C clock changes, the calibration reads, two calibration saves that change the stored tag and put it back, a null on the null path, the DIAGnostic queries, the bypass relay and a refused spare, 500 SYSTem:STATus?, *RST), each followed by another DIAGnostic:HEAP?. The boot's counts and what each family adds to the two since-main counts must equal tests/bench/heap_expectations.toml, an error a family may not queue fails it, and the pre-main counts must never move. From FW-17 every report, the boot's and each family's, must also read allocs_since_main=0 frees_since_main=0 (and allocs_after_init, frees_after_init, the same window, 0 with armed=1), with no exemption. Until FW-16 a step whose count was ESP-IDF's to vary (an NVS write, by the state of its pages) could be marked a ceiling; from FW-17 the file refuses the mark, and every count is exact. The file only falls: test_bench_support.py reads every committed version of it and fails a count above an earlier one, and each zero-allocation change lowers it in its own commit. Nothing in the sweep leaves the DUT without its supply (the lead opens only on the null path, with the bypass closed first) or writes a shunt value, and kleidos-meter calibration verify still answers applied after it. --bench-record writes what was measured, with the image's fw and elf, for a change that lowers the file.
The heap session of record (test_heap_session.py, FW-32, with --bench-long): the claim on one boot, where the sweep holds one family at a time and the other long cases run on boots of their own. The meter is rebooted, every step of the sweep runs (the same SWEEP, the save included) and, before its last *RST, a full TRACE ring is captured and dumped whole, RAW and then SCALed, each held to its CRC-32 and to the ring's 1,048,576 samples. DIAGnostic:HEAP? must read the since-main keys at 0 after every step and at the end, with the pre-main counts D1's, on the same boot throughout (the boot instant of SYSTem:HEALth? unmoved), no watchdog stall and the console's stack above its floor. About ten minutes; --bench-session-record writes the boot's and the end's report, the ring's statistics and the dumps' sizes. Its run on the release image is the run of record of docs/misra.md.
A damaged dump is the line's (2026-11-24, 0.17.0's image). The 6 Mbaud line has no flow control, and a long TRACe:DATA? now and then reaches the host damaged: bytes lost, so the block never ends, or a block of the right length whose CRC-32 does not match. Of 56 SCALed dumps of a 143,000-sample ring (5.0 to 5.2 MB each, 10.5 to 10.7 s, about 480 kB/s) 53 arrived whole, as did 20 of 20 RAW dumps of it (0.5 MB each); a full ring's RAW dump (3.8 MB) was damaged in one session of three, and its SCALed one (36.6 MB, about 76 s) the first time it was asked for in both sessions that reached it, whole the second time. One damaged block was compared byte for byte with a good one: one 64-byte block arrived 320 bytes early, in the place of a 64-byte block that was lost, and another 64 bytes were missing where it belonged. The instrument cannot have sent that: uart0::write() places a row's bytes in order in a FIFO of 128 bytes, and a byte 320 ahead had not been written yet. What was damaged was between the UART's pin and the reader (the CH343 or the host's driver: a buffer of either that the host did not empty in time, inferred, not traced), and the block's CRC-32 is there to find it (docs/architecture.md §3.9). bench_support.dump_whole() asks again, at most three times, and the session's record keeps every damaged attempt; the panel's recorder asks again once and keeps a block that fails twice as trace.damaged.
On 2026-11-26, FW-09's candidate image of 0.18.0 (ELF 9b23c01cda4eb3e9), the line damaged the full ring's SCALed dump in all three attempts of one session, twice never ending the block and once with a CRC-32 that did not match, while the host also ran scripts/run_tests.sh, the commit hooks and other builds; run again with the host otherwise quiet, both dumps of the session arrived whole at the first request. A long dump is best asked for on a quiet host.
On 2026-11-28 the overrun case of test_uart_bench.py (a 1.36 MB SCALed dump of a 10 s TRACE capture, a 4,096-byte burst sent 0.3 s into it) timed out at 120 s in one run of the bench suite on the ESP-IDF 6.1.1 image, a block that never ended, and in one of twelve runs of the case alone. Read raw, the same dump arrived damaged in 3 of 20 runs on that image without the burst and in 4 of 20 on main's ESP-IDF 6.0.3 image minutes later (twice 63 bytes lost, so the block never ended, and twice a block of the right length whose CRC-32 did not match, each with rows from about 320 bytes further on in the place of the ones that belonged there), with the host's load average between 9 and 170 from other builds: the line's damage again, neither the overrun's nor the release's. The case had held its dump to the closing row alone, so a block of the right length passed it damaged and one that never ended failed it; it now asks with bench_support.whole_block(), which dump_whole() is built on, holds the block to its CRC-32 and runs the scenario again, at most three times.
The watchdog (test_watchdog_bench.py, FW-11): DIAGnostic:WATChdog:TEST stops the console's check-ins, and the chip must reset between 3.9 and 7.1 s later (the 5 s timeout plus the round's longest interval, measured to the boot instant SYSTem:HEALth?'s uptime_us gives, whose clock starts after the ROM and the bootloader), with reset=task_wdt, no coil found energized, both subscriptions back, the boot's pre_main_ counts and nothing since app_main() (FW-17). With --bench-long it also holds that a 600 s idle and a full TRACE ring, captured and dumped in RAW, keep the same boot, that the full ring and its dump leave both since-main counts at 0, and (FW-18, with PSRAM in the memory map only) that the dump's opening row counts the whole ring and the block matches the CRC-32 its closing row carries (about fifteen minutes); without it those two cases are skipped with that reason. The test waits past the reset before it asks anything, because the ROM prints its boot banner at 115200 baud, which the 6 Mbaud line reads as a run of NUL bytes.
The I2C bus (test_i2c_bench.py, FW-14): the acceptance 0.16.5 filed for ESP-IDF's driver, held on the own I2C master: *TST? answers 0 in 100 of 100; 20 scans at each of 400, 100 and 50 kHz list 0x40 alone, each followed by a read of MANUFACTURER_ID; 200 rounds of MANUFACTURER_ID, DEVICE_ID and DIAG_ALRT's MEMSTAT read right; each of the four profiles (BURST at 1 MHz) captures 15 s of statistics with no read error, no dropped sample and no stale edge, STATE and SLEEP paced by the ALERT pin, and pace_err_ppm inside the band the file states for it from the filed records (docs/architecture.md §3.4, §5.2); the null path's STATE floor is no noisier than the 19.0 µA filed with the radio off (§5.2), as far as one capture can tell (three standard errors of its estimate, 0.6 % each; §2.6); and three clock changes leave every count of DIAGnostic:HEAP? as it was. About fifteen minutes.
The pin map (test_pins_bench.py, FW-05): SDA, SCL, the pair swapped, an address nothing answers at and an ALERT pin with no wire are each applied and put back with one 117, the live map, *TST?, q=cal and the scan as they were; Relay 1 is moved to GPIO16, where nothing is wired, and the DUT's current must read the same through the shunt with GPIO7 parked high and, after a reset, low, then it is moved back and a null path run (check=ok verified=1 with a DUT that draws 2 mA, check=unverified verified=0 with one that does not); an address and a clock stored survive a reset, and SYSTem:PINS:DEFault brings the rig back; DIAGnostic:HEAP? counts nothing after any step. Each relay is also moved to a free GPIO and back (Relay 1 to GPIO16, Relay 2 to GPIO17, no wire on either): the pads read right, the DUT's current reads the same through the shunt before and after a reset, and a null path on the moved relay must be refused with the check its missing contact fails (104 for the lead, 103 for the bypass) when the DUT draws the 2 mA a check needs. Under that floor the instrument does not judge the steps, so the moved lead's null path forms check=unverified (the rig's bypass closes, and the lead on GPIO16 never opens) and the moved bypass is given none: it would open the lead with nothing closed beside it (“The pin map” in the SCPI command set). Whatever fails, each case ends on the default map. On 2026-11-25 (ELF 0e07120e923709dd) all seven cases then in the file passed (docs/architecture.md §2.7); on 2026-11-26 (ELF f7e84874d9376d08, the integration of 0.18.0) all nine passed, with the T-Deck asleep behind the shunt at 42 to 50 µA, so every null path read check=unverified and no relay could be verified by one.
The averaging override (test_averaging_bench.py, FW-06): STATE streams 15 s at AVG 16 and at AVG 64 at the period its word gives, paced by ALERT, with no read error, no dropped sample and pace_err_ppm in STATE's band, its header's keys its own, and off again at 1,152 µs; the null path's standard deviation falls from AVG 1 to 16 to 64; the six periods next to the refusals' limits are kept, 15 s each; the five past a limit, and BURST, are refused with their reason and change nothing; *RST turns every override off; DIAGnostic:HEAP? counts nothing. One stale edge is allowed, the start's (docs/architecture.md §3.2). About four minutes. On 2026-11-25 (ELF 512499c7a306c77a) all fifteen passed. On 2026-11-26 (ELF f7e84874d9376d08) they passed again, the null path's standard deviation 18.9 µA at AVG 1, 4.82 µA at AVG 16 and 2.86 µA at AVG 64; two kleidos-meter capture --profile STATE --seconds 10 runs of the T-Deck asleep, the second after SENSe:AVERage at 16 on STATE, read 18.88 µA of standard deviation around 51.02 µA (8,727 samples, noise_reduction off in the run's meta.json) and 4.67 µA around 50.83 µA (545 samples, on, count 16, 1,052 µs, 18,432 µs per sample), the factor of four sixteen conversions should give to white noise.
The run of record of 0.18.0 (2026-11-26, ELF 80a257970e934ff6, built from 90fafb7, firmware/src tree ca4ba6e5b7c5063b, the tree of the tag; docs/misra.md, "The run of record: 0.18.0"): 70 of the suite's 71 cases passed with --bench-long in 37 min 51 s, the heap session's RAW and SCALed dumps (3,760,443 and 36,583,759 bytes) whole at the first request and every since-main count 0 at the boot and the end; the one failure, test_a_relay_moved_off_its_wire_fails_its_null_path_check_and_comes_back[relay1], read the DUT's current at 21.83 µA after the meter's reboot with Relay 1 stored on GPIO16, against 43.02 µA before, and passed in the pin map's run before the suite and in three runs after it on the same image, its cause not found; the panel's bench test passed 9 of 9, its readout's mean 43.24 µA against FETCh:STATistics? 43,242.86 nA. FW-09's candidate (2026-11-26, ELF 9b23c01cda4eb3e9, before the review of that day changed the firmware): 68 of the suite's 69 cases passed with --bench-long, and the heap session, whose full ring's SCALed dump the line damaged three times in that run, passed alone on the same image; the panel's bench test, its page included, passed 9 of 9. The integration's run (2026-11-26, ELF f7e84874d9376d08, built from the same firmware/ tree, 89bb825049a9, in the integration's own clean worktree): all 71 cases passed with --bench-long in 38 minutes, the heap session's RAW and SCALed dumps of the full ring (3,773,672 and 36,596,112 bytes) whole at the first request with the host otherwise quiet, every since-main count 0 at the boot and the end and the console's stack at 5,792 bytes free; the panel's bench test passed 9 of 9, its readout's mean 42.170 µA against FETCh:STATistics? 42,171.845 nA.
The calibration in the flash log (test_calibration_bench.py, FW-16): 20 calibration saves that each change the stored record (the tag altered and put back) leave every count of DIAGnostic:HEAP? as it was and queue no error; one more altered tag survives a reboot through the auto-reset, the tag put back survives another, CALibration:DATA? ends as it began and *TST? answers 0, so kleidos-meter calibration verify still answers applied. On FW-16's image (ELF f30fed2a5e870da3, 2026-11-23) it passed, and so did the heap sweep with every count since app_main() at 0 allocations and 2 frees from the boot to its end. On FW-17's image (ELF 41f60a8bc5d49b06, 2026-11-23) the whole suite passed with --bench-long, every count since app_main() at 0 allocations and 0 frees from the boot to its end, through the watchdog's reset and a full ring's dump, and the console's stack kept 6,012 bytes free after the sweep and the dump, against 5,160 on 0.16.6's image (ELF 75603e5b2c364645) after the same sweep and 5,564 on FW-16's; the full ring's dump timed out twice in the client (600 s, a block never completed) while the device's dump arrived whole in 12 s when read raw and in the client on every other run, an intermittent loss on the host's side, and the test passed when run again.