You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Protection of acp_rule invocation pairs should be conditioned on rule liveness: historical pairs of deleted rules should be collapsible. | acp_rule 调用对保护应随规则存活性条件化:已删除规则的历史 pair 应可折叠 #377
acp_rule is in ALWAYS_PROTECTED_TOOLS (src/protected.ts), so every acp_rule tool-call/result pair is hard-protected from compression unconditionally. billion-context#1177 adds rule deletion (removeRule/clearRules, shipped in acp-kernel 0.0.84) to the proxy-side executor — but after a rule is deleted its historical record pair remains permanently protected: it can never enter a compressible range, so stale rules accumulate forever in context.
Impact
Stale (deleted) rules permanently occupy context and keep influencing model behavior (real case: an "offline force-model" rule was revoked by the user but could not be removed).
Trial-and-error garbage entries cannot be cleaned up (6 dead entries were created during one debugging session).
Offsetting "void" rules make the list longer and self-contradictory over time.
Root cause
The protection decision is name-based only (isMessageProtected → ALWAYS_PROTECTED_TOOLS includes-check). No liveness signal exists anywhere on the protection path, so "the recorded rule no longer exists" is invisible to the fold planner.
Suggested fix (owner-approved direction)
Conditional protection derived from the message stream itself — works identically in proxy mode AND plugin mode (where folding runs in the agent's own kernel copy whose state has no rules table, so a state.rules lookup would misjudge live rules there):
Walk acp_rule tool-results in order. Result text forms a closed partition with host executors (billion-context executeRule is the reference implementation): Recorded ruleN: … → add id to live set; Removed ruleN: … → remove id; Cleared N rule(s). → clear set.
A record pair is protected iff its id survives the walk (kernel contract: ids are never re-issued, so final-set membership equals per-event liveness). All other acp_rule exchanges (removals/clears/listings/failures) become ordinary foldable content — they are event traces, not persistent reminders; pinning them forever would recreate the accumulation problem.
Fail-closed: a result starting Recorded with an unparseable id keeps its pair protected (format drift must never silently fold a live rule).
No-op safe: without any removal/clear events every record pair stays protected — behaviorally identical to today.
Cache-safe: zero byte change at deletion time; a dead pair is absorbed only at the next natural fold (with CCR v2, billion-context#1179, its original additionally becomes retrievable via acp_retrieve).
changed the title [-]acp_rule 调用对保护应随规则存活性条件化:已删除规则的历史 pair 应可折叠[/-][+]Protection of acp_rule invocation pairs should be conditioned on rule liveness: historical pairs of deleted rules should be collapsible. | acp_rule 调用对保护应随规则存活性条件化:已删除规则的历史 pair 应可折叠[/+]on Oct 16, 2026
Activity
ranxianglei commentedon Sep 24, 2026
[bot] 🏷 PR #378 审查完成(本 issue 的实现)— 结论:可以合并(按规范由人工合并,见末尾)。
① Issue 方向关(最高优先) — 方向正确。根因诊断准确:保护判定纯基于工具名(
isMessageProtected→ALWAYS_PROTECTED_TOOLSincludes-check),无存活性信号,导致已删除规则的历史 pair 永不可折叠。stream-derived liveness walk 是正确层次:proxy 模式与 plugin 模式下行为一致(plugin 模式的折叠跑在 agent 自带 kernel 副本里,其 state 没有 rules 表,查state.rules会误判存活规则)。我对照参考执行器(billion-context#1177 的executeRule)逐条验证了「结果文本构成闭合划分」:成功输出Recorded ${id}: …/Removed ${id}: …/Cleared N rule(s).与三条正则精确匹配;列表(N. [id] …数字开头)、惰性响应(No rules recorded.、No rules to clear.、one-op-per-call 提示)及全部内核错误串均不匹配任何正则。漂移失效分析:若未来执行器改名 Removed/Cleared 前缀,walk 漏掉事件 → pair 保持永久保护,即退化为现状(过度保护,安全方向);唯一的欠保护向量(Recorded前缀漂移)被 fail-closed 分支捕获。id 永不复用(allocateRuleId单调递增,src/rules.ts:70-72),故终态集合成员资格 = 逐事件存活性,满足设计前提。② 回归清点(diff 触碰的既有行为逐项判定):
ALWAYS_PROTECTED_TOOLS(src/protected.ts:75)无条件保护。assignRefsNode把规则保护放在hasProtection配置门之外(与 media 同层)。对运行空保护配置的宿主(kernel 默认protectedTools: []),新会话中存活规则 pair 的首次 ref 分配从带标签mNNNNN变为BLOCKED(不渲染标签,render-refs.ts:57);任何非空保护配置的宿主字节级不变(这些 pair 之前已是 BLOCKED)。既有会话不受影响(ref 不可变)。与其他所有消费端的一致性处理相符,可接受。version:未动 ✓。③ 代码审查 — walk(src/protected.ts
collectRulePairProtection)两遍扫描、保序、^锚定正则匹配内核rule${n}id 格式;result↔call 配对覆盖两种 wire 形态(projected result 无 toolName 时经调用侧名称配对;显式 toolName 亦正确处理);fail-closed 经 toolCallId 同时保护畸形 pair 的两半。五个消费端全部接线(fold 门、ref 分配、压缩过滤、CCR store、absorb+crush)。全 src/ 排查无遗漏的isMessageProtected/ALWAYS_PROTECTED_TOOLS消费端。④ 测试有效性 — tests/rule-pair-protection.test.ts 共 13 个测试(PR 描述写 11,后续测试 commit 后计数漂移,外观问题),纯函数无 I/O,断言有牙:精确 ref 集合断言、经
buildCompressibleRanges的集成验证(dead pair 可压缩 / live pair 排除)、no-op 安全、CCRstoredCount断言、absorb 拒绝 vs 放行双向。walk 每个分支都有钉住,含 re-record-after-remove 与畸形 id fail-closed。若有人日后把 acp_rule 加回ALWAYS_PROTECTED_TOOLS,tests/rules.test.ts 的反向断言 + 集成测试会抓住。⑤ diff 整洁度 — 11 个文件全部在范围内;无版本号变更、无空白重排、无生成物/锁文件连带变更。干净。
前置验证证据(本地,PR head 2f1e50a):typecheck 通过 · 全量测试 1042/1042 通过 · build 通过。
format:check报 118 个文件风格问题 — 但 master(312eb11)以完全相同的 118 个文件同样失败(src/protected.ts、src/recommend.ts在 master 上即失败),属仓库既有的 prettier 漂移,非本 PR 引入;此处整文件格式化会污染 diff,不建议在本 PR 处理。CI(head commit):绿(CI 与 PR Build Artifact 均成功)。小 nit(不阻塞):PR 描述中 "11 tests"(实际 13)、"1040/1040"(rebased head 实际 1042/1042)。
按 AGENTS.md §7.4,本改动触及内核契约 #6(protected-tool filtering),即使其余自动合并条件全部满足也须人工把关。我未合并也不会合并 — 请人工合并:#378
中文摘要:审查了 PR #378 —— 已删除规则的历史 acp_rule 调用对现在可正常折叠、存活规则仍受保护(fail-closed 兜底),闭合划分对照参考执行器逐条验证通过,测试 1042/1042 与 CI 全绿,diff 干净,可以合并(按规范由人工操作)。
ranxianglei commentedon Sep 24, 2026
[bot] 🏷 状态更新:实现 PR #378(流推导方案)已于 2026-09-24 被维护者决定搁置——理由:按消息流文本协议推导存活是补丁式做法,rule 的增删改查需综合设计先行(生命周期所有权、完整 CRUD 语义),保护语义只是下游结论。
后续路径:先出设计,再重做实现。设计 issue 已立 → acp-kernel#390(RFC:source of truth / CRUD 语义 / 保护语义三问 + A/B/C 方案对比与建议)。本 issue(#377)保持 open,待 #390 拍板后由新 PR 关闭。PR #378 代码保留为参考实现(branch
2026-09-24_rule-pair-protection)。[-]acp_rule 调用对保护应随规则存活性条件化:已删除规则的历史 pair 应可折叠[/-][+]Protection of acp_rule invocation pairs should be conditioned on rule liveness: historical pairs of deleted rules should be collapsible. | acp_rule 调用对保护应随规则存活性条件化:已删除规则的历史 pair 应可折叠[/+]