BOLT-1322 [6/7] adapters/oem/tesla: sync internal endpoint POST /internal/tesla/vehicle/check-pairing-status
completedNew internal HTTP endpoint on the oem adapter that synchronously calls fleet_status, derives keyPaired + extendedCapabilities, returns within a single HTTP round-trip. No Kafka, no command.executed event published from this path.
Location: adapters/oem/src/routes/ (find the existing internal http surface — likely an Express/Fastify app exposing /internal/* endpoints already; mirror that pattern).
Endpoint contract:
POST /internal/manufacturers/tesla/vehicle/check-pairing-status
Body: { manufacturerDeviceId: string (VIN), manufacturerUserId: string }
200 Response: { keyPaired: boolean | null, extendedCapabilities?: Record<string, unknown> }
4xx: validation errors
5xx: tesla fleet_status unavailable / timed out (caller falls back to cached value)
Implementation:
1. Resolve the active Tesla connection for manufacturerUserId via connectionService.getLatestConnection (existing helper, see adapters/oem/src/manufacturers/tesla/events/command.issued/index.ts for the call site reference).
2. Call existing teslaService.getDevices(accessToken) — this is the same call used in publishDeviceStateUpdate; reuse it directly. From its response, extract keyPairedVins (Set) + vehicle_info for the VIN.
3. Call deriveKeyPaired(vin, keyPairedVins, vehicleInfo, undefined) — existing helper.
4. Call extractExtendedCapabilities(vin, vehicleInfo) — existing helper.
5. Return { keyPaired, extendedCapabilities }.
6. Wrap in standard adapter error handling (TeslaApiException → 502 with upstream error details; timeout → 504).
Timeout: set a hard 5s deadline on the fleet_status call so we never make Amazon wait forever.
Tests:
- Happy path: VIN in keyPairedVins set → keyPaired=true returned
- VIN not in set → keyPaired=false returned
- vehicle_command_protocol_required=false → keyPaired=null returned (per existing deriveKeyPaired semantics)
- Tesla API returns 5xx → endpoint returns 502
- Tesla API times out → endpoint returns 504
Branch: havoc/bolt-1322-tesla-sync-endpoint
Worktree: ../mono-bolt-1322-tesla-sync-endpoint
Depends on: nothing structurally (uses existing helpers)
Done when: endpoint test passes, branch builds, integrates cleanly into adapter http surface.
Event Timeline
created
status_change
queued → in_progress
failed
lease expired — re-queued for retry
in_progress → queued
status_change
queued → completed