Skip to content

[PR] kernel: preserve issued refs and quarantine known historical collisions (#5196) - #5233

Open
qiangu2020 wants to merge 7 commits into
ranxianglei:masterfrom
qiangu2020:2026-10-30_ref-safety
Open

qiangu2020 wants to merge 7 commits into
ranxianglei:masterfrom
qiangu2020:2026-10-30_ref-safety

Conversation

@qiangu2020

@qiangu2020 qiangu2020 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem and scope

Closes #5196. Reported against billion-context 0.1.209. A restart could restamp previously issued refs, and an allocator could reuse historical numbers. A model citing a previously seen ref could then resolve or compress a different message.

kernel-change: preserve issued message refs across restart and prevent historical ref reuse, including low ledgerSeq/dead/reserved ref cases. Host-only removal of restamping is insufficient because the kernel owns allocation and its never-reuse contract.

Changes

  • Stop cold-load ref restamping and preserve the existing message/block identity.
  • Make both kernel allocation branches reserve previously issued/dead refs and respect the historical high-water mark. Kernel version: 0.0.170 -> 0.0.171; root package stays 0.1.209 in this fix PR.
  • Detect known retained old/current collisions and refuse ref-resolving mutations before summary work or plugin state/credit/storage mutation. Preserve messages/blocks and read-only inspection/recovery.
  • Carry a monotonic quarantine fact through existing Session.metadata serialization, absorb/adoption/fork and active-store convergence; preserve it regardless of payload arbitration winner, without replacing unrelated metadata.

No new dependency, database schema, public config, wire surface, behavior budget or threshold. The kernel remains platform-agnostic and has no host I/O. This does not reconstruct intent whose historical evidence was already pruned or missing, nor claim a general multi-process transaction guarantee.

Validation on rebased head

Base: dcf7607 (current official master when checked). The only newer upstream changes were two non-overlapping revert paths; all 25 reviewed file bytes are unchanged after rebase.

Node 24.21.0, real repository commands:

  • npm run typecheck: exit 0.
  • npm run build: exit 0 (build-info names this repair commit).
  • npm --prefix kernel test: 1494 tests, 1494 PASS, 0 FAIL/SKIP.
  • Targeted host boundary/storage/fork/summary/plugin suites plus tests/verif-subset-guard.test.ts: 158 tests, 157 PASS, 1 existing SKIP, 0 FAIL.

Prior isolated RED/GREEN probes and independent Standards/Spec closures cover retained collision rejection, before-work mutation boundaries, durable multi-hop quarantine, all active-convergence directions and healthy controls. Full host regression is intentionally left to the remote CI lanes on this pushed head, per AGENTS.md; no local full-host-suite verdict is claimed.

Review and delivery boundary

Kernel/message identity changes require human review and merge. Do not auto-merge. This PR does not publish, merge, activate a service or alter user stores. A separately versioned local-maintained artifact is being prepared for the user's expressly authorized local deployment; its version/provenance metadata is not mixed into this repair PR. Native Prime integration acceptance remains a separate delivery gate.

Baseline CI prerequisite follow-up

Head 5f7218c6cb2329232f27b3b6210988433e1f93a7 adds only five baseline prerequisite paths: the existing sessions.hardMaxBytes authoritative seed, its normal generated EN/ZH outputs, the existing environment knob lifecycle entry, and the stale MySQL concurrent-lock test expectation. The nine original related blobs matched official base dcf76075342dbe57eb1a2b10107aef6235c4289a; the faults predate this ref repair. The test captures the already-initialized MySQL stamp before rewind and demands strict equality after migration, without coupling it to SQLite's separate version constant or changing any lock/dedup/marker assertions.

The original 25 ref-repair file hashes remain byte-for-byte unchanged. Root version remains 0.1.209 and kernel 0.0.171; no runtime, schema, guard, workflow, dependency, budget or new public API change. Parent independently ran config-surface/lifecycle/config-docs coverage and clean-commit official generator + git diff: all exit 0. Bounded migration file: 2 SQLite PASS, 3 MySQL explicitly SKIP locally (no service), 0 FAIL. Real MySQL and full regression matrix remain pending the new remote CI run; prior skipped jobs are not represented as test passes. Initial typecheck/build/kernel/targeted host results above were measured at repair commit 58a53c79dfed7333d6764c063296be5b90c75274.

No auto-merge or publish. Kernel changes still require human review and merge.

2026-11-01 additive refresh — current validation supersedes older base/version lines above

Fixes #5485 (focused residual lifetime-ref floor/tombstone gap after #5360; original #5196 remains historical context).

This refresh preserves the contributor's existing commits and authorship. It merges current master 0d0c0b956b496761a0512558f444371aaac8531f additively rather than replacing the contribution. Root package and all plugin manifests remain official 0.1.211; in-repo kernel version is 0.0.178. No private release metadata is included.

Both official #5360 settlement loops retain same-pass retired-seat protection, and BOTH now use historical/tombstone-aware parking. The full current host/kernel changes, including #5253 and #5188, remain present. Five added combined tests cover orphan highwater + tombstones + both settlement paths + overlap dedup/idempotence + atomic exhaustion. The known-collision cold-load, before-work mutation refusal and durable fork/restart/active-store quarantine coverage remains intact.

Native Node24.21.0 / npm11.19.0 validation:

  • npm run typecheck: exit0.
  • npm run build: exit0; frozen CLI version/commit verified.
  • npm --prefix kernel test:1553 PASS,0 FAIL/SKIP. The later master merge changes only three unrelated web-comment files; kernel/source test bytes are unchanged.
  • Nineteen targeted host/ref/fork/summary/recovery/verif/version files under BOTH sandbox preloads:172 PASS,0 FAIL/SKIP. Real subset guard and bug3805/generic/induction/symbolic checks execute, not solver skips.
  • Current-master web-comment route regression runs separately after the final merge.
  • The real kernel-source synthetic probe in Historical ref floor and tombstones still permit lifetime reuse after #5360 #5485 reproduces all four failures on official .211; the repair produces all four expected values. Current master keeps the same affected official refs.ts blob.

Full public host regression is the remote CI matrix on this pushed head; no full-public-suite pass is claimed here. Kernel/message identity changes require explicit maintainer approval and human review. No approval, auto-merge, release, npm publish, service activation or store migration is claimed. This cannot reconstruct historical intent whose identity evidence was already pruned and is not a general multi-process transaction-safety claim.

@ranxianglei ranxianglei changed the title kernel: preserve issued refs and quarantine known historical collisions (#5196) [PR] kernel: preserve issued refs and quarantine known historical collisions (#5196) Oct 30, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 本 PR 对应 GitHub PR #5233(外部贡献者 qiangu2020,分支 2026-10-30_ref-safety,head 1ffd4e75),修的是 #5196 的根因面——kernel ref 分配器复用历史编号 + 冷加载重打 ref。同家族相关项:

标签: bug, scope/kernel, p1(ref 被复用 → 模型引旧 ref 可能解析/压缩到另一条消息,属数据完整性/会话损伤类,按 owner 修订归 p1;无具体客户端,不打客户端标签)。

初审初步发现(完整八问审核随后跟进):

  1. PR base dcf76075 落后当前 master 44067a5bc 一个合并([PR] fix(#5140): name the failed raw-tail reconstruction gate instead of failing closed silently #5188);GitHub 报 mergeable_state: dirty(与 master 有冲突),需要 rebase 后才能合。
  2. CI check 缓存目前为空(该 head 尚无已缓存的 check 记录)。
  3. 触碰 kernel/:PR 正文带 kernel-change: 声明,kernel 版本 0.0.170→0.0.171(符合 Kernel Boundary 版本纪律)。kernel/message-identity 变更 = 人工评审合入,禁止 auto-merge,本审核按 PR Review 规范全项执行。
  4. 一个待核实点:第 2 个 commit(5f7218c6)把 CONFIGURATION.md/LIFECYCLE.md/website yaml 的 sessions.hardMaxBytes 文档补齐和 MySQL stamp 测试期望塞进了本 PR 分支——若这些是 master 级门禁缺口,按 CI 协调纪律应收敛到 ci-fixes(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599),不应混进外部修复 PR;正在核对 master 现状判定归属。

审核进行中,结论稍后以结构化八问回复。

@ranxianglei ranxianglei added bug Something isn't working p1 scope/kernel labels Oct 30, 2026
Resolve four conflicts where this branch's CI-baseline commit (5f7218c) had
independently fixed the same gaps that already landed on master via
527e850 (sessions.hardMaxBytes config docs) and abe4c27 (v9 terminal
stamp assert in the ranxianglei#4666 concurrent-boots lock test):

- CONFIGURATION.zh-CN.md / LIFECYCLE.md / website/config-reference/process.yaml:
  take master's registration text (semantically identical; also drops an
  off-schema default_zh field only this branch had).
- tests/issue4666-migration-dedup.test.ts: take master's literal v9 assert,
  matching the three sibling asserts in the same file.

No code conflict: kernel/src/refs.ts, src/* and the rest auto-merged clean;
kernel version stays 0.0.171, root package stays 0.1.209.
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

Merge-guard outcome: merged origin/master (44067a5) into 2026-10-30_ref-safety and resolved all 4 conflicts — CONFIGURATION.zh-CN.md, LIFECYCLE.md, website/config-reference/process.yaml, tests/issue4666-migration-dedup.test.ts (all took master's canonical wording; both sides had independently fixed the same gaps, no design decision needed). Pushed fca461e; PR now reports mergeable=true / mergeable_state=blocked (checks + review pending), i.e. the conflict is cleared. Local targeted verification on the merged tree: typecheck + build green, verif-subset-guard green, kernel refs suite 20/20, plugin-fork/issue4666 suites 0 fail (full-suite verdict = CI on the new head).

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

Merge-guard re-fire note: no action taken — verified stale. Master has not moved since the resolution above (still 44067a5, 0 new commits) and the branch head fca461e already contains all of master; GitHub currently reports mergeable=true / mergeable_state=blocked (checks + review pending, not a conflict). No new push.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

冲突已解决:把 origin/master(44067a5)合入 PR 分支 2026-10-30_ref-safety,4 处冲突全部按 master 的定稿措辞解决(CONFIGURATION.zh-CN.md、LIFECYCLE.md、website/config-reference/process.yaml、tests/issue4666-migration-dedup.test.ts——两侧是各自独立修了同一批 master 级缺口,无设计分歧,未开决策 issue)。已推送 fca461e;PR #5233 现报 mergeable=true / mergeable_state=blocked(等 CI + 人工 review,内核改动本就 human-only)。合并树上本地定向验证:typecheck+build 绿、verif-subset-guard 绿、kernel refs 20/20、plugin-fork/issue4666 套件 0 fail;全量结论以 CI 新 head 为准。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

merge-guard 重复触发,已核实为陈旧告警:master 自上次解决后未动(仍 44067a5,0 个新提交),分支 head fca461e 已完整包含 master,GitHub 现报 mergeable=true / mergeable_state=blocked(等 CI + review,非冲突)。本轮无新推送;已在 PR #5233 留说明。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

merge-guard 第三次触发同一告警,状态与上两轮完全一致:head=fca461e95、base/master=44067a5bc(0 个新提交)、API 报 mergeable=true / blocked(非冲突)。本轮无动作、无推送;PR 线程已有两条同结论说明,不再重复贴。若守护侧仍在按旧快照判 dirty,建议检查其 mergeable_state 缓存/刷新逻辑(该 PR 自 fca461e 推送后 API 一直报无冲突)。

@qiangu2020

Copy link
Copy Markdown
Contributor Author

(ai: congee/gpt-6.1-sol)

Additive refresh complete at 393aeac55197c37bcebe7a4681a05c7f521d8cea, retaining the original contributor's history and current master 0d0c0b956b496761a0512558f444371aaac8531f. Focused remaining-gap issue: #5485. Root stays official0.1.211; kernel0.0.178. The appended validation section supersedes older base/version counts without rewriting prior work.

Real repository validation: typecheck/build pass; kernel1553/1553; targeted host/ref/fork/recovery/summary/verif/version172/172; newly merged web regression7/7. Official .211 reproduces the four synthetic lifetime-floor/tombstone failures in #5485; repaired source passes all four. Full public-host regression remains remote CI on this head. No full-public-suite pass is claimed.

Kernel/message-identity changes still require maintainer scope approval and human review. No approval claim, auto-merge, release, publish or service/store action. Known limits remain in the PR body.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

merge-guard 独立核实(非复读上方结论):新 head 393aeac5 已取回本地验证——① git merge-base --is-ancestor origin/master pr-5233-head = yes(master 0d0c0b95 是 head 的完整祖先,数学上无冲突),与 GitHub API 的 mergeable=true / mergeable_state=blocked 一致;② 我方此前的解决提交 fca461e95 在新 head 历史中(additive refresh 确实保留了原贡献者与守卫两侧的历史);③ 版本核对:root 0.1.211、kernel 0.0.178,与评论声明一致。守卫侧无需任何动作;PR 维持等 CI + 人工内核 review(kernel/message-identity 改动按边界规则 human-only,不自动合并)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

PR #5233(镜像 #5235)审核结论 — findings-only(kernel PR,不批准)

先说结论:代码自洽、测试有牙、无阻塞性缺陷;但这是 kernel/message-identity 变更,按 Kernel Boundary 属人工评审合入、禁止 auto-merge,agent 不得批准 → 已走 🔶 需要决策(见下条评论 + needs-decision 标签)。本条是独立重做的方向/回归/代码/测试审查,不复读 issue 侧结论。

CI(head 393aeac55,镜像缓存 @2026-11-01T16:50Z):0 failed / 13 pending(queued·in_progress)/ 15 skipped / 2 success;mergeable_state=blocked = 等人工内核评审,非冲突。

结构化八问

  1. 是什么问题:重启后可能重新盖章已发过的 ref、分配器可能复用历史编号;模型引用一个「见过」的旧 ref 时,可能解析/压缩到另一条消息(数据损坏)。
  2. 什么原因:① After model switch / client-side history rewrite, all message identities (content hashes) are replaced: ACP numbers re-m | 切模型/客户端重写历史后,消息身份(内容哈希)全部更换:acp 编号重铸、折叠覆盖大规模重挂、死 ref、churn 区临时膨胀重折 #4316 PR3/3 的冷加载 ref/ledger 对齐会在冷载时把一个编号从一条 raw 挪到另一条,而旧引用仍按 live-first 解析 → 陈旧 compress 折叠错 raw;② 分配器游标在重启后可能低于历史峰值,把已删/历史编号重新发出。
  3. 影响范围与严重程度:仅「残留 old-vs-current ref 碰撞」的会话(罕见,是已退役 restamp 的产物);严重度 p1(折叠错消息 = 数据完整性/会话损伤)。新建会话不受影响(kernel HWM 封死已发 ref)。
  4. 怎么修复(疏,治产生碰撞的机制而非症状):删掉产生碰撞的机制——冷加载不再 renumber,改为封死已发 ref;分配器两条分支都预留 dead/pruned ref 并把游标抬到 historical high-water mark 之上;统一存储 join 检测残留碰撞,对 ref-resolving 变更(compress/absorb)fail-closed 拒绝,保留 messages/blocks + 只读(decompress/search/status/export);用 metadata.refLedgerConflict 单调隔离事实贯穿 load/arbitration/save/fork/adoption。
  5. 是否有回归:逐项过——
  6. 是否破坏缓存:否。封死 ref 反而提升字节稳定(不再中史重排);quarantine 拒绝不触碰缓存。
  7. 是否改了设计方向:从「主动在 load 时对齐引用空间」转向「封死已发 ref + 隔离歧义残留」,与 KDD feat: self-update (auto + manual) #11/fix: cache health — remove condense, fix isTitleGen, preserve cache_control #13(msgid/order-centric、快照渲染)一致,属方向细化非反转。
  8. 是否引入新配置:无。无新 env/config/threshold/wire/schema/依赖;隔离是内部 metadata + 拒绝。

具体发现(均非阻塞)

  • [文档陈旧] PR 正文写 kernel 0.0.170→0.0.171、「root stays 0.1.209」;实际 head kernel 0.0.177→0.0.178、root 0.1.211(Nov-1 同步 master 后版本前移)。正文是作者原始输入,agent 不改;此处仅提示准确性。
  • [FYI] host 侧删除 persist.ts 调用后,restampRefsToLedger/restampContentStore 在 billion-context 内已无调用方;二者仍是 acp-kernel 受测公共 API(kernel/src/refs.ts:278、content-store.ts:136,kernel/tests/* 覆盖)。内核内不算死代码;留/弃属 owner/kernel 决策。
  • [运维小项] 误报 quarantine 无 operator 清除入口;逃生通道 = 导出 + 新会话。可接受。

判定:代码质量达标、测试兜底到位、无阻塞缺陷;因触碰 kernel/ 且带 kernel-change: 声明,不批准、不 auto-merge,转 🔶 需要决策请 owner 授权。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策

本 PR(PR #5233 / 镜像 #5235,head 393aeac55)触碰 kernel/(message-ref 分配与冷加载语义)并携带 kernel-change: 声明,按 Kernel Boundary 属人工评审合入、禁止 auto-merge;agent 不得批准,现请求 owner 裁决。

被门禁的 diff:

选项:

建议:A。实现自洽、测试有牙(cache-theorem 钉住 stale-cursor→m00006;absorb/S15–S19 钉住拒绝前不变量与单调隔离),无阻塞代码缺陷;唯一需 owner 拍板的是移除 #4316 冷加载对齐这一行为变更(旧:冷载重排对齐 ledger seq;新:冷载封死 ref 不动,已被对齐的会话不受影响)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

审核收工(PR #5233 / 镜像 #5235):已独立重做方向/回归/代码/测试审查——代码自洽、测试有牙、无阻塞缺陷。因触碰 kernel/ 且带 kernel-change: 声明,按 Kernel Boundary 不批准、不 auto-merge:findings-only 八问结论见上条评论,并已发 🔶 需要决策 + needs-decision 标签请 owner 授权。CI head 393aeac55 无失败(blocked=等人工内核评审,非冲突)。唯一待披露行为变更=移除 #4316 冷加载对齐。待 owner 拍板后人工合入。

@qiangu2020

Copy link
Copy Markdown
Contributor Author

(ai: congee/gpt-6.1-sol)

Async fork-publication admission follow-up

Pushed additive commit 3e137c4ac8eeeb21df9a462b0e2d04c199c8d353 to this existing PR branch as an ordinary fast-forward from 393aeac55197c37bcebe7a4681a05c7f521d8cea. This keeps the original authors and all existing changes; it does not replace the PR or alter kernel, versions, manifests, locks, storage format or API.

  • Reserve a child before the first asynchronous existence probe, so two publishers cannot both pass it.
  • Recheck publication after a pending load and keep a valid current resident.
  • Invalidate the existing pending-load claim when fork publication starts. Require ownership before adopting a late result, even after normal LRU eviction or a durable DB commit followed by an envelope error.
  • Let an old load clean up only its own claim, preserving newer single-flight work.

The identical 15-case actual-module suite was RED on the previous public head 393aeac5 (6 pass, 9 causal fail, 0 skip) and GREEN with the fix (15 pass, 0 fail, 0 skip). It uses real temporary SQLite and ordinary one-slot LRU. The envelope failure is explicitly injected after the real durable clone; it is not an actual disk outage. Known quarantine and issued/retired refs are synthetic fixtures.

Local Node 24.21.0 / npm 11.19.0 evidence on commit 3e137c4ac8eeeb21df9a462b0e2d04c199c8d353:

  • Root and kernel typechecks, official build and manifest check pass.
  • 19 bounded host files: 257 tests, 256 pass, 0 fail, 1 optional better-sqlite3 skip. All 15 causal cases and 14 S15–S19 cases execute. All 10 existing solver obligations execute with installed Z3 5.1.0.
  • Complete kernel suite: 1553 pass, 0 fail, 0 skip. Kernel stays 0.0.178 and package stays 0.1.211; neither is changed by this follow-up.

Both mandatory host preloads, the zone preload and fresh task-owned HOME/TMP/XDG were used. Dependencies came from an independent cache copy with exact-lock offline npm ci. Builds finished before test imports.

This does not claim a complete new local host-suite verdict, production acceptance, real-provider testing, or multi-process publication atomicity. The superseded base 393aeac5 had 11 concrete full-test matrix lanes passing; those old-head results do not validate this additive commit. The first new-head CI snapshot for 3e137c4a contains 54 checks: 24 successes, 15 skips, 11 in progress and 4 queued, with no failed conclusion at that snapshot. Skipped jobs are not passes, and the complete new-head matrix is still pending. Please review the follow-up and its subsequent CI. Human review of the kernel changes already in this PR remains required; no merge or publication approval is implied.

This follow-up is now on the existing PR. No merge, npm publication or release action was taken.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

已独立复审本次追加提交 3e137c4a(fix: fence async session loads across fork publication):仅新增 src/session.ts(+16)+ 新测试 tests/session-fork-publication.test.ts(+355)。以下为针对该追加提交的结论(整体内核授权仍待 owner,见第 7 问)。

范围核对:本提交为纯 host 侧——未触碰 kernel/、版本号、manifest、lock、存储格式或 API(与作者声明一致);因此本提交自身不重新触发内核门禁。但整个 PR 仍含此前已送审的内核改动 → 整体合并仍需 owner 对内核部分拍板。

机制正确性(逐条核对,判定成立):

  • publishForkSession:锁(publishingForks)在异步存在性探测之前原子获取(check→add 间无 await,单线程内无交错窗口);发布起点即失效该 id 的进行中 load 声明;sessions.set 在锁内、persist 之后完成;finally 释放锁。修掉了旧代码「存在性检查位于取锁之前」的双发布者 / 加载-发布竞态。
  • getSessionAsync:在 await store.loadAsync 之后复核——若该 id 正在发布 fork → 抛「child fork publication in progress」;若已有新 resident → stampExisting 返回胜者;若自身声明被顶替 → 抛「superseded by fork publication」。.finally 仅在 === pending 时删自己的声明,旧 load 不会清掉更新的 single-flight。
  • 非 fork 常规路径完全不变(新分支只在 fork 发布窗口激活)→ 无稳态回归。

测试有效性:约 11 个具名因果用例与修复机制一一对应(双发布者预留、in-flight load 不得在 persist 期间 adopt、无发布时 single-flight 保持、锁释放不泄漏 exclusion set、envelope 失败后恢复已 durable 提交的 fork、=== pending finally 守卫等),63 处断言,真实临时 SQLite + 单槽 LRU,作者报告旧 head RED(9 fail)→ 新 head GREEN。有牙。

CI:新 head 3e137c4a 镜像缓存 @00:52Z = 0 failed(30 total / 12 pending),blocked=等评审(非冲突)。

八问(针对本追加提交):

  1. 是什么问题:async session load 与 fork 发布并发时,load 可能在 fork persist 期间 adopt 同一 child id 造成 clobber/重复;且旧存在性检查在取锁前,两个发布者都能通过。
  2. 什么原因:单飞(single-flight)与发布互斥之间缺少「跨异步边界的再校验」——load 的 await 返回后不再确认世界是否已被 fork 发布改变。
  3. 影响面/严重度:窄竞态——需客户端请求恰好落在某 child id 的发布窗口内;一旦命中即数据损坏(child 行被覆盖/重复)。数据损坏类,但触发条件极窄。
  4. 怎么修的:fence + revalidate——发布先原子取锁并失效 load 声明;load 跨 await 后三态复核(发布中 / resident 胜出 / 声明被顶替)之一则中止或让位;.finally 只清自己的声明。
  5. 回归风险:常规路径不变,新分支只在发布窗口激活;未发现既有行为被破坏。
  6. 是否破坏缓存:不涉及(prefix cache / 账本游标不受此并发栅栏影响)。
  7. 是否改设计方向:否——只把既有的 publishingForks/pendingSessionLoads 两结构补上正确时序,不引入新抽象。整体 PR 的内核改动仍待 owner 授权(🔶 需要决策 / needs-decision 在列),本追加提交不能替代该决策。
  8. 是否引入新配置:无。

两条非阻塞观察(不拦合并,供 owner/作者定夺):

  • [可观测性] getSessionAsync 两处新 throw 无本地 loggerLog,依赖调用方(src/server/handle.ts:1432 热路径)的错误路径记录;错误信息本身清晰、可诊断。如需字段排查时更易定位,可在两处 throw 前各加一行 warn/debug 日志——可选,我可顺手补(等你点头,避免在你正迭代时往分支塞 commit)。
  • [范围] 本提交修的是「async fork-publication 准入竞态」,与 [Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196(ref 复用)是不同失败域;因本 PR 本就改了 fork 相关路径(fork-adoption / handlePluginFork / createForkAsync),放同一 PR 可辩护,是否按「一个 issue 一个 scope」拆出由 owner 定夺,我不擅自决定。

结论:本追加提交代码自洽、测试有牙、纯 host 侧、无阻塞缺陷。整体 PR 仍停在 owner 内核授权这一步(🔶 需要决策),待 owner 拍板 + 新 head CI 全绿后人工合入。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

🔶 需要决策 — PR #5233(镜像 #5235)与 master 的合并冲突含一处内核设计分叉,非机械可解,CI 车道不擅自猜解。

本轮实况(全部 live 核实,非凭记忆)

  • 镜像 check 缓存已陈旧(Nov-2 快照,报 behind);我直接用 git 重新核:merge-base(PR head, master)=0d0c0b95(Nov-2),master 现值 dc041dd1ab(今日 15:14)已领先 1415 个提交。
  • git merge-tree 实测:真冲突(exit 1),14 文件 / 22 hunk。此前 Nov-1~2 那几轮 "dirty" 是误报(当时 master 没动、只是 blocked);本轮 master 大动后冲突真实存在。
  • 推送通道已验证可用(origin 与贡献者 fork 分支 2026-10-30_ref-safety dry-run 均通过)——所以只要设计定了,我就能立刻落地并推送。

为什么不是机械冲突
22 处里 20 处是机械 union(两侧各自新增独立特性/字段/import,可安全并集):session.ts(同时保留 refLedgerConflict 与 pendingLedgerAlign)、plugin.ts/stream.ts/external-summary-compress.ts 的 import 并集、stream.ts 两套独立函数并存、版本行(kernel 0.0.178→取 0.0.196=master+1,root 0.1.211→取 master 0.1.213)。
唯一卡点是 src/persist.ts(4 hunk):

选项

推荐:default-if-undecided = C(不猜 p1 内核分叉);若 owner 明确「封死优先于 #5608-D」则走 A。

结构化八问

  1. 是什么问题:合并冲突里有一处是「同一 ref/ledger 对齐机制的两套互斥设计」相撞(PR 封死+隔离 vs master # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 延迟 restamp),不是文本级可并集的差异。
  2. 什么原因:PR 在 Nov-2 分叉并删了 maybeRestampToLedger;master 在 Nov-6 (# Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D)把同函数改成延迟执行——两条 owner 级决策落在同一机制上且互斥。
  3. 影响范围与严重程度:仅挡本 PR 合入,不直接伤用户;但属 p1 内核 message-identity 修复,猜错会触发 # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 回退或 [Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196 数据损坏级回归。
  4. 怎么修的(思路):未猜解。已清点全部 22 处——20 处机械 union 已明确(见上),只差 persist.ts 那一处分叉由 owner 定夺,即可一次性机械落地并推送。
  5. 回归风险:选 A=有意回退 # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D(需披露);选 B=需确认无双重处理;选 C=零改动零回归。本 run 未推任何内容,当前零回归。
  6. 是否破坏缓存:本 run 未改运行时代码,不涉及;# Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 本身即缓存面,选项 A/B 会触及(已在第 5 问标注)。
  7. 是否改设计方向:正是待决策点([Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196 vs # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 谁为主),未擅改,交 owner。
  8. 是否引入新配置:无,冲突解决不新增 env/config/threshold/wire/schema。

状态:已打 needs-decision 标签;工作区已清理回干净 PR head;未推送、未改 PR 正文、未开新 issue,按规则停手等 owner 拍板。定了之后(尤其 A)我可即时完成 merge + 推送。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

🔶 需要决策(仍待)— CI 车道再次被触发,已 live 复核最近楼层(floor 45–51):尚无 owner 对 floor 50 那处内核设计分叉(#5196 封死+隔离 vs #5608-D 延迟 restamp)的 A/B/C 拍板,needs-decision 标签已在。

结论不变、不重复贴全文(见 floor 50):22 处冲突里 20 处是机械 union,唯一卡点是 src/persist.ts 同一 ref/ledger 机制的两条 owner 级互斥决策——CI 车道不猜解 p1 内核取舍。master 再前进也不改变这一分叉,故本轮无新增可做的机械动作。

按规则停手等拍板;一旦你选定(尤其 A:封死优先于 #5608-D)我立即完成 merge + 推送(push 通道上轮已验证可用)。默认 C=继续 hold。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

🔶 需要决策(仍待 · 第 3 次自动触发)— 刚 live 复核 floor 52–55:仍无 owner 对 floor 50 那处内核设计分叉(#5196 封死+隔离 vs #5608-D 延迟 restamp)的拍板,needs-decision 标签在,状态与前两轮完全一致。

为避免这个 dirty 状态让 CI 车道一直空转,给你个最低成本收敛口(回一个字即可):

不重复贴分析全文(见 floor 50)。当前零改动、零回归。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

🔶 需要决策(仍待)— live 复核(floor 56–57 + 镜像缓存 23:31Z):PR head 仍 3e137c4a、仍 dirty、无 owner 拍板,与前几轮零变化,persist.ts 设计分叉(#5196 vs #5608-D)不变。

我这边机械动作已全部做完并停在 needs-decision(完整选项见 floor 50)。为避免刷屏:此后 CI 车道若再自动触发此 parked 项,我不再逐轮刷楼,静默 hold(C 默认)——你回 A / B / C 任一字,我立即落地 merge+推送。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

live 复核(镜像缓存 23:52Z + floor 58–60):PR head 仍 3e137c4a、仍 dirty、无 owner 拍板,零变化。维持 C 默认静默 hold,不再逐轮刷楼;你回 A / B / C 任一字我立即落地 merge+推送(完整选项仍在 floor 50)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

重复触发——5 分钟前 floor 60 已回复(live 核:PR head 仍 3e137c4a、仍 dirty、无 owner 拍板,零变化,静默 hold C 默认)。本轮无新增信息,不重复贴分析。你回 A / B / C 任一字我立即落地 merge+推送(完整选项见 floor 50)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

live 核(镜像缓存 13:51Z):PR head 仍 3e137c4a、仍 dirty、无 owner 拍板,零变化。此项 parked 在 floor 49 的 🔶 需要决策(needs-decision 标签在),等你对 #5196 vs #5608-D 拍 A/B/C;回任一字我立即落地 merge+推送。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 7 次自动触发。镜像 check 缓存已 31h 陈旧,本轮改用 git fetch 直接核 master 实况(非凭缓存):

结论不变:唯一卡点仍是 owner 对 #5196 vs #5608-D 的取舍,CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字我即重建分支并落地 merge+推送;若此 PR 已不再推进,关闭/搁置它即可止住 CI 车道空转。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 8 次触发,零实质变化。镜像缓存 ~2 天陈旧,git fetch 直核:master 已至 f648217cb8(Nov-15,PR #6823),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts:2038)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–72 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 9 次自动触发,零实质变化。镜像缓存 ~12h 陈旧,git fetch 直核:master 已至 4ea79acdbb(Nov-16,PR #6886),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–75 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 10 次自动触发,零实质变化。镜像缓存 ~25h 陈旧,git fetch 直核:master 已至 301e1a5459(Nov-16 20:35,PR #6151),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–79 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 11 次自动触发,完全零变化——连 master 都未再前进(仍 301e1a5459,Nov-16 20:35,PR #6151)。git fetch 直核:PR head 仍 3e137c4a、dirty;master 仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;floors 1–80 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

第 12 次自动触发,零实质变化。镜像缓存 ~28h 陈旧,git fetch 直核:master 已至 a259e0b8fa(Nov-17 23:24,PR #6996),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–83 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

第 13 次自动触发,零实质变化。镜像缓存 ~22h 陈旧,git fetch 直核:master 已至 548e39602(Nov-18 14:08,PR #7083),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–87 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

第 14 次自动触发,零实质变化。镜像缓存 ~18h 陈旧,git fetch 直核:master 已至 a446a3c1c(Nov-18 23:47,PR #6827),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;PR head 仍 3e137c4a、dirty,floors 1–89 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

第 15 次自动触发,完全零变化——连 master 都未再前进(仍 a446a3c1c,Nov-18 23:47,PR #6827)。git fetch 直核:PR head 仍 3e137c4a、dirty;master 仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处)→ persist.ts 设计分叉依旧 live;floors 1–91 无 owner A/B/C。

唯一卡点不变(owner 对 #5196 vs #5608-D 的取舍),CI 车道不猜解 p1 内核分叉。回 A/B/C 任一字即落地 merge+推送;不再推进则关闭/搁置以止住空转。完整选项见 floor 50。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策(第 16 次自动触发 · live 复核零实质变化)

本轮 live 核实(全部 git fetch 直核,非凭缓存/记忆)

唯一卡点不变:owner 对 #5196 vs #5608-D 的取舍。完整选项见 floor 49:

推荐 default-if-undecided = C(不猜 p1 内核分叉);若 owner 明确「封死优先于 #5608-D」则走 A。

CI 车道不猜解 p1 内核取舍。回 A / B / C 任一字,我立即落地 merge + 推送(其余 13 文件为机械 union,已清点;persist.ts 那一处待你定夺)。

结构化八问

  1. 是什么问题:PR 与 master 的合并冲突里有一处是同一 ref/ledger 对齐机制的两套互斥设计相撞([Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196 封死+隔离 vs # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 延迟 restamp),不是文本级可并集的差异。
  2. 什么原因:PR 在 Nov-2 分叉并删除 maybeRestampToLedger;master 在 Nov-6(# Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D)把同函数改成延迟执行——两条 owner 级决策落在同一机制上且互斥;master 此后 1747 个提交未消解该分叉。
  3. 影响范围与严重程度:仅挡本 PR 合入,不直接伤用户;但属 p1 内核 message-identity 修复,猜错会触发 # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 回退或 [Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196 数据损坏级回归。
  4. 怎么修的(思路):未猜解。已清点全部 14 文件冲突——13 处机械 union 可安全并集,唯一 persist.ts 设计分叉交 owner 定夺;定了即可一次性机械落地并推送。
  5. 是否有回归:本 run 未推任何内容,零回归。选 A = 有意回退 # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D(需披露);选 B = 需确认无双重处理;选 C = 零改动零回归。
  6. 是否破坏缓存:本 run 未改运行时代码,不涉及;# Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 本身即缓存面,选项 A/B 会触及(已在第 5 问标注)。
  7. 是否改设计方向:正是待决策点([Bug] compress can silently fold another message after restart when a pre-restart ref is reused (0.1.209) #5196 vs # Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608-D 谁为主),未擅改,交 owner。
  8. 是否引入新配置:无。冲突解决不新增 env/config/threshold/wire/schema。

状态:needs-decision 标签已在;工作区干净(未 checkout 冲突树);未推送、未改 PR 正文、未开新 issue,按规则停手等 owner 拍板。

ranxianglei pushed a commit that referenced this pull request Nov 19, 2026
Cherry-picked from #5233 (qiangu2020) kernel core, rebased onto current
master. The deadRefs tombstone infrastructure already landed via #5360;
this adds the missing ref floor:
- highestIssuedIndex: byRef orphans whose byRaw owner is gone still count
- assignRefs: cursor clamped to max(requested, historicalHighWater+1)
- ledger stamp accepted only above the floor and outside tombstones
- allocateFreeRef skips tombstoned indices
- both restamp paths seed nextIndex from the unified floor

Prevents lifetime ref reuse after pruning (the #5485 defect).

Cherry-picked-from: 3e137c4 (qiangu2020/2026-10-30_ref-safety)
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策(第 17 次自动触发 · live 复核零实质变化)

本轮 live 核实(git fetch 直核,非凭缓存)

选项(完整分析见 floor 49,上轮全文见 floor 94)

CI 车道不猜解 p1 内核取舍。回 A / B / C 任一字我立即落地 merge + 推送(其余 13 文件机械 union 已清点;persist.ts 那一处待你定夺)。本轮零改动、零推送、零回归。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策(第 18 次自动触发 · live 复核:连 master 都未动)

git fetch 直核:master 仍 6453feeeb8(Nov-19 19:12,PR #7151)、仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处);PR head 仍 3e137c4a(Nov-2);persist.ts 设计分叉(#5196 封死+隔离 vs #5608-D 延迟 restamp)依旧 live;floors 1–99 无 owner A/B/C 拍板;needs-decision 标签已在。

选项不变(全文见 floor 97/49):A = 本 PR 为准(删 restamp,回退 #5608-D)/ B = 两者共存(需内核评审确认无双重处理)/ C = Hold(推荐默认)。回任一字我立即落地 merge + 推送。本轮零改动、零推送。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策(第 19 次自动触发 · live 复核:master 又前进,分叉依旧)

git fetch 直核:master 前进到 b10c1a0d4e(Nov-20 22:31,PR #7412),仍保留 maybeRestampToLedger(#5608-D,src/persist.ts 4 处);PR head 仍 3e137c4a(Nov-2);git merge-tree 实测真冲突、14 文件(与 floor 49/97 一致);persist.ts 设计分叉依旧 live;floors 1–101 无 owner A/B/C 拍板;needs-decision 标签已在。

选项不变(全文见 floor 97/49):A = 本 PR 为准(删 restamp,回退 #5608-D)/ B = 两者共存(需内核评审确认无双重处理)/ C = Hold(推荐默认)。回任一字我立即落地 merge + 推送。本轮零改动、零推送。

This branch has not been deployed

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

Projects

None yet

2 participants