Skip to content

[PR] fix(omp): release the compaction takeover when bili's own view is over budget (#7060) - #8145

Open
tcflying wants to merge 3 commits into
ranxianglei:masterfrom
tcflying:2026-12-02_omp-takeover-budget-gate-7060
Open

tcflying wants to merge 3 commits into
ranxianglei:masterfrom
tcflying:2026-12-02_omp-takeover-budget-gate-7060

Conversation

@tcflying

@tcflying tcflying commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

Fixes the tracked-session half of #7060 on the omp lane.

The omp lane cancels the host's auto compaction (session_before_compact -> {cancel:true}) whenever bili "owns" the conversation. Ownership today is carriage evidence only — the proxy answers for that conversation id. On the omp lane that is not enough:

  • the host's own compaction is the only thing that rewrites the host's message array (bili folds the outbound wire view), so a cancel taken while bili's fold is not holding the conversation inside the window leaves the host with no compaction path at all — the history grows past the window and the session overflows (the reported 500366/500000 case);
  • the proxy already reports its own view of the conversation on the status route: contextTokens (the effective, post-fold context it is serving) against contextLimit (the effective limit it resolved for that session).

This PR adds the second kind of evidence to the omp takeover: bili's own view must still be inside the window. When it is not, the pass is released and the host owns that fold. The proxy reconciles the boundary on session_compact (#395) — a surviving native compaction is safe, where a wrong cancel overflows the session (the principle the ownership gate next to it already states).

The pi lane and every other host are untouched: pi's fold rides the ACP tool round-trip, so its host-visible context follows the proxy's view.

Difference from #7076

Complementary halves of the same issue — the two diffs do not overlap:

#7076 this PR
Case the proxy does not carry the conversation (unknown session) the proxy does carry it, but bili's fold is not holding the window
Evidence carriage: the identity register is not carriage evidence, the status probe decides soundness: the proxy's own effective context has reached the limit
Result native compaction proceeds native compaction proceeds

Both are needed to close #7060: #7076 alone leaves the tracked-session overflow untouched, and this PR alone leaves the unknown-session overflow untouched. They compose — with #7076's change applied, the omp lane probes the status route on every pass and this PR reads the budget evidence from that same route.

The two reads are kept separate on purpose. The ownership probe keeps its payload local to the probe, and the budget evidence is fetched fresh on every omp pass (see "Review follow-up" below): sharing one payload between passes would let two conversations in flight at the same time decide on each other's numbers — a wrong cancel is exactly the failure this gate exists to prevent. On the probe path that is two status reads per pass; on the omp identity-stamp fast path it is one (the budget evidence is the only read there).

This PR does not touch the identity-stamp fast path, so it stands alone on master and composes with #7076 in either merge order.

Behaviour

state before after
bili's fold holds the window (contextTokens < contextLimit) host's compaction cancelled unchanged — cancelled
bili's fold does not hold it (contextTokens >= contextLimit) host's compaction cancelled -> no fold -> overflow host's compaction proceeds; the host folds and the proxy reconciles on session_compact
no measurement yet (contextTokens / contextLimit absent) cancelled unchanged — cancelled (a release needs evidence)
the proxy does not carry the conversation native compaction proceeds unchanged (the ownership gate; #7076 covers the omp stamp)

Tests

tests/issue7060-omp-takeover-degradation.test.ts (7 cases):

  • the takeover stands while bili's fold holds the window, and is released when it does not;
  • missing numbers are not over budget — no evidence, no release;
  • an unknown conversation never claims the takeover;
  • the omp identity-stamp fast path does not skip the budget evidence (that path's only status read is the budget evidence itself);
  • two omp conversations decided at the same time stay independent — both passes are in flight together, so a payload shared between them would show up;
  • a released pass does not consume the auto_compaction_start announcement, and repeated passes stay released;
  • the pi lane is untouched — pi keeps its takeover even when the status says over budget.

Locally green on this head: npm run typecheck, npm run build, npm run check:unused-exports, npm run check:test-import-graph, tests/plugin-agent.test.ts (77 cases), tests/issue7060-omp-takeover-degradation.test.ts (7 cases) and tests/pi-msgids*.test.ts (26 cases — master also touched src/agent/pi.ts).

Review follow-up

The first review raised two points on the earlier head; both are addressed here:

  • the status payload was one shared mutable closure variable — two omp passes in flight at the same time could read each other's payload and decide on the wrong conversation. The budget evidence is now read fresh on every omp pass, so nothing is shared between calls; the ownership probe keeps its own payload local to the probe. The cost is one extra loopback status read on the compaction path.
  • the "parallel omp conversations" case was actually sequential — it is now genuinely concurrent (both passes in flight together, one conversation's status answer held back) and is renamed for what it does.

Not in this PR

Refs #7060, #7076.

@ranxianglei ranxianglei changed the title fix(omp): release the compaction takeover when bili's own view is over budget (#7060) [PR] fix(omp): release the compaction takeover when bili's own view is over budget (#7060) Dec 2, 2026
@tcflying
tcflying force-pushed the 2026-12-02_omp-takeover-budget-gate-7060 branch from 366345e to eece55b Compare December 2, 2026 12:12
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

PR #8145 Review — fix(omp): release the compaction takeover when bili's own view is over budget (#7060)

Direction (①): Sound. The PR fixes the tracked-session facet of #7060: when the proxy carries the conversation (200) but the fold is not holding the window (contextTokens >= contextLimit), the cancel is released so the host's native compaction proceeds. The issue's reported case (500366/500000 with "parent conversation unknown") is the unknown-session facet, which is #7076's scope — the PR correctly defers it. The budget-gate approach is a more direct signal than the issue's suggested lastCompressAt watchdog (it checks the actual state rather than inferring from compression recency).

Regression (②): None. The PR only touches the omp lane's session_before_compact handler. The pi lane handler is untouched. All fast paths (no proxyBase / non-http veto / no sid / identity stamp) leave probedStatus undefined, so ompBudgetEvidence does a fresh fetch or returns undefined — behavior is identical to before on every pre-existing path.

Code (③): Clean and well-documented. takeoverOverBudget correctly treats missing numbers as "not over budget" (no evidence → no release). ompBudgetEvidence never throws (a failed read is "no evidence", never a release).

One minor concern: probedStatus is a single shared mutable closure variable. Two concurrent omp session_before_compact handlers (different conversations, both on the probe path) can clobber it across the await fetchStatus gap. Worst case = a wrong cancel (the bug) if an over-budget conversation reads a healthy payload. This is low-probability (the omp lane is designed for one conversation per process; state.identityAt is a single value, and without #7076 the probe path is only hit when the identity stamp is absent), but real. The "one read per pass" optimization is the source; a fresh fetch in ompBudgetEvidence would remove the race at the cost of a second read in the probe path. Not a blocker.

Tests (④): Valid. 7 new cases cover the budget gate (over → release, under → cancel), the fast paths (identity stamp → fresh fetch, no sid → no release), and the pi lane being untouched. All 7 pass locally; the existing 77 plugin-agent.test.ts tests pass. Note: the "parallel omp agents decide independently" test is actually sequential (each handler call is awaited before the next), so it doesn't test concurrent interleaving — the name is slightly misleading, but the race is low-probability so this is acceptable.

Diff (⑤): Clean. Exactly 6 files (CHANGELOG.md, docs/configuration.{ja,md,zh-CN}.md, src/agent/pi.ts, tests/issue7060-omp-takeover-degradation.test.ts). No unrelated changes.

Code cleanliness (⑤b): Clean. Clear naming, no dead code, no magic numbers, no as any, comments explain the "why".

CI: Still running at review time — 16 passed, 0 failed, 12 in progress (mergeable_state: blocked on pending checks). No failures so far.

Verdict: Mergeable. The PR is well-scoped, correctly fixes a real problem (the tracked-session facet of #7060), and is clean. The race concern is low-severity and worth noting but not a blocker.


结构化八问

  1. 是什么问题: omp 车道的 session_before_compact veto 在 bili 自己的视图已超窗时仍然取消宿主原生压缩,导致会话溢出([omp lane] session_before_compact veto has no takeover watchdog in 0.1.215: ownership claimed via identity stamp, no fold ever lands, native compaction never released → context overflowed to 500366/500000 #7060 的 tracked-session 半)。
  2. 什么原因导致的: 所有权门(identity stamp 或 status probe)只判定"bili 是否认领了压缩权",不判定"bili 的 fold 是否真的把会话保持在窗内"。认领了但 fold 没守住窗时,取消宿主压缩 = 宿主没有压缩路径 = 溢出。
  3. 影响范围与严重程度: 仅 omp 车道、仅 tracked-session(proxy 200 但 contextTokens >= contextLimit)场景。严重——会话溢出到不可用(500366/500000 类)。unknown-session 半(proxy 404)由 [PR] fix(omp): identity register is NOT carriage evidence for compaction ownership #7076 覆盖,本 PR 不碰。
  4. 怎么修复的: 在 omp 的 session_before_compact 里,取消前先读 status route 的 contextTokens/contextLimit;若 bili 自己的视图已超窗(tokens >= limit),放行宿主原生压缩(release the pass)。缺数 = 无证据 = 不 release(保持现状)。pi 车道不动。
  5. 是否有回归问题: 无。pi 车道 handler 未动;所有 fast path(无 proxyBase / 非 http / 无 sid / identity stamp)都让 probedStatus 为 undefined,ompBudgetEvidence 自己 fetch 或返回 undefined,行为与改前一致。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。只是在既有所有权门后加一道预算证据门,不改所有权判定本身。
  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

判定: 可合。唯一小瑕疵是 probedStatus 共享可变闭包变量在并发 omp 会话下的竞态(低概率、最坏是错误 cancel),建议后续用 fresh fetch 消除,但不阻塞本 PR。

@tcflying

tcflying commented Dec 2, 2026

Copy link
Copy Markdown
Author

CI note: the three red lanes are not from this PR. All three fail in the same test — sessions ls and rm account for egress payloads ("no such table: eg_debug") — and the ubuntu jobs log ENOSPC: no space left on device right before it.

The same test fails on master's own CI run at this PR's base commit (230753fc, run 46869252687), so the failure is inherited from master, not introduced here. I cannot re-run the failed jobs (no admin rights on the repository), so please re-run those lanes when convenient.

Everything else is green on this PR (35 checks passing), including architecture-docs, config-surface-guard, docs-coverage, docs-sync, kernel-guard, version-guard, gate, static-gates and the rest of the test shards.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Fixed the 3 red test lanes. They were an inherited master-level born-red, not introduced by this PR — confirmed against the live job log, not just the forwarded note.

What was red: test (ubuntu-latest, 22, 1), test (ubuntu-latest, 24, 1), test (windows-latest, 22, 4) — all failing the same two subtests in tests/egress-session-footprint.test.ts: sessions ls and rm account for egress payloads (legacy tables present: false/true), error no such table: eg_debug.

Root cause: the 2026-11-30 owner ruling renamed the wire-evidence table eg_debug → egress_debug in src/storage/schema.ts (EG_DEBUG_DDL) and src/storage/store.ts (egDebugInsert/egDebugSetResponse), but the footprint test still queried the old name at :22 (footprint table map) and :78 (post-rm assertion). Master's own test lane plan-skips by design, so the red only surfaced on PR heads merged with master. (The ENOSPC: no space left on device lines in the ubuntu log are unrelated [warn] SSE-stream-dump failures, not the cause of this test failure.)

Fix (2 commits, pushed as final head a8a89becfe3, no ci-held marker → triggers the one full CI pass):

Verification (local, targeted): footprint test 2/2 green, this PR's own tests/issue7060-omp-takeover-degradation.test.ts 7/7 green, npm run typecheck clean. ci-fixes (8d196c74305) is an ancestor of master, so merging it was a no-op — the fix is in-branch per the few-line-fix policy.


中文结构化八问:

  1. 是什么问题:3 个 test 分片(ubuntu 22/1、ubuntu 24/1、windows 22/4)同挂 tests/egress-session-footprint.test.ts 的两个用例,报 no such table: eg_debug。
  2. 什么原因导致的:2026-11-30 owner 裁定把 wire-evidence 表 eg_debug 改名为 egress_debug(schema.ts EG_DEBUG_DDL + store.ts egDebugInsert/egDebugSetResponse),但该测试 :22/:78 仍查旧表名;master 自身 test 车道按设计 plan-skip,所以红只在「PR head 合 master」时显形——是 master 级 born-red,非本 PR 引入(已对 live job log 核验,非仅凭转述)。
  3. 影响范围与严重程度:所有基于含该改名的 master 的 PR head,其 test 分片跑 footprint 测试时都会红(触发条件:PR head 与 master 合并);严重度 = 阻塞 PR 合并(CI 红),非运行时/数据问题。
  4. 怎么修复的:把测试里两处旧表名改回 egress_debug(与 [PR] fix: allow fork child its own one-shot preflight fold (#8127) #8129/[PR] fix: kimi plugin manifest names root-local shims for Kimi >= 2.8 KIMI_PLUGIN_ROOT #8128/[PR] fix: overflow-arm display provenance + lastUsagePayloadUpper reload restore #8138/[PR] fix(server): log the envelope 400 reject surface (gate #8117) #8140 同款两行改名);顺带把 store.ts 注释里的旧表名也改对(纯注释)。
  5. 是否有回归问题:无。改动仅 3 行字符串(2 测试 + 1 注释),不触及任何运行时逻辑;本 PR 自身 7 个用例 + footprint 2 个用例 + typecheck 本地全绿。
  6. 是否破坏缓存:不涉及(无缓存/重试/游标/去重键变更)。
  7. 是否改了设计方向:不涉及(纯测试/注释修复,无架构/数据流转向)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

判定:3 个红分片已修,最终 head a8a89becfe3(无 ci-held 标记,触发完整 CI)已推送,等 CI 重跑转绿。给哨兵:ci-fixes 仍落后 master(是其祖先,merge 为 no-op),该 eg_debug→egress_debug 测试改名请收敛进 ci-fixes/master(继 #8129/#8128/#8138/#8140 之后的又一处分支内修复)。

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Fixed the 3 red test lanes. They were an inherited master-level born-red, not introduced by this PR — confirmed against the live job log, not just the forwarded note.

What was red: test (ubuntu-latest, 22, 1), test (ubuntu-latest, 24, 1), test (windows-latest, 22, 4) — all failing the same two subtests in tests/egress-session-footprint.test.ts: sessions ls and rm account for egress payloads (legacy tables present: false/true), error no such table: eg_debug.

Root cause: the 2026-11-30 owner ruling renamed the wire-evidence table eg_debug → egress_debug in src/storage/schema.ts (EG_DEBUG_DDL) and src/storage/store.ts (egDebugInsert/egDebugSetResponse), but the footprint test still queried the old name at :22 (footprint table map) and :78 (post-rm assertion). Master's own test lane plan-skips by design, so the red only surfaced on PR heads merged with master. (The ENOSPC: no space left on device lines in the ubuntu log are unrelated [warn] SSE-stream-dump failures, not the cause of this test failure.)

Fix (2 commits, pushed as final head a8a89becfe3, no ci-held marker → triggers the one full CI pass):

Verification (local, targeted): footprint test 2/2 green, this PR's own tests/issue7060-omp-takeover-degradation.test.ts 7/7 green, npm run typecheck clean. ci-fixes (8d196c74305) is an ancestor of master, so merging it was a no-op — the fix is in-branch per the few-line-fix policy.


中文结构化八问:

  1. 是什么问题:3 个 test 分片(ubuntu 22/1、ubuntu 24/1、windows 22/4)同挂 tests/egress-session-footprint.test.ts 的两个用例,报 no such table: eg_debug。
  2. 什么原因导致的:2026-11-30 owner 裁定把 wire-evidence 表 eg_debug 改名为 egress_debug(schema.ts EG_DEBUG_DDL + store.ts egDebugInsert/egDebugSetResponse),但该测试 :22/:78 仍查旧表名;master 自身 test 车道按设计 plan-skip,所以红只在「PR head 合 master」时显形——是 master 级 born-red,非本 PR 引入(已对 live job log 核验,非仅凭转述)。
  3. 影响范围与严重程度:所有基于含该改名的 master 的 PR head,其 test 分片跑 footprint 测试时都会红(触发条件:PR head 与 master 合并);严重度 = 阻塞 PR 合并(CI 红),非运行时/数据问题。
  4. 怎么修复的:把测试里两处旧表名改回 egress_debug(与 [PR] fix: allow fork child its own one-shot preflight fold (#8127) #8129/[PR] fix: kimi plugin manifest names root-local shims for Kimi >= 2.8 KIMI_PLUGIN_ROOT #8128/[PR] fix: overflow-arm display provenance + lastUsagePayloadUpper reload restore #8138/[PR] fix(server): log the envelope 400 reject surface (gate #8117) #8140 同款两行改名);顺带把 store.ts 注释里的旧表名也改对(纯注释)。
  5. 是否有回归问题:无。改动仅 3 行字符串(2 测试 + 1 注释),不触及任何运行时逻辑;本 PR 自身 7 个用例 + footprint 2 个用例 + typecheck 本地全绿。
  6. 是否破坏缓存:不涉及(无缓存/重试/游标/去重键变更)。
  7. 是否改了设计方向:不涉及(纯测试/注释修复,无架构/数据流转向)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

判定:3 个红分片已修,最终 head a8a89becfe3(无 ci-held 标记,触发完整 CI)已推送,等 CI 重跑转绿。给哨兵:ci-fixes 仍落后 master(是其祖先,merge 为 no-op),该 eg_debug→egress_debug 测试改名请收敛进 ci-fixes/master(继 #8129/#8128/#8138/#8140 之后的又一处分支内修复)。

@ranxianglei
ranxianglei force-pushed the 2026-12-02_omp-takeover-budget-gate-7060 branch from a8a89be to 774fd3f Compare December 2, 2026 13:44
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Conflict resolved — PR rebased onto current master, new head 774fd3f53cd.

The PR's base moved from 230753fc to 96e46fdcb58 (the #8131 merge — KDD #26 bundle split). I rebased the PR branch onto current master and resolved the overlap:

Local verification on the rebased head: npm run typecheck exit 0; tests/egress-session-footprint.test.ts 2/2 pass; tests/issue7060-omp-takeover-degradation.test.ts 7/7 pass. Working tree clean.

Push: force-pushed to the fork branch (sanctioned for this conflict-rebase; verified no concurrent push first — the fork head was still my prior a8a89becfe3). PR head is now 774fd3f53cd, mergeable: true, mergeable_state: blocked (CI running on the new head). This is the final head (no [ework:ci-held] marker) → one full CI pass.


八问(中文,供人工 reviewer):

  1. 是什么问题:PR 分支与 base 冲突(dirty)——base 从 230753fc 前进到 96e46fdcb58(合入 [PR] fix: dedupe dist bundles — shared code once, engine lazy (62MB → 7.8MB, #8074) #8131 / KDD release v0.1.10 #26 bundle 拆分),PR 的 commit 需要重放到新 master 上才能合并。
  2. 什么原因导致的:非 PR 自身缺陷,是 master 在 PR 期间前进了——[PR] fix: dedupe dist bundles — shared code once, engine lazy (62MB → 7.8MB, #8074) #8131 改了 src/agent/pi.ts 的 entryFile 解析、docs/configuration.* 的 env 表,并顺带修了 footprint 测试的 eg_debug 改名,与 PR 触碰的文件重叠。
  3. 影响范围与严重程度:仅本 PR 分支的合并状态;不影响任何已发布行为。冲突前 PR 处于 dirty 无法合并,解决后恢复可走 CI 与合并。
  4. 怎么修复的:rebase 到新 master(而非 merge,避免把冗余 commit 带进历史);pi.ts 取「并集」(master 的 chunk-safe entryFile 与 PR 的 [omp lane] session_before_compact veto has no takeover watchdog in 0.1.215: ownership claimed via identity stamp, no fold ever lands, native compaction never released → context overflowed to 500366/500000 #7060 budget gate 都保留,二者不同区);footprint 测试取 master 版(已含同样改名 + 注释),丢弃我上一轮 CI 修复的冗余 commit;store.ts 注释修复保留(master 未修);docs 两处改动在不同区域,自动干净合并。
  5. 是否有回归问题:无。typecheck 0、footprint 2/2、issue7060 7/7 全绿;pi.ts 两个改动区不重叠、无语义冲突;未触碰 wire / 配置 / 持久化 / kernel。
  6. 是否破坏缓存:不涉及——纯分支合并操作,无缓存 / 重试 / 游标 / 去重键变更。
  7. 是否改了设计方向:不涉及——未改架构 / 边界 / 数据流;[PR] fix: dedupe dist bundles — shared code once, engine lazy (62MB → 7.8MB, #8074) #8131 的 KDD release v0.1.10 #26 bundle 拆分是 master 已定的方向,本 PR 只是叠加其上。
  8. 是否引入了新的配置:不涉及——无新 env / config / 默认值。

判定:冲突已解决,新 head 774fd3f53cd 已推送,CI 正在新 head 上跑;等 CI 绿即可合并(合并权在 owner / 人工)。

tcflying pushed a commit to tcflying/billion-context that referenced this pull request Dec 2, 2026
… state

Review follow-up on ranxianglei#8145: the status payload the takeover decision used to
read was kept in one closure variable, so two omp passes in flight at the
same time could read each other's payload and decide on the wrong
conversation — the very failure this gate exists to prevent (a wrong cancel
overflows the session).

The budget evidence is now read fresh on every omp pass, so nothing is
shared between calls. The ownership probe keeps its own payload local, as
before. The cost is one extra loopback status read on the compaction path;
the benefit is that a concurrent pass can never be decided on another
conversation's numbers.

The "two conversations decide independently" case is now actually concurrent
(both passes in flight together) and is named for what it does.
@tcflying
tcflying force-pushed the 2026-12-02_omp-takeover-budget-gate-7060 branch from 01424d7 to f546a9d Compare December 2, 2026 15:29
tcflying pushed a commit to tcflying/billion-context that referenced this pull request Dec 2, 2026
… state

Review follow-up on ranxianglei#8145: the status payload the takeover decision used to
read was kept in one closure variable, so two omp passes in flight at the
same time could read each other's payload and decide on the wrong
conversation — the very failure this gate exists to prevent (a wrong cancel
overflows the session).

The budget evidence is now read fresh on every omp pass, so nothing is
shared between calls. The ownership probe keeps its own payload local, as
before. The cost is one extra loopback status read on the compaction path;
the benefit is that a concurrent pass can never be decided on another
conversation's numbers.

The "two conversations decide independently" case is now actually concurrent
(both passes in flight together) and is named for what it does.
@tcflying

tcflying commented Dec 2, 2026 •

Copy link
Copy Markdown
Author

Review follow-up — both review points addressed (head 64b6b6df). Reviewing the previous head, the bot raised two points on the first review of this PR. Both are now addressed in the new head, and the PR body was corrected where it described the old read pattern. 1. The shared mutable probedStatus (race). The status payload the takeover decision read was kept in one closure variable, so two omp session_before_compact passes in flight at the same time could read each other's payload and decide on the wrong conversation — the very failure this gate exists to prevent (a wrong cancel overflows the session). The budget evidence is now read fresh on every omp pass, so nothing is shared between calls; the ownership probe keeps its own payload local to the probe. The cost is one extra loopback status read on the compaction path; the benefit is that a concurrent pass can never be decided on another conversation's numbers. 2. The "parallel omp conversations" case was sequential. It is now genuinely concurrent — both passes are in flight together (one conversation's status answer is held back by 250 ms) — and it is renamed "two omp conversations decided at the same time stay independent" for what it does. Honest caveat: with the old shared-variable code this test also passed, because the timing window it creates is narrow. The race is removed by construction (nothing is shared between calls), not proven by the test — the test guards the property going forward rather than reproducing the old failure. Body correction. The previous body claimed the budget evidence was "one read per pass, no extra round trip" and that the identity-stamp path "does not cost a second status read". The first claim was no longer true after the race fix, and is now stated accurately: on the probe path there are two status reads per pass (the ownership probe's read and the budget evidence's own read); on the omp identity-stamp fast path there is one — the budget evidence is the only read there. The identity-stamp path's single-read property is unchanged and is still asserted by the test. Rebased onto current master (head 64b6b6df, base 301ac24f — master moved twice under this PR: the #8114 egress hard-gates merge, which also touched src/agent/pi.ts, and the #8140 envelope-400-logging merge). Both rebases were conflict-free; the PR diff is unchanged in scope (7 files: CHANGELOG.md, docs/configuration.{md,zh-CN.md,ja.md}, src/agent/pi.ts, src/storage/store.ts (comment-only), tests/issue7060-omp-takeover-degradation.test.ts). Local verification on the rebased head: npm run typecheck clean; npm run build clean (dist-import-annotations: OK, dist-external: OK); npm run check:unused-exports clean; npm run check:test-import-graph OK; tests/issue7060-omp-takeover-degradation.test.ts 7/7; tests/plugin-agent.test.ts 77/77; tests/pi-msgids*.test.ts 26/26 (master also touched src/agent/pi.ts, so master's own pi-lane tests were run against the rebased tree). Scope is unchanged and stays orthogonal to #7076: #8145 only releases the native fold when bili already took the conversation over and its own view is over budget (contextTokens >= contextLimit). The unknown-session half remains #7076's scope.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Verified the live state independently — the conflict is gone, the head is healthy, and CI is running with no failures.

I did not take the forwarded claims at face value; I checked the live sources:

  • Head / base: PR head is f546a9db (matches the comment); base is 804dd31c, which is exactly the current origin/master tip (the [PR] egress plane: freeze accepted bytes, fail loud on identity swaps (#8098) #8114 egress hard-gates merge). So the PR is now based on the live master, not a stale base.
  • Conflict: mergeable: true, mergeable_state: blocked (blocked = CI running, not a merge conflict). The dirty state from the previous wake is resolved — the rebase onto 804dd31c cleared it.
  • CI (mirror cache): 30 checks, 0 failed, 13 in progress (the test shards + static-gates), 17 already green. Nothing red to fix right now.
  • The race fix is real (code-verified): the shared closure variable probedStatus is gone. ompBudgetEvidence (src/agent/pi.ts:1476) now calls fetchStatus(proxyBase, sid) fresh on every omp pass with no state shared between calls, and ownsCompaction no longer captures a payload — the race is removed by construction, exactly as described.

Local verification on the new head f546a9db (targeted, per local-testing discipline): npm run typecheck exit 0; tests/issue7060-omp-takeover-degradation.test.ts 7/7; tests/plugin-agent.test.ts 77/77; tests/egress-session-footprint.test.ts 2/2; tests/pi-msgids*.test.ts 26/26.

State: no conflict, no red CI, head is healthy. The 13 in-progress shards are the authoritative full-suite verdict — I'll confirm green when they land, and if any shard goes red I'll fix it on the branch. No action needed from anyone right now.


八问(中文,供人工 reviewer):

  1. 是什么问题:上一轮唤醒的合并冲突(PR 落后于 master)已由贡献者 rebase 到当前 master 804dd31c 解决;本轮是贡献者推送新 head f546a9db(修 review 指出的竞态 + 真并发测试)后的状态确认。
  2. 什么原因导致的:非缺陷——是 PR 正常推进:贡献者按 review 意见把共享可变 probedStatus 闭包变量改成每次 omp pass 现读(ompBudgetEvidence 内直接 fetchStatus),消除并发 pass 串读对方 payload 的竞态。
  3. 影响范围与严重程度:仅本 PR 分支;不影响已发布行为。冲突前 dirty 不可合并,现 mergeable: true。
  4. 怎么修复的:贡献者侧修复(非我本轮动手);我独立核对了代码——probedStatus 共享变量已删除,ompBudgetEvidence(pi.ts:1476)每次现读、调用间无共享状态,竞态按构造消除。
  5. 是否有回归问题:本地 typecheck 0 + issue7060 7/7 + plugin-agent 77/77 + footprint 2/2 + pi-msgids 26/26 全绿;pi.ts 改动未触碰 wire/配置/持久化/kernel;全量回归以 CI 13 个在跑分片为准。
  6. 是否破坏缓存:不涉及——竞态修复只改 omp 压缩路径的 status 读取时序(每 pass 一次 loopback 读),无缓存/重试/游标/去重键变更。
  7. 是否改了设计方向:不涉及——未改架构/边界/数据流;只是把「共享闭包变量」换成「每次现读」的局部实现调整。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

判定:冲突已解决、无红 CI、新 head f546a9db 本地健康;等 13 个在跑分片出结果,绿即可合并(合并权在 owner/人工),红则我来修。

Codex Developer and others added 3 commits December 2, 2026 23:50
…r budget (ranxianglei#7060)

The omp lane's session_before_compact cancel claims compaction ownership on
carriage evidence alone. On this lane the host's own compaction is the only
thing that rewrites the host's message array — bili folds the outbound wire
view — so a cancel taken while bili's fold is NOT holding the conversation
inside the window leaves the host with no compaction path at all: the history
grows past the window and the session overflows.

The takeover now needs a second kind of evidence: the proxy's own effective
context for that conversation (contextTokens vs contextLimit on the status
route) must still be inside the window. When it is not, the pass is released
and the host owns that fold — the proxy reconciles the boundary on
session_compact (ranxianglei#395), and a surviving native compaction is safe where a
wrong cancel overflows the session.

The pi lane is untouched: its fold rides the ACP tool round-trip, so its
host-visible context follows the proxy's view. Missing numbers are not over
budget — a release needs evidence, so an unmeasured session keeps today's
behaviour.
sessionStorageStats doc comment still referenced the pre-rename table name; the table is egress_debug since the 2026-11-30 owner ruling. Comment-only, zero runtime impact. Small in-passing fix (owner policy 2026-10-01) found while fixing the footprint test red.
… state

Review follow-up on ranxianglei#8145: the status payload the takeover decision used to
read was kept in one closure variable, so two omp passes in flight at the
same time could read each other's payload and decide on the wrong
conversation — the very failure this gate exists to prevent (a wrong cancel
overflows the session).

The budget evidence is now read fresh on every omp pass, so nothing is
shared between calls. The ownership probe keeps its own payload local, as
before. The cost is one extra loopback status read on the compaction path;
the benefit is that a concurrent pass can never be decided on another
conversation's numbers.

The "two conversations decide independently" case is now actually concurrent
(both passes in flight together) and is named for what it does.
@tcflying
tcflying force-pushed the 2026-12-02_omp-takeover-budget-gate-7060 branch from f546a9d to 64b6b6d Compare December 2, 2026 15:51

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

Labels

None yet

Projects

None yet

2 participants