diff --git a/packages/polyfill/src/emulated-verifier/open-repo.ts b/packages/polyfill/src/emulated-verifier/open-repo.ts index ed9d500..fed93e8 100644 --- a/packages/polyfill/src/emulated-verifier/open-repo.ts +++ b/packages/polyfill/src/emulated-verifier/open-repo.ts @@ -198,8 +198,9 @@ export function setOpenTimeoutForTests(ms: number): void { OPEN_TIMEOUT_MS = ms; } -/** Reset the open registry (mainly for tests / a switched wallet). Tears down the - * held bootstrap subscriptions so a subsequent open re-subscribes cleanly. */ +/** Reset the open registry (mainly for tests / a switched wallet). Releases the bootstrap + * listeners so a subsequent open takes out a new subscription, and DISOWNS the documents it + * takes them from rather than forgetting them - see {@link disowned}. */ // @provenance resetOpenedRepos kind=invention level=none ref=none — per-session bookkeeping reset; upstream the verifier owns `self.repos` and nothing resets it from outside export function resetOpenedRepos(): void { for (const [nuri, open] of [...opens]) { @@ -241,12 +242,15 @@ export function resetOpenedRepos(): void { /** * The bootstrap sync state of `nuri` (lib-internal accessor; NOT a reactive - * app-facing hook — that is a later phase). Returns `"unknown"` if the repo was - * never opened via {@link ensureRepoOpen} (or was opened on the fake-ng no-op - * path, which has no `State` semantics). Otherwise `"syncing"` (subscribed, no - * `State` yet), `"synced"` (first `State` received — the barrier), or - * `"timed-out"` (fallback fired without a `State`). `"synced"` and `"timed-out"` - * are deliberately distinct — a later readiness signal must not confuse them. + * app-facing hook - that is a later phase). **DERIVED on every call, never stored**: from the + * document's one real subscription ({@link docChannel}) and this module's record of having + * opened it. Returns `"unknown"` if the repo was never opened via {@link ensureRepoOpen} (or + * was opened on the fake-ng no-op path, which has no `State` semantics); `"synced"` once a + * `State` has arrived on the channel standing NOW - the barrier; `"syncing"` while the open is + * inside its bounded wait; and `"timed-out"` when it was opened here with no barrier to show + * for it, whether the fallback fired, the subscribe was refused, or the channel was taken + * away. `"synced"` and `"timed-out"` are deliberately distinct - a readiness signal must not + * confuse them - and deriving both is what stops either outliving its subscription. */ // @provenance getSyncState kind=aligned level=1 ref=engine/net/src/app_protocol.rs:AppResponseV0 — reports whether the first `State` arrived; upstream this is not observable from JS export function getSyncState(nuri: Nuri): SyncState | "unknown" {