test(search): name the in-brain swap-race tests after what they sample
CI / Lint / Test / Vet (pull_request) Successful in 56s
CI / Mirror to GitHub (pull_request) Skipped

Review of #172 (rule 9): "LeaksNothing" claims more than a 1.5s
sampled race can prove -- the same overclaim this PR removes from the
"Never" names. Renamed to DoesNotReturn...DuringASampledSwapRace,
and the brainfstest doc now says the target may be inside the brain
(#171) and that observation is over a sampled window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-05 07:19:27 +02:00
co-authored by Claude Opus 5.5
parent bf3646c0c7
commit a83f0cb381
2 changed files with 9 additions and 7 deletions
@@ -1,8 +1,10 @@
// Package brainfstest is the shared harness for hyperguild#157's swap-race // Package brainfstest is the shared harness for hyperguild#157's swap-race
// tests: it keeps swapping a regular note, a symlink to an outside file, or a // tests: it keeps swapping a regular note, a symlink to a sentinel target file
// FIFO (with a writer held open) into a path while a reader under test loops. // (outside the brain, or inside it for hyperguild#171), or a FIFO (with a
// It observes two things: no sentinel byte from the outside file reaches the // writer held open) into a path while a reader under test loops.
// reader's output, and the reader returns within a timeout. It does not cover // It observes two things, over a sampled window only: no sentinel byte from
// the target reaches the reader's output, and the reader returns within a
// timeout. It does not cover
// hard links, other paths into the reader, or races it does not generate. // hard links, other paths into the reader, or races it does not generate.
package brainfstest package brainfstest
@@ -18,7 +20,7 @@ import (
"time" "time"
) )
// Sentinel marks the outside file's contents. // Sentinel marks the target file's contents.
const Sentinel = "zqbrainfssentinelonefiftyseven" const Sentinel = "zqbrainfssentinelonefiftyseven"
// outsideContent carries Sentinel in every field a reader might extract: the // outsideContent carries Sentinel in every field a reader might extract: the
+2 -2
View File
@@ -184,7 +184,7 @@ func inBrainTarget(t *testing.T, brain string) string {
return brainfstest.WriteSentinelAt(t, filepath.Join(brain, "raw", "s.md")) return brainfstest.WriteSentinelAt(t, filepath.Join(brain, "raw", "s.md"))
} }
func TestQueryLeaksNothingFromAnInBrainTargetUnderASymlinkSwapRace(t *testing.T) { func TestQueryDoesNotReturnAnInBrainSymlinkTargetDuringASampledSwapRace(t *testing.T) {
brain, facts, _ := searchBrain(t) brain, facts, _ := searchBrain(t)
target := inBrainTarget(t, brain) target := inBrainTarget(t, brain)
read := func() string { read := func() string {
@@ -200,7 +200,7 @@ func TestQueryLeaksNothingFromAnInBrainTargetUnderASymlinkSwapRace(t *testing.T)
assert.NotContains(t, read(), brainfstest.Sentinel, "static in-brain link") assert.NotContains(t, read(), brainfstest.Sentinel, "static in-brain link")
} }
func TestHydrateRefusesAnInBrainSymlinkAndLeaksNothingUnderASwapRace(t *testing.T) { func TestHydrateRefusesAnInBrainSymlinkAndDoesNotReturnItsTargetDuringASampledSwapRace(t *testing.T) {
brain, facts, _ := searchBrain(t) brain, facts, _ := searchBrain(t)
target := inBrainTarget(t, brain) target := inBrainTarget(t, brain)
require.NoError(t, os.Symlink(filepath.Join("..", "..", "..", "raw", "s.md"), filepath.Join(facts, "inlink.md"))) require.NoError(t, os.Symlink(filepath.Join("..", "..", "..", "raw", "s.md"), filepath.Join(facts, "inlink.md")))