# U6 independent-review regression fixes

2026-10-01. Changes supersede `rideform-analysis-1` with `rideform-analysis-2`. The independent RED findings are preserved in `docs/validation/u6-independent.md` and `/tmp/rideform-u6-independent-mbxibs26/report.json`.

## Observed RED before production fixes

Three new acceptance tests were added before changing the production implementation and run against an isolated package snapshot. Command:

```sh
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \
  swift test --package-path /tmp/rideform-u6-fix-snapshot/RideFormCore \
  --scratch-path /tmp/rideform-u6-fix-scratch --disable-sandbox \
  --filter 'testSidecarRejectsSymlinkParentsWithoutChangingMaster|testEvenGridIncludesNyquistEnergyWithOneSidedWeighting|testPartialLegsAtSessionAndGapStartRetainBoundaryUncertainty'
```

Observed result: 3 tests, 9 assertion failures (including the nil Nyquist metric unwrap). Log `/tmp/rideform-u6-fix-red.log`. It reproduced newly created files/directories inside the master through symlink parents, omitted Nyquist energy, and absent boundary uncertainty on both confirmed-onset and unconfirmed partial legs. Each test used disposable artifacts, preserving user sessions.

## Fixes and GREEN

- **Master isolation:** Resolve path components and their symlinks before appending nonexistent descendants. Relative, absolute and chained links are handled; existing ancestor device/inode identity handles alternate casing. The writer rejects master descendants before parent creation, writes to the canonical destination, and rechecks after creating the parent. Symlink loops and non-file URLs are `invalidSidecarPath`. Tests verify actual master sentinel bytes and directory inventory remain unchanged, including absent nested parents, an existing leaf, and an aliased master URL. Outside aliases with new descendant directories remain usable.
- **Nyquist energy:** Include bin N/2 for even N. One-sided real-signal energy doubles conjugate-paired bins and counts the unpaired Nyquist bin once. A 1e−12 relative band tolerance handles timestamp roundoff. For 100 samples at 50 Hz with rectangular window, alternating ±1 gives ratio 1; adding a unit-amplitude low-frequency cosine gives independently calculated ratio 2/3.
- **Incomplete boundaries:** All transitions starting at a segment boundary retain `onset_at_segment_boundary`, including active truncated/gap-interrupted and pending unconfirmed legs. Existing uncertainty flags, observed partial legs and nil endpoints remain visible.

After the production fixes, the isolated full package ran **39 tests, 0 failures**. Log `/tmp/rideform-u6-fix-green.log`. This snapshot includes the current diagnostics files from concurrent U7 work; it is worker evidence, not the coordinator's authoritative shared-workspace run. A final focused run after expanding path coverage ran **16 U6 tests, 0 failures**, log `/tmp/rideform-u6-fix-final.log`.

## Independent oracle

Fresh command: `python3 scripts/verify-analysis.py`.

Result: **10 grouped checks passed; failures []**. Artifacts and frozen source hashes are in `/tmp/rideform-u6-independent-rvzo5kem/report.json`; stdout is `/tmp/rideform-u6-fix-independent.log`. The independent oracle confirms saved hashes/configuration/master bytes, symlink isolation, irregular derivatives/integrals, orientation, phases/corrections/returns, summaries/filter/direct-cross/incomplete data, ordinary DFT/bandwidth/gaps, even-grid Nyquist energy, and truncated boundary uncertainty.

No master migration is performed. Current analysis defaults select v2, so derived sidecars keyed by the v1 configuration are not reused as v2 results. Original recordings and initial evidence remain intact. Physical mounting/sign checks, labeled real-session recomputation, matched raw/fused captures and approximately 50 garage transitions remain pending hardware gates.
