ADR-0038: One report package for generated pages and results tables¶
Context¶
Each study under src/navkit writes a CSV, builds a block of Markdown from it, and splices the block into a documentation page between a pair of marker lines. Each study also has its own command. Nothing shared exists for any of the three steps, so each study carries its own copy.
At commit 3fbef21 (grep, not retyped into a page):
- Page splice. Twenty modules define a function that puts a block between markers. Nine of the ten file-writing copies are the same code;
timing_checkswaps the argument order. Six of the ten text-returning copies check that both markers are present and in order and share one error message; two delegate to a private strict helper;fault_matrixandmismatch_sweepcheck presence only. - Results tables. Fifteen modules define
write_csvorread_csv. All write with plainstr()exceptintegrity.py, which uses fixed formats by design (ADR-0035). Only four read. Two of those return typed rows and two return every value as a string.vo_error.read_clone_csvonly callsread_csv.urbannav_data.write_merged_csvmerges rows by sequence for three studies. - Commands.
cli.pyroutes thirteen sweeps to each module'smain. The flags--csv,--page,--markdown,--seeds,--from-csvand--compareare declared again in each module. Compare is done three ways: through a temporary CSV, by parsing text, and by comparing rows in memory.
The cost is locality. A change to the marker rule or to how a value round-trips through a CSV has to be made in many places, and the copies have already drifted (the presence-only check, the argument order, the string-only readers). The per-page tests re-test the same splice behaviour for each page.
Options¶
(a) Leave the copies. Rejected in the candidate review: the drift is the evidence that the copies do not stay equal.
(b) One package, navkit.report, with three modules, in this order: a page-splice module, a results-table module, then a study-runner module that uses both. Each is migrated by expand-contract: the new module is added beside the old code, studies move over in small batches, and the old copies are deleted last.
(c) One module for all three. Rejected in the candidate review: the study-runner depends on the other two, and a single module would make the first migration batch as large as the last.
Decision¶
One package, navkit.report, with three modules, in this order: a page-splice module, a results-table module, then a study-runner module that uses both. Each is migrated by expand-contract: the new module is added beside the old code, studies move over in small batches, and the old copies are deleted last.
Consequences¶
To be confirmed with the decision. The intended consequences, if (b) is chosen:
- Every committed page block and CSV stays byte-identical in every batch. A batch that needs a golden to change stops and goes to the maintainer.
- The command names and flags of every
navkit sweepentry stay as they are. - The one behaviour change is the error raised for reversed markers in the two presence-only copies.
integrity.pystays outside the results-table module.- The sweeps that write only JSON (
seeds,scenes,outages) keep their own commands. - The per-page tests keep running until the contract step, so a migration batch is checked against the old behaviour.