diff --git a/docs/api-contract.json b/docs/api-contract.json index 12cb37c8..c4f4e056 100644 --- a/docs/api-contract.json +++ b/docs/api-contract.json @@ -1507,6 +1507,7 @@ "BrainyError", "DerivedArtifactMissingError", "GraphIndexNotReadyError", + "MetadataArrayTooLargeError", "MetadataIndexNotReadyError", "MigrationInProgressError", "ProtectedArtifactError", diff --git a/src/brainy.ts b/src/brainy.ts index 5fd6c627..15f51ef9 100644 --- a/src/brainy.ts +++ b/src/brainy.ts @@ -13342,25 +13342,33 @@ export class Brainy implements BrainyInterface { } return this._flushQueued } - return this.startFlushLeader() + return this.#startFlushLeader() } /** * @description Run one flush body as the leader and install it as - * `_flushInFlight`. On settle — resolved OR rejected — the gate opens and + * `_flushInFlight`. + * + * ECMAScript-private (`#`), not TypeScript `private`: `private` is erased at + * compile time, so the method still lands on the prototype and the contract + * manifest — which reads the surface the BUILD exposes — emitted it as a + * door. A door is a promise every engine implementing the contract must + * keep, and this is the flush gate's own bookkeeping, not a promise. `#` + * keeps it off the prototype, so the emitter cannot see it. + * On settle — resolved OR rejected — the gate opens and * the ONE queued waiter (if any) is promoted. The `finally` callback returns * nothing on purpose: a callback that returned the promoted run's promise * would make the leader await its own follower. * @returns The leader's own promise, settling on its own body alone. */ - private startFlushLeader(): Promise { + #startFlushLeader(): Promise { const run = this._runFlush() // `finally` and not `then`: a failed flush must still open the gate, or // one rejection would wedge every later flush behind a promise nobody // will ever settle. const gated: Promise = run.finally(() => { if (this._flushInFlight === gated) this._flushInFlight = null - this.promoteQueuedFlush() + this.#promoteQueuedFlush() }) this._flushInFlight = gated return gated @@ -13368,12 +13376,14 @@ export class Brainy implements BrainyInterface { /** * @description Promote the single queued waiter (if one is waiting) to - * leader and settle its deferred from that run. Never throws into the + * leader and settle its deferred from that run. ECMAScript-private for the + * same reason as {@link flush}'s leader starter: internals are not doors. + * Never throws into the * leader's `finally`: a synchronous failure starting the promoted run is * reported to the waiter, which must be settled on every path. * @returns Nothing. */ - private promoteQueuedFlush(): void { + #promoteQueuedFlush(): void { const settle = this._flushQueuedSettle if (!settle) return // Clear BEFORE starting, so the promoted run's own joiners queue afresh @@ -13381,7 +13391,7 @@ export class Brainy implements BrainyInterface { this._flushQueued = null this._flushQueuedSettle = null try { - this.startFlushLeader().then(settle.resolve, settle.reject) + this.#startFlushLeader().then(settle.resolve, settle.reject) } catch (error) { settle.reject(error) }