Source Model — Image preparation: the Set Up step that turns photographs into pages a model can read — Design Spec (#5382)
Milestone: image-preparation Manual: TBD — a section, “Preparing images”, explaining what Fichero does to a photograph before reading it (find the page, split, turn, straighten, clean), that the original is never changed, how to check and correct what it did, and how to see whether a step helped.
Design-led (Testing Constitution). Status: DRAFT — ruled 2026-10-29, ready to build (first draft 2026-10-03; rewritten 2026-10-29; the owner’s rulings of 2026-10-29 folded in the same day, see Rulings; no open question remains; the APPROVED tag waits only on the manual section and the first pinning test, as
check_spec_manual_refsandcheck_specs_have_testsrequire). Review:agent-work/status/briefs/imgprep-review-2026-10-29.md. Stage 1 to 2 of../../roadmap/research-pipeline.md.Three specs, one line between them. This spec owns the Set Up step: the questions and their defaults, what runs by itself, finding the page, squaring a lopsided photograph, dewarping a curved page, splitting, turning, blank pages, the check-and-correct flow, the detectors as cards, how corrections train a detector, and the time and cost shown before Start (
prep.*).image-enhancement.md(#6185) owns the pixel steps that write renditions (the whole OpenCV suite: contrast, yellowing, stains, ruling, show-through, binarise, denoise, sharpen, the working rendition,image.enhance.*) and the one function behind every door.../ui/preview-image-editing.mdowns the editor a person corrects with (preview.edit.*, its tools in section C). Where two specs could say one thing, this spec cites the owner and does not restate it. Theprep.*ids of 2026-10-03 are kept; the ids four issues cite but no spec carried (#6188, #6189, #6190, #6192) are added below with their tags.Tags: [OK] built and pinned · [PARTIAL] exists, partly wired or unpinned · [GAP] not built · [BROKEN] built, wrong.
Intent
Archives are photographed, not scanned: a book open on a table, two pages at once, a ruler and a colour card beside the paper, a dark mount, the camera a little turned. Models read single, upright, flat, clean pages; a photograph taken at an angle, or a bound page curving into the gutter, is neither flat nor square. Image preparation turns the one into the other by itself, for a whole collection, as the first step of a recipe, and a person checks and corrects it instead of doing it. Every result is a new rendition beside the original, which is never changed. The step is judged by whether reading improves, not by how the picture looks.
What the person sees: in Set Up, one card, “Prepare Images”, with three short questions already answered from a sample of their pages, and a line saying how long the step takes on this Mac. After Start, a short list of pages to check: the ones Fichero was unsure about, and a few it was sure about, so the person sees both. Each opens in Preview with the page box, its four corners, the cut and the turn drawn on the photograph, ready to be dragged. A correction on one page can be applied to the rest of its folder. Enough corrections, and Fichero offers to train a detector on them; the detector replaces the default only when it measures better.
The first test sets: a notebook corpus (a project: 374 photographs, 3000×2000, open spiral notebooks on a dark table, a ruler along the top, the left page often blank graph paper) and a court archive’s scans (two documents of one box: a wooden ruler down the left edge, a grey colour card at the top, a wide dark border).
What exists today
- Finding the page and the gutter (
fichero-server/src/fichero_server/media/page_split.py, nodefichero-server/src/fichero_server/workflows/tools/split_pages.py): Apple Vision’s document outline (VNDetectDocumentSegmentationRequest), an outline narrower than tall left whole, the gutter at the darkest column of the middle band, a confidence from the gutter’s depth, a proposal below 0.15. Pinned on 11 notebook photos byfichero-server/tests/unit/media/test_page_split.py. The four-corner quad is returned and dropped; no attribute, nopage_box, no perspective correction. - Deskew (
media/image_ops.detect_deskew_angle, ±15°, 0.1° steps): the shear that sharpens the row profile of the ink inside the eroded bright page, so the ruler and table edges are not read; the editor’s Straighten and the nodedeskew_imagesuse it. Tested on a synthetic photograph (tests/unit/media/test_photo_page_prep_5382.py); not yet measured on the notebook corpus photographs. - Content box (
media/image_ops.detect_content_bbox): pixels above the midpoint of the dark and bright Otsu classes (20 where they are under 60 apart), so a grey table is left out; a bright ruler on the table is still counted. - Remove background (
media/image_ops.remove_black_background_opencv,remove_scan_background): a dark-mount mask, labelled “AI background removal” in the editor. - The edit chain and renditions:
preview.edit.*in../ui/preview-image-editing.md; renditions from a workflow bypersist_workflow_renditions. The recipe’s prepared image is not attached as a rendition (#5386). - The upright frame (
media/upright.py): EXIF applied once, new geometry markedframe: "upright". - The onboarding stage (
fichero-server/src/fichero_server/recipes/stages.py,prepare-images): two questions, “Two pages per image?” and “Straighten, crop, brighten?”, stored and not run; the Start plan runssplit-pagesonly and treatsprepare-the-imageas nothing to configure (fichero-server/src/fichero_server/recipes/start.py). - Sample checks that nobody sees (
fichero-server/src/fichero_server/recipes/prepare.py): a page is faded, a sample is text. - YOLO (
fichero-server/src/fichero_server/llm/yolo_runtime.py,recipes/regions.py,training/yolo_set.py,training/yolo_local.py): the DocLayNet layout card runs on the GPU and a fine-tune from corrected regions ran on this Mac. No page detector; nothing trains from page boxes. - The legacy tools (
fichero_archive/_archive/fichero_legacy/tools/, outside this repository): a YOLOv8 page model and contour templates (crop.py), the aspect gate and neighbour test (split.py), Hough rotation (rotate.py). Their methods are restated inimage-enhancement.md; the code is never imported (image.enhance.old-conventions-left-behind). - Leave Out (
fichero-server/src/fichero_server/recipes/leave_out.py) reads apage_boxthat nothing writes.
Prior art
Apple’s own document scanning (Notes, Files) finds the paper with Vision’s document segmentation and corrects perspective from its quad; Fichero adopts the same request and keeps the quad. ScanTailor and Transkribus prepare pages as an ordered sequence (crop, deskew, split, clean) with a review of the unsure pages; Fichero does the same, as a recipe step with a worklist. Kraken and the eScriptorium flow treat page geometry as data a later step reads (regions inside the page); Fichero stores the page outline as a Shape so Find Regions and Leave Out can read it. Ultralytics YOLO is the usual trainable detector for pages and page furniture; Fichero keeps it as an optional, trained card behind the two model-free methods. Nothing here is invented.
The design
The Set Up step: three questions, answered from a sample
The stage prepare-images keeps its two jobs (split-pages, prepare-the-image) and asks, per project,
with the answers suggested from a sample of five pages (first, a quarter in, middle, three quarters,
last) before the person reads them; an answer is suggested when three of the five pages agree (owner
2026-10-29). Each answer is stored per folder: a notebook folder and a map folder of the same project can
differ. A fourth question, added 2026-10-29, belongs to Find Lines but is asked here so Set Up stays one
card: whether to check for lines and words the segmenter missed.
| Question | Choices | Suggested when | Default without a sample |
|---|---|---|---|
| Two pages in one picture? | yes / no | the sample’s outlines are wider than tall on 3 of 5 | no |
| Anything beside the page? | ruler · colour card · dark mount or table · nothing | the outline covers under 85 % of the frame on 3 of 5 (the first three are one answer: “find the page”; the ruler and card choices add Leave Out’s reasons) | nothing |
| The paper | ruled or graph paper · stained or faded · writing shows through | recipes/prepare.sample_shows_faded; a hue mask finds thin regular coloured lines on 3 of 5; a mirrored faint copy of the previous page on 3 of 5 |
none |
| Check for missed lines and words? | yes / no | the sample’s Find Lines (the bake-off already segments the sample) leaves over 3 % of the ink outside the line boxes on 3 of 5, or any sample line reads under 60 % of the page’s characters per width (source.segment.check-lines.*) |
yes for handwriting, no for typescript |
Below the questions, one line: Finds each page, turns it upright and straightens it; cuts spreads into
pages; marks blank pages. About 2 min for 374 pages on this Mac. Nothing leaves this Mac. The time comes
from prep.estimate.* below; the sentence is the engine’s (how_it_works), never the app’s.
What runs by itself, whatever the answers: find the page and crop to it (a no-op when the page fills
the frame), square a lopsided page from its corners, flatten a page curved toward the gutter, turn
upright by the text, straighten (skipped under 0.3°), mark and hide blank pages. What the answers
switch on: split (two pages), contrast and yellowing (faded), ruling, show-through, the check for missed
lines (image-enhancement.md, segments-and-geometry.md). A step that finds nothing to do writes
nothing.
The operations, in order
- Find the page. Apple Vision’s document outline first; the contour finder (the legacy templates,
auto-chosen by the border’s mean brightness) where Vision answers nothing or under 0.5; the YOLO page
card where one is installed and the recipe names it. The result is a
page_regionShape on the image (quad, box, method, confidence;segments-and-geometry.md) and the document’spage_boxmetadata in fractions, which Leave Out and Find Regions read. The crop is a rendition; the outline maps every later shape back to the photograph. - Square the page (perspective). When the quad’s corners are not a rectangle (any side’s angle from
the frame’s axes over 1°, or the two opposite sides’ lengths differing by over 2 %), the page is warped
to a rectangle from the four corners:
cv2.getPerspectiveTransformandcv2.warpPerspectiveto the size the longer sides give, white fill. The source quad is the Vision outline or the contour finder’s polygon (cv2.approxPolyDPon the largest contour, four corners), never a hand guess. The result is a rendition with the homography on its row, so every later shape maps back to the photograph through it. A page whose quad is already a rectangle writes nothing. Below the finder’s confidence the quad is a proposal: the person drags a corner and Fichero squares from the corrected quad. - Flatten the curve (dewarp), for a bound book. After squaring, a page whose text lines curve or
slant toward the gutter is flattened: text lines are found by connected components of the ink mask
(the legacy
segment.get_connected_component_linesidea) and each line’s baseline is fitted with a quadratic; the baselines together give a smooth displacement field (a thin-plate spline through the baseline samples,cv2.remap) that straightens every baseline to horizontal and evens the stretch toward the gutter. The step runs only where the fitted curvature is over 0.5 % of the page height on the gutter side (both sides on a spread cut in two) and is skipped otherwise; a page with no text lines (blank, a map) is skipped. It is a rendition with the field’s control points on its row. Its test is reading: lines in the gutter third must read no worse than before and the bake-off keeps the step only where it helps (prep.judged-by-reading). - Split at the gutter. An outline wider than tall is a spread; the gutter is the darkest column of the middle band, kept only when darker than 180 and 15 darker than its neighbours (the legacy test); pages come out in the cascade’s reading order as child items. Below the confidence the cut is a proposal.
- Turn by the text. Vision text recognition on a reduced copy at 0, 90, 180 and 270; the orientation
with the most recognised words wins; skipped when the first try already recognises most of them. A
lossless quarter turn, recorded with its reason. (As built, 2026-10-29: one read, the turn taken from the order of the
lines, because Vision reads every turn equally well; see
prep.turn-by-the-text.) - Straighten. The skew is read from the writing’s row profile (the shear that sharpens it; the table, ruler and page edge are not read), the angle on the row, skipped under 0.3°; a page already squared or flattened is usually under that and writes nothing.
- Mark blank pages. A page with no ink beyond its ruling (ink pixels under 0.2 % after the ruling
mask) is marked blank: kept, dimmed, hidden in the item view, skipped by every later step (find
regions, leave out, read, check), never deleted. A person unhides one with one click, and an unhidden
page runs through the steps it skipped.
“Sure” means no mark at all at the faint cut (12 grey levels under the paper, ruling and specks taken out: a folio
number, a squiggle and faded pen are all marks) and no text line found on the page, when lines exist for it. A page
with ink over 0.2 % is shown as written. In between, or with a line found, the page is unsure: it stays shown and a
blankproposal is stored on the page (prep_proposals, for Pages to check). The faint cut sits under the faint ink the contrast step raises (20 to 30 levels), so a page that step would brighten is never hidden before it sees it. Three short pen strokes on a ruled ledger page, or a folio number alone, are unsure, never hidden: a hidden page is never read. Unmeasured on real scans: the cut is set from drawn pages. - Enhance where asked:
image-enhancement.md’s suite (contrast, yellowing, stains, ruling, show-through, binarise, denoise, sharpen), each a rendition.
Each operation reports a confidence and a reason; below its threshold it proposes instead of
changing: a dashed page box, dashed corner handles, a dashed gutter line, a turn shown as an arrow. Every applied operation is a
row in the page’s edit chain with method, confidence and who: run <id> (image.enhance.rendition-records-its-steps).
Check and correct
After the run, Set Up (and Activity’s summary) shows Pages to check: N, which opens a worklist in the
Check lens (checking.md): every page with a proposal, plus one confident page in twenty as a sample, the
proposals first. Each row says what is unsure in words (“gutter faint”, “page box covers 61 %”, “turned
180° from its text”). A page opens in Preview’s editor with the run’s result drawn on the photograph: the
page box with corner handles, the gutter line, the turn. The person drags, or accepts with one key. A
correction replaces the run’s row with a row who: person, keeping the run’s values beside it so the
disagreement is a training label. “Apply to the rest of this folder” copies a correction’s parameters in
fractions of the frame to the folder’s other pages (the same notebook is photographed the same way), as a
batch with its own undo (image.enhance.batch-preview-undo). Marking a page as not blank, or blank, is a
correction too, and so is unhiding a blank page in the item view. The tools themselves are preview.edit.tool.*.
Corrections train a detector
Corrected page boxes are labels. When a project holds 30 or more corrected or accepted pages, Set Up
offers Train a page finder from your corrections: a one-class YOLO fine-tune (training/yolo_set.py,
training/yolo_local.py, the same pipeline as regions, #5525) on this Mac’s GPU, as a Hugging Face
job, or on a cluster through Slurm (ACENET) through the existing training places and nothing new
(../compute/training-and-evaluation.md: training.place.compared, training.place.this-mac-gentle,
training.place.hf-priced-first, training.place.slurm; the cluster targets of
../compute/targets-and-connection.md and ../compute/hpc-runner-acenet.md), the cost and time shown
first and the place allowed by Set Up Fichero (source.onboard.places-cap-projects). The Kraken
segmenter trained from accepted check-lines corrections (source.segment.check-lines.corrections-train)
goes through the same places. The offer appears once at 30 and
again after every 30 more; it is never started by itself. The result is a project card. It replaces the
classical finder only on evidence: the bake-off scores every page-finding card on the held-out
corrected pages (one in five, never trained on) by box overlap (mean IoU) and the recipe adopts the best;
a trained card that does not beat Vision and the contour finder stays installed and unused, and the
offer says so in words. Marked ruler and colour-card regions are labels for the layout detector in the
same way (prep.yolo.fine-tune-from-corrected-regions).
Methods are cards, chosen by rule, replaced by evidence
| Job | Cards | Default | Licence |
|---|---|---|---|
| find the page | Apple Vision outline · contour finder · YOLO page detector (trained) | Vision, then contour | Vision: the OS · OpenCV: Apache-2.0 · Ultralytics: AGPL-3.0 |
| square the page | perspective warp from the quad | itself | OpenCV, Apache-2.0 |
| flatten the curve | baseline-field dewarp | itself | OpenCV, Apache-2.0 |
| split pages | the built-in splitter | itself | — |
| turn by the text | Vision text at four turns | itself | the OS |
| straighten | row-profile shear of the ink | itself | OpenCV, Apache-2.0 |
| find regions | Kraken blla · YOLO layout card |
blla (prep.regions.open-default) |
Apache-2.0 · AGPL-3.0 |
Why Vision and OpenCV first. Both are on every Mac the app runs on, load in well under a second, need
no download and no licence sheet, and found the page on every notebook photo tried. Why YOLO third and
optional. It needs PyTorch resident (seconds and gigabytes), a model on disk, and corrected pages to be
worth training; its value is learning one collection’s furniture, which only corrections can teach. The
licence. Ultralytics is AGPL-3.0, as Fichero is (fichero-server/pyproject.toml, ruled 2026-10-09), so
shipping it is compatible. Two consequences are stated here so nobody is surprised: a detector fine-tuned
with Ultralytics is itself AGPL by Ultralytics’ reading, so it can be shared with a recipe but not
relicensed; and the App Store’s terms are widely held to conflict with the AGPL, which matters only if
Fichero moves from DMG and TestFlight to the store. Neither default card carries that caution.
Time and cost, before Start
Every operation here runs on this Mac and costs nothing; the Start sheet says so and gives the time: the
per-page seconds measured on this machine’s last run of each card (recorded on the run, recipes-run.*),
or, before any run, the seed figure on the card, marked “estimate”. Training a detector is the one thing
with a price: a local fine-tune says its minutes; a Hugging Face job says its rate and minutes from the set
size, through the existing estimate (source.onboard.estimate-before-start).
Judged by reading
The bake-off (source.recipe.*) treats a preparation operation like any other job: the same sample read
with and without it, character error rate against checked pages, and an operation stays in the recipe only
where it helps. Ruling suppression in particular stays off until the bake-off shows it helps this
collection (ruling 2026-10-04: some models use the ruling as a line guide).
Behaviors
The step in Set Up
prep.setup.three-questions-suggested-from-a-sample— [GAP] (#5580; owner 2026-10-29: five pages, three of five) the Prepare Images card asks the questions above (the id keeps its name; a fourth, the missed-lines check, was added 2026-10-29) with answers suggested from five sample pages (first, quarter, middle, three quarters, last) when three of the five agree (outline aspect, outline coverage,sample_shows_faded, a ruling mask, a mirrored-verso match, the sample’s ink-outside and characters-per-width figures), each answer stored per folder; the person changes any. Built 2026-10-29 (partial):recipes/stages.pyasks the four questions;recipes/prepare_suggest.pysuggests two-pages, beside-the-page and the paper from the five pages (GET /api/recipes/prepare-images/facts), the card shows them with Use (PrepareImagesCard.swift,PrepareImagesSetupUITests.swift, unrun). Built 2026-10-30: the answers are kept per folder (answers.job_answers_by_folder,{folder id: {question: answer}}; the Start plan gives a folder with its own paper or two-pages answer its own run,folder_id, and the project’s run leaves it out; the card’s folder picker,PrepareImagesCard.swift,PrepareImagesFolderAnswersTests.swift); the missed-lines suggestion (ink outside the line boxes of the pages’ lines on three of five; the characters-per-width half needs readings and is not built) and the show-through suggestion (a faint mirrored copy of the previous page,prepare_suggest.shows_through),tests/unit/recipes/test_prepare_answers_per_folder.py. Neither suggestion is measured on real scans yet; the drawn pages pass and a ruling alone does not trigger show-through. Not built: the characters-per-width figure; the bake-off’s per-folder answer (the card shows one folder at a time).prep.setup.what-runs-by-itself— [GAP] (#5580) find the page, square, flatten, turn, straighten and mark blanks run on every page whatever the answers; split, contrast, yellowing, ruling, show-through and the missed-lines check run only when their answer says so; a step with nothing to do writes no row. Built 2026-10-29 (partial): theprepare-the-imagecard (runner._run_prepare) now runscrop_pages(prepare=True)first on every page (find the page, square, flatten, turn, straighten, blanks; accountpage_prep), then the contrast step;tests/unit/recipes/test_prepare_step_setup.py. The paper answer gates the contrast step (no answer: each page is looked at and only faded ones raised). Built 2026-10-30: each paper answer is its own gate (faded raises the contrast, ruled and show-through are kept and the plan says the operation is not built yet) and an explicit no to “Two pages in one picture?” skips the split with its why (no answer keeps the old behaviour). Not built: the ruling and show-through operations themselves (Step 4.2); an unhidden page is run through the page operations and contrast at once (blank_page.queue_unhidden).prep.setup.step-runs-from-the-start-plan— [GAP] (#5580) the Start plan holds a runnableprepare-the-imageentry naming the operations and their cards, beforefind-regions; its progress line says “Preparing images: 23 of 374 pages, about 2 min left” (image.enhance.onboarding-stepis this line’s twin in the enhancement spec and is retired in favour of it).prep.estimate.time-on-this-mac-before-start— [GAP] (#5580) the Start sheet shows the step’s time as the per-page seconds measured on this machine’s last run of each card times the page count, or the card’s seed figure marked “estimate”, and says the step costs nothing and leaves nothing this Mac; a training offer shows its minutes locally or its rate and minutes on Hugging Face.prep.setup.how-it-works-is-the-engines-sentence— [PARTIAL] (#5791) the one-line description under the questions is the job’s topic text from the engine (how_it_works,recipes/seed/topics.yaml), never written in the app. Built: the mechanism. Theprepare-the-imagetopic now names the operations.
Finding the page
prep.find-the-page— [OK] (#5382, #6188) the page is found on a busy background and the photograph is cropped to it; the outline is kept as a geometry mapping back to the original. Built:split_pagesfinds it with Vision’s outline and crops to its box (media/page_split.py). Missing at the 2026-10-29 rewrite (all built since): the quad stored, the attribute, the contour fallback, the crop as a rendition of the page. Built 2026-10-29 (lane/image-prep):media/find_page.find_page(Vision, then contour), the quad andpage_regionon the document, the crop as a rendition (recipes/page_crop.py). The contour finder is not sure (confidence under the cut, so a proposal and the whole frame kept) when a second page-sized piece lies beside the one chosen (MIN_PIECE_SHARE): a spread cut in two by a gutter shadow is never cropped to one half. A re-run withreuseskips a page already prepared from the same file under the same rules (page_prep_stamp). Tests:tests/unit/media/test_find_page.py,tests/unit/recipes/test_page_crop_writes_page_region.py.prep.page.opencv-default-yolo-optional— [PARTIAL] (#6188)media/find_page.pytries Vision’s outline, then the contour finder (templates auto-chosen by border brightness: dark mount →dark_background, light table →light_background; largest external contour with area 0.15–0.99 of the frame and aspect 0.5–2.0; pad 30 px), then the YOLO page card only when its model is installed; it returns outline, method and confidence and never alters the original. On a test page and a notebook photo with no model installed the outline is within 2 % of the hand-drawn box. Built: Vision outline (trusted from 0.5), then the contour finder; both return the quad; the original is never altered; furniture (ruler, colour card) from the contour pass. Not built: the YOLO page card (Step 4.1 trains it) and the legacy templates beyond the auto dark/light choice.prep.page.region-attribute-and-page-box— [OK] (#6187, #6198) finding the page writes apage_regionShape (quad, box, method, confidence,frame: "upright") on the image and the document’spage_boxmetadata in fractions, the same numbers Leave Out reads (image.enhance.page-crop-writes-page-boxis this line’s twin and defers to it).page_region(quad, box, method, confidence,frame: "upright", settings) andpage_boxare written together; a person’s box is never replaced.tests/unit/recipes/test_page_crop_writes_page_region.py.prep.page.detected-before-lines— [OK] (#6189) when a page has apage_region,recipes.regions.find_regionsgives the segmenter only that crop and maps every region and line back to the page image’s frame; a fixture with a ruler strip and a dark border yields no line outside the region. With #6296 the finder reads the page’s current image (media/current_image.py): the box, kept in fractions of the upright photograph, is carried onto that image (regions.page_box_on), not cut again when it is already the whole image, and what is found goes from the cut to the current image to the photograph. A copy that keeps an EXIF orientation tag (a phone photograph’s smaller or cut copy) is handled the same way (#6302):to_imagelands in the file’s raw pixels, soPageImage.upright_mapcarries it on through the tag to the upright pixels thatpage_cropcuts and the finders answer in, andphotograph_mapgoes back from those; a rendition imported with a transform and any orientation tag is put on its raw pixels in_rendition_map(_in_file_pixels), and a turn of it follows the parent’s upright picture; a rendition file that is missing or not a picture is passed over (logged as a warning, counted asrenditions_passed_overin Find Regions’ account, andPageImage.whysays so). A good turned rendition whose parent’s file is gone is passed over too (its frame is never guessed): the page reads the photograph, its signature isoriginal, so readings made from the turned copy stop counting (working_lines.unread_by) and the page is read again. Lines already stored from a tagged copy with ato_imagebefore #6302 stay where they were put (wrong) until Find Lines runs again; no migration ships. Pinned bytests/unit/recipes/test_find_regions_inside_page.py.prep.page.passed-over-renditions-are-shown— [GAP] (#6303) when Find Regions cannot read or follow a page’s newer rendition and reads the page on an older rendition or the photograph, the run summary and Activity say so in words: the number of pages read on an image nobody chose, with each page’s reason fromPageImage.why, so a person paying for a cloud reader is told. Built: the count isrenditions_passed_overin the accountfind_regionsreturns and one WARNING log line (test_find_regions_inside_page.py). Not built: the run summary and Activity read no such key. Test (to write): a run whose page passed over a rendition lists it in the summary.prep.page.kraken-time-saved-is-reported— [PARTIAL] (#6189) the run summary says per page the seconds with and without the region and the lines inside and outside it, on the two test-page fixtures. Built: the run account says pages cropped, area saved, seconds andlines_inside/lines_outsidethe page box. Also built:find_regions(..., measure_whole=True)reads each cut page’s whole frame once more, saves nothing from it, and addswhole_seconds,whole_seconds_per_page,whole_lines_inside,whole_lines_outsidebesideseconds_per_page(test_the_run_reports_seconds_per_page_and_lines_inside_and_outside_the_page_before_and_after_when_asked; without the ask no whole-frame read happens). Not built: any card or recipe that setsmeasure_whole, so the run summary still carries only the cut figures;fichero-server/scripts/measure_page_crop.pyproduces the before/after figures on real scans.prep.crop.content-bbox-is-fast— [OK] (#6190)detect_content_bboxis a NumPy reduction, under 0.5 s on a 3000×2000 image, with the same answer as today on the fixtures. NumPy reduction; 2400x1700 content in a 3000x2000 frame well under 0.2 s, the loop’s answer unchanged (tests/unit/media/test_image_ops_legacy_port.py).prep.page.remove-background-is-the-dark-mount-method— [PARTIAL] (#6188) the editor’s Remove Background and theremove_background_imagesnode become the contour finder’s dark-mount method inside find-the-page; the old operation name survives only so an existing chain re-renders unchanged. Built: the oldremove_backgroundre-renders unchanged (pinned) and the contour finder handles the dark mount. Not built: rewiring the editor’s operation and the node onto the finder.
Squaring and flattening
prep.square.perspective-from-the-quad— [OK] (#5382; owner 2026-10-29) a page whose found quad is not a rectangle (a side over 1° off the frame’s axes, or opposite sides differing by over 2 %) is warped to a rectangle from its four corners (cv2.getPerspectiveTransform,cv2.warpPerspective, white fill, the size the longer sides give) as a rendition whose row carries the homography; a rectangular quad writes nothing; thepage_regionand every later shape map back through the homography (framenames the rendition). On a fixture photographed at 15° the warped page’s edges are within 0.5° of the axes and the hand-drawn box overlaps the result over 0.97. Built 2026-10-29:media/square_page.py(quad_is_rectangular,square_page,unsquare_points), thesquareedit operation, asquaredrendition fromrecipes/page_crop.pywith the homography and quad on itstransform; a flat page writes nothing.tests/unit/media/test_square_page.py(a 15° fixture squared within 0.5°). The 0.97 overlap with a hand-drawn box waits for the fixture files.prep.square.corner-handles-correct-it— [PARTIAL] (#5382) below the finder’s confidence the quad is a proposal drawn as four dashed corner handles in Crop (preview.edit.tool.crop-is-a-page-box); dragging a corner and Return squares the page from the corrected quad withwho: person. Built 2026-10-29:POST /api/images/{id}/operations/squaretakes a person’s four corners and writes the rowwho: person;PageCornersandPageCornerHandlesOverlaydraw four dashed handles over the found page (toolbar button on a page with apage_region), drag moves a corner, Return squares (ImageEditDirectToolsTests.swift, unrun). Not built: the handles follow the editor’s own zoom (they are drawn on the unzoomed fit); the quad of a page the finder was unsure of is not stored yet (Step 3.2), so they show only where apage_regionexists.prep.flatten.curve-toward-the-gutter— [PARTIAL] (#5382; owner 2026-10-29) a page whose text baselines curve or slant toward the gutter (fitted quadratic curvature over 0.5 % of the page height on the gutter side) is flattened by a displacement field from the baselines (connected-component lines, quadratic baselines, a thin-plate spline,cv2.remap) that makes every baseline horizontal and evens the stretch; a straight page, a blank page or a page with no lines writes nothing; the rendition’s row carries the control points. On a synthetic page bent by a known curve the recovered baselines are within 2 px of straight. Built 2026-10-29:media/flatten_curve.py(connected-component lines, robust quadratic baselines, a smooth displacement field,cv2.remap); aflattenedrendition with the control points on its row fromrecipes/page_crop.py; a bent synthetic page comes out within 2 px (11 px before), straight, blank and one-line pages write nothing (tests/unit/media/test_flatten_curve.py). Decided deviation (2026-10-29): linear interpolation between baselines then a blur, not a thin-plate spline. (Review 2026-10-29: scipy is not a direct dependency but already ships in the app through pykeen and Kraken, so the reason is weak; the thin-plate spline is the upgrade, no new download.) the baselines come out straight within 2 px, which is what the test asks; a thin-plate spline is the upgrade if real bound volumes show the smooth field is not enough; no even-out of the stretch toward the gutter; whole page, not the gutter side.prep.flatten.judged-by-the-gutter-third— [GAP] (#5382) the bake-off reads the gutter third of the sample with and without the flatten and keeps the step only where its character error rate is no worse; the figures are on the run.
Splitting, turning, straightening, blanks
prep.split-at-the-gutter— [PARTIAL] (#5382) a two-page image is cut at its gutter or spiral, not at the middle, into pages in reading order; a single page is left whole. Built:split_pages(Vision outline, darkest column, aspect gate, proposal below 0.15; pinned on 11 notebook photos,tests/unit/media/test_page_split.py). Missing: the neighbour test (darker than 180 and 15 darker than its neighbours), regions as children for several items on one sheet, the recipe calling it from the Start plan (#5390).image.enhance.split-spreaddefers to this line. Built 2026-10-29: the neighbour test infind_gutter(under 180 and 15 darker than the columns 60-140 px beside it, else a proposal), pinned intests/unit/media/test_page_split.py. Still missing: regions as children for several items on one sheet, the Start plan calling it.prep.turn-by-the-text— [PARTIAL] (#5382) after cropping, a page is turned 0, 90, 180 or 270 degrees from its text: Vision text recognition at four turns on a reduced copy, the most words wins, skipped when the first try is confident; a lossless quarter turn recorded with its reason. EXIF alone is not enough (prep.image.one-upright-frameapplies EXIF first). Built 2026-10-29:media/turn_by_text.py, arotatedrendition fromcrop_pages(prepare=True). Deviation from the ruling above, kept beside it (2026-10-29, builder, measured; the ruling’s text stands until the maintainer changes it): Apple Vision reads sideways and upside-down text as well as upright (the same 72 words at all four turns, measured), so a word count at four turns cannot decide; the turn is read from the order of the lines Vision returns (first line first: down the picture is upright, up is 180, left to right is 90, right to left is 270) in one read, no turn tried when fewer than three lines. Pinned with the real reader on a drawn page at all four turns (tests/unit/media/test_turn_straighten_blank.py). Not built: a page-less photograph of one line.prep.straighten-and-flatten— [PARTIAL] (#5382, #6190) small skew is corrected by Hough median with the angle recorded on the row and skipped under 0.3°. Built:deskew_images, the editor’s Straighten. Missing: the angle on the row (todayangle: 0means “auto”). Flattening a curved page isprep.flatten.curve-toward-the-gutter; squaring isprep.square.perspective-from-the-quad.image.enhance.rotate-deskewdefers to this line. Built 2026-10-29: thedeskew_imagesnode writes the angle found on its row (methodhough) and no row under 0.3 degrees;auto_straighten_angle; adeskewedrendition fromcrop_pages(prepare=True). The editor’s Straighten already stored its estimate. Flattening isprep.flatten.curve-toward-the-gutter.prep.blank-pages-marked— [PARTIAL] (#5382; owner 2026-10-29) a page whose ink pixels are under 0.2 % after the ruling mask is marked blank: imported and kept, dimmed, skipped by every later step (find regions, leave out, read, check), never deleted; a person can mark or unmark any page. The mark is a chain row (prep.check.blank-mark-is-a-correction); the skip is Leave Out’s page-level reasonblank, so the reading never sees it. Built 2026-10-29:media/blank_page.py(ink_shareafter a ruling mask,is_blank,mark_blank), amark_blankchain rowwho: run <id>,crop_pages(prepare=True)marks and skips; a person’s word is kept on a re-run. The skip is the existing exclusion (Database._UNIT_OF_WORK_WHEREnow leaves excluded pages out of what a recipe runs), not a Leave Out reasonblank.tests/unit/media/test_turn_straighten_blank.py,tests/unit/api/test_blank_pages_hidden.py.prep.blank-pages-hidden-in-the-item-view— [PARTIAL] (#5382, #1791; owner 2026-10-29) a blank page is hidden in the item view (the list and the grid) withexclude_from_processingset and the row kept, under a “N hidden” line that reveals them dimmed (library.chrome.excluded-from-processing-treatment); Unhide on one clears the mark, writes the correction row and queues the page through the steps it skipped; a leaf pairing (finding-documents.md) still counts a hidden verso. Engine built:exclude_from_processingset, row and file kept,unhideclears it and writes the person’s row and returns the id to queue;POST /api/images/{id}/operations/mark-blank(blank: falseunhides). Swift built 2026-10-29 (unrun):HiddenPagesLine(“N hidden” above the rows, reveals the pages dimmed, each with Unhide), the rows leave the hidden pages out (BlankPagesHiddenTests.swift). Built 2026-10-30 (unrun): the line and the rows read the page again from the engine after the action and after every Undo and Redo (HiddenPages.settle, used by Unhide, Hide and Keep;BlankPagesHiddenTests.swift), so “N hidden” follows the page’s real state. Not built: queueing the unhidden page through the steps it skipped (Step 3.1’s plan), the leaf pairing counting a hidden verso (not checked).prep.suppress-ruling— [GAP] (#5382, #6195) ruled and graph-paper lines are removed and the ink kept, off until the bake-off shows it helps; the method isimage.enhance.ruled-lines.prep.image.one-upright-frame— [PARTIAL] (#5382; Test 14, 2026-10-24; ## 1114) a phone photo carries its rotation as an EXIF Orientation tag, and a page is ONE frame wherever geometry meets its image: the thumbnail, Preview, the reader’s line crops (cloud and local, TrOCR, the re-asks), the Inspector’s and Reader’s segment pictures, the check’s and the tie’s reads of given lines, a training set’s page and lines, and the Kraken segmenter’s geometry are all in the upright frame, the tag applied once (media/upright.py:upright,upright_size,open_in_frame). New geometry says so (frame: "upright"); geometry with no marker was measured on the raw pixels and every consumer reads it so. The marker is on the pass (media/upright.pass_frame), inherited by a person’s split, create or merge; a region node saysframetoo (media/region_crops); the evaluation and the bake-off score on the chosen pass’s frame. Built (unrun on a real photo): the helpers, the marker on results, boxes, segments and passes, the consumers above. Not done: a pass not made from a result (a format import, a hand-made pass) reads raw; the live check on a real phone photo. Tests:tests/unit/llm/test_one_upright_frame_exif_test14.py,tests/unit/llm/test_exif_crops_are_upright_1114.py.
Check and correct
prep.unsure-becomes-a-proposal— [PARTIAL] (#5382) an operation below its confidence proposes (a dashed page box, a dashed gutter, an arrow for a turn) and lists the page for review rather than changing it. Built 2026-10-30:page_cropstoresmetadata.prep_proposals.page_box(the contour finder’s unsure quad, box, confidence and two sentences) and.turn(the lines do not agree which way the page runs) and, with the existing.blank, withdraws a kind when a later run is sure; a kind a person answered (metadata.prep_answered) is never proposed again; the page keeps its whole frame. The list isrecipes/prepare_check.py. Not built: the gutter proposal (split_pagesreturns it below 0.15 but it is not stored on the page); drawing the stored page box as the dashed corners in Preview (the handles still show only where apage_regionexists).prep.check.worklist-of-proposals-and-a-sample— [PARTIAL] (#5382) after the run, “Pages to check: N” opens a Check-lens worklist of every page with a proposal plus one confident page in twenty, proposals first, each row saying in words what is unsure; the count is on the Set Up card and in Activity’s summary. Built 2026-10-30:GET /api/recipes/prepare-images/check(proposals first in the project’s page order, then every 20th page the step found a page on and was sure of, with “checked as a sample”),to_checkon/prepare-images/facts; Swift (unrun)PrepareImagesCheckListunder the Prepare Images card: “Pages to check: N”, rows with the words, Accept, Mark blank, Open in Preview (PrepareImagesCheckListTests.swift,PrepareImagesSetupUITests). Not built: the count in Activity’s summary; the Check lens itself (checking.md) does not list these pages, the worklist lives on the card.prep.check.correction-replaces-the-runs-row— [PARTIAL] (#5382) accepting or adjusting a proposal, or changing an applied operation, writes a chain rowwho: personthat replaces the run’s row and keeps the run’s values beside it; the rendition is re-made; the page leaves the worklist. Built 2026-10-30: a person’s squaring (image.square) writes its row withreplaces: {by, values: {quad, box, confidence}}(the run’s values, a training label) and answerspage_box;image.rotateanswersturn;image.mark_blankanswersblank;image.accept_proposalleaves the page as it is; each is one audited action and Undo (image.restore_proposals) puts the proposal and the chain back. Not built: the run’s own rendition is not re-made from the person’s row (the row is applied through the editor’s chain, not as the step’s rendition).prep.check.apply-correction-to-the-folder— [PARTIAL] (#5382, #6192) a correction’s parameters, in fractions of the frame, can be applied to the folder’s other pages as one batch with whole-batch and per-page undo; the sheet previews three pages (first, middle, last) before it runs (prep.cleanup.preview-three-samples-before-batch,prep.cleanup.batch-over-a-folder,prep.cleanup.per-page-undoare this line’s names in #6192 and resolve to it and toimage.enhance.batch-preview-undo). Built 2026-10-30:POST /api/images/batch-prepare/preview(the folder’s first, middle and last page with the correction applied, a small JPEG each, no row written; pages in the project’s order), the actionimage.batch_prepare(a squaring’s four corners, in fractions of the upright frame, or a turn’s degrees, copied to every other page of the folder as awho: personrow carrying onebatch_id, which is the audit’s id; pages hidden as blank and pages a person already squared or turned are left out and said), whole-batch Undo (image.restore_batch, one audit) and per-page Undo (image.undo_batch_pagedrops that page’s row of the batch). Swift (unrun): the image editor’s toolbar button “Apply this correction to the rest of this folder” opensImageBatchPrepareSheet(three previews, Apply, then a list with Undo for each page;ImageBatchPrepareTests.swift). Also built (#6192):POST /api/images/batch-applytakes every operation ofmedia/image_opsbesidecropandsplit(paramscarries the step’s settings); such a batch adds one step per page to the page’s edit chain, each stamped with the batch’s id (test_batch_apply_adds_a_stamped_step_for_a_non_crop_operation_on_every_page,test_batch_apply_takes_the_other_operations_too);?preview=3returns the first, middle and last page before and after and adds no step (test_preview_three_shows_first_middle_last_before_and_after_and_writes_nothing);POST /api/images/batch-apply/{batch_id}/undoremoves the steps the batch added and keeps the page’s other steps (test_undo_on_the_batch_removes_every_step_it_added_and_only_those); removing one page’s step leaves the other pages’ (test_deleting_one_pages_step_leaves_the_rest_of_the_batch). Not built: the Prepare sheet callingbatch-apply(it still callsbatch-prepare); a split has no preview. Not built: the page-box correction as a corner-handles drag copied by the same sheet (a square is copied from the page’s chain, so it works once a page has been squared); batches over folders of PDFs; progress for very large folders (the action runs in one call).prep.check.blank-mark-is-a-correction— [PARTIAL] (#5382) a person marks a page blank or not blank from the worklist or Preview; the mark is a chain row like any other and reading honours it at once. Engine built: marking blank or not blank is amark_blankchain row withwho, honoured at once by the work-unit filter. Built 2026-10-30: Mark blank on the Pages to check worklist (Swift, unrun). Not built: the Preview button.
Detectors: cards, training, adoption
prep.methods-are-cards-the-recipe-chooses— [GAP] (#5382, #4951) each preparation job has its cards (Vision, contour, YOLO stock or trained, Kraken regions); the recipe names one per step, material kind and folder; onboarding picks the default by rule (built in, local, cheapest first); the bake-off replaces it only on evidence; a shared recipe carries its card choices.prep.judged-by-reading— [GAP] (#5382) each operation’s effect on character error rate is measured in the bake-off on the same sample read with and without it; an operation that does not help is left out of the recipe.prep.train.offered-after-thirty-corrections— [GAP] (#5382, #5525; owner 2026-10-29) when a project holds 30 or more corrected or accepted page boxes, Set Up offers “Train a page finder from your corrections”, once at 30 and again after every 30 more, with its time (local) or rate and time (Hugging Face) shown first; never started by itself; 29 corrections show no offer.prep.train.runs-locally-or-on-hugging-face— [GAP] (#5382, #5525, #5642; owner 2026-10-29, second ruling) the offer runs through the existing training places and no separate mechanism: this Mac as the regions fine-tune does (training/yolo_local.py,POST /api/training/regions/herewith the page class), a Hugging Face job through the route Kraken training uses, or a cluster through Slurm (ACENET) through the Slurm training place and the lane’s cluster targets (../compute/training-and-evaluation.md:training.place.compared,training.place.slurm,training.place.cost-before-train;../compute/hpc-runner-acenet.md); each place is a row with its time and cost, shown only when Set Up Fichero allows it (source.onboard.places-cap-projects) and refused in words otherwise; the Kraken segmenter trained from corrected lines offers the same rows (source.segment.check-lines.corrections-train). The id keeps its name; the cluster is in it.prep.train.adopted-only-on-held-out-overlap— [GAP] (#5382; owner 2026-10-29) the trained page card is scored against Vision and the contour finder on the held-out corrected pages (one in five, never trained on) by mean box overlap; the recipe adopts the best and says the figures; a trained card that does not beat the classical finder stays installed, unused, and the offer line says so.prep.yolo-detectors-run-and-train— [GAP] (#5382, #5525) a YOLO page and region detector runs locally and is trainable in Fichero from corrected outlines. Made concrete by the lines below.prep.yolo.regions-card— [PARTIAL] (#5525) Built 2026-10-10:recipes/regions.py,llm/yolo_runtime.py; pinned byfichero-server/tests/unit/recipes/test_yolo_regions_card.py. Thefind-regionsjob has a YOLO card: a layout model runs in the local model lane and writes a region pass (text block, heading, marginal note, page header, page footer, table, picture) with outline and confidence. The stock DocLayNet YOLO11 (hantian/yolo-doclaynet, AGPL like Fichero) is downloaded on request, never bundled; measured 2026-10-10 at 0.1 s a page warm, 6 s first load, and on two handwritten notebook photos it saw one “Picture” at 26–28 %: a starting point for fine-tuning only. Not yet: a trained model offered as a card by setup. Built 2026-11-08 [engine] a layout model whose weights are not on this Mac stops Find Regions before any page with the typed missing-model error, wordedmodel_missingwith the download in Settings, never a page that finds nothing (#6404,tests/unit/recipes/test_yolo_model_not_ready_6404.py). Not built: the app’s own words and download button for that state beyond what the plan already offersprep.regions.open-default— [PARTIAL] (#5668 walkthrough section 4) Find Regions’ default is Kraken’s built-in segmenter (blla, Apache-2.0, ships inside the app), kept to its regions; the YOLO DocLayNet model (AGPL-3.0) is a candidate with its licence sheet for pages that need its finer labels. Every page the project holds is found as every step finds it (sources._resolve_abs_path). Measured 2026-10-11: on a two-column printed pagebllafound 3 regions and 81 lines in 11 s on the MacBook Air. One pass, not two (#5689): the segmenter finds regions and lines together; Find Lines and Read use them (fichero-server/tests/unit/recipes/test_regions_one_pass_5689.py). Built: the bundled card, the rules,recipes/regions.pywithprovider="kraken"; pinned byfichero-server/tests/unit/recipes/test_model_chooser_per_step_5668.py. Not built: the Start plan still sends afind-regionsstep to YOLO only (recipes/start.py).prep.regions.one-find-regions— [PARTIAL] (#5962; owner ruling 2026-10-20: no two Find Regions implementations) finding regions is ONE function,recipes.regions.find_regions: the throttle’s wait, Stop before each page, the page through the model lane, regions and lines kept together, the savedregionsartifact; the recipe’s step and the workflow nodedetect_regions(providerkraken) both call it. Built (unrun): the node calls it with the run’s Stop and progress words; the node’s Apple and vision-model providers stay in the node; a YOLO provider on the node is held (needs an OpenAPI-visible enum). Tests (unrun, M4):fichero-server/tests/unit/workflows/test_detect_regions_one_path_5962.py,test_kraken_segmenter_node.py.prep.regions.one-implementation— [GAP] (#5962) a guardrail test namesrecipes.regions.find_regionsas the only Find Regions implementation; the recipe step and the node produce the same regions for the same page through it.prep.yolo.fine-tune-from-corrected-regions— [PARTIAL] (#5525, #5397) Built 2026-10-10 (this Mac):training/yolo_set.py,training/yolo_local.py, started byPOST /api/training/regions/here(so the MCP tool and the CLI command); the trainer ran on the GPU (two epochs, 11 s); pinned byfichero-server/tests/unit/training/test_yolo_regions_training.py. Corrected regions become a YOLO label set (formats/yolo.py, the same set builder as Kraken’s, #5513) and the stock model is fine-tuned on it, on this Mac or as a Hugging Face job; the result is a project card scored by region overlap on held-out pages. Not yet: the Hugging Face path, the bake-off adopting it, a Train button in the app.prep.yolo.page-detector— [GAP] (#5382, #6188) the same pipeline with one class, the page, finds and crops the page; its labels are the corrected page boxes; the oldyolov8s-fichero.ptis the baseline to beat, not a dependency.prep.yolo.quiet-in-the-sandbox— [PARTIAL] (#5525) Built 2026-10-10: settings, datasets, weights and runs under the shared models folder, sync and loggers off (yolo_runtime._quiet). Ultralytics runs offline in the app; nothing is checked online. Not yet checked in the sandboxed app.prep.licence.agpl-stated-on-the-card— [GAP] (#5382) the YOLO cards’ licence sheet says AGPL-3.0, that a model trained with it is AGPL too and can be shared with a recipe but not relicensed; the Vision and contour cards say they need no sheet. The sheet is the existinglicence-not-acceptedrefusal (recipes/assemble.py).
Renditions and the original
prep.never-changes-the-original— [OK] every result is a new rendition in the edit chain (preview.edit.chain-is-a-separate-row-never-the-source;fichero-server/tests/unit/workflows/test_image_prep_source_immutability.py).prep.prepared-image-attached-as-rendition— [OK] (#5386) the recipe’s prepared image is saved as a rendition of the page it prepared, as Split’s parts become children, never only as a scratch file the library does not point at. Today JPEG stays JPEG (e62aa3bae) and run scratch is removed (70e882c81), so the result is lost: this contradictsprep.never-changes-the-original’s “every result is a rendition”. The recipe’s prepare step writes apreparedrendition inside the library, a JPEG staying a JPEG (PNG otherwise); the workflow node persists throughpersist_workflow_renditions.tests/unit/workflows/test_prepare_images_rendition_recipe.py.prep.derived-image-records-its-recipe— [PARTIAL] (#6191) a prepared image is a rendition of its page whosestepsname each operation with its settings and card (method,model_id), with the run id (producer_run_id) or the batch id (producer_batch_id); the source file’s checksum is unchanged;image.revert_preparedremoves one rendition row and its file and nothing else. Built: the recipe’s prepare step records itscontraststep (cutoff, autocontrast),contrast_imagesrecords its settings and method,persist_workflow_renditionscopies a result’s steps and the batch id,GET /api/documents/{id}/renditionsserves them. Also built: therotate_images,enhance_images,fuzzy_clean_imagesandremove_background_imagesnodes record their step, settings and card (test_every_image_node_rendition_records_its_step_settings_and_the_batch). Also built: an editor step and a batch step in a page’s edit chain carrycard(method,model_id) besideparamsand, for a batch,batch_id(test_an_editor_step_and_a_batch_step_record_the_operation_its_settings_the_card_and_the_batch). Not done: the editor and a batch write nostepson a rendition, and there is no Revert control in the app.tests/unit/workflows/test_prepare_images_rendition_recipe.py.prep.renditions-list-the-edit-chain-head— [GAP] (#6414; owner 2026-11-08: Enhance in the Preview’s image editor works but does not show in the page’s Renditions. Diagnosed in code 2026-11-08:image.enhanceis audited and undoable (api/routes/ingest/image_editing.py, the action at line 1733) but appends to the document’s EDIT CHAIN (_chain_ops_snapshot,ImageEditChainResponse, applied on demand) and writes no rendition row; renditions come only fromworkflows/tools/image_edit_chains.persist_workflow_renditions(the recipe’s pixel steps). PROVISIONAL, owner to confirm; the manager recommends (a)) the page’s Renditions list shows the edit chain’s head as a DERIVED row, computed from the chain and written nowhere: named by its last operation (“Enhanced”, “Cropped”, “Background removed”, “Rotated”) with when and by whom from the chain’s audit rows, selectable as the picture a reader or a pane shows like any rendition (ZoomableImagePreviewMac+Renditionslabels it the same way), and “removable” by undoing the chain’s last operation (⌘Z on the row), so one source of truth remains (preview.edit.chain-is-a-separate-row-never-the-source) and no second write is added; option (b), Enhance also persisting a rendition, is not taken unless the owner says so. Acceptance: Enhance a page in the editor and open Renditions: a row “Enhanced, just now” is listed beside the original and the recipe’s prepared image; choosing it shows the enhanced pixels; undoing the enhance removes the row; nothing new is written to the renditions table. Test:test_renditions_list_the_chain_head_6414.py(not yet written; fails on base: after an enhance the list has no derived row), the existingtest_image_edit_chains.pyandtest_workflow_renditions.py. Was: provisional; the owner answered on 2026-11-08 13:10 (option (a), with the order, the Used mark and the choice):prep.renditions-mark-the-image-readers-usebelow carries the decision; this text is kept as written.prep.renditions-mark-the-image-readers-use— [GAP] (#6414; owner 2026-11-08 13:10, DECIDED, answeringprep.renditions-list-the-edit-chain-head’s provisional question above, whose text stays as written. Diagnosed in code 2026-11-08:image.enhanceis audited and undoable (api/routes/ingest/image_editing.py, the action at line 1733) but appends to the document’s EDIT CHAIN (_chain_ops_snapshot,ImageEditChainResponse, applied on demand) and writes no rendition row; renditions come only fromworkflows/tools/image_edit_chains.persist_workflow_renditions; readers read the page’s current image by one rule,media/current_image.current_page_image: the chain, else the newest rendition with a known frame, else the original) the page’s Renditions list shows the edit chain’s HEAD as a DERIVED row, computed from the chain and written nowhere, named by its last operation (“Enhanced”, “Cropped”, “Background removed”, “Rotated”) with when and by whom from the chain’s audit rows, AND the chain’s operations in ORDER under it (each as the image chain already lists them,GET /api/pages/{id}/image-chain), beside the stored renditions in the order they were made; ONE row carries a clear mark, Used by readers, on the imagecurrent_page_imagewill read (reads_thisin the chain answer), and the person can CHANGE which is used: from the row’s menu (Use for Reading), by ⌥-clicking a rendition in the Preview’s Renditions menu, or from the Inspector’s Images section, the choice recorded as one field on the page through the existing audited document update (one ⌘Z) and read bycurrent_page_imagebefore its default rule, so every later step reads the chosen image anddata.image_readrecords it (prep.rendition-without-a-frame-says-so); a derived row is “removable” by undoing the chain’s last operation; one source of truth, no second write (preview.edit.chain-is-a-separate-row-never-the-source). Where Renditions live (the owner’s question, one answer): in the document Inspector’s Source › Images section for the page, the one place that lists the original, the chain’s head and operations, and the stored renditions with the Used mark and the menu; the Preview’s Renditions menu stays the quick switch for what is SHOWN and takes ⌥-click for what is USED; no archive pane and no new pane kind: the Inspector already inspects the page’s making (InspectorSegmentMakingSection), and the images belong beside it. Acceptance: Enhance a page and open Renditions: “Enhanced, just now” is listed with its operation under it, marked Used by readers; ⌥-clicking the original marks the original instead, the next Read reads the original and says so in Making; undoing the enhance removes the derived row; nothing new is written to the renditions table. Test:test_renditions_list_the_chain_head_6414.py(not yet written; fails on base: after an enhance the list has no derived row; the Used mark followscurrent_page_image; the choice changes what the next step reads), the existingtest_image_edit_chains.py,test_workflow_renditions.pyandtest_current_image_6296.py.prep.enhance-default-scope-is-this-image— [GAP] (#6436; DECIDED by the owner 2026-11-08 15:45) Enhance’s DEFAULT scope is THIS IMAGE: the Enhance verb in the Edit pane runs on the page in view with no question; the selection and the folder are ONE menu choice away (the verb’s menu: This Image, the Selection (N pages), This Folder (N pages)), the choice remembered per window for the session and the title saying the scope it will run on; the one action and the selection-scoped start are those ofprep.enhance-lives-in-the-edit-pane-and-runs-on-the-selection, this bullet only fixes the default and the menu. Acceptance: Enhance with one page in view enhances that page alone; the menu’s Selection choice runs on the selected pages and the title reads “Enhance 12 Pages”. Test:EnhanceDefaultScopeTests.swift(not yet written; the default, the menu’s three choices, the title),test_enhance_scope_is_the_selection_6436.pynamed on Step 1.6.prep.enhance-lives-in-the-edit-pane-and-runs-on-the-selection— [GAP] (#6436; owner 2026-11-08: image enhancement shows its OWN toolbar, and cannot run on the CURRENT image, only on the folder. Code: the leaked bar isViews/Preview/SourcePaneImageControls.swift(Enhance →sourcePane.enhance, Clean up the folder) overModels/SourcePaneImageActions.swift([.enhance]for a page with no parent, else[.enhance, .cleanUpFolder]); the engine’simage.enhancealready takes ONE document (ImageEnhanceRequest(documentId:), audited, one undo,prep.enhance.clahe-ported)) Enhance lives ONLY in the Preview’s Edit pane (the Editing bar ofsource/segment-editor-crud.mdStep 1.7, beside crop, rotate and the other image tools;menus.toolbars-one-home-per-tool) and runs on a chosen SCOPE: this image (the page shown), the selection (N pages), or the folder, each through the ONEimage.enhanceaction over its items, a scope of several as one audited batch with one ⌘Z (the action’s existing single-document form repeated inside one audit set, as Group does,safety.undo.a-set-is-undone-whole), priced and previewed first for the folder as the Clean up sheet does today;SourcePaneImageControlsis removed and the Source pane’s bottom bar shows no tool; the scope is named on the button (“Enhance This Image”, “Enhance 4 Pages”, “Enhance the Folder…”) and in the run’s account. Acceptance: with a page shown and no selection, Enhance in the Edit pane enhances that page alone, one ⌘Z; with three pages selected it enhances the three as one undo; the folder way asks first as today; nothing called Enhance appears outside the Edit pane. Test:test_enhance_scope_is_the_selection_6436.py(not yet written; one page, N pages as one audit set, the folder),EnhanceInEditPaneTests.swift(not yet written; the button’s scope words; no Source-pane bar), the existingtest_image_edit_chains.py.prep.preview-draws-segments-on-the-selected-rendition— [GAP] (#6420; owner 2026-11-08: segments show only on the ORIGINAL rendition. Code: the engine already reads the page’s CURRENT image for every model-sending step (media/current_image.current_page_image: the edit chain, else the newest rendition with a known place on the photograph, else the original), keeps stored lines as fractions of the upright photograph and carries them onto the image read and back withframe_map(crop, quarter and any-angle turn, flip, homography), and servesframe_bboxwithread_from(wide.chain.served-by-the-engine, #6296); the APP maps boxes onto an edited image only in Compare (CompareViewModel.drawnBox); the Preview’s segment overlay and the Segments pane draw photograph-space boxes, so on another rendition they vanish or misalign (the overlay’s match-or-skip matrix,ZoomableImagePreviewMac+Renditions)) the Preview draws the page’s segments on WHICHEVER rendition is selected, mapped through the engine’sframe_bboxfor that rendition, with ONE mapping in ONE place:CompareViewModel.drawnBox’s rule (edited or rendition:frame_bboxat that image’s size;followedfalse: no box; elsebboxat the photograph’s) moved to a shared model both Compare and the overlay read, the overlay’s match-or-skip matrix replaced by it; the Segments pane’s line pictures are cut from the image the page’s working pass was read from, and the Preview’s selection, handles, marquees and nudge work on the mapped boxes so an edit made on a rendition lands in photograph fractions through the same map back. No new route: the image-chain answer already carriesframe_bbox,read_fromandfollowedper rendition. Acceptance: a page cropped and turned in the editor shows its lines on the cropped rendition exactly over the writing, and on the original over the same writing; selecting a line on either lights the same segment; reshaping a line on the rendition saves photograph fractions that draw correctly on the original. Test:PreviewBoxesOnRenditionTests.swift(written in part: the shared mapping, unfollowed maps nothing, select-all; not yet written: a reshape saved as photograph fractions; the shared mapping from a frame and a bbox for original, edited, a turned rendition and a frameless one, through the real Preview overlay model), the existingCompareViewTests.swiftandtest_current_image_6296.py. Built: 2026-11-18, in part: the Preview draws the page’s segments on a mapped rendition and they are selectable there (SegmentOnRendition.mappedGeometry, read by the overlay, selection and hit-test). Not built: editing on a rendition: every edit that writes a place drawn on screen (move, reshape, draw, combine, promote, marker, paintbrush, knife, move a cut) is refused with a notice (SegmentOnRendition.editRefusal) until the inverse map exists, so the acceptance line’s “reshaping a line on the rendition” is not met; outlines and baselines are not mapped.prep.engine-answers-segment-boxes-on-a-rendition— [PARTIAL] (#6420, engine half of Step 1.5; a note onprep.preview-draws-segments-on-the-selected-rendition, acceptance untouched; pinned byfichero-server/tests/unit/api/test_segments_on_a_rendition_6420.py)GET /api/segments/document/{doc_id}/on-rendition/{rendition_id}answers every live segment’s box in that rendition’s pixels, carried by the same frame map the compare view and the readers use (media/rendition_boxes.py), or no boxes and the reason where the rendition’s place on the photograph is not recorded (followedfalse). Built 2026-11-18: the Preview’s overlay reads it (SegmentService.segmentBoxes, throughSegmentOnRendition.mappedGeometry). Spec change: 2026-11-09, new bullet only.prep.rendition-without-a-frame-says-so— [GAP] (#6420) a rendition whose frame is NOT recorded (a flatten, a turn with no angle, a rendition made before frames were kept) is passed over by the readers (the engine reads the photograph instead, today only logged,PageImage.why) and the page SAYS so where the rendition is shown: under the Preview when that rendition is selected (“this rendition’s place on the page is not recorded: lines are drawn on the original, and readers read the original”) and on its row in Renditions and in the image chain (reads_thisfalse with itswhy), never a silent miss; the reading that was made records which image it read (data.image_read) and the Inspector’s Making section shows it. Acceptance: select a frameless rendition: no boxes, and the one sentence under the picture; its Renditions row carries the same words; the Inspector’s Making for a line read on an edited page names the edited image. Test:PreviewBoxesOnRenditionTests.swift(not yet written; the sentence fromfollowedandwhy), the existingtest_current_image_6296.py. Built: 2026-11-18, in part: when the engine answersfollowedfalse the Preview shows itsnote(loadRenditionBoxes) and draws no boxes. Not built: the sentence on the Renditions row and in the chain, anddata.image_read.prep.segment-mapping-is-one-model— [PARTIAL] (#6420, first slice of Step 1.5; pinned byfichero/Tests/Unit/general/Views/Preview/PreviewBoxesOnRenditionTests.swiftand the existingCompareViewTests.swift) the rule that maps a segment onto the picture shown (an edited picture or rendition:frame_bboxat that picture’s size;followedfalse: no box; elsebboxat the photograph’s) lives in one place,SegmentOnRendition, and Compare reads it; nothing about what Compare draws changed. Built 2026-11-18: the Preview’s overlay and selection read it. Not yet built: handles, marquees and nudge on a mapped rendition, the Segments pane’s pictures, the sentence for a frameless rendition under the picture, on the Renditions row and in the chain, and the engine confirmation test (Kraken line crops and the VLM crop cut from the image the step read,data.image_read).prep.select-all-on-a-rendition-selects-the-pages-segments— [PARTIAL] (#6448; owner bug; pinned byPreviewBoxesOnRenditionTests.selectAllOnARendition) Select All (⌘A over the Preview) selects the page’s segments whichever rendition is shown: whether the geometry’s frame is the picture’s decides what is drawn, never what is selected. The old rule read the frame-matched list, which is empty on a rendition, so nothing was selected. Seen only through the unit test of the pure rule (SegmentOnRendition.selectAllIndices); the selected segments are not drawn on a rendition until the overlay reads the one mapping.prep.legacy-reviewed-before-rewrite— [OK] (#5382) a written review compares the legacy tools and today’s on the test set before any rewrite (the notebook corpus prep review, 11 notebook photos, 2026-10-03; its page-split cases are pinned byfichero-server/tests/unit/media/test_page_split.py;agent-work/status/briefs/imgprep-review-2026-10-29.md, this rewrite).prep.enhance.clahe-ported— [PARTIAL] (#6190) isimage.enhance.contrast-clahe; the id is kept so the issue resolves. Built:image_ops.apply_clahe_contrastand thecontrastoperation withclip,tile,gain,lift,profile(a barefactorrow is unchanged). Also built: theyellowingandsharpensteps, and anenhancerow withmethod: claheruns contrast, yellowing, sharpen (test_enhance_with_method_clahe_runs_contrast_then_yellowing_then_sharpen_and_a_row_without_a_method_is_the_pil_enhance,test_a_saved_clahe_enhance_row_previews_through_the_route). Also built:POST /api/images/{id}/operations/enhancetakesmethod(pilorclahe) andprofile, and a clahe row stores both (test_the_enhance_route_takes_a_clahe_method_and_profile_and_a_plain_request_is_stored_as_before); the image editor’s Enhance popover has a “Local contrast (faded writing)” switch and a Handwritten/Typescript choice that send them (Swift, unrun). The enhance route also takesclip,tile,gainandlift(empty is the profile’s), stores those given on a clahe row, and the row renders with them (test_the_enhance_route_stores_clip_tile_gain_and_lift_and_the_row_renders_with_them); the Enhance popover’s Fine-tune switch shows four sliders for them (Swift, unrun). The reference-sample 3/255 check isfichero-server/src/fichero_server/media/image_prep_samples.py(run by hand, not collected by pytest), which reads the owner’s pages from the folder named byFICHERO_IMAGE_PREP_SAMPLESand prints each page’s mean difference against the 3/255 limit; it exits 0 when every page is under it, 1 when one is not, and 2 (naming what it needs) when the variable is unset or the folder has no pair; it has not been run on real pages.
Test matrix
Fixtures (tests/fixtures/image_prep/, to add; reduced to 1500 px on the long side): ten
notebook photographs with hand-drawn page boxes, gutter positions, blank flags and orientation;
two test pages reduced with a hand-drawn page box; one photo rotated 90 and one 180 by its content with
EXIF 1; one page photographed at about 15° with its four hand-marked corners; a synthetic text page bent
by a known quadratic toward one edge; a blank graph-paper page; checked transcriptions of the notebook text
pages for the CER comparison.
| Behaviour | Unit | Click-around | Notes |
|---|---|---|---|
prep.setup.three-questions-suggested-from-a-sample, prep.setup.what-runs-by-itself, prep.setup.step-runs-from-the-start-plan, prep.estimate.time-on-this-mac-before-start |
tests/unit/recipes/test_prepare_step_setup.py |
needed (PrepareImagesSetupUITests.swift) |
five sample pages → suggested answers; the plan holds the step; the time line names its basis. |
prep.find-the-page, prep.page.opencv-default-yolo-optional, prep.page.region-attribute-and-page-box |
tests/unit/media/test_find_page.py |
not needed | outline within 2 % of the hand-drawn box on test-page and a notebook photo; attribute and page_box written; YOLO card absent with no model. |
prep.page.detected-before-lines, prep.page.kraken-time-saved-is-reported |
tests/unit/recipes/test_find_regions_inside_page.py |
not needed | no line outside the region; the summary’s four numbers. |
prep.crop.content-bbox-is-fast, prep.page.remove-background-is-the-dark-mount-method |
tests/unit/media/test_image_ops_legacy_port.py |
not needed | under 0.5 s; an old remove_background chain re-renders unchanged. |
prep.split-at-the-gutter |
fichero-server/tests/unit/media/test_page_split.py |
not needed | the neighbour test added; 11 photos still pass. |
prep.square.perspective-from-the-quad, prep.square.corner-handles-correct-it |
tests/unit/media/test_square_page.py; ImageEditDirectToolsTests.swift |
needed | the 15° fixture squared within 0.5°; a rectangular quad writes nothing; a dragged corner re-squares with who: person. |
prep.flatten.curve-toward-the-gutter, prep.flatten.judged-by-the-gutter-third |
tests/unit/media/test_flatten_curve.py, tests/unit/recipes/test_prep_cards_bakeoff.py |
not needed | the bent synthetic page recovers straight baselines within 2 px; a straight page writes nothing; the gutter-third CER on the run. |
prep.turn-by-the-text, prep.straighten-and-flatten, prep.blank-pages-marked |
tests/unit/media/test_turn_straighten_blank.py |
not needed | the 90 and 180 fixtures turned; the angle on the row; the blank page marked and skipped by find regions and read. |
prep.blank-pages-hidden-in-the-item-view |
tests/unit/api/test_blank_pages_hidden.py; BlankPagesHiddenTests.swift |
needed | the blank row is hidden, revealed dimmed under “N hidden”, unhidden with one click and queued. |
prep.unsure-becomes-a-proposal, prep.check.worklist-of-proposals-and-a-sample, prep.check.correction-replaces-the-runs-row, prep.check.blank-mark-is-a-correction |
tests/unit/recipes/test_prepare_check_worklist.py |
PrepareImagesCheckListTests.swift; PrepareImagesSetupUITests.testThePagesToCheckLineOpensTheWorklist (unrun) |
the proposal stored and listed; a correction replaces the row and leaves the worklist. |
prep.check.apply-correction-to-the-folder |
tests/unit/api/test_image_batch_prepare.py; ImageBatchPrepareTests.swift |
needed (the sheet is not driven by a UI test yet) | three previews write no row; batch id on every row; whole and per-page undo. |
prep.train.offered-after-thirty-corrections, prep.train.runs-locally-or-on-hugging-face, prep.train.adopted-only-on-held-out-overlap, prep.yolo.page-detector, prep.licence.agpl-stated-on-the-card |
tests/unit/training/test_yolo_page_detector.py |
not needed | 29 corrections: no offer; 30: offered with a time; the local and Hugging Face places offered only when allowed; the trained card adopted only when its IoU is higher; the sheet’s words. |
prep.methods-are-cards-the-recipe-chooses, prep.judged-by-reading |
tests/unit/recipes/test_prep_cards_bakeoff.py |
not needed | the card per step and folder; CER with and without an operation. |
prep.prepared-image-attached-as-rendition |
tests/unit/workflows/test_prepare_images_rendition_recipe.py |
needed | the prepared image is a rendition the viewer can switch to. |
prep.derived-image-records-its-recipe |
tests/unit/workflows/test_prepare_images_rendition_recipe.py |
not needed | the rendition names the step, its settings, the card and the run or batch id; Revert removes it alone. |
Build order
Stage 1 — The page is found and kept
Step 1.1 — Find the page without a model; the attribute and the page box (#6188, #6198)
- Behaviours:
prep.page.opencv-default-yolo-optional,prep.page.region-attribute-and-page-box,prep.find-the-page,prep.crop.content-bbox-is-fast,prep.page.remove-background-is-the-dark-mount-method - Tests: fichero-server/tests/unit/media/test_find_page.py, fichero-server/tests/unit/media/test_image_ops_legacy_port.py
- Size: M
Step 1.2 — Lines only inside the page (#6189)
- Behaviours:
prep.page.detected-before-lines,prep.page.kraken-time-saved-is-reported - Tests: fichero-server/tests/unit/recipes/test_find_regions_inside_page.py
- Depends on: 1.1
- Size: S
Step 1.3 — The prepared image is a rendition (#5386)
- Behaviours:
prep.prepared-image-attached-as-rendition,prep.enhance.clahe-ported - Tests: fichero-server/tests/unit/workflows/test_prepare_images_rendition_recipe.py
- Depends on: 1.1
- Size: S
Step 1.4 — The Renditions list shows the edit chain’s head and its order, marks the image readers will use, and lets the person change it (#6414, DECIDED 2026-11-08)
- Behaviours:
prep.renditions-list-the-edit-chain-head,prep.renditions-mark-the-image-readers-use - Tests: fichero-server/tests/unit/workflows/test_image_edit_chains.py, fichero-server/tests/unit/workflows/test_workflow_renditions.py, test_renditions_list_the_chain_head_6414.py (not yet written)
- Depends on: 1.3
- Size: S
Engine: the renditions listing adds the chain head as a derived entry (name from the last operation, time and actor from the audit rows) and the chain’s operations in order, with no write; the Used mark from current_page_image; the page’s one chosen-image field through the existing audited document update, read before the default rule (check which existing document action carries page fields; none is added). Swift: the Inspector’s Images section for the page, the row menu, ⌥-click in the Preview’s Renditions menu. For lane-ie after #6412.
- test (to write):
test_renditions_list_the_chain_head_6414.pyin fichero-server/tests/unit/workflows/ (an enhanced page lists the derived row and its operations; its name, time and actor; the Used mark; choosing another image changes what the next step reads; undo removes the row; the renditions table unchanged)
Step 1.5 — Segments drawn on the selected rendition through one mapping; a frameless rendition says so (#6420)
- Behaviours:
prep.preview-draws-segments-on-the-selected-rendition,prep.rendition-without-a-frame-says-so - Tests: fichero/Tests/Unit/general/Models/CompareViewTests.swift, fichero-server/tests/unit/media/test_current_image_6296.py, PreviewBoxesOnRenditionTests.swift (written in part, see
prep.preview-draws-segments-on-the-selected-rendition) - Depends on: 1.4
- Size: M
For lane-ie after #6419. Engine none beyond what GET /api/pages/{id}/image-chain and the segment answers already carry (frame_bbox, read_from, followed, why); confirm, with a test, that Kraken line crops and the VLM crop are cut from the image the step read and that data.image_read is recorded. Swift: the one mapping moved out of CompareViewModel.drawnBox into a shared model; the Preview overlay, the handles, marquees and nudge, and the Segments pane’s pictures read it; the overlay’s match-or-skip matrix goes; the sentence for a frameless rendition under the picture, on the Renditions row and in the chain.
- test (to write):
PreviewBoxesOnRenditionTests.swiftin fichero/Tests/Unit/general/Views/Preview/ (the mapping per rendition kind; a reshape on a rendition saved as photograph fractions; the frameless sentence; Compare and the overlay give the same box)
Step 1.6 — Enhance lives in the Edit pane only and runs on this image, the selection or the folder through the one action (#6436)
- Behaviours:
prep.enhance-lives-in-the-edit-pane-and-runs-on-the-selection,prep.enhance-default-scope-is-this-image - Tests: fichero-server/tests/unit/workflows/test_image_edit_chains.py, test_enhance_scope_is_the_selection_6436.py (not yet written), EnhanceInEditPaneTests.swift (not yet written)
- Depends on: 1.4
- Size: S
Engine: image.enhance as today for one page; N pages as one audit set undone whole (no new action). Swift: the Enhance tool on the Editing bar with its scope words; SourcePaneImageControls and SourcePaneImageActions removed; the folder way keeps the Clean up sheet. With ui/menus-and-commands.md Step 2.4.
- test (to write):
test_enhance_scope_is_the_selection_6436.pyin fichero-server/tests/unit/workflows/ (one page; three pages one undo; the folder preview first) - test (to write):
EnhanceInEditPaneTests.swiftin fichero/Tests/Unit/general/Views/Preview/ (scope words from the selection; the Source pane shows no bar)
Stage 2 — Square, flatten, split, turn, straighten, blanks
Step 2.1 — Square the page from the quad (#5382)
- Behaviours:
prep.square.perspective-from-the-quad,prep.square.corner-handles-correct-it - Tests: fichero-server/tests/unit/media/test_square_page.py, fichero/Tests/Unit/general/Views/Preview/ImageEditDirectToolsTests.swift
- Depends on: 1.1
- Size: M
Step 2.2 — Flatten the curve toward the gutter (#5382)
- Behaviours:
prep.flatten.curve-toward-the-gutter,prep.flatten.judged-by-the-gutter-third - Tests: fichero-server/tests/unit/media/test_flatten_curve.py, fichero-server/tests/unit/recipes/test_prep_cards_bakeoff.py
- Depends on: 2.1
- Size: M
Step 2.3 — The gutter’s neighbour test; turn by the text; the angle on the row (#5382, #6190)
- Behaviours:
prep.split-at-the-gutter,prep.turn-by-the-text,prep.straighten-and-flatten,prep.image.one-upright-frame - Tests: fichero-server/tests/unit/media/test_page_split.py, fichero-server/tests/unit/media/test_turn_straighten_blank.py
- Depends on: 2.1
- Size: M
Step 2.4 — Blank pages: marked, skipped, hidden, unhidden (#5382, #1791)
- Behaviours:
prep.blank-pages-marked,prep.blank-pages-hidden-in-the-item-view,prep.check.blank-mark-is-a-correction - Tests: fichero-server/tests/unit/media/test_turn_straighten_blank.py, fichero-server/tests/unit/api/test_blank_pages_hidden.py, fichero/Tests/Unit/general/Views/Preview/BlankPagesHiddenTests.swift
- Depends on: 2.3
- Size: M
Stage 3 — The Set Up step runs
Step 3.1 — Three questions from a sample; what runs by itself; the plan holds the step; the time (#5580)
- Behaviours:
prep.setup.three-questions-suggested-from-a-sample,prep.setup.what-runs-by-itself,prep.setup.step-runs-from-the-start-plan,prep.estimate.time-on-this-mac-before-start,prep.setup.how-it-works-is-the-engines-sentence - Tests: fichero-server/tests/unit/recipes/test_prepare_step_setup.py, fichero/Tests/UI/general/PrepareImagesSetupUITests.swift
- Depends on: 2.4
- Size: M
Step 3.2 — Proposals, the worklist, corrections (#5382)
- Behaviours:
prep.unsure-becomes-a-proposal,prep.check.worklist-of-proposals-and-a-sample,prep.check.correction-replaces-the-runs-row - Tests: fichero-server/tests/unit/recipes/test_prepare_check_worklist.py, fichero/Tests/Unit/general/Models/PrepareImagesCheckListTests.swift, fichero/Tests/UI/general/Shell/PrepareImagesSetupUITests.swift
- Depends on: 3.1
- Size: M
Step 3.3 — A correction applied to the folder (#6192)
- Behaviours:
prep.check.apply-correction-to-the-folder - Tests: fichero-server/tests/unit/api/test_image_batch_prepare.py, fichero/Tests/Unit/general/Views/Preview/ImageBatchPrepareTests.swift
- Depends on: 3.2
- Size: M
Stage 4 — Cards, training, evidence
Step 4.1 — The page detector trained from corrections, locally or on Hugging Face, adopted on evidence (#5525, #5382)
- Behaviours:
prep.train.offered-after-thirty-corrections,prep.train.runs-locally-or-on-hugging-face,prep.train.adopted-only-on-held-out-overlap,prep.yolo.page-detector,prep.licence.agpl-stated-on-the-card - Tests: fichero-server/tests/unit/training/test_yolo_page_detector.py
- Depends on: 3.2
- Size: M
Step 4.2 — Cards per step and folder; judged by reading (#4951, #5382)
- Behaviours:
prep.methods-are-cards-the-recipe-chooses,prep.judged-by-reading,prep.suppress-ruling - Tests: fichero-server/tests/unit/recipes/test_prep_cards_bakeoff.py
- Depends on: 4.1
- Size: M
Step 4.3 — Find Regions: one implementation, and the Start plan’s default (#5962, #5668)
- Behaviours:
prep.regions.one-implementation,prep.regions.open-default,prep.regions.one-find-regions - Tests: fichero-server/tests/unit/workflows/test_detect_regions_one_path_5962.py, fichero-server/tests/unit/recipes/test_model_chooser_per_step_5668.py
- Depends on: 4.1
- Size: S
Step 4.4 — The YOLO region cards: trained, offered, quiet (#5525)
- Behaviours:
prep.yolo.regions-card,prep.yolo.fine-tune-from-corrected-regions,prep.yolo.quiet-in-the-sandbox,prep.yolo-detectors-run-and-train - Tests: fichero-server/tests/unit/recipes/test_yolo_regions_card.py, fichero-server/tests/unit/training/test_yolo_regions_training.py
- Depends on: 4.3
- Size: M
Rulings
- 2026-10-04 (design lead): train in PyTorch, run in Core AI when the conversion exists; built so far is PyTorch on the GPU (
llm/yolo_runtime.py). Ruling suppression only where the bake-off shows it helps. - 2026-10-09 (owner): Ultralytics YOLO is in, AGPL-3.0 as Fichero is.
- 2026-10-20 (owner): one Find Regions implementation.
- 2026-10-26 (owner): two steps, prep (pixels, renditions) and Leave Out (decisions); order prep → find regions and lines → leave out → read; the legacy methods and parameters come over, not the old app’s shape.
- 2026-10-29 (owner, paraphrased): image preparation is a Set Up step that runs by itself with sensible defaults per collection and a check-and-correct flow; it crops to the page, leaves out the ruler, colour card and dark border, straightens, splits at the gutter and enhances into renditions; the detector may be classical, YOLO or trained from the person’s corrections; good manual tools stand beside it.
- 2026-10-29, second round (owner, paraphrased; closes every open question of the morning draft):
- Perspective correction is in, now, in two forms: a lopsided photograph squared from Vision’s quad or the contour polygon, and a bound page whose lines curve into the gutter flattened. Both are renditions; the original is never touched (
prep.square.*,prep.flatten.*). - Blank pages are imported, kept, dimmed and skipped by later steps; they are hidden in the item view and a person can unhide one (
prep.blank-pages-marked,prep.blank-pages-hidden-in-the-item-view). - Training the page finder is offered after 30 corrections, runs locally, on Hugging Face or on a cluster through Slurm (ACENET) through the existing training places, and is adopted only when it beats the classical finder on held-out pages (
prep.train.*). The same places serve the Kraken segmenter trained from corrected lines; no separate mechanism (../compute/training-and-evaluation.md). - Checking for missed lines is asked per project in Set Up with a suggested default, runs wherever a model can run, and must catch words dropped inside a line, not only marginalia (
segments-and-geometry.md,source.segment.check-lines.*). - The full OpenCV suite comes over from the legacy tools, as automatic steps and as editor options with sliders and before/after (
image-enhancement.md). - Show-through is one setting from the sample, per region only when the sample is uneven (
image.enhance.bleed-through-suppression). - Suggested answers come from a five-page sample with a 3-of-5 rule (
prep.setup.three-questions-suggested-from-a-sample).
Open questions
None. The four questions of the morning draft (perspective, blanks, the training threshold, the sample size) were ruled on 2026-10-29 and are written above as decided.
Future (ideas, not scheduled)
- (#4368) Native Apple image ops (book-spread split, border cleanup, bg removal) replacing OpenCV paths.
- A learned dewarp (DocTr, UVDoc) as a card beside the baseline-field flatten, if the bake-off shows the classical field is not enough on real bound volumes.