Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

test(config): pin fatal validation branches (PIN-313)

Luigi Agosti614ec9c244b0
diff --git a/internal/config/validate_fatal_census_test.go b/internal/config/validate_fatal_census_test.go
index d9f3561d..b56bab98 100644
--- a/internal/config/validate_fatal_census_test.go
+++ b/internal/config/validate_fatal_census_test.go
@@ -12,8 +12,16 @@ import (
"testing"
)
-var fatalAtLoadMembers = map[string]string{
- "sessions.agent.mode": "an uninterpretable authentication posture must not silently fall back to a weaker mode",
+type fatalAtLoadMember struct {
+ reason string
+ declarations int
+}
+
+var fatalAtLoadMembers = map[string]fatalAtLoadMember{
+ "sessions.agent.mode": {
+ reason: "an uninterpretable authentication posture must not silently fall back to a weaker mode",
+ declarations: 2, // the unsupported-required and invalid-value refusals are both fatal
+ },
}
func TestFatalAtLoadMembershipIsExplicitAndExhaustive(t *testing.T) {
@@ -90,13 +98,13 @@ func fatalAtLoadDeclarations(files map[string]*ast.File) ([]string, int) {
return fields, literals
}
-func fatalAtLoadCensusProblems(fields []string, literals int, expected map[string]string) []string {
+func fatalAtLoadCensusProblems(fields []string, literals int, expected map[string]fatalAtLoadMember) []string {
if literals < 20 {
return []string{fmt.Sprintf("found only %d ValidationError literals; the census is no longer walking the validator", literals)}
}
- actual := map[string]bool{}
+ actual := map[string]int{}
for _, field := range fields {
- actual[field] = true
+ actual[field]++
}
var problems []string
for field := range actual {
@@ -104,12 +112,12 @@ func fatalAtLoadCensusProblems(fields []string, literals int, expected map[strin
problems = append(problems, fmt.Sprintf("%s newly declares FatalAtLoad; add it to fatalAtLoadMembers with the deliberate reason", field))
}
}
- for field, reason := range expected {
- if strings.TrimSpace(reason) == "" {
+ for field, member := range expected {
+ if strings.TrimSpace(member.reason) == "" {
problems = append(problems, fmt.Sprintf("%s has no recorded reason for being fatal at load", field))
}
- if !actual[field] {
- problems = append(problems, fmt.Sprintf("%s is recorded as fatal at load but no declaration remains", field))
+ if actual[field] != member.declarations {
+ problems = append(problems, fmt.Sprintf("%s has %d fatal-at-load declaration(s), want %d; a validation branch was added or stopped gating startup", field, actual[field], member.declarations))
}
}
sort.Strings(problems)
@@ -125,11 +133,13 @@ func TestFatalAtLoadCensusMutationsTurnRed(t *testing.T) {
}{
{"new member", `package config
var _ = ValidationError{Field: "sessions.agent.mode", FatalAtLoad: true}
+var _ = ValidationError{Field: "sessions.agent.mode", FatalAtLoad: true}
var _ = ValidationError{Field: "server.logLevel", FatalAtLoad: true}
`, "server.logLevel newly declares FatalAtLoad"},
{"removed member", `package config
+var _ = ValidationError{Field: "sessions.agent.mode", FatalAtLoad: true}
var _ = ValidationError{Field: "sessions.agent.mode"}
-`, "sessions.agent.mode is recorded as fatal at load but no declaration remains"},
+`, "sessions.agent.mode has 1 fatal-at-load declaration(s), want 2"},
{"vacuous walk", "package config\n", "census is no longer walking the validator"},
} {
t.Run(tc.name, func(t *testing.T) {