oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package creds
2
3import (
4 "context"
5 "errors"
6 "os"
7 "path/filepath"
8 "slices"
9 "strings"
10 "sync"
11 "testing"
12 "time"
13)
14
15// dump-keychain-constructed-2026-11-29-docs-t1.txt is constructed on
16// docs-t1 in the documented `security dump-keychain` format (no -d). No
17// Mac's Keychain was read for it.
18
19const login = "/Users/paulequipo/Library/Keychains/login.keychain-db"
20
21// fakeKeychain is the runner user's Keychains: List as dump-keychain
22// would list them, Delete as delete-generic-password would delete one.
23type fakeKeychain struct {
24 mu sync.Mutex
25 items []Item
26 // lists counts listings; deleted records each deletion asked for.
27 lists int
28 deleted []Item
29 // fail makes every deletion fail; stale keeps a deleted item in the
30 // next listing (it goes from the one after).
31 fail, stale bool
32 ghost []Item
33 // asked is every keychain listed; search is the user's search list
34 // (what a listing without a path would show); broken fails the
35 // listings; dump, when set, is listed instead, as security prints it.
36 asked []string
37 search []string
38 broken bool
39 dump string
40}
41
42func (f *fakeKeychain) add(i ...Item) {
43 f.mu.Lock()
44 defer f.mu.Unlock()
45 f.items = append(f.items, i...)
46}
47
48func (f *fakeKeychain) list(_ context.Context, keychain string) ([]Item, error) {
49 f.mu.Lock()
50 defer f.mu.Unlock()
51 f.lists++
52 f.asked = append(f.asked, keychain)
53 if f.broken {
54 return nil, errors.New("security: could not list")
55 }
56 if f.dump != "" {
57 return ParseDump(f.dump)
58 }
59 var out []Item
60 for _, i := range append(slices.Clone(f.items), f.ghost...) {
61 // dump-keychain <path> lists that keychain, in the search list
62 // or not; without a path, only the search list's.
63 if keychain == i.Keychain || keychain == "" && slices.Contains(f.search, i.Keychain) {
64 out = append(out, i)
65 }
66 }
67 f.ghost = nil
68 return out, nil
69}
70
71func (f *fakeKeychain) delete(_ context.Context, i Item) error {
72 f.mu.Lock()
73 defer f.mu.Unlock()
74 f.deleted = append(f.deleted, i)
75 if f.fail {
76 return errors.New("security: The specified item could not be found in the keychain.")
77 }
78 n := slices.Index(f.items, i)
79 if n < 0 {
80 return errors.New("security: The specified item could not be found in the keychain.")
81 }
82 f.items = slices.Delete(f.items, n, n+1)
83 if f.stale {
84 f.ghost = append(f.ghost, i)
85 }
86 return nil
87}
88
89func (f *fakeKeychain) has(i Item) bool {
90 f.mu.Lock()
91 defer f.mu.Unlock()
92 return slices.Contains(f.items, i)
93}
94
95func newWatch(t *testing.T, f *fakeKeychain) *Keychain {
96 t.Helper()
97 return &Keychain{Dir: filepath.Join(t.TempDir(), "keychain"), Login: login, User: "paulequipo", List: f.list, Delete: f.delete}
98}
99
100const configDir = "/Users/paulequipo/.local/share/equipo-runner/scratch/homes/signin-1"
101
102func own() Item {
103 return Item{Keychain: login, Service: ServiceFor(configDir), Account: "paulequipo"}
104}
105
106func TestParseDump(t *testing.T) {
107 raw, err := os.ReadFile(filepath.Join("testdata", "dump-keychain-constructed-2026-11-29-docs-t1.txt"))
108 if err != nil {
109 t.Fatal(err)
110 }
111 items, err := ParseDump(string(raw))
112 if err != nil {
113 t.Fatal(err)
114 }
115 want := []Item{
116 {Keychain: login, Service: "Wi-Fi", Account: "paulequipo", Created: `0x32303236313131303130303030305A00 "20261110100000Z\000"`},
117 {Keychain: login, Service: "Claude Code-credentials-1a2b3c4d", Account: "paulequipf"},
118 {Keychain: "/Library/Keychains/System.keychain", Service: "AirPort", Account: "com.apple.network.eap.system.item.wlan.ssid.home"},
119 }
120 if !slices.Equal(items, want) {
121 t.Fatalf("generic passwords:\n%+v\nwant\n%+v", items, want)
122 }
123 // What it cannot read for sure is never an item anyone owns.
124 odd, err := ParseDump("keychain: \"" + login + "\"\nclass: \"genp\"\nattributes:\n \"svce\"<blob>=\"Claude Code-credentials-1a2b3c4d\"\n \"acct\"<blob>=<weird>\n")
125 if err != nil || len(odd) != 1 || !odd[0].Unread {
126 t.Fatalf("an unreadable account: %+v %v", odd, err)
127 }
128 if _, err := ParseDump("class: \"genp\"\n"); err == nil {
129 t.Fatal("an item with no keychain line was read")
130 }
131}
132
133func TestServiceFor(t *testing.T) {
134 // sha256("/Users/paulequipo/.local/share/equipo-runner/scratch/homes/signin-1"), first 8 hex.
135 if got := ServiceFor(configDir); len(got) != len("Claude Code-credentials-")+8 || got[:24] != "Claude Code-credentials-" {
136 t.Fatalf("service %q", got)
137 }
138 if ServiceFor(configDir) == ServiceFor(configDir+"x") {
139 t.Fatal("two config dirs share a service")
140 }
141}
142
143// TestKeychainWatch: what a sign-in adds is deleted only when it is
144// positively its own, everything else is left, and the hold stays until
145// a listing shows every item it found gone.
146func TestKeychainWatch(t *testing.T) {
147 ctx := context.Background()
148 wifi := Item{Keychain: login, Service: "Wi-Fi", Account: "paulequipo"}
149 t.Run("nothing new is clean and releases", func(t *testing.T) {
150 f := &fakeKeychain{items: []Item{wifi}}
151 k := newWatch(t, f)
152 if err := k.Before(ctx, "signin-1", configDir); err != nil {
153 t.Fatal(err)
154 }
155 if !k.Held() {
156 t.Fatal("not held while the sign-in runs")
157 }
158 out, err := k.After(ctx, "signin-1")
159 if err != nil || !out.Clean || k.Held() || len(f.deleted) != 0 {
160 t.Fatalf("clean: %+v %v held=%v deleted=%v", out, err, k.Held(), f.deleted)
161 }
162 })
163 t.Run("the before list is durable before anything starts", func(t *testing.T) {
164 f := &fakeKeychain{items: []Item{wifi}}
165 k := newWatch(t, f)
166 if err := k.Before(ctx, "signin-1", configDir); err != nil {
167 t.Fatal(err)
168 }
169 again := &Keychain{Dir: k.Dir, Login: login, User: "paulequipo", List: f.list, Delete: f.delete}
170 if !again.Held() {
171 t.Fatal("a restart does not see the watch")
172 }
173 })
174 t.Run("its own item is deleted by its exact attributes", func(t *testing.T) {
175 f := &fakeKeychain{items: []Item{wifi}, stale: true}
176 k := newWatch(t, f)
177 if err := k.Before(ctx, "signin-1", configDir); err != nil {
178 t.Fatal(err)
179 }
180 f.add(own())
181 out, err := k.After(ctx, "signin-1")
182 if err != nil || out.Clean || !slices.Equal(f.deleted, []Item{own()}) {
183 t.Fatalf("own item: %+v %v deleted=%+v", out, err, f.deleted)
184 }
185 // The second listing still showed it: held, until one does not.
186 if !k.Held() || !slices.Equal(k.Residue(), []string{own().Service}) {
187 t.Fatalf("released before a listing showed it gone: %v", k.Residue())
188 }
189 if err := k.Settle(ctx, false, nil); err != nil {
190 t.Fatal(err)
191 }
192 if k.Held() || f.has(wifi) == false {
193 t.Fatalf("held=%v after a listing showed it gone; wifi kept=%v", k.Held(), f.has(wifi))
194 }
195 })
196 t.Run("claude-code-user is the CLI's account too", func(t *testing.T) {
197 f := &fakeKeychain{}
198 k := newWatch(t, f)
199 _ = k.Before(ctx, "signin-1", configDir)
200 i := own()
201 i.Account = "claude-code-user"
202 f.add(i)
203 if out, _ := k.After(ctx, "signin-1"); out.Clean || f.has(i) || k.Held() {
204 t.Fatalf("claude-code-user item: %+v kept=%v held=%v", out, f.has(i), k.Held())
205 }
206 })
207 t.Run("a failed delete keeps the hold", func(t *testing.T) {
208 f := &fakeKeychain{fail: true}
209 k := newWatch(t, f)
210 _ = k.Before(ctx, "signin-1", configDir)
211 f.add(own())
212 out, err := k.After(ctx, "signin-1")
213 if out.Clean || !k.Held() || !f.has(own()) || !slices.Contains(out.Left, own()) {
214 t.Fatalf("failed delete: %+v %v held=%v", out, err, k.Held())
215 }
216 // Settling tries again; once it works and a listing shows it gone,
217 // the hold goes.
218 f.fail = false
219 if err := k.Settle(ctx, false, nil); err != nil || k.Held() || f.has(own()) {
220 t.Fatalf("retry: %v held=%v", err, k.Held())
221 }
222 })
223 t.Run("an unrelated item at the same time is left, and holds", func(t *testing.T) {
224 f := &fakeKeychain{}
225 k := newWatch(t, f)
226 _ = k.Before(ctx, "signin-1", configDir)
227 other := Item{Keychain: login, Service: "Other App", Account: "paulequipo"}
228 f.add(own(), other)
229 out, _ := k.After(ctx, "signin-1")
230 if out.Clean || f.has(own()) || !f.has(other) || slices.Contains(f.deleted, other) {
231 t.Fatalf("unrelated: %+v deleted=%+v", out, f.deleted)
232 }
233 if !k.Held() || !slices.Equal(k.Residue(), []string{"Other App"}) {
234 t.Fatalf("the unrelated item does not hold: %v", k.Residue())
235 }
236 _ = k.Settle(ctx, false, nil)
237 if !k.Held() || slices.Contains(f.deleted, other) {
238 t.Fatal("settling touched it or let it go")
239 }
240 f.mu.Lock()
241 f.items = nil
242 f.mu.Unlock()
243 if _ = k.Settle(ctx, false, nil); k.Held() {
244 t.Fatal("held after the person removed it")
245 }
246 })
247 // Only the login keychain is watched (fix round 1, #2): the CLI writes
248 // to the default one, and nothing elsewhere is ever touched.
249 t.Run("matching attributes in another keychain are left alone", func(t *testing.T) {
250 f := &fakeKeychain{search: []string{"/Users/paulequipo/Library/Keychains/other.keychain-db"}}
251 k := newWatch(t, f)
252 _ = k.Before(ctx, "signin-1", configDir)
253 elsewhere := own()
254 elsewhere.Keychain = "/Users/paulequipo/Library/Keychains/other.keychain-db"
255 f.add(elsewhere)
256 out, _ := k.After(ctx, "signin-1")
257 if !out.Clean || !f.has(elsewhere) || len(f.deleted) != 0 {
258 t.Fatalf("another keychain: %+v deleted=%+v held=%v", out, f.deleted, k.Held())
259 }
260 })
261 t.Run("another config dir's service or another account is left", func(t *testing.T) {
262 for _, i := range []Item{
263 {Keychain: login, Service: ServiceFor(configDir + "-2"), Account: "paulequipo"},
264 {Keychain: login, Service: ServiceFor(configDir), Account: "vicky"},
265 {Keychain: login, Service: "Claude Code-credentials", Account: "paulequipo"},
266 {Keychain: login, Service: "raw", Unread: true},
267 } {
268 f := &fakeKeychain{}
269 k := newWatch(t, f)
270 _ = k.Before(ctx, "signin-1", configDir)
271 f.add(i)
272 if out, _ := k.After(ctx, "signin-1"); out.Clean || len(f.deleted) != 0 || !k.Held() {
273 t.Fatalf("%+v: %+v deleted=%+v", i, out, f.deleted)
274 }
275 }
276 })
277 t.Run("an item there before is never touched", func(t *testing.T) {
278 f := &fakeKeychain{items: []Item{wifi}}
279 k := newWatch(t, f)
280 _ = k.Before(ctx, "signin-1", configDir)
281 f.add(own())
282 _, _ = k.After(ctx, "signin-1")
283 if !f.has(wifi) || slices.Contains(f.deleted, wifi) {
284 t.Fatal("an item from before was touched")
285 }
286 })
287 t.Run("a Claude Code item there before refuses and holds", func(t *testing.T) {
288 left := Item{Keychain: login, Service: "Claude Code-credentials", Account: "paulequipo"}
289 f := &fakeKeychain{items: []Item{left}}
290 k := newWatch(t, f)
291 if err := k.Before(ctx, "signin-1", configDir); !errors.Is(err, ErrExisting) {
292 t.Fatalf("before: %v", err)
293 }
294 if !k.Held() || !slices.Equal(k.Residue(), []string{"Claude Code-credentials"}) || len(f.deleted) != 0 {
295 t.Fatalf("existing: held=%v %v deleted=%v", k.Held(), k.Residue(), f.deleted)
296 }
297 if err := k.Existing(ctx); !errors.Is(err, ErrExisting) {
298 t.Fatalf("a pasted token's store: %v", err)
299 }
300 _ = k.Settle(ctx, true, func(Watch) bool { return true })
301 if len(f.deleted) != 0 || !f.has(left) {
302 t.Fatal("settling deleted an item from before")
303 }
304 })
305 t.Run("a restart settles a watch its runner never finished", func(t *testing.T) {
306 f := &fakeKeychain{}
307 k := newWatch(t, f)
308 _ = k.Before(ctx, "signin-1", configDir)
309 f.add(own())
310 restarted := &Keychain{Dir: k.Dir, Login: login, User: "paulequipo", List: f.list, Delete: f.delete}
311 // Not before its CLI is proven gone.
312 if _ = restarted.Settle(ctx, true, func(Watch) bool { return false }); !restarted.Held() || !f.has(own()) {
313 t.Fatal("settled before its CLI was proven gone")
314 }
315 if err := restarted.Settle(ctx, true, func(w Watch) bool { return w.Marker == "signin-1" }); err != nil || restarted.Held() || f.has(own()) {
316 t.Fatalf("restart: %v held=%v", err, restarted.Held())
317 }
318 })
319 t.Run("a running watch is never settled", func(t *testing.T) {
320 f := &fakeKeychain{}
321 k := newWatch(t, f)
322 _ = k.Before(ctx, "signin-1", configDir)
323 f.add(own())
324 _ = k.Settle(ctx, true, func(Watch) bool { return true })
325 _ = k.Settle(ctx, false, func(Watch) bool { return true })
326 if !f.has(own()) || !k.Held() {
327 t.Fatal("a watch still running here was settled")
328 }
329 })
330}
331
332// dumpOf is a login keychain dump holding one generic password, its
333// attributes as given (svce and acct values exactly as security prints
334// them) and mdat.
335func dumpOf(keychain, svce, acct, mdat string) string {
336 return "keychain: \"" + keychain + "\"\nversion: 512\nclass: \"genp\"\nattributes:\n" +
337 " \"acct\"<blob>=" + acct + "\n" +
338 " \"cdat\"<timedate>=0x32303236313132393130303030305A00 \"20261129100000Z\\000\"\n" +
339 " \"mdat\"<timedate>=" + mdat + "\n" +
340 " \"svce\"<blob>=" + svce + "\n"
341}
342
343// TestKeychainAmbiguousItems (fix round 1, #1): an item whose attributes
344// cannot all be read is known by its stable attributes only (keychain,
345// class, service, account, creation date), never by the whole dump; one
346// with the CLI's service name, or with no readable service, refuses a
347// preflight; and its hold goes only once a listing shows it absent.
348func TestKeychainAmbiguousItems(t *testing.T) {
349 ctx := context.Background()
350 t.Run("a metadata change keeps the identity and the hold", func(t *testing.T) {
351 f := &fakeKeychain{}
352 k := newWatch(t, f)
353 if err := k.Before(ctx, "signin-1", configDir); err != nil {
354 t.Fatal(err)
355 }
356 f.dump = dumpOf(login, "\"Other App\"", "<weird>", "0x31")
357 out, err := k.After(ctx, "signin-1")
358 if err != nil || out.Clean || len(out.Left) != 1 || !out.Left[0].Unread || !k.Held() {
359 t.Fatalf("an unreadable new item: %+v %v held=%v", out, err, k.Held())
360 }
361 f.dump = dumpOf(login, "\"Other App\"", "<weird>", "0x32")
362 if err := k.Settle(ctx, false, nil); err != nil || !k.Held() {
363 t.Fatalf("a metadata change released the hold: %v held=%v", err, k.Held())
364 }
365 f.dump = ""
366 if err := k.Settle(ctx, false, nil); err != nil || k.Held() {
367 t.Fatalf("held once the item is gone: %v", err)
368 }
369 })
370 t.Run("parsing keeps only stable attributes", func(t *testing.T) {
371 a, err1 := ParseDump(dumpOf(login, "\"Other App\"", "<weird>", "0x31"))
372 b, err2 := ParseDump(dumpOf(login, "\"Other App\"", "<weird>", "0x32"))
373 if err1 != nil || err2 != nil || len(a) != 1 || !slices.Equal(a, b) || strings.Contains(a[0].Account+a[0].Service, "mdat") || a[0].Created == "" {
374 t.Fatalf("%+v %+v", a, b)
375 }
376 })
377 t.Run("an unreadable item with the CLI's service there before refuses", func(t *testing.T) {
378 f := &fakeKeychain{dump: dumpOf(login, "\"Claude Code-credentials-1a2b3c4d\"", "<weird>", "0x31")}
379 k := newWatch(t, f)
380 if err := k.Before(ctx, "signin-1", configDir); !errors.Is(err, ErrExisting) || !k.Held() {
381 t.Fatalf("before: %v held=%v", err, k.Held())
382 }
383 if err := k.Existing(ctx); !errors.Is(err, ErrExisting) {
384 t.Fatalf("a store: %v", err)
385 }
386 })
387 t.Run("an item with no readable service there before refuses", func(t *testing.T) {
388 f := &fakeKeychain{dump: dumpOf(login, "<weird>", "\"paulequipo\"", "0x31")}
389 k := newWatch(t, f)
390 if err := k.Before(ctx, "signin-1", configDir); !errors.Is(err, ErrExisting) || !k.Held() {
391 t.Fatalf("before: %v held=%v", err, k.Held())
392 }
393 })
394 t.Run("an unreadable listing keeps the hold", func(t *testing.T) {
395 f := &fakeKeychain{}
396 k := newWatch(t, f)
397 _ = k.Before(ctx, "signin-1", configDir)
398 f.add(own())
399 f.broken = true
400 if _, err := k.After(ctx, "signin-1"); err == nil || !k.Held() {
401 t.Fatalf("after an unreadable listing: %v held=%v", err, k.Held())
402 }
403 _ = k.Settle(ctx, true, func(Watch) bool { return true })
404 if !k.Held() {
405 t.Fatal("settling with an unreadable listing released the hold")
406 }
407 f.broken = false
408 if err := k.Settle(ctx, true, func(Watch) bool { return true }); err != nil || k.Held() || f.has(own()) {
409 t.Fatalf("once it lists: %v held=%v", err, k.Held())
410 }
411 })
412 t.Run("a recheck that cannot list keeps a residue's hold", func(t *testing.T) {
413 f := &fakeKeychain{fail: true}
414 k := newWatch(t, f)
415 _ = k.Before(ctx, "signin-1", configDir)
416 f.add(own())
417 if _, err := k.After(ctx, "signin-1"); err != nil || !k.Held() {
418 t.Fatalf("a failed delete: %v held=%v", err, k.Held())
419 }
420 f.fail, f.broken = false, true
421 if err := k.Settle(ctx, false, nil); err == nil || !k.Held() {
422 t.Fatalf("a recheck with no listing: %v held=%v", err, k.Held())
423 }
424 })
425 t.Run("a preflight that cannot list refuses", func(t *testing.T) {
426 f := &fakeKeychain{broken: true}
427 k := newWatch(t, f)
428 if err := k.Before(ctx, "signin-1", configDir); err == nil {
429 t.Fatal("a sign-in started with no listing")
430 }
431 if err := k.Existing(ctx); err == nil {
432 t.Fatal("a store went ahead with no listing")
433 }
434 })
435}
436
437// TestKeychainLoginByPath (fix round 1, #2): the login keychain is
438// listed by its path, whatever the search list says, and items of other
439// keychains are not the watch's.
440func TestKeychainLoginByPath(t *testing.T) {
441 ctx := context.Background()
442 f := &fakeKeychain{search: []string{"/Library/Keychains/System.keychain"}}
443 k := newWatch(t, f)
444 if err := k.Before(ctx, "signin-1", configDir); err != nil {
445 t.Fatal(err)
446 }
447 f.add(own())
448 out, err := k.After(ctx, "signin-1")
449 if err != nil || out.Clean || !slices.Equal(out.Deleted, []Item{own()}) || f.has(own()) {
450 t.Fatalf("an item in a login keychain left out of the search list: %+v %v", out, err)
451 }
452 for _, kc := range f.asked {
453 if kc != login {
454 t.Fatalf("listed %q, not the login keychain by path", kc)
455 }
456 }
457 // What a dump of it says of another keychain is not the watch's.
458 f.dump = dumpOf("/Library/Keychains/System.keychain", "\"Claude Code-credentials\"", "\"paulequipo\"", "0x31")
459 if err := k.Before(ctx, "signin-2", configDir); err != nil {
460 t.Fatalf("another keychain's item refused the sign-in: %v", err)
461 }
462}
463
464// TestKeychainWatchUnproven (fix round 2): a watch knows when it began
465// and its launch's record; one whose end could not be proven here is
466// Unproven until a restart settles it.
467func TestKeychainWatchUnproven(t *testing.T) {
468 ctx := context.Background()
469 f := &fakeKeychain{}
470 k := newWatch(t, f)
471 before := time.Now()
472 if err := k.Before(ctx, "signin-1", configDir); err != nil {
473 t.Fatal(err)
474 }
475 if err := k.Ran("signin-1", "pg:4242:signin-1"); err != nil {
476 t.Fatal(err)
477 }
478 if len(unproven(k)) != 0 {
479 t.Fatal("a running watch is unproven")
480 }
481 k.Abandon("signin-1")
482 if !slices.Equal(unproven(k), []string{"signin-1"}) || !k.Held() {
483 t.Fatalf("an abandoned watch: %v held=%v", unproven(k), k.Held())
484 }
485 if err := k.Settle(ctx, false, func(Watch) bool { return true }); err != nil || !k.Held() {
486 t.Fatal("settled without a restart")
487 }
488 restarted := &Keychain{Dir: k.Dir, Login: login, User: "paulequipo", List: f.list, Delete: f.delete}
489 if !slices.Equal(unproven(restarted), []string{"signin-1"}) {
490 t.Fatalf("after a restart: %v", unproven(restarted))
491 }
492 var asked Watch
493 _ = restarted.Settle(ctx, true, func(w Watch) bool { asked = w; return false })
494 if asked.Run != "pg:4242:signin-1" || asked.Started.Before(before) || asked.Started.After(time.Now()) || !restarted.Held() {
495 t.Fatalf("asked %+v", asked)
496 }
497 if err := restarted.Settle(ctx, true, func(Watch) bool { return true }); err != nil || restarted.Held() || len(unproven(restarted)) != 0 {
498 t.Fatalf("once ended: %v held=%v", err, restarted.Held())
499 }
500}
501
502func TestBootTime(t *testing.T) {
503 boot, err := BootTime()
504 if err != nil || !boot.Before(time.Now()) || boot.Year() < 2020 {
505 t.Fatalf("boot %v %v", boot, err)
506 }
507}
508
509// unproven is k's unproven watches ("?" for an error).
510func unproven(k *Keychain) []string {
511 left, err := k.Unproven()
512 if err != nil {
513 return []string{"?"}
514 }
515 return left
516}
517
518// TestKeychainUnprovenUnreadable (fix round 3, #1): records that cannot
519// be listed are an error, never "none unproven".
520func TestKeychainUnprovenUnreadable(t *testing.T) {
521 ctx := context.Background()
522 f := &fakeKeychain{}
523 k := newWatch(t, f)
524 if err := k.Before(ctx, "signin-1", configDir); err != nil {
525 t.Fatal(err)
526 }
527 k.Abandon("signin-1")
528 if err := os.Chmod(k.Dir, 0); err != nil {
529 t.Fatal(err)
530 }
531 defer os.Chmod(k.Dir, 0o700)
532 if left, err := k.Unproven(); err == nil {
533 t.Fatalf("unreadable records read as %v", left)
534 }
535 if !k.Held() {
536 t.Fatal("unreadable records released the hold")
537 }
538}
539