Repository navigation
[PR] fix(tests): AC12 boot lineage reclamation test case pins access order, fixing persistently red Windows CI | [PR] fix(tests): AC12 开机血缘回收用例钉死访问顺序,修复 windows CI 持续红 - #3334
Conversation
…dition no longer rides wall-clock luck The AC12 boot-reconcile scenario requires the sweep to reach the grandchild before the intermediate child adopts. listSessions() orders by lastSeen desc and the two turns are ~seconds apart on a fast box, but the timestamps are ambient: a coarse clock or any reload path restamping lastSeen ties/flips the order — observed deterministically on the windows-latest CI lanes (every completed run of master since the batch). Once the child is visited first it legitimately adopts from the root, and the grandchild adopting from a now-block-bearing parent is CORRECT behavior under the #2807 contract, so the assertion fires for the wrong reason. Pin grandchild.lastSeen one minute past the child's after the strip step; production behavior is unchanged (both visit orders are legal outcomes).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3929-pr.3334.8f2ad9fThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3334.tgz
npm install -g packageInstall instructions are refreshed on each push. |
rahul05ranjan
left a comment
There was a problem hiding this comment.
Traced the flake story against the actual sweep mechanics and the diagnosis holds up.
What I verified (couldn't run the suite here — no deps installed on my box — so I extracted the reconcileDerivedLineage decision loop (fork-adoption.ts:415) into a standalone Node script with the AC12 post-strip P→C→G shape and executed the order matrix):
- Sweep order is exactly
listSessions()(session.ts:1075,[...values()].sort((a, b) => b.lastSeen - a.lastSeen)), and V8's sort is spec-stable, so alastSeentie falls back to Map insertion order — child before grandchild. Reproduced both failure shapes: with a tie (or a plain flip), the child is visited first and adopts from the root; the grandchild then legitimately adopts from its now-block-bearing parent andderivedBlocksAdopted=true→ theassert.notEqualfails. That's correct #2807 behavior tripping an unpinned precondition, which matches the PR description. - With the pin at tests/lineage-reconcile-boot.test.ts:461, both the tied and flipped variants visit the grandchild first, hit the "parent has nothing to adopt yet" branch, and the marker stays unset — the assertion passes for the intended reason, not clock luck.
- The pin is effective where it matters:
initSessions()(session.ts:950) isinitialized-guarded, so the phase-2 "boot" sweep reads the same in-memory session objects the test just pinned. The fix doesn't depend on a debounced disk write landing between the pin and the reload, and nothing restampslastSeenin between (getSession()isn't reached before the boot-time reconcile instartServer). Math.maxkeeps the natural timestamp when it's already later, so the pin only moves relative ordering — persona freshness windows / the split canary see the grandchild as more recent, which is the harmless direction.
One nit, feel free to ignore: the two listSessions().find(...) calls at lines 459-460 could share one listSessions() call.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.517-master.84a77b2 # this exact build
npm install -g billion-context@master # always the newest merged build
|
坏了什么
master 的
test (windows-latest, 22, 1)lane 自 #3312–#3320 批次合入后持续红(已完成 run:a046d4ec、两个 PR 的继承运行共 3 次,同一分片同一用例),红点是tests/lineage-reconcile-boot.test.ts的 AC12「a multi-hop grandchild stays eligible when its intermediate parent has nothing to adopt yet」,断言assert.notEqual(grandchild.metadata.derivedBlocksAdopted, true)失败。所有开着的 PR 都继承这个红。根因
不是产品 bug,是测试的前置条件没有固定:
reconcileDerivedLineage,按listSessions()的lastSeen降序)先访问孙辈、再访问子辈,这样孙辈访问时父(子)还没有块,走「留门下次重试」分支,marker 保持未设。lastSeen(convergeToDisk会用盘上 savedAt 回填)都可能打平或翻转顺序。marker=true→ 断言失败。这恰恰是 fix(sessions): wire-neutral affinity hashing for cross-protocol continuity (#2791) #2807 契约下的正确行为(父有块就收,收不了才留门),断言挂得冤枉。复现:在测试里把 child/grandchild 的
lastSeen强制打平后,本地 3/3 精确复现同一条断言失败(稳定排序下平局按 Map 插入顺序,子先于孙)。Windows CI 的环境扰动等价于这个打平。修法
测试在 strip 之后显式钉死顺序:
grandchild.lastSeen = max(自身, child.lastSeen + 60_000),一行前置条件固定,不再赌墙钟。产品代码零改动——两种访问顺序在 #2807 契约下都是合法结果,无需(也不应)改listSessions()的排序。证据
npm run typecheck干净归属说明
tests/lineage-reconcile-boot.test.ts一个文件 +12 行