fieldlens-desktop/PRINT_CAPTURE_ARCHITECTURE.md
Admin 3e17e1b55b
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled
fix(windows): forward captures through installed printer queue
2026-09-26 06:15:54 +00:00

70 lines
3.5 KiB
Markdown

# FieldLens Print Capture Architecture
## Target architecture
### Linux
```text
original document
-> FieldLens Print CUPS queue
-> FieldLens CUPS pre-filter
-> /var/lib/fieldlens-print/capture
-> FieldLens watcher / decode / sync
-> normal CUPS rendering
-> physical printer
```
The production Linux path does not depend on the RAW 9100 proxy. The CUPS pre-filter is authoritative for original-document capture.
The no-paper self-test uses the same CUPS pre-filter, then sends the rendered output to a local discard sink on 127.0.0.1:9101. Self-test success means the exact submitted document was observed by the FieldLens watcher, not merely accepted by CUPS.
### Windows
Target:
```text
original spool/document
-> FieldLens native capture backend
-> FieldLens capture / decode / sync
-> normal Windows print pipeline
-> physical printer
```
The current localhost:9100 capture listener remains a compatibility capture backend until the native Windows backend is complete. Forwarding from that listener should use the selected installed Windows printer queue through the Winspool RAW API by default, so USB, WSD, shared/local, and network printers work without requiring a destination TCP/9100 endpoint.
## Windows compatibility priority
1. Default forwarding to the selected installed Windows queue through Winspool (OpenPrinter / StartDocPrinter / WritePrinter) instead of connecting directly to the printer's TCP/9100 endpoint.
2. Validate USB, WSD, shared/local, IPP/class-driver, and network queues using the same-driver FieldLens virtual queue.
3. Keep direct RAW/TCP only as an advanced fallback.
4. Add Windows end-to-end capture/forward self-test and queue health diagnostics.
## Windows native backend implementation track
1. Build on the modern Windows Print Support Virtual Printer / Software Printer architecture rather than introducing a new legacy v3/v4 driver.
2. Spike the supported Windows spool interception options:
- custom port monitor,
- print processor,
- virtual printer / print support backend.
2. Prefer the least-privileged option that can capture the spool/document before final device rendering while returning the job to the normal Windows print pipeline.
3. Package and register the native component from the FieldLens installer with repair/remove support.
4. Preserve the existing FieldLens capture event contract so OCR/barcode, history, sync, and UI do not care which platform backend produced the job.
5. Support USB, WSD, locally installed, and network printers without requiring destination TCP/9100.
6. Add health checks that verify the native backend is installed, loadable, and attached to the FieldLens queue.
7. Add an end-to-end self-test that proves a submitted document creates a FieldLens capture event and reaches the downstream Windows print pipeline.
8. Remove the localhost:9100 compatibility backend after native backend rollout and migration are verified.
## Health invariants
FieldLens must not report Ready unless the active platform capture backend is actually operational.
Linux Ready requires:
- FieldLens Print queue present, enabled, and accepting jobs;
- FieldLens Test Capture queue present, enabled, and accepting jobs;
- installed FieldLens CUPS filter present and Python-syntax-valid;
- production capture watcher running.
Linux self-test passes only when the exact submitted test document creates a matching `cups-test` capture event.
Windows Ready will eventually require the equivalent native-backend registration/load/queue checks, rather than only queue existence.