shithub: furgit

Download patch

ref: afd58b4e5882402d606728e4f2ee8e5cb2354939
parent: 98231f518208f77ee6e92291976a1512ad1da282
author: Runxi Yu <runxiyu@umich.edu>
date: Sun Mar 22 19:24:18 EDT 2026

refstore: Update invariants

--- a/refstore/batch.go
+++ b/refstore/batch.go
@@ -6,6 +6,9 @@
 //
 // Unlike Transaction, Batch may reject some queued operations while still
 // applying others successfully when Apply runs.
+//
+// A batch borrows its underlying store and is invalid after that store is
+// closed.
 type Batch interface {
 	// Create creates one detached reference, requiring that the logical
 	// reference does not already exist.
--- a/refstore/reading.go
+++ b/refstore/reading.go
@@ -7,7 +7,7 @@
 	// Resolve resolves a reference name to either a symbolic or detached ref.
 	//
 	// Implementations should return value forms (ref.Detached or ref.Symbolic),
-	// not pointer forms.
+	// not pointer forms. Returned refs do not borrow the store.
 	// If the reference does not exist, implementations should return
 	// ErrReferenceNotFound.
 	Resolve(name string) (ref.Ref, error)
@@ -25,6 +25,8 @@
 	// The exact pattern language is backend-defined.
 	List(pattern string) ([]ref.Ref, error)
 	// Close releases resources associated with the store.
+	//
+	// Transactions and batches borrowing the store are invalid after Close.
 	//
 	// Repeated calls to Close are undefined behavior unless the implementation
 	// explicitly documents otherwise.
--- a/refstore/transaction.go
+++ b/refstore/transaction.go
@@ -4,6 +4,9 @@
 
 // Transaction stages reference updates for one atomic commit.
 //
+// A transaction borrows its underlying store and is invalid after that store
+// is closed.
+//
 // Ordinary methods operate in dereference mode if name resolves to
 // a symbolic ref, the operation applies to the final referent rather
 // than to the symbolic ref itself.
--