fix(setup): write the recommended tool call timeout into dsh registrations (#4043)

* fix(setup): write the recommended tool call timeout into dsh registrations

rea setup --client dsh wrote registrations without toolCallTimeoutMs, so
DeepSeek Harness applied its 60-second default while a native provider
startup alone can exceed it. Setup now derives the deadline from the same
provider allowance plus operation headroom used for Kimi and Codex,
preserves a positive caller-selected value, and doctor reports a
registration without a usable timeout as stale.

ProviderRequestBudgetResolver declares an optional budgetSettings read
set, so the fail-closed budget gate rejects unresolved Cordis expressions
only for settings the derivation may read plus the timeout inputs; an
unrelated expression such as GHIDRA_INSTALL_DIR still refreshes, and an
expression in REA_IDA_MCP_CONFIG fails closed.

* test(setup): record the dsh tool call deadline in the NUL repair fixture

The NUL refusal scenario rewrites a valid dsh registration and expects
doctor to report it healthy. That fixture omitted toolCallTimeoutMs,
which doctor now reports stale, so the repaired registration records the
deadline a current dsh registration carries.

* test(setup): separate dsh timeout repair coverage

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
mengzhe ganandmorluto authored and GitHub committed 2026-11-18 14:31:34 -05:00
1 parent b236bcfe34
commit 82e16b4dda
10 files changed
+454 -55

No files matched your search

+14 -3
View File
@@ -59,6 +59,7 @@ import {
clientRegistrationOwnershipRemediation,
refreshClientRegistration,
} from "./ClientRegistration.js";
import { recommendedMcpToolTimeoutMs } from "../config/mcpStartupPolicy.js";
import { PRODUCT_IDENTITY } from "../identity.js";
import { currentClientRegistrationCommand } from "./ClientRegistrationIdentity.js";
@@ -1346,18 +1347,28 @@ const clientConfigurationDesired = async (
const launcher =
command.length === 0 ? [PRODUCT_IDENTITY.cliBinary, "mcp"] : command;
if (format === "dsh") {
const validated = clientRegistrationEnvironment(
// The budget resolver's declared read set keeps the gate fail-closed only
// for settings the derivation may actually read, so unrelated Cordis
// expressions stay preserved while the budget still resolves.
const validated = await clientRegistrationEnvironmentDetailsWithBudget(
effective,
client,
platform,
providerEnvironment,
"effective",
resolveProviderRequestBudget,
platform,
);
if (!validated.ok) throw validated.error;
const desired = (
parsed === undefined
? new DshCordisDocument("")
: dshDocument(parsed.document)
).desired(launcher, providerEnvironment, platform);
).desired(
launcher,
providerEnvironment,
platform,
recommendedMcpToolTimeoutMs(validated.value.timeoutInputs),
);
if (!desired.ok) throw desired.error;
return desired.value;
}