# PDF Restoration Studio — FLUX Prompt Memo

This memo records the prompts used by the page-first Beta 6 workflow. The app
sends the complete rendered page plus up to three automatically selected
original detail crops in one FLUX request. The source-aligned candidate is shown
beside the original by default; the raw full-page FLUX result is available for
inspection only. OCR is read from the actual FLUX result. For a source-aligned
export candidate, the app extracts detected illustrations from that same
full-page result, checks them against the original, then places qualifying
images onto the original page while retaining source text. No additional model
request is made for each region. A retry instruction is appended only for an
explicit retry. Versioned user instructions and the complete prompt are saved
with every attempt. The prompt builder is in `server/server.js`; keep this memo
synchronized with it.

## Isolated figure prompts

Default for restoring one selected service-manual illustration. The initial
application preset is `Gold Standard`.

### Gold Standard

> Re-render the single provided source image as a clean, realistic, full-color service-manual illustration. Use this image as the only visual reference and the sole authority for the depicted scene. Preserve the exact crop and composition: keep every object, part, hand, tool, surface, hole, screw, line, connection, position, orientation, proportion, and figure number exactly as shown. Preserve visible marks and lettering verbatim; do not invent, clarify, rewrite, or add text, labels, numbers, or branding. Restore the illustration in clearly visible, natural full color: dark blue-gray outboard metal where supported by the source, natural hand tones, silver hardware, realistic rubber and plastic, balanced neutral lighting, and crisp but natural detail. Keep the page text, callouts, and surrounding paper outside this crop unchanged. Do not add, remove, substitute, move, connect, reshape, or simplify anything. Do not infer obscured details. Do not create a page, caption, border, or background. If a detail is unclear, keep it as it appears in the source. Output only the restored crop.

### Photograph

> Conservatively restore the single provided service-manual photograph as a realistic full-color image. Use the source image as the only visual reference and authority. Preserve the same objects, people, tools, parts, hand positions, connections, crop, composition, orientation, proportions, and visible markings. Correct faded color and improve natural tonal clarity only. Do not invent, remove, substitute, move, reshape, or simplify anything. Do not add text, labels, numbers, branding, borders, or a page background. If a detail is unclear, retain its source appearance. Output only the restored crop.

### Diagram / Schematic

> Carefully enhance the single provided technical diagram using the source as the only authority. Preserve every line, wire, dashed segment, arrow, symbol, terminal, label, number, connection, crossing, position, orientation, and proportion exactly as shown. Do not invent, remove, connect, disconnect, redraw, interpret, or clarify any geometry or text. Use only restrained color and contrast improvements where the source itself supports them. If any mark is uncertain, leave it unchanged. Output only the same isolated crop. This candidate requires direct source comparison before approval.

### Text + Illustration

> Restore the single provided service-manual figure crop as a clean, realistic, full-color illustration. Preserve every depicted object and all visible printed text, labels, numbers, arrows, lines, and callouts exactly in the same positions. Use the source as the sole authority; do not invent or correct content. Add restrained natural color and improve tonal clarity only. Do not change the crop, composition, orientation, proportions, connections, or technical details. Do not create a page, caption, border, or background. Output only the restored crop.

## Full-page proof prompts

These page-level prompts are applied to a complete rendered PDF page. The actual
request combines the shared page constraints, two newline characters, and the
selected preset prompt. These candidates and searchable PDFs remain review-only
and cannot become pages in the Gold Standard master.

When page analysis identifies illustrations, up to three original source crops
are attached as `input_image_1` through `input_image_3`, ordered by their source
position after prioritizing larger, higher-confidence regions and photographs.
The full page remains `input_image_0`. This runtime suffix is appended to the
selected prompt; the app fills in each region ID, type, and normalized bounds.
The exact expanded wording and reference list are stored in the attempt and
shown under **Show the exact prompt used**:

> SOURCE DETAIL REFERENCES
> Input image 0 is the complete source page. The following input images are close crops from that same original page, in this order:
> input_image_N: source region REGION_ID (TYPE), normalized page bounds X0, Y0, X1, Y1.
> Use each close crop only to retain detail in its matching existing illustration on input image 0. Keep the full-page layout, location, crop boundaries, and every technical relationship from input image 0. Do not repeat a close-up as a new figure or replace any page text with invented lettering.

## Shared constraints

This exact shared instruction applies to every full-page model request:

> The complete source page is the authority for layout and technical meaning; attached detail crops are closer views of existing source illustrations. Preserve the page orientation, boundaries, layout, every existing figure, and the position, shape, orientation, and relationship of its parts. Restore pictorial service images and realistic mechanical illustrations to clearly visible natural full color, not monochrome or a faint blue tint. Use only source-supported material colors: dark blue-gray outboard metal, silver hardware, natural hand tones, believable rubber and plastic, and balanced neutral light. Keep source arrows, labels, and callouts legible. For wiring schematics, pinouts, timing marks, dimensions, and geometry-critical line diagrams, preserve the exact source line structure and colors; do not add color coding or alter geometry. Never invent or infer obscured details. Do not redraw or rewrite page text; the application preserves original text separately and uses only checked illustration regions in the final page. Keep color inside existing illustrations, not on paper or text.

## Source-aligned export composition

The selected page preset and this shared instruction are sent with up to three source-detail references in one request. The reference suffix is filled with the actual region IDs, types, and normalized page bounds for each attempt:

> SOURCE DETAIL REFERENCES
> Input image 0 is the complete source page. The following input images are close crops from that same original page, in this order:
> input_image_N: source region REGION_ID (TYPE), normalized page bounds X0, Y0, X1, Y1.
> Use each close crop to redraw its matching existing service photograph or pictorial mechanical illustration as clearly visible, realistic full-color technical art with source-supported material colors. Preserve every part, hand, tool, hose, hole, shape, orientation, connection, figure boundary, arrow, and callout exactly as shown. If a crop is geometry-critical line art, such as wiring, dimensions, timing marks, or a pinout, keep every source line and connection exact and add no color coding. Keep the full-page layout and figure positions from input image 0; do not repeat close-ups as new figures. Do not redraw page text; the application retains original text and uses only checked illustration regions in the final page. Never invent obscured details or spill color onto paper or text.

The exact expanded prompt and reference list are stored with the attempt and shown under **Show the exact prompt used**. The raw full-page result is review-only; source text stays from the original page, and checked illustration regions are composed over that source page. A failed color, text, or geometry gate prevents the page from entering the master.

## Preset 1 — Gold Standard

Default for general service-manual pages.

> Restore this complete service-manual page to a clean, professionally published appearance using the source as the sole authority. Reproduce the same page orientation, margins, reading order, figure locations, captions, and page number. Make the paper clean and neutral, improve contrast, and render existing pictorial service illustrations and photographs as clearly visible, realistic full-color technical art: source-supported dark blue-gray metal, natural hands, silver hardware, believable rubber and plastic, neutral light, and crisp natural detail. Preserve each part, hole, tool, connection, figure boundary, and arrow in its exact source position and proportion. Keep wiring schematics, timing marks, dimensions, and other geometry-critical line drawings source-faithful with no invented color coding. Do not redraw or rewrite text; original page text is retained separately. Do not add, remove, connect, reshape, crop, or rearrange content, and do not create captions, branding, or background details. Return one full-page image for source-aligned illustration extraction.

## Preset 2 — Full-color technical photograph

Default for pages dominated by photographs of motors, tools, hands, or repairs.

> Restore the complete manual page while preserving the source layout, printed page boundaries, figure locations, and caption positions. Give each existing service photograph and pictorial mechanical illustration a clearly visible, realistic full-color technical-illustration treatment: natural metal and rubber, believable dark blue-gray outboard components where supported, restrained natural hand tones, neutral light, silver hardware, and crisp mechanical edges. Keep every component, fastener, hand position, tool, hose, connection, hole, and figure boundary in its source position and exact proportion. Preserve wiring, schematic, timing, and dimension line art exactly; do not invent color coding or change connections. Do not redraw page text or captions; original text is retained separately. Do not invent unseen components, crop the page, alter its layout, or create decorative backgrounds. Return one complete full-page image for source-aligned illustration extraction.

## Preset 3 — Mixed text, photographs and diagrams

Default for pages that mix text, photographs, and diagrams, including lubrication-style pages.

> Restore this mixed-content manual page using the source as the sole authority for layout and technical meaning. Clean the paper, then render existing photographs and pictorial service illustrations, including mechanical scenes with hands or tools, as clearly visible realistic full-color artwork with source-supported metal, skin, rubber, and plastic materials. Keep each illustration in its original boundary and position. For wiring diagrams, dimensions, timing marks, pinouts, and other geometry-critical line art, retain every source line and connection exactly and add no color coding. Keep labels, arrows, figure numbers, and callouts readable and in place. Do not redraw or rewrite page text; original wording is retained separately. Do not merge or omit figures, move captions, guess unclear labels, invent parts, or crop page content. Return one complete full-page image for source-aligned illustration extraction.

## Preset 4 — Strict line-art / electrical schematic

Default for wiring diagrams, measurements, timing, pinouts, and dense line art. Review-only unless geometry checks pass.

> Restore the whole source page with the highest possible fidelity to the existing technical line art. Remove scanner noise and uneven paper tone conservatively; make already visible strokes and printed marks clear without altering their connectivity. Keep every line segment, junction dot, crossing, open gap, dashed segment, terminal, connector outline, pin, arrow, polarity mark, component symbol, dimension, wire color label, page number and note in exactly its source position. Preserve every legible character, sign and numeral verbatim. Never straighten a wire by changing its path, join lines that appear separated, close open shapes, replace a symbol, complete a faint circuit, infer missing labels, invent dimensions or introduce color coding not established in the source. Keep the full source page, including all borders and callouts belonging to it; do not crop or reinterpret the schematic. Return a conservative full-page cleaning candidate, not a redesigned circuit. If any feature is uncertain, leave it faithful to the scan rather than guessing.

## Preset 5 — Severe fading / old paper

Default for yellowed or gray scans, faint print, stains, and modest bleed-through.

> Restore this degraded source page as a clean, well-preserved printing of the same manual page. Neutralize paper discoloration, uneven light, stains, and scanner shadows. Improve visible illustration and photographic detail without thickening or erasing source lines. Render existing pictorial service illustrations and photographs in clear, natural full color using only source-supported material colors; keep geometry-critical diagrams, dimensions, timing marks, and wiring source-faithful. Preserve the complete composition, orientation, figure locations, page number, and all source marks. Do not redraw or rewrite page text; original wording is retained separately. If detail has disappeared, retain the uncertainty: do not generate replacement words, part numbers, tools, faces, connections, or circuit paths. Avoid aggressive sharpening, posterization, generic AI textures, decorative backgrounds, or cropping. Return a full-page image for source-aligned illustration extraction.

## Optional text-parity retry suffix

This string is appended after two newlines only for an explicit text-parity
retry. It is not sent on the ordinary first request.

> TEXT-PARITY RETRY: the first generated result did not preserve all text detected in the source. Regenerate the complete page from the original reference. Preserve every word, number, label, abbreviation, unit, punctuation mark, and line break exactly as printed, in the same location. Do not redraw text from memory or substitute similar-looking characters. Keep all other page content and geometry unchanged.

## Selection and review

1. Classify each selected page and choose one initial preset: general, photo,
   mixed, strict line art, or severe fading.
2. One user action queues one initial full-page request. Persist the model,
   preset and complete prompt, source and candidate hashes, settings, timing,
   and dimensions.
3. Compare source and result visually, check page layout and region occupancy,
   and compare source OCR with OCR from the actual FLUX image. Apply stricter
   label and line-art review for technical pages.
4. Keep generated pages as candidates until source comparison and human review
   pass. A failed candidate may be retried with another preset from Advanced;
   preserve all attempts and do not run all presets automatically.
5. Correct text from independently verified source text. For geometry-critical
   figures that FLUX changes, retain the source-faithful figure and require
   review rather than accepting invented geometry.

## Recorded live prompt — page 20, attempt 3

This is the exact prompt displayed by the live app for the explicit retry on PDF page 20 (printed page 1-14, “Lubrication Recommendations”). It combines the shared page constraints, the Gold Standard full-page prompt, and the text-parity retry suffix. The result remains `NEEDS_REVIEW`: page shape passed, color and illustration geometry failed, and 34 of 35 source OCR lines differed. The prompt is preserved here for reproducibility; the candidate was not approved.

```text
These instructions apply to the entire displayed PDF page. The supplied source page is the sole visual authority. Preserve its original page aspect ratio, orientation, boundaries, overall layout, figure count, captions, arrows, leaders, small marks, and page number. Do not add figures or infer obscured parts. FLUX output is an image, not reliable editable text; lettering and geometry will be checked separately against the source. If the provider cannot preserve source geometry at the requested size, the application will retain source-aligned content for review rather than stretch, crop, or omit it.

Restore this complete service-manual page to a clean, professionally published appearance. The supplied page is the sole authority. Reproduce the same page orientation, boundaries, margins, column widths, reading order, figure locations, captions, page number, and all visible text in exactly the same positions. Make the paper clean and neutral, improve contrast and legibility, and render existing technical illustrations with precise, natural detail. Preserve every visible letter, number, decimal point, unit, symbol, arrow, leader, connection, part, hole, tool, and figure reference exactly as shown; never invent missing words or mechanical features. Retain the source proportions and the whole page, without cropping or rearranging content. Do not create a new manual design, add captions or branding, replace diagrams with generic art, or insert new background details. Return one faithful full-page restoration candidate only.

TEXT-PARITY RETRY: the first generated result did not preserve all text detected in the source. Regenerate the complete page from the original reference. Preserve every word, number, label, abbreviation, unit, punctuation mark, and line break exactly as printed, in the same location. Do not redraw text from memory or substitute similar-looking characters. Keep all other page content and geometry unchanged.
```
