Repository navigation
feat(#2446): durable-state carriers become virtual tool paths (Config.messagePathOf) - #2736
Conversation
….messagePathOf) The four dsh durable-state text carriers (#2419 skill catalog, #2446 mcp catalog, #2447 workspace-instructions baseline, #2481 runtime-context snapshot) stop being host-hardcoded boolean guards. A lane-scoped host classifier now projects each carrier to a canonical durable/<name> identity via the new kernel Config.messagePathOf hook, and the EXISTING protectedTools / protectedLatestTools pattern machinery governs them — same knobs, same semantics as the tool channel (#1947). kernel (0.0.116): - Config.messagePathOf: host-projected virtual tool path (pure, cheap, never re-projects tool-call/tool-result) - protected.ts: virtualToolPathOf; isMessageProtected + collectLatestProtected + isMessageLatestProtected accept virtual paths (protectedTools patterns and per-path latest semantics both apply to projected carriers) host: - durable-message-guards.ts rewritten: DurableMessageClassifier per carrier (same matching predicates, evidence comments preserved), durableMessageToolPaths registry (KDD #9 dsh-only allowlist unchanged), withDurableProtection() — default injects durable/* all-instance protection (byte-equivalent to the old boolean guards); ANY durable pattern in protectedTools/protectedLatestTools = whole-identity takeover (user policy wins verbatim, only the classifier is attached) - handle.ts / session.ts wiring + config.ts JSDoc for both knobs tests: kernel protected-virtual-paths 6 (projection domain, pattern matrix, per-path latest, tool-channel parity); host durable-tool-identity 8 (policy units + e2e: default all-instance, durable/* latest takeover, exact-identity takeover, lane scoping); the four #24xx suites migrated to the Path API with e2e assertions unchanged (behavioral parity). kernel-change: yes — kernel/package.json 0.0.115 -> 0.0.116; new optional Config field messagePathOf plus virtual-path support in protected.ts. Backwards compatible: without messagePathOf the kernel behaves exactly as before (all suites unchanged).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3009-pr.2736.36e9542This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2736.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2736 review 结论(分支 结构化八问
测试有效性(质量关)
发现(F1/F2 需你拍板,F3 已顺手修,F4/F5 记录在案)
判定代码过审:kernel 侧改动最小且干净,调用点传导完整,clone-safe 纪律保持,测试真实,CI 绿。F1 补齐(或你明确豁免文档要求)后可合;F2 是方向确认项。按 Kernel Boundary,此 PR 属 human-only review 档(kernel 0.0.115→0.0.116 + feat + 配置语义),我不代合。 |
[bot] 🏷 F3 已修(上一条 review 的发现项):迁移后残留的四处旧函数名引用已直接在 PR 分支上修正——commit
纯注释/测试标题改动,零逻辑变化;CI 将在新 commit 上重跑确认。其余发现项维持原结论:F1(CONFIGURATION.md en+zh 补 durable/ 值域)建议合并前补;F2(#2446 与 open PR #2576 的关系)待你方向确认*。 |
… single live copy) Switch withDurableProtection's injected default from protectedTools "durable/*" (all-instance) to protectedLatestTools "durable/*": every carrier keeps exactly its newest instance pinned (skill/MCP visibility can never be lost — the #2419 fingerprint gate never resends an unchanged catalog), while superseded instances (runtime snapshots, re-based AGENTS.md lines) fold normally. This matches the pi reference architecture, where the skill catalog and AGENTS.md live in the system prompt as a single live copy, and cuts the pinned tail (runtime-context snapshots accumulate per state change). Explicit takeover unchanged: any durable pattern in protectedTools/protectedLatestTools takes over the whole policy verbatim. Owner decision 2026-10-11 (pi/dsh-native comparison: pi keeps both carriers alive forever via system-prompt residency; dsh-native compaction protects neither — its summary template has no skill/instructions section and there is no re-injection).
…D BLOCKS section The bare /\bb(\d+)\b/ harvest matched the ACTIVE SURFACE build stamp "(b<shortsha>)" first whenever the CI merge ref abbreviates to 'b'+digits (#2736 run 38119865934: merge b288144 → decompress "b288144" → block not found → rebuilt-history assertion failed twice, deterministic per-merge-ref). Anchor to the COMPRESSED BLOCKS section so the block listing is the only harvestable surface.
|
The two a5a29a1 anchors the harvest to the COMPRESSED BLOCKS section (deterministic, immune to the stamp). Verified locally against pinned pi-stable 0.83.6 (A green, 6.3s). |
[bot] 🏷 Round-2 review: lottery diagnosis confirmed, c2a1947 policy flip reviewed, branch re-greened after the master merge ① Lottery diagnosis — verified point-by-point in codeYour root cause is exactly right; I traced every link:
② c2a1947 (default → latest-per-identity) — reviewed, soundSemantics check on all four carriers: each is a cumulative snapshot where the newest instance IS the source of truth (catalogs are re-emitted only on visible-set change via the fingerprint gate; agents-md baseline only on
③ The #2658 reds — cross-branch flake, already fixed upstreamWhile chasing these I gathered independent evidence they were not your diff:
④ Fixes I pushed to the branch (all verified)
⑤ Final stateCI fully green on 结构化八问(round-2 delta)
遗留项(不阻塞本次代码判定):F1 — CONFIGURATION.md en+zh 仍缺 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.272-master.8e16c89 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…ages — model echo cannot take over a durable identity The four dsh carriers are host INJECTIONS into the user channel, but the classifiers matched on contentType+text alone: an assistant message echoing a carrier marker (<available_skills>, Instructions from:, <mcp_catalog>, Current runtime context) projected to durable/<name> too. Under the default latest-per-identity policy (ranxianglei#2736) the LAST match wins, so a later model echo took the identity over from the real carrier: the echo got pinned, the real carrier demoted to foldable, and one compression later the forged/partial copy was the only survivor — including the adversarial variant where an injected instruction makes the model emit a fake <mcp_catalog> with attacker-chosen server names (the ranxianglei#2446 failure mode, attacker-authored). Anything visible to the model eventually shows up in its output (bili-chain tags, ranxianglei#2483 render tags, ranxianglei#933/ranxianglei#1039 echo noise), so the gate cannot be the marker text. Every classifier now refuses assistant-role messages first (system/user injections stay covered); zero legitimate protection loss — no carrier is ever emitted as assistant output. Kernel unchanged: virtualToolPathOf stays role-agnostic by design; the boundary belongs to the classifiers that own the evidence (KDD ranxianglei#9). tests/issue2766-durable-role-gate.test.ts: 11 cases — per-carrier echo never projects (individual + lane-composed), user-role still projects, system-role still projects, collectLatestProtected keeps the real carrier as the latest instance across a later echo, echo between two real snapshots does not break succession.
feat(#2446): durable-state carriers become virtual tool paths (Config.messagePathOf)
What
The four dsh durable-state text carriers stop being host-hardcoded boolean guards:
<available_skills>)<mcp_catalog>)Instructions from: AGENTS.md)Current runtime context)A lane-scoped host classifier now projects each carrier to a canonical
durable/<name>identity via the new kernel hookConfig.messagePathOf, and the existingprotectedTools/protectedLatestToolspattern machinery governs them — same knobs, same semantics as the tool channel (#1947 projectedskill/<name>the same way). The kernel never learns dsh dialects: it only consumes identities.kernel-change: yes —
kernel/package.json0.0.116 → 0.0.117 (post-merge bump: master already took 0.0.116 for #2663/#2695/#2607 kernel work). New optionalConfig.messagePathOf?: (msg) => string | undefined(pure, cheap, never re-projects tool-call/tool-result);protected.tsaccepts virtual paths inisMessageProtected(pattern match) andcollectLatestProtected/isMessageLatestProtected(per-path latest). WithoutmessagePathOfbehavior is byte-identical to before (all 1272 kernel tests unchanged).Policy contract (host side)
withDurableProtection(config, classifier):protectedLatestTools: [..., "durable/*"]+ attaches the classifier. Every carrier keeps exactly its newest instance pinned (skill/MCP visibility can never be lost — the 开启 bili 后「规矩与 skill 好像没被使用」? #2419 fingerprint gate never resends an unchanged catalog); superseded instances (runtime snapshots, re-based AGENTS.md baselines) fold normally. This mirrors the pi reference architecture, where the skill catalog and AGENTS.md live in the system prompt as a single live copy; dsh-native compaction protects neither (no skill/instructions section in its summary template, no re-injection) — not a precedent to follow.durable*pattern in the user'sprotectedToolsORprotectedLatestTools→ bili attaches only the classifier, injects nothing. The user owns the entire durable policy:protectedLatestTools: ["durable/*"]→ every carrier keeps only its LATEST instance (all four are cumulative snapshots — older catalogs/baselines fold away);protectedTools: ["durable/agents-md"]→ exactly one identity protected; skill/mcp catalogs fold normally.durableMessageToolPaths= dsh only, KDD release v0.1.2 #9). Unregistered lanes get no projection at all.Config flows through the normal three-level cascade (
global → provider → model, whole-array replace) — durable patterns are ordinary pattern entries, no new knobs, no env vars.Why this shape (vs. the boolean guards / #2557 marker)
Tests
kernel/tests/protected-virtual-paths.test.ts(6): projection never touches tool exchanges; pattern matrix (exact / first-segment / glob / other-identity / unclassified / none / case-insensitive); both channels compose; per-path latest; plain-name latest; tool-channel latest unchanged with a classifier attached.tests/durable-tool-identity.test.ts(8): policy units (default ensure / both takeover forms / idempotent) + e2e through the real config cascade and/__bili/plugin/tool: default keeps EVERY catalog instance across a fold;protectedLatestTools: ["durable/*"]folds the older catalog and keeps the newest; exact-identity takeover folds the skill catalog while the agents-md baseline survives; unregistered lane unchanged.Closes #2446 (the umbrella: host-hardcoded protection → configurable identity-based protection).
Supersedes the guard half of #2557's approach (marker protocol remains parked per owner — this PR needs no wire changes).