Repository navigation
The CLI, 3/3: the commands that write nothing, and English everywhere - #37
Merged
Merged
Conversation
…must exist PR 3 of the CLI rebuild, first instalment: the two verified fixes that cost something today. **Asking for the help destroyed the versioned fixture.** `scripts/build_test_fixture.py` tested `if "--golden" in sys.argv` and let everything else — `--help` included, and every typo — fall through to a function whose first act is `rmtree` of `tests/fixtures/alto_min/`, the file the strict golden diff compares against. On a machine without the private corpus it died before the removal; on a maintainer's, it rebuilt the fixture with today's thinning rules rather than the ones the golden was written under. It is a subcommand with an `ArgumentParser` now, and the logic moved into the package because `scripts/` is not importable from an installed distribution — the script could not have been shared, only duplicated. The script stays, as a launcher, because CONTRIBUTING.md, the CI and two years of wrapper scripts invoke it by name; it carries nothing, so it cannot drift from the command it stands for. `--target` exists so a test can watch it work without touching the versioned copy. **A mistyped input path converted the corpus and reported success.** The guide and CLAUDE.md both say the settings converters "reject empty, unusable, non-finite and out-of-range values"; for a path they rejected nothing at all. `TDOUCE_METADATA_CSV=/typo.csv` warned once, wrote twenty-seven volumes of placeholder headers and exited 0 — forty minutes to produce files nobody wants, reported as a success. Not fixed in the converter, though the design note said so: `info` and `check` have to be able to read a configuration on a machine with no corpus, and validating during resolution couples the two. `Settings` answers `unreadable_inputs()` instead, from a table that says which paths are READ and which are written — an output directory does not have to exist, it is created — and the callers decide. `run` refuses before it reads anything; `check`, next, will list them. `teille-douce check` asks the same question in two seconds. This is what happens when nobody asked. 1321 tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SVwGPQx73aibsv8PeHiRQS
… script The ODD compilation chain moves into the package, for the reason the fixture's did: `scripts/` is not importable from an installed distribution, so `teille-douce odd` could not have shared it — only duplicated it. `scripts/build_odd.py` stays as a launcher, because CLAUDE.md, `schema/README.md`, CONTRIBUTING.md and the CI all type that name, and it translates the old `--check` FLAG into the new `check` ACTION so neither spelling breaks. `--check` with no argument still means build, which is what two years of muscle memory expects; a subcommand that silently started checking instead would be the worst kind of rename. `scripts/rng_simplify.py` carried `#!/usr/bin/env python3` and had neither `__main__` nor argparse in two hundred and sixty-five lines. It is a library `build_odd` imports, and it is `teille_douce/odd/simplify.py` now — in English, like everything else inside the package. Translating two hundred and sixty-five lines of RELAX NG reduction rules is exactly the change that can go wrong silently, so the proof is the command itself: `odd check` recompiles into a temporary directory and compares against the versioned artefacts, and it passes. The derivatives are byte-identical, so the translation changed nothing the schema says. `--toolchain-dir` is new: the hundred megabytes of TEI Stylesheets are pinned and slow to fetch, and a machine that has them unpacked elsewhere should not fetch them twice. The coverage `omit` needed its glob form. `build.py` drives an external chain — downloads, Saxon, the TEI toolchain — and cannot run in the suite; `simplify.py` is pure logic and stays measured, which is what makes the byte-identical check above worth anything. 1326 tests, coverage 93.00. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
… used The logic of `scripts/validate_tei.py` was sound. Its envelope was the largest violation of the rule CONTRIBUTING.md states — "CLI help is in English" — down to the name of the positional argument, `fichiers`. It is `teille_douce/validation/` now, in English, and the script is a launcher. Three defaults were each the opposite of the one in use: **`--odd` is on.** It was opt-in, and its absence forced the program to print a note explaining that five invariants had not been checked. A default that has to apologise is the wrong default. `--no-odd` cancels it, and still prints the note, because a partial check that looks complete is the thing the note exists to prevent. **`-j` is `auto`** — as many workers as there are files, capped by the machine. It was 1, and every invocation in the documentation passes `-j 8`. A default everyone overrides is a false default. **An argument may be a directory, and no argument means the output directory.** The question asked is almost always "check what I have just written", and the answer was a shell glob. And the schemas were compiled twice. The parent built `relaxng`, `odd_rng`, the Schematron and the Saxon processor; `_preparer_worker` built them again into the context the check actually reads — in the parallel path and in the sequential one, where the worker runs in the same process. The parent's four objects were never read; only their side effect, two `note:` lines, mattered. On a one-megabyte `tei_all.rng` and a Schematron sheet through Saxon, that is not free. `available()` answers the question the notes needed, compiling nothing, and the worker is the only place a schema is built. The truncations at twenty, ten and five were applied when the errors were COLLECTED, so a file with more than twenty was said to have exactly twenty and no flag could lift it. They are a display decision now, and `--max-errors 0` shows them all. `--json` for a wrapper. `SystemExit` raised from a helper and caught two frames up to decide whether an absent Schematron ends the check or narrows it is a `Missing` exception, which says the same thing without pretending to be a program exit. 1335 tests, coverage 92.95. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
…hat exist Every page still named `scripts/validate_tei.py --odd`, `scripts/build_odd.py --check` and `scripts/build_test_fixture.py --golden`. Those files are launchers now and still work, but a reader told to type a path rather than a command will not discover that there is a command — and `--odd` is a flag that no longer needs asking for. README, the user guide, the developer guide, the schema guide, schema/README, CONTRIBUTING and the architecture map, plus the module map entries for the three packages the logic moved into. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
The command that was missing. Until now the only way to learn whether the input was well formed was to convert the whole corpus — the user guide says as much of `--dry-run`, which resolves everything and lists a plan without ever asking whether the catalogue matches anything. Forty minutes to discover that a `BDD` column matches nothing. Four of the ten troubleshooting entries in that guide are diagnoses this poses in two seconds. Five families, each measured against a real directory in its test: - a volume with no catalogue row — its header would keep every placeholder, and the run would exit 0 saying so to nobody; - two files claiming one page number — `f12.xml` and `f12-np.xml` both give 12, so the numbering is ambiguous and they share one IIIF view; - a IIIF mapping under the thirty per cent floor — refused in silence today, so the volume converts with no @source and whoever supplied the mapping never learns it was thrown away; - a directory holding no ALTO; - a service that refuses its probe, or NER dependencies that are absent. Every line says what it would COST, not only that something is wrong: a line an operator cannot act on is a line they learn to skip. **An imperfect corpus is not a failure.** Exit 0 with things to look at, 1 under `--strict`, 3 unusable — no input, no volume, an output that cannot be written. The design note settles it in one line, "on seventeenth-century OCR imperfection is the normal state", and a preflight that exited non-zero on the normal state would be running under `|| true` within a week and would stop being read. The analyses are the run's own, not copies: `pages_sharing_a_number` came out of `build_sourcedoc` so both can ask it, and the catalogue lookup, the IIIF detection and the service probes are the ones a run uses. A preflight that disagreed with the run it precedes would be worse than none. And the rendering is a pure function of the answer, which is how the subject column got caught: `{subject:<14}` pads to fourteen and stops, so `LIV0326_v1_reconciled` ran straight into its own detail — the defect `summary._entry` took three review rounds to settle, reproduced in a file one week old. It is measured off the widest subject now, in cells, and both that and what `--strict` changes are pinned by mutating the line and watching the test go red. 1348 tests, coverage 92.91. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
… caught up with `--jobs` lost its `type=` in the move, so `-j eight` came out as a traceback with exit 1 — which in this CLI means "some files failed validation", so a typo in a command line was read by a wrapper as a corpus problem. It is a usage error again, and `-j 0` with it. `validate` forked its workers after `available()` had imported saxonche, so a process carrying SaxonC's native runtime and its threads was forked: a DeprecationWarning today, an error in 3.14. forkserver, for the reason `sourcedoc/builder.py` already gives. "nothing to check" always named the configured output directory, so `validate /srv/exports/batch-12` answered about `tei_output` — a path the user never mentioned, and one that may well hold files. `Path(__file__).parent.parent.parent` is the repository root only when the package is imported from a checkout. Three modules read `schema/`, `tests/` and `OCR/` through it, so an installed distribution looked under `site-packages/` and was told to run `teille-douce odd build` — a command that compiles an ODD it does not have either. `paths.py` answers which of the two it is, once, and each caller says something true. And since `--odd` became the default, a wheel install failed every `teille-douce validate`: an inherited default now narrows the check and says so, while a `--odd` you typed is a demand and still fails. Under `--json`, where the notes are suppressed, `applied` names the schemas that actually ran. `odd --refresh` rmtree'd whatever `--toolchain-dir` named. That is fine for the default `.odd-toolchain/`, which the class owns, and is data loss for the directory the flag exists to point at. A cache invalidates its own entries. A file whose name carries no sortable number is placed last and takes the sentinel IIIF view even when it is alone — the guide's third troubleshooting entry, and `check` now poses it. The analyses no longer log over the report they answer, and put the level back. `check` takes `-i`, `-o`, `--metadata` and `--persons`. `run -i OCR_test` is the shape the guide teaches; the preflight answering "unrecognized arguments" taught that it could not be asked about what the run would do. Also: `cli/fixture.py` was omitted from coverage — it entered the list with the script it came from, and its tests were measuring nothing. 92.8 % with it back in. `_print`'s `with_schematron` had no reader; it has one now. And the guide's third validate example was the second one again, `check` and `preflight.py` appeared in no documentation at all, and the ODD/fixture commands were still documented as scripts. Every fix carries a test, and each was run against the code it condemns. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
…y read `info` answers the question the four layers make unanswerable on their own: which of flag, TDOUCE_*, teille-douce.toml and config.py set this value. Layer by layer, including the ones that offered nothing — the answer to "why is my variable ignored" is always a layer ABOVE it — and including a layer whose value the converters refused, which until now was said once in a RuntimeWarning four hours before anyone read the log. The config file is named whether or not anything in it won: it is found by walking up from the working directory, so one that has been forgotten is the least debuggable thing in the design. `report` reads what a run left under .teille-douce/runs/. The selectors compose, a code may be given as a prefix, `--why I2 --context` quotes the log around one incident, and a half-written record — no manifest, a JSONL line cut in half by a Ctrl-C — is reported as far as it goes rather than refused, since a run that went wrong is exactly when that shape turns up. `--limits` is the part that matters in the long run: it separates what this pipeline CANNOT measure from what it does not measure YET, and gives the second kind its price. Entities under the NER threshold are the first — the threshold is applied inside GLiNER's own inference, so what it cost has no denominator. Blocks 1 and 2 over a past run are the second, and `report --block source` says "not indexed" rather than "nothing", which would be read as "the run lost nothing that way". The JSON says it too, in a field, because JSON has no sentence to say it in. `completion bash|zsh|fish` is generated from the parser. `--fail-on <TAB>` offers never/incident/loss because record.py declares three, and a flag added in a later PR appears with no edit here: a copied list diverges at once, and a completion offering a flag the parser refuses is worse than none. Along the way, three things the new code found in the old: `app._config_file` was renamed public for `info` and its local shadowed the function; `run --strict` folded `fail_on=incident` into the settings of every command that has a `--strict`, `check` included; and `report/store.py` gained the reader half of what it writes, in the same file, so the two cannot drift. Coverage 93.2 %, ratchet to 92.9. Every test was run against the code it condemns; two mutants survived on `completion` and one of them was right — the class-name list beside `nargs == 0` matched nothing that `nargs == 0` had missed, and is gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
`_workers("64", 3) == 3` was true on this laptop and false on the
two-core CI runner, where the answer is 2. A test whose truth depends on
the machine proves whichever of the two caps that machine happens to
apply — and the one it silently stopped proving is the flag's.
`cpu_count` is stubbed at 8 and then at 2, so all three caps are
asserted wherever the suite runs; and the forkserver test pins it at 4,
since a single-core runner takes the sequential path and proves nothing
about the start method being fixed there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
It was rewritten to `run --help`, on the ground that the top-level parser listed a command and nothing you could pass it. That was true when `run` was the only command. This instalment is the reason it stopped being true: `--help` is the one place someone looks for `check`, `info` and `report`, and it named none of them. The bare help now lists the commands, and the epilog carries what the rewrite protected — that a bare invocation converts, and where `run`'s fifty options are. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
**A hang.** `validate --schema` naming a file that is not a RELAX NG
grammar raised inside `_prepare_worker`, and a `Pool` whose initializer
raises respawns its workers for ever: one transposed letter in
`--schema tei_all.rng` — the invocation the guide, schema.md and
schema/README.md all teach — burned two cores with nothing on screen
until it was killed. The parallel path is the default now, so this was
the ordinary case. The parent checks the file's root element (not the
schema: compiling it here would be the second compile this module
exists to have removed), `_prepare_worker` can no longer raise at all,
and a grammar that parses and still will not compile fails the run
once, at 3, instead of once per file at 1.
**Seven exit codes.** `raise SystemExit("text")` exits 1 — "some volumes
failed" — so a missing run record, a directory with no XML in it and two
flags that contradict each other all told a wrapper the corpus was at
fault. `info._named` had it right and its comment names the trap; the
six others now go through `cli/exits.refuse`, which puts the message on
stderr and the code in the code. The tests asserted the message and not
the code, which is why nothing caught it; they assert both now.
**`TDOUCE_TEI_RNG` refused every conversion.** It is read by
`tests/test_e2e_pipeline.py` and by nothing else, and CLAUDE.md tells
contributors to set it — so a stale value in a shell profile exited 3
with "an input this run must read is not readable", over a file no run
opens. Out of `READS`. And the message beside it named `-i:` whatever
layer had supplied the value; it now names the one that did.
**Two tests that did not hold**, each satisfied by the very mutation its
docstring condemned: `report`'s column test skipped every row once the
name was clipped (a negative assertion satisfied by absence), and
`info`'s was satisfied by `pad`'s right-aligned origin, which puts a run
of two spaces in every line whatever happens at the left edge. Both
rewritten and re-run against the code they condemn — and the second
found that the collision it described is impossible: `max(2, …)` already
prevents it, and what the measured column buys is alignment, which is
now what is asserted.
Also: `report --runs` showed a run whose manifest was never written as
"0/0 converted · exit None" — a false denominator reading as "converted
nothing", which is the sentence CLAUDE.md forbids; `report --json --why`
returned every incident; `read_run` promised never to raise on a damaged
record and raised on `{"argv": null}`; the log path vanished entirely
below 43 columns, and `--limits` overran below 29; `completion` leaked
argparse's `%%` and left `[OCR]` where zsh ends a description at the
first `]`; `docs/user-guide.md` documented an error message this branch
had already replaced and left four new sections out of its own contents.
1459 tests, coverage 93.2 %.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
`unreadable_inputs() == ()` was true on this laptop, where the corpus is in the working directory, and false on the runner, where `ocr_dir` is a default that is not there and legitimately in the list. The claim being made is about `tei_rng` and nothing else, so that is what it asks. The fifth hollow shape, written in the commit that removed two others: an environment the suite itself makes untrue. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
Two of the five hollow shapes turned up again in one afternoon, and both
were about where the suite runs rather than what it asserts: CI has no
`OCR/` and two cores, so `_workers("64", 3) == 3` and
`unreadable_inputs() == ()` were true on this laptop and false on the
runner. The list now says so, with the two remedies and the one-line
rehearsal.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
It was the one that got the exit code right, and its comment names the trap the rest fell into — which is why `cli/exits.py` was written. Six commands went through the new helper and this one kept its own copy of the same three lines. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
…ypes `_prepare_worker`'s guard covered `--schema` and stopped there, which is the flag nobody passes. The parent's `available()` only STATS `teille-douce.rng` and `teille-douce.svrl.xsl`; it never compiles them. So a truncated `odd build`, a partial checkout or a hand-edited derivative made every worker's initializer raise, and a `Pool` whose initializer raises respawns its workers for ever — under `teille-douce validate` with no flags at all, since `--odd` is on and `-j` is `auto`. The whole body is inside the guard now, and the test asserts `_prepare_worker` itself rather than reaching it through a pool: a regression there hangs rather than fails, and a suite that hangs tells you nothing. The same shape twice more. `read_run` shape-checked the three `run.json` fields and left the JSONL loop assuming a dict, so a line reading `null` raised out of the function whose docstring promises it never does — and `--runs` reads every run kept here, so one damaged line in one old run took the whole listing down. And both `check.py` fixes had no test at all: reverting either left the suite green, because the width sweep started at 40 and compared against `min(width, MAX_WIDTH)` rather than the renderer's own `room` — two cells looser than the contract, and above the widths where the only unclipped line in that file lived. It sweeps from 2 now, against `room`. Also: `report --limits --json` and `report --runs --json` printed prose into the stdout a wrapper was parsing; `--block source --why I1` blamed the number the reader had just been shown rather than the filter that removed it; the command the end-of-run summary offers broke on an output directory with a space in it, which is exactly the "last line that teaches distrust" its own comment says the `-o` prevents; and two per-command exit-code sentences in the guide still said 1 where the code now says 2 and 3. 1478 tests, coverage 93.2 %. Suite green with `OCR/` moved aside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
`read_run` shape-checked the JSON *value* and left the *decode* on the same read open. `UnicodeDecodeError` is a `ValueError`, the read of `run.json` eleven lines above already catches it, and the canonical damage this format exists for — a Ctrl-C cutting a line — lands in the middle of a multibyte character. So `report --runs`, which reads every run kept here, died with a traceback and exit 1 out of the function whose docstring promises it never raises: verbatim the bug the previous commit's test claims to have closed. The read now replaces what it cannot decode, catches `ValueError` and `RecursionError` beside `OSError`, and checks the fields as well as the container — `run.json`'s half of the same reader was already doing that. `import saxonche` was guarded with `except ImportError` in three places, and a wheel whose native `libsaxonc` will not load raises `OSError`. The previous commit guarded the child, where `except Exception` covers it, and left the parent's copy — so `teille-douce validate` with no flags exited 1 with a traceback, from `available()`, before any worker existed. Which contradicts the paragraph that same commit added to the guide: one broken install must not be reported as a corpus that does not conform. `--why` is resolved over what the other selectors leave, so "no incident 'I3'" was false whenever `--code` or a document had removed it — and `report LIV0044 --code phase_lost` is that module's own example of composing selectors. Only `--block` was special-cased. It now names whichever one removed it. The end-of-run summary offers three commands and the `-o` was added to one: `--retry-failed` pasted after a run written elsewhere read a different directory's manifest and answered "nothing failed last time", exit 3, over a volume that had just failed. All three now carry `-i` and `-o` when they are not the defaults, and quote them. Two tests did not hold. The Schematron guard's own test never posed its case — every call had the RelaxNG broken too, so `unusable` already held the other message and `schematron is None` was already true from the `_CONTEXT.update`; replacing the whole branch with `pass` left the suite green. And `info`'s width sweep measured against a bound two cells looser than the renderer's own, the same slack `check`'s sweep had just been tightened for, so dropping `- _MARGIN` from `info.render` changed nothing anywhere. Also: `validate` listed schemas as applied in JSON for a run it refused two lines later; a directory it may not list reported as one that is empty; `--schema`'s diagnosis was overwritten by the versioned schema's; `_CONTEXT["processor"]` was not reset between workers; and `report` emitted trailing whitespace at six, eleven and twelve columns, which its sweep did not look for and `check`'s did. 1485 tests, coverage 93.3 %. Green with `OCR/` moved aside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
Three rounds running, the finding was that the previous round's fix had reached one call site of several. This time the class is closed, not the case. **A directory that cannot be listed is not a directory that is empty.** `expand` learned this last round, for `validate`. It was true in four other places: `preflight._volumes` crashed outright on a chmod-000 `OCR/` (traceback, exit 1, from a command that converts nothing) and reported an unreadable volume as "holds no ALTO" — `cli/run.py` has had `_is_readable` for exactly that since PR #33, and the preflight that must not disagree with the run did not use it. `RunStore._runs` swallowed the same error and answered "no run has been recorded here yet" over records sitting right there; `failed_last_time` guards it and its comment names the defect, so the guard had reached one caller of three. `kept()` is now the version for askers and raises; `_runs` stays swallowing for `prune`, whose caller is a run that must not die over its own housekeeping. **`--target` fed an unguarded `rmtree`.** It is new in this PR: the old script's target was a constant and the removal inherited that constant's safety. `teille-douce fixture build --target ~/notes` deleted the directory whole. This module exists because asking for the help destroyed a versioned file, and the remedy had reached the parser and stopped one line short of the removal itself. Three things are removable now: the versioned fixture, a directory that is not there, and one holding exactly what a build leaves. **A command offered for pasting carries what makes it mean this run.** `summary._where` was written for that sentence — "a last line that exits 3 is a last line that teaches distrust" — and applied to three lines in one file. `report`'s footer carried neither `--run` nor `-o`, so from another working directory it exited 3 and from the same one it silently answered about the newest run instead of the one on screen. `check`'s footer said `teille-douce check --strict` with no `-i`, so pasted elsewhere it answered "unusable — nothing to convert" about a corpus it had never seen. Both are addressed, quoted, and printed whole — a command is never clipped, which is the rule `summary` states for its own. **And the reads.** `verify()` read the versioned derivatives with no guard, so a `teille-douce.rng` re-saved in latin-1 — the case the saxonche widening's own comment names — was a traceback out of `odd check`, whose exit 1 is reserved for drift. `fixture golden` on a checkout without the dev extra was another. `failed_last_time` did not inherit the `RecursionError` its sibling gained twelve lines away. Eight changes from the last commit had no test at all: stacking all eight mutations left the suite green. Each has one now, and the `--target` guard needed two attempts — a test of the guard's existence left deleting the CALL green. Also: the third `.rstrip()` could not fire and its comment said otherwise; `check` offered `--strict` on an installation where it changes nothing; the unusable input is named before "nothing to convert", being the more specific cause and the reason there are no volumes. **And the French.** Six test names and their docstrings were written in French because the file around them is. CLAUDE.md asks for English in test names, docstrings and comments; the design note's exemption is for not translating what was already there, not for adding more. They are English now. 1519 tests, coverage 93.4 %, ratchet 92.9. Green with `OCR/` moved aside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
Found while sweeping the classes round four closed — and it hung the shell I was sweeping from, which is how it announced itself. `IIIFMapping.detect_csv` globs the candidates, stats them and reads them with pandas. A FIFO reports zero bytes, so it passed the size cap, and `read_csv` then waited for a writer that never came: `run` and `check` both stopped for ever with nothing on screen. A directory or a broken symlink with the same name raised instead. A candidate has to be a regular file, and `is_file` answers no to all three; `preflight`'s own candidate loop, which reads what the run's detection has just refused, had the same shape and the same fix. Pre-existing, and reachable from a command this instalment adds, which is why it is here rather than in a follow-up: a known silent hang under `teille-douce check` is not something to ship and note. The regression test runs in a subprocess with a timeout, because a regression here HANGS, and a suite that hangs says nothing at all. And two holes in the removal guard written two commits ago — the readability rule, missing from the guard written for the removal rule. A `--target` that is a file raised `NotADirectoryError`; one that cannot be listed raised `PermissionError`; both came straight out of the function whose entire job is to refuse cleanly, at exit 1. An empty directory is now removable too: `mkdir /tmp/fx && fixture build --target /tmp/fx` is the obvious way to try the command, and refusing it bought no safety. 1499 tests, coverage 93.3 %. Green with `OCR/` moved aside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
…balled The class round four closed, broken by the function that closed it — twice, in the same way both times. `_where` carried `-i` to all three commands the summary offers, and `report` has no `-i`: the last line of a run was an `unrecognized arguments` usage error. And it carried `-i`/`-o` alone, so a command pasted after a run given a named `--metadata` reported "no catalogue row" for every volume — a different run from the one being reported. Each command now gets the flags it has, and all of them; `check`'s footer had the same two holes and gets the same four paths. The guard is no longer a list of flag names, because asserting them by name is what let this through — `-vv` is two `-v` and is in no `option_strings`. Every command the summary offers is put through `build_parser().parse_args(normalise(...))`, and `shlex.split` undoes the quoting first, which is the point of quoting it. argparse is the authority on what argparse accepts, so argparse is asked. Verified by hand as well, from a different working directory: the three commands parse, the `report` one finds the run it names and exits 1 because that run had incidents, and `check`'s footer round-trips. `RunOutcome` and the collector carry the two catalogues for this and for nothing else, which is what their comments say. 1500 tests, coverage 93.3 %. Green with `OCR/` moved aside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
The blocker first. The last commit carried the two catalogues from
`run.py` into the collector and from the collector into `RunOutcome`,
and both new tests built `RunOutcome` by hand: deleting either line left
the whole suite green. The guard goes through the binary now — a real
run, a failed volume, a `--metadata` named somewhere else with a space
in it — and each line is condemned by it.
Then the class the previous commit did not close. `iiif.detect_csv` was
the mapping CSV; a page can be a FIFO too. `rglob("*.xml")` yielded it
and `etree.parse` waited for a writer that never came, in the main
process, so `run` never returned and nothing reached the screen — and
`preflight` counted it as a page, so `check` answered "usable · N pages"
about a corpus the run cannot finish. A preflight disagreeing with its
run is the one thing that module says it must not do.
Four more of the same: `--metadata`/`--persons` as a FIFO blocked in
pandas, because `inspect` read the catalogues BEFORE asking which paths
this run could read — the ordering had been fixed for the corpus and
not for the two catalogues, one line down; `store.read_run` guarded
`incidents.jsonl` with `is_file` and not `run.json` beside it;
`validate` took a FIFO as a positional, where `_check` catches
exceptions per file and cannot catch a block; and `--target` as a
broken symlink returned early from the removal guard and then raised
`FileExistsError` out of `mkdir`.
Also: `report` exited 0 for a run whose record could not be read — the
screen said `unreadable run.json` and the exit code told the wrapper the
run was clean. The honest answer to "was it clean" is that it cannot be
told. And two examples in the guide still showed footers this branch had
already replaced; both were put through the real parser.
One mutation could not be run in-process: reverting `validate`'s guard
makes its own test hang, which is the proof it was looking for.
1508 tests, coverage 93.3 %. Green with `OCR/` moved aside.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third and last of the CLI rebuild.
runhad everything it needed afterPR2; what was left was six commands, four of which existed as scripts
with four different conventions, and one project rule broken
everywhere — the help and the messages were in French in a program whose
CLAUDE.mdrequires English.check— the preflightThe command that was missing. The only way to know whether the input was
well formed was to convert the whole corpus: forty minutes to learn that
a
BDDcolumn matches nothing. Four of the ten troubleshooting entriesin the user guide are diagnoses this poses in two seconds — an
unmatched catalogue row, a persons CSV that did not load, file names
with no sortable number, a IIIF mapping under the threshold and
therefore refused — and it poses them with the run's own analyses, so
the two cannot disagree.
Exit 1 is "usable, and degraded"; only an absent input, an empty corpus
or an unwritable output is exit 3. On seventeenth-century OCR
imperfection is the normal state, and a preflight that went red on it
would be run with
|| trueinside a week.validate— the same checks, the right defaults--oddis on: a default that has to print a note explaining that fiveinvariants went unchecked is the wrong default.
-jisauto: adefault every documented invocation overrides is a false default. An
argument may be a directory, and no argument means the output directory.
And the schemas are compiled once — the parent used to build all
four and then have each worker build them again into the context the
check actually reads.
info— where did this value come fromFour layers per setting is a trap rather than a feature without a way to
ask the chain. Layer by layer, including the ones that offered nothing
(the answer to "why is my variable ignored" is always a layer above it)
and including a layer whose value the converters refused — said until
now in a
RuntimeWarningfour hours before anyone read the log.report— coming back on ThursdayReads what a run left under
.teille-douce/runs/. Selectors compose,--codetakes a prefix,--why I2 --contextquotes the log around oneincident, and a half-written record is reported as far as it goes: a run
that went wrong is exactly when that shape turns up.
--limitsseparates what this pipeline cannot measure from what itdoes not measure yet, and gives the second kind its price. Entities
under the NER threshold are the first — the threshold is applied inside
GLiNER's own inference, so what it cost has no denominator. Blocks 1 and
2 over a past run are the second, and
report --block sourcesays "notindexed" rather than "nothing", which would be read as "the run lost
nothing that way".
completion— generated, never copied--fail-on <TAB>offersnever incident lossbecauserecord.pydeclares three. A flag added by a later PR appears with no edit to
completion.py.The verified fixes
build_test_fixture.py--helpdestroyed and regenerated the versioned fixture — everything but--goldenfell through to amain()whose first act isrmtreevalidate_tei.pyrng_simplify.py--jobstype=, so-j eightwas a traceback and exit 1 — which in this CLI means "some volumes failed"odd --refreshrmtreeof whatever--toolchain-dirnamedPath(__file__).parent.parent.parentsite-packages/in a non-editable install, sovalidatesent people toodd build, a command that compiles an ODD the wheel does not carry eitherNumbers
61 test files, 1508 tests, coverage 93.3 % (ratchet 92.5 → 92.9).
cli/fixture.pycame out of the coverageomit, where it had enteredwith the script it came from while its tests measured nothing.
Every fix carries a regression test, and each was run against the code
it condemns.
Five rounds of agent review, folded in
validate --schemanaming anything that is not a RELAX NGgrammar raised inside
_prepare_worker, and aPoolwhose initializerraises respawns its workers for ever — so one transposed letter in the
invocation three documents teach burned two cores with nothing on
screen until it was killed. The parallel path is the default now, so
this was the ordinary case rather than the unlucky one.
raise SystemExit("text")exits 1, which inthis CLI means "some volumes failed": a missing run record, a directory
with no XML in it and two flags that contradict each other all told a
wrapper the corpus was at fault.
cli/exits.pyholds the contract now,and the tests assert the code as well as the message — asserting only
the message is why nothing caught it.
TDOUCE_TEI_RNGrefused every conversion. It is read by the e2etest and by nothing else, and
CLAUDE.mdtells contributors to set it,so a stale value in a shell profile exited 3 over a file no run opens.
its own docstring condemned. Rewriting the second showed that the
collision it described is impossible —
max(2, …)already preventsit — so what the measured column buys is alignment, and that is what
is asserted now.
has no
OCR/and two cores; two assertions were true here and falsethere.
docs/developer-guide.mdgained the shape and the one-linerehearsal that catches it.
It guarded
--schema, which is the flag nobody passes; the parentonly stats the project schemas and never compiles them, so a
truncated
odd buildor a hand-edited derivative still made everyworker's initializer raise, under
teille-douce validatewith noflags at all. The whole body is inside the guard now, and the test
asserts
_prepare_workeritself rather than reaching it through apool: a regression there hangs rather than fails, and a suite that
hangs tells you nothing. Round two also found that both
check.pyfixes had no test at all — reverting either left the suite green,
because that file's width sweep started at 40 and measured against a
bound two cells looser than the renderer's own.
read_run's fixguarded the JSON value and left the decode on the same read open —
UnicodeDecodeErroris aValueError, and a line cut through amultibyte character is the canonical damage this format exists for, so
report --runsstill died with a traceback. Andimport saxonchewaswidened to
except Exceptionin the child, whereexcept Exceptionalready covered it, and not in the parent, where it was the one that
escaped.
Each round's finding was, three times running, the previous round's fix
applied to one call site of several. Round four's response was to close
the class rather than the case:
expandlearned it in round three, and it was untrue in four otherplaces, including a
checkthat crashed outright on a chmod-000OCR/and a
reportthat answered "no run has been recorded here yet" overrecords sitting right there;
--targetis new in this PR, the old script's target was a constant,and
fixture build --target ~/notesdeleted the directory whole;the rule existed in
summaryand had been applied to three lines ofone file, so
report's footer silently answered about the newest runrather than the one on screen.
The mutation pass now runs on every guard as it is written: each test in
these commits was checked by applying the one-line mutation it names to
the production code and confirming it fails.
Sweeping those three classes myself afterwards found six more, all of
them in the code written to close them:
the size cap and
pandas.read_csvthen waited for a writer that nevercame —
runandcheckboth hung with nothing on screen. Itannounced itself by hanging the shell I was sweeping from. Pre-existing
in
metadata/iiif.py, and reachable from a command this PR adds, soit is fixed here rather than noted;
NotADirectoryErroron a--targetthat is a file andPermissionErroron one it could not list — the readability rulemissing from the guard written for the removal rule;
_wherecarried-ito areportthat has none, making the lastline of a run an
unrecognized argumentsusage error, and dropped thetwo catalogues, so a pasted command reported "no catalogue row" for
every volume. The guard is no longer a list of flag names —
-vvistwo
-vand is in nooption_strings, and asserting by name is whatlet it through. Every offered command is now put through
parse_args(normalise(...)): argparse is the authority on whatargparse accepts.
A sixth pass, asked for a merge decision, returned
DO NOT MERGEon onepoint: the wiring that carries the two catalogues from
run.pyinto thecollector and from the collector into
RunOutcomehad no test — bothguards built
RunOutcomeby hand, so deleting either line left thesuite green. It goes through the binary now. The same pass found that
the FIFO class was closed for a mapping CSV and not for a page:
rglob("*.xml")yielded one andetree.parsewaited for a writer thatnever came, in the main process, so
runnever returned — andpreflightcounted it, socheckanswered "usable · N pages" about acorpus the run cannot finish. Four more of the same shape, and a
reportthat exited 0 for a run whose record could not be read.One mutation could not be run in-process: reverting
validate's guardmakes its own test hang, which is the proof it was looking for.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ToHE2uzVAPzcxaZbKktYGz