cross-tab-worker-databus 0.21.16 → 0.21.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -297,6 +297,34 @@ export declare class WorkerClusterRuntime {
297
297
  * expires, which avoids unnecessary transport subscribe/unsubscribe churn.
298
298
  */
299
299
  private reconcileSubscriptions;
300
+ /**
301
+ * Repair a confirmed route that names this Worker while its assignment is gone.
302
+ *
303
+ * Every write that settles ownership stamps the new owner's assignment in the
304
+ * same task as the confirmation (`confirmRoute()` has exactly three call sites,
305
+ * each directly after an `assignedTopics.set`), so a route carrying
306
+ * `confirmedAt` while this map has no entry can only mean the assignment was
307
+ * taken *after* the route settled. That is what `pause()` does: it clears the
308
+ * map unconditionally but rewrites only the routes it can hand off, so a
309
+ * handoff whose final flush is cut short by a storage failure — and the
310
+ * `discardPending()` that ends the teardown throws the rest away — leaves a
311
+ * durable route naming this worker. If the same worker id registers again (a
312
+ * BFCache restore, or a runtime rebuilt with an explicit `workerId`), every
313
+ * peer reads that route as a live, confirmed owner and stands down, while no
314
+ * worker holds a transport subscription for the topic any more. Both reconcile
315
+ * passes miss it by construction: one walks `subscribedTopics`, the other
316
+ * `assignedTopics`, and the phantom is in neither.
317
+ *
318
+ * Acting here is this worker's alone — a peer that elected it is still waiting
319
+ * for its own CONTROL/SUBSCRIBE to be accepted, and the single-writer rule
320
+ * recorded in `reconcileSubscriptions()` forbids anyone else rewriting the
321
+ * record. Reclaim when the local subscription is still live, which restores the
322
+ * assignment and the transport subscription without touching the route, so the
323
+ * owner and its generation stay exactly as peers recorded them; release
324
+ * otherwise, since an owner that has no handler for the topic and never will is
325
+ * a record nothing can act on.
326
+ */
327
+ private reconcileStrandedSelfRoutes;
300
328
  /** Drop assignments where the route no longer points to this worker. */
301
329
  private reconcileAssignedTopics;
302
330
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/core/cluster.ts"],"names":[],"mappings":"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AAgB;IASxB;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAsF9B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,OAAO,CAAC,2BAA2B;IAqCnC,wEAAwE;IACxE,OAAO,CAAC,uBAAuB;IAa/B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA6CnB,oFAAoF;IACpF,OAAO,CAAC,IAAI;IAUZ,qFAAqF;IACrF,OAAO,CAAC,WAAW;IAenB,0EAA0E;IAC1E,OAAO,CAAC,oBAAoB;IAsB5B;;;qEAGiE;IACjE,OAAO,CAAC,SAAS;IAKjB;;;yCAGqC;IACrC,OAAO,CAAC,eAAe;IAavB,2EAA2E;IAC3E,OAAO,CAAC,UAAU;IAUlB;;qCAEiC;IACjC,OAAO,CAAC,gBAAgB;IAgBxB,yFAAyF;IACzF,OAAO,CAAC,YAAY;IAYpB,8EAA8E;IAC9E,OAAO,CAAC,qBAAqB;IAU7B,oEAAoE;IACpE,OAAO,CAAC,0BAA0B;IAQlC,8DAA8D;IAC9D,OAAO,CAAC,eAAe;IAQvB;;;;;;mCAM+B;IAC/B,OAAO,CAAC,WAAW;IAYnB,4EAA4E;IAC5E,OAAO,CAAC,cAAc;IAItB,8GAA8G;IAC9G,OAAO,CAAC,WAAW;IAOnB,kGAAkG;IAClG,OAAO,CAAC,UAAU;IAqBlB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IA6BrB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,aAAa;IAQrB,8EAA8E;IAC9E,OAAO,CAAC,YAAY;CAGrB"}
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  selectRebalanceTarget,
21
21
  selectWorkerBackend,
22
22
  topicMatchesPattern
23
- } from "./chunk-GQ6NYWQL.js";
23
+ } from "./chunk-EZYCSJRS.js";
24
24
  import {
25
25
  DEFAULT_STORAGE_PREFIX,
26
26
  PRUNE_STRATEGY,
@@ -572,7 +572,7 @@ Transport message → isAssigned(topic)? → Yes → broadcastEvent(EVENT)
572
572
 
573
573
  Cluster convergence is driven on two timelines:
574
574
 
575
- - **Heartbeat + reconcile loop** (default `3000 ms`, `heartbeatIntervalMs`). On every tick each Worker refreshes its own record and runs a reconcile pass: prunes Workers past `workerTtlMs`, orphaned subscribers whose Tab is no longer active, and orphaned routes that have no subscribers and exceed the TTL; recomputes its own active/standby role; re-writes its subscriber records; and re-sends `CONTROL/SUBSCRIBE` for any route that still lacks `confirmedAt` — which also recovers control messages lost on the channel.
575
+ - **Heartbeat + reconcile loop** (default `3000 ms`, `heartbeatIntervalMs`). On every tick each Worker refreshes its own record and runs a reconcile pass: prunes Workers past `workerTtlMs`, orphaned subscribers whose Tab is no longer active, and orphaned routes that have no subscribers and exceed the TTL; repairs a confirmed route that names this Worker after its assignment was cleared (see the invariant below); recomputes its own active/standby role; re-writes its subscriber records; and re-sends `CONTROL/SUBSCRIBE` for any route that still lacks `confirmedAt` — which also recovers control messages lost on the channel.
576
576
  - **`REGISTRY` nudge**. Writes to Worker records and routes broadcast a `REGISTRY` message so every peer reconciles immediately rather than waiting for the next heartbeat. A subscriber-only write does not: `subscribe()` on a topic whose owner is still live writes this Tab's subscriber record and returns.
577
577
 
578
578
  Heartbeat writes are not announced, so a stale record is only noticed within one heartbeat interval. The worst case for failing to detect a dead owner is `heartbeatIntervalMs + workerTtlMs` (default about 13 s); see [TTL Message-Loss Window](./configuration.md#ttl-message-loss-window) for the trade-offs.
@@ -611,6 +611,7 @@ These invariants are pinned by regression tests (see `tests/stability.test.ts` a
611
611
  - **Unserved route drop.** A departing owner migrates only the routes that still have subscribers. When every remaining subscriber record of a route it owns has gone — a peer tab that died without releasing — the route is deleted instead of handed to a live peer, which would otherwise carry a transport subscription no Tab listens to. `pause()` runs no orphan-route cleanup (that lives in `reconcile`), so this is the only synchronous release of that record (pinned by regression).
612
612
  - **Last-subscriber release.** An owning Worker learns a topic is unserved from the last subscriber's `CONTROL/UNSUBSCRIBE`: it drops the assignment *and* dispatches the release to its transport. Consuming the message inside the handoff short-circuit alone would leave the server subscription — and its inbound fan-out — alive after every tab has left.
613
613
  - **Assignment drift repair.** Every reconcile tick drops any topic this Worker holds in `assignedTopics` once the durable route no longer names it, releasing the transport subscription as it goes. Ownership thus follows the storage record rather than whichever message arrived last: a stale `CONTROL/SUBSCRIBE`, a lost route write, or a tab that claimed a route it does not own all converge back to exactly one owner within a heartbeat. `tests/coordination-invariants.test.ts` fuzzes three tabs through those corruptions and asserts the quiescent result (pinned by regression: emptying this sweep makes the fuzzed end state fail).
614
+ - **Stranded-self-route repair.** The inverse of the drift above: a durable route *confirmed* to this Worker while `assignedTopics` no longer carries the topic. Every write that settles ownership stamps the assignment in the same task as the confirmation, so the combination can only appear when the assignment is cleared afterwards — `pause()` clears the map unconditionally but rewrites only the routes it can hand off, and a handoff whose final flush is cut short by a failing storage write (the teardown then discards what is still queued) leaves the old record pointing at the departing owner. When that worker id registers again, every peer defers to a live, confirmed owner that holds nothing, and no Tab keeps a transport subscription for the topic. The repair therefore belongs to the named Worker and to nobody else: if it still has a local handler it reclaims the route through the same self-assignment `subscribe()` performs, leaving the record and its generation exactly as peers recorded them; otherwise it deletes the record and lets a remaining subscriber elect an owner it can act on, flushing the deletion *before* broadcasting `REGISTRY` so a peer that reconciles on the nudge reads the repaired state. Routes still awaiting their confirmation are left alone — taking one over would put two transport subscriptions on the same topic, the overlap the strict handoff exists to prevent (pinned by regression).
614
615
  - **Stranded-handoff recovery.** If the previous owner is gone and its `ROUTE_RELEASED` never arrives (dropped channel message under load, or a crash between the route write and the ACK), the reconcile loop re-elects a live owner once the unconfirmed handoff has been stuck longer than a worker TTL (10 s default): the route is rewritten with a fresh generation and the handoff marker cleared, so the normal confirmation path completes (pinned by regression). The age gate matters — a fresh unconfirmed route may simply be waiting out its confirmation flush — and while the previous owner is still alive the new owner keeps waiting, so the strict handoff keeps its no-overlap guarantee.
615
616
  - **Loss and recovery matrix.** Each coordination message has a bounded recovery path: a lost `CONTROL/SUBSCRIBE` is re-sent by the heartbeat reconcile for any route still lacking `confirmedAt`; a lost `REGISTRY` nudge costs at most one heartbeat interval (3 s default) because every tick reconciles anyway; a lost `ROUTE_RELEASED` is recovered by reconcile re-election once the previous owner is gone and the handoff has been stuck longer than a worker TTL (see the stranded-handoff invariant above, pinned by regression); publications dropped during a transport disconnect window are the one documented unrecoverable loss (transport contract). The storage-event fallback channel makes every write a distinct value — a per-channel sender nonce *and* a monotonic sequence in the envelope — because a browser suppresses the `storage` event when `setItem` leaves the stored value unchanged, and the nonce is what separates two tabs whose first identical frame would each be `seq=1`; a dropped dispatch still recovers through the same reconcile loop.
616
617
  - **Recovery diagnostics.** `getHealthSummary()` derives a single readiness verdict from the lifecycle flags (`stopped` / `starting` / `healthy` / `recovering` / `suspended` / `degraded`); the unified `lastFailure` ledger and persistence counters reset on every explicit `start()`.
@@ -20,7 +20,7 @@ Only `pnpm bench:browser` / `pnpm bench:compare` / `pnpm bench:trend` stay local
20
20
  1. Update `package.json`, `CHANGELOG.md`, and both roadmap files.
21
21
  2. Run `pnpm check`, `pnpm lint`, `pnpm test:coverage`, `pnpm bench`, `pnpm test:e2e`, `pnpm bench:browser`, `pnpm verify:pack`, `pnpm verify:compat`, `pnpm verify:types`, and `git diff --check`. (`verify:compat` asserts the package `exports` subpaths and type fields present in the `COMPAT_BASE_TAG` baseline still exist; `verify:pack` steam-imports the full root public surface plus every subpath in ESM and CJS from the packed tarball; `verify:types` freezes every public entry's declared export names against the same baseline and asserts no public signature names a type that no entry exports — a type-only export emits no runtime key, so neither the `Object.keys()` freeze in `tests/dual-format.test.ts` nor `verify:compat` can see one change. `verify:compat` and `verify:types` resolve their baseline from the most recent release tag, so a shallow or tag-less clone must first run `git fetch --tags` or they fail with "no version tag found".)
22
22
  3. Gate dependency security: `pnpm audit --registry=https://registry.npmjs.org` (the configured mirror registry lacks the audit endpoint; CI runs it on the public registry in the verify job). Fail the release on any known-vulnerability advisory; `pnpm-workspace.yaml` overrides pin patched ranges.
23
- 4. Gate browser benchmark regressions: run `pnpm bench:browser` (twice at minimum; the gate compares the newest report against the median of the same metric in up to the five preceding archived reports, **and additionally requires the new value to exceed the highest of those samples**) and then `pnpm bench:compare --fail-above-pct 50`. The median baseline exists because the in-page hot-path metrics alternate between a fast and a slow mode on identical code — two consecutive runs of `dedup1000Ms` measured 12.7 ms then 25.6 ms, and a single noisy previous report could fail the documented ceiling with no code change at all. The second leg exists because a median over an alternating sample is only stable while the modes stay mixed: when several consecutive reports land in the same mode the median itself jumps, which is how one comment-only tree read +121% against one baseline and −56.7% against another minutes apart. A metric excused by that leg is printed under `within-baseline, not gated` rather than passing silently — measured on the current archive, `publish/dedicated/perMessageMs`, `publish/shared/perMessageMs` and `databus/publishBatch1000Ms` were all inside their own five-report range, so treat that list as the metric's real resolution, not as a clean bill. `publish/dedicated/perMessageMs` is noisy the same way: two consecutive runs of identical code measured 49.9 ms then 71.1 ms, failing the gate at +75.7% while `dedup1000Ms` and `traceAndPublish1000Ms` *improved* in the same report — that single-metric-up-everything-else-down shape is the noise signature, and the next run reported 49.4 ms and passed. Before accepting or acting on a failure, re-run and check the spread; if the change touches a hot path, size it directly (a micro-benchmark of the 0.20.95 bounded-map rewrites measured 80–86 ns/op across all three variants, i.e. inside run-to-run variance). A baseline shift (e.g. a metric becoming real instead of a no-op) is an expected one-time failure. Refresh the long-run trend doc with `pnpm bench:trend` and commit it when the tables change. **Re-running a failure can manufacture its own excuse, and that was measured.** `bench:compare`'s baseline — both the median and the maximum leg — is drawn from the most recent archived reports, and every `bench:browser` run appends to that same archive, so the samples you add while investigating a failure become the baseline that judges the next attempt. On 2026-09-24, at host load averages 7.7–15.1 with a zero non-comment `src/` diff in the tree, the first two runs measured `publish/dedicated 77.3 ms` and `publish/shared 67.7 ms` against a ~38/~34 ms fast mode and failed the 50% ceiling; five further re-runs reported **OK**, because the baseline median had slid to `70.6`. One clean run after taking those samples out of the archive showed every metric rising together (`dedicated +92.5%`, `shared +99.2%`, `dedup +43.4%`, `trace +21.0%`), which is the contention signature and the inverse of the single-metric-up shape above. So read the load average *before* re-running, and when a suspect failure occurs on a loaded host, record it as deferred with its numbers and move the off-mode samples aside instead of letting them into the baseline — and do not regenerate `docs/benchmarks.md` from them.
23
+ 4. Gate browser benchmark regressions: run `pnpm bench:browser` (twice at minimum; the gate compares the newest report against the median of the same metric in up to the five preceding archived reports, **and additionally requires the new value to exceed the highest of those samples**) and then `pnpm bench:compare --fail-above-pct 50`. The median baseline exists because the in-page hot-path metrics alternate between a fast and a slow mode on identical code — two consecutive runs of `dedup1000Ms` measured 12.7 ms then 25.6 ms, and a single noisy previous report could fail the documented ceiling with no code change at all. The second leg exists because a median over an alternating sample is only stable while the modes stay mixed: when several consecutive reports land in the same mode the median itself jumps, which is how one comment-only tree read +121% against one baseline and −56.7% against another minutes apart. A metric excused by that leg is printed under `within-baseline, not gated` rather than passing silently — measured on the current archive, `publish/dedicated/perMessageMs`, `publish/shared/perMessageMs` and `databus/publishBatch1000Ms` were all inside their own five-report range, so treat that list as the metric's real resolution, not as a clean bill. `publish/dedicated/perMessageMs` is noisy the same way: two consecutive runs of identical code measured 49.9 ms then 71.1 ms, failing the gate at +75.7% while `dedup1000Ms` and `traceAndPublish1000Ms` *improved* in the same report — that single-metric-up-everything-else-down shape is the noise signature, and the next run reported 49.4 ms and passed. Before accepting or acting on a failure, re-run and check the spread; if the change touches a hot path, size it directly (a micro-benchmark of the 0.20.95 bounded-map rewrites measured 80–86 ns/op across all three variants, i.e. inside run-to-run variance). A baseline shift (e.g. a metric becoming real instead of a no-op) is an expected one-time failure. Refresh the long-run trend doc with `pnpm bench:trend` and commit it when the tables change. **Re-running a failure can manufacture its own excuse, and that was measured.** `bench:compare`'s baseline — both the median and the maximum leg — is drawn from the most recent archived reports, and every `bench:browser` run appends to that same archive, so the samples you add while investigating a failure become the baseline that judges the next attempt. On 2026-09-24, at host load averages 7.7–15.1 with a zero non-comment `src/` diff in the tree, the first two runs measured `publish/dedicated 77.3 ms` and `publish/shared 67.7 ms` against a ~38/~34 ms fast mode and failed the 50% ceiling; five further re-runs reported **OK**, because the baseline median had slid to `70.6`. One clean run after taking those samples out of the archive showed every metric rising together (`dedicated +92.5%`, `shared +99.2%`, `dedup +43.4%`, `trace +21.0%`), which is the contention signature and the inverse of the single-metric-up shape above. So read the load average *before* re-running, and when a suspect failure occurs on a loaded host, record it as deferred with its numbers and move the off-mode samples aside instead of letting them into the baseline — and do not regenerate `docs/benchmarks.md` from them. **The standing decision, recorded at 0.21.17 (the fifth release in that state): when no quiet window exists across a cycle, defer the sample with its load numbers instead of taking it on a loaded host.** The deferral is what keeps `docs/benchmarks.md` stale, and staleness-by-recorded-opportunity is the intended outcome of this step, not a gate that passed quietly; what would not be acceptable is a loaded sample entering the archive, because that becomes the baseline the next release is judged against.
24
24
  5. Confirm the package contains only intended files with `npm pack --dry-run --json`.
25
25
  6. Commit on a feature branch, push that branch, and merge its green PR using squash or fast-forward (no merge commit). Fetch the merged commit, tag that exact commit, and push only the specific version tag; never push `main`/`master` directly or force-push. The workflow runs `node scripts/verify-release-version.mjs` to require `RELEASE_TAG` to equal `v` + the package version and to require exactly one non-empty CHANGELOG section.
26
26
 
package/docs/roadmap.md CHANGED
@@ -1,6 +1,33 @@
1
1
  # Roadmap
2
2
 
3
- 0.21.16 was released on September 24, 2026. The project is intentionally continuing through reliability-focused releases before a 1.0.0 stability freeze.
3
+ 0.21.17 was released on September 24, 2026. The project is intentionally continuing through reliability-focused releases before a 1.0.0 stability freeze.
4
+
5
+ ## 0.21.17 delivered scope
6
+
7
+ - **A confirmed route that named a live Worker holding nothing no longer orphans its Topic.** `pause()` clears
8
+ `assignedTopics` unconditionally but rewrites only the routes it can hand off, so a handoff whose final storage
9
+ flush fails leaves the durable record pointing at the departing owner — confirmed, with its old generation. When
10
+ that worker id registers again, every peer defers to a live confirmed owner that holds nothing, no tab's transport
11
+ subscribes the channel, and inbound delivery stops everywhere while publishing still looks healthy. The named
12
+ Worker now repairs it on each reconcile: reclaim when it still has a local handler, release the record otherwise,
13
+ with the deletion flushed before the `REGISTRY` nudge so the peer that reconciles on it reads repaired state.
14
+ - **Why neither reconcile pass could have noticed, written down at the site.** One walks `subscribedTopics` and the
15
+ other `assignedTopics`, and the phantom is in neither; `isAssigned()` then answers `true` for it through its
16
+ durable-route fallback, which is what made the state silent rather than merely slow.
17
+ - **Four gates on a sweep that deletes shared state**, each measured separately: the confirmation must be present (a
18
+ route still awaiting its ACK is an election in flight), the worker must be the named one, the assignment map is
19
+ consulted first so the legitimate elected-owner-without-local-handler case is left alone, and `knownTopics` — a map
20
+ this worker filled itself — is the only source of the plaintext. Mutating them one at a time fails 6, 28, 7 and 1
21
+ tests respectively, and the reclaim/release/flush/nudge legs each die to exactly one assertion.
22
+ - **One pre-existing test's premise corrected**: its hand-written takeover route carried the previous owner's
23
+ `confirmedAt`, a state no worker writes and precisely the shape the new pass releases, so its assertion was passing
24
+ by a mechanism other than the one it named.
25
+ - **The `storage-fail` fuzz interleaving that found this is measured and deliberately not shipped** — it reddens the
26
+ sweep on the pre-fix code from seed 414 onward, which is four times below the sweep's depth floor, so it is a finder
27
+ rather than a guard; its knob (`MemoryStorage.failNextWrites`) and the recipe are committed.
28
+ - **A classification, comment-only:** `handoffAssignedTopics()`'s unreachable `if (!owner) continue;` now names the
29
+ four links that make it unreachable, the test that pins each, and the measured counterfactual — deleting it keeps
30
+ the suite green and fails the type check five times, so it is a narrowing rather than a branch.
4
31
 
5
32
  ## 0.21.16 delivered scope
6
33
 
@@ -509,7 +509,7 @@ Transport 消息 → isAssigned(topic)? → 是 → broadcastEvent(EVENT)
509
509
 
510
510
  集群收敛由两条时间线驱动:
511
511
 
512
- - **心跳 + reconcile 循环**(默认 `3000 ms`,`heartbeatIntervalMs`)。每轮心跳每个 Worker 刷新自己的记录并跑一次 reconcile:清理超过 `workerTtlMs` 的 Worker、所属 Tab 已不活跃的孤儿 subscriber、以及没有 subscriber 且超过 TTL 的孤儿路由;重算自己的 active/standby 角色;重写自己的 subscriber 记录;并对任何还缺 `confirmedAt` 的 route 重发 `CONTROL/SUBSCRIBE`——顺带恢复通道上丢失的控制消息。
512
+ - **心跳 + reconcile 循环**(默认 `3000 ms`,`heartbeatIntervalMs`)。每轮心跳每个 Worker 刷新自己的记录并跑一次 reconcile:清理超过 `workerTtlMs` 的 Worker、所属 Tab 已不活跃的孤儿 subscriber、以及没有 subscriber 且超过 TTL 的孤儿路由;修复那条已确认给自己、但 assignment 已被清掉的 route(见下文不变量);重算自己的 active/standby 角色;重写自己的 subscriber 记录;并对任何还缺 `confirmedAt` 的 route 重发 `CONTROL/SUBSCRIBE`——顺带恢复通道上丢失的控制消息。
513
513
  - **`REGISTRY` 通知**。Worker 记录与路由写入后广播 `REGISTRY`,让所有对端立即 reconcile,而不是等下一轮心跳;只写 subscriber 记录不会广播:`subscribe()` 命中一个仍然存活的 owner 时,写完本 Tab 的 subscriber 记录就直接返回。
514
514
 
515
515
  心跳写入不广播,因此在发现过期记录之前最多会经过一个完整心跳间隔。检测死 owner 的最坏窗口为 `heartbeatIntervalMs + workerTtlMs`(默认约 13 秒);相关权衡见 [TTL 消息丢失窗口](./configuration.md#ttl-消息丢失窗口)。
@@ -549,6 +549,7 @@ Transport 消息 → isAssigned(topic)? → 是 → broadcastEvent(EVENT)
549
549
  - **无人订阅路由的删除。** 离开的 owner 只交接仍有订阅者的路由。若它拥有的某条路由,其剩余订阅记录已全部消失(某个 peer Tab 未释放就死亡),则该路由被删除而不是交给仍然存活的 peer——否则那个 peer 会背负一个没有任何 Tab 监听的 transport 订阅。`pause()` 不执行孤儿路由清理(该逻辑在 `reconcile` 中),因此这是对该记录唯一的同步释放(由回归测试固定)。
550
550
  - **最后一个订阅者的释放。** owner Worker 通过最后一个订阅者发来的 `CONTROL/UNSUBSCRIBE` 得知某 Topic 已无人订阅:它会同时丢弃本地 ownership 并把释放动作派发给自己的 transport。若只在交接短路里消费该消息,server 订阅(以及它的入站扇出)会在所有 Tab 离开后依然存活。
551
551
  - **归属漂移的修复。** 每一轮 reconcile 都会丢弃那些 `assignedTopics` 里仍持有、但持久路由已不再指向本 Worker 的 Topic,并顺带释放对应的 transport 订阅。于是 ownership 跟随存储记录,而不是最后到达的那条消息:陈旧的 `CONTROL/SUBSCRIBE`、丢失的路由写入、或某个抢到了不属于自己的路由的 Tab,都会在一个 heartbeat 内收敛回“恰好一个 owner”。`tests/coordination-invariants.test.ts` 会针对三个 Tab 随机制造这些破坏并断言静默后的结果(由回归测试固定:把这一轮清扫掏空,模糊测试的终态就会失败)。
552
+ - **自身路由悬空的修复。** 上面那条漂移的反面:持久路由已经*确认*给本 Worker,而 `assignedTopics` 里已经没有这个 Topic。所有确立 ownership 的写入都会在盖章确认的同一个任务里写下 assignment,所以这种组合只可能来自 assignment 事后被清掉——`pause()` 无条件清空这张 map,却只重写它交接得出去的路由;若这次交接的最后一次 flush 被一次失败的存储写入打断(拆除流程随后会丢弃仍然排队的那批写入),旧记录就还指向离开的那个 owner。当同一个 worker id 再次注册时,每个 peer 都会对着一个存活、已确认、却什么都不持有的 owner 让路,而没有任何 Tab 还留着这个 Topic 的 transport 订阅。因此修复只能由被点名的那个 Worker 做,别人也不行:若它本地仍有 handler,它就走一遍 `subscribe()` 对自己的那条自我分配路径把路由认领回来,记录与 generation 都保持各 Tab 看到的样子;否则它删除该记录,让剩下的订阅者去选一个能真正执行的 owner,并在广播 `REGISTRY` **之前**先落盘这次删除,好让因通知而 reconcile 的 peer 读到的是已经修好的状态。仍在等待自己确认的路由一律不动——提前接管会让同一 Topic 上出现两个 transport 订阅,而那正是严格交接要防的重叠(由回归测试固定)。
552
553
  - **悬挂交接恢复。** 若前任 owner 已消失而其 `ROUTE_RELEASED` 始终未到达(高负载下通道消息丢失,或 route 写入与 ACK 发送之间崩溃),reconcile 循环会在该未确认交接悬挂超过一个 worker TTL(默认 10 秒)后重新选举存活 owner:路由以全新 generation 重写并清除交接标记,使常规确认路径得以完成(已有回归固化)。年龄门限很关键——刚写入的未确认路由可能只是在等确认落盘,不能误判为悬挂;而只要前任 owner 仍然存活,新 owner 会继续等待,因此严格交接的无重叠保证不受影响。
553
554
  - **丢失与恢复矩阵。** 每类协调消息都有有界恢复路径:丢失的 `CONTROL/SUBSCRIBE` 由心跳 reconcile 对未确认路由重发;丢失的 `REGISTRY` 通知最多损失一个心跳间隔(默认 3 秒),因为每次 tick 都会 reconcile;丢失的 `ROUTE_RELEASED` 由 reconcile 在前任 owner 消失且交接悬挂超过一个 worker TTL 后重新选举恢复(见上文悬挂交接不变量,已有回归固化);transport 断连窗口内被丢弃的 publication 是唯一文档化的不可恢复丢失(transport 契约)。storage-event 降级通道让每次写入都是一个不同的值——信封里同时带一个**每通道 sender nonce** 和一个单调递增的序列号——因为浏览器在 `setItem` 没有改变存储值时会抑制 `storage` 事件,而两个 Tab 各自的第一帧同样都是 `seq=1`,把它们区分开靠的是那个 nonce;丢失的派发仍由同一 reconcile 循环恢复。
554
555
  - **恢复诊断。** `getHealthSummary()` 从生命周期标志推导单一就绪判定(`stopped` / `starting` / `healthy` / `recovering` / `suspended` / `degraded`);统一的 `lastFailure` 账本与持久化计数在每次显式 `start()` 后重置。
@@ -21,6 +21,7 @@
21
21
  2. 运行 `pnpm check`、`pnpm lint`、`pnpm test:coverage`、`pnpm bench`、`pnpm test:e2e`、`pnpm bench:browser`、`pnpm verify:pack`、`pnpm verify:compat`、`pnpm verify:types` 以及 `git diff --check`(`verify:compat` 断言 `COMPAT_BASE_TAG` 基线中的 package `exports` 子路径与类型字段仍然存在;`verify:pack` 从打包产物冒烟导入完整根公共面与全部子路径的 ESM/CJS;`verify:types` 用同一基线冻结每个公共入口声明层导出的名字,并断言没有任何公共签名引用了「任何入口都未导出」的类型——纯类型导出不会在运行时产生任何键,因此 `tests/dual-format.test.ts` 的 `Object.keys()` 冻结和 `verify:compat` 都看不到它的变化。`verify:compat` 与 `verify:types` 从最近的发布 tag 解析基线,因此浅克隆或缺少 tag 的克隆需先执行 `git fetch --tags`,否则会以 "no version tag found" 失败)。
22
22
  3. 依赖安全门禁:`pnpm audit --registry=https://registry.npmjs.org`(配置的镜像 registry 缺少 audit 端点;CI 在 verify job 中于公共 registry 运行)。任一已知漏洞公告即视为发布失败;`pnpm-workspace.yaml` overrides 钉住补丁版本。
23
23
  4. 浏览器基准回归门禁:运行 `pnpm bench:browser`(至少两次;门禁将最新报告与之前最多五份归档报告中同一指标的中位数比较,**并且额外要求新值超过这些样本中的最大值**),随后执行 `pnpm bench:compare --fail-above-pct 50`。采用中位数基线是因为页内热路径指标在同一份代码上会在快/慢两档之间来回跳——`dedup1000Ms` 相邻两次实测分别为 12.7 ms 与 25.6 ms,只看"上一份报告"时,一次偶发噪声就能在无代码改动的情况下击穿既定上限。第二个条件则是因为:在两档交替的样本上,中位数只有当两档保持混合时才稳定——一旦连续几份报告落在同一档,中位数本身就会跳变,这正是同一份纯注释改动在一版基线前读出 +121%、几分钟后在另一版基线前读出 −56.7% 的原因。被该条件放过的指标会打印在 `within-baseline, not gated` 下,而不是静默通过——在当前归档上实测,`publish/dedicated/perMessageMs`、`publish/shared/perMessageMs` 与 `databus/publishBatch1000Ms` 三项都落在各自五份报告的区间内,因此应把这份清单读作该指标的真实分辨率,而不是一张合格证。`publish/dedicated/perMessageMs` 同样如此:同一份代码相邻两次实测为 49.9 ms 与 71.1 ms,令门禁以 +75.7% 失败,而同一份报告里 `dedup1000Ms` 与 `traceAndPublish1000Ms` 反而*变快*——"单指标上涨、其余下降"正是噪声的特征,第三次实测为 49.4 ms 并通过。因此在采信或处理失败前先复跑并观察离散度;若改动涉及热路径,就直接量化其开销(0.20.95 有界映射改写的微基准显示三种写法均为 80–86 ns/op,落在运行间波动之内)。基线迁移(例如某指标从空操作变为真实路径)属预期内的一次性失败。用 `pnpm bench:trend` 刷新长期趋势文档,表格变化时一并提交。**复跑失败可能亲手制造出让它通过的基线,这一点已被实测。** `bench:compare` 的基线(中位数与最大值两个条件)取自最近若干份归档报告,而每一次 `pnpm bench:browser` 都会往同一个归档里追加——于是排查失败时新增的样本,就变成了裁决下一次尝试的基线。2026-09-24:主机负载均值 7.7–15.1、待发布树的非注释 `src/` 差异为 0 行,前两次实测 `publish/dedicated 77.3 ms`、`publish/shared 67.7 ms`,相对约 38/34 ms 的快档在 50% 上限上失败;随后五次复跑报告 **OK**,因为基线中位数已经滑到 `70.6`。把这些样本移出归档后的一次干净实测显示所有指标同时上涨(`dedicated +92.5%`、`shared +99.2%`、`dedup +43.4%`、`trace +21.0%`),那是资源竞争的形态,与上文"单指标上涨、其余下降"的噪声形态相反。因此:复跑之前先看负载(`uptime`);在满载主机上遇到可疑失败,就把数字连同负载一起记为"本轮推迟",并将偏离常态的样本移出基线——也不要据它们重新生成 `docs/benchmarks.md`。
24
+ **这条既定决策在 0.21.17 被写下,那是处于该状态下的第五个发布周期:一个发布周期里始终没有安静的窗口时,就把这份采样连同当时的负载数字一起记为"本轮推迟",而不是在满载主机上取它。** 推迟正是 `docs/benchmarks.md` 保持陈旧的原因,而"按机会更新"的这份陈旧是本步骤期望的结果,不是一道悄悄通过的门禁;真正不可接受的,是把一个受资源竞争的样本放进归档——那会变成下一次发布用来判定回归的基线。
24
25
  5. 用 `npm pack --dry-run --json` 确认发布包只包含预期文件。
25
26
  6. 在功能分支提交并推送该分支,PR 验证通过后使用 squash 或 fast-forward 合入(不创建 merge commit)。获取合入后的精确提交并打 tag,只推送该版本 tag;禁止直接推送 `main`/`master` 或 force-push。工作流运行 `node scripts/verify-release-version.mjs`,要求 `RELEASE_TAG` 等于 `v` 加 package 版本,且 CHANGELOG 中恰好有一个非空的对应版本章节。
26
27
 
@@ -1,6 +1,30 @@
1
1
  # 路线图
2
2
 
3
- 0.21.16 已于 2026 年 9 月 24 日发布。项目会先持续完成可靠性发布,再进入 1.0.0 稳定性冻结。
3
+ 0.21.17 已于 2026 年 9 月 24 日发布。项目会先持续完成可靠性发布,再进入 1.0.0 稳定性冻结。
4
+
5
+ ## 0.21.17 已完成范围
6
+
7
+ - **一条指向"活着但什么都不持有"的 Worker 的已确认路由,不再永久搁置它的 Topic。** `pause()` 无条件清空
8
+ `assignedTopics`,却只重写它交接得出去的路由,所以一次最终 flush 失败的交接会把持久记录留在原 owner 身上——已确认、
9
+ 代次不变。当同一个 worker id 再次注册,每个 peer 都对着这个存活且已确认、却什么都不持有的 owner 让路,没有任何 Tab 的
10
+ transport 还订阅着这条通道,入站投递在所有 Tab 上同时停止,而发布看起来仍然正常。被点名的 Worker 现在每轮 reconcile
11
+ 都会修它:本地仍有 handler 就认领回来,否则释放这条记录,并且**先**把删除落盘再广播 `REGISTRY`,好让因通知而
12
+ reconcile 的 peer 读到的是修好的状态。
13
+ - **两轮 reconcile 都不可能发现它的原因,写在了代码现场。** 一轮走 `subscribedTopics`,另一轮走 `assignedTopics`,
14
+ 而这个幽灵两边都不在;随后 `isAssigned()` 又会通过它的持久路由兜底分支对返回 `true`——这正是该状态保持沉默、
15
+ 而不是仅仅变慢的原因。
16
+ - **一条会删除共享状态的清扫,加了四道闸门**,每一道都分别测过:必须已经确认(还在等 ACK 的路由是一次进行中的选举)、
17
+ 必须是被点名的那个 Worker、先查 assignment map(所以"被选出来但本地没有 handler"这一合法情况不受影响),而明文
18
+ topic 只能来自 `knownTopics`——那是一张只由本 Worker 自己填过的 map。逐个删掉这四道闸门分别会让 6、28、7、1 个测试
19
+ 失败;reclaim / release / flush / nudge 四条腿各自恰好被一条断言固定。
20
+ - **一个既有测试的前提被改正**:它手写的"被接管"路由带着前任 owner 的 `confirmedAt`,而没有任何 Worker 会写出这种
21
+ 状态——它恰好就是新清扫会释放的形状——所以那条断言其实是通过另一个机制成立的,而不是它声称的那一个。
22
+ - **找到这个问题的 `storage-fail` 交错被测量过,并且刻意没有留在 fuzz 里**:在修复前的代码上,它从 seed 414 起就让
23
+ sweep 失败,而这个深度是 sweep 自身 100-seed 下限的四倍,所以它是发现器而不是守卫;它需要的开关
24
+ (`MemoryStorage.failNextWrites`)和复现配方已经提交。
25
+ - **一条纯注释的归类**:`handoffAssignedTopics()` 里那条走不到的 `if (!owner) continue;` 现在写清了使它不可达的四个
26
+ 环节、每个环节各自被哪个测试固定,以及实测的反事实——删掉它整个测试套件的数字不变,而类型检查会报 5 个错误,所以它是
27
+ 下方三处调用赖以成立的类型收窄,而不是一个行为分支。
4
28
 
5
29
  ## 0.21.16 已完成范围
6
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-tab-worker-databus",
3
- "version": "0.21.16",
3
+ "version": "0.21.17",
4
4
  "description": "Framework-agnostic cross-tab data bus with Dedicated/Shared Worker clustering and Centrifuge support.",
5
5
  "type": "module",
6
6
  "license": "MIT",