Skip to content

fix: default-off count-triggered tier distillation, delete #238 usage gate - #380

Merged
ranxianglei merged 5 commits into
masterfrom
2026-09-24_count-trigger-off
Sep 24, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-09-24_count-trigger-off

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #379

What

Two decisions from #379 (maintainer call):

  1. Count path default-off — tiers.tier2Trigger 5→1000, tier3Trigger 10→2000. Block count is not a need signal: five 10:1-condensed summary blocks can carry almost nothing to reclaim, while every distillation rewrites the rendered wire from the fold anchor onward → prefix-cache invalidation far beyond the reclaimed tokens. This is the root cause of [Bug] oh-my-pi 长会话缓存命中率波动:相邻请求 99%→4%,125 folds 估算净收益为负 billion-context#1249 (cache-hit-rate sawtooth; maintainer's bili omp audit: distillation "actionable" at 26% usage on summary-only mass). Explicit config still fires the count path for exotic setups ("如果不去掉可以搞成配置参数 配置为1000个").
  2. Delete the fix: usage-gate count-triggered tier nudges #238 usage gate — tierCountUsageFloor (usage >= nudge.minContextLimitPct on count paths) is removed. Percentages never gate compression: growth (T1, ≥ growthFloor) and token mass (≥1.5× growthFloor) are the need signal and were already ungated. Count-based tier nudges (tier2Trigger/tier3Trigger) fire below the usage band #237's injection storm was the same disease patched at the wrong layer; tierActionHint (count-only, no gate) escaped that sweep and re-imported the symptom through the receipt channel — both channels now agree on pure count.

Diff

  • src/config.ts: defaults 1000/2000
  • src/compress.ts: t2CountReady/t3CountReady pure count; idle-reason usage-gated annotation removed; rationale comment updated
  • tests/nudge.test.ts: the two Count-based tier nudges (tier2Trigger/tier3Trigger) fire below the usage band #237 usage-band tests rewritten — (a) 5 summary blocks at 40% usage stay silent under default triggers (the #1249 repro shape), (b) explicit triggers fire below the old 45% band (gate deleted)
  • README.md: nudge section updated

Verification

  • npm run typecheck clean
  • Full suite 1029/1029 green (incl. the 39 nudge-arbitration tests)
  • Token-mass paths and the T1 growth path untouched and ungated

… gate

- tiers.tier2Trigger 5->1000, tier3Trigger 10->2000: block COUNT is not a
  need signal; count-path distillations reclaimed ~nothing while rewriting
  the wire from the fold anchor onward (prefix-cache loss, the root cause
  of ranxianglei/billion-context#1249). Explicit config still fires the
  count path for exotic setups.
- decideNudge: delete tierCountUsageFloor (#238 gate) — growth/token-mass
  are the need signal, percentages never gate compression; tierActionHint
  and the idle-reason annotation now agree (pure count).
- Token-mass paths (>=1.5x growthFloor) and the T1 growth path unchanged.

Fixes #379
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-24_count-trigger-off (efd27bc)

Option A — Install from npm PR tag (recommended)

In your adapter project:

npm install acp-kernel@pr-380

Each push to this PR publishes a new version under the pr-380 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf acp-kernel-pr380.tgz
npm install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到。这是 #379 的修复 PR,我按 PR Review 规范走完整审查(原 issue 方向 → 既有行为回归清点 → 代码 → 测试有效性 → diff 整洁度),结论稍后回帖。

ework-agent added 3 commits September 24, 2026 13:35
…le reason

Review fix for #380: the PR collapsed the ternary in the label template, which
made the .map() call fit on one line per the repo's prettier config. File was
clean before this PR; keep it clean.
Review fix for #380: the headline default-off change was only exercised via
explicit config overrides in nudge.test.ts, so a silent revert of the
defaultConfig values would keep the whole suite green. Pin the actual
defaults where production defaults are already asserted.
Review fix for #380: after deleting the #238 usage gate, the only remaining
consumer of nudge.minContextLimitPct in decideNudge is the first-sight mass
bypass (#194, compress.ts). The old 'Threshold gate' bullet contradicted the
adjacent bullet added by this PR ('no usage gate'); describe the mechanism
that actually exists.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #380 审查完成 — 可合并(需人工合并)。对照当前 master 审(base == master tip 312eb11,无 stale base);审查中直接在分支上补了 3 个小修(2362c8f..efd27bc),CI 已在新 head 上重跑全绿(详见文末)。

查重

无其他 open/closed issue 或 PR 实现同一修复;来源即 #379 本身,无并行工作。

① 方向关(原 issue)

成立,两条论断都对代码验证过:

  • count 无需求信号:t2CountReady 旧为 count >= trigger && usage >= minContextLimitPct;五个 ~10:1 浓缩摘要块几乎无可回收量,而每次蒸馏都从 fold anchor 起重写渲染 wire → 前缀缓存失效远超回收量(billion-context#1249 锯齿)。块数确实不是需求信号。
  • 错层补丁史:fix: usage-gate count-triggered tier nudges #238 只在 count 路径加了 usage gate;tierActionHint(src/compress.ts:216-227)读同一组 trigger 且无 gate——确认它就是漏点(receipt 通道)。本 PR 后两通道均为纯 count、均默认关闭,一致。
  • 修的是机制本身(默认关 + 删 gate),token-mass 路径(≥1.5× growthFloor)与 T1 growth 路径未动,仍是需求信号。治本,非治标。

② 回归审查(diff 触碰的既有行为清点)

既有行为 旧 新 结论
tiers.tier2Trigger 默认值 5 1000 有意变更(#379 maintainer call),PR 正文已披露
tiers.tier3Trigger 默认值 10 2000 同上
count 路径触发条件 count ∧ usage ≥ 45% 纯 count(growth gating 不变) 有意变更(#238 gate 删除,已披露)
idle-reason 文本 (count, usage-gated) (count) 已披露;纯诊断文本,kernel 内无消费者依赖该标注
pressure 路径(over-limit/emergency) max-pending 路由 未变——pressure 分支从不使用 t2CountReady/t3CountReady(核实 src/compress.ts:1497-1526) 保持
token-mass / T1 growth 路径 无 gate 未变 保持
显式低 trigger(如 tier2Trigger: 2) 仅 ≥45% 时触发 任意 usage 达 count 即触发 gate 删除的直接后果,即 #238 删除本意;测试 B 钉住
minContextLimitPct 消费点 count 路径 + first-sight bypass 仅剩 first-sight mass bypass(#194,src/compress.ts:1478-1482) 观察项、超范围:该 bypass 仍用百分比做「加速」门槛而非按需求压缩,#379 未点名,未动

未发现无意回归。

③ 代码审查

干净。tierCountUsageFloor 全仓零残留(src/+tests/ grep 确认);countReadyUngated/countReady 正确合并为单一纯 count 函数;config 校验 tier3Trigger > tier2Trigger 在 2000>1000 下仍成立;零运行时依赖与平台无关性保持。一个值得知道的语义细节:即使纯 count,注入仍需 growthReady(growth ≥ floor 或 first-sight mass)——显式配置的 count trigger 不会让完全空闲的会话被 nudge,它只决定「到了该压的时候压哪层」。这与 #379 的表述一致(百分比从不 gate 压缩;count 路径本就没有独立需求信号)。

④ 测试有效性

两个重写测试都有牙:

  • 测试 A(默认关):5 个 T1 块 @ 40% usage,断言静默且 doesNotMatch(/T2 \d+ blocks \(count\)/)——默认配置下 count 路径若复活会抓到。
  • 测试 B(gate 删除):显式 trigger @ 40%(低于旧 45% band),断言 shouldInject === true、tier === 3、精确 reason 串——任何百分比 gate 回潮都会抓到。

发现缺口并已直接修复:两个测试都没钉住 真实 defaultConfig 值(测试 A 显式传 1000/2000,若有人把默认值悄悄改回 5/10,全套件照样绿)。已在既有生产默认值测试里补 assert.equal(cfg.tiers.tier2Trigger, 1000) / tier3Trigger, 2000(tests/sync-config.test.ts)。

⑤ diff 整洁度

紧凑(4 文件,+27/−30,每行都在主题上)。发现两处并已直接在分支上修掉:

  1. src/compress.ts 在 master 上是 prettier-clean 的,但本 PR 缩短三元表达式后留了一个 prettier 要求单行的 .map() → 仅对该文件跑了 prettier。
  2. README 相邻的 "Threshold gate: fires when context usage ≥ minContextLimitPct" 一条在删 gate 后失实(与本 PR 新增的 "no usage gate" 自相矛盾)→ 替换为对 first-sight mass bypass(growth floor 挡住新会话/重启继承的大量就绪 pendingT1 —— 首次 nudge 被无谓推迟 #194,唯一剩余消费点)的准确描述。
    其余 3 个文件(config.ts / nudge.test.ts / README.md)在 master 上本就非 prettier-clean——属于 open 的风格收敛 PR chore: converge on explicit prettier style (#360) #361 的范围,刻意不在此重排,避免污染 diff。

验证

  • CI @ 最终 head efd27bc:test(node 22+24)、pr-validation、build-artifact 全部 success(05:36–05:37Z)。
  • 本地:typecheck clean;1029/1029 pass;prettier --check src/compress.ts clean。

合并门

按策略此 PR 必须人工合并:§7.4 将默认值变更排除在 auto-merge 之外,且被删的 usage gate 触及 nudge-invariant 契约清单(§7.3)——属 #379 中你的 maintainer call 有意变更,实现与其完全一致。跨仓说明:adapter 无需改代码,下次 acp-kernel 版本 bump 时自动继承新默认(kernel 先行),billion-context#1249 的 cache-hit 锯齿应随之消失。

中文摘要:审查了 #379 的修复 PR(count 触发默认关闭 5→1000/10→2000、删除 #238 usage gate)——方向正确、无意外回归、测试有牙;我直接在分支上补了 3 个小修(prettier 格式、默认值回归断言、README 过时描述),CI 全绿,可以合并。

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

Labels

None yet

Projects

None yet

1 participant