LESSONS: a gone check that looks past made-up text moves into the code standards

Seen a third day: on 11-15 TestMoreKinds' "ops" was in the made-up
user name zpxopsat (ubuntu CI at 500f39886, #4345), after 10-10's
placeholder suffix and 11-10's port and route_id. The rule is now a row
in docs/code-standards.md's Tests table, and LESSONS.md lists it under
"Moved to the code standards". Docs only; nothing run.
This commit is contained in:
yetone
2026-11-16 03:38:48 +08:00
parent 8765ca1758
commit 2d106b5c1a
2 changed files with 11 additions and 12 deletions
+10 -12
View File
@@ -530,18 +530,9 @@ push.**
testdata.
- Seen 1× (2026-10-10).
**A check that a value is gone looks past text magpie generates.**
- 6c099edd's redact test checked that "ops" was gone by substring. The
placeholder's random suffix spelled it ({{HOSTNAME_mlopsiy3}}) on macOS
CI. f0453192 strips placeholders before the check, in its sibling
TestMask too.
- 11-10: TestSearchAPIFailureKeepsNoURL looked for its query's "4410"
in usage.jsonl by substring. A random port (127.0.0.1:44105, #5616)
and then a route_id (1794294410888, run 42771382484) held it, and
main went red. Gaoshou101's patch, posted on #5616 three days before,
made the query letters only (17b9b5b03). A word a test looks for
can't be spelled by a port, an id, a time or a hash.
- Seen 2× (2026-10-10, 2026-11-10).
**A check that a value is gone looks past text magpie generates** is
in the code standards since 11-16. See
[Moved to the code standards](#moved-to-the-code-standards).
**A script Settings loads runs in every mode the GUI has: the window,
the panel and gateway mode.**
@@ -1110,6 +1101,13 @@ standards since 10-18, widened to a worktree and its logs. See
## Moved to the code standards
- **A check that a value is gone looks past text magpie or the test
made up** (10-10, 11-10, 11-15). On 11-15 TestMoreKinds checked that
the user name "ops" was gone, and the made-up name for it, eight
letters from a key new each run, was zpxopsat: ubuntu CI red at
500f39886. #4345 had the same red on mote on 11-12, filed as "passes
on rerun" with its output lost. A probe that searched for a key whose
made-up name spells "ops" (key 2207: dopsubnz) made it red every run.
- **A commit's `--stat` names only the files its change touched; any
other file is a stale tree** (11-11, 11-12, 11-13). On 11-13 8c7328f3a
(remote quotas) wrote 21 files back to 35aaaa4b9^ and took out three
+1
View File
@@ -31,6 +31,7 @@ describe and review a change to a subsystem is in the
| Tests check behavior, not implementation. | Assert what the user or caller needs. Formatting changes and internal refactors shouldn't break a test, unless exact bytes are the requirement. |
| A test that fails on `main` is a bug to fix now. | "Fails the same on origin/main" is not a baseline, and neither is "fails under the full run, passes alone". Fix it at its cause, or open an issue naming the cause, in a commit of its own, before shipping on top of it. From 10-05 to 10-07 dozens of commits shipped past red tests. Some were real bugs: a data race (a45b3e09), test order (bfe8bcaf), and click-scroll red since 5d871723 while dcbae2ef, 76d82528 and b2345078 shipped past it. Run `go test -race -count=20 -run X` before calling a Go test a flake. |
| A red's issue is read to its last comment, and a patch on it is taken first. | Before filing, commenting on or shipping past a red, search its test's name and read every comment. "Seen again" is not work on it: take it, or say who has it. A patch posted there is reviewed and ported before anyone writes another. #1794 got four "seen again" comments before anyone took it (10-12). #2444 had ump45nose's patch for 22 hours while two sessions commented, until CI went red at f191d6423 (10-17). JoeyWu-tech's #3568 patch, with red-on-old tests, waited three days until 0a7633136's CI went red and 11c427eaa ported it (10-28). |
| A check that a value is gone looks past text magpie or the test made up. | A substring check strips placeholders and stand-ins first, or looks for a value no port, id, time, hash or random name can spell (letters only, longer than a few characters). 6c099edd's "ops" was in a placeholder's suffix ({{HOSTNAME_mlopsiy3}}, f0453192, 10-10). On 11-10 a port and then a route_id held TestSearchAPIFailureKeepsNoURL's "4410" (17b9b5b03). On 11-15 TestMoreKinds' "ops" was in the made-up user name zpxopsat (#4345, filed 11-12 as "passes on rerun"); a key found to spell it reproduces the red. |
| Tests stay out of the real machine. | Run them under a temp HOME with Go's caches pinned (see the snippet in [provider-plugins.md](subsystems/provider-plugins.md)). Never touch a real agent's config or `~/.config/magpie`. An agent's variable goes in `agentenv.Vars`, so the sandbox clears it. |
| Whatever a test starts ends when the test does. | A fake process, a goroutine or an async refresh a test sets going is stopped or waited for before the test returns, or it writes into the next test's folder ("directory not empty") or spins for days. A package that isolates itself in its own `TestMain` instead of `testenv.Run` sets what testenv sets, `testenv.Marker` included. TestClaudeSignInByPaste's fake polled for 2 days (38a0f470). On 10-11 a CLI-identity ask outliving its test broke the next one (#1524): 4ee3a76b fixed it in internal/gateway only, 9c377231 for every package through the marker, which the gateway never set (a349de82). |
| A timing test leaves room on both sides. | Never bound a test by wall-clock time a loaded runner can exceed, and keep a threshold classifier's fixture far from every threshold it has. Reproduce a timing failure by injecting the delay (a held write, a late first arrival), not by rerunning until it fails, and list every timing assumption in the test when fixing one. 319b72c7 fixed one of two loops sharing a 2000-line bound and the other went red 9h later (229ce19a). On 10-11 TestMaxRPM's flake was a real gap: a first request that reached the vendor late let the vendor see one too many in its minute (ce1ecaa4), and the queued-stream tests timed the client's clock under CPU starvation (3f4287e6). |