Business · Product · Technology · AI

An iOS document cache needs identity, status and reconciliation—not just a filename

A Movo-X portable-core case covering facility/person/document keys, issued-status sidecars, reconciliation, presentation names and explicit platform-test limits.

Work directly with Omer Muneer Qazi · Reviewed 29 November 2026

The scenario: two documents share a date or title

A household application can display documents for several people and facilities. Two records may have the same title or issue date while representing different documents. If the cache uses that display text as identity, an otherwise successful download can overwrite or retrieve the wrong local file. The cache key needs to carry the scope of the document it represents.

The reviewed Movo-X portable cache uses facility, patient and document identifiers for its document key. Nine existing cache tests were run on Linux using synthetic temporary files; all passed. This chapter follows those local storage properties and selected app integration source, without treating the result as iOS device or server-authorization acceptance.

Use stable record identity for the underlying file

The document key constructs its path from the three record identifiers. The corresponding test stores different synthetic bytes for two documents belonging to one person and another document belonging to a second person. Each lookup returns its own bytes rather than colliding on a common date or label.

This is a precise local isolation property. It does not mean that knowing those identifiers authorizes a download; the server must still evaluate the request. It also does not add an account identifier to the document key. Account changes therefore require the appropriate lifecycle cleanup rather than assuming a key with facility and person scope independently solves every account-switch condition.

Keep the presentation filename separate from cache identity

The inspected cache can present a document using a sanitized server filename while retaining the identifier-based underlying PDF location. It creates a named hard link where supported, with a write fallback for file systems that cannot create the link. A name that fails sanitization falls back to the identifier filename.

The portable test checks the presented filename, the unchanged underlying identity and the synthetic bytes. It also checks traversal-style input and removal of the named presentation directory when the document becomes void. That gives the user a readable export name without making the export name the authority for which document the cache retrieves.

A file on disk is not enough to serve a cached document

The implementation writes a status sidecar with the fetched document. A normal cache lookup requires both an existing file and a sidecar whose value is issued. A missing sidecar, unknown status or non-issued status does not qualify for ordinary cached retrieval.

A test explicitly writes a non-issued document for immediate presentation and then checks that it cannot be retrieved through the normal cache method. The distinction matters: refusing cached reuse does not mean the bytes were never written. Teams reviewing local retention should inspect both temporary presentation requirements and subsequent deletion, rather than equating a nil lookup with an empty filesystem.

Reconcile against the loaded list in the selected scope

The reviewed reconciliation method examines the selected facility and person directory. It retains a copy only when the supplied current list still contains that document as issued and its cached status agrees. Unlisted or changed-status documents are removed with their related local entries. The test verifies that another person’s directory is unaffected.

The inspected app model forwards a loaded document list with its person and facility context to this method. Acceptance must still establish that the caller supplies the intended authoritative list and handles partial loading correctly. The cache cannot infer whether a missing item was intentionally withdrawn or merely absent from an incomplete input; list completeness is part of the integration contract.

Reconciliation is not a real-time revocation channel

The sidecar records the status seen when the copy was stored. A local lookup does not contact the server to prove that status remains current. Reconciliation needs a later authoritative list, and expiration cleanup is a separate method that must be invoked. A disconnected device does not acquire new revocation knowledge merely because its local file has a status label.

That boundary should shape the product’s offline policy. Decide which documents may be reused, when refresh is required and how an unavailable network is explained. The portable tests establish selected local decisions after explicit calls; they do not prove instant removal on every device when a server record changes.

Separate portable filesystem tests from iOS protection

The source chooses a cache-directory root, applies backup-exclusion settings on Darwin and requests complete file protection for iOS writes. It also exposes facility removal, complete removal and age-based cleanup. The Linux tests exercise selected removal and expiry outcomes with temporary files.

The platform branches are important: the non-Darwin backup-check helper returns true without checking a Darwin filesystem flag, and Linux writes do not execute the iOS protection option. A passing Linux assertion therefore cannot validate those protections. Device acceptance should inspect the actual platform attributes, locked-device behaviour and app lifecycle paths, including how failures to remove files are handled.

A useful cache acceptance handover

Deliver the identity key, display-name rule, stored-status policy, authoritative-list contract and lifecycle cleanup map. Include the collision, status-less copy, voided document, other-person scope and filename tests. Mark iOS protection and real UI transitions as separate evidence rather than burying them in a portable test total.

For a CTO, the result is a cache whose responsibilities can be explained. Record identity selects bytes, a presentation name improves readability, local status gates reuse and reconciliation reacts to new server knowledge. Those are related controls with different timing and authority. Keeping them distinct makes both the implementation and its remaining acceptance work easier to review.

Illustrative control flow

Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.

key = facility_id + person_id + document_id
store(bytes, identity=key, fetched_status=status)

if file_exists(key) and cached_status(key) == issued:
    offer_cached_copy_under_offline_policy()

on_authoritative_list_loaded(scope, documents):
    remove_unlisted_or_nonissued_copies(scope, documents)
# Local status does not establish current server status.

About this engineering series

Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.

Explore the Movo-X engineering series → · Related implementation experience →

Discuss a similar engineering problem

Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.

Discuss your project on WhatsApp ↗
WhatsApp Omer about this project ↗