bindery-cli 0.45.0__tar.gz → 0.46.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/.github/workflows/ci.yml +6 -3
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/CLAUDE.md +23 -16
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/PKG-INFO +4 -3
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/README.md +3 -2
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/patchnotes.md +38 -3
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/plugin/__init__.py +5 -3
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/pyproject.toml +1 -1
- bindery_cli-0.46.1/roadmap.md +212 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/spec.md +32 -14
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/__init__.py +1 -1
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/cli.py +47 -116
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/epub.py +124 -86
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/transforms.py +46 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_cli.py +23 -9
- bindery_cli-0.46.1/tests/test_comment_hyphens.py +279 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_epub.py +115 -51
- bindery_cli-0.46.1/tests/test_flags_real_core.py +487 -0
- bindery_cli-0.46.1/tests/test_flags_wiring.py +113 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_pagination.py +2 -2
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_space_renames.py +4 -3
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/uv.lock +1 -1
- bindery_cli-0.45.0/roadmap.md +0 -2004
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/.github/FUNDING.yml +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/.github/workflows/publish.yml +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/.gitignore +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/AGENTS.md +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/LICENSE +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/docs/screenshots/library-sweep.png +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/logo.svg +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/project.done +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/run_tests.sh +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/scripts/FastSweep.java +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/scripts/build_plugin.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/scripts/fast_sweep.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/__main__.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/audit.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/library.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/pagination.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/reserialize.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/validate.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/src/bindery/watermark.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_audit.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_cover_tocdrift.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_library.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_matcher_hardening.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_plugin.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_reserialize.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_transforms.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_validate.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_version.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_watermark.py +0 -0
- {bindery_cli-0.45.0 → bindery_cli-0.46.1}/tests/test_xml_hardening.py +0 -0
|
@@ -44,9 +44,10 @@ jobs:
|
|
|
44
44
|
# The install floor (decision 63): vir-tui/cquarry are marker-gated
|
|
45
45
|
# to 3.14 there, so these legs install the core (tqdm only) and run
|
|
46
46
|
# exactly the test modules that never touch the gated stack: the
|
|
47
|
-
# repair core, the plugin under calibre stubs, validate,
|
|
48
|
-
# version/grammar pins
|
|
49
|
-
#
|
|
47
|
+
# repair core, the plugin under calibre stubs, validate, the
|
|
48
|
+
# version/grammar pins, the RSC-016 comment-hyphen fix, the
|
|
49
|
+
# RepairFlags wiring pins, and the flags-driven real-core run.
|
|
50
|
+
# audit/library/CLI-stack tests stay on the 3.14 leg above.
|
|
50
51
|
python-version: ["3.12", "3.13"]
|
|
51
52
|
steps:
|
|
52
53
|
- uses: actions/checkout@v5
|
|
@@ -59,6 +60,8 @@ jobs:
|
|
|
59
60
|
tests.test_transforms tests.test_epub tests.test_pagination
|
|
60
61
|
tests.test_watermark tests.test_reserialize tests.test_version
|
|
61
62
|
tests.test_plugin tests.test_validate
|
|
63
|
+
tests.test_comment_hyphens tests.test_flags_wiring
|
|
64
|
+
tests.test_flags_real_core
|
|
62
65
|
plugin-compat:
|
|
63
66
|
name: Parse-check the plugin zip under the interpreters Calibre embeds
|
|
64
67
|
runs-on: ubuntu-latest
|
|
@@ -30,21 +30,26 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
30
30
|
`xmlns`, bare `&`, named entities, void self-closing), the NCX pipeline, and the
|
|
31
31
|
mimetype fix (added/normalized/first-stored, epub.py's archive rewrite); every core
|
|
32
32
|
fix must render identically to the author's intent: never add, remove, or reorder
|
|
33
|
-
visible content. The canonical opt-in inventory lives in spec.md:
|
|
34
|
-
repairs,
|
|
33
|
+
visible content. The canonical opt-in inventory lives in spec.md: sixteen structural
|
|
34
|
+
repairs, four lossy strips, four safe opt-ins, plus `--reserialize`.
|
|
35
35
|
* **Structural repairs** (`--fix-empty-body`, `--fix-missing-title`, `--fix-id-colons`,
|
|
36
36
|
`--fix-page-map`, `--strip-epub3-attrs`, `--downgrade-epub3-tags`,
|
|
37
37
|
`--unwrap-block-in-inline`, `--strip-invalid-value`, `--unwrap-illegal-tags`,
|
|
38
38
|
`--prune-missing-resources`, `--strip-broken-anchors`, `--encode-url-spaces`,
|
|
39
|
-
`--fix-container`, `--fix-media-types`, `--fix-cover
|
|
40
|
-
|
|
39
|
+
`--fix-container`, `--fix-media-types`, `--fix-cover`,
|
|
40
|
+
`--fix-comment-double-hyphen`; transforms.py, threaded
|
|
41
|
+
through epub.py). `--fix-comment-double-hyphen` (v0.46.0, the RSC-016 fatal)
|
|
42
|
+
replaces `--` inside XML comments with an en-dash: comment bodies only (text
|
|
43
|
+
nodes and CDATA never touched, the one deliberate exception to the
|
|
44
|
+
never-rewrite-comments invariant), in content documents, the NCX, and the OPF
|
|
45
|
+
alike; normal `gate` (clearing the fatal IS the measurable gain). Since v0.44.0 `--encode-url-spaces` also RENAMES the
|
|
41
46
|
archive entries whose names carry raw spaces to their underscore spellings
|
|
42
47
|
and rewrites every reference (OPF, NCX, content, CSS `url()`); underscore,
|
|
43
48
|
never percent-encoding (epubcheck decodes references before entry lookup,
|
|
44
49
|
verified against 5.3), ambiguous renames refused per entry (`space_rename_map`),
|
|
45
50
|
accepted under `no_worse` because PKG-010 sits on the warning axis the gate
|
|
46
|
-
does not measure
|
|
47
|
-
|
|
51
|
+
does not measure.
|
|
52
|
+
They alter markup structure or fabricate minimal content. v0.14–v0.16 ran these unconditionally, which broke this rule;
|
|
48
53
|
v0.17.0 restored it. `--unwrap-illegal-tags` additionally protects any illegal-tag
|
|
49
54
|
name that an EPUB stylesheet styles as an element selector (`css_protected_tags`,
|
|
50
55
|
book-wide, inline `<style>` blocks included). The two EPUB2-targeted fixes
|
|
@@ -75,11 +80,13 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
75
80
|
- **The gate is the safety contract.** Never apply a repair epubcheck has not accepted.
|
|
76
81
|
Respect the two-mode logic in `validate.gate` (fatal-fixing tolerates error unmasking;
|
|
77
82
|
error-cleanup does not). The lossy strips (`--strip-pagination`, `--strip-broken-tags`,
|
|
78
|
-
`--strip-watermarks`) are accepted by `validate.no_worse` instead
|
|
79
|
-
invisible to epubcheck, so it only forbids a regression, never demands
|
|
80
|
-
improvement). The structural opt-ins go through the normal `gate
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
`--strip-watermarks`, `--strip-stub-docs`) are accepted by `validate.no_worse` instead
|
|
84
|
+
(their gain is invisible to epubcheck, so it only forbids a regression, never demands
|
|
85
|
+
a measured improvement). The structural opt-ins go through the normal `gate` (their
|
|
86
|
+
gain IS visible, so a run with no measurable improvement is a noop and nothing is
|
|
87
|
+
applied) except the two whose gains sit on axes epubcheck does not measure:
|
|
88
|
+
`--fix-cover` and `--encode-url-spaces`, accepted under the same `no_worse` bar with
|
|
89
|
+
the partial rule intact. Changing either bar means re-running the library dry run.
|
|
83
90
|
- **Library writes are sacred.** Replacement must stay atomic (temp in same dir, then
|
|
84
91
|
`os.replace`), touch only the `.epub`, preserve mode, and be dry-run by default.
|
|
85
92
|
Calibre format installation goes through cquarry's write module (`--install-to-calibre`;
|
|
@@ -88,17 +95,17 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
88
95
|
|
|
89
96
|
## Layout
|
|
90
97
|
|
|
91
|
-
- `src/bindery/transforms.py`: pure `str -> (str, int)` text transforms (including `strip_broken_tags`). Since v0.32.0: `strip_attrs_in_start_tags` anchors attribute edits on the quote-aware start-tag matcher, `_outside_protected` forwards arguments (context-carrying transforms can be decorated), `fix_id_colons` matches only the bare `id` attribute and only internal fragments (`fix_ncx_src_fragments` carries renames into the NCX), `fix_ncx_playorder` is anchored to `<navPoint>` start tags, and the css selector boundary covers namespaced and functional selector forms. HAZARD (the 0.41.0 spin): the quote-aware tag-prefix alternation (double-quoted | single-quoted | [^>]) OVERLAPS ([^>] matches quotes too), so a plain `*` re-partitions exponentially on failing candidates; every such greedy loop must carry the possessive `*+` (re 3.11+, the plugin's minimum Calibre). Since v0.42.0 the census is complete and pinned by tests/test_matcher_hardening.py: every greedy loop of this family is possessive (the three 0.41.1 rewrites plus _START_TAG_RE, _COVER_META_RE, _GUIDE_REF_RE, prune_dangling_edges' spine|item|itemref matcher, _ITEM_TAG_RE, _SPINE_ITEM_RE
|
|
98
|
+
- `src/bindery/transforms.py`: pure `str -> (str, int)` text transforms (including `strip_broken_tags`). Since v0.32.0: `strip_attrs_in_start_tags` anchors attribute edits on the quote-aware start-tag matcher, `_outside_protected` forwards arguments (context-carrying transforms can be decorated), `fix_id_colons` matches only the bare `id` attribute and only internal fragments (`fix_ncx_src_fragments` carries renames into the NCX), `fix_ncx_playorder` is anchored to `<navPoint>` start tags, and the css selector boundary covers namespaced and functional selector forms. HAZARD (the 0.41.0 spin): the quote-aware tag-prefix alternation (double-quoted | single-quoted | [^>]) OVERLAPS ([^>] matches quotes too), so a plain `*` re-partitions exponentially on failing candidates; every such greedy loop must carry the possessive `*+` (re 3.11+, the plugin's minimum Calibre). Since v0.42.0 the census is complete and pinned by tests/test_matcher_hardening.py: every greedy loop of this family is possessive (the three 0.41.1 rewrites plus _START_TAG_RE, _COVER_META_RE, _GUIDE_REF_RE, prune_dangling_edges' spine|item|itemref matcher, _ITEM_TAG_RE, _SPINE_ITEM_RE; possessive is byte-identical on success because the loop is always followed by a literal `>` the [^>] branch cannot consume), and the five LAZY siblings (_VOID_RE, the transforms <img> matcher, and epub's link/a/img matchers) use the disjoint catch-all `[^>"']` instead: mutually exclusive branches cannot re-partition, and an unterminated quote inside a tag now fails to match rather than pairing across markup. NEW tag matchers: quote-aware possessive for greedy loops, the disjoint catch-all for lazy ones, and the tempered-quote idiom (["'])((?:(?!\1).)*)\1 for attribute values. Since v0.37.0: `fix_ncx_playorder` strips quotes before its already-correct comparison (regex groups carry quote characters; comparing quoted values against bare numbers counted phantom fixes on every sequential NCX and rewrote single-quoted correct attributes to double quotes).
|
|
92
99
|
- `src/bindery/pagination.py`: the opt-in lossy page-number strip (runhead detection, page-layer decision, block-centric removal/merge, safety nets).
|
|
93
100
|
- `src/bindery/watermark.py`: the opt-in lossy watermark strip (anchored and anchorless signature removal).
|
|
94
101
|
- `src/bindery/reserialize.py`: structural repair via `html5lib`.
|
|
95
102
|
- `src/bindery/audit.py`: read-only body-text audits (`content`, `pagenumbers`, `emptytext`, `ocr`, `monolithic` since v0.21.0 with `--max-doc-chars N`, and `completeness` since v0.36.0) behind the `audit` subcommand (v0.15.0). Since v0.18.0 library mode resolves EPUB paths through `cquarry.get_format_path()` and can apply a tag to flagged books via `cquarry.write.WritableCalibreDB` (only with explicit `--tag`; the only sanctioned write path). Since v0.19.0 `audit --id BOOK_ID` audits a single library book through cquarry's single-entity `get_book()` fetch (no library-wide cache; supports `--tag`; incompatible with the directory argument; comma lists since v0.23.0). Since v0.22.0 every archive entry is fully read (CRC + decompression) before analysis (a damaged entry reports its own CORRUPT verdict instead of feeding emptytext) and manifest/NCX references to absent files classify as `convention` (bloated ToC, consecutive span) or `fragment` (broken span). Hazard: the scan loop reuses `tag` as its per-book display column, so the `--tag` argument is captured as `audit_tag` at function entry; do not collapse them again. Since v0.29.0 `audit --json FILE` writes per-file analyzer verdicts in the `library --json` shape (directory, library, and single-book modes; with `--id`, exactly one id; emptytext omitted from a record when the archive verdict owns the body-text story). Since v0.44.0 two more advisory analyzers ride the single pass: `cover` (the EPUB3 `properties~="cover-image"` slice of the ruled hybrid: dangling EPUB2 meta, EPUB3 declaration, cover-file presence) and `tocdrift` (the NCX navMap vs EPUB3 nav toc structural diff, fragments included; audit-only, ToC synthesis out of charter permanently); the loader now exposes the parsed OPF, the NCX text, and the nav HTML on `Book`. Since v0.36.0 the completeness analyzer (Phase 15) reports the phase-1 spot-check per book: spine/prose-doc counts (prose = >= 400 visible chars), first/middle/last prose-doc opening/closing excerpts, trailing-ToC classification (`_trailing_toc`: short link lines dominate, no paragraph-length blocks), and the unreadable fraction. It is ADVISORY by contract (problem always False; ADVISORY on a trailing ToC or unreadable fraction >= 10%), never moves the exit code, and is skipped like emptytext when the archive verdict owns the book. Since v0.38.0 the archive verdict distinguishes font obfuscation from DRM (`OBFUSCATION_ALGOS`: IDPF 2008/embedding + both Adobe URIs; readable obfuscated entries are the benign OBFUSCATED advisory, an unreadable one is CORRUPT, and only non-obfuscation algorithms give ENCRYPTED). Since v0.43.0 untrusted metadata XML is parsed through `_safe_xml_parse` (DOCTYPE/ENTITY declarations refused before xml.etree sees them; the stdlib shape of defusedxml's entity protection) and single entries above `_MAX_ENTRY_BYTES` (32 MB) are refused before decompression; a refused metadata file returns the shell book. Since v0.40.0 the vir-tui console renderer loads through the module-level `_LazyUI` proxy (a plain `import vir_tui as ui` at module level would make 3.12/3.13 installs unimportable now that the stack is marker-gated; LOAD_GLOBAL never consults module `__getattr__`, so a proxy object is the lazy shape that works).
|
|
96
|
-
- `src/bindery/epub.py`: archive rewrite, NCX uid sync, RepairReport, mismatch detection, and the opt-in structural-repair plumbing (including the CSS precondition scan). Since v0.38.0/v0.39.0 (Phase 16): `generate_container` + the `--fix-container` gateway (insert after mimetype when missing, replace in-loop when stale; constant-epoch timestamp keeps bytes deterministic), `prune_dangling_edges` (prune_missing_manifest_items returns the pruned ids and the edges that pointed at them (spine@toc, media-overlay, fallback, EPUB2 cover meta) are rewritten so pruning cannot manufacture the regression the gate rejects), and `fix_manifest_media_types` (extension map + magic-byte confirmation via a `peek` callable over the open source zip; jpg/png/gif only), and `fix_cover_meta` (the ruling's deterministic half: dangling EPUB2 cover meta re-pointed from the guide's cover reference when exactly one manifest item carries that file, removed otherwise; accepted under no_worse like the lossy strips because cover wiring is invisible to epubcheck).
|
|
103
|
+
- `src/bindery/epub.py`: archive rewrite, NCX uid sync, RepairReport, mismatch detection, and the opt-in structural-repair plumbing (including the CSS precondition scan). Since v0.46.0 the opt-in selection is the `RepairFlags` dataclass (one field per flag, all off by default; the all-off instance IS the default pass): `repair_epub(src, dst, flags)` and `process_book(..., flags)` take one object instead of a ~25-kwarg signature, the EPUB2-targeted fixes' version gate swaps in a `dataclasses.replace` copy (never mutating the caller's instance), and the plugin's bare `repair_epub(src, dst)` call constructs exactly the all-off default pass. Since v0.38.0/v0.39.0 (Phase 16): `generate_container` + the `--fix-container` gateway (insert after mimetype when missing, replace in-loop when stale; constant-epoch timestamp keeps bytes deterministic), `prune_dangling_edges` (prune_missing_manifest_items returns the pruned ids and the edges that pointed at them (spine@toc, media-overlay, fallback, EPUB2 cover meta) are rewritten so pruning cannot manufacture the regression the gate rejects), and `fix_manifest_media_types` (extension map + magic-byte confirmation via a `peek` callable over the open source zip; jpg/png/gif only), and `fix_cover_meta` (the ruling's deterministic half: dangling EPUB2 cover meta re-pointed from the guide's cover reference when exactly one manifest item carries that file, removed otherwise; accepted under no_worse like the lossy strips because cover wiring is invisible to epubcheck).
|
|
97
104
|
- `src/bindery/validate.py`: epubcheck wrapper, the `gate` (improvement) and `no_worse` (no-regression, for the lossy strips) acceptance bars.
|
|
98
105
|
- `src/bindery/library.py`: Calibre walk, atomic replace, backups, and native format installation. Since v0.19.0 `CalibreIdResolver` resolves the book id from `metadata.db` through cquarry (one lazy path→id map per run; since v0.20.0 the map comes from `CalibreDB.format_path_index()`, re-normalized with `resolve().lower()` for the resolver's symlinked-directory and case-insensitive matching); the `(id)` directory-name regex is only the no-catalog fallback. Since v0.24.0 `install_format()` places the repaired file atomically and updates the `data` row through `cquarry.write.WritableCalibreDB` (since v0.31.0 via `set_format`, cquarry 1.17's sanctioned remove+add in one transaction); the external `calibredb` CLI is gone. Since v0.32.0 a guessed id drives a row update only when metadata.db corroborates it (`_verify_guess`: books row exists, file in the book's own directory, catalogued `data.name` when a row exists); anything else saves in place and leaves the catalog untouched: never reintroduce directory-name guessing as the primary source: renamed/mismatched directories would replace the wrong book. Since 2026-09-15 `make_backup` takes the opt-in `--backup-keep N` ring: at most N backup files per book, the author original `.bak` never deleted, newest content at the highest name; default remains an unbounded rotation.
|
|
99
|
-
- `src/bindery/cli.py`: `repair` and `library` subcommands, including `--all` and `--install-to-calibre`; `repair --json` emits the library per-book record vocabulary (2026-09-15; since v0.45.0 every per-book record, the phase1 payload included, also carries the structured fix breakdown: the `fixes` dict plus `ncx_uid_synced`/`watermark_refusals` off the `Outcome`, and `_phase1_decisions` reads that data instead of substring-matching the rendered `summary`, which stays for human eyes; CalibreQuarry's lossy-consent mirror is the waiting consumer, floor `bindery>=0.45.0`); since v0.29.0 also the `run` verbs: `phase1` (pre-import vetting over loose files: the audit battery composed with one gated repair sweep; read-only until `--apply-lossy`, which IS the lossy-strip consent) and `phase3` (the scoped post-import apply step: `library --id --sweep --only all --apply --all --install-to-calibre` plus a pre/post summary; mechanically refuses unscoped sweeps with exit 2; since 2026-09-15 the summary sums applied/equal states only and carries rejected projections as `rejected_projection`). Plus `bindery doctor` (2026-09-15): the environment self-check that imports none of the VirInvictus stack, never raises, and always exits 0. Both run verbs take `--non-interactive` and surface open questions as `decisions_needed` in their JSON, never prompts. They drive the shipped `run_library` through the real parser, so no flag can drift between the verb and the subcommand it wraps. `library --workers N` (v0.30.0) parallelizes only the sweep's candidate pass, in windows of N consumed in order so `--limit` stays lazy; the repair phase is never parallel (shared workdir, atomic-replacement contract). Since v0.40.0 `main()` guards the VirInvictus stack: a `ModuleNotFoundError` naming `vir_tui`/`cquarry` (marker-gated to 3.14+ on the 3.12 floor) becomes one stderr line and trouble exit 2 instead of a traceback; anything else missing still raises.
|
|
100
|
-
- `plugin/__init__.py` + `scripts/build_plugin.py`: the Bindery Repair Calibre plugin (v0.37.0; identity `Bindery Repair` / `bindery_repair`, approved and built per the scoped spec in roadmap.md Phase 3). The builder vendors `transforms.py`, `epub.py`, `pagination.py`, `watermark.py`, `reserialize.py` byte-identically into the zip (the zip root is a package, so their relative imports resolve unchanged; the suite's drift test pins the equality) with the version tuple substituted from the single-source VERSION; `publish.yml` attaches `BinderyRepair-v<VERSION>.zip` to each release. The plugin runs ONLY the default pass (epubcheck cannot gate inside Calibre), never raises, is byte-idempotent (zero fixes returns the original path), testzip()-verifies its output, logs one line per book, and takes JSON config via `site_customization` (`log`, `log_path`, `max_size_mb` default 150, `epubcheck_path` experimental validation default OFF). Load it in tests through the `tests/test_plugin.py` stubs: the calibre namespace is installed in sys.modules and the package loads with a two-dir `__path__` (plugin dir first, then src/bindery) exactly like calibre's zipplugin loader shape. **Plugin/interpreter compatibility (v0.40.0):** v0.39.0 shipped PEP 758 unparenthesized except tuples, and the plugin died with a bare SyntaxError on every released Calibre (7.x and the whole 8.x series embed Python 3.11, 9.0+ embeds 3.14; from calibre's bypy sources.json, checked against the upstream clone). The core is now grammar-pinned: parenthesized except tuples everywhere, `ruff`'s `target-version = "py312"` pin (inference from requires-python would rewrite the parens back off), `tests/test_version.py`'s parse guard, and CI's `plugin-compat` job byte-compiling the built zip under 3.11/3.12/3.13/3.14. `minimum_calibre_version` is (7, 0, 0): the oldest series whose interpreter CI covers, replacing the hollow (2, 0, 0); `supported_platforms` stays `["linux"]` (developed and tested on Linux only). Any new syntax in the vendored modules must clear the guard before it ships.
|
|
101
|
-
- `tests/`: transforms, end-to-end repair, atomic replace, pagination, watermarks, the audit analyzers (content/pagenumbers/emptytext/ocr/monolithic/completeness, archive integrity, spine classification), the library sweep and `CalibreIdResolver`, validate, reserialize, CLI wiring, the version pin and the syntax-floor grammar guard, and the Calibre plugin (build drift + run behavior under calibre stubs).
|
|
106
|
+
- `src/bindery/cli.py`: `repair` and `library` subcommands, including `--all` and `--install-to-calibre`; `repair --json` emits the library per-book record vocabulary (2026-09-15; since v0.45.0 every per-book record, the phase1 payload included, also carries the structured fix breakdown: the `fixes` dict plus `ncx_uid_synced`/`watermark_refusals` off the `Outcome`, and `_phase1_decisions` reads that data instead of substring-matching the rendered `summary`, which stays for human eyes; CalibreQuarry's lossy-consent mirror is the waiting consumer, floor `bindery>=0.45.0`); since v0.29.0 also the `run` verbs: `phase1` (pre-import vetting over loose files: the audit battery composed with one gated repair sweep; read-only until `--apply-lossy`, which IS the lossy-strip consent) and `phase3` (the scoped post-import apply step: `library --id --sweep --only all --apply --all --install-to-calibre` plus a pre/post summary; mechanically refuses unscoped sweeps with exit 2; since 2026-09-15 the summary sums applied/equal states only and carries rejected projections as `rejected_projection`). Plus `bindery doctor` (2026-09-15): the environment self-check that imports none of the VirInvictus stack, never raises, and always exits 0. Both run verbs take `--non-interactive` and surface open questions as `decisions_needed` in their JSON, never prompts. They drive the shipped `run_library` through the real parser, so no flag can drift between the verb and the subcommand it wraps. Since v0.46.0 `cli._flags_from_args(args)` is the one place the argparse names map onto `RepairFlags` fields (each `or --all`), shared by `run_library` and `run_repair`; the old per-verb ~25-kwarg blocks are gone. `library --workers N` (v0.30.0) parallelizes only the sweep's candidate pass, in windows of N consumed in order so `--limit` stays lazy; the repair phase is never parallel (shared workdir, atomic-replacement contract). Since v0.40.0 `main()` guards the VirInvictus stack: a `ModuleNotFoundError` naming `vir_tui`/`cquarry` (marker-gated to 3.14+ on the 3.12 floor) becomes one stderr line and trouble exit 2 instead of a traceback; anything else missing still raises.
|
|
107
|
+
- `plugin/__init__.py` + `scripts/build_plugin.py`: the Bindery Repair Calibre plugin (v0.37.0; identity `Bindery Repair` / `bindery_repair`, approved and built per the scoped spec in roadmap.md Phase 3). The builder vendors `transforms.py`, `epub.py`, `pagination.py`, `watermark.py`, `reserialize.py` byte-identically into the zip (the zip root is a package, so their relative imports resolve unchanged; the suite's drift test pins the equality) with the version tuple substituted from the single-source VERSION; `publish.yml` attaches `BinderyRepair-v<VERSION>.zip` to each release. The plugin runs ONLY the default pass (epubcheck cannot gate inside Calibre), never raises, is byte-idempotent (zero fixes returns the original path), testzip()-verifies its output, logs one line per book, and takes JSON config via `site_customization` (`log`, `log_path`, `max_size_mb` default 150, `max_log_mb` rotation cap default 2, `epubcheck_path` experimental validation default OFF). Load it in tests through the `tests/test_plugin.py` stubs: the calibre namespace is installed in sys.modules and the package loads with a two-dir `__path__` (plugin dir first, then src/bindery) exactly like calibre's zipplugin loader shape. **Plugin/interpreter compatibility (v0.40.0):** v0.39.0 shipped PEP 758 unparenthesized except tuples, and the plugin died with a bare SyntaxError on every released Calibre (7.x and the whole 8.x series embed Python 3.11, 9.0+ embeds 3.14; from calibre's bypy sources.json, checked against the upstream clone). The core is now grammar-pinned: parenthesized except tuples everywhere, `ruff`'s `target-version = "py312"` pin (inference from requires-python would rewrite the parens back off), `tests/test_version.py`'s parse guard, and CI's `plugin-compat` job byte-compiling the built zip under 3.11/3.12/3.13/3.14. `minimum_calibre_version` is (7, 0, 0): the oldest series whose interpreter CI covers, replacing the hollow (2, 0, 0); `supported_platforms` stays `["linux"]` (developed and tested on Linux only). Any new syntax in the vendored modules must clear the guard before it ships.
|
|
108
|
+
- `tests/`: transforms, end-to-end repair, atomic replace, pagination, watermarks, the audit analyzers (content/pagenumbers/emptytext/ocr/monolithic/completeness, archive integrity, spine classification), the library sweep and `CalibreIdResolver`, validate, reserialize, CLI wiring, the version pin and the syntax-floor grammar guard, and the Calibre plugin (build drift + run behavior under calibre stubs). Since the v0.46.0 follow-ups: `tests/test_flags_wiring.py` reflectively pins the RepairFlags inventory to the argparse dests and `_flags_from_args` mapping (a flag added without a field, a field without a flag, or a remapped line fails there), the all-off defaults, and the version gate's caller-immutability contract (test_epub's `TestVersionGateKeepsFlagsIntact`); `tests/test_comment_hyphens.py` carries the RSC-016 fix; `tests/test_flags_real_core.py` drives every repair flag from argv through the unmocked core (--no-validate; the gate itself stays pinned by the mocked-oracle tests and runs for real wherever epubcheck exists). All three ride CI's core-compat 3.12/3.13 leg; the hand-listed module list there must gain an entry for every new stack-free test module.
|
|
102
109
|
|
|
103
110
|
## Conventions
|
|
104
111
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bindery-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.46.1
|
|
4
4
|
Summary: Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library.
|
|
5
5
|
Project-URL: Homepage, https://github.com/VirInvictus/bindery-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/VirInvictus/bindery-cli
|
|
@@ -67,10 +67,11 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
67
67
|
- **`--unwrap-illegal-tags`**: strips completely invalid or deprecated HTML tags that break EPUB3 validation (`<st>`, `<sentence>`, `<o>`, `<w>`, `<pagebreak>`) while retaining their inner text. Any of those names styled as an *element selector* by an EPUB stylesheet (`.css` entries and inline `<style>` blocks alike; class/id selectors like `.st`/`#w` don't count) is protected for the whole book, guaranteeing format preservation.
|
|
68
68
|
- **`--prune-missing-resources`**: removes references to files the archive does not contain (RSC-007/PKG-010): dead `<link>` elements, anchors' `href` to absent files (anchor text preserved), absent `<img>` sources (replaced by their alt text when they carry one), and orphaned non-spine OPF manifest items (with every package edge that pointed at them rewritten: `spine@toc`, `item@media-overlay`, `item@fallback`, and the EPUB2 cover meta). Spine documents are never pruned: a missing spine document is reported as a damaged fragment, not silently dropped.
|
|
69
69
|
- **`--strip-broken-anchors`**: strips href attributes that cannot resolve, keeping the anchor text byte-for-byte: a `#fragment` the target document does not define (RSC-020/RSC-012; NCX navTargets fall back to the document target, so chapter navigation survives) and unresolvable URI schemes (`kindle:`, `file:`).
|
|
70
|
-
- **`--encode-url-spaces`**: percent-encodes raw spaces in `src`/`href` attribute values across the package (OPF manifest, NCX, content documents). A URL with a literal space is not a valid URL (RSC-020) and unresolvable on strict readers; the encoded form denotes the same file.
|
|
70
|
+
- **`--encode-url-spaces`**: percent-encodes raw spaces in `src`/`href` attribute values across the package (OPF manifest, NCX, content documents). A URL with a literal space is not a valid URL (RSC-020) and unresolvable on strict readers; the encoded form denotes the same file. Since v0.44.0 the flag also renames archive entries whose names carry raw spaces to their underscore spellings and rewrites every reference to them (OPF, NCX, content, CSS `url()`), clearing the PKG-010 space-in-filename advisories: underscore, never percent-encoding, because epubcheck decodes references before entry lookup.
|
|
71
71
|
- **`--fix-container`**: generates `META-INF/container.xml` at the located OPF when the container is missing or names a file the archive does not contain. This is the gateway defect: epubcheck stays fatal while the OPF is unfindable, so no repair can be gate-accepted on such a book until the container exists.
|
|
72
72
|
- **`--fix-media-types`**: normalizes wrong manifest media-type declarations (OPF-029, e.g. a jpg stamped `image/png` by an aggregator). Attribute-only and quote-preserving; it fires only when the file's magic bytes confirm the extension, so a misnamed-but-consistent file (a PNG renamed .jpg) is never made worse.
|
|
73
73
|
- **`--fix-cover`**: repairs dangling EPUB2 cover wiring. A `<meta name="cover">` whose content names no manifest item is re-pointed when the OPF guide's own cover reference names an existing item, and removed when nothing identifies it; EPUB3 `properties="cover-image"` is deliberately audit-only (guessing which image is the cover is not deterministic). Cover wiring is invisible to epubcheck, so cover-only repairs are accepted under the same no-worse bar the lossy strips use.
|
|
74
|
+
- **`--fix-comment-double-hyphen`**: replaces `--` sequences inside XML comments with en-dashes. `--` is illegal inside an XML comment (epubcheck fatal RSC-016: the book opens in lenient readers but never passes epubcheck). The edit stays inside the comment bodies: text nodes and CDATA sections are never touched, and each comment's terminator is left intact.
|
|
74
75
|
|
|
75
76
|
|
|
76
77
|
Four opt-in fixes are **lossy** and stand apart from the semantics-preserving rest:
|
|
@@ -93,7 +94,7 @@ Introducing a net-new fatal is always rejected. If epubcheck itself fails to run
|
|
|
93
94
|
|
|
94
95
|
Under the hood, the oracle can run two ways: the usual `epubcheck --json -` subprocess, or a persistent daemon that writes `FastDaemon.java` into a temp directory at runtime, compiles it in memory with the running JVM's own compiler (Java's single-file source launcher: no javac, no javac/java version skew), and drives the warm JVM over a pipe. The daemon reports the counts it reads from the JSON document that epubcheck's own `CheckingReport` serializes, so it measures exactly what the subprocess measures, just ~15x faster. It is a pool bounded by `--workers` (serial runs use one), every roundtrip is bounded by the caller's timeout, and any failure tears it down and falls back to the subprocess for good.
|
|
95
96
|
|
|
96
|
-
The lossy modes (`--strip-pagination`, `--strip-broken-tags`, and `--strip-
|
|
97
|
+
The lossy modes (`--strip-pagination`, `--strip-broken-tags`, `--strip-watermarks`, and `--strip-stub-docs`) are the exception to the "must improve" rule. Since they remove converter-injected content rather than correcting XML schema violations, epubcheck counts often remain unchanged. They are accepted when the result is **no worse** (no net-new fatals or errors), relying on strict programmatic safety nets instead.
|
|
97
98
|
|
|
98
99
|
## Install
|
|
99
100
|
|
|
@@ -40,10 +40,11 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
40
40
|
- **`--unwrap-illegal-tags`**: strips completely invalid or deprecated HTML tags that break EPUB3 validation (`<st>`, `<sentence>`, `<o>`, `<w>`, `<pagebreak>`) while retaining their inner text. Any of those names styled as an *element selector* by an EPUB stylesheet (`.css` entries and inline `<style>` blocks alike; class/id selectors like `.st`/`#w` don't count) is protected for the whole book, guaranteeing format preservation.
|
|
41
41
|
- **`--prune-missing-resources`**: removes references to files the archive does not contain (RSC-007/PKG-010): dead `<link>` elements, anchors' `href` to absent files (anchor text preserved), absent `<img>` sources (replaced by their alt text when they carry one), and orphaned non-spine OPF manifest items (with every package edge that pointed at them rewritten: `spine@toc`, `item@media-overlay`, `item@fallback`, and the EPUB2 cover meta). Spine documents are never pruned: a missing spine document is reported as a damaged fragment, not silently dropped.
|
|
42
42
|
- **`--strip-broken-anchors`**: strips href attributes that cannot resolve, keeping the anchor text byte-for-byte: a `#fragment` the target document does not define (RSC-020/RSC-012; NCX navTargets fall back to the document target, so chapter navigation survives) and unresolvable URI schemes (`kindle:`, `file:`).
|
|
43
|
-
- **`--encode-url-spaces`**: percent-encodes raw spaces in `src`/`href` attribute values across the package (OPF manifest, NCX, content documents). A URL with a literal space is not a valid URL (RSC-020) and unresolvable on strict readers; the encoded form denotes the same file.
|
|
43
|
+
- **`--encode-url-spaces`**: percent-encodes raw spaces in `src`/`href` attribute values across the package (OPF manifest, NCX, content documents). A URL with a literal space is not a valid URL (RSC-020) and unresolvable on strict readers; the encoded form denotes the same file. Since v0.44.0 the flag also renames archive entries whose names carry raw spaces to their underscore spellings and rewrites every reference to them (OPF, NCX, content, CSS `url()`), clearing the PKG-010 space-in-filename advisories: underscore, never percent-encoding, because epubcheck decodes references before entry lookup.
|
|
44
44
|
- **`--fix-container`**: generates `META-INF/container.xml` at the located OPF when the container is missing or names a file the archive does not contain. This is the gateway defect: epubcheck stays fatal while the OPF is unfindable, so no repair can be gate-accepted on such a book until the container exists.
|
|
45
45
|
- **`--fix-media-types`**: normalizes wrong manifest media-type declarations (OPF-029, e.g. a jpg stamped `image/png` by an aggregator). Attribute-only and quote-preserving; it fires only when the file's magic bytes confirm the extension, so a misnamed-but-consistent file (a PNG renamed .jpg) is never made worse.
|
|
46
46
|
- **`--fix-cover`**: repairs dangling EPUB2 cover wiring. A `<meta name="cover">` whose content names no manifest item is re-pointed when the OPF guide's own cover reference names an existing item, and removed when nothing identifies it; EPUB3 `properties="cover-image"` is deliberately audit-only (guessing which image is the cover is not deterministic). Cover wiring is invisible to epubcheck, so cover-only repairs are accepted under the same no-worse bar the lossy strips use.
|
|
47
|
+
- **`--fix-comment-double-hyphen`**: replaces `--` sequences inside XML comments with en-dashes. `--` is illegal inside an XML comment (epubcheck fatal RSC-016: the book opens in lenient readers but never passes epubcheck). The edit stays inside the comment bodies: text nodes and CDATA sections are never touched, and each comment's terminator is left intact.
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
Four opt-in fixes are **lossy** and stand apart from the semantics-preserving rest:
|
|
@@ -66,7 +67,7 @@ Introducing a net-new fatal is always rejected. If epubcheck itself fails to run
|
|
|
66
67
|
|
|
67
68
|
Under the hood, the oracle can run two ways: the usual `epubcheck --json -` subprocess, or a persistent daemon that writes `FastDaemon.java` into a temp directory at runtime, compiles it in memory with the running JVM's own compiler (Java's single-file source launcher: no javac, no javac/java version skew), and drives the warm JVM over a pipe. The daemon reports the counts it reads from the JSON document that epubcheck's own `CheckingReport` serializes, so it measures exactly what the subprocess measures, just ~15x faster. It is a pool bounded by `--workers` (serial runs use one), every roundtrip is bounded by the caller's timeout, and any failure tears it down and falls back to the subprocess for good.
|
|
68
69
|
|
|
69
|
-
The lossy modes (`--strip-pagination`, `--strip-broken-tags`, and `--strip-
|
|
70
|
+
The lossy modes (`--strip-pagination`, `--strip-broken-tags`, `--strip-watermarks`, and `--strip-stub-docs`) are the exception to the "must improve" rule. Since they remove converter-injected content rather than correcting XML schema violations, epubcheck counts often remain unchanged. They are accepted when the result is **no worse** (no net-new fatals or errors), relying on strict programmatic safety nets instead.
|
|
70
71
|
|
|
71
72
|
## Install
|
|
72
73
|
|
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
# bindery-cli Patch Notes
|
|
2
|
+
## v0.46.1 (2026-10-02)
|
|
3
|
+
|
|
4
|
+
### The closing sweep: documentation truth after the 0.46 line
|
|
5
|
+
|
|
6
|
+
The 2026-10-02 verification of the four-lane run left four documentation
|
|
7
|
+
findings against the v0.46.0 tree; all four land here as text plus one
|
|
8
|
+
plugin string. No surface change beyond the plugin's help text.
|
|
9
|
+
|
|
10
|
+
* The safety contract's lossy enumeration names all four modes: the
|
|
11
|
+
paragraph listed three and omitted `--strip-stub-docs` (shipped
|
|
12
|
+
v0.41.0), while the mode list twenty lines up, spec.md, and CLAUDE.md
|
|
13
|
+
all carry four. Its rationale sentence now says converter-injected
|
|
14
|
+
content rather than visible markup, true of the document-dropping stub
|
|
15
|
+
mode too.
|
|
16
|
+
* CLAUDE.md's tests bullet loses its em-dash: the one straggler in the
|
|
17
|
+
v0.45.0..HEAD markdown delta, recast with a semicolon.
|
|
18
|
+
* ci.yml's core-compat comment describes every module its list runs: the
|
|
19
|
+
v0.46.0 follow-ups added comment-hyphens, flags-wiring, and
|
|
20
|
+
flags-real-core to the module list without touching the enumeration
|
|
21
|
+
above it, so a reader reconciling comment against list found three
|
|
22
|
+
orphans.
|
|
23
|
+
* The plugin's `customization_help` names `max_log_mb`: the rotation cap
|
|
24
|
+
is documented in the README and honored by the log writer, but the
|
|
25
|
+
in-Calibre customization dialog never mentioned the key. Rides the
|
|
26
|
+
release-attached plugin zip.
|
|
27
|
+
* Suite: 544 -> 575 tests since v0.46.0 (the two follow-up wiring-test
|
|
28
|
+
commits, unpinned in that entry's count), all green on this text-only
|
|
29
|
+
sweep.
|
|
30
|
+
## v0.46.0 (2026-10-02)
|
|
31
|
+
|
|
32
|
+
### The last open repair class closes: RSC-016, plus the RepairFlags refactor
|
|
33
|
+
|
|
34
|
+
* **`--fix-comment-double-hyphen` (new structural repair, in the `--all` set)**: a `--` inside an XML comment is illegal XML (epubcheck fatal RSC-016, "The string \"--\" is not permitted within comments"), so such a book parses in lenient readers and never passes epubcheck. The fix replaces each `--` with an en-dash inside comment bodies only: text nodes are never touched (a `--` in character data is legal XML), CDATA sections stay protected, and every comment's `-->` terminator stays intact (the span ends there, so the replacement cannot reach it). It applies to content documents, the NCX, and the OPF alike, and each replaced sequence is counted under the `fixes` key `fix_comment_double_hyphen` (an additive key; CalibreQuarry's lossy-consent mirror reads the dict with `.get()` over its fixed lossy-marker tuple, so the new key is tolerated as structural, verified in `cquarry_cli/run.py`). It is the sixteenth structural repair, built exactly to the 2026-09-16 classics-wave box's recorded design: the Theaetetus hand-rescue's en-dash half, now native. The normal `gate` accepts it (clearing the fatal IS the measurable gain; verified against epubcheck 5.x on a synthetic book: 1f/1e -> 0f/1e), and the never-rewrite-comments invariant gains its one documented exception in spec.md.
|
|
35
|
+
* **`RepairFlags` (internal)**: the opt-in selection that used to be a ~25-kwarg signature triplicated across `repair_epub`, `process_book`, and the CLI's per-verb call sites is now one dataclass (`epub.RepairFlags`, one field per flag, all off by default; the all-off instance IS the default pass). `cli._flags_from_args` is the single argparse-to-fields mapping, shared by `library` and `repair`; the EPUB2-targeted fixes' package-version gate swaps in a `dataclasses.replace` copy, so a caller's instance is never mutated. No surface change: the CLI flags, the gate, and the JSON records are untouched (end-to-end and byte-determinism verified against real epubcheck). One API note for in-repo consumers: `bindery.epub.repair_epub` and `bindery.cli.process_book` now take `flags=RepairFlags(...)` instead of keyword flags; the plugin's bare `repair_epub(src, dst)` call constructs exactly the default pass.
|
|
36
|
+
* Suite: 524 -> 544 tests (`tests/test_comment_hyphens.py`: transform units, end-to-end over content/NCX/OPF, and the gate on both sides; the flag-wiring tuples pin the new flag).
|
|
2
37
|
## v0.45.0 (2026-09-21)
|
|
3
38
|
|
|
4
39
|
### The structured fix breakdown in the JSON records
|
|
@@ -19,7 +54,7 @@
|
|
|
19
54
|
|
|
20
55
|
* **`--encode-url-spaces` gained its rename half**, the biggest real-prevalence repair class left (PKG-010: 8,237 occurrences in 284 books at the 2026-09-17 refresh). Archive entries whose names carry raw spaces are renamed to their underscore spellings and every reference is rewritten (OPF, NCX, content `src`/`href`, stylesheet `url()`). The design was decided by experiment, not by the roadmap box's plan: epubcheck 5.3 DECODES references before entry lookup, so percent-encoded entries are unfindable by the encoded references pointing at them (all four raw/percent/underscore combinations built and checked); underscore on both sides resolves and clears PKG-010. Ambiguous renames are refused per entry (a target that already exists, two names converging, a duplicated archive name), a book with any non-UTF-8 document refuses all of its renames, a renamed OPF regenerates a stale container, and the acceptance rides `no_worse` because the gain sits on the warning axis the improvement gate does not measure (same bar as `--fix-cover`).
|
|
21
56
|
* **The matcher fix that explains Theaetetus** (the 2026-09-16 hand-rescue): the encode pass's value class `[^"']` stopped at apostrophes inside double-quoted hrefs, so the 270 raw-space OPF hrefs never matched and the fatal survived. The matcher now takes the tempered-quote idiom (possessive, house style), and an apostrophe in a double-quoted filename is ordinary.
|
|
22
|
-
* **`bindery audit cover`** (advisory, the EPUB3 half of the ruled hybrid): dangling EPUB2 `<meta name="cover">` (the `--fix-cover` class), the EPUB3 `properties~="cover-image"` declaration, and whether the named cover file exists. **`bindery audit tocdrift`**: the structural diff between the NCX navMap and the EPUB3 nav toc, keyed on the full target including fragments
|
|
57
|
+
* **`bindery audit cover`** (advisory, the EPUB3 half of the ruled hybrid): dangling EPUB2 `<meta name="cover">` (the `--fix-cover` class), the EPUB3 `properties~="cover-image"` declaration, and whether the named cover file exists. **`bindery audit tocdrift`**: the structural diff between the NCX navMap and the EPUB3 nav toc, keyed on the full target including fragments: entries each side is missing plus label mismatches. Both never flag a book and never move the exit code; ToC synthesis stays out of the repair charter permanently. The loader exposes the parsed OPF, the NCX text, and the nav HTML on `Book`.
|
|
23
58
|
* **The audit-refresh deep-dive ran** (read-only FastSweep extract over the full 5,228-book library; raw report in the facility): RSC-005 164,302 -> 13,782 occurrences, RSC-007 3,219 -> 14,162 in 604 books (the classics-wave imports), RSC-020 9,953 in 337 books, PKG-010 8,237 in 284 books (population flat: the rename class was still live, hence this ship).
|
|
24
59
|
* **The roman grammar is one copy again**: pagination.py is the canonical home (it vendors into the plugin; audit does not), audit.py imports `ROMAN_RE`/`ROMAN_MAX`/`roman_value`, and the two byte-identical copies cannot drift. The RepairFlags dataclass refactor stays boxed with its reason (pure churn on the signatures this release touched).
|
|
25
60
|
* Suite: 497 -> 521 tests (tests/test_space_renames.py, tests/test_cover_tocdrift.py, and the updated `--encode-url-spaces` end-to-end pins).
|
|
@@ -28,13 +63,13 @@
|
|
|
28
63
|
|
|
29
64
|
### The stdlib XML hardening: untrusted metadata is bounded and entity-refused, no dependency
|
|
30
65
|
|
|
31
|
-
* **`--audit` and every `load_book` caller no longer decompress blind.** Two protections, both stdlib-only (the defusedxml dependency stays declined): single entries whose declared size exceeds `_MAX_ENTRY_BYTES` (32 MB) are refused before decompression
|
|
66
|
+
* **`--audit` and every `load_book` caller no longer decompress blind.** Two protections, both stdlib-only (the defusedxml dependency stays declined): single entries whose declared size exceeds `_MAX_ENTRY_BYTES` (32 MB) are refused before decompression (a bomb entry in a tiny zip cannot be downloaded into memory), and the untrusted metadata files (container.xml, OPF, encryption.xml) parse through `_safe_xml_parse`, which refuses DOCTYPE/ENTITY declarations before xml.etree sees them. A refused or unparseable metadata file returns the shell book (the archive verdict is the book's whole story), never a hang or a traceback.
|
|
32
67
|
* Pinned by `tests/test_xml_hardening.py` (entity-bomb container returns the shell book; clean XML parses; the entry cap is sane). The defusedxml dependency ask is closed as declined with the stdlib shape delivered.
|
|
33
68
|
|
|
34
69
|
## v0.42.0 (2026-09-16)
|
|
35
70
|
|
|
36
71
|
### The matcher audit executed: every quote-aware tag matcher hardened
|
|
37
|
-
The follow-up box the 0.41.1 hotfix opened is closed with a full per-matcher census, and the audit found the box's own enumeration incomplete. Six GREEDY patterns of the exponential overlap class were unhardened
|
|
72
|
+
The follow-up box the 0.41.1 hotfix opened is closed with a full per-matcher census, and the audit found the box's own enumeration incomplete. Six GREEDY patterns of the exponential overlap class were unhardened: `_START_TAG_RE` (the quote-aware start-tag matcher anchoring `--strip-epub3-attrs` and `--strip-bad-attrs`, running under `repair --all` on every content doc; not even named in the box), `_COVER_META_RE`, `_GUIDE_REF_RE`, `prune_dangling_edges`' spine|item|itemref matcher, `_ITEM_TAG_RE`, and `_SPINE_ITEM_RE`. All six are possessive-bounded now: byte-identical on every successful match (the loop is always followed by a literal `>` that the `[^>]` branch cannot consume, so backtracking only ever happened on failure) and linear on failure. Five LAZY patterns of the quadratic class (`_VOID_RE`, the transforms `<img>` matcher, and epub's link/anchor/img matchers) took the disjoint catch-all `[^>"']` instead of a blind possessive swap: mutually exclusive branches cannot re-partition, so any quantifier is linear, and an unterminated quote inside a tag now fails to match instead of pairing with a distant quote and matching across markup. Every well-formed shape is byte-identical. The epub `_IMG_TAG_RE` is renamed `_PRUNE_IMG_TAG_RE` (it collided with the transforms matcher of the same name). Everything else in the package audited safe by construction: tempered-quote value matchers, two-branch quote alternations, `[^>]*` single-class prefixes (linear, not quote-aware; accepted, documented), lazy paired-delimiter spans, and the analyzer tokenizers.
|
|
38
73
|
|
|
39
74
|
Pinned by `tests/test_matcher_hardening.py` (15 tests): alarm-guarded spin shapes per greedy site (OPF flavor, the truncated-OPF prune shape), unterminated-quote skips, and well-formed byte-identity. `CLAUDE.md`'s hazard note now carries the census and the rule for new matchers. The full suite is 491 tests.
|
|
40
75
|
|
|
@@ -270,7 +270,9 @@ class BinderyRepair(FileTypePlugin):
|
|
|
270
270
|
def customization_help(self, gui=False):
|
|
271
271
|
return (
|
|
272
272
|
'Enter a JSON object: {"log": true, "log_path": ..., '
|
|
273
|
-
'"max_size_mb": 150, "epubcheck_path": null}. '
|
|
274
|
-
"
|
|
275
|
-
"
|
|
273
|
+
'"max_size_mb": 150, "max_log_mb": 2, "epubcheck_path": null}. '
|
|
274
|
+
"max_log_mb is the log rotation cap in MB (default 2, one .old "
|
|
275
|
+
"generation kept, 0 disables). epubcheck_path enables the "
|
|
276
|
+
"experimental post-repair validation with the epubcheck binary "
|
|
277
|
+
"(slow; off by default)."
|
|
276
278
|
)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bindery-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.46.1"
|
|
8
8
|
description = "Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
classifiers = [
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# bindery-cli roadmap
|
|
2
|
+
|
|
3
|
+
*Phase numbers are historical identifiers, not an order: the campaign added phases
|
|
4
|
+
non-monotonically and two distinct efforts both carry "Phase 4". Cross-repo notes
|
|
5
|
+
cite them, so the ledger keeps the identifiers.*
|
|
6
|
+
|
|
7
|
+
**Minimized 2026-09-29 (the cquarry precedent).** Phases 1-16, the supplementary
|
|
8
|
+
audit section, the bug-report waves, and every audit block are shipped; their full
|
|
9
|
+
text is preserved in git at the tree of commit 157afc9 (the last full roadmap) and
|
|
10
|
+
the release-by-release record is `patchnotes.md`. This file keeps the ledger, the
|
|
11
|
+
open work, the records that live nowhere else, and the parity dispositions.
|
|
12
|
+
|
|
13
|
+
Standing rules: `spec.md` is the contract (deterministic, semantics-preserving,
|
|
14
|
+
epubcheck-gated repairs; opt-in lossy lane; dry-run default; atomic replacement).
|
|
15
|
+
The plugin vendors the core and never gates (the epubcheck latency ruling).
|
|
16
|
+
`tests/test_version.py` pins the version carriers.
|
|
17
|
+
|
|
18
|
+
## Completed phases (ledger)
|
|
19
|
+
|
|
20
|
+
| Phase | Scope | Shipped |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| 1 | Deterministic repair engine: transforms, NCX-001, mimetype repair, the two-mode epubcheck gate, `repair`/`library` modes, atomic in-place replacement with backups, dry-run default | v0.1.0 |
|
|
23
|
+
| 2 | The long tail: unclosed non-void elements (`--reserialize`), unbound namespaces (`--strip-bad-attrs`), digit-led/colon ids (`--fix-ids`), JSON reports + `--manual-list`, `--sweep` re-audit integration | v0.2.0-v0.7.0 |
|
|
24
|
+
| 4 (lossy) | `--strip-pagination`: the fenced lossy lane's first member (confident interrupts, character conservation, `no_worse`) | v0.5.0 |
|
|
25
|
+
| 5 | Audit fixes and hardening: the partial-classification bug, per-book exception isolation, id-anchor preservation, html5lib as an extra, the epubcheck locale/JSON hardening (5.2; cited by tests/test_validate.py), UX batch (progress, warnings, exit codes, `--limit`), mimetype/unknown-entity/NCX-ids/`--add-img-alt` additions, the void-end-tag spec gap | v0.6.0-v0.10.0 |
|
|
26
|
+
| 3 | Calibre plugin ("Bindery Repair", `FileTypePlugin` `on_import`): the decided shape (see Records kept), scoped vendor slice, byte-idempotence, per-release zip attachment | v0.37.0 |
|
|
27
|
+
| Suppl. | Library-audit schemas: `--fix-id-colons`, `--fix-empty-body`, `--fix-missing-title`, `--unwrap-block-in-inline`, `fix_ncx_playorder`, `--strip-invalid-value` (all opt-in since v0.17.0; `--add-img-alt` deliberately never defaulted) | v0.14.0 |
|
|
28
|
+
| 4 (cquarry) | cquarry integration: `get_format_path()` resolution, the `--tag` write path, `audit --id` single-book mode | v0.18.0-v0.19.0 |
|
|
29
|
+
| 6 | Code sweep: the content-loss fix, `--replace` crash, dead method, java pin removal, regex bounds, opt-in decoupling, CSS-aware unwrapping | v0.16.3-v0.19.0 |
|
|
30
|
+
| 7 | `monolithic` analyzer + the version-sync pin (`tests/test_version.py`) | v0.21.0 / v0.19.2 |
|
|
31
|
+
| 8 | `library --id` batch scoping, spine-integrity classification (convention vs fragment), `audit --id` comma lists; `--workers` made real in v0.30.0, the daemon pool in v0.35.0 | v0.23.0 |
|
|
32
|
+
| 9 | Archive integrity: the CRC sweep with its own CORRUPT verdict (never mislabeled EMPTY), the unreadable sub-reason split | v0.22.0 |
|
|
33
|
+
| 10 | OPF/NCX edges: `--fix-page-map`; the RSC-005 EPUB3 scrubs (`--strip-epub3-attrs`, `--downgrade-epub3-tags`), ruled Option B | v0.25.0-v0.27.0 |
|
|
34
|
+
| 11 | install-to-calibre on the native cquarry write module (`install_format`/`set_format`; the calibredb subprocess retired) | v0.24.0 |
|
|
35
|
+
| 12 | Top-error repairs: `--prune-missing-resources`, `--strip-broken-anchors`, the HTM-025 half, the FastSweep harness; bulk RSC-005 rejected (see Records kept) | v0.28.0 |
|
|
36
|
+
| 13 | Machine-readable audit (`audit --json`) + the `run phase1`/`run phase3` acquisition slices + the non-interactive contract | v0.29.0 |
|
|
37
|
+
| 14 | Hardening from the 2026-09-08 sweep: anchored/quote-aware regexes, `fix_id_colons` honesty + NCX follow, CDATA/comment protection everywhere, strict UTF-8, `--reserialize` html-root scoping, the watermark/roman/install/EPUB3-gate bug fixes, audit ToC accounting inside the open zip, the "unify on trouble" exit ruling, backup rotation + out-of-tree refusal, the daemon pool, docs reconciliation, the test-suite cleanups | v0.32.0-v0.35.0 |
|
|
38
|
+
| 15 | `audit completeness` spot-check analyzer (trailing-ToC, prose sampling), fixtures from the Redwall run | v0.36.0 |
|
|
39
|
+
| 16 | Package-structure repairs: the prevalence study, `--fix-container`, the OBFUSCATED vs DRM verdict split, prune edge completion, `--fix-media-types`, `--fix-cover` (the ruled hybrid), the boxed classes below | v0.38.0-v0.39.0 |
|
|
40
|
+
| Waves 15 + blitz | The plugin PEP-758 HIGH + the 3.11-3.14 interpreter matrix, analyzer robustness, the per-matcher census (possessive bounding; cited by tests/test_matcher_hardening.py), stdlib XML hardening, FastDaemon v2 (reconcile-not-retire), `--strip-stub-docs`, `bindery doctor` + `repair --json`, `--encode-url-spaces` entry renames, the cover + tocdrift analyzers, the privacy/GitHub/docs/comment/hygiene batches, requires-python 3.12 with markers, the em-dash sweep | v0.40.0-v0.44.0 |
|
|
41
|
+
| 0.45 | Structured fix records (`fixes`, `ncx_uid_synced`, `watermark_refusals`) in every JSON payload; CalibreQuarry consumes them with the 0.45.0 floor | v0.45.0 |
|
|
42
|
+
| 0.46 | RSC-016 `--fix-comment-double-hyphen` (the last open repair class) and the RepairFlags dataclass | v0.46.0 |
|
|
43
|
+
|
|
44
|
+
## Open work
|
|
45
|
+
|
|
46
|
+
- [ ] **Obfuscation-aware encryption.xml repair**: prune stale obfuscation entries
|
|
47
|
+
when font magic bytes prove the fonts are decrypted in place; drop
|
|
48
|
+
encryption.xml when only obfuscation entries remain and fonts verify. NEVER
|
|
49
|
+
un-obfuscate. *(BOXED with real counts, 2026-09-12: 424/424 readable
|
|
50
|
+
obfuscation fonts genuinely scrambled, zero stale entries in-library; the
|
|
51
|
+
precondition is validated and recognition carries both Adobe URI spellings.
|
|
52
|
+
The audit half SHIPPED v0.38.0 as the OBFUSCATED verdict. Opens only if
|
|
53
|
+
acquisition ever brings a decrypted-in-place book.)*
|
|
54
|
+
- [ ] **href case/backslash resolution**: case-insensitive namemap when exactly one
|
|
55
|
+
zip entry matches; backslash to slash. Kills the present-file
|
|
56
|
+
RSC-007/PKG-010 slice prune cannot touch. *(BOXED with real counts,
|
|
57
|
+
2026-09-12: exactly 1 case-mismatch href in 1 book and 0 backslash hrefs
|
|
58
|
+
across the library; reopen if acquisition changes the mix.)*
|
|
59
|
+
- [ ] **Duplicate zip-entry dedupe on rewrite**: drop shadowed duplicates (audit
|
|
60
|
+
already counts `dup_entries`). *(BOXED with real counts, 2026-09-12: 0 books
|
|
61
|
+
with duplicate entries in-library.)*
|
|
62
|
+
- [ ] **CSS url() pruning** as a `--prune-missing-resources` scope extension:
|
|
63
|
+
stays closed until a named epubcheck finding demands it (the 2026-09-12
|
|
64
|
+
prevalence read found selector damage, not url() candidates).
|
|
65
|
+
- [x] **Candidate transform: `--` inside XML comments (RSC-016 fatal)**. A
|
|
66
|
+
`fix_comment_double_hyphen` transform (comment nodes only, `--` -> en-dash,
|
|
67
|
+
byte-counted) would make the always-on core able to parse such books at all;
|
|
68
|
+
until then the book parses in lenient readers but never passes epubcheck.
|
|
69
|
+
Low frequency (one book in the classics wave); the fixture reference is in
|
|
70
|
+
git history. *(SHIPPED v0.46.0 as the opt-in `--fix-comment-double-hyphen`
|
|
71
|
+
structural repair: comment bodies only in content documents, the NCX, and
|
|
72
|
+
the OPF; the `-->` terminators stay intact; normal `gate`. Not a core
|
|
73
|
+
transform: it edits comment content, which everything else protects.)*
|
|
74
|
+
- [x] **RepairFlags dataclass** for the triplicated ~25-kwarg
|
|
75
|
+
process_book/repair_epub signature. Deferred with reason: pure churn on that
|
|
76
|
+
surface immediately after the v0.44 batch touched exactly those signatures;
|
|
77
|
+
do it as a standalone lane with the full suite and the plugin byte-compat
|
|
78
|
+
job green at every step, not as a rider. (The roman/arabic half of its parent
|
|
79
|
+
box resolved to UNIFY at pagination.py, v0.44.0.) *(SHIPPED v0.46.0 as its
|
|
80
|
+
own commit, exactly by that method: dataclass in epub.py, repair_epub, then
|
|
81
|
+
process_book, then `cli._flags_from_args` collapsing the per-verb kwarg
|
|
82
|
+
blocks, suite green at every step; the plugin's bare repair_epub call and
|
|
83
|
+
byte-compat unchanged.)*
|
|
84
|
+
- [ ] **MobileRead listing for the Bindery Repair plugin** (Brandon's manual
|
|
85
|
+
step): post the listing with name/identity, the release-attached zip,
|
|
86
|
+
minimum Calibre 7.0, Linux platform note. Posting is outward-facing under
|
|
87
|
+
his name.
|
|
88
|
+
- [ ] **README screenshot regeneration** (Brandon's call pending): rebuild
|
|
89
|
+
docs/screenshots/library-sweep.png against a synthetic testing_facility
|
|
90
|
+
library (invented titles, real dry-run output); the current PNG shows 16
|
|
91
|
+
real rows. Asked 2026-09-15, unanswered.
|
|
92
|
+
- [x] **The 2026-10-02 closing sweep** (the four-lane verification's doc
|
|
93
|
+
findings against the v0.46.0 tree): the safety contract's lossy
|
|
94
|
+
enumeration names all four modes, the core-compat em-dash is gone,
|
|
95
|
+
ci.yml's module comment covers all eleven stack-free modules, and the
|
|
96
|
+
plugin's `customization_help` names `max_log_mb`. *(SHIPPED v0.46.1:
|
|
97
|
+
text plus the one plugin string; no surface change.)*
|
|
98
|
+
|
|
99
|
+
## The repair domain in the ecosystem parity program (recorded 2026-09-29)
|
|
100
|
+
|
|
101
|
+
Brandon opened the ecosystem Calibre-parity program on 2026-09-29 (cquarry roadmap.md,
|
|
102
|
+
"The parity program"; parity counts native coverage plus orchestration of Calibre's own
|
|
103
|
+
headless tools, and excludes process-bound and declined surface with recorded reasons).
|
|
104
|
+
bindery-cli's lane is the repair/acceptance domain, where this repo is already past
|
|
105
|
+
parity with Calibre's own tooling: ebook-polish has no acceptance oracle, no determinism
|
|
106
|
+
contract, and no atomic library replacement; bindery has all three, plus native
|
|
107
|
+
metadata.db registration and the Calibre plugin. Dispositions recorded under the program:
|
|
108
|
+
|
|
109
|
+
- **Conversion stays out, permanently** (spec.md:10-14): Calibre's conversion engine
|
|
110
|
+
(~45 input / ~20 output formats) is orchestration-lane territory (CalibreQuarry
|
|
111
|
+
`run convert`); bindery never grows one, and no parity claim depends on it.
|
|
112
|
+
- **The ebook-polish content-improving actions bindery lacks stay declined**:
|
|
113
|
+
embed/subset fonts, jacket, smarten punctuation, remove-unused-css, compress-images,
|
|
114
|
+
upgrade-book, download-external-resources, the --opf rewrite, --cover. They are
|
|
115
|
+
content-improving rather than repair, and dc: metadata editing is out of charter
|
|
116
|
+
(spec.md:597). Recorded here so the parity ledger's bindery row names them declined,
|
|
117
|
+
not missing.
|
|
118
|
+
- **The `data`-row waiver note**: bindery has updated `data` rows through
|
|
119
|
+
`WritableCalibreDB.set_format` since v0.24.0 (the sanctioned install path);
|
|
120
|
+
cquarry's conditional write-back waiver was reworded 2026-09-29 to name what it
|
|
121
|
+
actually guards: a bindery-side book-metadata write-back convenience, still declined.
|
|
122
|
+
- **Parity-relevant accepted gaps**: RSC-016 (`--` inside XML comments) SHIPPED
|
|
123
|
+
v0.46.0 as `--fix-comment-double-hyphen` (the candidate box above), so no open
|
|
124
|
+
repair class blocks epubcheck acceptance on prevalence anymore; the
|
|
125
|
+
prevalence-gated classes (encryption.xml, href case/backslash,
|
|
126
|
+
zip dedupe, CSS url()) reopen only on acquisition mix. The RepairFlags refactor shipped
|
|
127
|
+
v0.46.0 (the ticked box above).
|
|
128
|
+
- **Brandon-parked items are unchanged**: the MobileRead plugin listing and the README
|
|
129
|
+
screenshot regeneration stay his; the program does not schedule them.
|
|
130
|
+
|
|
131
|
+
## Records kept (decisions and counts that live only here)
|
|
132
|
+
|
|
133
|
+
- **The plugin shape decision** (2026-08-09, researched against the Calibre source;
|
|
134
|
+
corrected 2026-09-05; shipped v0.37.0): `FileTypePlugin` with `on_import`:
|
|
135
|
+
`run(path)` returns a `temporary_file()` replacement before the file lands, so the
|
|
136
|
+
original on disk is never touched and metadata.db is never written. A raising plugin
|
|
137
|
+
cannot abort an import and cannot lose the file, but the failure is silent, so the
|
|
138
|
+
plugin never raises and keeps its own log under the Calibre config dir.
|
|
139
|
+
`supported_platforms = ['linux']` (the loader rejects an empty declaration). The hook
|
|
140
|
+
also fires on `add_format`, so the plugin is byte-idempotent. The vendor slice
|
|
141
|
+
(transforms/epub/pagination/watermark/reserialize + a plugin `__init__`) is
|
|
142
|
+
generated at release from the tagged tree with a byte-equality drift test. Active
|
|
143
|
+
set = the gate-safe default pass only: every structural repair and the four
|
|
144
|
+
lossy strips stay CLI-only, because epubcheck cannot gate inside Calibre (no jar/JVM
|
|
145
|
+
and seconds-per-book latency). Config via `site_customization` JSON (`log`,
|
|
146
|
+
`log_path`, `max_size_mb`, recorded default 150MB); `publish.yml` attaches
|
|
147
|
+
`BinderyRepair-v<VERSION>.zip` to each release.
|
|
148
|
+
- **The metadata-validity carve-out ruling** (Brandon, 2026-09-12): route to
|
|
149
|
+
cquarry/CalibreQuarry; bindery's side is closed and dc: metadata stays a non-goal.
|
|
150
|
+
The routed half (51 OPF-085 invalid-UUID warnings plus the thin date/language tail)
|
|
151
|
+
is CalibreQuarry's lane (recorded in its roadmap; its 3.41/3.42 audit rows found the
|
|
152
|
+
classes clean at the DB level, the warnings file-side).
|
|
153
|
+
- **Prevalence baselines** (2026-09-12 study over 5,228 books; 2026-09-17 refresh):
|
|
154
|
+
RSC-005 164,302 -> 13,782 occurrences; RSC-007 14,156 in 600 books; RSC-020 9,953
|
|
155
|
+
in 337; PKG-010 8,237 in 284 (population flat, the rename class stayed live, hence
|
|
156
|
+
v0.44.0); container.xml valid 5,228/5,228; case-mismatch hrefs 1 in 1 book;
|
|
157
|
+
backslash hrefs 0; duplicate zip entries 0 books; encryption.xml in 86 books (426
|
|
158
|
+
Adobe + 3 IDPF obfuscation entries; 424/424 readable obfuscated fonts genuinely
|
|
159
|
+
scrambled at offset 0; the wild Adobe URI is `http://ns.adobe.com/pdf/enc#RC`, and
|
|
160
|
+
recognition carries both spellings); NO real-DRM algorithm anywhere in the library.
|
|
161
|
+
- **The exit-code contracts:** argparse-level misuse exits 2 before the tool's
|
|
162
|
+
validation; the tool's own usage errors exit 1; trouble (rejected + errors +
|
|
163
|
+
unreadable + partial books) exits 2 in all three layers by the 2026-09-10 "unify on
|
|
164
|
+
trouble" ruling (option A of the recorded pair).
|
|
165
|
+
- **The daemon decision** (2026-09-10): RECONCILE, not retire. The counting divergence
|
|
166
|
+
ran deeper than the daemon (the human summary counts message occurrences, epubcheck's
|
|
167
|
+
JSON counts aggregated messages, and the gate has always measured the aggregated
|
|
168
|
+
scale), so FastDaemon v2 reads the JSON epubcheck itself serializes and measures the
|
|
169
|
+
subprocess oracle's numbers exactly; the launch is Java's single-file source launcher
|
|
170
|
+
(no javac, no version skew); warm throughput ~0.27s/book vs ~4.2s/book subprocess.
|
|
171
|
+
Shipped v0.35.0.
|
|
172
|
+
- **requires-python ~3.12** (decision 63, executed v0.40.0): every cquarry/vir-tui on
|
|
173
|
+
PyPI declares >=3.14, so the VirInvictus pins carry
|
|
174
|
+
`; python_version >= '3.14'` markers (3.14 installs byte-identical); 3.12/3.13
|
|
175
|
+
installs run the stack-free repair core; the CLI dispatch guard turns a missing
|
|
176
|
+
stack into one stderr line + exit 2; CI byte-compiles the plugin zip under
|
|
177
|
+
3.11/3.12/3.13/3.14; `minimum_calibre_version` is (7, 0, 0).
|
|
178
|
+
- **Tag policy** (decided 2026-09-11, recorded 2026-09-12): v0.35.0 is the anchor;
|
|
179
|
+
every release from v0.36.0 on is tagged at its release commit under auto-tag
|
|
180
|
+
promotion. The nine untagged 0.18.0-0.26.0 entries are exempted by decision of
|
|
181
|
+
record (no backfill tags; patchnotes and PyPI carry them). Executed 2026-09-12: the
|
|
182
|
+
v0.28.0 tag re-pointed at its first green commit with its title line restored, the
|
|
183
|
+
v0.33.0 tag message corrected verbatim, and the 10 test_facility EPUBs stripped from
|
|
184
|
+
all history via git filter-repo (main + 14 tags force-pushed; PyPI untouched).
|
|
185
|
+
- **Privacy record:** top500candidates/REPORT.md is untracked forward-only (Brandon's
|
|
186
|
+
ruling, no history strip); the file stays on disk as the fast_sweep `--summary`
|
|
187
|
+
target. Reopen condition: the history-strip recipe (rewrite 16 release tags,
|
|
188
|
+
publish.yml disabled around the push) if the reachable copy is ever judged
|
|
189
|
+
unacceptable (also in project.done).
|
|
190
|
+
- **The matcher census** (v0.42.0; cited by tests/test_matcher_hardening.py): six
|
|
191
|
+
greedy exponential-class sites possessive-bounded (`_START_TAG_RE`, `_COVER_META_RE`,
|
|
192
|
+
`_GUIDE_REF_RE`, the prune spine matcher, `_ITEM_TAG_RE`, `_SPINE_ITEM_RE`); five
|
|
193
|
+
lazy quadratic-class sites took the disjoint `[^>"']` catch-all (`_VOID_RE`, the
|
|
194
|
+
transforms `<img>` matcher, epub's link/a/img matchers); everything else audited
|
|
195
|
+
safe by construction. Never a third grammar copy: pagination.py is the canonical
|
|
196
|
+
roman/number home (it vendors into the plugin; audit imports from it), and any
|
|
197
|
+
future divergence is a decision at pagination.
|
|
198
|
+
- **Non-goals kept with reasons:** ToC synthesis is out of the repair charter
|
|
199
|
+
permanently (tocdrift is detector-only); conversion is out permanently (the parity
|
|
200
|
+
section above); dc: metadata editing is out (spec); bulk RSC-005 rejected (164,302
|
|
201
|
+
instances; narrowly bounded sub-cases stay opt-in under their own flags); no
|
|
202
|
+
spine-item manifest pruning (missing spine documents mean corrupt archives or broken
|
|
203
|
+
fragments); no text deletion in anchor unwrapping (character conservation is
|
|
204
|
+
absolute); no auto-split of monolithic docs and no auto-trim of bloated ToCs (flag
|
|
205
|
+
and re-source); no repair of corrupt archive entries (re-source, never repair); no
|
|
206
|
+
PDF/DJVU work (never this repo's charter); `--add-img-alt` stays opt-in
|
|
207
|
+
(`alt=""` asserts "decorative" to screen readers); defusedxml stays declined (the
|
|
208
|
+
stdlib `_safe_xml_parse` delivers the entity protection and the vendored-plugin cost
|
|
209
|
+
was the real objection; the full-parser swap is Brandon-gated on a real 3.12/3.13
|
|
210
|
+
stranger audience); the plugin never gates on epubcheck (the latency ruling); no
|
|
211
|
+
manifest format ownership (CalibreQuarry owns `acquisition-manifest` and the
|
|
212
|
+
orchestration).
|