Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(hub): honor exec approval timeout fallback

yushenabc48e515200
diff --git a/src/hub/exec-approval-manager.test.ts b/src/hub/exec-approval-manager.test.ts
index 7de230023f..79ac55d0c6 100644
--- a/src/hub/exec-approval-manager.test.ts
+++ b/src/hub/exec-approval-manager.test.ts
@@ -88,6 +88,54 @@ describe("ExecApprovalManager", () => {
expect(result.decision).toBe("deny");
});
+ it("honors askFallback full on timeout", async () => {
+ const promise = manager.requestApproval({
+ agentId: "agent-1",
+ command: "cmd",
+ riskLevel: "needs-review",
+ riskReasons: [],
+ askFallback: "full",
+ });
+
+ vi.advanceTimersByTime(6000);
+
+ const result = await promise;
+ expect(result.approved).toBe(true);
+ expect(result.decision).toBe("allow-once");
+ });
+
+ it("honors askFallback allowlist on timeout", async () => {
+ const allowPromise = manager.requestApproval({
+ agentId: "agent-1",
+ command: "cmd",
+ riskLevel: "needs-review",
+ riskReasons: [],
+ askFallback: "allowlist",
+ allowlistSatisfied: true,
+ });
+
+ vi.advanceTimersByTime(6000);
+
+ const allowResult = await allowPromise;
+ expect(allowResult.approved).toBe(true);
+ expect(allowResult.decision).toBe("allow-once");
+
+ const denyPromise = manager.requestApproval({
+ agentId: "agent-1",
+ command: "cmd",
+ riskLevel: "needs-review",
+ riskReasons: [],
+ askFallback: "allowlist",
+ allowlistSatisfied: false,
+ });
+
+ vi.advanceTimersByTime(6000);
+
+ const denyResult = await denyPromise;
+ expect(denyResult.approved).toBe(false);
+ expect(denyResult.decision).toBe("deny");
+ });
+
it("returns false when resolving unknown approval", () => {
const resolved = manager.resolveApproval("unknown-id", "allow-once");
expect(resolved).toBe(false);
diff --git a/src/hub/exec-approval-manager.ts b/src/hub/exec-approval-manager.ts
index 14d0ea079e..8274b962e1 100644
--- a/src/hub/exec-approval-manager.ts
+++ b/src/hub/exec-approval-manager.ts
@@ -47,6 +47,8 @@ export class ExecApprovalManager {
riskLevel: "safe" | "needs-review" | "dangerous";
riskReasons: string[];
timeoutMs?: number;
+ askFallback?: "deny" | "allowlist" | "full";
+ allowlistSatisfied?: boolean;
}): Promise<ApprovalResult> {
const approvalId = uuidv7();
const timeoutMs = params.timeoutMs ?? this.defaultTimeoutMs;
@@ -63,11 +65,17 @@ export class ExecApprovalManager {
};
return new Promise<ApprovalResult>((resolve) => {
- // Timeout: auto-deny (fail-closed)
+ // Timeout: follow askFallback (default: fail-closed)
const timer = setTimeout(() => {
if (this.pending.has(approvalId)) {
this.pending.delete(approvalId);
- resolve({ approved: false, decision: "deny" });
+ const fallback = params.askFallback ?? "deny";
+ const decision =
+ fallback === "full" ||
+ (fallback === "allowlist" && params.allowlistSatisfied)
+ ? "allow-once"
+ : "deny";
+ resolve({ approved: decision !== "deny", decision });
}
}, timeoutMs);
diff --git a/src/hub/hub.ts b/src/hub/hub.ts
index 563a4ed781..ff87aee85d 100644
--- a/src/hub/hub.ts
+++ b/src/hub/hub.ts
@@ -409,6 +409,8 @@ export class Hub {
riskLevel: evaluation.riskLevel,
riskReasons: evaluation.reasons,
timeoutMs: config.timeoutMs,
+ askFallback: config.askFallback,
+ allowlistSatisfied: evaluation.allowlistSatisfied,
});
// Handle allow-always: persist to profile allowlist