Skip to content

test(persona): dual-run retired persona-anchor pins against the live session-resolver + import-graph gate - #2990

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-13_test-debt-live-resolver-dualrun
Oct 13, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-13_test-debt-live-resolver-dualrun

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2989

What this is

The #2815 stack swapped production session-identity wiring to personaConversationOrder (src/session-resolve.ts); src/persona-anchor.ts is retired from production (comment refs only). At least seven suites still imported and pinned the retired module directly — a green matrix that guarantees nothing about the wired path. #2988 finding ① is the proof: the post-restart persona race shipped while every persona-anchor pin stayed green.

Changes

Inventory (ask 1): an import-graph audit (BFS from the 16 tsup entries) found exactly one unreachable module with test importers: src/persona-anchor.ts. The other unreachable modules are intentional test-only registries (src/marker/spec.ts, src/exit-matrix.ts) plus build-time artifacts (pi-host-stub.ts, .d.ts shims).

Dual-run (ask 2), patterned on tests/issue2944-neutral-skeleton.test.ts:

  • tests/issue2601-model-drift-absorption.test.ts — 7 live-twin tests over the same corpus. Shared expectations where OLD and NEW agree (absorption keeps the raw key; fork keys byte-identical ${id}|sub:<sha16>). Designed divergences, each marked with the justifying principle:
    • v2 folds model-switch absorption into the existing reanchor branch — no separate action (the ladder's migrate-model was a display distinction; the key outcome is identical);
    • v2 requires a deep main-shaped history (≥3 turns incl. assistant) before trusting the two host declarations — shallow switches fork where the old ladder absorbed;
    • v2 never parses system line-diff — workspace-instruction drift + model-header change rides raw (old: fork). The host declarations are the guard, not the prose.
  • tests/dsh-persona-continuity.test.ts — twin unit block, one shared key expectation per old-ladder row (claim/match/migrate/fork/passthrough all agree on the KEY; actions differ by design). Both e2e rigs already run through live wiring and pass unchanged.
  • tests/issue2601-persona-fork-lineage.test.ts — twin for the resolvePersonaKey migrate row: the re-serialized model switch rides raw through the continuation branch on order+fragment evidence (the dsh anthropic-messages lane bypasses native-intercept fetch patch: anonymous pfa-* session, fold ledger orphaned, silent ~182s re-fold on cross-protocol switch #2791 projection fragments equal across provider re-serialization — verified in src/affinity-neutral.ts). Control arm: same prefix with a genuinely different tail still forks when nothing corroborates it. Part-A chainContinues rows kept unmodified: prefix-affinity stays LIVE (server.ts anonymous-ladder consults it).

Clean up (ask 3): Category-B suites (dsh-persona-fingerprint, durable-tool-identity, issue2419, issue2446, issue2447, issue2481, responses-instructions-drift) now reset the LIVE session-order registry in rig hygiene instead of the retired anchor ladder. Notable: dsh-persona-fingerprint's import was dead (never called) — its absence leaked session-order skeletons across rigs; now reset in startRig like every sibling suite. Retired-module pins kept for characterization are labeled // retired-module pin: persona-anchor.

Hardening (ask 4): new zero-dep CI leg test-import-graph (scripts/check-test-import-graph.mjs) fails when any tests/** file imports a src module absent from the production import graph, unless whitelisted (the two test-only registries) or labeled with a retired-module pin comment. Gates both test and static-gates jobs. The debt cannot silently re-accumulate on the next wiring swap.

Behavior changes

None in production code. This PR touches only tests/, one new scripts/ lint, package.json scripts, and ci.yml. The twin tests PIN pre-existing production behaviors that differ from the retired ladder (shallow-history switches fork; system line-diff is not inspected) — those shipped with #2815, they are not introduced here. One test-isolation fix: dsh-persona-fingerprint rigs previously leaked session-order state between tests (dead reset import); each rig now starts cold.

Verification

  • Targeted: 12 affected suites, 91/91 tests pass (node --import tsx --test <files>) — full regression left to CI per local-testing discipline.
  • npm run typecheck clean; node scripts/check-test-import-graph.mjs passes (every remaining persona-anchor import is labeled; both registries whitelisted).
  • Diff: 15 files, all in scope (no version bump, no src/, no lock churn).

ework-agent added 2 commits October 13, 2026 14:17
…ion import graph (#2989)

A green suite over a retired module guarantees nothing about the wired
path: #2988 finding ① shipped while every persona-anchor pin stayed
green. New zero-dep gate scripts/check-test-import-graph.mjs BFS-walks
the tsup entry set and fails on any tests/** import of an unreachable
src module unless whitelisted (test-only registries marker/spec.ts,
exit-matrix.ts) or the importing file carries a 'retired-module pin'
label. Wired into ci.yml as the test-import-graph leg gating both
test and static-gates.
…session-resolver (#2989)

The #2815 stack swapped production session-identity wiring to
personaConversationOrder (src/session-resolve.ts); persona-anchor.ts is
retired from production but at least seven suites still pinned it.

- issue2601-model-drift-absorption: 7 live-twin tests over the same
  corpus — shared expectations where OLD and NEW agree (absorption keeps
  the raw key, fork keys byte-identical), designed divergences marked:
  v2 folds model-switch absorption into the reanchor branch (no separate
  action), requires a deep main-shaped history (shallow switches fork),
  and never parses system line-diff (drift + header change rides raw).
- dsh-persona-continuity: twin unit block with one shared key
  expectation per old-ladder row; e2e rigs already run through live
  wiring and pass unchanged.
- issue2601-persona-fork-lineage: twin for the resolvePersonaKey
  migrate row — the re-serialized switch rides raw via the continuation
  branch on order+fragment evidence; control arm proves unproven
  switches still fork. Part-A chainContinues rows kept: prefix-affinity
  stays LIVE (server.ts anonymous-ladder).
- Category B (fingerprint/durable-tool-identity/issue2419/2446/2447/
  2481/responses-instructions-drift): rig hygiene now resets the live
  session-order registry instead of the retired anchor ladder
  (dsh-persona-fingerprint's import was dead — its absence leaked
  skeletons across rigs; now reset in startRig like every sibling).
- issue2944-neutral-skeleton / session-continuity-proof: label stale
  references to the retired module.

Targeted verification: 12 suites, 91 tests green; typecheck clean;
new import-graph gate passes.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-13_test-debt-live-resolver-dualrun (4dd6173)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3384-pr.2990.8ef387e

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-pr2990.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 已完成 #2990 审查(agent-authored [PR],走 review 姿态:拉分支核对代码 + 独立复算 + 确认 CI,未重做实现)。结论先行:可合(mergeable),按 §7.4 触及 ci.yml + 新增能力面,须人工合并。

结构化八问

1. 是什么问题
不是缺陷修复,是测试债清理 + 结构护栏。#2989 要求:把仍在 import+pin 已退役模块 src/persona-anchor.ts(生产自 #2815 起改走 src/session-resolve.ts)的测试套件,双跑对齐到真实接线,并加一道 import-graph 门禁防止未来再漂移。根因锚点 #2988 finding①:退役模块的 pin 全绿,却挡不住「重启后 persona race」上线——因为 pin 的根本是不在生产路径上的模块。

2. 什么原因导致
#2815 把生产会话身份接线从 persona-anchor 换成 session-resolve,但 ≥7 个测试套件仍直接 import 旧模块做 characterization——绿矩阵只保证旧模块自洽,不保证真实接线。本 PR 不修那个 race(那是 #2988/#2817 的活),而是消除「pin 与接线脱节」这个盲区本身。方向打在根因层,不是症状层。✓

3. 影响范围与严重程度
零生产代码改动——无 src/、无 version bump、无 lock churn。仅 tests/ + 新增 scripts/check-test-import-graph.mjs + package.json 一条 script + ci.yml 一个 job。对运行时 bili 行为无任何影响。纯测试基建,无外部用户面。

4. 怎么修复的(四个 ask 逐一对应)

  • ① inventory:BFS 从 16 个 tsup entry 扫出「不可达但仍被测试 import」的 src 模块恰好只有 persona-anchor.ts。我独立复算确认 reachable=false(src/ 内对它只剩 3 处注释引用,无真实 import)。entry 清单与 tsup.config.ts 逐条核对一致。
  • ② dual-run:新 tests/issue2601-model-drift-absorption.test.ts(旧梯 characterization 11 行 + live twin 7 行,同一语料跑 resolveSessionOrder/personaConversationOrder,共享 key 期望、显式标注两处设计性分歧并给依据);dsh-persona-continuity / issue2601-persona-fork-lineage 各加 live twin 块。
  • ③ clean-up:7 个 Category-B 套件把死掉/错指向的 resetPersonaAnchorsForTest 换成 resetSessionOrderForTest。其中 dsh-persona-fingerprint 那条 import 确实是从未调用的死导入(我核过 base 版 startRig 无该调用),换掉后 rig 才真正 reset 生产所查的 session-order registry,修掉了跨 rig 骨架泄漏。
  • ④ gate:新门禁在 PR 上 fail 任何「import 不可达 src 模块且未带 // retired-module pin: 标签或白名单」的测试。本地实跑 exit 0,正确点名 persona-anchor 为退役项、4 个 twin/pattern 套件已打标、7 个 Category-B 已清干净。

5. 是否有回归问题(逐项过既有行为)

  • 无 src/ 改动 ⇒ 无生产回归。
  • twin 钉住的两处「分歧」——浅历史(2-msg) model switch 在 v2 下分叉(旧梯曾 migrate)、v2 不解析 system line-diff(workspace/行数变化 ride raw)——是 Inbound markers: one declarative strip engine for all four wires (#2789, #2798, #2811 plan B) #2815 已上线的既有行为,本 PR 只是首次钉住而非引入;CI 绿即证明 pin 与当前生产一致。PR 描述对此披露准确。
  • 测试隔离收紧(rig 现 reset session-order registry)只会更隔离,不回灌生产。
  • 高危模式排查:无语义漂移、无 fail-fast→吞错、无阈值/时序/输出格式变化、无缓存/重试策略静默失效。结论:无回归。

6. 是否破坏缓存:不涉及。无持久化格式/版本变更;fork key 字节格式 ${id}|sub:<sha256(tag)[0..16]> 由 twin 显式钉住且两实现一致(persistence contract 保住,升级跨 lane 会话不丢)。

7. 是否改了设计方向:不涉及。不转向架构/边界/数据流;只是让测试对齐既有接线 + 加一道静态门禁(镜像既有 check-unused-exports 的保守文本纪律)。

8. 是否引入了新的配置:不涉及运行时配置。仅新增 package.json script check:test-import-graph 与 ci.yml job test-import-graph(零依赖 node 脚本)。无 env/config/默认值变更。

质量 & diff 整洁度

  • 门禁脚本:零依赖、确定性、保守文本 BFS。两个理论小缺口(字符串字面量含 from "x" 可能误报、目录 index import 未解析)都在其声明的保守设计内、对称处理、且 CI 绿——非阻断,不建议为此扩 diff。
  • twin 测试有牙:能抓 live resolver 吸收时误分叉、fork-key 格式漂移、mainShaped 门回归;control arm(genuinely-different tail 仍 fork)证明 guard rail 非空转。hermetic XDG dir + port:0 + 每子例显式 reset,确定性 OK。非恒真断言。
  • diff 干净:15 文件全部服务四个 ask,无跑题文件、无大量空白重排、无 lock churn、无 version bump。(responses-instructions-drift 有 2 行注释 leading-space 微移,属注释随事实改写的一部分,可接受。)

CI 状态

head 4dd6173 现 18/20 绿:test-import-graph ✓、test(ubuntu 24/22) ✓、static-gates 全绿 ✓、lock-sync/docs/lane-guard/version-guard/kernel-guard/pi-subagents-guard/unused-exports/build-artifact 全 ✓。仅剩 2 个 Windows test job 仍 in_progress(同一套已在 ubuntu 全绿的矩阵,测试为平台无关的 node:test + hermetic,风险低)。

收工判定

可合。 方向正确、零生产回归、twin 有牙、diff 干净、新门禁独立验证通过。等最后 2 个 Windows test job 落地即可合并;若翻红我再定向排查。按 §7.4 我不代合,请人工 merge:#2990

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 更新:CI 已全部落地 —— head 4dd6173 20/20 全绿(test ubuntu 24/22 + windows 24/22、test-import-graph、static-gates 全矩阵、lock-sync/docs/lane-guard/version-guard/kernel-guard/pi-subagents-guard/unused-exports/build-artifact 均 ✓,failure=0 pending=0)。

上一条八问结论维持:可合。零生产回归、twin 有牙、新门禁独立验证通过、diff 干净。请人工 merge:#2990

@ranxianglei
ranxianglei merged commit 663fdb2 into master Oct 13, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.362-master.663fdb2 (rolling master tag).

npm install -g billion-context@0.0.362-master.663fdb2  # 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.

Test debt: suites still pin the retired persona-anchor ladder after the v2.2 wiring swap — dual-run them against the live resolver (ework work item)

1 participant