@@ -954,16 +954,28 @@ export async function backfill(
954954 blocks : MemoryBlock [ ] ,
955955 explicitBinding ?: CachedBinding ,
956956 sweepDirectory ?: string ,
957- ) : Promise < { ok : number ; failed : number ; skipped : number ; declined : number ; deferred : number ; gated : boolean } > {
957+ ) : Promise < {
958+ ok : number
959+ failed : number
960+ skipped : number
961+ declined : number
962+ deferred : number
963+ gated : boolean
964+ /** Why a gated sweep never ran; only "disabled" is a confirmed workspace toggle. */
965+ gateReason ?: "local-off" | "unbound" | "disabled" | "error"
966+ } > {
958967 // ``gated`` says the sweep never ran, as opposed to running and storing
959968 // nothing. A caller recording "this binding is seeded" must be able to tell
960969 // those apart: memory being off is not a completed seed.
961- if ( ! isEnabled ( ) ) return { ok : 0 , failed : 0 , skipped : 0 , declined : 0 , deferred : 0 , gated : true }
970+ if ( ! isEnabled ( ) ) return { ok : 0 , failed : 0 , skipped : 0 , declined : 0 , deferred : 0 , gated : true , gateReason : "local-off" }
962971 // The bind path passes the binding it just recorded; there is no ambient
963972 // instance to resolve one from on the `link` subcommand.
964973 const binding = explicitBinding ?? ( await currentBinding ( ) )
965- if ( ! binding || ! ( await memoryEnabled ( binding ) ) )
966- return { ok : 0 , failed : 0 , skipped : blocks . length , declined : 0 , deferred : 0 , gated : true }
974+ if ( ! binding )
975+ return { ok : 0 , failed : 0 , skipped : blocks . length , declined : 0 , deferred : 0 , gated : true , gateReason : "unbound" }
976+ const status = await memoryStatus ( binding )
977+ if ( status !== "enabled" )
978+ return { ok : 0 , failed : 0 , skipped : blocks . length , declined : 0 , deferred : 0 , gated : true , gateReason : status }
967979 const index = await readIndex ( )
968980
969981 const { pending, skipped } = partitionPending ( blocks , binding , index )
0 commit comments