agent: a new agent named nowhere in the Library fails internal/agent's tests
TestEveryAgentInLibrary (internal/library) went red on main for a new agent four times:399010befand68cb92e8e(11-10),7e8214d60(11-12), andeffdd1bebtoday after00b2c11a6(Open Code Review). A change that adds an agent runs internal/agent, and the guard is in another package, so each was found after the push. TestEveryAgentNamedForTheLibrary reads internal/library's targets.go and every_agent_test.go (library imports agent, so it reads the files) and fails when an agent on this machine's list is in neither a targetOf case nor noLibrary. The library test still checks a target has something in it. Same shape as internal/gui's TestEveryRouteIsNamedForTheCLI. LESSONS.md: the route/setting guard lesson now covers agents, seen a third day. code-standards criterion 3 names both twins. Run (mote, ateffdd1beb+ this change): - go test -count=1 -timeout 45m ./internal/agent ./internal/library: ok - broken by hand (open-code-review's noLibrary line removed): red, "open-code-review (Open Code Review) isn't named in internal/library"; restored - win-run and wsl-run, -run TestEveryAgentNamedForTheLibrary: ok - gofmt -l: clean Not run: the full ./... suite (test-only change in one package).
This commit is contained in:
+14
-4
@@ -398,9 +398,10 @@ rate and at its largest input.**
|
||||
on the largest reply a test has.
|
||||
- Seen 2× (2026-10-14, 2026-10-18).
|
||||
|
||||
**A new route or setting runs the packages whose guards list them.**
|
||||
TestEveryRouteHasACommandOrIsNamed (internal/cli) lists every route, and
|
||||
TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui) every setting.
|
||||
**A new route, setting or agent runs the packages whose guards list
|
||||
them.** TestEveryRouteHasACommandOrIsNamed (internal/cli) lists every
|
||||
route, TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui) every
|
||||
setting, and TestEveryAgentInLibrary (internal/library) every agent.
|
||||
- 11-11: 747632890 (context-cap) and eb56de0b5 (the catalog's model list)
|
||||
ran chosen tests and turned both guards red on CI at 8aae124b0. An hour
|
||||
later 58fb07095 (named proxies, 1,714 lines) did it again with three
|
||||
@@ -416,7 +417,16 @@ TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui) every setting.
|
||||
TestEveryRouteIsNamedForTheCLI fails on a route that the CLI's list
|
||||
doesn't name. When a rule keeps being missed, put its check where
|
||||
the work already runs.
|
||||
- Seen 2× (2026-11-11, 2026-11-15).
|
||||
- 11-17: 00b2c11a6 (Open Code Review) added an agent and ran chosen
|
||||
internal/agent tests, a real ocr review and both cross-OS vets, but
|
||||
pushed before its full suite. The suite then found
|
||||
TestEveryAgentInLibrary red, and effdd1beb added the noLibrary line
|
||||
half an hour later. That guard was red on main for a new agent on
|
||||
11-10 twice (399010bef, 68cb92e8e), 11-12 (7e8214d60) and now. The
|
||||
check now also runs where agents are added: internal/agent's
|
||||
TestEveryAgentNamedForTheLibrary fails on an agent that targetOf's
|
||||
cases and noLibrary both leave unnamed.
|
||||
- Seen 3× (2026-11-11, 2026-11-15, 2026-11-17).
|
||||
|
||||
**A byte-for-byte check of a stream allows what the protocol allows,
|
||||
and its failure message counts against what it compared.**
|
||||
|
||||
@@ -74,6 +74,10 @@ listed as not run, never left out.
|
||||
test that pinned the old text. On 10-13 four commits ran chosen
|
||||
packages and turned main red this way: 6fa3109ea (494609866),
|
||||
43d8a5633 (24146c031), 5617281f5 and cdb7b5ff7 (c6de0d2a5).
|
||||
A guard that keeps being missed gets a twin in the package the change
|
||||
runs: internal/gui's TestEveryRouteIsNamedForTheCLI for a new route,
|
||||
internal/agent's TestEveryAgentNamedForTheLibrary for a new agent
|
||||
(red on main four times before it, last at 00b2c11a6, 11-17).
|
||||
4. **GUI tests in both engines.** A change to `internal/gui/assets` runs the
|
||||
Playwright tests it touches in Chromium and WebKit (`make test-ui`, or
|
||||
`BROWSER=webkit node --test …`). The suite must also pass in Chinese,
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Every agent is named in internal/library: a case of targetOf
|
||||
// (targets.go) or a line of noLibrary (every_agent_test.go). A change that
|
||||
// adds an agent runs this package, and a new agent named in neither left
|
||||
// library's TestEveryAgentInLibrary red on main again and again (399010bef,
|
||||
// 68cb92e8e, 7e8214d60, effdd1beb), each found after the push. That test
|
||||
// still checks the target has something in it; this one only checks the
|
||||
// agent was named at all. library imports agent, so this reads its files.
|
||||
func TestEveryAgentNamedForTheLibrary(t *testing.T) {
|
||||
dir := filepath.Join("..", "library")
|
||||
targets, err := os.ReadFile(filepath.Join(dir, "targets.go"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
list, err := os.ReadFile(filepath.Join(dir, "every_agent_test.go"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var cases strings.Builder
|
||||
for _, l := range strings.Split(string(targets), "\n") {
|
||||
if l = strings.TrimSpace(l); strings.HasPrefix(l, "case ") {
|
||||
cases.WriteString(l + "\n")
|
||||
}
|
||||
}
|
||||
h := t.TempDir()
|
||||
n := 0
|
||||
for _, a := range onMachine(h, filepath.Join(h, ".config")) {
|
||||
if a.WSL != "" || a.Plugin != "" || strings.Contains(a.ID, "#") {
|
||||
continue // a distro's twin, a plugin's agent and another profile have their own
|
||||
}
|
||||
n++
|
||||
q := regexp.QuoteMeta(`"` + a.ID + `"`)
|
||||
inCase := regexp.MustCompile(q).MatchString(cases.String())
|
||||
listed := regexp.MustCompile(`(?m)^\s*` + q + `:`).Match(list)
|
||||
if !inCase && !listed {
|
||||
t.Errorf("%s (%s) isn't named in internal/library: give it a case in targetOf (targets.go), or a reason in noLibrary (every_agent_test.go)", a.ID, a.Name)
|
||||
}
|
||||
}
|
||||
if n < 50 {
|
||||
t.Fatalf("read %d agents", n)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user