Repository navigation
[PR] feat: POST /__bili/plugin/protect — durable-registration aux channel (#2556) - #2574
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
…2556) The marker (#2555) stays the durable truth; registration buys zero content pollution and post-hoc protection. Refs resolve to raw ids into session.metadata.protectedRawIds (persisted, fork-adoption clone-safe, id-never-reused keeps registrations pinned), composed into the same isMessageProtected guard at both resolution sites. Manifest advertises protectEndpoint; PLUGIN.md documents the contract.
Owner
Author
This was referenced Oct 10, 2026
Owner
Author
[bot] 🏷 PR #2574 review — 可合(人工合并) 验证了什么(在 head
结构化八问:
测试有效性:断言有牙——行为级 e2e(折叠存活、clear 后再折叠被吞掉证明注册是唯一保护、marker+注册组合、幂等 changed:0、metadata 精确等于 byRef[target]、错误码点名坏 ref),该 bug 回归时抓得住。两个已知缺口(可接受,不拦):新套件未含重启持久化测试(机制与其他 metadata key 共用,round-trip 由其他套件覆盖);测试折叠走 plugin-tool=read path,wire-path guard 为同形代码隐式覆盖。 Guardrail:feat + 新插件协议端点 ⇒ §7.4 定义上人工合并,PR 自检标记正确。 判定:可合。 前置条件仅堆叠依赖:#2557 先落,retarget 后等主 unit CI 绿。本地证据链完整(100/100 + typecheck + 8/8 e2e),无需再改。 |
Owner
Author
|
后续重新设计 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2557 (marker guard composition lands there first) — base is the marker branch; it retargets to master automatically when #2557 merges.
Fixes #2556
What
POST /__bili/plugin/protect— server-side durable registration, the aux channel of the durable protocol. Body{conversationId, refs: [mNNNNN...], clear?}; refs resolve to raw content ids held insession.metadata.protectedRawIds(union on register, subtract on clear; empty set deletes the key). Registered raw ids compose into the sameisMessageProtectedguard as the marker (#2555) and lane guards, at both resolution sites: the wire path (src/server/handle.ts) and the read path (session.ts effectiveConfig), so a registration protects the very next fold on either surface. Manifest advertisesprotectEndpoint.Why an aux channel (and why the marker stays primary)
The durable truth is content-embedded declaration: registration is session-keyed state, which fork raw-replay (#2383), cross-machine exports and proxy-mode re-sends do not carry. What registration buys instead: zero content pollution (no marker line in host-visible text) and post-hoc protection of a message emitted before the host learned the protocol. Ids are never reused (kernel contract), so a registration stays pinned to its message even after it dies.
Validation contract (loud, no guessing)
400 INVALID_REQUEST: missing conversationId / refs not a non-emptymNNNNNarray / clear not boolean400 UNKNOWN_REFnaming the never-assigned refs (a typo cannot silently protect nothing)404 NOT_FOUNDconversation not residentchanged: 0);flushSyncon mutation (warn + debounced retry on failure), same as the fork endpointTests (
tests/issue2556-protect-tool.test.ts, 4/4)validation matrix · lane-less session: registered ref survives a positional fold that swallows its neighbors, then folds away after
clear(registration was the only protection) · composition: marker + registration co-protected in one session · manifest advertises the endpoint.Local verification: new suite 4/4; regression family issue2555/2446/2419/2447/2481 22/22; plugin-fork 43/43; ccr-plugin 12/12; dsh-acp 11/11; issue760 8/8; typecheck clean. (dsh-native / dsh-settings-ui / issue2082 hang or fail on this machine at the PR base too — environmental, CI arbitrates.)
Guardrail check (§7.4)
feat + new plugin-protocol endpoint => human merge by definition. No kernel change (
isMessageProtectedconsumed as-is), no config surface, no persistence format change (metadata key is additive and clone-safe), no wire/message-shape change to model traffic.