Skip to content

feat: acp_rule on by default + /acp-rule remove/clear forwarding (#1399) - #1402

Merged
ranxianglei merged 4 commits into
masterfrom
2026-09-26_rules-default-on-acp-rule-remove-clear
Sep 26, 2026
Merged

ranxianglei merged 4 commits into
masterfrom
2026-09-26_rules-default-on-acp-rule-remove-clear

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1399

Behavior changes (flagged per owner policy)

  1. compress.rules default: false → true (诉求 1). The persistent-rules feature (acp_rule) was pure opt-in; an absent config block now means enabled, and only an explicit compress.rules: false at any level disables it. Rationale: owner decision that the model owns session rules — most users never found the opt-in switch, so the feature effectively did not exist. Risk is minimal: the tool description is self-contained, there is zero system-prompt cost, and rules are hard-protected across compression (an ACP selling point). Migration: users who relied on off-by-default should set compress.rules: false.
  2. /acp-rule command surface expanded (诉求 2): pi/omp lanes previously could only list/record. Now remove <id> forwards {delete} and bare clear forwards {clear:true} to the same executeRule path as the model's tool; bare remove warns with usage instead of forwarding; clear <text> records text instead of wiping (typo guard). Humans now have full parity with the model side (fixes the inversion vs billion-context-pi's native adapter).

Changes

  • src/rules-feature.ts: rulesEnabled() = config.rules?.enabled ?? true; new effectiveRulesEnabled(session, fallback) for session-level paths
  • Gates flipped at all four sites: executeProxyTool (src/loop/core.ts), isProxyToolFor (src/absorb.ts), plugin-tool allowlist (src/plugin.ts), manifest advertisement (via rulesEnabled). Kernel needs no change — acp_rule is unconditionally protected there.
  • src/agent/pi.ts: /acp-rule subcommand parsing + description update
  • Docs en+zh (CONFIGURATION ×2, README ×2, PLUGIN.md): default line + migration note, full /acp-rule usage incl. remove/clear, stale "feat: acp_rule delete/clear — wire kernel removeRule/clearRules (#1177) #1178" claim removed
  • Tests: default-on expectations flipped at every gate site (rules, rules-wire, issue1192, issue1204, wire-contract, plugin-protocol, codex-official, launcher-plugin-mode); new regression cases (default-on execution, remove/clear/bare-remove/clear-text forwarding); two exact-budget harnesses in preflight-compress.test.ts pin rules: false following the file's own CCR precedent (the new ~300-token schema would shift those fold boundaries)
  • Golden tests/golden/wire-contract/manifest-default.json regenerated via scripts/update-wire-contract-goldens.ts (required by the §7.3 wire-constraint-ledger rule — the default surface now advertises acp_rule); kernel/bili/optin goldens byte-identical after regen

Pre-flight

  • typecheck ✅ · full unit suite 2789 pass / 0 fail ✅ · build ✅
  • E2E codex preflight (E2E_CHECK=1) ✅; the full ACP_TEST_E2E=1 run could not complete locally because this environment's local upstream endpoint was refusing TCP connections (transient environment issue, unrelated to the diff — the proxy itself returned its structured 502 diagnostics correctly). The repo's ci-e2e workflow auto-runs the suite against this PR (diff touches src/loop/** and src/agent/**).

诉求 1 — compress.rules defaults ON (owner decision: the model owns session rules):
- rulesEnabled(): absent block now means enabled; only explicit false disables
- new effectiveRulesEnabled() for the session-level plugin-tool paths
  (loop/core executeProxyTool, absorb isProxyToolFor, plugin tool allowlist)
- kernel needs no change: acp_rule is unconditionally protected there

诉求 2 — human-side parity: pi/omp /acp-rule now forwards the full op set:
- bare = list, text = record (unchanged)
- 'remove <id>' -> { delete: id }; bare 'remove' warns with usage, no forward
- bare 'clear' -> { clear: true }; 'clear <text>' records (typo guard)

Docs en+zh: rules default line + migration note, /acp-rule usage incl.
remove/clear, stale '#1178' claim removed. Tests: default-on expectations
flipped at every gate site, new forwarding/regression cases, wire-contract
ledger + manifest-default golden regenerated via scripts/update-wire-contract-goldens.ts.
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-26_rules-default-on-acp-rule-remove-clear (b3d211f)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1402

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

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1402.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] 🏷 Reviewed PR #1402 end-to-end (full diff, every gate site, test assertions, CI). Verdict: mergeable — recommend owner merge.

① Original issue direction (#1399)

  • Root causes correctly identified and fixed at the source: 诉求1 = pure opt-in predicate made the feature effectively invisible; 诉求2 = human/model capability inversion vs billion-context-pi's native adapter. No symptom-masking anywhere.
  • Default-on is the owner's stated product decision in the issue background — no further 拍板 needed.
  • Approach is minimal and structurally sound: one predicate flipped (rulesEnabled = config.rules?.enabled ?? true) plus a session-aware twin (effectiveRulesEnabled). Grep-verified inventory: exactly 8 gate sites (wire injection ×4 in src/server.ts:2724/2924/3152/3389, manifest src/plugin.ts:572, execution allowlist src/plugin.ts:897, executeProxyTool src/loop/core.ts:187, isProxyToolFor src/absorb.ts:55) — all key off these two functions, so no site can drift. src/server.ts correctly needed zero edits.

② Regression audit (pre-existing behaviors touched)

  1. compress.rules default off→on — intended (owner decision), disclosed in PR body + CONFIGURATION en/zh migration notes + README. Consequence: ~300-token tool schema rides every request on the 4 native-tools wires, and every plugin manifest now advertises it. Escape hatch compress.rules: false documented at every surface.
  2. Wire surface grows by acp_rule on anthropic/openai/responses/google — tested per wire (rules-wire, codex-official, wire-contract D). Tools-array-only growth; no system-message or protocol-shape impact (SGLang single-system unaffected — it's a tool declaration, not a message).
  3. Default manifest advertises acp_rule — the dsh acp rule报错 #1192 invariant (advertise ⟺ executable) holds because manifest and execution allowlist read the same predicate; golden manifest-default.json regenerated via the sanctioned script, all other goldens byte-identical.
  4. Execution: acp_rule calls now execute by default instead of answering [Unknown proxy tool] — intended.
  5. /acp-rule reserves remove … and bare clear — a literal rule named "clear" can no longer be recorded via the human command (model side unaffected). Effectively unreachable in practice; typo-guard rationale documented. Intended/disclosed.
  6. Deepest-wins merge semantics unchanged — verified src/compress-settings.ts:329: s.rules !== undefined ? { rules: { enabled: s.rules === true } } : {}, i.e. absent leaves the base block untouched, so ?? true flips exactly the unset case.

No unintended regressions found.

③ Code review

  • effectiveRulesConfig validates the stored metadata (typeof meta.enabled === "boolean") before use; storeEffectiveRules(null) falls through to the base config — robust across both config sources.
  • pi.ts subcommand parsing: empty→{} list, remove <id>→{delete}, bare clear→{clear:true}, else record; bare remove warns without forwarding. All ops flow through the existing forwardTool → the same executeRule path as the model tool, and the dsh acp rule报错 #1192 disabled-note detection (startsWith("acp_rule is not enabled")) applies to remove/clear identically.
  • omp coverage confirmed: src/agent/omp.ts:1 and src/agent/omp-native.ts:21 both import createBiliPlugin from ./pi.js — one registration covers all four pi/omp entries, matching the issue scope.
  • Kernel pin 0.0.93 ≥ 0.0.84 — delete/clear supported by the bundled kernel (docs' requirement satisfied).
  • Minor (non-blocking, pre-existing): the disabled-feature messages say compress.rules.enabled (src/plugin.ts:648, pi.ts enablement warning) while the user-facing key is the boolean compress.rules — inherited from the absorb message pattern, where .enabled is the real key. Cosmetic; fine as a follow-up string fix.
  • Minor (by design): remove requires exactly "remove " (single space); remove\tid or Remove x record literally. Acceptable strictness.

④ Tests

  • Real assertions throughout: deepEqual on exact forwarded args ({delete:"rule1"}, {clear:true}, {rule:...}), returned content, manifest toolNames per wire shape, wire-forwarded tool sets. Nothing tautological.
  • New regression cases pin both directions: default-on executes (issue1192, rules-wire, wire-contract C/D, codex-official, launcher-plugin-mode) AND explicit-false disables everywhere (rules, rules-wire, wire-contract C, issue1204, plugin-protocol, manifest hidden on all three shapes).
  • The two exact-budget preflight harnesses pinning rules: false follows the file's own CCR precedent with tripwire comments — the correct way to handle the fold-boundary shift rather than silently re-baselining.
  • Golden regen via scripts/update-wire-contract-goldens.ts satisfies the §7.3 wire-ledger rule (default surface now legally advertises acp_rule).

⑤ Diff cleanliness

22 files, +343/−91, every file on-purpose (rules-feature, config comment, 3 gate consumers, pi agent, 5 docs en/zh, 10 test files incl. 1 golden). No unrelated changes, no whitespace churn, no package.json/lockfile churn (kernel pin untouched → no cross-repo dependency).

Evidence

  • Base fresh: head 93e25138 contains master tip 36d654ff (rev-list --count 93e25138..origin/master = 0).
  • CI 13/13 green on head: unit matrix (ubuntu 22/24 + windows 22/24), e2e, build-artifact, version-guard, hermetic registry e2e, real pi/dsh/codex/opencode lanes — the author's local ACP_TEST_E2E gap (transient upstream TCP refusal) is covered by the CI e2e run.
  • Author pre-flight (typecheck ✅ / 2789 pass / build ✅) is consistent with CI results.

中文摘要:审核了 #1402 —— 把 acp_rule 默认打开(单一谓词翻转,8 处门控全部同源、grep 清点无遗漏,server.ts 无需改动),并为 pi/omp 的 /acp-rule 补齐 remove/clear 转发(与模型侧同一执行路径,含裸 remove 警告和 clear 手误保护);两处行为变更均按规范披露且带迁移说明,回归清点未发现意外回归,测试断言有牙、CI 13/13 全绿,可以合并。

…injection

Owner decision on #1402: the #1399 'model has full rights over session
rules' ruling covers the CAPABILITY (record/list/delete/clear, unprompted
use allowed) within sessions where the feature is enabled — it does not
inject the tool for everyone. Revert rulesEnabled/effectiveRulesEnabled
to explicit-enable (=== true), flip every default-on assertion back
(rules/manifest/mcp-shell/wire-contract/codex-official), regenerate the
default golden manifest without acp_rule, and update README/CONFIGURATION
(en+zh) + PLUGIN.md wording.
@ranxianglei

Copy link
Copy Markdown
Owner Author

Owner 裁决落地(head ecc60ef):#1399 的"模型对会话规则有全权"指的是开启后的能力范围(record/list/delete/clear,且可未经提示自主调用),不是默认注入——acp_rule 回到 opt-in。

改动:

  • rulesEnabled / effectiveRulesEnabled 回到 === true(显式 compress.rules: true 开启;显式 false 仍是大声关闭)
  • 全部默认开断言翻回:rules/manifest/mcp-shell/wire-contract/codex-official(BASE_EXPECTED 去掉 acp_rule;opt-in lane 测试显式 rules: true 并把它加进期望表——开启路径的注入覆盖保留)
  • 默认 golden manifest 重新生成,acp_rule 退出(-81 行,精确回滚 PR 的 +81)
  • README/CONFIGURATION(en+zh)/PLUGIN.md 措辞:默认关闭;开启后模型全权+可自主调用(rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权) #1399)

门禁:定向 134/134 + typecheck 0 错(全量远程 CI)。

保留不变:CRUD 全能力面(delete/clear + /acp-rule remove <id> / clear)、自主调用语义、#1192 纪律(未开启绝不广播)。

ework-agent added 2 commits September 26, 2026 20:55
The pivot commit rewrote the Description lines of the compress.rules entry but left the Default line as 'true (since #1399; previously false)' in CONFIGURATION.md / CONFIGURATION.zh-CN.md — self-contradictory with the 'off by default' description directly below. Restored to the pre-PR value 'false'.
…te (#1399 pivot)

v1 pinned 'rules: false' with a comment claiming '#1399 made it default-on'; after the pivot acp_rule is opt-in again, so the pin is redundant (absent == false, verified via compress-settings.ts mapping) and the rationale comment describes a world that no longer exists. Restored master's original comment block + config object; file is now byte-identical to master. Targeted rules suites: 134/134 pass.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Round-2 review of the pivot commit ecc60ef — revert verified correct, but I found two residuals the pivot missed and fixed them directly on the branch (commits below). Verdict: code is right; two gate items remain before merge (see end).

What I verified in ecc60ef (the opt-in revert)

  • Core: rulesEnabled / effectiveRulesEnabled back to === true; comments now encode the ruling correctly ("full rights = capability when enabled, not default injection"). All 8 gate sites inherit via these two predicates — re-grepped, no site left behind.
  • Assertions flipped back completely: rules/rules-wire (unset → not injected, with teeth), issue1192 (unset → ok:true explanation, same as explicit false), plugin-protocol manifest (default = base 6 tools, all three wire shapes), wire-contract C (default surface has no acp_rule), launcher-plugin-mode mcp-shell tool lists. Enabled-path coverage preserved as claimed: wire-contract D and codex-official now set rules: true explicitly and assert acp_rule in the forwarded/injected set.
  • Golden tests/golden/wire-contract/manifest-default.json is byte-identical to master (exact rollback of v1's regen).
  • 诉求 2 untouched: /acp-rule remove <id> / bare clear forwarding + the new plugin-agent regression cases all intact; dsh acp rule报错 #1192 discipline (never advertise when off) preserved by construction.
  • Docs description lines correctly rewritten (off by default + "开启后模型对会话规则有全权、可未经提示自主调用 rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权) #1399").

Two residuals found — fixed in place (pushed, branch now at b3d211f4)

  1. e04a9d52 docs: stale Default lines — the pivot rewrote the Description lines of the compress.rules entry but left - **Default:** \true` (since rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权) #1399; previously `false`)in CONFIGURATION.md:407 and- 默认值: `true`(rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权) #1399 起…)in CONFIGURATION.zh-CN.md:407 — self-contradictory with "off by default" one line below. Restored both to the pre-PR value`false``.
  2. b3d211f4 test: stale pin/comment in tests/preflight-compress.test.ts — v1's exact-budget harnesses still carried rules: false with a comment claiming "rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权) #1399 made it default-on"; that rationale describes a world that no longer exists. Restored master's original comment block + config object (file now byte-identical to master). Behavior-neutral: absent == false under opt-in (verified via the compress-settings mapping at src/compress-settings.ts:329).

Evidence: targeted run of all 10 rules-related suites locally = 134/134 pass / 0 fail (matches your number exactly), typecheck clean. Remote CI on b3d211f4: e2e ✅, build-artifact ✅, version-guard ✅, hermetic registry e2e ✅, real codex lane ✅; remaining jobs in progress at time of writing.

Remaining gate items before merge

  1. Rebase to current master — the branch is now 15 commits behind (mergeable_state: behind; round-1 base was fresh). Master since then: releases v0.1.155/v0.1.156, [Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403 pck-leak fix, fix: re-anchor the fetch chain when a coexisting plugin tears down its adopted wrapper (#1410) #1412 fetch-reanchor, test: pin claude-bridge lane — compress, 1M beta window, no false over-window (#1339) #1389 claude-bridge pin, issue templates. Four files overlap (src/agent/pi.ts, src/config.ts, tests/plugin-agent.test.ts, tests/wire-contract.test.ts) — GitHub reports no textual conflict, and I checked master's changes to those files don't semantically collide with this PR's regions, but per §7.2 the full gate (typecheck + suite + build, ideally the E2E suite) should run once on the rebased head before claiming mergeable.
  2. Windows test matrix still in progress on ecc60ef when I first looked; superseded anyway by item 1.

中文摘要:二审了 owner 裁决后的回退提交 ecc60ef(acp_rule 回到 opt-in、开启后全权)——核心回退完整正确、断言全部翻回且保留开启路径覆盖、golden 精确还原、诉求 2 的 remove/clear 转发原样保留;发现并已在分支上直接补两个遗漏(两份 CONFIGURATION 的 Default 行仍写着 true、preflight 测试残留"default-on"注释与冗余 pin,已恢复为 master 原状,本地定向 134/134 全过);代码本身可以合并,但分支已落后 master 15 个提交,合并前需先 rebase 并在 rebased head 上重跑全套门禁。

@ranxianglei
ranxianglei merged commit 30701b0 into master Sep 26, 2026
13 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-26_rules-default-on-acp-rule-remove-clear 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.

rules 默认打开 + /acp-rule 命令补 remove/clear 转发(人类侧删除权)

1 participant