v1 plan: fix TestPinAndUnpin event assertion (positions -> order and content); note the finding

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 04:05:02 -07:00
co-authored by Claude Fable 5.1
parent 0874e00bdd
commit 29b3a5c38e
2 changed files with 25 additions and 2 deletions
+6
View File
@@ -77,3 +77,9 @@ tools/run-plan.sh docs/plans/v1 # from a clean checkout on master
files were protected and the rule was to stop. Owner's fault for the conflict; the model's
deviation is noted. The corrected files now sit in `_files/internal/config/` as the reference
copies for the reviewer's byte-exact check.
- 2026-09-25, task 04: my `TestPinAndUnpin` asserted the pin event at exactly `len-3` and the
release event at `len-1`, but the task's own rules make acquires under a pin record events too,
so a faithful implementation produces `[new pin pin new new release]` and the assertion cannot
hold. Ornith spent its first ten minutes puzzling over exactly that. Test fault (mine): the
assertion now checks order and content (a pin event naming beta, followed later by a release),
not positions.
@@ -217,9 +217,26 @@ func TestPinAndUnpin(t *testing.T) {
if host, _, _ := tbl.Acquire(k, []string{"alpha", "beta"}, t0.Add(4*time.Minute)); host != "beta" {
t.Errorf("after unpin the existing lease (on beta) simply continues: %q", host)
}
if got := p.reasons(); got[len(got)-3] != store.ReasonPin || got[len(got)-1] != store.ReasonRelease {
t.Errorf("events = %v, want a pin event and a release event", got)
// Events: a pin event naming beta must exist, and the unpin's release event must come after it.
// Acquires under the pin may record their own events in between; their number is not fixed here.
got := p.reasons()
pinAt, releaseAt := -1, -1
for i, r := range got {
if r == store.ReasonPin && pinAt < 0 {
pinAt = i
}
if r == store.ReasonRelease {
releaseAt = i
}
}
if pinAt < 0 || releaseAt < pinAt {
t.Errorf("events = %v, want a pin event followed later by a release event", got)
}
p.mu.Lock()
if pinAt >= 0 && p.events[pinAt].ToHost != "beta" {
t.Errorf("pin event = %+v, want ToHost beta", p.events[pinAt])
}
p.mu.Unlock()
}
func TestDrainKeepsExistingRefusesNew(t *testing.T) {