Skip to content
This repository was archived by the owner on Sep 17, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fa793a0
feat(operator): build and verify the HITL approval gate (read-only)
ginccc Aug 1, 2026
1222379
feat(operator): the approval surface — resolve a pause inline in the …
ginccc Aug 1, 2026
f8e8098
fix(operator): verify per-tool rules too, and de-duplicate 3 locale l…
ginccc Aug 1, 2026
92e2d5d
fix(operator): reconcile the resumed turn by identity, and handle a r…
ginccc Aug 1, 2026
6b2fefc
feat(operator): derive the system prompt from the granted endpoint set
ginccc Aug 1, 2026
33cb961
fix(operator): close a gate-verification gap and two resume-path defects
ginccc Aug 1, 2026
829289d
fix(operator): keep the pause placeholder in state, not a ref
ginccc Aug 2, 2026
a1efbaf
feat(operator): populate WRITE_ENDPOINTS with the four curated writes
ginccc Aug 3, 2026
982e57d
feat(operator): the write canary — prove a real write pauses before g…
ginccc Aug 3, 2026
11f2615
feat(operator): let the admin actually choose read_write in the activ…
ginccc Aug 3, 2026
6f47e83
feat(operator): render the backend's resolved-request preview in the …
ginccc Aug 3, 2026
1d022dd
docs: catch up HANDOFF and AGENTS on the write-scope arc
ginccc Aug 3, 2026
f729b98
feat(operator): let the operator author agent groups, and flag capabi…
ginccc Aug 3, 2026
f93a047
fix(operator): two review findings on the write path
ginccc Aug 3, 2026
74f5188
fix(operator): four review findings on the activation and canary paths
ginccc Aug 3, 2026
d71a0aa
docs(operator): record why an absent hitlPausedAt is not treated as a…
ginccc Aug 3, 2026
864afd3
docs(operator): drop a stale endpoint count from a test comment
ginccc Aug 3, 2026
a5fea34
docs(operator): correct the AbortSignal.any rationale
ginccc Aug 3, 2026
addf66b
fix(hitl): source pause reason and timeouts from approval-status
ginccc Aug 3, 2026
14040d3
feat(hitl): let the approvals inbox decide TOOL_CALL pauses in place
ginccc Aug 3, 2026
c306cdb
feat(operator): create and modify agents and groups, not just deploy …
ginccc Aug 3, 2026
e22850c
fix(operator): close a self-ungating path, a dead canary, and two lie…
ginccc Aug 3, 2026
8dead9a
feat(operator): complete the authoring cascade, and refuse a self-aim…
ginccc Aug 3, 2026
d25ddc8
fix(operator): close four escalation-flag evasions, and a hole in gat…
ginccc Aug 3, 2026
691cb8e
fix(operator): the self-guard was inert for approvers, and missed a t…
ginccc Aug 3, 2026
eb35fe0
fix(operator): malformed hitlConfig JSON took down the approval surface
ginccc Aug 3, 2026
ffa87b9
fix(operator): roll back a half-provisioned activation, and stop hidi…
ginccc Aug 4, 2026
578c458
feat(operator): a context-aware side-chat drawer, in Manager and Work…
ginccc Aug 4, 2026
a6ab700
fix(operator): six defects from the final review, one of which broke …
ginccc Aug 4, 2026
79fd7fe
feat(operator): show what a whole-document config write CHANGES
ginccc Aug 4, 2026
ee9d176
feat(operator): keyboard-close the drawer, and say when a decision is…
ginccc Aug 4, 2026
b0fb907
fix(hitl): a failed pause-details read left Approve enabled, not blocked
ginccc Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions src/components/hitl/__tests__/approval-banner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,102 @@ describe("ApprovalBanner", () => {
expect(screen.queryByTestId("tool-call-approvals")).not.toBeInTheDocument();
expect(screen.getByTestId("approval-banner")).toHaveAttribute("data-pause-type", "RULE");
});

it("always shows the redaction caveat, regardless of requireExplicitPerCall", () => {
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={vi.fn()} />,
);
expect(screen.getByTestId("redaction-caveat")).toHaveTextContent("[REDACTED]");
});

it("renders renderCallExtra content for each call", () => {
renderWithProviders(
<ApprovalBanner
surface="regular"
pauseDetails={toolPause()}
onDecide={vi.fn()}
renderCallExtra={(call) => <span data-testid={`extra-${call.callId}`}>POST /agentstore/agents</span>}
/>,
);
expect(screen.getByTestId("extra-c1")).toBeInTheDocument();
expect(screen.getByTestId("extra-c2")).toBeInTheDocument();
});
});

describe("requireExplicitPerCall", () => {
it("disables Approve until every call has an explicit verdict", () => {
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={vi.fn()} requireExplicitPerCall />,
);
expect(screen.getByTestId("approve-button")).toBeDisabled();
expect(screen.getByTestId("explicit-review-missing")).toBeInTheDocument();
});

it("enables Approve once EVERY call has been explicitly toggled", () => {
const onDecide = vi.fn();
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={onDecide} requireExplicitPerCall />,
);
fireEvent.click(screen.getByTestId("tool-approve-c1"));
// Still missing c2 — must stay disabled.
expect(screen.getByTestId("approve-button")).toBeDisabled();

fireEvent.click(screen.getByTestId("tool-approve-c2"));
expect(screen.getByTestId("approve-button")).not.toBeDisabled();
expect(screen.queryByTestId("explicit-review-missing")).not.toBeInTheDocument();

fireEvent.click(screen.getByTestId("approve-button"));
confirmInDialog("Approve");
expect(onDecide).toHaveBeenCalledWith("APPROVED", undefined, undefined, {
c1: { verdict: "APPROVED" },
c2: { verdict: "APPROVED" },
});
});

it("un-reviewing a call (toggling it back off) re-disables Approve", () => {
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={vi.fn()} requireExplicitPerCall />,
);
fireEvent.click(screen.getByTestId("tool-approve-c1"));
fireEvent.click(screen.getByTestId("tool-approve-c2"));
expect(screen.getByTestId("approve-button")).not.toBeDisabled();

// Toggling an already-selected verdict off is the existing "un-toggle"
// behavior (see the onToggle handler) — Approve must track it live.
fireEvent.click(screen.getByTestId("tool-approve-c2"));
expect(screen.getByTestId("approve-button")).toBeDisabled();
});

it("Reject stays available regardless — rejecting the batch needs no per-call review", () => {
const onDecide = vi.fn();
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={onDecide} requireExplicitPerCall />,
);
expect(screen.getByTestId("reject-button")).not.toBeDisabled();
fireEvent.click(screen.getByTestId("reject-button"));
confirmInDialog("Reject");
expect(onDecide).toHaveBeenCalledWith("REJECTED", undefined, undefined, undefined);
});

it("does not affect a RULE pause, which has no per-call state to require", () => {
const onDecide = vi.fn();
renderWithProviders(
<ApprovalBanner
surface="regular"
pauseDetails={{ type: "RULE", reason: "x", actions: [] }}
onDecide={onDecide}
requireExplicitPerCall
/>,
);
expect(screen.getByTestId("approve-button")).not.toBeDisabled();
});

it("defaults to off — existing callers (conversation-detail, discussion-transcript) keep sweep-approve", () => {
renderWithProviders(
<ApprovalBanner surface="regular" pauseDetails={toolPause()} onDecide={vi.fn()} />,
);
expect(screen.getByTestId("approve-button")).not.toBeDisabled();
expect(screen.queryByTestId("explicit-review-missing")).not.toBeInTheDocument();
});
});
});
57 changes: 54 additions & 3 deletions src/components/hitl/approval-banner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useState, type ReactNode } from "react";
import { useTranslation } from "react-i18next";
import {
CheckCircle2,
Expand Down Expand Up @@ -60,6 +60,24 @@ interface ApprovalBannerProps {
) => void;
/** Called when the user cancels. */
onCancel?: () => void;
/**
* On a TOOL_CALL pause, disables top-level Approve until every gated call has
* an explicit per-call verdict — an untouched call otherwise inherits the
* top-level verdict silently (see the hint text below the call list). Regular
* conversation and group review intentionally keep that default; this exists
* for a surface where a swept-in call executes an unreviewed write against the
* platform itself (the Platform Operator), so "I clicked Approve" must mean
* "I looked at every call", not "I looked at the batch".
*/
requireExplicitPerCall?: boolean;
/**
* Rendered per call, above the redacted arguments — e.g. the reconstructed
* "METHOD /path" a generated tool actually calls, which `PendingToolCallView`
* does not carry (only the operationId-derived tool name does). Kept as a
* render prop rather than a new required field so this stays optional for
* every other caller.
*/
renderCallExtra?: (call: PendingToolCallView) => ReactNode;
}

/** Whether a date string parses to a real instant. */
Expand Down Expand Up @@ -125,6 +143,8 @@ export function ApprovalBanner({
pauseDetailsPending,
onDecide,
onCancel,
requireExplicitPerCall = false,
renderCallExtra,
}: ApprovalBannerProps) {
const { t } = useTranslation();
const [note, setNote] = useState("");
Expand Down Expand Up @@ -154,6 +174,14 @@ export function ApprovalBanner({
const toolPause = pauseDetails?.type === "TOOL_CALL" ? pauseDetails : null;
const isToolCall = !!toolPause;

// Every gated call must carry an explicit verdict before Approve is offered.
// Checked against callStates directly (not toolDecisions, which is built only
// at submit time) so the button reflects the CURRENT review state live.
const explicitReviewMissing =
requireExplicitPerCall &&
isToolCall &&
toolPause!.calls.some((call) => callStates[call.callId]?.verdict === undefined);

const setCall = (callId: string, patch: Partial<CallState>) => {
setCallStates((prev) => ({ ...prev, [callId]: { ...prev[callId], ...patch } }));
setSubmitError(null);
Expand Down Expand Up @@ -373,12 +401,22 @@ export function ApprovalBanner({
<p className="text-xs font-medium text-muted-foreground">
{t("hitl.toolCallsAwaiting", "Tool calls awaiting approval")}
</p>
{/* The backend never sends raw arguments to a client — only the
redacted, size-capped form. A secret inside the payload reads as
the literal text "[REDACTED]" here, which is correct, but an
approver who doesn't know that can mistake it for "nothing
sensitive was in this call" rather than "something was, and it was
hidden from you". */}
<p className="text-[11px] text-muted-foreground" data-testid="redaction-caveat">
{t("hitl.redactionCaveat", "Arguments shown below are redacted — a secret value appears as \"[REDACTED]\", not omitted.")}
</p>
{toolPause.calls.map((call) => (
<ToolCallRow
key={call.callId}
call={call}
state={callStates[call.callId] ?? {}}
outcomeUnknown={outcomeUnknown.has(call.callId)}
extra={renderCallExtra?.(call)}
onToggle={(verdict) =>
setCall(call.callId, {
verdict: callStates[call.callId]?.verdict === verdict ? undefined : verdict,
Expand All @@ -400,8 +438,16 @@ export function ApprovalBanner({
</p>
)}
<p className="text-[11px] text-muted-foreground">
{t("hitl.toolApprovalHint", "Approve applies your per-call choices (calls you didn't change are approved). Reject rejects the whole batch.")}
{requireExplicitPerCall
? t("hitl.toolApprovalHintExplicit", "Every call needs its own Approve or Reject before you can approve the batch. Reject rejects the whole batch.")
: t("hitl.toolApprovalHint", "Approve applies your per-call choices (calls you didn't change are approved). Reject rejects the whole batch.")}
</p>
{explicitReviewMissing && (
<p className="flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400" data-testid="explicit-review-missing">
<AlertTriangle className="h-3.5 w-3.5" aria-hidden="true" />
{t("hitl.explicitReviewMissing", "Review every call above before approving.")}
</p>
)}
</div>
)}

Expand Down Expand Up @@ -521,7 +567,7 @@ export function ApprovalBanner({
<div className="flex items-center gap-2">
<button
type="button"
disabled={isSubmitting || pauseDetailsPending}
disabled={isSubmitting || pauseDetailsPending || explicitReviewMissing}
onClick={() => setConfirmAction("APPROVED")}
className="inline-flex items-center gap-1.5 rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-emerald-500 disabled:opacity-50 disabled:cursor-not-allowed"
data-testid="approve-button"
Expand Down Expand Up @@ -578,13 +624,17 @@ function ToolCallRow({
call,
state,
outcomeUnknown,
extra,
onToggle,
onToggleAmend,
onAmendChange,
}: {
call: PendingToolCallView;
state: CallState;
outcomeUnknown: boolean;
/** Optional caller-supplied content rendered above the arguments block —
* see `ApprovalBannerProps.renderCallExtra`. */
extra?: ReactNode;
onToggle: (verdict: HitlVerdict) => void;
onToggleAmend: () => void;
onAmendChange: (amend: string) => void;
Expand Down Expand Up @@ -656,6 +706,7 @@ function ToolCallRow({
</button>
</div>
</div>
{extra}
{call.arguments && (
<pre
className="max-h-40 overflow-auto rounded bg-muted/60 p-2 text-[11px] leading-relaxed text-foreground"
Expand Down
30 changes: 22 additions & 8 deletions src/components/operator/operator-activation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ import { MODEL_SUGGESTIONS, isBaseUrlRequired } from "@/lib/model-suggestions";
import { useVaultHealth } from "@/hooks/use-secrets";
import { useAuth } from "@/hooks/use-auth";
import {
OPERATOR_SAFETY_PREAMBLE,
OPERATOR_PROMPT_BODY,
safetyPreambleForScope,
defaultOperatorPromptBody,
} from "@/lib/operator/system-prompt";
import { READ_ENDPOINTS } from "@/lib/operator/tool-scopes";
import { endpointsForScope, type OperatorScope } from "@/lib/operator/tool-scopes";
import { extractVaultKeyName, toVaultRef } from "@/lib/operator/vault-ref";
import type { OperatorConfig, OperatorAuthMode } from "@/lib/api/operator";
import type { ActivationStage } from "@/hooks/use-operator";
import { cn } from "@/lib/utils";

/**
* The scope this form provisions.
*
* Pinned, not chosen: a write grant comes from deliberately populating
* `WRITE_ENDPOINTS`, never from a control in the activation UI. Named so the
* review step renders the preamble, default body and tool list of the *same*
* scope that `handleActivate` submits — what the admin reads is what is sent.
*/
const PROVISIONED_SCOPE: OperatorScope = "read_only";
const GRANTED_ENDPOINTS = endpointsForScope(PROVISIONED_SCOPE);
const SAFETY_PREAMBLE = safetyPreambleForScope(PROVISIONED_SCOPE);

interface OperatorActivationProps {
initial: OperatorConfig;
stage: ActivationStage;
Expand Down Expand Up @@ -51,7 +63,9 @@ export function OperatorActivation({
);
const [baseUrl, setBaseUrl] = useState("");
const [environment, setEnvironment] = useState(initial.environment);
const [promptBody, setPromptBody] = useState(initial.promptBody || OPERATOR_PROMPT_BODY);
const [promptBody, setPromptBody] = useState(
initial.promptBody || defaultOperatorPromptBody(PROVISIONED_SCOPE),
);
const [authMode, setAuthMode] = useState<OperatorAuthMode>(initial.authMode);

const providerConfig = getProviderConfig(provider);
Expand Down Expand Up @@ -95,7 +109,7 @@ export function OperatorActivation({
promptBody,
authMode,
credentialKey: extractVaultKeyName(apiKey),
scope: "read_only",
scope: PROVISIONED_SCOPE,
},
apiKey,
baseUrl || undefined,
Expand Down Expand Up @@ -246,7 +260,7 @@ export function OperatorActivation({
hint={t("operator.activation.safetyPreambleHint", "Always prepended. It tells the operator to treat everything its tools return as untrusted data.")}
>
<pre className="max-h-40 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs whitespace-pre-wrap text-muted-foreground">
{OPERATOR_SAFETY_PREAMBLE}
{SAFETY_PREAMBLE}
</pre>
</Field>

Expand All @@ -265,9 +279,9 @@ export function OperatorActivation({
/>
</Field>

<Field label={t("operator.activation.tools", { toolCount: READ_ENDPOINTS.length })}>
<Field label={t("operator.activation.tools", { toolCount: GRANTED_ENDPOINTS.length })}>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<ul className="max-h-32 space-y-1 overflow-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-xs text-muted-foreground">
{READ_ENDPOINTS.map((e) => (
{GRANTED_ENDPOINTS.map((e) => (
<li key={e}>{e}</li>
))}
</ul>
Expand Down
Loading
Loading