(Accuracy = Integrity = Quality = Trust) > Progress > Speed > Cost

Adopter tracker-label shapes and the added-line diff check

tools/check_internal_names.py counts four built-in tracker-label shapes in every shipped file and holds each per-file count to the ratchet baseline .aiqt/tracker-label-baseline.toml. An adopter can add its own shapes, and can run an extra check that reports labels on lines a branch adds.

Configuration: .aiqt/tracker-labels.toml

The adopter owns this file. This repository tracks it with no shape and does not ship it. If the file is absent, no extra shape applies. A present file is checked before any shape is matched, and any fault fails closed with exit 2.

format-version = 1
[[shape]]
name = "backlog-id"
regex = '\bACME-[0-9]+\b'
red = ["References ACME\U0000002D123 here."]
green = ["References ACME-next here."]

Replace ACME with your tracker's own prefix. The red fixture writes its hyphen as the TOML escape \U0000002D, so the fixture value is a real label while the text of this page does not match the shape. Before you adopt a shape, run the full gate: a match in any shipped file is a count above the baseline and fails.

  • The schema is closed. The file holds only format-version (the integer 1) and [[shape]] tables, and each table carries exactly name, regex, red and green.
  • name is a lower-case ASCII identifier (letters, digits and single hyphens, at most 48 characters), and names are unique. The baseline key is adopter-<name>, so it never collides with a built-in key.
  • regex is a Python regular expression, applied to each line separately. Letter case follows the regex, inline flags included.
  • red lists fixture strings the shape must match, and green lists strings it must not match. Both arrays are nonempty, and each fixture is one nonempty line.
  • A shape fails closed when its regex does not compile, a red fixture is not matched, a green fixture is matched, or any match is zero-width (in a fixture or in a scanned line).

Limits

BoundValue
File size64 KiB
Shapes32
Regex length512 characters
Fixtures of each colour per shape16
Fixture length4096 characters
Wall-clock budget for one run of adopter patterns300 seconds

Adopter regexes are compiled, checked against their fixtures and matched only in a separate worker process. The worker is stopped when the budget runs out. A timeout, a worker failure or malformed worker output exits 2. A slow shape is never dropped so that the scan can continue clean.

The budget comes from one measurement. The worker alone matched 32 linear-time shapes of the form \bZQX00-[0-9]+\b over this repository's shipped set (926 decodable files, 721,140 lines, about 48 MB) in 39.6 seconds on one shared, loaded host. One shape took 2.6 seconds and four took 6.4 seconds, so each shape adds about 1.2 seconds. The 300-second budget leaves about 7.5 times the 32-shape figure. This is one host's figure, not a guarantee: a slower host, a larger shipped set or a costlier regex can still run out of budget and fail closed. The other limits are proposed bounds and are not measured.

The ratchet

Adopter shapes join the per-file ratchet after the built-in shapes, sorted by name. The baseline's exactness holds in both directions for them as well. With no adopter shape, the baseline render is unchanged. If you remove a shape while its baseline key remains, the baseline is refused as carrying an unknown key.

The baseline .aiqt/tracker-label-baseline.toml is pack content: the release ships it, and an adopter tree must not change it. The supported adopter procedure is therefore:

  • An adopter shape must match nothing in the shipped set of the adopter tree. A shape with no match leaves the baseline byte-identical, so the shipped baseline still passes.
  • Do not run --write-baseline in an adopter tree to admit adopter counts. Editing the shipped baseline is drift from the released content.
  • If a shape matches shipped text, narrow the shape, or remove the label from your own tracked file under .github/. To report labels only on lines a branch adds, use --diff BASE, which ignores the baseline.

In this repository, where the baseline is authored, regenerate it with python3 -I -B tools/check_internal_names.py --write-baseline after a change that legitimately moves a count. Treat both the configuration change and the regenerated baseline as reviewed policy changes.

The configuration file has no filename exemption. If the release inventory listed it, it would be scanned like any shipped file: its red fixture lines, which its own shapes can match, would count and need reviewed baseline entries, which only this repository, where the baseline is authored, can add. The release inventory does not list it, and its path is outside .github/ and opf/, so it is not shipped and the adopter procedure above needs no baseline entry for it.

--diff BASE

python3 -I -B tools/check_internal_names.py --diff BASE reports every built-in or adopter shape match on a line added between the merge base of BASE and HEAD, in HEAD's shipped set, whatever the baseline allows. A label deleted in one place and added in another, with the count unchanged, is still reported.

  • The check reads the HEAD commit's manifest, configuration, baseline (validated, not compared), tree and file contents. It also reads the merge base's manifest and tree, to find which paths the merge base shipped. The working tree and the index are not read.
  • Every Git read ignores replace refs (refs/replace/), any grafts file and any commit-graph file, so none of them can change the commits, parents or file contents the check reads or move the merge base.
  • Lines are counted by LF. A carriage return stays part of the line, and a last line without LF counts.
  • An added file counts all its lines as added. A rename from a path the merge base did not ship reports every line, with or without edits. Deleted files, deletion-only changes, pure renames within the shipped set and mode-only changes add nothing. Within the shipped set, a rename with edits reports added lines at the destination path. A rename Git does not detect counts as a delete plus an add.
  • Added lines are read with command-line options that outrank user and repository Git configuration: no colour, no external diff, no text conversion, fixed a/ and b/ prefixes, and no inter-hunk context.
  • A binary attribute does not hide a change. The check decodes a HEAD blob only for a shipped path that changed between the merge base and HEAD (added, edited, renamed or with a new mode) or is newly shipped at HEAD. Such a blob that is not UTF-8 fails closed, unless its path has a suffix outside the text-suffix list, in which case it is skipped. A path that was shipped at the merge base and is unchanged is not decoded, so a blob there that is not UTF-8 does not fail the check. Archive contents are not examined.
  • Exit codes: 0 means no label on an added line, 1 means at least one, and 2 means the check cannot be evaluated. Exit 2 covers: BASE is not a readable commit, the repository is shallow, there is no merge base or more than one, Git fails or times out, Git output is malformed, a shipped path other than the baseline is absent from HEAD, a present shipped path is not a regular file in HEAD (both checked for every shipped path, changed or not, before any line is read; an absent baseline is not an error, and then no baseline is validated), a changed or newly shipped blob is not UTF-8 as stated above, a manifest present at the merge base is not a regular file, is not UTF-8 or is not a usable inventory, or the HEAD configuration or baseline is invalid (also when no line was added). The check never fetches history.
  • --diff takes exactly one operand that does not start with -, and it cannot be combined with another option.

The diff check is an extra check. Keep the full gate required in CI. A clean diff check does not mean the full gate passes.

The gate also has an internal --adopter-match-worker entry. It is the budgeted worker the gate launches itself, reads its request as JSON on standard input, and is not a user option.

What this does not cover

A fixture shows only that its own examples behave as stated. Labels can still go unreported when they are written in prose no shape describes, belong to an undeclared shape, are split or encoded, sit inside binary or archive contents, or sit on lines the diff check does not see as added. Removing or narrowing a pattern is a reviewed configuration change.