Skip to content

fix(vehicle): align BLE and cloud command parity#60

Merged
Bre77 merged 5 commits into
mainfrom
fm/tfa-ble-parity-cloud-vs-ble
Jul 10, 2026
Merged

fix(vehicle): align BLE and cloud command parity#60
Bre77 merged 5 commits into
mainfrom
fm/tfa-ble-parity-cloud-vs-ble

Conversation

@Bre77

@Bre77 Bre77 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Intent

BLE program capstone: audit cross-transport parity between the Teslemetry/Fleet cloud REST command path (VehicleFleet) and the BLE signed-command protobuf path (Commands/VehicleBluetooth), verifying that the same Python call builds semantically equivalent vehicle instructions on both transports. Fix genuine parameter-handling mismatches; leave documented form differences and response-body form differences (REST JSON dict vs decoded protobuf) alone.

Two genuine cross-transport bugs found and fixed, one commit each with cross-transport mocked tests:

  1. trigger_homelink on the REST path (fleet.py) used a truthy 'if lat and lon' guard that silently dropped a valid 0.0 latitude/longitude, while the BLE path already correctly uses 'is not None'. Fixed REST to match BLE semantics so 0.0 coordinates are forwarded.
  2. adjust_volume validated the 0.0-11.0 range only on the cloud path; the BLE path forwarded any float to the car unchecked. Added the identical guard (verbatim ValueError message) to the BLE path so both reject the same inputs.

Deliberate decisions a diff reader won't know: I intentionally did NOT 'fix' several form differences that look like asymmetries but are protocol reality - set_scheduled_departure's preconditioning_enabled/off_peak_charging_enabled (no proto fields), window_control lat/lon and navigation_sc_request id (no proto fields), navigation_request type/locale/timestamp_ms (REST share-intent framing), and media_volume_up (no Tesla REST endpoint, BLE-only). I also deliberately LEFT UNFIXED two suspected divergences that need live car verification and are security/behavior-sensitive: clear_pin_to_drive_admin builds DrivingClearSpeedLimitPinAction (speed-limit PIN, not PIN-to-Drive - suspected mismapping) and navigation_gps_request's order param is required on BLE but optional on cloud (null-order wire semantics undecided). These are documented in AGENTS.md and flagged in the report for the captain rather than changed autonomously. New test file tests/test_cross_transport_parity.py exercises both transports with mocked _request and mocked _send. Live cloud/BLE/stream execution was not driven autonomously (single-held BLE connection, physical-car risk); parity determination is code-authoritative.

What Changed

  • Fixed cross-transport parameter handling mismatches so REST trigger_homelink preserves valid 0.0 coordinates and BLE adjust_volume enforces the same 0.0-11.0 range as the cloud path.
  • Added mocked cross-transport parity coverage for cloud REST vs BLE signed-command construction, including documented protocol/form differences that should not be normalized.
  • Updated BLE and signed-command docs with the parity findings and known follow-up divergences.

Risk Assessment

✅ Low: The branch is narrowly scoped to two parity fixes plus focused mocked coverage, and I did not find material correctness, security, performance, or maintainability risks in the changed code.

Testing

Exercised the new cross-transport parity tests, an evidence-producing mocked cloud/BLE command probe, and the full pytest suite; all passed, with reviewer-visible JSON evidence captured under /tmp/no-mistakes-evidence/01KX525PX40B34XPPARFMRXD3Y.

Evidence: Cross-transport parity evidence
{
  "adjust_volume_11_5_ble_rejection": {
    "error": "Volume must a number from 0.0 to 11.0",
    "outbound_call_count": 0
  },
  "adjust_volume_11_5_cloud_rejection": {
    "error": "Volume must a number from 0.0 to 11.0",
    "outbound_call_count": 0
  },
  "adjust_volume_5_0_ble_protobuf": {
    "volume_absolute_float": 5.0
  },
  "adjust_volume_5_0_cloud_rest_json": {
    "volume": 5.0
  },
  "trigger_homelink_zero_coordinates_ble_protobuf": {
    "latitude": 0.0,
    "location_present": true,
    "longitude": 0.0,
    "token": "tok"
  },
  "trigger_homelink_zero_coordinates_cloud_rest_json": {
    "lat": 0.0,
    "lon": 0.0,
    "token": "tok"
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • uv run pytest tests/test_cross_transport_parity.py tests/test_ble_mocked_media_commands.py -q
  • uv run python - <<'PY' | tee /tmp/no-mistakes-evidence/01KX525PX40B34XPPARFMRXD3Y/cross_transport_parity_evidence.json
  • uv run pytest tests -q
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

firstmate crewmate added 5 commits July 10, 2026 13:42
trigger_homelink on the Fleet REST path gated lat/lon with a truthy
"if lat and lon" check, silently dropping a valid 0.0 coordinate. The
BLE signed-command path already guards with "is not None" and forwards
0.0 correctly, so the two transports built different instructions from
the same call. Match the REST path to the BLE semantics and lock the
parity in with a cross-transport test.
The Fleet REST adjust_volume rejected out-of-range volumes with a
ValueError before building the request; the BLE signed-command path
forwarded any float to the vehicle unchecked. Same call, different
behavior. Apply the identical 0.0-11.0 guard on the BLE path so both
transports reject the same inputs, and extend the cross-transport
parity test.
Document the parity contract between the Fleet REST and BLE signed-command
paths, the non-bug form differences that must not be "fixed", and the two
open divergences (clear_pin_to_drive_admin action mapping, navigation_gps_request
order signature) left for live verification.
A docstring should not announce a bugfix; the fix speaks for itself.
Restore the original trigger_homelink docstring in both commands.py
and fleet.py.
@Bre77
Bre77 merged commit a1af07a into main Jul 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant