# #35 — Selected trip export and deletion

Android 0.14.0-trip-data, implemented 2026-09-19. The recording history exposes independent selection checkboxes, a JSON share action, and a two-step delete confirmation showing the selected trip times. Only completed trips can be deleted; active records can be exported as snapshots.

## Export and sharing

Schema version 1 includes selected profiles, actual SOC observations, GPS samples, charging sessions and immutable pre-leg prediction snapshots. Units, recording provenance and export time are explicit; original timestamps and synthetic/mock flags remain. An explicit data field vocabulary excludes unrelated account/transport fields, including credentials nested in fixture profiles, model metadata or route headers.

A private UTF-8 JSON file is written and synced before launching the Android chooser. A scoped FileProvider exposes only `cache/trip-exports/`, with temporary read permission. No arbitrary app file path is accepted from JavaScript. Failure to serialize, write or launch sharing never deletes source records; chooser cancellation is not reported as delivery. Reference: [Android FileProvider documentation](https://developer.android.com/reference/androidx/core/content/FileProvider).

## Deletion and calibration

After explicit UI confirmation, the recorder validates the complete selection, invalidates derived calibration, revokes/removes private exported copies and atomically deletes selected event rows. Memory is reconstructed only after database deletion succeeds. Other trip events remain unchanged. A failed precondition or database operation preserves source records, although calibration may require rebuilding because invalidation deliberately happens first.

The calibration report explicitly requests a rebuild from remaining history, with the base scenario used meanwhile. Existing pre-leg predictions remain historical snapshots. Previously shared copies held by other apps cannot be recalled; the confirmation states this limitation.

History snapshots carry a native revision. Model publication verifies that revision under the recorder lock before its document compare-and-write, preventing a stale activity from reintroducing deleted history. Export snapshot creation and private file publication hold the same recorder lock used by deletion, so an older exporter cannot recreate a deleted trip's private copy afterward.

## Verification

- 66 Node tests pass, including model publication conflict and absent-native-document regressions.
- 24 JVM tests pass. Recorder additions cover selected deletion and restart, unchanged other trips, failed/mixed selections, readable selected export with units/source/time and credential exclusion, failed export preserving source, stale history revision rejection, and deletion waiting for export publication.
- Android debug build and lint pass.
- Physical TECNO KF8 checks open the Android chooser, parse the actual exported JSON, cancel deletion, confirm deletion, reopen the process and verify the other trip remains identical. Invalid export selections preserve the source. Calibration invalidation persists across restart. The native calibration button persists its captured history revision, and attempts to publish that old snapshot after deletion are rejected. Test databases, model documents and permissions are restored.
- TECNO exposed that absent Java documents appear as `undefined` in WebView; the client now normalizes them to `null` before compare-and-write, so first model creation succeeds.
- Standards review identified two multi-activity publication races; revision-bound calibration and serialized export publication resolve both. Standards and Spec reviews have no remaining code-level blockers.

Device helper/evidence are ignored under `research/runtime/check-trip-data-device.py` and `issue35-device.json`. Integration fixtures are synthetic and do not establish field battery accuracy or energy savings.
