High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix(ci): enrol the audit CLI implementation and guard every audit source against the map
Luigi Agostide1270e21824
diff --git a/TESTING.md b/TESTING.mdindex c05a95ff..6443f3e5 100644--- a/TESTING.md+++ b/TESTING.md@@ -76,10 +76,12 @@ The map reads product paths as well as test paths:| `tests/e2e/scenarios/<group>/*-smoke.sh` | `smoke` || any other `*.sh` under `tests/e2e/scenarios/api/`, `cli/` or `infra/` | that group's extended suite || `Dockerfile`, `.dockerignore`, `scripts/docker-*smoke.sh`, the smoke Dockerfile and workflows | `smoke` |-| audit implementation — `internal/audit/`, `pkg/pinchtabaudit/`, the audit handlers, `cmd/pinchtab/cmd_audit*` | `api-extended`, `cli-extended` |+| audit implementation — `internal/audit/`, `pkg/pinchtabaudit/`, the audit handlers, `internal/cli/actions/actions_audit*`, `cmd/pinchtab/cmd_audit*` | `api-extended`, `cli-extended` |Covering a new product area is one line in the map. `go test ./internal/devtools/` drives the script over synthetic file lists, so a mapping is verified by running it rather than by reading the YAML. Extended coverage the map does not claim still runs on `workflow_dispatch` only.+Audit is also declared there as an *enrolled area*: every tracked audit source file must escalate the audit suites, with a short exclusion list for files that only share the word (`internal/authn/audit.go` is security audit logging). So a new file in an enrolled family cannot quietly miss the map — which is how the CLI audit implementation went unenrolled while its cobra wrapper was covered. Enrolling a second area is one entry in `enrolledAreas`.+### Basic Suites```bashdiff --git a/internal/devtools/e2e_escalation_test.go b/internal/devtools/e2e_escalation_test.goindex 795e07d9..db872b5b 100644--- a/internal/devtools/e2e_escalation_test.go+++ b/internal/devtools/e2e_escalation_test.go@@ -30,6 +30,11 @@ func TestEscalationFollowsProductPathsAndTestPaths(t *testing.T) {changed: []string{"internal/audit/run.go", "pkg/pinchtabaudit/client.go", "internal/handlers/audit.go", "cmd/pinchtab/cmd_audit.go"},want: []string{"run_api_extended", "run_cli_extended"},},+ {+ name: "audit CLI implementation rather than its command wrapper",+ changed: []string{"internal/cli/actions/actions_audit.go"},+ want: []string{"run_api_extended", "run_cli_extended"},+ },{name: "audit implementation alongside a basic scenario",changed: []string{"internal/audit/enrich.go", "tests/e2e/scenarios/api/audit-basic.sh"},@@ -219,3 +224,85 @@ func readRepoFile(t *testing.T, root, rel string) string {}return string(body)}++type enrolledArea struct {+ name string+ match string+ suites []string+ excluded map[string]string+}++var enrolledAreas = []enrolledArea{+ {+ name: "audit",+ match: `(?i)audit`,+ suites: []string{"run_api_extended", "run_cli_extended"},+ excluded: map[string]string{+ "internal/authn/audit.go": "security audit logging — AuditLog writes slog entries, a different sense of the word, covered by no audit scenario",+ },+ },+}++func TestEveryEnrolledAreaIsCoveredByTheMap(t *testing.T) {+ root := repoRoot(t)+ tracked := trackedPaths(t, root)++ for _, area := range enrolledAreas {+ t.Run(area.name, func(t *testing.T) {+ pattern, err := regexp.Compile(area.match)+ if err != nil {+ t.Fatalf("area %q has an unusable match %q: %v", area.name, area.match, err)+ }++ var sources []string+ for _, path := range tracked {+ if isAreaSource(path) && pattern.MatchString(path) {+ sources = append(sources, path)+ }+ }+ if len(sources) < 2 {+ t.Fatalf("area %q matches %d source files; the match has stopped finding the area and this guard would pass vacuously", area.name, len(sources))+ }++ usedExclusion := map[string]bool{}+ for _, path := range sources {+ escalated := detectSuites(t, root, []string{path})+ if why, excluded := area.excluded[path]; excluded {+ usedExclusion[path] = true+ if len(escalated) > 0 {+ t.Errorf("%s is excluded from the %s area (%s) yet escalates %v; drop the exclusion rather than keeping a claim the map contradicts", path, area.name, why, escalated)+ }+ continue+ }+ for _, want := range area.suites {+ if !containsString(escalated, want) {+ t.Errorf("%s is %s implementation but escalates %v, not %s; the extended scenarios covering %s never fire on the diff most likely to break them",+ path, area.name, escalated, want, area.name)+ }+ }+ }++ for path, why := range area.excluded {+ if !usedExclusion[path] {+ t.Errorf("%s is excluded from the %s area (%s) but is no longer a source file the area matches; drop the exclusion or re-point it", path, area.name, why)+ }+ }+ })+ }+}++func isAreaSource(path string) bool {+ if !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {+ return false+ }+ return !strings.HasPrefix(path, "tests/")+}++func containsString(values []string, want string) bool {+ for _, v := range values {+ if v == want {+ return true+ }+ }+ return false+}diff --git a/scripts/ci/e2e-escalation.map b/scripts/ci/e2e-escalation.mapindex 9ff58958..ba192f81 100644--- a/scripts/ci/e2e-escalation.map+++ b/scripts/ci/e2e-escalation.map@@ -18,4 +18,5 @@^internal/audit/ api-extended cli-extended^pkg/pinchtabaudit/ api-extended cli-extended^internal/handlers/(a11y_)?audit api-extended cli-extended+^internal/cli/actions/actions_audit api-extended cli-extended^cmd/pinchtab/cmd_audit api-extended cli-extended