Business · Product · Technology · AI

Reconcile Android document caches with current known status

A Movo-X Android case tracing account/facility/person/document cache identity, JSON status variants, PDF sidecars, network-first reconciliation and separate viewer-copy lifecycle.

Work directly with Omer Muneer Qazi · Reviewed 29 November 2026

The scenario: cached content and current document status can differ

A device can retain issued content and later learn that the document is void. It can also be offline when the user opens the document. A cache needs to distinguish the stored representation, its scoped identity and the latest status the client actually knows. Those facts should not collapse into one generic cached success.

Fourteen existing Android JVM cases passed for selected Movo-X cache/file and JSON-store behaviour. The fixtures use software keys, host files and injected fetch results. Native screen and lifecycle connections were inspected separately. No real clinical document was rendered and no current server authorization was exercised.

Use stable scoped identifiers instead of a date or title

The selected key includes account, facility, patient, document and a JSON status variant. Existing cases check its path, distinguish selected people/documents/facilities/accounts/statuses and reject path traversal, date-like document input and a malformed status. These are selected namespace and input-shape contracts.

The identifiers are UUID-shaped key components, not proof of authority. A valid key cannot establish that the signed-in account may read the corresponding record. Current server access, changed clinic relationships and cache clearing on account transition need separate acceptance. Keep namespace isolation connected to those lifecycle decisions rather than treating a correctly formed path as an authorization result.

Keep JSON status variants distinct from the single PDF representation

The selected JSON writer removes other status variants before storing a new one. An existing case replaces issued bytes with void bytes and checks the preferred result and remaining root file. The PDF fixture instead uses one PDF path per document regardless of status and retains a separate server-filename sidecar.

These are different representation policies. The PDF path itself does not determine whether the document is void; the surrounding list/status logic supplies that meaning. The selected PDF fixture writes a tiny byte stub, reads a host file and checks removal of the encrypted cache entries. It is not a PDF validity, page-layout or renderer acceptance test.

Refetch online and use fetched status when available

The selected JSON-store cases check that an injected successful fetch is invoked even when older cached content exists. A fetched void response is stored under its selected status, replaces the earlier issued variant and marks the displayed result void, including when the supplied list was stale.

These outcomes use a synthetic status extractor and fetch callback. They do not decode a real medical-document body or contact a service. Actual request identity, response scope, record status and authorization still need current integration acceptance. A local network-first decision is useful without establishing that every real fetched document is complete or correctly issued.

Show offline bytes with the latest known void meaning

An existing offline case retains issued cached bytes but supplies a latest-known void list status. The result is marked from cache and void. Another case checks that an offline failure without a cached representation propagates rather than creating a success. The inspected merge rule gives a known void status precedence.

Latest known is the important limit. An offline client cannot establish an unseen server transition or newly revoked access from an old copy alone. Accept the wording and interaction for offline documents explicitly, including reconnect and changed access. The selected cases do not certify clinical validity or permission to reuse a cached document in another workflow.

Refuse selected authoritative errors rather than falling back

The selected refusal case injects forbidden and not-found HTTP responses and checks that the matching cached document entries are removed and the error propagates. The inspected source also names a gone-response branch, which was not separately executed by that case. It distinguishes these HTTP refusals from selected transport failures used for offline fallback.

Do not generalize the fixture into every possible session or access error. The caller’s current service contract and session lifecycle decide what a response means. Verify actual refusal mapping, cleanup failures and later recovery with controlled records. A fake HTTP response supports the selected cache policy, not a completed production permission audit.

Keep scoped root cleanup separate from viewer copies

The selected filesystem cases clear a facility across selected accounts, retain another facility and clear all entries. Their root file enumeration makes those cache outcomes inspectable. The inspected implementation separately creates decrypted PDF viewer files outside that encrypted root and has its own viewer-copy clearing method.

The source connects clearing to selected startup, screen-disposal and full-clear paths. Those native lifecycle hooks were not executed here. A root-only empty-file assertion is not proof that every viewer or exported copy disappeared. Accept viewer use, background/disposal, sign-out and failed deletion independently before making a broader residue or retention claim.

Accept PDF fetch, sidecar pairing and interruption separately

The inspected PDF-store method handles a fetched PDF, a JSON compatibility result and selected offline/read errors. The fourteen selected cases do not execute all of that fetch integration. They also do not simulate interruption between writing PDF bytes and the filename sidecar, which are separate operations in source.

Add controlled disk/rename failures, interrupted sidecar writes, missing metadata and concurrent readers before claiming transactional pairing or crash-safe publication. The inspected app selects a no-backup directory, but actual backup exclusion and file-provider behaviour require device acceptance. File location, encryption, availability and current document meaning are separate responsibilities.

A native document-cache handover

Retain the fourteen scoped cases with exact identities, byte/status observations and injected error outcomes. Add current service refusal tests, native lifecycle acceptance, viewer/export review and interrupted-write recovery. Verify the PDF and JSON paths with generated complete documents and their own visual acceptance.

For a CTO, the model is clear: identity selects a cache entry, fresh content can change known status, selected transport failures permit an offline representation and authoritative refusals follow a different policy. The selected host fixtures establish useful parts of that model while current access, device retention and clinical-document acceptance remain independently verifiable.

Compare the reviewed boundaries

Document identity, known state and retained bytes are separate

On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.

BoundarySelected evidenceSeparate acceptance
Scoped keySelected account/facility/person/document/status fixturesCurrent authorization and native account transitions
Known statusInjected online/offline void and miss casesUnseen server changes and rendered wording
Refusal cleanupSynthetic forbidden/not-found outcomesCurrent error contract and deletion failures
PDF/view lifecycleHost file/sidecar cases and inspected sourceRenderer, interruption, viewer copies and actual backups

Illustrative control flow

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

key = scoped_document_identity(account, facility, person, document, status)
try: content = fetch_current_representation_and_reconcile_known_status(key)
except selected_transport_failure: use_cached_bytes_with_latest_known_status(key)
except authoritative_refusal: remove_selected_cache_entries_and_propagate()
# Viewer copies, current access and complete PDF acceptance are separate boundaries.

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 ↗