#!/usr/bin/env python3 """census_row_delta.py -- row-level diff of two doc_census_check.py censuses. WHY THIS EXISTS `tools/doc_census_check.py` prints a census; the number a reader quotes is its row total. When that total moved (the digest-rev fix of 2026-10-16), the sentence that mattered was not the total but the PARTITION: how many rows were REMOVED, how many ADDED, how many CHANGED VERDICT. Two briefs over the same pair of runs reached the same new total with different partitions -- nineteen removed and three added in one, twenty removed and four added in the other -- and both are arithmetically consistent, because the partition is not a property of the two runs alone. It is a property of the two runs AND of the key a row is identified by. A census row is a record (tool, block, line, rev, unit, claim, token, verdict); pick a different subset of those as the identity and you rename a row that only moved position into a row that was deleted and another that was created. So this tool prints the partition under a NAMED key, never a bare "removed N", and `--keys` prints it under every key shape it knows -- so a disagreement about the count can be resolved to the key that produced it instead of argued about. Every partition is then restated with position taken out of the key: a removed row and an added row whose records agree on every field the key holds fixed are ONE row that MOVED, reported separately from a row that was deleted or introduced. Reading a position shift as a content change is the whole defect class this tool exists for. WHAT IT READS Two JSON files written by `doc_census_check.py --json`. It does not run the census and does not judge a census: it cannot see anything the JSON does not carry, and it makes no claim about which census is right. READ-ONLY. The only write path is `--json PATH`; every other mode prints. A STATED LIMIT, NOT AN IMPLIED ONE Rows are compared as records, so a claim whose TEXT moved between blocks (a docstring line re-wrapped, a claim reworded) is REMOVED and ADDED, never CHANGED. `--moves` catches the pure-position case and nothing else; a reworded claim is reported as a delete plus a create and is not paired. The key shapes below are the whole vocabulary this tool has for that; it invents no similarity metric. PASS-THROUGH, because a census leg drives every tool as `