feat(addons): let a caller ask whether the grants store is usable

View hides a closed or doubtful store behind an empty document, which
would drop the deny rules kept in it. A caller that must fail closed asks
Usable first.

Assisted-by: Claude:claude-sonnet-5-5 go
This commit is contained in:
Ettore Di Giacinto committed 2026-11-03 22:06:43 +00:00
1 parent 173a97302f
commit ef26fa19f7
1 file changed
+9
+9
View File
@@ -130,6 +130,15 @@ func (s *Store) usable() error {
return nil
}
// Usable reports whether the store answers: it is neither closed nor in doubt
// about its last write. A caller that must fail closed asks it before it
// trusts View, which hides the failure behind an empty document.
func (s *Store) Usable() error {
s.mu.Lock()
defer s.mu.Unlock()
return s.usable()
}
// Snapshot returns a copy of the current document.
func (s *Store) Snapshot(ctx context.Context) (Snapshot, error) {
s.mu.Lock()