Add maintainer tool to validate Tesla field semantics against prod NATS#8
Closed
Bre77 wants to merge 1 commit into
Closed
Add maintainer tool to validate Tesla field semantics against prod NATS#8Bre77 wants to merge 1 commit into
Bre77 wants to merge 1 commit into
Conversation
Promotes the proven cache-validation recipe (data/chargeport-null-validate-v4) into a committed, reusable script: scripts/tesla_cache_validate.py reads the live na_cache/eu_cache NATS KV buckets (vehicle_data, streamed signals, and energy live_status/site_info, both regions) to answer per-field questions - tri-state vs true-or-absent, observed value domains, presence rates - instead of leaving that confirmation as one-off archaeology. Read-only and offline: never calls nats kv get (proven to silently read empty on these buckets, per the recipe), only nats stream get --last-for -j; never writes to NATS; not exercised by CI, which has no prod access. Presence classification uses has-key semantics and a non-empty-read guard so a fetch failure or silent-empty read can never be mistaken for a genuine "absent" finding. Raw records are sanitized by default (VIN/tokens/geo redacted, type-preserved) except for the maintainer's own reference vehicle/site. Phase 1 of the executable-schema roadmap; the Field/Presence registry and fixtures module (phases 2+) are intentionally not implemented here.
Member
Author
|
Closing on the captain's review: the tool embeds Teslemetry-internal details (KV bucket naming and prod topology) that must not live in a public library repo. It is moving to a private Teslemetry repo; the public libs will still receive the sanitized golden fixtures (vehicle/site data approved) in the later roadmap phases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
api-tesla-schema-fixtures-n6): promote the one-off prod-cache validation recipe into a committed, reusable maintainer script.data/chargeport-null-validate-v4/report.md) settledcharge_state.charge_port_door_openas a genuine tri-state (431/723 vehicles report explicitfalse) - proving the method works, but leaving nothing reusable behind.b72b9a9(six streamed fields silently mistyped until hand-checked against na_cache) is the same failure mode on the streaming side.scripts/tesla_cache_validate.py: a read-only CLI that queries the livena_cache/eu_cacheNATS KV buckets to answer, per field: is it tri-state or true-or-absent, what value domain is actually observed, what's the presence rate across the fleet.<VIN>.vehicle_data), streamed Fleet Telemetry signals (<VIN>.data.<Signal>), and energylive_status/site_info(energy_sites.<id>.*) - bothna_andeu_regions.nats stream get --last-for ... -j(nevernats kv get, which silently reads empty on these buckets), has-key presence classification (never truthiness), and a non-empty-read guard that refuses to emit a report if every fetch failed or decoded empty.natscontext (name configurable via--context; no endpoint or credential is hardcoded).tests/test_cache_validate_logic.py, safe for CI even though the tool itself isn't exercised there.provenanceline ready to paste into a field's registry entry once phase 3 exists.Field/Presenceregistry or thefixtures/module (phases 2-3 of the roadmap) - those are separate, later PRs.What Changed
scripts/tesla_cache_validate.py- the CLI tool (argparse; stdlib only, no new dependencies).scripts/README.md- usage, the four record shapes, and the reliability guards.tests/test_cache_validate_logic.py- offline unit tests for the pure logic (extraction, envelope unwrapping, sanitization, presence-shape inference, key discovery), modeled on the real corpus shape.AGENTS.md/CLAUDE.md- new project memory file documenting thescripts/convention (prod-touching, CI-exempt tooling) for future maintainers.Risk Assessment
Low. Additive only; touches no existing package code. The script is read-only against prod (verified live during development - see Testing) and has no write path. Not wired into CI.
Testing
python3 tests/test_cache_validate_logic.py- all 21 assertions pass.uvx mypy --strict scripts/tesla_cache_validate.py- clean.na_cache/eu_cachebuckets (read-only) for all four record kinds during development:vehicle_data(with cross-tab),signal,energy_live_status, andenergy_site_info- including exercising the non-empty-read guard (trips correctly on a forced-failure timeout) and--save-rawsanitization (redacts nested VIN/din, preserves numeric shape; passes through unredacted for the preferred vehicle/site).Full narrative / original brief
Tesla executable-schema roadmap PHASE 1 ONLY: promote the proven prod-cache validation recipe into a committed, reusable maintainer tool.
Required reading:
api-tesla-schema-fixtures-n6/report.md(design + phased roadmap) andchargeport-null-validate-v4/report.md(the proven validation recipe this tool codifies, with raw corpus).Deliverable: a maintainer script (
scripts/) that validates Tesla field semantics against the live prod NATS KV caches - vehicle AND energy, na_ and eu_ buckets - answering per-field questions like tri-state vs true-or-absent, observed value domains, and presence rates across the fleet.Reliability guards baked in: the reliable
nats stream get --last-forread path (plainnats kv getreliably times out); always verify the scan read at least one non-empty value before trusting any absent-record conclusion; offline/read-only (never writes to prod NATS; CI never runs it).Captain rulings in force (2026-07-07): real customer values may appear in outputs/fixtures - prefer the captain's own vehicle (VIN LRW3F7EK4NC716336) and energy site (2533979794926773); other customers' data must be sanitized but shape-valid. Output should make the later fixture-seeding phase (phase 2) easy, but do not implement phase 2 (no fixtures/ module, no registry) - one phase, one PR.