From a22951dd58d6bfe4f41b26b8fd5dcaec2eb2e5f9 Mon Sep 17 00:00:00 2001 From: Kaiyi Date: Wed, 19 Aug 2026 05:05:47 +0800 Subject: [PATCH] fix(flow): REST identity follows the gates state; VS Code rejections carry provenance Review round 19: - An undo across a newer run's start restored the previous run's identity in the undoable state while the world-time gates kept the newer run's records. The REST route now prefers the gates state's identity, which is by construction the one the retained records belong to (identical for a live run). - VS Code's No now resolves with selectedLabel: 'Reject', so a real click keeps writing the gate audit while a bare transport-failure rejection stays unobserved. --- apps/vscode/src/runtime/reverse-rpc.ts | 5 ++++- packages/kap-server/src/routes/flow.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/vscode/src/runtime/reverse-rpc.ts b/apps/vscode/src/runtime/reverse-rpc.ts index 13a66f049..61ef0c5d5 100644 --- a/apps/vscode/src/runtime/reverse-rpc.ts +++ b/apps/vscode/src/runtime/reverse-rpc.ts @@ -60,7 +60,10 @@ export class ReverseRpcController { } else if (response === "approve") { resolve({ decision: "approved" }); } else { - resolve({ decision: "rejected" }); + // The label proves a user actually clicked No — a bare rejection is + // reserved for transport failures, which flow-gate provenance treats + // as unobserved and refuses to record as a human verdict. + resolve({ decision: "rejected", selectedLabel: "Reject" }); } return true; } diff --git a/packages/kap-server/src/routes/flow.ts b/packages/kap-server/src/routes/flow.ts index 3b43fff3a..aad349e2b 100644 --- a/packages/kap-server/src/routes/flow.ts +++ b/packages/kap-server/src/routes/flow.ts @@ -67,8 +67,8 @@ export function registerFlowRoutes(app: FlowRouteHost, deps: FlowRouteDeps): voi const payload: FlowStateResponse = { run: { active: run.active, - flow_id: run.flowId ?? gates.flowId, - task: run.task ?? gates.task, + flow_id: gates.flowId ?? run.flowId, + task: gates.task ?? run.task, stages: run.stages?.map((stage) => ({ id: stage.id, objective: stage.objective,