# U4 storage and export evidence

Date: 2026-10-01. This is deterministic disk/simulator evidence, not physical motion evidence.

## Focused core run

Command: `DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer swift test --disable-sandbox --package-path Packages/RideFormCore --scratch-path /tmp/rideform-u4-build`.

RED: the first disk round-trip test failed to compile because `SessionWriter` and `SessionIO` did not exist. The ordinary SwiftPM invocation first encountered sandbox-exec nesting failure; `--disable-sandbox` enabled the actual compile. GREEN: 19 tests, zero failures, including six U4 tests (five SessionIO tests and one CSVExport test). Last focused log: `/tmp/rideform-u4-test.log`.

Covered: pending-buffer drain; precise irregular timestamps and all MotionSample values/calibration inputs round-trip through real disk; unsupported versus empty available streams; real optional-stream file/directory conflict causing SaveError; preserving newly enqueued rows while retrying; repeated finalization and enqueue unable to mutate sealed master; nonfinite accepted/written/loss accounting; truncated final row recovery; changed input with same UUID and changed algorithm configuration invalidating derived currentness; ZIP refusing an existing destination.

## Export fixture for independent checks

Frozen artifact directory: `/tmp/rideform-u4-export-2DCFBC03-B42C-4B8F-AD25-43E36E46B1AE`.

Generated by `CSVExportTests.testFullDiskExportFixture` through `SessionWriter` → finalization → `SessionIO.load` → `CSVExport.write` / `MasterArchive.write`. Fixture source and every expected field are in that test. Session UUID `11111111-1111-4111-8111-111111111111`; calibration UUID `22222222-2222-4222-8222-222222222222`; event UUID `33333333-3333-4333-8333-333333333333`.

Rows: motion 2, accelerometer 1, gyroscope 1, events 1; calibration neutral 1, left gesture 1, forward gesture 2, summary 1. Irregular fused timestamps are `12.123456789012345` and `42.987654321098765`; raw timestamps differ intentionally. The fixture includes available/invalid/unavailable optional values, raw validity codes, a full nonidentity matrix, precision-sensitive vector components, and a quoted multiline event note.

Python `zipfile.ZipFile.testzip()` passed. Every ZIP entry was byte-identical to its master bundle file. Python csv.DictReader parsed all eight CSVs, including the quoted multiline event. Selected timestamp round trips passed. Main integration independently checks every CSV field against master JSON; that authoritative result should be recorded separately.

Frozen master SHA256s:

- manifest.json: `575403d3b25b5bd33ad163a72402543cd7ec7bd45f8098e8ccdedcd3a04492f9`
- motion.jsonl: `99e248a1af50a385fc48cd3991f046cb356abbbb6a13051f606f202d64264a35`
- accelerometer.jsonl: `1f88c5e4172743692a2b73db9bf13599fd35403ef07c6a5f912f8c7640a5513f`
- gyroscope.jsonl: `c1a83bb21e7d16f9aa750ad5722da877d5f34e267211d234d6c0591301016a80`
- events.jsonl: `74bec547d558bd91d142e5b0972be9edba34425e5d8f4ce3008fcd748ba4c9d1`
- calibration.json: `67b442a1cdf89dbec135732b9eb661ef04150af6ef44649ac866b71158c172e7`

## Integration and human gates

`RecordingPersistenceTests` supplies two-session persistence with export preparation/cancellation semantics and relaunch recovery that retains original bytes. The coordinator owns authoritative app/simulator runs; no worker app execution claim is made here. Actual share-to-Files/AirDrop, external reopen, physical mounting/sign checks, matched raw/fused capture, and roughly 50 garage transitions remain human verification gates.

Follow-up recovery regression RED: `/tmp/rideform-u4-red-recovery.log` recorded three failures for missing event count reconciliation, stale sensor loss count, and absent event mismatch diagnostic. GREEN: full focused run 19 tests. Required missing files now mark incomplete; recovery preserves original expected-written/accepted checkpoint counts in diagnostics, exposes observed event/written counts, and reconciles accepted = written + loss while explicitly stating missing-tail accepted count is unknown. Coordinator earlier authoritative runs passed 18 core / 13 app tests before this follow-up; rerun required for the final recovery change.
