> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leverine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture Vault — End-to-End Specification

> Capture Vault — a Quest app that moves headset captures to your own destinations, with every copy verified before anything is deleted.

# Capture Vault — End-to-End Specification

**Product:** Capture Vault (`com.leverine.capturevault`) — a Leverine product **Document status:** Living specification, v1.0 — 2026-12-03 **Code basis:** v0.3.0+3 (Chunks 1–3 built and pushed to `Leverine/Capture-Vault`) **Grounding documents:** product plan 2026-12-02 (§9 decisions settled), roadmap 2026-12-03 (incl. the no-accounts amendment), Quest platform homework 2026-12-03, Quest filesystem survey 2026-12-03, company analytics plan 2026-12-03, and the build journals in this `docs/` folder (`journal-chunk1.md`, `journal-chunk1-fix.md`, `journal-chunk2.md`, `journal-chunk3.md`).

**How to read this document.** “MUST / MUST NOT” are requirements. “SHOULD” is a strong default that needs a recorded reason to deviate. Statements about on-device behaviour are labelled **\[proven]** (observed on Kev’s Quest 2), **\[documented]** (Meta/Android documentation or the platform homework), or **\[unproven]** (believed, designed-for, but not yet observed on hardware). Nothing in this spec may be quoted in store copy in a stronger form than its label here.

***

## 1. Product definition

### 1.1 What it is

Capture Vault is a paid 2D panel app for the Meta Horizon Store that gets screenshots and screen recordings off a Quest headset — organised by game, transferred to a destination the user chooses — with **every copy hash-verified before the app will offer to delete the original**.

### 1.2 The promise (normative wording)

> Open Capture Vault and everything new since your last visit offloads automatically — every copy verified — to your phone, PC, or NAS. No account, no cloud, no Developer Mode.

Every clause of that sentence is a requirement:

* **“Open … offloads”** — the trigger is opening (or resuming) the app. On-open is the automation model; see §1.4 for what is *not* promised.
* **“everything new since your last visit”** — newness is defined by the persisted scan watermark (§3.5). The app MUST badge and offload exactly the captures newer than the watermark, and MUST say plainly on first run that everything present is new (there is no “last visit” yet).
* **“every copy verified”** — a copy counts as done only when its SHA-256 equals the original’s SHA-256 (§3.4). Size alone is never verification.
* **“No account, no cloud, no Developer Mode”** — the app MUST NOT require, offer, or upsell an account; MUST NOT route captures through any Leverine server (there is none in the design); MUST install and run as a normal Store app on a stock headset.

### 1.3 Target users and devices

* **Users:** Quest owners who screenshot or record and then fight Meta’s built-in sync to get the files anywhere useful. Meta’s own help documents sync failing when the headset sleeps, disconnects, or opens another app, and videos over a minute are never auto-synced.

* **Devices (v1, one product):** Quest 2, Quest 3, Quest 3S, Quest Pro. Capture storage is identical on all four **\[documented]**:

  | | All four models |
  | - | - |
  | Screenshots | `/sdcard/Oculus/Screenshots` (JPG) |
  | Recordings | `/sdcard/Oculus/VideoShots` (MP4, H.264/HEVC) |
  | Filename pattern | `<package>-<YYYYMMDD>-<HHMMSS>[-n]` |

* **Quest 2 / Pro are a closing window:** Horizon OS v2.13 is their final feature release and new-app submissions for them close **December 2027**. The v1 build MUST remain v2.13-compatible for those models (§5.2); later Quest 3-only features MUST be device-targeted so the frozen branch keeps working.

* **Per-model capture defaults** (resolution/fps/bitrate) could not be verified from a primary Meta source. The app MUST read actual file metadata (dimensions, duration, size) and MUST NOT hard-code expectations per model.

* Pairing for the browser receiver (§5.1) differs by model: QR code on Quest 3/3S; **6-digit code / typed address on Quest 2/Pro**, which have no colour passthrough cameras to scan with.

### 1.4 What v1 is NOT (never promised — in the listing, in the app, anywhere)

* No background offload while playing a game, while the headset is asleep or off, or instant on-capture sync. Horizon OS suspends 2D panel apps; even Meta’s own sync cannot do these. **\[documented]**
* No guaranteed overnight or set-time scheduled sync. A WorkManager periodic check MAY run when Horizon OS chooses; if present it MUST be labelled best-effort in the UI and MUST NOT be sold as scheduled sync.
* No Google Drive in v1 (fast-follow, §5.3). No iPhone camera-roll auto-save (iOS delivers a ZIP to Files — a platform limit).
* No recovery of captures Meta’s sync lost, of files already deleted, and no “fixing” Meta sync.
* No Quest 2/Pro parity with post-v2.13 Horizon OS features.

### 1.5 Commercial terms (settled, §9 of the plan)

* **Price: \$7.99 one-time** (Kev, 2026-12-02). Meta handles tax/VAT and takes its standard platform fee. No subscription. No IAP paywall for destinations in v1. Lifetime updates at that price.
* Ships under **Leverine**: repo, signing key, website product page, and `support@leverine.com` as the contact.
* **Name: “Capture Vault”** (Kev, 2026-12-02) — clearance screen verdict **RISKY but usable** (`chunk0/name-clearance.md` in the project records): no Horizon Store collision and no blocking registration found, but a live identical-name iOS screenshot app exists in the same Nice Class 9. Mitigations are mandatory: distinctive icon and listing subtitle, and **no branding spend until the manual CIPO/NUANS check is done** (§9, D-1). Screened-CLEAR fallback: **CaptureCrate**. The working name lives in exactly two places in code (`kAppName` in `lib/branding.dart` and the manifest `android:label`) so a rename stays a two-line change.

***

## 2. Current state — Chunks 1–3 as built

Everything in this section is built, unit-tested, and pushed. Device verification status is stated per item; §8.4 lists everything still owed on hardware. Current build: **0.3.0+3**, 97/97 tests passing, `flutter analyze` clean, zero third-party packages (Dart and Kotlin sides alike).

### 2.1 Chunk 1 — panel shell (commit `608a3d9`)

* Flutter 2D panel app: Home / Destinations / Gallery / Settings over a tested state layer; dark Material 3; layout is a function of panel width (side `NavigationRail` ≥ 640 dp, bottom `NavigationBar` below) because Horizon OS panels resize freely.
* `applicationId` / namespace `com.leverine.capturevault`; minSdk 29 / targetSdk 34; arm64-v8a only; release signed with the Leverine keystore (signer SHA-256 `5bc0623a…cd9210`, verified against the keystore, not the certificate DN — the keystore carries a debug-looking DN by accident of generation; the fingerprint is the identity).
* **Zero declared permissions.** Permissions arrive with the features that justify them (VRC Security.2, minimum permissions).
* The verified-delete setting exists in the state layer from day one, **default OFF**, with a unit test pinning the default — the rule cannot drift.
* Sideload verdict on Kev’s Quest 2 (Horizon OS v210, Android 14, 106 GB free): **positive** **\[proven]** — after the fix in §2.2.

### 2.2 Chunk 1 fix — the launch crash (commit `324b37c`)

The first on-device launch crashed instantly: `ClassNotFoundException: com.leverine.capturevault.MainActivity`. Root cause: `MainActivity.kt` sat in package `com.leverine.capture_vault` (underscore — the Dart package name) while namespace/applicationId are `com.leverine.capturevault`; this template’s release build **does** run R8, which stripped the real class as unreferenced. The shipped dex contained no MainActivity in any package — the crash was guaranteed on every device, and Chunk 1’s verification (build success, size, signing, install) could not see it, because **install success does not imply a launchable activity**.

Fix: file moved to `kotlin/com/leverine/capturevault/MainActivity.kt`, package aligned across file path, package, namespace, applicationId, and manifest. This defect is the origin of the standing verification rule in §8.1: **no build is “done” without a dex check for the MainActivity class, an on-device launch, and an exit-info check.**

### 2.3 Chunk 2 — capture scan + organise-by-game gallery (commit `9581976`, gitignore fix `642d101`)

* **Scan via MediaStore**, the sanctioned route under scoped storage: a Kotlin `MethodChannel` queries the Images collection filtered to `Oculus/Screenshots` and the Video collection filtered to `Oculus/VideoShots` (`RELATIVE_PATH LIKE`), newest first. Raw-path reads of those folders are closed at targetSdk 34 and MUST NOT be built on.
* **Exactly two permissions** — the app’s first: `READ_MEDIA_IMAGES` + `READ_MEDIA_VIDEO`, requested at runtime from the Gallery behind a rationale state, never at startup (startup only *checks*). Android 14 selected-photos grants (`READ_MEDIA_VISUAL_USER_SELECTED`) count as image access; MediaStore then returns only the selected subset — a partial grant MUST produce a partial-but-honest gallery, not an empty one or a crash.
* **Organise-by-game:** filenames parse in pure Dart (`<package>-<YYYYMMDD>-<HHMMSS>[-n]`; packages never contain hyphens, so the first hyphen is a reliable separator). Package → installed-app label resolves through PackageManager, falling back to the raw package name, and to an **Unknown** bucket for names that don’t follow the convention. Groups sort by newest capture; group headers show count + total size; image tiles show thumbnails, video tiles a frame + duration/size badges. The filename timestamp, when it parses, is the timestamp of record; MediaStore’s is the fallback. Metadata is always read from the file.
* **New-since-last-visit watermark** (§3.5), persisted via the channel into Kotlin SharedPreferences. First run: everything is new and the UI says so (“First visit — every capture here is new”). An empty scan never rewinds the watermark.
* **Deferred by decision, on record:** duplicate detection is a *transfer-time* skip (§2.8 of the plan), so it landed with the offload engine in Chunk 3, not here. App icons in group headers deferred (labels resolve; icon bitmap plumbing is marginal gain — revisit if the gallery feels anonymous on-device).
* **Postscript defect:** the machine’s *global* gitignore contains `*.xml`, which had silently kept every XML file — including `AndroidManifest.xml` — out of version control since Chunk 1. A fresh clone could not have reproduced the app. Fixed repo-locally with a `!*.xml` negation (commit `642d101`); the global file itself is the machine owner’s call and was NOT edited.

### 2.4 Chunk 3a — offload engine (commit `844c0ac`)

* **Decision engine in pure Dart** (`decideTransfer`, §3.3): weighs source size + SHA-256 against the destination’s final file and partial, and returns skip-as-duplicate / copy fresh / resume at the partial’s real length / verify a full-length partial without copying. An unknown hash never counts as verified.
* **Byte-moving in Kotlin** behind the channel: copies stream into `<name>.part` (256 KiB buffers, streaming SHA-256 — multi-GB files never sit in memory) and are renamed to the final name **only after the partial’s hash matches the original**. A file under its final name at a destination is verified *by construction*. Resume appends only after the platform re-checks the partial’s real length against the requested offset; a mismatch fails the attempt and leaves the partial for re-decision.
* **Destinations with real storage:** (a) a SAF granted folder (tree picker
  * persisted grant, re-validated at cold start, `grantLost` repair state — §3.6), and (b) the app’s own external folder (always available). The Chunk 1 Phone/Computer/NAS destination *kinds* remain named intentions; the engine refuses them with a logged “no folder yet” failure rather than pretending to copy. Their transports are §5 work.
* **Duplicate detection at transfer time:** same name + size + hash at the destination → skip, logged as a `duplicate` row.
* **Persistent 30-day transfer log** (§3.7) with a **History tab** (fifth shell section). Verified, duplicate, and failed rows are all kept — failures stay visible on purpose; from Chunk 3b the log is also the delete gate’s only evidence.
* **Home offload action** with progress (file x of y, current file) moving only captures the scan badged new. NOTE: this is the on-open promise *on demand* — the automatic launch trigger and the dataSync foreground service are **not yet built** (§5.1).

### 2.5 Chunk 3b — verified delete (commit `daa512a`)

* **The gate is a pure function** (`assessDelete`, §3.8): an original is deletable only when ALL hold — the Settings switch is on (default OFF); a *live* log row proves a hash-verified copy for that exact source URI; and the original’s **freshly-read current hash** still equals the verified hash. Refusals are named and counted, never hidden: `settingOff`, `noVerifiedCopy`, `sourceChanged`.
* **Per-batch headset confirmation** (count, bytes to be freed, free space before/after) **plus** the system consent prompt. Two routes, consent preferred: MediaStore `createDeleteRequest` (one prompt per batch, all-or-nothing) and a per-file SAF route through a granted Oculus-folder tree (built and tested in the state layer; the Gallery wires the consent route today). Only platform-confirmed deletions leave the gallery — partial results reconcile per file.
* **Adversarial pass: green, nothing stubbed.** All abuse cases are refused in tests: no verified copy; failed-hash rows; a verified row whose own hashes disagree; switch off; changed original; pruned proof row (a seeded 31-day-old row is pruned at bootstrap and refused); partial batch consent; cross-file proof; a later failed attempt does not erase earlier proof. This pass is a **permanent gate**, not a one-time event (§8.2).

### 2.6 Chunk 3 build defect — owned

The first clean build of Chunk 3 failed: the Kotlin splice scripts that grew `MainActivity.kt` mismatched closing braces and closed the class early. **The 3a commit therefore contained Kotlin that could not have compiled** — its Dart side was fully test-green, its design unchanged, and nothing from it ever reached a device. Fixed in the 3b commit and journalled in full (`docs/journal-chunk3.md` §5). Standing lesson, now a rule (§8.1): **a checkpoint isn’t landed until its build is green** — a green test suite on one side of the channel proves nothing about the other.

### 2.7 What is NOT built yet (honest list)

* Browser receiver (plan must-ship #4) — §5.1.
* Automatic on-open trigger + dataSync foreground service (plan must-ship #5’s glue) — §5.1.
* Phone/Computer/NAS transports (SMB etc.) — §5.3 fast-follows.
* Copy-protection layers (entitlement, signature integrity) — §6, lands with Chunk 4.
* **All on-device verification of Chunks 2–3** — §8.4. The staged 0.3.0 APK (17,374,603 B, SHA-256 `79ee1dad…`, libapp.so present arm64-only, dex MainActivity present, Leverine-signed, exactly the two media permissions) has never been installed: the headset was flat/charging at build time.

***

## 3. Architecture

### 3.1 State-layer-first (standing rule)

All product logic lives in a pure-Dart state layer (`lib/state/`); widgets only render state and forward intent. Platform access sits behind the `CapturePlatform` interface (`lib/state/capture_platform.dart`); `AppState` consumes the interface and tests substitute fakes. New platform capability MUST arrive as a new implementation or a defaulted interface member, never as a refactor of the state layer. The Chunk 3 SAF path arrived exactly this way under the Chunk 2 interface.

Current state-layer modules:

| File | Responsibility |
| - | - |
| `lib/state/capture.dart` | Capture model, filename parsing, grouping, watermark maths, formatting — pure Dart |
| `lib/state/capture_platform.dart` | `CapturePlatform` interface + `MethodChannelCapturePlatform` |
| `lib/state/offload.dart` | `decideTransfer`, `assessDelete`, transfer log model + retention — pure Dart |
| `lib/state/app_state.dart` | `AppState` (ChangeNotifier): bootstrap, scan, offload orchestration, delete planning, persistence |

### 3.2 Platform channel surface

One `MethodChannel` (`com.leverine.capturevault/captures`) implemented in `MainActivity.kt` (Kotlin, framework APIs only — no AndroidX additions). MediaStore/thumbnail/copy work runs on a background executor; results are posted to the main thread. **Every Dart-side channel call MUST degrade, not throw**: a failed scan keeps the previous results on screen; a platform failure becomes a logged outcome, never a blank gallery or a crash.

Channel methods (grouped; see Appendix A for the full list):

* Permissions/scan: `checkPermissions`, `requestPermissions`, `scanCaptures`, `resolveLabels`, `loadThumbnail`
* Watermark/persistence: `loadWatermark`, `saveWatermark`, `loadPersisted`, `savePersisted`
* Folders: `pickFolderTree`, `listGrantedFolders`, `appFolderPath`
* Transfer: `statFile`, `hashUri`, `hashFile`, `copyFile`, `finalizeFile`, `discardPartial`
* Delete/space: `requestDelete`, `deleteViaSaf`, `freeSpaceBytes`

### 3.3 Decision-engine purity (normative)

`decideTransfer` and `assessDelete` are **pure functions**: gathered facts in, decision out, no I/O, no platform calls, no clock reads inside. The state layer gathers facts (sizes, hashes, log rows, switch state) and the platform layer executes decisions. This purity is what makes the adversarial delete pass (§8.2) possible as unit tests, and it MUST be preserved: any new transfer or delete behaviour lands as a pure decision plus a thin execution path, with tests on the decision first.

`decideTransfer` rules that MUST hold:

* A duplicate requires size **and** hash equality. Size alone never skips.
* An over-long partial is corrupt → restart fresh. A zero-length partial is no partial.
* A full-length partial is verified by hashing, not assumed.
* `hashMatches` is case-insensitive and treats null/empty as never-matching: **an unknown hash is not a verified hash.**

### 3.4 The verified-copy invariant

1. Bytes stream to `<name>.part` at the destination.
2. The partial is hashed (streaming SHA-256).
3. Only on hash equality with the original is the partial renamed to its final name.

Therefore: **a file under its final name at a destination is a verified file, by construction.** Any code that places a file under its final name by another route breaks the product’s core claim and MUST NOT be written.

### 3.5 Newness: the scan watermark

* The state layer persists a watermark = the newest capture timestamp seen (epoch millis), via the channel into Kotlin SharedPreferences.
* On scan, captures newer than the watermark are “new” (badged per item and per group; Home shows “N new captures since your last visit”).
* First run (no watermark): everything is new, stated plainly.
* An empty scan MUST NOT rewind the watermark. The watermark advances only to a timestamp actually observed.
* The filename timestamp, when it parses, is the timestamp of record (the naming convention is the product’s foundation); MediaStore’s DATE\_TAKEN/DATE\_ADDED is the fallback for unconventional names.

### 3.6 Storage model

Two destination kinds have real storage today; the model MUST generalise to the §5.3 transports without changing the decision engine (transports differ in how facts are gathered and bytes moved, not in what “verified” means).

* **App folder** — the app’s own external files directory. Always available, listed first, not removable. This is the always-works home base **\[documented]**.
* **SAF granted folder** — a user-granted tree (`ACTION_OPEN_DOCUMENT_TREE` + `takePersistableUriPermission`). Persisted grants survive reboot and update **\[documented]**; they die on uninstall, user revocation, target deletion/move, or the per-app grant cap. Therefore:
  * Grants MUST be re-validated at every cold start against the OS grant list (the platform’s `listGrantedFolders` is the source of truth, not the app’s own record).
  * A destination whose grant is gone MUST surface as `grantLost` with a repair action — it MUST NOT silently vanish and MUST NOT fail copies mysteriously at transfer time (the engine refuses a lost grant before any copy).
  * The picker reporting `unavailable` (no resolver / `ActivityNotFoundException`) is a **first-class UI outcome**, not an error path (§4).
* **Destinations persist** across launches (a SharedPreferences string slot, reconciled against live platform facts at bootstrap — same pattern as the grant book). Phone/Computer/NAS kinds persist as intentions and fail honestly (“no folder yet”) until their transports land.

### 3.7 Transfer log — schema and retention

The log is the user’s proof of offload and the delete gate’s only evidence. It persists across launches (JSON via the channel persistence slot; tolerant decode — a malformed row is dropped, never crashes the load).

Row schema (`TransferLogEntry`, `lib/state/offload.dart`):

| Field | Meaning |
| - | - |
| `fileName` | Capture file name |
| `sourceUri` | Content URI of the original on the headset (the delete gate matches on this, strictly) |
| `destinationId` / `destinationName` | Where it went |
| `sizeBytes` | Source size |
| `sourceHash` | SHA-256 of the original; empty when unreadable |
| `destHash` | SHA-256 of the copy; null when no copy was produced/hashed |
| `verdict` | `verified` \| `duplicate` \| `failed` |
| `timestampMillis` | When the attempt finished (epoch millis) |
| `detail` | Short human note for failures |

Rules:

* **Every** attempt appends a row — verified, duplicate, and failed alike.
* **Retention: 30 days.** Rows prune at bootstrap; the boundary is inclusive (exactly-30-days is kept). Pruning is load-bearing: a pruned proof row is no proof (§3.8), which is deliberate — delete eligibility expires with the evidence.
* A row counts as verified-copy proof only when `verdict == verified && hashMatches(destHash, sourceHash)`. (`duplicate` rows also carry matching hashes and are admitted by the gate as proof, since a duplicate *is* a verified copy already present.)

### 3.8 The delete gate (`assessDelete`)

An original is deletable only when ALL of the following hold, evaluated in this order:

1. **Switch on.** `verifiedDeleteEnabled` is ON (default OFF; the user turns it on in Settings). Checked before any evidence is read — `settingOff`.
2. **Live proof.** The un-pruned log holds a row for that exact source URI whose `isVerifiedCopy` is true — else `noVerifiedCopy`. Failed rows are not proof; a verified row whose own hashes disagree is not proof; a verified row with no destination hash is not proof; a row for a different file is not proof; failure rows never subtract earlier proof.
3. **Original unchanged.** The original’s hash, read fresh at plan time, still equals the verified hash — else `sourceChanged`. An unreadable original (empty hash) refuses the same way.

Execution rules:

* The plan is presented for **per-batch confirmation in the headset**: count, bytes to be freed, free space before/after (StatFs).
* Consent route preferred: MediaStore `createDeleteRequest` — one system prompt per batch, all-or-nothing. (`createDeleteRequest` is API 30+; minSdk is 29 — the Kotlin route checks the SDK level and degrades to “nothing deleted” on API 29 rather than crashing. All supported headsets run API 34 in practice.)
* SAF route: per-file deletes inside a granted Oculus-folder tree (root level or one subfolder down, where Screenshots/VideoShots live).
* **Only platform-confirmed deletions leave the gallery** (`reconcileDeleteResults`). A refused prompt deletes nothing; a partial SAF run removes exactly the confirmed subset.
* Deletion is **never automatic** and **never** offered for anything the gate refuses. Free-space reporting (before/after) MUST accompany every batch result.

### 3.9 Dependencies and build shape

* **Zero third-party packages** (Dart and Kotlin). Framework/SDK APIs only. This keeps the cold-launch budget (\< 10 s on Quest 2 — a plan requirement; the on-device stopwatch number is still **\[unproven]**) easy and the review surface small. Any future dependency needs a recorded reason.
* Single-ABI (arm64-v8a) release builds via `flutter build apk --release --target-platform android-arm64` — the Gradle `abiFilters` line does NOT constrain Flutter’s own libraries (Chunk 1 journal, failure #2); the build-command flag is what enforces it.
* This template’s release build runs R8 despite a stale “no minify” comment in the Gradle file — assume shrinking is ON and verify the dex (§8.1) rather than trusting comments.

***

## 4. Platform constraints — mandated behaviour

Distilled from the platform homework (2026-12-03) and the filesystem survey of Kev’s Quest 2 (Horizon OS v210, Android 14 base, \~6 GB RAM, 128 GB model with 106 GB free at survey). Each constraint has a mandated behaviour; the spec’s behaviour is the requirement, whatever a future Horizon build does.

| # | Constraint | Mandated behaviour |
| - | - | - |
| P-1 | **Scoped storage is fully enforced** at targetSdk 34; raw-path reads of the Oculus folders are blocked. | MediaStore + granular media permissions for captures; SAF for folders. No raw-path code paths to shared storage. |
| P-2 | **Legacy storage permissions are dead**: `READ_EXTERNAL_STORAGE` is not granted at targetSdk 33+, `WRITE_EXTERNAL_STORAGE` has no effect at targetSdk 30+; both are also review-required. | MUST NOT be declared. (Chunk 2’s manifest declares exactly the two media permissions.) |
| P-3 | **The SAF picker is the flakiest link on Quest** — present on some Horizon builds, restricted on others, undocumented by Meta. **\[unproven on v210]** | Always catch picker failure (`ActivityNotFoundException` / no resolver); `unavailable` is a first-class UI outcome; the picker MUST NOT be the only route to a core feature (MediaStore scan and the app folder are independent routes). |
| P-4 | **Deleting captures the app doesn’t own needs consent or a grant**: `createDeleteRequest` (one prompt per batch) or a SAF write grant on the Oculus folder. | The delete flow budgets for one of the two, per batch (§3.8). No third route may be assumed. |
| P-5 | **Partial media grants exist** (Android 14 selected-photos). | Partial grant → partial-but-honest gallery (§2.3). Never treat partial as none, never crash. |
| P-6 | **Grants silently reset**: runtime permissions can be auto-reset after months unused (hibernation); persisted SAF grants die on uninstall/revoke/move/cap. | Re-validate every grant at cold start; degrade gracefully with a repair action (§3.6). Never assume yesterday’s grant. |
| P-7 | **`MANAGE_EXTERNAL_STORAGE` is NOT prohibited** on the Horizon Store — review-required, with file management a named permitted use. Its Settings grant screen working on v210 is **\[unproven]**. | Capture Vault does not request it in v1 (the media + SAF routes suffice). It MAY be proposed later only as its own reviewed decision (§9, D-6); the app MUST remain fully functional without it. |
| P-8 | **`QUERY_ALL_PACKAGES` is prohibited** — an APK requesting it fails Horizon upload automatically. | MUST NOT appear in any store build (§5.2 manifest audit). Capture Vault doesn’t need it: label resolution is per-package via PackageManager for capture filename prefixes only. |
| P-9 | **Close ≠ minimise.** “Close app” / Window Manager X removes the task — next launch is a cold start with no saved state. Minimised panels keep running but the low-memory killer reclaims backgrounded 2D processes aggressively on a 6 GB headset. | Checkpoint everything resumable (the `.part` design, §3.4); persist state at every step, never only on close; never design anything that assumes a minimised panel is alive minutes later. |
| P-10 | **Focus loss is not pause.** Unfocused panels stay visible and MUST keep rendering (VRC); display-off / unmount is the real pause signal. | Pause only non-essential work on focus loss; never blank the panel. |
| P-11 | **Foreground-service discipline:** an FGS cannot be started from the background (Android 12+); at targetSdk 34 it needs a declared type + matching permission. Meta lists FGS/WorkManager as fully supported for 2D apps. Whether a dataSync FGS notification renders meaningfully in-headset is **\[unproven]** (`POST_NOTIFICATIONS` is review-required). | When auto-offload glue lands (§5.1): start the dataSync FGS **from the foreground**, declare type `dataSync` + `FOREGROUND_SERVICE_DATA_SYNC`, and design progress UX that does not depend on the notification being seen. |
| P-12 | **Android 15 caps dataSync FGS at 6 hours per 24 h** and forbids starting one from `BOOT_COMPLETED`. Not binding on today’s Android-14-based Horizon OS; arrives with a future base bump. | Checkpoint-resumable transfers are the only safe architecture — already the design (§3.4). No transfer may assume it can run to completion in one FGS window. |
| P-13 | **Panel lifecycle numbers:** launch \< 10 s, typical memory \< 1.5 GB (Meta 2D-porting requirements); minSdk 29, targetSdk 34+ for new 2D apps. No Google Play Services / FCM / Play Billing dependencies. | Hold all three; the zero-dependency rule (§3.9) is how. Memory: stream, never buffer whole files (256 KiB copy buffers). |
| P-14 | **Filesystem facts** (survey, **\[proven]** for the adb shell identity; app-UID reach is narrower and is what the app codes against): captures live exactly at the §1.3 paths with the §1.3 naming; `/tmp` does not exist (`/data/local/tmp` is the stand-in — tooling only); at survey the app had no external data dir yet. | Code only against MediaStore/SAF/app-folder reach. Shell-level writability is never evidence of app-level reach. |
| P-15 | **Horizon OS storage behaviour shifts between builds** (v60s–v70s tightened repeatedly, per shipping file managers). | Storage features are verified on Kev’s actual build before being trusted (§8.4) — including the assumptions in this table. |

***

## 5. The remaining build path, end to end

Chunks are executed in order; each lands under the release discipline of §8 before the next starts. Numbering continues the roadmap’s: Chunks 1–3 are built (§2); what follows is 4 (split into 4.0/4.1 for honesty about what remains of v1’s core) and then the fast-follow sequence in roadmap order.

### 5.1 Chunk 4.0 — v1 core completion (receiver + auto-offload glue)

Two plan must-ship items are not yet built. v1 is not complete — and Chunk 4.1’s “ready to submit” cannot be claimed — until both land or are explicitly re-scoped by Kev (§9, D-5).

**(a) Browser receiver** (plan §2 #4)

* Scope: a local HTTP server on the headset; a phone or PC browser downloads originals — ZIP or individual, bit-identical. Pairing: QR code on Quest 3/3S; 6-digit code / typed address on Quest 2/Pro. Remembered browsers. If plain HTTP is used, it MUST be flagged in-app (the CaptureHop precedent).
* This is also what makes the Phone/Computer destination kinds real for browser-equipped devices.
* Acceptance: a phone and a PC each download captures over home Wi-Fi; every downloaded file hash-identical to the original; Quest 2 pairs without a camera scan; an unpaired browser is refused.

**(b) On-open auto-offload + foreground service** (plan §2 #5)

* Scope: on launch/resume, auto-scan and auto-offload everything new to the default destination (today’s Home action, triggered automatically); dataSync FGS started from the foreground per P-11 with progress in the panel; transfers resume after any death (P-9/P-12) via the §3.4 checkpoint design. A WorkManager periodic check MAY be added, labelled best-effort (never “scheduled sync”, §1.4).
* Acceptance: a multi-GB transfer interrupted mid-flight (Wi-Fi drop, app closed, headset slept) resumes and finishes byte-exact — the File Handler F1 fixture discipline (300 MiB and 1 GiB byte-exact, twice) applied here; the panel shows progress throughout; killing the panel mid-transfer loses nothing already finalised.

### 5.2 Chunk 4 — store readiness (ends at “ready to submit”)

Goal: a submittable Horizon Store package with Quest 2/3/3S/Pro targeting, submitted during 2027 — well before the December 2027 Q2/Pro cutoff.

Scope:

* **VRC self-check pass, Privacy.1 first.** Privacy.1 is the most commonly failed VRC. The privacy policy is already live at [https://leverine.com/capture-vault/privacy/](https://leverine.com/capture-vault/privacy/) ; it MUST be **entered in the console listing** in this chunk (draft-only console edit — allowed). The policy states what is collected (nothing), how it’s used, and how deletion is requested. Data Use Checkup surface stays minimal: no Platform SDK features beyond what distribution requires.
* **Permission justification package:** video of the core flow + text justification for `READ_MEDIA_IMAGES` / `READ_MEDIA_VIDEO` (review-required; Meta’s own note — “access images/videos created by other apps” — is literally this app’s function). Request nothing the feature set doesn’t use (VRC Security.2). The SAF architecture (§3.6) is the standing insurance: if review denies the media permissions, the app ships on SAF grants alone with a degraded-but-working first run.
* **Copy protection lands in this chunk** (§6) — all three layers, with their verification, before any store candidate is cut.
* **Pricing:** set **\$7.99** on the draft listing once Meta Payment Information is saved (§9, D-2). The Developer Distribution Agreement signature is Kev-only (§9, D-3).
* **Listing assets:** store covers/screenshots at Meta’s required sizes; listing copy in the honest language of §1 — the promise of §1.2 and the exclusions of §1.4, verbatim in spirit. No background-sync claims anywhere, including screenshots and captions.
* **IARC rating** questionnaire completed.
* **Store-build hygiene (hard rules):**
  * The store build’s merged manifest MUST be audited by dump, not memory: no `QUERY_ALL_PACKAGES` (P-8), no other prohibited permissions (`REQUEST_INSTALL_PACKAGES`, `INSTALL_PACKAGES`, `MANAGE_DOCUMENTS`, `PACKAGE_USAGE_STATS`, `START_FOREGROUND_SERVICES_FROM_BACKGROUND`), no legacy storage permissions (P-2).
  * Frozen **v2.13-compatible branch** for Quest 2/Pro; later Quest 3-only features device-targeted off it.
  * Release discipline per §8.3.

Acceptance: VRC self-check green with Privacy.1 verified first; a store-candidate APK passes the manifest audit and the §8.1 build checks; the listing preview shows the privacy URL and the \$7.99 price; the package is **ready to submit**.

**Gate (standing boundary, Kev 2026-12-02): nothing is submitted, posted, or uploaded to the Horizon Store except on Kev’s explicit word.** This chunk ends at “ready to submit,” never at “submitted.”

### 5.3 Fast-follows (post-launch, roadmap order)

Each ships as its own chunk under the same release discipline; the Quest 2/Pro frozen branch is kept compatible or a feature is device-targeted out explicitly. Transports plug into §3.6’s model: the decision engine and the verified-copy invariant do not change.

| # | Fast-follow | Scope | Depends on | Acceptance |
| - | - | - | - | - |
| FF-1 | **SMB/NAS destination** | SMB client transport (File Handler’s existing protocol engine makes this cheap); NAS destination kind becomes real; Tailscale-aware networking pattern reused so a home NAS over the tailnet works the same way | Chunk 4.0 (engine transports pattern); a real NAS on Kev’s network | Multi-GB offload to the NAS finishes hash-verified; interrupted transfer resumes byte-exact; credentials never leave the device except to the target server |
| FF-2 | **Android manager app** | The depth surface on the phone — browsing, destinations, transfer control, proof log — from the shared Flutter codebase; the headset panel stays slim. Same tab names as the panel (per the 2026-12-03 UI arrangement) | FF-1-era transport maturity; the arrangement-page decisions (§9, D-4) | Manager pairs with the headset, browses the gallery, starts/monitors an offload, and shows the same transfer log the headset shows |
| FF-3 | **iOS manager app** | Same surface, honest platform limits: foreground-only receiving, Local Network permission, captures arrive as ZIP to Files (no camera-roll auto-save — §1.4) | FF-2 | Same acceptance as FF-2 within the stated iOS limits, with the limits shown in-app, not discovered |
| FF-4 | **WebDAV / SFTP destinations** | Self-hosted/Nextcloud rides the same stack as SMB (File Handler’s SFTP/WebDAV work is the starting point) | FF-1 | Verified offload + resume against a real WebDAV and a real SFTP endpoint |
| FF-5 | **Cloud destinations** | Dropbox first (its SDK needs no Google Play Services), then Google Drive (hand-rolled WebView OAuth + REST; Google’s OAuth verification burden for sensitive scopes), then OneDrive | FF-4; per-provider OAuth review timelines | Verified offload to each provider; tokens stored on-device only; the “no cloud” promise is reworded honestly the day this ships — cloud becomes a *user-chosen destination*, never a Leverine intermediary |
| FF-6 | **USB-C destination; batching & naming** | USB-C drive as a destination (via SAF/MediaStore volumes); auto-ZIP batching rules; rename templates (`Game/Date` folders on the destination) | SAF maturity from §8.4 device results | Offload to a USB-C drive verifies; a templated batch lands in the expected folder shape with expected names |
| FF-7 | **Multi-headset household; inbound send; storage analysis** | More than one headset against shared destinations; phone → headset inbound send; storage analysis (what’s eating the headset) as features of this app | FF-2/FF-3 | Two headsets offload to one destination without collisions; inbound send verifies like outbound; analysis numbers match the device’s own storage report |
| FF-8 | **“Offload while charging + idle”** (conditional) | Opportunistic mode — **only if** on-device testing proves Horizon OS behaviour reliable enough to describe honestly | Repeated device evidence across Horizon builds | Either it ships with copy that matches measured behaviour, or it doesn’t ship. No third outcome. |

***

## 6. Copy protection and integrity posture

Honest framing (from the roadmap, normative here): **client-side checks raise friction; they do not make copying impossible.** Anyone determined can patch an APK. The layers below exist to make the *casual* copy — the re-signed APK passed to a friend, the scrape-and-reupload — fail plainly, while never punishing a paying user. Capture Vault is the paid app (\$7.99), so of the Quest products this is where entitlement matters most.

**Layer 1 — Meta entitlement verification at launch (the layer with real teeth).** Verify the signed-in account owns Capture Vault, leaning on Meta’s account system rather than anything we invent. The verdict MUST be cached with a grace window: a paying user launching offline (or with Meta’s servers unreachable) is never locked out; entitlement re-checks in the background and only a persistent, confirmed non-ownership state degrades the app. *Feasibility note (honest): the Meta Platform SDK route for a Flutter panel app is an open question — the File Handler integrity work left it as a stub interface for the same reason. Chunk 4 MUST resolve it (SDK bridge, or a documented alternative) before claiming this layer.*

**Layer 2 — Signature integrity check at load.** The app verifies its own signing-certificate SHA-256 against the Leverine release fingerprint (`5bc0623a…cd9210`) and fails closed with an honest message on mismatch — the standard pirate repack is a re-signed copy, and this is what stops it. Debug-signed builds are exempt (development must not fight the gate); the phone/Quest pattern is the one already proven in File Handler Quest’s integrity chunk (gate before any service starts; no file operations on a failed build).

**Layer 3 — Activation codes, non-store flavours only.** Sideload/personal builds (Kev’s own copies, tester builds) use the File Handler personal-build pattern: the build carries only the code’s SHA-256, first launch prompts, and the correct code binds to the device’s ANDROID\_ID. Store builds rely on Layers 1–2; the activation path is compiled into non-store flavours only.

**Settled NOT-to-do list (not up for re-litigation per chunk):**

* **No user accounts.** Deliberate decision (Kev, 2026-12-03): company-wide accounts (the Rookie-style model — sign up, receipts and entitlements in one Leverine account) were considered and rejected. An account system is a forever commitment — auth, resets, support, custody of customer purchase data — that a solo company should not take on to protect a \$7.99 utility. Revisit only as a feature of the paid Leverine Licensing service, where paying developer customers justify the upkeep. Capture Vault’s “no account” promise stands as written.
* **No LVN- licence keys in the app.** The Leverine licensing system stays out of mobile/Quest apps; Meta handles payment on this channel.
* **No phone-home requirement for basic function.** The app works fully offline on a local network — that is the privacy pitch, and copy protection doesn’t get to break it.
* **No punishing offline use.** Grace windows on every check; a check that can’t reach its authority degrades to “ask later,” not “lock out.”

**Verification (Chunk 4, all required):** (1) a copy re-signed with a different key fails the integrity check with the clear message; (2) the store build launches and offloads fully with Wi-Fi off, inside the entitlement grace window; (3) an activation-flavoured build rejects a wrong code and a code moved to a second device (different ANDROID\_ID).

**Gate:** if any layer ever locks out a legitimate launch in testing, the layer ships weakened or not at all — a paying user locked out is worse than a copied app.

***

## 7. Privacy and analytics posture

### 7.1 Privacy (architecture, not policy-washing)

* **Collect nothing.** No analytics server, no account, no telemetry. Captures never touch a Leverine server — there is no Leverine server in the design. Transfers stay on the local network or go direct to the user’s chosen destination.
* **Use no Platform SDK features** beyond what distribution requires → smallest possible Data Use Checkup surface (annual recertification still applies).
* **Privacy policy is a launch blocker, treated early:** live at [https://leverine.com/capture-vault/privacy/](https://leverine.com/capture-vault/privacy/) (HTTPS, publicly accessible without login, app-specific), stating what is collected (nothing), how it’s used, and how users request deletion. Entity wording on the page is “Leverine, Kemptville, Ontario, Canada” — to be aligned once Ontario business registration is confirmed (§9, D-7). Privacy.1 is the most commonly failed VRC; §5.2 puts it first.
* Listing copy states the architecture plainly: “Your captures never leave your local network or your chosen destination.” (Revisited honestly if FF-5 cloud destinations ship — §5.3.)

### 7.2 Analytics (per the company analytics plan, 2026-12-03)

* **The app itself collects nothing** — no telemetry, no usage reporting, no analytics SDK — and no chunk in this spec may add any. Adding in-app telemetry would be a product decision requiring Kev’s explicit approval and a privacy-policy rewrite, not an engineering default.
* Capture Vault’s numbers come entirely from the **Meta Horizon developer dashboard**: units sold, net revenue, refund rate (the quality signal for a utility — a spike after an update is a regression alarm), rating average and review count. Sideload-channel numbers come from GitHub release download counts, labelled by channel.
* These feed the **weekly digest** defined in the company plan (units, net revenue, best sellers, trend vs prior week), which stands up only when the first paid product goes live. A failed source renders as a named gap, never a silent zero. Nothing customer-facing depends on the digest.
* **PIPEDA posture:** aggregate business metrics only; customer-level records stay at the platforms (Meta holds the purchase records; Leverine holds none and wants none).

***

## 8. Testing and release discipline

### 8.1 Standing verification rules (every build, no exceptions)

1. **Clean build** (`flutter clean` first) with `--target-platform android-arm64`; verify `libapp.so` is present and arm64-v8a is the only ABI.
2. **Dex check:** the APK’s `classes.dex` MUST contain `Lcom/leverine/capturevault/MainActivity;` (origin: §2.2).
3. **Signer check:** APK signer SHA-256 MUST equal the Leverine release fingerprint `5bc0623a…cd9210`, verified against the keystore.
4. **Manifest check:** declared permissions dumped from the built APK (aapt), never asserted from memory (origin: §5.2 hygiene; Chunk 3’s build confirmed exactly the two media permissions).
5. **On-device launch + exit-info:** install on the real headset, launch the resolved component, confirm the process survives and the activity resumes; `dumpsys activity exit-info` MUST show no new crash.
6. **A checkpoint isn’t landed until its build is green** (origin: §2.6) — green tests on one side of the channel prove nothing about the other.

### 8.2 The adversarial delete gate (permanent)

The §2.5 abuse matrix is a **standing requirement**, not a Chunk 3 event: any change touching `assessDelete`, the log, or the delete routes MUST re-run the full matrix (no proof / failed hash / disagreeing hashes / switch off / changed original / pruned proof / partial consent / cross-file proof / failure-after-success) and keep every case refused. The delete flow does not ship in any daily-driver build on unit tests alone — the on-device pass (§8.4) is part of the gate. Data loss here breaks VRC Functional.4 and the product’s entire “your files are safe” pitch; this gate is not negotiable.

### 8.3 Release discipline (per release)

CHANGELOG entry, GitHub push, annotated tag `v<version>`, README badges current, CI green, plus all of §8.1. Version lives in `pubspec.yaml` (`version:`), mirrored in `AppState.appVersion` and the Settings About row — the version-pin tests enforce the mirror.

### 8.4 Device-test checklist — currently owed (Chunks 2–3)

To run on Kev’s Quest 2 (Horizon OS v210) in the next device session, in this order. Until these pass, Chunks 2–3 are “built,” not “verified.”

* [ ] Install the staged 0.3.0 APK; launch; exit-info clean (§8.1.5).
* [ ] Grant media permissions from the Gallery; confirm the scan finds the headset’s real captures — the expected first catch is the two `com.oculus.vrshell` screenshots the filesystem survey found in `Oculus/Screenshots` — grouped under the right labels, Unknown bucket behaving.
* [ ] Take a new capture between two app opens; confirm only it is badged new on the second open (watermark behaviour, §3.5).
* [ ] **SAF picker existence on v210 (P-3):** does the tree picker appear at all? Grant a folder; kill and relaunch; confirm the grant re-validates at cold start; revoke it and confirm the `grantLost` repair state appears instead of a silent disappearance.
* [ ] **`renameDocument` behaviour:** does the Files provider honour it (the §3.4 finalise step depends on it)? Does `createDocument` keep the `.part` name verbatim? Both degrade to logged failures, not data loss — but the SAF destination’s real verdict is this test.
* [ ] **Real end-to-end offload:** offload the headset’s actual captures to the app folder and to a granted folder; verify hashes; confirm duplicate skip on a second run; interrupt a copy mid-flight and confirm resume finishes byte-exact.
* [ ] **Delete consent in a panel (P-4):** with the switch ON and a verified copy in the log, run a batch delete — does the `createDeleteRequest` IntentSender surface correctly from a 2D activity? Refuse it once (nothing deleted) and approve it once (exactly the confirmed set leaves the gallery; free-space report matches). Exercise the SAF delete route the same way.
* [ ] **Selected-photos mode (P-5):** grant selected photos only; confirm the gallery is partial-but-honest.
* [ ] Cold-launch stopwatch (\< 10 s, P-13) and a multi-GB HEVC recording end-to-end (list, thumbnail, offload, verify).

***

## 9. Open decisions register

Everything still owed a decision or an external step. “Blocks” means the named work cannot finish — not start — without it.

| # | Item | Owner | Blocks |
| - | - | - | - |
| D-1 | **Name clearance, Canadian leg:** manual CIPO / NUANS check for “Capture Vault” (the 2026-12-02 screen could not execute the Canadian register search; USPTO was searched via a mirror). Professional search before any branding spend. Fallback if it fails: CaptureCrate (screened CLEAR). | Kev (or a trademark agent Kev engages) | Branding spend, final listing assets (§5.2) |
| D-2 | **Meta Payment Information completion:** entry was in progress 2026-12-02 (Canadian routing number corrected to institution+transit order); tax information generally **cannot be changed after submission** and the bank account name must match the developer account name — completion is unconfirmed. | Kev | Setting the \$7.99 price (§5.2) |
| D-3 | **Developer Distribution Agreement** signature in the Meta console. | Kev | Submission itself (not “ready to submit”) |
| D-4 | **Arrangement-page decisions (3):** the 2026-12-03 UI-arrangement page (`capture-vault-ui-arrangement`) closed with three open decisions for Kev, including whether **delete confirmation stays headset-only** (the page’s recommendation) or can also be approved from a manager app. | Kev | FF-2/FF-3 manager scope; any change to §3.8’s “confirmation in the headset” rule |
| D-5 | **SMB-in-v1 confirmation:** the plan (§9.3) left open whether SMB/NAS pulls forward into v1 (File Handler’s engine makes it cheap) or holds as FF-1. Working assumption in this spec: **fast-follow (FF-1)**; and whether the §5.1 receiver + auto-offload glue are both required for v1 as specced. | Kev | Final v1 scope; §5.1/§5.2 sequencing |
| D-6 | **`MANAGE_EXTERNAL_STORAGE` posture:** not requested in v1 (P-7). Any future proposal is its own reviewed decision with the no-grant fallback kept. | Kev (on a BBv2 proposal) | Nothing in v1 |
| D-7 | **Ontario business registration confirmation** — aligns the privacy-policy entity wording, the D-U-N-S application, and the eventual personal→organization Play Console conversion. | Kev | Privacy-policy final wording (§7.1); D-2 confidence |
| D-8 | **Meta entitlement feasibility (Layer 1, §6):** the Platform SDK route for a Flutter panel app is an open technical question (a stub interface is all that exists today, in File Handler’s work as here). Chunk 4 must resolve it or document the alternative. | BBv2 | §6 Layer 1 claim in the store candidate |
| D-9 | **Console draft tidy-ups (allowed, draft-only):** enter the privacy policy URL into the Capture Vault listing (the app’s Meta App ID, as held in the console); complete the File Handler privacy-policy page dependency for the sibling listing. Nothing posted or submitted (§5.2 gate). | BBv2 | §5.2 Privacy.1 verification speed |
| D-10 | **Corpus of device evidence:** §8.4’s checklist is owed a device session (headset was flat at Chunk 3 build time). | Kev + BBv2 (scheduled session) | “Verified” status for Chunks 2–3; SAF destination verdict (P-3) |

***

## Appendix A — Platform channel methods (as built, Chunk 3)

Channel: `com.leverine.capturevault/captures` (single MethodChannel, `MainActivity.kt`). Dart surface: `CapturePlatform` in `lib/state/capture_platform.dart`; members added after Chunk 2 carry default bodies so additional implementations (and test fakes) opt in — fakes that `extends` the interface inherit the defaults; fakes that `implements` it must provide the full surface (Chunk 3 journals, failures #1 in both checkpoints — recorded so the next builder doesn’t rediscover it).

`checkPermissions` · `requestPermissions` · `scanCaptures` · `resolveLabels` · `loadThumbnail` · `loadWatermark` · `saveWatermark` · `pickFolderTree` · `listGrantedFolders` · `appFolderPath` · `statFile` · `hashUri` · `hashFile` · `copyFile` · `finalizeFile` · `discardPartial` · `loadPersisted` · `savePersisted` · `requestDelete` · `deleteViaSaf` · `freeSpaceBytes`

## Appendix B — Per-headset notes

| | Quest 2 | Quest 3 | Quest 3S | Quest Pro |
| - | - | - | - | - |
| Captures layout | §1.3 (identical) | same | same | same |
| Receiver pairing | 6-digit code / typed address | QR | QR | 6-digit code / typed address |
| Horizon OS future | v2.13 final; new submissions close Dec 2027 | ongoing | ongoing | same as Quest 2 |
| v1 build | ✓ frozen v2.13 branch | ✓ | ✓ | ✓ frozen branch |
| Verified on hardware | **Yes — shell only** (v210) **\[proven]** | No | No | No |

*End of specification v1.0. Amendments land as commits to this file with a journal note; the spec is wrong the moment it describes code that doesn’t exist, so §2 and the journals win any argument until the spec is updated.*

***

*Source: Leverine/Capture-Vault\@66b31c5 — `docs/SPEC.md`.*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.