#!/usr/bin/env python3 """Route 140's census, take 4. Two corrections to take 3, both mine. (1) Take 3 called every occurrence on a `*-sha256:` line `self_provenance` and then tested all 882 of them against the file's own head -- but `out-sha256` is the digest of the normalised STDOUT, not of the head, so ~441 of its 443 "failures" were the test asking the wrong question. The two header roles are now separate and each is tested against the thing it names: `code-sha256` against the head (tailfmt.js headText) and `out-sha256` against the normalised stdout (tailfmt.js outputText + normalise). (2) Take 3's comparison test was line-local: `const SHA = ""` on one line and `if (got !== SHA)` on the next is invisible to it, which is how a classifier reports 0. The test is now two-stage: find the 64-hex literal on a non-comment line, take the identifier it is bound to (or the object key it sits under), then look for that identifier in a comparison anywhere in the same file, and quote both lines. Only the resulting `compared_in_code` class is the route's object; `citation` is not, and the header classes are the file's own provenance, which the route explicitly is not asking about. usage: census4.py [--out dir] """ import argparse import hashlib import json import os import re import sys sys.stdout.reconfigure(encoding="utf-8", errors="replace") HERE = os.path.dirname(os.path.abspath(__file__)) RUN = os.path.dirname(HERE) CACHE = os.path.join(RUN, "job128", "cache") LIST = os.path.join(RUN, "job128", "docs-list.txt") EXTS = (".py", ".js", ".mjs", ".sh", ".ts", ".cjs") HEX = re.compile(r"\b([0-9a-f]{64})\b", re.I) COMMENT_LEADER = re.compile(r"^\s*(#|//|\*|/\*|