Getting Started: a Document Desk

A Document desk reads scanned invoices, receipts, contracts and identity cards into tables on your computer, and asks a cloud model about a field it cannot read, sending that field's crop. Redaction and approval are one uncommented line each in .adk/vision.toml. This page builds one from the vision template and walks through what each part does.

Note: adk-vision is Experimental (spec 3.7). The desk runs PP-OCRv6 and RF-DETR on ONNX Runtime, which vision-local downloads at build time.

1. Scaffold the Desk

cargo install cargo-adk
cargo adk new claims-desk --template vision
cd claims-desk
cp .env.example .env        # ANTHROPIC_API_KEY for the cloud model

The project depends on adk-rust alone:

[dependencies]
adk-rust = { version = "3.0.0", default-features = false, features = ["minimal", "harness", "vision-local", "artifacts", "cli", "anthropic"] }
FeatureWhat it brings
vision (implied by vision-local)adk_rust::vision: regions, manifests and the fetcher, the egress gate, the cloud describers, the image privacy guardrail; with harness, the vision pack
vision-localThe on-device backends: PP-OCRv6, PaddleOCR-VL-1.6, RF-DETR, EfficientSAM, SAM 2.1 and SigLIP 2
harness, cliThe governed harness agent, and the terminal prompter that asks you when a rule holds an image
FileHolds
src/main.rsThe model, the harness with the vision pack, and the loop over inbox/
src/desk.rsThe on-device models, the vision pack and the harness over an artifact store
.adk/vision.tomlWhat leaves the machine: everything as written, with each restriction commented
tests/desk_smoke.rsA cloud describe that leaves under the desk's rules, and one held for a person and refused under a rule that asks

2. Run It

cp ~/scans/*.png inbox/
cargo run

The first run fetches PP-OCRv6 tiny (6 MB) and RF-DETR Nano (108 MB) by revision into the Hugging Face cache and checks every file's SHA-256 before ONNX Runtime loads it. Set HF_HUB_CACHE to keep the cache elsewhere, and HF_HUB_OFFLINE=1 once it is warm: the fetcher then opens no socket.

For each page the agent calls vision_read, which runs PP-OCRv6 on your computer, and writes one row per page to tables/<kind>.csv. Nothing about these calls leaves the machine.

3. What Runs Where

StepBackendWhere
Read a pagepp-ocrv6-tiny (PpOcrReader)This computer
Describe a region the reader could not readThe cloud model (LlmDescriber::remote), at the hosts its client namesThe provider, through the egress gate
Find people to cover, when the rules list facesrf-detr-n (RfDetr) behind PersonRedactor, or yunet-2023mar (YuNet) for faces behind FaceRedactorThis computer
Find personal text to cover, when the rules list personal_textPP-OCRv6 and the PII patterns behind PersonalTextRedactorThis computer

desk::pack wires them into the vision pack:

VisionPack::new(MediaStore::new(artifacts), move |gate, store| {
    VisionRuntime::builder()
        .reader(reader)                 // on the device
        .remote_describer(describer)    // only released images
        .shared_egress_gate(gate)
        .media_store(store)
        .build()
})
.redactor(Arc::new(PersonRedactor::new(people)))
.redactor(Arc::new(PersonalTextRedactor::new(reader).with_labelled_fields(["Name"])))

A remote backend takes only a ReleasedImage, which only the egress gate constructs, so the describer cannot be handed a page the gate has not cropped and recorded.

4. What Leaves

.adk/vision.toml holds the rules. As generated, a crop for the cloud model leaves as it is; each restriction is commented, and uncommenting it opts in:

[egress]
default = "allow"
redact = ["faces", "personal_text"]

[[egress.rule]]
provider = "anthropic"
classes = ["document"]
action = "deny"

[[egress.rule]]
provider = "anthropic"
classes = ["document_crop"]
action = "ask"
LineEffect once uncommented
redactFaces (the face, or a detected person's whole box when no face is found; spec 3.7 Q3) and personal text are filled solid before any decision; a listed class with no redactor refuses the release
document → denyA whole page never leaves
document_crop → askA field's crop waits for you: the terminal shows the host, the data class, what was covered and the image's digest, and only that exact image is released
on_device = trueNo image leaves at all

A rule names a host, or a provider for every host that provider's client uses. The harness applies the workspace's file as written; an operator who wants a workspace allow to ask instead calls VisionPack::distrust_workspace_rules. ReadOnly and Plan modes send nothing off the machine whatever the rules say. See Governed Vision Tools and Restricting What Leaves the Machine.

5. Check What Left

Every release and refusal is an egress record: source and egress digests, destination, data class, redactions by class and the decision. With the CLI installed with vision, the project's log is one command away:

cargo install adk-cli --features vision-local
adk-rust vision egress log

The adk-rust vision CLI also lists and fetches models, records licence acceptance and runs one perception call on an image.

6. Test It

cargo test

tests/desk_smoke.rs plays the agent and the provider with a scripted model: the agent asks to describe an identity card. Under the desk's rules the crop reaches the provider without asking; under a rule that asks, the call is held for a person, the person says no, and the provider receives nothing. It needs no key and no model download.

The Scenarios Behind It

examples/vision (package vision-scenarios) runs spec 3.7's scenarios S1–S13. S1–S8, the Document desk, run on forty generated pages with invented data: PP-OCRv6 and RF-DETR on the device, NVIDIA NIM, Claude, Gemini and Meta sam-3.1 on recorded responses through their real clients. S9–S13 — the Inspector on a conveyor stream, visual wakes, frame budgets, the live camera surface and native video — are in The vision scenarios.

cargo run --manifest-path examples/vision/Cargo.toml
cargo run --manifest-path examples/vision/Cargo.toml -- s3_redact_before_it_leaves
ScenarioWhat passes
S1 Document desk, local firstForty pages read on the device into one table per kind; each value carries page, region and backend; pages whose blocks all clear the threshold send nothing
S2 Escalate the crop, not the pageExactly five crops leave, one per hard field, each its block plus margin
S3 Redact before it leavesThe bytes the provider received hold no face and none of the card's personal strings
S4 Approve with the imageThe held call carries the exact egress image; approval releases that digest; a swapped image is held again
S5 One region, four framesClaude, Gemini, sam-3.1 and RF-DETR answers for twelve targets land within 2 px
S6 Weights you can trustOffline fetch opens no socket; a tampered file is refused; a restricted model waits for acceptance
S7 A budget per imageA run capped at 20 images makes 20 sam-3.1 calls of 30; the rest are refused before any request; the run's spend is read whole while the ledger's clock crosses midnight UTC
S8 Same tool, any backendOne tool call shape across PP-OCRv6, PaddleOCR-VL-1.6 and NIM, and RF-DETR and sam-3.1