Skip to content

Commit 07900e4

Browse files
atulmguptaCopilot
andcommitted
fix(ci): respect handler ratchet and recognize optional config bindings
Move analysis transport to its own v1 subpackage and teach config parity to recognize optional float bindings with a regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a4bf5d2 commit 07900e4

9 files changed

Lines changed: 23 additions & 8 deletions

File tree

docs/features/catalogue-tesla-physics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Sidebar group **Tesla Physics**. In the app, expand this section in the left nav
2525

2626
## Analysis boundaries
2727

28-
New HTTP routes use `internal/handler/v1` and the `physicssvc` / `sciencesvc`
28+
New HTTP routes use `internal/handler/v1/analysis` and the `physicssvc` / `sciencesvc`
2929
application services. The ledger uses recorded intervals, exposes gaps and row
3030
caps, and does not reconcile partial telemetry against a complete session.
3131
Explicit `Disconnected` state, not latch release, denotes unplugging.

internal/api/router.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ import (
407407
v1handlers "github.com/ev-dev-labs/teslasync/internal/handler/v1"
408408
actioncenterhandler "github.com/ev-dev-labs/teslasync/internal/handler/v1/actioncenter"
409409
advancedintelligencehandler "github.com/ev-dev-labs/teslasync/internal/handler/v1/advancedintelligence"
410+
analysishandler "github.com/ev-dev-labs/teslasync/internal/handler/v1/analysis"
410411
fleetstatehandler "github.com/ev-dev-labs/teslasync/internal/handler/v1/fleetstate"
411412
ownershipintelhandler "github.com/ev-dev-labs/teslasync/internal/handler/v1/ownershipintel"
412413
"github.com/ev-dev-labs/teslasync/internal/tracing"
@@ -1063,7 +1064,7 @@ func NewRouter(db *database.DB, teslaClient *tesla.Client, mqttClient *mqtt.Clie
10631064
// server-side, so the browser never downloads a raw counter history.
10641065
fsdInsightsHandler := apifsd.NewHandler(db)
10651066
physicsHandler := apiphysics.NewHandler(db, stateReader, liveStateReader)
1066-
physicsLedgerHandler := v1handlers.NewPhysicsLedgerHandler(physicssvc.New(db, stateReader, cfg))
1067+
physicsLedgerHandler := analysishandler.NewPhysicsLedgerHandler(physicssvc.New(db, stateReader, cfg))
10671068
var scienceWeather sciencesvc.HistoryFetcher
10681069
if cfg.Physics.WeatherEnabled {
10691070
client := apistormguard.NewClient()
@@ -1079,7 +1080,7 @@ func NewRouter(db *database.DB, teslaClient *tesla.Client, mqttClient *mqtt.Clie
10791080
return out, nil
10801081
}
10811082
}
1082-
scienceHandler := v1handlers.NewScienceHandler(sciencesvc.New(db, stateReader, cfg, scienceWeather))
1083+
scienceHandler := analysishandler.NewScienceHandler(sciencesvc.New(db, stateReader, cfg, scienceWeather))
10831084
if mqttClient != nil {
10841085
physicsHandler.WithMQTTConnected(func() *bool {
10851086
connected := mqttClient.IsConnected()

internal/handler/v1/analysis_handler.go renamed to internal/handler/v1/analysis/analysis_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package analysis
22

33
import (
44
"context"

internal/handler/v1/analysis_handler_test.go renamed to internal/handler/v1/analysis/analysis_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package analysis
22

33
import (
44
"net/http/httptest"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Package analysis provides thin v1 HTTP transport for physics and science reports.
2+
//
3+
// Layer: handler
4+
package analysis

internal/handler/v1/physics_ledger_handler.go renamed to internal/handler/v1/analysis/physics_ledger_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package analysis
22

33
import (
44
"context"

internal/handler/v1/science_handler.go renamed to internal/handler/v1/analysis/science_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package analysis
22

33
import (
44
"context"

internal/ops/parity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type ParitySnapshot struct {
6565
}
6666

6767
var (
68-
goEnvRe = regexp.MustCompile(`env(?:Str|Bool|Int|Int64|Float|Float64|Duration|StringSlice|CSV)\(\s*"([A-Z][A-Z0-9_]*)"`)
68+
goEnvRe = regexp.MustCompile(`env(?:Str|Bool|Int|Int64|Float|Float64|OptionalFloat64|Duration|StringSlice|CSV)\(\s*"([A-Z][A-Z0-9_]*)"`)
6969
goGetenvRe = regexp.MustCompile(`(?:os\.Getenv|getenv|LookupEnv)\(\s*"([A-Z][A-Z0-9_]*)"`)
7070
helmDataKeyRe = regexp.MustCompile(`(?m)^\s{2}([A-Z][A-Z0-9_]*):`)
7171
composeKVRe = regexp.MustCompile(`^([A-Z][A-Z0-9_]*)\s*[:=]`)

internal/ops/parity_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ func TestExtractGoEnvVars(t *testing.T) {
108108
if strings.Join(got, ",") != strings.Join(want, ",") {
109109
t.Fatalf("got %v, want %v", got, want)
110110
}
111+
112+
}
113+
114+
func TestExtractOptionalFloatBindings(t *testing.T) {
115+
source := `var mass = envOptionalFloat64("TESLASYNC_VEHICLE_MASS_KG")
116+
var dynamic = envOptionalFloat64(variableName)`
117+
got := ExtractGoEnvVars(source)
118+
if len(got) != 1 || got[0] != "TESLASYNC_VEHICLE_MASS_KG" {
119+
t.Fatalf("optional float binding not recognized: %v", got)
120+
}
111121
}
112122

113123
// TestExtractComposeEnvVars_BothFormsAndServiceScoping pins the two

0 commit comments

Comments
 (0)