Skip to content

test(vehicle): cover BLE closures and locks commands#50

Merged
Bre77 merged 3 commits into
mainfrom
fm/tfa-ble-pr3-closures-c5
Jul 9, 2026
Merged

test(vehicle): cover BLE closures and locks commands#50
Bre77 merged 3 commits into
mainfrom
fm/tfa-ble-pr3-closures-c5

Conversation

@Bre77

@Bre77 Bre77 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Intent

PR-3 of the BLE production-readiness program: first live-actuation batch for the closures/locks command group (door_lock, door_unlock, auto_secure_vehicle, charge_port_door_open/close, and the 8 individual door open/close commands). This is HOLD-FOR-CAPTAIN: it introduces the first real BLE actuation of the car, testable safely because these are inherited Commands methods already present on VehicleBluetooth (verification work, not new command implementations).

Delivered: mocked-transport regression tests (tests/test_ble_mocked_closures_locks.py) covering all 12 commands in the group, following the existing MockedBleTransportTestCase pattern from PR-0/1. door_lock already had coverage in test_ble_mocked_commands.py.

Live verification against the real car (VIN LRW3F7EK4NC716336, Model 3, via the git-excluded scripts/ble-harness/ helper and m5-btproxy.local): door_lock, door_unlock, and auto_secure_vehicle were each live-verified with a full snapshot->act->verify->restore->confirm cycle and all passed. Deliberate scope reduction, confirmed with the human operator (firstmate/captain) before shipping:

  • charge_port_door_open/close: NOT live-tested. The test car currently has a charge cable physically engaged (conn_charge_cable=IEC, charge_port_latch=Engaged), so actuating the charge port door live was judged unsafe (could conflict with the physical connector). Shipped as mocked-transport unit tests only.
  • The 8 individual door commands: only one (open/close_rear_passenger_door) was live-probed, per an explicit brief instruction to test exactly one door first and inspect reliability before deciding on the rest. That probe confirmed a real hardware limitation: open_*_door() unlatches the door over BLE, but there is no reliable powered close on this Model 3 - close_rear_passenger_door() returned an OK ack but the door did not physically re-latch (confirmed via closures_state().door_open_passenger_rear staying True), leaving the physical door ajar until a human pushed it shut. Given that finding, the human operator explicitly decided to defer all further individual door-open live testing to a captain-present session and ship all 8 as mocked-transport unit tests only - the same treatment as the existing CAPTAIN-PRESENT-ONLY group (honk_horn, actuate_trunk, etc.) in the program's master plan. No further doors were opened after that decision.

Also fixed, along the way: a real bug in the (git-excluded, not part of this diff) live-test harness script (scripts/ble-harness/ble_harness.py) - its door_lock/door_unlock CommandSpec restore conditions were inverted, which caused one real restore failure during testing (the harness tried to unlock the car when it should not have). This was caught immediately, the car was manually confirmed re-locked via a read-only state check before any further testing, and the harness logic was corrected before continuing. This harness fix is NOT part of the shipped diff (the directory is git-excluded local tooling) but is noted here for context on why one of the live-test transcripts shows a transient restore failure that was not a library bug.

Documentation: added a 'BLE individual-door powered-close gotcha' entry to AGENTS.md documenting the no-powered-close finding for future crews (e.g. the captain-present PR-CAP session), and a live-verify-status docstring in the new test module clarifying which commands are live-verified vs. unit-test-only-pending-captain-session.

End state: car confirmed locked (door_lock/door_unlock/auto_secure_vehicle tests left it locked); the rear passenger door required a human to physically push it shut after the live probe (outside the scope of anything further I could do remotely).

What Changed

  • Added mocked BLE transport regression coverage for door_unlock, auto_secure_vehicle, charge-port door open/close, and the 8 individual Bluetooth door commands, including signed VCSEC payload assertions.
  • Clarified VehicleBluetooth individual door docstrings and Bluetooth docs so close-command OK acknowledgements are not treated as proof that a door physically latched.
  • Documented the live-verified powered-close caveat for future BLE door testing sessions; pipeline passed intent, rebase, review, targeted/full pytest, docs, lint, and push checks.

Risk Assessment

✅ Low: The change is limited to mocked BLE regression tests and a documentation note, with no runtime library behavior changed.

Testing

Targeted mocked BLE closures/locks tests passed, a reviewer-visible JSON transcript was generated showing public API calls, success responses, routed VCSEC domain, and decoded payloads for all commands in scope, then the full test suite passed.

Evidence: BLE closures/locks mocked API transcript
{
  "records": [
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "RKEAction",
      "decoded_value": 1,
      "decoded_value_name": "RKE_ACTION_LOCK",
      "decoded_vcsec_oneof": "RKEAction",
      "public_api_call": "await vehicle.door_lock()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "RKEAction",
      "decoded_value": 0,
      "decoded_value_name": "RKE_ACTION_UNLOCK",
      "decoded_vcsec_oneof": "RKEAction",
      "public_api_call": "await vehicle.door_unlock()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "RKEAction",
      "decoded_value": 29,
      "decoded_value_name": "RKE_ACTION_AUTO_SECURE_VEHICLE",
      "decoded_vcsec_oneof": "RKEAction",
      "public_api_call": "await vehicle.auto_secure_vehicle()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.chargePort",
      "decoded_value": 3,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_OPEN",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.charge_port_door_open()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.chargePort",
      "decoded_value": 4,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_CLOSE",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.charge_port_door_close()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.frontDriverDoor",
      "decoded_value": 3,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_OPEN",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.open_front_driver_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.frontDriverDoor",
      "decoded_value": 4,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_CLOSE",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.close_front_driver_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.frontPassengerDoor",
      "decoded_value": 3,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_OPEN",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.open_front_passenger_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.frontPassengerDoor",
      "decoded_value": 4,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_CLOSE",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.close_front_passenger_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.rearDriverDoor",
      "decoded_value": 3,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_OPEN",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.open_rear_driver_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.rearDriverDoor",
      "decoded_value": 4,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_CLOSE",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.close_rear_driver_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.rearPassengerDoor",
      "decoded_value": 3,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_OPEN",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.open_rear_passenger_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    },
    {
      "caller_observed_result": {
        "response": {
          "reason": "",
          "result": true
        }
      },
      "decoded_surface": "closureMoveRequest.rearPassengerDoor",
      "decoded_value": 4,
      "decoded_value_name": "CLOSURE_MOVE_TYPE_CLOSE",
      "decoded_vcsec_oneof": "closureMoveRequest",
      "other_closure_fields": {
        "chargePort": "CLOSURE_MOVE_TYPE_NONE",
        "frontDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontPassengerDoor": "CLOSURE_MOVE_TYPE_NONE",
        "frontTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "rearDriverDoor": "CLOSURE_MOVE_TYPE_NONE",
        "rearTrunk": "CLOSURE_MOVE_TYPE_NONE",
        "tonneau": "CLOSURE_MOVE_TYPE_NONE"
      },
      "public_api_call": "await vehicle.close_rear_passenger_door()",
      "signed_message_domain": "DOMAIN_VEHICLE_SECURITY"
    }
  ],
  "scenario": "mocked VehicleBluetooth public API calls for BLE closures/locks"
}

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_ble_mocked_commands.py::DoorLockTests tests/test_ble_mocked_closures_locks.py
  • Generated /tmp/no-mistakes-evidence/01KX34DE1QENP22ECF5C21GS3R/ble_closures_locks_mocked_api_transcript.json by exercising each VehicleBluetooth closures/locks method against the mocked BLE transport and decoding the signed VCSEC payloads
  • uv run pytest tests
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

firstmate crewmate added 3 commits July 9, 2026 19:44
Covers door_unlock, auto_secure_vehicle, charge_port_door_open/close, and
the 8 individual door commands (door_lock already had coverage). Live-verify
against the test car confirmed door_lock/door_unlock/auto_secure_vehicle
round-trip correctly; charge_port_door_* and 7 of 8 individual doors are
deferred (see AGENTS.md gotcha) so this PR ships mocked-transport regression
tests for the full group with live-verify status tracked separately.
Records which commands are live-verified (locks) vs unit-test-only pending
a captain-present session (charge port cable was engaged; individual doors
leave a door physically ajar with no powered close on this Model 3).
@Bre77 Bre77 merged commit 3659f00 into main Jul 9, 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