Skip to content

[PR] fix(tests): AC12 boot lineage reclamation test case pins access order, fixing persistently red Windows CI | [PR] fix(tests): AC12 开机血缘回收用例钉死访问顺序,修复 windows CI 持续红 - #3334

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-16_lineage-ac12-order-pin
Oct 17, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

坏了什么

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,是测试的前置条件没有固定:

  • AC12 测的场景要求 sweep(reconcileDerivedLineage,按 listSessions() 的 lastSeen 降序)先访问孙辈、再访问子辈,这样孙辈访问时父(子)还没有块,走「留门下次重试」分支,marker 保持未设。
  • 这个先后顺序完全依赖两次回合的天然时间戳。Linux 上两者差 ~3 秒,永远孙先;但时间戳是环境值——时钟粒度、reload/驱逐路径重打 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() 的排序。

证据

  • 修复前本地强制打平:3/3 复现 Windows 同款失败
  • 修复后本文件 5 连跑 4/4 全绿,npm run typecheck 干净
  • Windows lane 无法本地验证,合入后以 CI 为准

归属说明

  • config surface:无
  • kernel:无
  • 只动 tests/lineage-reconcile-boot.test.ts 一个文件 +12 行

…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).
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-16_lineage-ac12-order-pin (705e426)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3929-pr.3334.8f2ad9f

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3334.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(tests): AC12 开机血缘回收用例钉死访问顺序,修复 windows CI 持续红 [PR] fix(tests): AC12 boot lineage reclamation test case pins access order, fixing persistently red Windows CI | [PR] fix(tests): AC12 开机血缘回收用例钉死访问顺序,修复 windows CI 持续红 Oct 16, 2026

@rahul05ranjan rahul05ranjan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a lastSeen tie 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 and derivedBlocksAdopted=true → the assert.notEqual fails. 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) is initialized-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 restamps lastSeen in between (getSession() isn't reached before the boot-time reconcile in startServer).
  • Math.max keeps 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.

@ranxianglei
ranxianglei merged commit 84a77b2 into master Oct 17, 2026
38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.517-master.84a77b2 (rolling master tag).

npm install -g billion-context@0.0.517-master.84a77b2  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants