Skip to content

fixes.py: read and check a fixes file; label, compose and count any set (SPEC 16, step 2) - #24

Draft
mklarmann wants to merge 6 commits into
fixes-formatfrom
fixes-validator
Draft

mklarmann wants to merge 6 commits into
fixes-formatfrom
fixes-validator

Conversation

@mklarmann

@mklarmann mklarmann commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Step 2 of SPEC §16.12: the reader, validator and made-up fixtures for sentier-diagnostics-fixes/1. A fixes file holds one base state and fixes, each measured on its own against that base. Stacked on #23 (SPEC §16), which Manuel approved, and on #22 (noise per state, the matrix's "=").

 src/sentier_diagnostics/
+├── fixes.py          # read, check, build; label, compose and count any set
 ├── cli.py            # `check` dispatches a fixes file, checks it against the file it names, prints its size
 tests/
+├── test_fixes.py     # every §16.9 check, F1–F6 and F8–F13, requires, added items, chain states, noise, the CLI
 ├── test_modules.py   # fixes doctests
 SPEC.md, GLOSSARY.md  # §16 says what the code decided

Four questions settled here, before any producer writes a file (§16, for Manuel to agree in this PR):

Question Decision Why
May a pair's reason name an activity? A pair holds no text: {fixes, kind, reach, largest}, kind one of five A check of text catches identifier shapes, not names. Five kinds come from where two changes of h = c·B·A⁻¹·f meet: same entry, technosphere, technosphere and emission, technosphere and factor, emission and factor, in that order of precedence
A fix that needs another applied first? requires, earlier in the file Its effect is measured against the build of what it requires; choosing it chooses them; a fix and one it requires are never a pair
A fix that adds items? Allowed They follow the matrix's items, base null, and some fix gives each a result; a new unit takes a floor of 0 from nothing
A built set that is a chain state? state on a built set The release with every fix is held to the chain's state by the rule: two builds of one thing

Noise belongs to a build (§5.3 from #22, Manuel: "sum, go ahead"). A comparison takes the sum of the noise of the builds it stands on, never of one it does not:

the base                      its state's noise (of.base_noise); none where it is the published results: exact
a fix                         its build + the build it was measured against
a set, item by item           where the item's result is a build's (one fix, a cover, or the set is built):
                                that build + the base
                              where it is a sum: Σ over the fixes that change the item
                                (fix's build + what it was measured against); the base once per such fix
a built set vs its sum,       the built set + what the sum stands on at that item
  item by item                  (a build; or the base + Σ over the fixes that change it; or the base alone)
a built set vs its state      the built set + the state

A fix that does not change an item adds nothing to it: sentier-bafu's review found that a noise summed over every ticked fix put an item that moved 2.9 % "within noise" as soon as an unrelated fix was ticked (A30 again). Per indicator a set says its largest item noise and at how many of the builds those items stand on the noise is known ({value, known, builds}); compose gives each item's noise (item_noise), the reference for the page's port. Not measured is never none.

errors(f)                     the file on its own
  shape, keys, limits, of.base_noise
  requires: earlier fixes, once, never itself; the file holds a build of them together
  built sets: >= 2 fixes, closed under requires, not a fix with its requirements, once each
  each fix: effect sparse against the build it was measured against, never equal to it
            counts + verdicts worked out again against that build (own tolerance, the two builds' noise, claim)
  interactions: checked or not, no half; pairs {fixes, kind, reach, largest}, once,
                never a fix with one it requires; a pair with no size is built
  built sets, where checked:
    no listed pair            -> must be the sum of its fixes' effects (else refused: set, item, indicator)
    exactly one listed pair   -> within its `largest` of the sum; where "no size", its build has none
against(f, data, matrix)      items = the matrix's, in order, then items a fix brings
                              base = the matrix column of the base state ("=" written out), or the listed items
                              of.base_noise = the base state's noise; the states must carry noise
                              a built set's `state` = that column of the matrix, by the rule
label / compose / counts      closed under requires; built | exact | estimated
                              tolerance = largest; noise item by item, as above; pair terms = Σ sizes
                              (unknown where one is not measured or has no size)

A set's result at an item:

one fix changes it              -> that fix's built result
several do, inside one build    -> that build's result (a fix with what it requires, then a built set; measured, not summed)
otherwise                       -> base + each fix's difference against what it was measured with
                                   (what two fixes build on counts once)
a difference cannot be taken    -> no result, reported apart as `cannot_add`

The independence check sums the fixes alone, without a built set inside: otherwise a set within tolerance of a build that is itself within tolerance of the sum would pass at twice the tolerance. A test pins this.

From sentier-bafu's review as producer. It wrote a file from its own chain (BAFU:2026 v1, 11,947 items × 25 indicators): 12 fixes and the release, checked clean in 1.9 s. Taken in:

  • largest is the rule's own measure (size_of): the smallest tolerance under which the built pair agrees with its sum. "no size" where none is enough, kept apart from null ("not measured"). A pair with no size must be built, and its build must have none.
  • reach is counted on the build with both fixes.
  • §16.4: an effect is measured on the base's route, and results are read exactly (a default CSV reader misread 134,743 of 298,675 results in the last bit).
  • §16.3: the list of pairs assumes fixed changes of A, B and c. A producer whose fixes edit data checks that the release's matrix change is the sum of the fixes' changes, entry by entry.
  • §16.7: a release taken from the same build as its state passes the state check by construction, so the sum check is the one that can fail it.

Sparse counting. A fix is counted from the items it changes plus the classes of the build it was measured against, not item by item. SparseCounts and Requires hold this to a dense item-by-item count.

Evidence

  • Before: no reader for sentier-diagnostics-fixes/1.
    After: 286 Python tests (67 fixes tests) and 82 node tests pass; ruff check is clean on the changed files.
  • Sabotage probes: each rule disabled in turn on a scratch copy, 76 probes. The tests catch every one:
CAUGHT  no independence check
CAUGHT  built sets cover in the check       (tolerances would stack)
CAUGHT  effect measured against the base    (requires)
CAUGHT  fix counts without what it was measured against
CAUGHT  sum: the base once, not per fix
CAUGHT  set noise over every fix (A30)
CAUGHT  check: noise over every fix
CAUGHT  fixes summed out of file order      (the page's port must match bit for bit)
CAUGHT  fixes summed in id order
CAUGHT  fixes summed in the set's own order  (30 of 30 hash seeds)
CAUGHT  check: an untouched item without the base
CAUGHT  state check without the state's noise
CAUGHT  base noise not held to its state
CAUGHT  = not written out
CAUGHT  no-size claim not held to its build
CAUGHT  no size read as size 0
CAUGHT  counts with one noise for every item
... 76 of 76 caught
  • Size and speed: a made-up file at the size sentier-bafu runs: 11,947 items, 25 indicators, 100 fixes of 500 items each in every indicator, ten of them requiring the one before (39.5 MB), every build's noise measured. errors() takes about 2.4 s; counts() of a 50-fix set 1.1 s, of which about 0.4 s is the noise item by item (most of these items are changed by several fixes, so each sums its own; the sum keeps the file's order for the page's port).

What I did not check

  • F7 (the page's port of the rule and of a set's noise) belongs to sentier-bafu's page work. §16.5 fixes the order of the noise sum so the port can match it bit for bit.
  • No real fixes file is committed. sentier-bafu's trial ran on its chain and stays local. Its next build must write of.base_noise (read from its base state), each build's noise, largest by size_of or "no size", and reach on the build with both fixes.
  • Only one CI chain checks the premise that fixes which edit data meet only in the matrices; sentier-bafu says its method will state that check.

Merge Danger

Door: two-way. A new module and format; nothing existing reads it. The only change to existing behaviour is one new branch in check.

Blast Radius: none for current files. Once a producer writes sentier-diagnostics-fixes/1, any later change to its keys means a new major version (SPEC 4.1). That is why requires, state, added items, the pair shape, base_noise and "no size" are in now.

No reviewer requested. Reviews stay in-house between the sessions for now. Manuel merges.

🤖 Generated with Claude Code

mklarmann and others added 4 commits November 17, 2026 06:38
The validator, reader and made-up fixtures of sentier-diagnostics-fixes/1
(SPEC 16.12, step 2). errors() checks a file on its own: shape and
limits, every fix's counts and verdicts worked out again from its effect
and the base, pairs, and every built set the file calls independent
against the sum of its effects. against() and beside() hold it to its
diagnostics file and matrix; `check` dispatches to it and prints what
the file is made of.

A listed pair carries the measured size of its cross term (`largest`),
as sentier-bafu proposed: an estimated set then says how far it may lie
from its sum, and a built pair is held to its stated size.

SPEC 16 now says what the code decided: the rule without the chain's
total tolerance, closer/further null on a fix, a claim that names its
items, a set where the base has no result, the noise of the built-set
check, pair terms, measured sizes, and the open questions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te, pairs without text

Four questions the fixes format left open, settled before any producer writes a file:

- A pair holds no text: {fixes, kind, reach, largest}, its kind one of five places where
  two changes of h = c·B·A⁻¹·f meet. A reason in words names the model, and a check of
  text catches identifier shapes, not names.
- `requires`: a fix that cannot be applied alone names the fixes it needs, earlier in the
  file. Its effect and counts are measured against their build (a fix with what it
  requires, or a built set of exactly those fixes); choosing it chooses them; a fix and
  one it requires are never a pair.
- A fix may bring items no state holds: after the matrix's items, base null, and some fix
  or built set gives each a result.
- A built set may name the state of the chain it is (the release with every fix); the
  check holds the two builds to each other by the rule.

A set's result at an item is now the measured one wherever a build inside the set covers
every fix that changes it, and otherwise each effect on top of what it was measured with.
The independence check still sums the fixes alone, so tolerances do not stack.

48 fixes tests (was 30); 43 of 43 sabotage probes caught; check of 100 fixes on 11,947
items x 25 indicators: 2.7 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st build once per indicator

counts() of a 50-fix set at 11,947 items x 25 indicators: 2.6 s -> 0.87 s. The base's own
classes were worked out six times per call (2 million classify calls); they are now built
once and only when a count needs them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… review

Noise belongs to a build, as it belongs to a state (SPEC 5.3, Manuel: "sum, go ahead"):
- the base's noise is its state's (`of.base_noise`, left out where the base is the
  published results, which are exact), held to the diagnostics file; a diagnostics
  file whose states carry no noise is refused;
- a fix is judged with the noise of its build and of the build it was measured against;
- a set takes the sum, over its fixes, of both (the base once for each fix measured
  against it), or the noise of a build it takes a result from and the base's, where
  larger; it says at how many builds the noise is known;
- a built set is held to its sum with the noise of every build both sides stand on,
  and to its state with its own noise and the state's.

The matrix of #22 writes a result equal to the one before as "=": the base and the
state check read it written out.

From sentier-bafu's review as producer (12 fixes and the release, written from its chain):
- `largest` is the rule's own measure, the smallest tolerance under which a built pair
  agrees with its sum (`size_of`); "no size" where none is enough, apart from null (not
  measured); a pair with no size must be built, and its build must have none;
- the kinds of pair are in their order of precedence: same entry first;
- an item a fix brings in a unit no item of the chain has takes a floor of 0 from nothing;
- SPEC 16: effects on the base's route, results read exactly, reach counted on the build
  with both fixes, the premise of the list of pairs for fixes that edit data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mklarmann and others added 2 commits November 17, 2026 07:46
sentier-bafu's review as producer (finding 1): a set's noise summed over
every ticked fix put an item that moved 2.9 % within noise as soon as an
unrelated fix was ticked (A30 again). Each item now takes the noise of the
builds its result stands on: a build's item that build and the base; a
summed item the fixes that change it, each with what it was measured
against, summed in the order of the file so the page's port matches bit for
bit. The built-set check takes the same per item. compose gives the noise
of each item (item_noise) as the reference for the port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sentier-bafu's review of 8c7f2c3 (nothing blocking) found three mutations
the tests let through:
- a sum in id order: the three fixes of the order test were already in id
  order. Six fixes now, out of id order, with noise whose sum in file order
  only one other order of the 720 gives (its first two swapped); the test
  asserts that it still tells the orders apart.
- a sum in the set's own (hash) order: caught on some seeds only; now on
  30 of 30.
- the built-set check without the base at an item none of the set's fixes
  change: a built set of a and b moving p3 by 1.2 % passes with the base's
  noise and its own (1.5 %), not with its own alone.

SPEC 16.5: a set that changes nothing in an indicator stands on no build
there; the page says nothing changed, never "not measured".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant