Skip to content

feat(proto): sync command protobuf definitions - #46

Merged
Bre77 merged 2 commits into
mainfrom
fm/tfa-proto-sync-r5
Jul 9, 2026
Merged

feat(proto): sync command protobuf definitions#46
Bre77 merged 2 commits into
mainfrom
fm/tfa-proto-sync-r5

Conversation

@Bre77

@Bre77 Bre77 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Intent

Rationalize this library's protobuf definitions against the newer Teslemetry/api command protos (fresh clone of Teslemetry/api, Release 944, at /home/brett/firstmate/projects/api/src/proto/command/, read-only reference) and bring the library's proto/ sources and generated Python bindings up to date. Pure proto/codegen task - deliberately does not touch the vehicle/BLE command classes (tesla_fleet_api/tesla/vehicle/*), which a separate crew owns.

Did a full semantic diff of all 9 shared proto files (common, errors, keys, managed_charging, signatures, vehicle, car_server, universal_message, vcsec) plus checked for protos present in one tree but not the other:

  • 6 of 9 shared protos were byte-identical - left untouched.
  • car_server.proto: the library was already AHEAD of the api tree (has SetLowPowerModeAction/SetKeepAccessoryPowerModeAction that the api tree lacks) - deliberately left untouched, did not remove/regress this.
  • vcsec.proto: the 550-line diff was pure formatting/brace-style (2-space K&R vs 4-space brace-on-own-line, import/option ordering) with zero semantic difference - deliberately left untouched to avoid a no-op reformat churning the file.
  • universal_message.proto: api tree added 3 new UniversalMessage.Domain enum values (DOMAIN_AUTHD=5, DOMAIN_ENERGY_DEVICE=7, DOMAIN_ENERGY_DEVICE_AUTH=8) - added these.
  • session.proto: entirely missing from the library - added it (Session.SessionStore message), matching the api tree's content and using the library's existing tesla/ import-namespacing convention from tools/regenerate_protos.sh. Nothing else in the api tree imports session.proto, so no cross-file import rewiring was needed.
  • teslapower.proto: confirmed this is library-specific (not in the api tree) and is deliberately NOT part of the codegen PROTOS list already (pre-existing, unrelated to this change) - left as-is per instructions to keep it.

Regeneration: no protoc was on PATH in this environment, so downloaded protoc v32.0 specifically (matching this library's documented HA-compatibility pin: gencode must be stamped <= 6.32.0 to match Home Assistant core's protobuf==6.32.0 pin, and protoc vX.Y stamps gencode 6.X.Y under unified protobuf versioning). Added session.proto to the PROTOS array and the 'own' import-rewrite set in tools/regenerate_protos.sh (the library's own documented codegen mechanism - found via that script's header comment), then ran it to regenerate all _pb2.py/_pb2.pyi files. Also manually added 'from . import session_pb2' to the hand-maintained tesla_fleet_api/tesla/vehicle/proto/init.pyi stub (this file is not touched by the regen script) for consistency with the other pb2 modules.

Verified: fresh Python import of the new/changed modules works, confirmed the new Domain enum values and SessionStore message are present at runtime, full existing pytest suite (58 tests) passes, pyright strict mode reports 0 errors, ruff check passes. Reverted unrelated uv.lock/egg-info version drift (1.5.2 -> 1.5.4) that running 'uv run' commands caused as a side effect - that drift predates this task and is out of scope.

What Changed

  • Added the missing session.proto source plus generated session_pb2 bindings and exported the new module from the proto package stub.
  • Synced universal_message.proto and generated bindings with the new DOMAIN_AUTHD, DOMAIN_ENERGY_DEVICE, and DOMAIN_ENERGY_DEVICE_AUTH enum values.
  • Updated the proto regeneration script and AGENTS guidance so session.proto is included in future protobuf code generation.

Risk Assessment

✅ Low: The change is narrowly scoped to protobuf source updates, generated bindings, and regeneration script wiring, with no material correctness, packaging, or compatibility issues found in the reviewed diff.

Testing

Exercised the existing pytest suite plus an end-user style Python import/serialization check showing the new protobuf enum values and SessionStore binding work at runtime; all checks passed and the worktree was cleaned afterward.

Evidence: Runtime protobuf evidence
Tesla Fleet API generated protobuf runtime evidence
installed protobuf runtime: 7.34.1

UniversalMessage.Domain values available to client code:
  DOMAIN_AUTHD = 5 (DOMAIN_AUTHD); reference: DOMAIN_AUTHD = 5;
  DOMAIN_ENERGY_DEVICE = 7 (DOMAIN_ENERGY_DEVICE); reference: DOMAIN_ENERGY_DEVICE = 7;
  DOMAIN_ENERGY_DEVICE_AUTH = 8 (DOMAIN_ENERGY_DEVICE_AUTH); reference: DOMAIN_ENERGY_DEVICE_AUTH = 8;
  generated descriptor numbers: [0, 2, 3, 5, 7, 8]

RoutableMessage round-trip using new energy-device domain:
  parsed domain name: DOMAIN_ENERGY_DEVICE
  parsed destination oneof: domain
  parsed payload: b'payload'

SessionStore message imported, serialized, and parsed:
  descriptor full name: Session.SessionStore
  fields: ['public_key', 'epoch', 'delta', 'lock']
  parsed public_key=b'pub', epoch=b'epoch', delta=42, lock.seconds=1234567890
  package stub exposes session_pb2: True

session_pb2 gencode compatibility stamp: (6, 32, 0)
expected Home Assistant-compatible maximum from project docs: (6, 32, 0)

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
  • Created /tmp/no-mistakes-evidence/01KX2XG5GW600W025MRRS76KMQ/proto_runtime_evidence.txt by importing universal_message_pb2 and session_pb2, checking the new Domain enum values against the Teslemetry/api reference proto, round-tripping a RoutableMessage using DOMAIN_ENERGY_DEVICE, round-tripping SessionStore, and confirming the generated protobuf stamp is (6, 32, 0).
  • Cleaned transient test artifacts from the worktree and confirmed git status --short was clean.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

firstmate crewmate added 2 commits July 9, 2026 17:44
…n.proto

Semantic-diffed the library's proto/ against Teslemetry/api's
src/proto/command/ (Release 944). Most shared protos were already
identical; the only real deltas were three new UniversalMessage.Domain
enum values and the session.proto file the library was missing.

- Add session.proto (Session.SessionStore) with its google/protobuf
  timestamp import, following the existing proto/tesla/ namespacing
  convention in tools/regenerate_protos.sh.
- Add DOMAIN_AUTHD, DOMAIN_ENERGY_DEVICE, DOMAIN_ENERGY_DEVICE_AUTH to
  universal_message.proto's Domain enum.
- vcsec.proto's diff was pure formatting (brace/indent style); no
  semantic changes needed. car_server.proto already carries
  SetLowPowerModeAction/SetKeepAccessoryPowerModeAction that the
  api tree lacks, so it was left untouched. teslapower.proto stays
  as the library-specific, non-generated proto it already was.
- Regenerated Python bindings with protoc v32.0 (matching the
  HA-compatible 6.32.0 gencode pin documented in AGENTS.md).
@Bre77
Bre77 merged commit 1e94661 into main Jul 9, 2026
4 of 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