状态:已实施。2026-08-13 的持久信任简化由
workspace-hook-trust-persistent-only.md定义; 本文涉及allow_once、keep_blocked、独立审核面板与 SessionStart 补跑的旧描述均由该规格取代。
从安全与产品的基本公理出发,而不是从现有实现出发:
由公理 2+4 推出:turn 永不停等审核;由公理 1 推出:pending hook 本轮直接跳过(blocked);由公理 3 推出:会话内常驻提示 + 一键去审核;由公理 5 推出:删除 parked-turn 全套协议机制。
旧(硬门禁):
user prompt ──ACK──> turn 停在 activate() ──强制打开 Settings/Hooks──> 用户被迫决策
│ │
└──── 10min watchdog / turnStartTimeout(超时不写 Trust) ────┘
(审核完成后 turn 才继续;用户被丢在设置页)
新(软门禁):
user prompt ──ACK──> turn 立即执行,pending hooks 一律跳过(HookRunBlocked)
│
└─> 事件: WorkspaceHookAdmissionUpdated { pendingCount>0 }
└─> snapshot.workspaceHookAdmission
└─> 聊天底部常驻提示条 [N 个 Hook 待审核] [去审核] [忽略]
└─(用户主动点击)─> requestWorkspaceHookReview
└─> controller 开 review flow(受 supervisor 监管)
└─> Settings/Hooks 未信任行显示[信任]
└─> exact persistent trust 落盘,revision bump
└─> 只影响未来自然发生的 Hook event
时序(信任生效链路,涉及状态同步,按规范画图):
Renderer V4 Server(bootstrap) Core Runtime
│ │ │
│ prompt #1 │ │
├─────────────────────────────>│ startPromptTurn │
│ ├──────────────────────────────────>│ activate(): pending → skip
│ │ WorkspaceHookAdmission │ 记录 skippedSessionStart
│<── snapshot{pendingCount:2} ─┤<──────── Updated(2) ──────────────┤ + securityRevision R1
│ [提示条出现] │ │ turn 正常执行(无 hooks)
│ │ │
│ 点击[去审核] │ │
├─ requestWorkspaceHookReview >│ openReviewFlow + supervise │
│<── ReviewRequested ──────────┤ │
│ 行内点击[信任] │ │
├─ respondWorkspaceHookReview >│ exact grant → 落盘 → revision R2 │
│<── ReviewSettled ────────────┤ │
│<── snapshot{pendingCount:0} ─┤<──── AdmissionUpdated(0) ─────────┤
│ [提示条消失] │ │
│ prompt #2 │ │
├─────────────────────────────>│ startPromptTurn │
│ ├──────────────────────────────────>│ 不补跑旧 SessionStart
│ │ │ 仅后续自然事件使用新 Trust
workspace-hook-runtime-admission.ts:
reviewPendingSnapshot() 及其在 activate() 中的调用、reviewActivation 状态、review port 的等待用途。HookRunBlocked(errorCode: workspace_hooks_pending_trust),turn 照常执行。桌面与 headless 语义合流,不再有分叉。activate() 计算 pending 快照后,通过新 port 上报 { pendingCount, bundleDigest, workspaceIdentity }(见 D2)。waitForWorkspaceHookAdmission 保留(trust-store bootstrap 仍需要),仅删除 review 等待的调用点。bootstrapFailed / invalidatedReason)语义不变。conversationSnapshotSchema 新增 additive 字段(必须带 default: null,遵守 snapshot.ts 冻结规则):
workspaceHookAdmission: {
pendingCount: number; // configuredEnabled && admissionClass === "pending" 的声明数
bundleDigest: string; // 提示条 dismiss 的幂等 key
workspaceIdentity?: string;
} | null
新会话事件 WorkspaceHookAdmissionUpdated(与 WorkspaceHookReviewRequested/Settled/Superseded 同族),投影层据此写入/清空 snapshot 字段(pendingCount === 0 → 置 null)。
触发点:
activate()(startup / resume)完成评估后;不用 pendingInteractions 承载 admission(它是"阻塞性"的 load-bearing 语义:隐藏 composer、压 spinner、通知、侧栏);hooksService.loadHooks 仅用于 Settings 静态持久 Trust 视图。snapshot 走 V4 协议,桌面/Web 远控天然同源,满足多端约束。
requestWorkspaceHookReview(shared + bootstrap)revokeWorkspaceHookTrust 的 non-flow target 变体(sessionId + workspaceIdentity + bundleDigest,无 interactionId)。openReviewFlowForNewPendingItems(getCurrentSnapshot());已有活跃 flow 时复用(openOrReuseFlow 幂等)。superviseFlow——否则重蹈"撤销后面板永久失效"UAT bug(见 workspace-hook-review-supervisor.ts 头注)。ReviewSettled(timed_out);不创建 Trust、
不写负向决定,也不清除 admission pending。用户可从提示条重新请求新 generation。WorkspaceHookPendingBanner,置于 SessionPane 的 conversationBottomDock(ConversationQuotaBanner 同级,composer 之上),样式/结构仿 PendingCommandRecoveryBanner(role="status"、border/bg-surface、主操作+忽略)。snapshot.workspaceHookAdmission?.pendingCount > 0 且未被忽略。chat.workspaceHookPending.*,缺 key 校验仿 workspaceHookTrustState.test.ts 的 parity 断言):
setPendingSettingsSectionIntent("hooks") + openSettingsTab() + 经 findWorkspaceHookCommandBinding(该通道正是为无 pending-review 时保留命令通道而设,当前无 caller)发送 requestWorkspaceHookReview。sessionId + bundleDigest;bundle 变化(hook 内容变更)后提示条重新出现。不落盘。V4InteractionDialogs.tsx 的强制跳转(presentedWorkspaceHookReviewInteractions Set + setPendingSettingsSectionIntent/openSettingsTab);保留 store connect/upsert/clear(面板数据通路)与"不降级为通用对话框"守卫。chatLoadingVisibility.ts:workspaceHookReview 不再是 chat-loading blocker(对应测试断言反转)。SessionPane 的 blockingInteractionId 推导必须排除 workspaceHookReview,否则用户点开审核面板时 composer 与提示条会被 display:none。WorkspaceHookReviewPanel 与 Hooks 行内 configured/trust/effective 三组徽章。信任 按钮;点击成功后刷新持久 Trust 快照,按钮消失。已信任行不显示额外状态或撤销入口。DESIGN.md(颜色/圆角/主题/国际化)与多端约束(banner 数据源是 V4 snapshot,web-remote 同样生效)。parked turn 消失后,以下机制整体退役(近期 deadlock/超时监管 bug 的高发区):
| 位置 | 删除内容 |
|---|---|
prompt-turn.ts |
review observer 全套(workspaceHookReviewProgress、deferred/waiters、observeWorkspaceHookReview 等)、early-ACK 分支(requestAuthority: "workspace_hook_review")、monitorTurnStartedAfterWorkspaceHookReview、admittableHookTimeoutMs 延时、WORKSPACE_HOOK_REVIEW_SETTLE_GRACE_MS、相关类型与头注双权威条款 |
prompt-turn.ts |
observeAcknowledgedPromptInputFailure(review-only,3 个 call site 一并清理) |
handlers/queue.ts |
finalizeReviewedQueuePromotion review 分支(确认无其他 caller 后删) |
保留:review flow/controller/supervisor(按需生成 immutable 操作快照)、WorkspaceHookReviewRequested/Settled/Superseded 事件与投影。删除独立 panel、once/user-block 分支;flow timeout 只使快照过期。
requestWorkspaceHookReview 仅由新 UI 发送,桌面端 server 与 UI 同版本捆绑,无需新增 capability 协商;workspaceHookReview capability 保持原样。requestWorkspaceHookReview schema。WorkspaceHookAdmissionUpdated 重算;投影写入/清空 snapshot 字段;prompt-turn 不再 park(改写 v4-native-commands.test.ts:968 起五案、v4-native-queue.test.ts 三案为"直接 TurnStarted + AdmissionUpdated")。docs/testing/workspace-hook-trust-manual-acceptance.md §1 重写为软门禁验收。