feat(engine): a protected factory for the generation store — a subclass may substitute one that keeps the contract
Some checks are pending
CI / Node 22 (push) Waiting to run
CI / Node 24 (push) Waiting to run
CI / Integration + conformance (Node 22) (push) Waiting to run
CI / Bun (latest) (push) Waiting to run

This commit is contained in:
David Snelling 2026-09-02 09:09:30 -07:00
parent a8c5fbf9dc
commit f763317af7
2 changed files with 113 additions and 1 deletions

View file

@ -1040,6 +1040,17 @@ export class Brainy<T = any> implements BrainyInterface<T> {
}
}
/**
* Factory hook for the generation store, so an engine built on top of this
* reference implementation can substitute a `GenerationStore` that keeps
* the same behavioural contract (for example, one backed by a native
* implementation) overriding it never changes this engine's own
* behaviour, since the default implementation is unchanged.
*/
protected createGenerationStore(storage: BaseStorage): GenerationStore {
return new GenerationStore(storage)
}
/**
* Initialize Brainy.
*
@ -1297,7 +1308,7 @@ export class Brainy<T = any> implements BrainyInterface<T> {
// guarantees indexes never observe rolled-back state. Reader-mode
// instances skip recovery (readers never write; the next writer
// repairs).
this.generationStore = new GenerationStore(this.storage)
this.generationStore = this.createGenerationStore(this.storage)
const generationOpenResult = await step(
'generation-store.open',
'reading the generation manifest and committed ranges, opening the fact log and the ' +