fix(flush): clear() and repairIndex() set the dirty witness themselves
Both mutate durable state outside the two commit paths, so neither was seen by the flush witness added with the idle-flush law. A clear() followed by a flush() would have found the brain "clean" and skipped the entity-tree stamp, leaving a stamp describing the population the clear had just removed — a false divergence warning at the next open. Closing the gap where it is, rather than widening the witness to guess.
This commit is contained in:
parent
b33a93ddba
commit
05820a673d
1 changed files with 9 additions and 0 deletions
|
|
@ -8523,6 +8523,11 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
*/
|
||||
async clear(): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
// A clear mutates durable state without going through a commit path, so
|
||||
// it must set the dirty witness itself — otherwise a `clear()` followed by
|
||||
// `flush()` would find the brain "clean" and skip the entity-tree stamp,
|
||||
// leaving a stamp that describes the population this call just removed.
|
||||
this._dirtySinceLastFlush = true
|
||||
|
||||
// Clear storage
|
||||
await this.storage.clear()
|
||||
|
|
@ -18394,6 +18399,10 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
*/
|
||||
async repairIndex(options?: { rebuild?: Array<'metadata' | 'graph' | 'vector'> | 'all' }): Promise<RepairReport> {
|
||||
await this.ensureInitialized()
|
||||
// A repair recounts, prunes and rebuilds outside the commit paths; the
|
||||
// dirty witness is set so a caller's flush after a repair does its normal
|
||||
// work rather than finding the brain "clean".
|
||||
this._dirtySinceLastFlush = true
|
||||
const startedAt = Date.now()
|
||||
const families: RepairFamilyReport[] = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue