/code-intelligence:declaring-invariantsfrom code-intelligence
Finds tests that enumerate a domain by copying it rather than iterating the source registry, catching drift where new members go untested. Also records which invariants a codebase declares and what backs them.
Ships in code-intelligence. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Two scripts over one idea: a test that enumerates a domain must loop the registry rather than a copy of it. Someone also has to say which domains matter in the first place.
python3 scripts/totality_lint.py <repo> # tests that copy a domain
python3 scripts/claims.py <repo> # what the repo declares, and what backs it
Python only, stdlib ast only: no install, no config file, no network.
A test that loops a hand-written list passes its runner and proves nothing about completeness. When the same members also exist as a registry in the source, the list is a copy, and the copy drifts the moment someone adds a member to the registry and not to the test. Nothing goes red.
Measured on oaustegard/remex, 2026-08-24: adding a fourth member to
ROTATION_CODES with no construction behind it left the entire 267-test
suite green. Four separate tests looked total; each parametrized
["haar", "rht"] against a three-member registry. Only a test that looped the
registry itself caught it.
Adapted from the meta-oracle in daniloc/coherence
(src/oracle-domain.ts), which classifies an oracle's iteration root as LIVE
or LITERAL by parsing the oracle's own AST. That harness needs spec files, a
claim grammar, a ledger and Node; the check does not.
totality_lint.py — tests that copy a domain| finding | meaning |
|---|---|
sampled-domain | a parametrize or for over a literal whose members are a strict subset of a source registry. The uncovered members are named. |
ratchet-broken | a hand-list marked ratchet names a member the registry no longer contains. Detected statically, without running anything. |
unratcheted | a registry enumerated live with nothing pinning its membership. Suppressed when no-floor already claimed the same line. |
no-floor | a test iterates a live registry with no len(...) >= n assertion in the file, so an emptied registry passes vacuously. |
stale-ack | an acknowledgement on a test that now covers the whole domain. |
python3 scripts/totality_lint.py <repo> # the report
python3 scripts/totality_lint.py <repo> --json
python3 scripts/totality_lint.py <repo> --strict # exit 1 if any finding
python3 scripts/totality_lint.py --selftest # fixtures, no repo
A partial domain is often correct. Say so on the test and it stops being a finding:
# totality: partial — mojo has no construction for "none"
@pytest.mark.parametrize("rotation", ["haar", "rht"])
def test_save_params_accepts_every_mojo_rotation(rotation): ...
The marker also works as totality: partial — <why> inside the docstring. An
acknowledgement on a test that later covers the whole domain is reported as
stale-ack, so a suppression cannot become a silence.
An enumeration loops whatever the domain currently holds, so it is
structurally blind to the domain narrowing. Remove a member and the loop simply
ranges over fewer of them, green. Raised by Yep, 2026-08-24; reproduced on
oaustegard/remex before being believed:
perturbation of ROTATION_CODES | domain floor | enumeration | parity | hand-list |
|---|---|---|---|---|
grow — add "hadamard2" | pass | RED | RED | pass |
shrink — drop "none" | RED | pass | RED* | pass |
substitute — "none" → "xyz" in both spellings | pass | pass | pass | pass |
* only because the other spelling of the domain did not shrink, which is incidental to that repository.
In the substitution row cardinality holds, both spellings agree, and five green tests cover a registry that quietly stopped supporting a rotation every index on disk was written with. The floor is a cardinality check; it cannot see a member swapped for another.
The second form is a ratchet: a hand-list asserting the domain keeps containing it. Mark it and the linter checks the pin rather than taking the marker's word for it.
# totality: ratchet — these three shipped; one leaving is a compatibility break
def test_no_shipped_rotation_is_ever_removed():
for shipped in ("haar", "rht", "none"):
assert shipped in ROTATION_CODES
Under that same substitution the linter reports ratchet-broken naming
'none' statically, before any test runs, and the test itself goes red
while the other five pass.
So: an enumeration proves every current member is handled, and a ratchet proves
no member left without a decision. unratcheted names a registry that has the
first and not the second. Neither half alone is the answer.
A ratchet covers shrink only. Over a strict subset it still reports
sampled-domain for the members it never listed, because pinning two of three
says nothing about the third. Suppressing that would make the marker a
laundering channel — the escape hatch these notes criticise via guard for
being in coherence. It was one: until 2026-08-25, # totality: ratchet over
two of three members silenced the report entirely and checked nothing about the
third. Caught by an adversarial pass on this skill, not by its own tests.
claims.py — what the repo declarestotality_lint asks whether a test's domain is complete. It presumes a test
exists. This asks the prior question, the one coherence's own Known Limits
concedes it does not answer: nothing enforces exists ⇒ declared.
A claim is a test whose docstring opens with invariant:. No new file
format, and the claim inherits its test's pass/fail:
def test_every_skipped_directory_is_actually_skipped(self):
"""invariant: every name in SKIP_DIRS is excluded from the walk.
refuted: replaced the walk's `part in SKIP_DIRS` check with
`part in {"node_modules"}` -> this test went red naming `.coherence`,
while the other 25 tests in this file stayed green.
"""
| finding | meaning |
|---|---|
unrefuted | a claim nobody has watched fail |
literal | the claiming test iterates a copy of the registry, so the claim cannot see a new member |
unanchored | a registry no invariant names — a question, not a verdict |
A claim whose test carries a ratchet marker is reported as pinning its
registries rather than copying them, and a ratcheted registry is not
unanchored.
python3 scripts/claims.py <repo> [--json] [--strict] [--selftest]
refuted: is the half that costs something. Break the chokepoint, watch the
claim go red by name, restore, and record what you saw. A green test and an
unfalsifiable one look identical from outside; the refutation is what separates
them.
Never write a refutation you have not run. The first refutation authored
for the SKIP_DIRS invariant above asserted a failure that did not occur — the
fixture placed the registry outside the test's reachability, so the test passed
under perturbation for an unrelated reason. A vacuous claim, written while
building the tool that catches vacuous claims, and caught only by running the
perturbation instead of trusting the sentence.
Procedure, in order:
refuted: <the edit> -> <what went red, by name>.The reference wiring lives in oaustegard/claude-workspace
(scripts/tdd_hook.py): a commit where a registry gained a member and no
invariant: test iterates it live is denied, naming the registry and what it
gained. Override with no-invariant: <why> in the commit body.
Registry shrink is gated the same way, and needs a ratchet rather than an enumeration to clear it. A new function or a new branch is behavioural growth too, but neither is diffable without guessing, and a gate that guesses stops being consulted. A brand-new registry is not gated. Declaring one is a judgement call; growing one has already made it.
Both filters exist because the unfiltered version was noise. Reproduce either by removing the filter and re-running against a real repo.
no-floor fires only on a name independently recognised as a registry.
Firing on every for x in <local> produced 27 findings on remex, all
noise: numpy arrays, query matrices, loop counters.tests/test_<mod>.py. Matching against any registry in the tree joined a
test in discrepancy/ to registries in kb-k-sweep/ and
remex-vs-higgs-ablation/ on a monorepo, because small integer sets collide
by chance. Four findings became one, and the survivor was real.The join key is membership, not names: [1, 2, 3, 4, 8] and
SUPPORTED_BITS share no token, so containment is what ties them together. No
naming convention is assumed, and none is required.
_registries_py and _domains_py; a
tree-sitter pair for another language slots in beside them. The join, the
acknowledgements and the reports are all language-independent.--strict opts into a nonzero exit. The
tool this was adapted from gates by default, and its parity arm false-fails a
correct oracle that binds its domain to a local name first. A gate that
false-fails stops being consulted.parametrize is read.unanchored is a question. Most registries need no invariant. Treat the
list as candidates for declaration, never as a backlog to clear.ROTATION_CODES = {"haar": 0, "rht": 1, "none": 2} exists to pin
bytes on disk; permuting it to {"haar": 0, "rht": 2, "none": 1} keeps every
key, every count and every ratchet intact, and every index already written
decodes under the wrong rotation. Verified 2026-08-25 on a fixture: the
linter reports nothing and the gate's registry half reports nothing. (The
gate denied that fixture, but on the unrelated TDD rule — checked, because
claiming otherwise would have been the overclaim this skill exists to catch.)
Nothing here checks a name-to-code mapping. Extracting (key, value) pairs
as the member set would, at the cost of breaking the subset join against a
parametrize list of keys."none"
to "identity" in both files was silent, while every index already on disk
still decodes byte 2 as the old name. Both sides of a co-located hand-list
move together, so no static check over one working tree can see it. The
commit gate can, because it diffs against git history — and only if the
ratchet itself is untouched in that commit, which it now requires.unanchored and
unratcheted surface it in the report; the gate deliberately does not, on
the grounds that gating every new module is how a gate stops being consulted.
That is a judgement, not a proof, and it is the largest hole a cross-model
review found.@register("name") populating a
dict at import time is the common Python registry idiom and is not a literal,
so nothing here sees it. Named because it is the shape most likely to be
mistaken for coverage.verifying-claims covers the prose layer: does the documentation match
reality? Agent-judged, non-deterministic, run as a triggered review. This
skill is the deterministic half, over code and tests rather than prose.tree-sitting locates the registry or the test before you edit it.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub oaustegard/claude-skills --plugin code-intelligence14 skills in this plugin
/assessing-impactPre-change blast-radius report for a symbol or file. Walks tree-sitting references, augments with a plain-text scan over non-parsed files (configs, plain docs), and clusters affected sites by feature (`_FEATURES.md`) or top-level package. Use when about to refactor, rename, or delete something in a repo you don't own — "what breaks if I change `validateUser`", "who calls this", "is this safe to remove", "where is this used", "blast radius", "impact analysis". This is the CONVERGENT pre-change risk skill — for "what is this repo?" use exploring-codebases; for "where is X?" use searching-codebases./describing-productsBuilds a product description repo for a software product - prose documents that say, feature by feature and event by event, what the user sees, what they can do, and exactly what happens when they do it, including when they stop halfway. Drafted from the code and tests, verified against the running product with hand checklists, and triaged into a bug list. Works for canvas editors, web apps, CLIs, chat products, mobile apps, and libraries or SDKs. Use when asked to "write a product description for X", "describe the user experience of X", "document how X behaves for the user", "make a behavior-spec repo", or for an event-by-event account of an app's behavior rather than API docs. Also resumes or extends an existing product description repo.Other plugins' skills for the same job