From 29b3a5c38e6f1f59249f0e2ca3f9352a763b7ac5 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Fri, 25 Sep 2026 04:05:02 -0700 Subject: [PATCH] v1 plan: fix TestPinAndUnpin event assertion (positions -> order and content); note the finding Co-Authored-By: Claude Fable 5.1 --- docs/plans/v1/README.md | 6 ++++++ .../v1/_files/internal/lease/lease_test.go | 21 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/plans/v1/README.md b/docs/plans/v1/README.md index f99b373..bfb58bb 100644 --- a/docs/plans/v1/README.md +++ b/docs/plans/v1/README.md @@ -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. diff --git a/docs/plans/v1/_files/internal/lease/lease_test.go b/docs/plans/v1/_files/internal/lease/lease_test.go index a1db60e..5fdf3d2 100644 --- a/docs/plans/v1/_files/internal/lease/lease_test.go +++ b/docs/plans/v1/_files/internal/lease/lease_test.go @@ -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) {