Repository navigation
fix(hide-official): mask refused official tools in PTC scopes - #568
tietoumiao wants to merge 1 commit into
Conversation
A run_code presentation resolves no native provider for its selected counterparts, so the plan's readiness check could never pass, `deny` stayed empty, and `tools.restrict` was never called. The host renders `tools:sdk` (ToolArgsMap) from the same scope view, so the model was told to call read/glob/grep inside a program while the guard refused them, and a later surface change refused the program's legal sub-calls too, because the failed plan re-set the readiness error. A scope that presents the reserved transport is now masked on its refusal contract instead: exactly the selected official names still visible in that scope are hidden, a program's other SDK sub-calls keep dispatching, and the native presentation keeps the readiness-gated mask, where a failed plan still hides nothing. The assembled-surface check now verifies collapsed scopes too.
|
The changed tests deliberately enable retained legacy rows through legacyComponent. In the normal single-row bundle, official-tool-hiding.apply returns through The recorded actual Node PTC check executes visible Please clarify whether the intended target is an explicit legacy/backport surface. Leaving the PR open for the maintainer's policy decision, as its risk section requests. This review does not claim the old 0.4.4 implementation was fixed by retirement, and does not approve fork CI. |
Nicholas023
left a comment
There was a problem hiding this comment.
审查结论:REQUEST_CHANGES — 建议关闭
这个修复在 0.5.0 上已经没有目标路径,而 0.4.4 也不再维护。
关键事实
0.5.0 的单行 bundle 不挂载 official-tool-hiding:
text src/index.ts: mountIntegration / mountRuntimeSettings / panel / tui / custom preset —— 没有 hide-official src/official-tool-hiding.ts:29: if (retiredLegacyRow(root, 'hide-official')) return
被修改的测试通过 test/lib/legacy-component.mjs 显式设置 DSH_OPS_LEGACY_ROWS=1 才进入该路径。正常安装的 0.5.0 用户永远走不到这段代码。
既然 0.4.4 不再维护、0.5.0 又没有该路径,本 PR 既没有 main 的发布面价值,也没有 backport 的目标分支。
附带问题:文档与 issue 关联
docs/component-reference.md、docs/CHANGELOG.md把 legacy-only 的行为写成发布行为Closes #415与事实不符:#415 的关闭理由是「被单行架构替代」,不是被本 PR 修复
已核实为真的部分
official-tool-hiding33/33、presentation-readiness6/6、mount51/51- revert-red(撤
src/official-tool-hiding.ts)→ 2/33 红,与声明一致 - 代码逻辑本身自洽、revert 真红,不存在实现缺陷
处置建议
关闭。 如果未来仍需维护 0.4.x,这份补丁应去对应的维护分支;在 main 上若保留,必须显式标注 legacy-only,并改用 Related to #415。
|
Closing — the review is right that |
Closes #415
What was wrong
In PTC presentation the hide-official component computed its deny list from
nativeProviders(),which is empty for a PTC scope because
src/publication/providers.ts:30withholds nativepublication there. The result was
deny: [], sotools.restrictwas never called and the toolsthe plugin refuses to serve stayed advertised in
tools:sdk(the SDKToolArgsMap) while everycall to them was refused at dispatch — a surface that disagrees with itself.
Measured live before the change (real host, PTC scope):
tools:sdkdeclared["read","glob","grep","foreign"]and all threeread/glob/greprefused at dispatch.The change
src/official-tool-hiding.ts— derive the mask from the names the scope can actually see(
names.filter(hideable)), using the public transport visibility (run_code) as the collapsesignal instead of the native-provider readiness path. A scope that refuses a tool now stops
advertising it; the Native presentation keeps its readiness-gated mask (a failed plan still hides
nothing there).
test/lib/official-tool-hiding.mjs,test/presentation-readiness.test.mjs— assertions for thePTC surface, the Native sibling, and a legal nested sub-call after
tools/change.docs/component-reference.md+docs/组件参考.md— the "never masked" claim is replaced by theactual rule;
docs/CHANGELOG.mdentry.Deliberately not done: no private host API, no change to which tools the plugin hides, and the
Studio/native readiness path is untouched.
Validation
presentation-readiness的 4 条docs/CHANGELOG.md## [Unreleased]:已加(EN+ZH)tools:sdk声明里",提示词段与工具 schema 均未改变
pull_request事件触发,届时回填CI required的 run URLEnvironment
065cd7fnpm ci --ignore-scripts未验证 / 风险披露
component-reference.md的"PTC 下永不遮蔽"。请维护者确认这是想要的方向;若要保留 fix(hide-official): stop gating run_code scopes on native readiness #366 的行为,请驳回本 PR,我会改为只修
deny的推导而不改遮蔽时机。
bothscope 被阻塞时也会发生(不可见、失败保留);若不想要这个窗口,删除src/official-tool-hiding.ts里对应的一小段即可。presentation-readiness覆盖。CI