fix(FN-4702): scope pre-approved override to install gate

Fusion-Task-Id: FN-4702
Fusion-Task-Lineage: 378b46bc-2e71-43bf-9ff7-85e7aed8bf85
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 23:07:05 -07:00
committed by gsxdsm
parent 412e59e1f9
commit ac264bf64b

View File

@@ -195,25 +195,18 @@ export async function executeApprovedWorktrunkInstall(opts: {
return result; return result;
} }
export async function installWorktrunk(opts: { async function applyInstallGate(opts: {
settings: WorktrunkSettings;
auditor?: RunAuditor; auditor?: RunAuditor;
runContext?: EngineRunContext; runContext?: EngineRunContext;
gateOverride?: "pre-approved"; gateOverride?: "pre-approved";
}): Promise<{ binaryPath: string; source: "installed-release" | "installed-cargo" }> { }): Promise<{ satisfied: boolean }> {
if (opts.gateOverride === "pre-approved") { if (opts.gateOverride === "pre-approved") {
await emitBinaryAudit(opts.auditor, "binary:install-requested", { await emitBinaryAudit(opts.auditor, "binary:install-requested", {
reason: "pre-approved", reason: "pre-approved",
taskId: opts.runContext?.taskId, taskId: opts.runContext?.taskId,
runId: opts.runContext?.runId, runId: opts.runContext?.runId,
}); });
await emitBinaryAudit(opts.auditor, "binary:install-success", { return { satisfied: true };
source: "installed-release",
binaryPath: WORKTRUNK_INSTALL_PATH,
taskId: opts.runContext?.taskId,
runId: opts.runContext?.runId,
});
return { binaryPath: WORKTRUNK_INSTALL_PATH, source: "installed-release" };
} }
await emitBinaryAudit(opts.auditor, "binary:install-denied", { await emitBinaryAudit(opts.auditor, "binary:install-denied", {
@@ -224,6 +217,22 @@ export async function installWorktrunk(opts: {
throw new WorktrunkInstallFailedError(AUTO_INSTALL_DISABLED_MESSAGE, { stage: "auto-install-disabled" }); throw new WorktrunkInstallFailedError(AUTO_INSTALL_DISABLED_MESSAGE, { stage: "auto-install-disabled" });
} }
export async function installWorktrunk(opts: {
settings: WorktrunkSettings;
auditor?: RunAuditor;
runContext?: EngineRunContext;
gateOverride?: "pre-approved";
}): Promise<{ binaryPath: string; source: "installed-release" | "installed-cargo" }> {
await applyInstallGate(opts);
await emitBinaryAudit(opts.auditor, "binary:install-success", {
source: "installed-release",
binaryPath: WORKTRUNK_INSTALL_PATH,
taskId: opts.runContext?.taskId,
runId: opts.runContext?.runId,
});
return { binaryPath: WORKTRUNK_INSTALL_PATH, source: "installed-release" };
}
export function clearWorktrunkResolveCache(): void { export function clearWorktrunkResolveCache(): void {
resolveCache.clear(); resolveCache.clear();
} }