Skip to content

feat: kernel-native deterministic pre-crush via compress.crush (#1094) - #1176

Merged
ranxianglei merged 1 commit into
2026-09-23_kernel-0.0.84from
2026-09-23_crush-kernel
Sep 23, 2026
Merged

ranxianglei merged 1 commit into
2026-09-23_kernel-0.0.84from
2026-09-23_crush-kernel

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Rework of #1098 on top of acp-kernel 0.0.84 (#1175): the kernel now ships the crush strategies natively (pipeline node crush between absorb-hide and absorb-prompt, kernel PR #359), so this PR deletes the 1263-line bili-local duplicate and keeps only the config surface.

What ships:

  • compress.crush top-level key (sibling of absorb): { enabled, minReduction (ratio | percent-string), strategies: { "json-fold" | "code-trim" | "log-select": { enabled, excludeTools } } }
  • Strict parse validation (fail-loud on malformed shapes, consistent with fix: resolve issues #150 #151 #152 #154 (24h issue batch) #155 discipline)
  • Three-level merge: scalars sub-field-wise, strategies map id-wise (deeper entry replaces the id whole)
  • applyCompressSettings maps onto kernel CrushConfig (DEFAULT_CRUSH_CONFIG defaults; percent-string parsed)
  • No applyAbsorbView change — the kernel node fires inside processTurn for every existing call site (all 7 pass the active config), identical behavior in both compression modes

Why rework instead of merging #1098 as-is: #1098 carried its own JSON/code/log crushers (src/pre-crush.ts, __pre_crush envelopes) — now a byte-divergent duplicate of kernel crush.ts (__acp_crush). Two writers for one concern violates the kernel-owns-format-contract split; also its re-crush after processTurn was a non-idempotent double pass.

Testing: tests/crush.test.ts — parse validation, three-level strategies merge, kernel mapping defaults, and an integration test through processTurn proving the kernel node crushes an oversized repetitive-JSON tool result via bili config plumbing (and passes through intact, absorb-prompt-only, when crush is off).

Pre-flight: typecheck ✅ / 2288 tests 0 fail ✅ / build ✅ (on top of #1175's kernel 0.0.84 pin)

Fixes #1094
Supersedes #1098

Replaces the bili-local pre-crush library of #1098 with the kernel's
crush pipeline node (acp-kernel >= 0.0.84): config plumbing only —
three-level merge + validation for the top-level compress.crush key
mapping onto kernel CrushConfig. The kernel executes between
absorb-hide and absorb-prompt inside processTurn, so both compression
modes behave identically and no duplicate strategy library ships in
dist.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Picked up. This is a [PR] issue mirroring PR #1176 (head a807dfe5, stacked on PR #1175's kernel 0.0.84 bump). I'm pulling the branch to verify the diff, re-run the pre-flight gate (typecheck / full test suite / build), and check CI status on both PRs — will report findings here shortly.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #1176 verified — no code changes needed. Pulled 2026-09-23_crush-kernel @ a807dfe5, reviewed the full diff, re-ran the gate locally on the exact head, and checked both stacked PRs' CI.

Local pre-flight (on head a807dfe): typecheck ✅ · build ✅ · npm test: 2288 tests, 0 fail (2 skipped) ✅ — matches your claim.

Code review — claims confirmed:

  • Kernel mapping is exact. acp-kernel 0.0.84 CrushConfig (dist/types.d.ts:163) is { enabled: boolean; minReduction: number; strategies?: Record<string, CrushStrategyOverride> } — bili's applyCompressSettings maps onto it 1:1, percent-string via parsePercent ("10%" → 0.1), defaults from DEFAULT_CRUSH_CONFIG, and the spread only happens when some level defines crush.
  • "All call sites pass the active config" holds. All 7 processTurn sites in src/server.ts (L2342/2513/2716/2799/2942/3161/3241) use configs derived from reqConfig = resolveRequestConfig(...) (src/server.ts:1219), plus preflight/plugin/acp-status panel paths. Where absorb is stripped (loopConfig = { ...config, absorb: undefined }), the kernel's own gate (crush?.enabled === true && ctx.config.absorb?.enabled === true) keeps crush off — so crush can never fire without absorb, exactly as documented.
  • Merge semantics match the docs: scalars sub-field-wise across global→provider→model; strategies merged id-wise with the deeper entry replacing that id whole (verified by test). hasCompressSettings is a generic undefined-scan, so crush is counted automatically — no gap.
  • The "deleted 1263-line duplicate" framing is accurate in context: src/pre-crush.ts exists only on the unmerged feat: deterministic pre-crush channel in front of model absorb (#1094) #1098 branch (ae2a8b6), not on master — so this diff vs base is purely additive (+236/-2, 6 files), which is what makes it low-risk.
  • Diff is clean: every line relates to the feature, zh/en CONFIGURATION sections in sync, CHANGELOG entry present, no version bump, no lock churn.

Regression review — existing behaviors touched by the diff paths:

  1. Default-config requests → unchanged: no level defines crush ⇒ field absent from merged settings ⇒ applyCompressSettings returns byte-identical Config ⇒ wire identical in both compression modes.
  2. Existing compress keys (absorb/rules/tiers/nudge/etc.) → untouched; the new code path is strictly additive in parseCompressSettings/mergeCompress/applyCompressSettings.
  3. Behavior change to flag (intended): user configs containing a compress.crush block were silently ignored before (unknown key); they are now parsed and validated fail-loud — a malformed crush block now rejects the config instead of being dropped quietly. This is the fix: resolve issues #150 #151 #152 #154 (24h issue batch) #155 discipline applied to the new key, but it is a real old→new shift for anyone who had hand-written crush blocks ahead of the feature.
  4. Tool-result bytes → unchanged unless crush+absorb are both explicitly enabled AND the payload qualifies AND reduction ≥ minReduction; when active, reduction is kernel-owned (fail-open, deterministic view-only) — bili only passes config, consistent with the kernel-owns-format-contract split.

CI status:

Suggested order: merge #1175 first (it's green), then retarget/rebase #1176 onto master (or merge as-is once the base resolves) — Fixes #1094 will close the feature issue. Per §7.4 this stays a human merge either way (feat: scope + cross-repo dependency), so I won't touch it.

中文摘要:核对了 PR #1176 的完整 diff 与内核 0.0.84 的 CrushConfig 契约(映射、三级合并、fail-loud 校验均与设计一致,默认关闭时线上字节不变),本地在精确 head 上重跑 typecheck/2288 测试/build 全绿;唯一行为变化是 compress.crush 键从"静默忽略"变为"严格校验"(符合 #155 纪律),建议先合并已全绿的 #1175 再合本 PR。

@ranxianglei
ranxianglei merged commit bcc7c33 into 2026-09-23_kernel-0.0.84 Sep 23, 2026
1 check passed
@ranxianglei
ranxianglei deleted the 2026-09-23_crush-kernel branch October 15, 2026 05:32
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.

1 participant