Import Pipeline
UnauditedEsta página aún no está disponible en tu idioma.
The import pipeline runs entirely client-side in capsule-library::import, over the pure grouping, scope and upload-policy half in capsule-core::import. No server is contacted until bytes are handed to the upload protocol (Upload). Every import is deterministic, idempotent and resumable by import id. The planner is pure, so most of the pipeline is testable without I/O.
Pipeline Stages
Section titled “Pipeline Stages”Initiate
Section titled “Initiate”Manually, when the user picks files or directories (flat or DCIM-style), or automatically, when a platform watches directories for new media.
Scan & Extract
Section titled “Scan & Extract”Files are walked and their metadata (Metadata) extracted, and an unsupported format is rejected here, before confirmation.
- Motion photos. A still carrying an embedded clip (the
MotionPhoto/MicroVideoXMP container, or a trailing video after the image’s end marker) is imported byte-exact as one original. Its clip is also extracted, as a second asset whose bytes are a pure slice of the original, and the two are stacked as a Live Photo (Asset Organization — Stack Types). Detection comes from Rawshift throughcapsule-core::media. - Edited copies. An edited file the platform links to its original, or a
-edited/_editedsibling with the same capture time, is stacked over the original (Asset Organization — Stack Types). The server independently enforces a closedcontent_typeset at session creation, and received bytes are decoded only in the sandboxed decoder (Clients — Sandboxed Decoder).
Plan & Confirm
Section titled “Plan & Confirm”The pure planner turns scanned files into an ImportPlan (added, skipped, conflicts, total size, import id), shown to the user for confirmation.
- An asset already in the local library is refused.
- An asset that exists remotely under different ciphertext is admitted and resolves as a merge (Upload — Deduplication and Merge).
- Destination. Each added asset gets a container album (Asset Organization — Container Albums): the user’s pick, else
resolve_default_album(scope override, then the default-album pointer; see Asset Organization — The Default Album). The context and pointer snapshot are planner inputs, so the resolvedalbum_idis recorded in the plan and a later re-point does not retarget a confirmed plan. - Free-space probe. Outside the pure planner, the client compares
total_sizewithcapsule-library::library::available_bytesand setsstreaming_recommendedwhen the import is near or over free space.
Execute
Section titled “Execute”For each planned file, in the order given by Upload Prioritization:
- move it into its library location;
- encrypt under the destination album’s key and sign the manifest (Signed Manifests and Provenance — Asset Manifest), the signed path in
capsule-library::lifecycle::Workspace; - generate derivatives (Thumbnails and Previews);
- hand each blob of the bundle to its own upload session.
Steps 1–3 parallelize across files. Execution is cancellable at file boundaries, and re-running re-derives the plan and skips completed work.
Import-Upload Streaming Mode
Section titled “Import-Upload Streaming Mode”For a storage-constrained device, streaming mode (capsule-library::import::streaming) bounds peak disk to one in-flight asset instead of the whole import. When the plan is streaming_recommended and the user confirms, the executor runs a sliding window:
- import the next file onto the signed path, deferring source release;
- upload its bundle;
- pass the release gate (Durability — Verify Before Destroy);
- only then release the local original and delete any Move-mode source;
- advance.
- The plan MUST have headroom for its largest single asset; otherwise confirmation fails with a “free Y to import X” error.
- On lost connectivity or exhausted quota (Quota — Enforcement Points) the window pauses, admitting no new source files, and in-flight uploads resume from the server’s committed set. No original is released for an asset that did not upload.
- Streaming is a large reconciliation under the synchronization criteria (Sync — Synchronization Criteria), and is mutually exclusive with a staged upload policy (Upload — Upload Tiering (Staged Uploads)).
Third-Party Importers
Section titled “Third-Party Importers”An importer is a source adapter (capsule-library::import::importers) on the filesystem scanner’s contract: it yields entries into Scan & Extract and adds no stage and no server surface. It folds out-of-band exporter metadata into extraction under one precedence rule: embedded EXIF wins, except for what the exporter is authoritative for (album membership, favourites, user-typed descriptions). Because the fold happens at extraction, an archive yields the same plan on every run.
Google Takeout is implemented; iCloud Photos and Immich are planned post-v1. Camera import (Import — Camera Import) uses the same seam. Fixed Takeout mappings:
| Exporter field | Written as | Why |
|---|---|---|
| Favourite | rating = 5 |
Capsule has no favourite; writing a cull pick would fabricate a review decision (Asset Organization — Culling). |
| Album membership | tags_user entries |
An import may not invent container albums (Asset Organization — The Default Album); tags are searchable and rebuildable as smart albums. |
| Exporter GPS fix | GpsSource::Manual |
Exif would be false inside a signed record. |
| Over-long description | truncated on a char boundary, with a warning | Truncation loses less than dropping. |
At the write site, capture time is the file’s EXIF instant, else the adapter’s folded value, else the import clock. It is never the raw exporter value, which would beat a floating EXIF time the precedence rule says should win.
Upload Prioritization
Section titled “Upload Prioritization”The pipeline decides which assets to start: recently modified files first, then shallower directory depth, with file size secondary. File type is not a criterion, and sidecars (.xmp, paired audio) travel with their parent. How started uploads stream is the upload protocol’s concern (Upload — Adaptive Chunk Sizing).
Contracts the Pipeline Exposes
Section titled “Contracts the Pipeline Exposes”ImportPlan— the planner’s deterministic output, each added entry carrying itsalbum_id;streaming_recommendedis attached at confirmation.available_bytes()— library-volume free space.execute(plan, cancel_token)— honours cancellation at every file boundary and returns per-file status; in streaming mode it drives the import → upload → verify → release window.- A progress event stream (queued / processing / encrypting / uploading / done / failed),
capsule-library::import::progress. The typed per-stage events and the diagnostics snapshot built on it are owned by Performance — Typed Stage Events and the Diagnostics Snapshot.