Skip to content

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

test: require a floor on every measured preamble surface and guard its CI trigger

Luigi Agostie2704e5acf27
diff --git a/internal/mcp/preamble_budget_test.go b/internal/mcp/preamble_budget_test.go
index 765d8edb..891b8b25 100644
--- a/internal/mcp/preamble_budget_test.go
+++ b/internal/mcp/preamble_budget_test.go
@@ -10,10 +10,13 @@ import (
"testing"
"github.com/mark3labs/mcp-go/mcp"
+ "gopkg.in/yaml.v3"
)
const preambleBudgetPath = "testdata/preamble_budget.json"
+const ciWorkflowPath = ".github/workflows/ci-go.yml"
+
const toolPayloadSurface = "mcp:allTools"
var fileSurfaces = []string{"skills/pinchtab-mcp/SKILL.md", "skills/pinchtab/SKILL.md"}
@@ -179,6 +182,9 @@ func TestAgentPreambleStaysWithinBudget(t *testing.T) {
t.Errorf("%s is measured but carries no budget in %s; record today's number there so the surface can only ratchet down", measurement.surface, preambleBudgetPath)
continue
}
+ if budget.MinBytes <= 0 {
+ t.Errorf("%s carries a budget but no floor in %s; a missing minBytes reads as 0, which silently disables the deletion guard for this surface — record a floor beside its budget", measurement.surface, preambleBudgetPath)
+ }
if measurement.bytes > budget.MaxBytes {
over := measurement.bytes - budget.MaxBytes
t.Errorf("%s is %d bytes (~%d tokens), %d bytes (~%d tokens) over the budget of %d recorded on %s at %s; shrink the surface, or raise the budget as a deliberate line in this diff",
@@ -190,3 +196,62 @@ func TestAgentPreambleStaysWithinBudget(t *testing.T) {
}
}
}
+
+type ciTriggerFilter struct {
+ Paths []string `yaml:"paths"`
+ PathsIgnore []string `yaml:"paths-ignore"`
+}
+
+type ciWorkflowTriggers struct {
+ On struct {
+ Push ciTriggerFilter `yaml:"push"`
+ PullRequest ciTriggerFilter `yaml:"pull_request"`
+ } `yaml:"on"`
+}
+
+type ciTrigger struct {
+ name string
+ filter ciTriggerFilter
+}
+
+func loadCITriggers(t *testing.T) []ciTrigger {
+ t.Helper()
+ body, err := os.ReadFile(filepath.Join("..", "..", ciWorkflowPath))
+ if err != nil {
+ t.Fatalf("cannot read %s, so nothing checks that CI runs on the surfaces this file measures: %v", ciWorkflowPath, err)
+ }
+ var workflow ciWorkflowTriggers
+ if err := yaml.Unmarshal(body, &workflow); err != nil {
+ t.Fatalf("cannot parse %s: %v", ciWorkflowPath, err)
+ }
+ return []ciTrigger{
+ {name: "push", filter: workflow.On.Push},
+ {name: "pull_request", filter: workflow.On.PullRequest},
+ }
+}
+
+func TestEveryMeasuredFileSurfaceTriggersCI(t *testing.T) {
+ if len(fileSurfaces) == 0 {
+ t.Fatalf("fileSurfaces is empty, so this guard has nothing to look for in %s", ciWorkflowPath)
+ }
+ for _, trigger := range loadCITriggers(t) {
+ if len(trigger.filter.PathsIgnore) > 0 {
+ t.Errorf("%s filters its %s trigger with paths-ignore, which cannot re-include a measured surface once a broad pattern excludes it — that is how skills/** kept a SKILL.md growth from ever reaching the Go suite; express the filter as paths so every measured surface is named",
+ ciWorkflowPath, trigger.name)
+ continue
+ }
+ if len(trigger.filter.Paths) == 0 {
+ continue
+ }
+ listed := make(map[string]bool, len(trigger.filter.Paths))
+ for _, pattern := range trigger.filter.Paths {
+ listed[pattern] = true
+ }
+ for _, surface := range fileSurfaces {
+ if !listed[surface] {
+ t.Errorf("%s is measured here but is not listed in the %s paths filter of %s; the filter excludes documentation by default, so a PR touching only that file skips the Go suite entirely and its budget goes unchecked on exactly the change that can breach it — add the surface to both triggers whenever it is added here",
+ surface, trigger.name, ciWorkflowPath)
+ }
+ }
+ }
+}