Restore durable log ingest and typed plugin projections

This commit is contained in:
npc0-hue
2026-09-02 10:20:30 +08:00
parent 40ac46ba17
commit 6018d8f0fc
61 changed files with 809 additions and 3157 deletions
@@ -1,10 +1,6 @@
package companion
import (
"os"
"strings"
"testing"
)
import "testing"
func TestCompanionVehicleHandlerCapabilityIsExplicitAndBounded(t *testing.T) {
base := append([]string(nil), requiredCapabilities...)
@@ -18,29 +14,3 @@ func TestCompanionVehicleHandlerCapabilityIsExplicitAndBounded(t *testing.T) {
t.Fatal("undeclared raw command handler capability must be rejected")
}
}
func TestLoadConfigDeclaresRawTrajectoryCollection(t *testing.T) {
config := loadTestConfig(t)
if !config.Trajectory.Enabled || config.Trajectory.Source != TrajectorySourceSCUMSQLite || config.Trajectory.Store != TrajectoryStoreSharedPlatformMySQL {
t.Fatalf("trajectory collection is not enabled with plugin-owned source/store: %+v", config.Trajectory)
}
if config.Trajectory.FileEnv != SCUMDatabaseFileEnvironment || config.Trajectory.IntervalSeconds != DefaultTrajectoryCollectionIntervalSecs || config.Trajectory.MaxRows != DefaultTrajectoryCollectionMaxRows {
t.Fatalf("trajectory collection did not use bounded defaults: %+v", config.Trajectory)
}
}
func TestTrajectoryConfigRejectsUnsafeEnvironmentNames(t *testing.T) {
fixture := strings.ReplaceAll(string(mustReadConfigFixture(t)), "fileEnv: SCUM_DB_FILE", "fileEnv: PATH")
if _, err := LoadConfig(strings.NewReader(fixture)); err == nil || !strings.Contains(err.Error(), "environment") {
t.Fatalf("expected reserved env name to be rejected, got %v", err)
}
}
func mustReadConfigFixture(t *testing.T) []byte {
t.Helper()
payload, err := os.ReadFile("config.yaml.example")
if err != nil {
t.Fatalf("read config fixture: %v", err)
}
return payload
}