Skip to content

0005: A document import default with per-source ownership ​

Status: implemented, 2026-11-12. Second phase of #40, stacked on document packages (#41).

UI follow-up (#108): Book → Copy Assets into Book controls future imports for this book. Checked means copy; unchecked means link. The default is copy when project.importMode is absent. The earlier development-only app preference is intentionally retired rather than inherited by unrelated books; existing linked sources keep their ownership. Individual imports can still override the book policy through the API. Book → Assets… opens an independent, book-bound window with combinable filters, conditional attention badges, and contextual actions. It retries unavailable originals on open/focus. File → Duplicate uses a native Include all files sheet, with a short full-path note for linked copies.

Decision ​

Copy versus link is a document-level default, not a strict document mode. Book → Copy Assets into Book chooses copy (checked, the default) or link (unchecked). The default applies to photos, Markdown, parameter-file pickers, folder imports, and drag/drop. Existing sources retain their actual ownership when the default changes, and individual imports may override it. A document can mix copied and linked sources. Imports of resources already inside the package remain document-owned rather than linking a document to itself.

Import… and file parameter pickers inherit the book default; programmatic imports may pass an explicit mode. Template code, its fonts, and bundled template assets stay document-owned; linking applies to registered source files, including everything selected through parameter file pickers. File parameters retain their existing UTF-8 text contract and 20 MB limit.

Persisted locations and identity ​

project.json.importMode is the optional future-import default (copy when absent). Photo IDs remain in photos.json: a copied photo has a relative path, while a linked photo has an absolute path and linked: true. Markdown and parameter registries retain their IDs, with either a relative string for a copied file or { path, linked: true } for an external file. Locations do not become IDs. Relinking, replacing, collection, and Save a Copy preserve IDs, metadata, assignments, and normalized crops.

Linked paths identify exported files, not a Lightroom catalogue. A package manifest is not permission to read external files. App-owned approvals, stored outside documents and keyed by filesystem book identity (device, inode and birth time), bind each source ID to its exact canonical target. Native import and Locate selections grant access on this Mac. Parameter-file grants also record the declaring picker’s accepted extensions and reject mismatches before reading. Loading, revision hashing, opening text in an editor, collection and Save a Copy all enforce that gate. Unapproved references show “Locate to approve access” and expose no cached or original contents. A Finder duplicate, downloaded book or restored package with a new identity needs its own approval; an explicit Save a Copy transfers only already approved links. Earlier cached previews never grant access.

Atomic replacement at that path updates the same source. The first implementation uses canonical absolute locators and explicit Locate actions for moves; it does not search arbitrary directories or follow filename-only guesses. A Locate Folder action considers byte-identical candidates with the saved filename and digest. Ambiguous candidates are reported for explicit per-source Locate rather than silently selected.

Stable inputs and availability ​

The shared source store reads only approved regular linked files and checks the original identity before/after reading. The editor reads photos where they are, linked or document-owned: opening reads metadata without decoding, hashing or duplicating any original, so linking a folder that Lightroom re-exports into costs nothing per open. Rendition keys name the original's path and stamp (inode, size and times), and rendition generation guards that identity, so a photo re-exported in place gets new renditions and changed bytes cannot enter an old rendition key; the book reloads when a linked original changes. A linked photo's digest, which Locate Folder uses to find a moved original, is reused while its stamp is unchanged and otherwise computed in the background after opening. Markdown and parameter files, whose contents are loaded into render data, are still hashed into immutable content-addressed snapshots (APFS clones when possible). Exports clone/copy every photo, linked or owned, into private job folders, so one export reads one consistent set of bytes, and remove those snapshots when the job settles. Checks read photos in place like the editor: their inputs, photo stamps included, are captured before and compared after rendering, so a photo changed during a check rejects its result. The 50 MB import/linked-photo limit does not make larger originals already inside a package unreadable.

Revised 2026-11-20 (beta.15 finding F-037): checks pinned every photo as well, and since each check has a new private folder, every check copied, hashed and decoded all photos again: about 8 s per check for 163 linked photos, before the first page rendered.

Revised 2026-11-19 (#211): linked photos were snapshotted for the editor too. That made every re-export, and every photo evicted from the 2 GB cache, cost a copy, a hash and a decode at the next open (2.2 s for a 163-photo, 2.8 GB book), for a guarantee only jobs need.

The app-owned source cache also retains last-good content and metadata across reopen. Missing, denied, and unreadable states always come from the original location. Cached content never makes an unavailable original available. Derived cache corruption is checked and repaired from an available original; a fallback snapshot is verified against its digest before use. Missing photos, linked or owned, fall back to already rendered previews/thumbnails, preserving their known dimensions and an explicit unavailable state. These caches live outside .imageflow documents and are not needed to open a collected book with available originals.

One shared store per book serializes index publication, including scan probes and source actions, so concurrent users cannot overwrite each other’s records. Cleanup runs at launch, document close, periodically while idle, and quit. It removes unreferenced snapshots, stale book indexes and abandoned staging files, and evicts closed-book snapshots to a 2 GB budget. Open frames/jobs remain pinned and can temporarily exceed that budget. The most recent book indexes are retained for offline-drive recovery; evicting a last-good snapshot leaves an honest unavailable state rather than an implied original.

Each document watches selected external files' parent directories, so an atomic replacement does not strand an inode watch. Metadata reconciliation and watch reinstallation cover missed events, disconnected locations, resume, and files changed while closed. Short writes are coalesced; invalid content retains a marked last-good view. Unavailable sources are retried without repeatedly rebuilding the editor. A refresh pending behind a save or export is separate from actual source-change invalidation.

Checks reconcile source revisions around loading/rendering. Exports capture current inputs, load pinned contents, and recheck before publishing a PDF. A replacement during export rejects the result. External content changes do not rewrite files or enter ordinary layout Undo. Undo preserves each registered source's current location, so it cannot revive an obsolete relink or replace an external file.

Recovery, collection and saving ​

Manage Sources lists photos, Markdown and parameter files with actual storage, location, availability, and cached-view status. It offers Reveal, Locate/Replace Original, Retry, Copy into Book, folder relinking, and Include All Assets. A missing source does not prevent the rest of a book from opening or being edited. Relinking an ID repairs every use. ImageFlow never overwrites or deletes a linked original.

Include All Assets on the current book validates every registered original, prepares owned copies, and publishes the manifest changes through the recoverable save path. Failure leaves the original registries intact; required recovery data and staged referenced assets survive an interrupted committed save. Successfully collecting also sets future imports to Copy.

File → Save a Copy… includes an Include all assets checkbox, checked by default, before the destination picker. Checked produces an independent package with copied photos, Markdown and parameter files, and a Copy import default. Unchecked preserves the current mix and document default. Linked locators include full paths, which can disclose account names and folder layout when shared; the dialog explains this and that another Mac must locate/approve the links. Preparation takes place beside the destination, copies each owned asset once and each collected linked snapshot once, then publishes the package without an additional full-book copy or internal-disk staging. The original document and linked originals remain untouched. A missing original blocks collection with a list of sources to locate, rather than a falsely portable result. Normal autosave preserves existing ownership and links. Source actions are recorded as non-undoable updates; Locate, Replace, Copy into Book and collection do not consume an empty Undo step.

Only unavailable sources used by the active layouts or assigned file parameters block print. Missing unused library sources remain diagnostic warnings. Proof export requires explicit confirmation to use cached content/placeholders, retains Book check errors, and marks affected PDF pages with PROOF: ORIGINAL UNAVAILABLE. The cached view never satisfies an original-file requirement for print or collection. The confirmation and page markings share the same source-diagnostic codes; unrelated template messages containing “missing” do not trigger a source warning.

Revised 2026-11-24 (#308): on a Mac that a book reached through sync, a missing original is the normal state, so the editor sums up originals that are elsewhere in one line instead of reporting each as an error and a warning (SourceStatus.away, src/away-originals.ts). It is decided from what this Mac already knows: the placeholder path a pull writes (unlocatedPath), the provider's own answer, and this Mac's sync record; an unapproved path is still never read. Print, proof and check_book are unchanged in substance: every render still reports each box (source-unavailable).

Validation ​

Unit coverage exercises the shared import default, per-import exceptions, linked Markdown and file inputs, atomic replacement, original dimensions/crops, immutable pinned bytes, missing-source reopen, identity-preserving relinking across Undo, ambiguous folder candidates, collection, and portable Save a Copy. The desktop source workflow exercises all three source kinds, a deterministic replacement during PDF rendering, missing/cached views, print blocking, proof confirmation/marking, and opening a collected copy after external originals are removed. Existing document/session, authoring, editing, layout, parameter-file, and PDF workflows remain regression checks.