Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Remove the turn-wall-clock admin resource (#2341)

Regan Bell9d145db5ced8
diff --git a/src/api/routes/admin-resources.ts b/src/api/routes/admin-resources.ts
index fdef771e1..c2efcf02a 100644
--- a/src/api/routes/admin-resources.ts
+++ b/src/api/routes/admin-resources.ts
@@ -798,31 +798,6 @@ export const ADMIN_RESOURCES: readonly AdminResource[] = [
return { ok: true };
},
},
- {
- id: "turn-wall-clock",
- kind: "string",
- target: "org",
- clearable: true,
- label:
- "Maximum wall-clock time for a turn in seconds. Zero leaves turns uncapped; empty restores the deployment default.",
- readKey: "turnWallClockSec",
- get: (deps, scope) => deps.config!.getTurnWallClockSecDurable(scope),
- apply: generic<number | null>(
- (body, { scope }) => {
- const bad = orgOnly(scope, "the turn wall-clock limit is org-wide");
- if (bad) return bad;
- const raw = (body as { sec?: unknown }).sec;
- const trimmed = typeof raw === "string" ? raw.trim() : raw;
- if (trimmed === undefined || trimmed === null || trimmed === "") return { value: null };
- const sec = typeof trimmed === "number" ? trimmed : Number(trimmed);
- if (!Number.isInteger(sec) || (sec !== 0 && (sec < 60 || sec > 86_400))) {
- return { error: "turn-wall-clock requires { sec: 0 or integer 60-86400 } (empty clears the override)" };
- }
- return { value: sec };
- },
- (deps, scope, sec) => deps.config!.setTurnWallClockSec(scope, sec),
- ),
- },
{
id: "browse-model",
kind: "enum",
diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.ts
index 62f7117f7..e4563f3a5 100644
--- a/src/core/orchestrator.ts
+++ b/src/core/orchestrator.ts
@@ -3089,21 +3089,10 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
...(input.displayText?.trim() ? { display: input.displayText } : {}),
}
: undefined;
- const requestedTurnWallClockMs =
- typeof input.turnWallClockMs === "number" && input.turnWallClockMs > 0 ? input.turnWallClockMs : undefined;
- const configuredTurnWallClockSec = await deps.config?.getTurnWallClockSecDurable(resolution.orgScopeId);
- const configuredTurnWallClockMs =
- configuredTurnWallClockSec === null || configuredTurnWallClockSec === undefined
- ? undefined
- : configuredTurnWallClockSec * 1000;
- let effectiveTurnWallClockMs =
- configuredTurnWallClockMs ?? deps.defaultTurnWallClockMs ?? CONFIG_DEFAULTS.turnWallClockSec * 1000;
- if (requestedTurnWallClockMs !== undefined) {
- effectiveTurnWallClockMs =
- configuredTurnWallClockMs !== undefined && configuredTurnWallClockMs > 0
- ? Math.min(requestedTurnWallClockMs, configuredTurnWallClockMs)
- : requestedTurnWallClockMs;
- }
+ const effectiveTurnWallClockMs =
+ typeof input.turnWallClockMs === "number" && input.turnWallClockMs > 0
+ ? input.turnWallClockMs
+ : (deps.defaultTurnWallClockMs ?? CONFIG_DEFAULTS.turnWallClockSec * 1000);
const runtimePurpose = turnRuntimePurpose(
{ surface: input.surface, triggered: automatedTurn },
!!session.parentSessionId || !!swarmBinding?.member.parentId,
@@ -3485,14 +3474,10 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
...(input.clientTools?.length ? { clientTools: input.clientTools } : {}),
...(input.surfaceTools && surfaceToolDeps ? { surfaceTools: true } : {}),
...(isPollFire ? { pollFire: true } : {}),
- ...(effectiveTurnWallClockMs !== undefined
- ? {
- turnWallClockMs:
- effectiveTurnWallClockMs > 0
- ? Math.max(1, effectiveTurnWallClockMs - (Date.now() - turnStart))
- : effectiveTurnWallClockMs,
- }
- : {}),
+ turnWallClockMs:
+ effectiveTurnWallClockMs > 0
+ ? Math.max(1, effectiveTurnWallClockMs - (Date.now() - turnStart))
+ : effectiveTurnWallClockMs,
...(securityPolicy.screening !== "off"
? {
screenToolResult: async ({
diff --git a/src/resolution/config-store.ts b/src/resolution/config-store.ts
index 26b62a140..102d13960 100644
--- a/src/resolution/config-store.ts
+++ b/src/resolution/config-store.ts
@@ -147,10 +147,6 @@ interface AutoFlaggerConfig {
export interface PersistedAutoFlaggerConfig extends AutoFlaggerConfig {
scopeId: ScopeId;
}
-export interface PersistedTurnWallClock {
- scopeId: ScopeId;
- sec: number;
-}
interface ScopeConfigPresence {
soul: boolean;
commandPolicy: boolean;
@@ -266,8 +262,6 @@ export interface ScopedConfigStore {
setEmbeddingModel(modelId: string | null): Promise<void>;
getAutoFlaggerConfig(): AutoFlaggerConfig | null;
setAutoFlaggerConfig(config: AutoFlaggerConfig | null): void;
- getTurnWallClockSecDurable(id: ScopeId): Promise<number | null>;
- setTurnWallClockSec(id: ScopeId, sec: number | null): Promise<void>;
setConnectorClient(id: ScopeId, provider: string, input: ConnectorClientInput): Promise<void>;
listConnectorClients(id: ScopeId): Promise<PublicConnectorClient[]>;
deleteConnectorClient(id: ScopeId, provider: string): Promise<void>;
@@ -306,7 +300,6 @@ export function createMemoryConfigStore(
browseMaxSteps?: DurableMap<PersistedBrowseMaxSteps>;
browseModels?: DurableMap<PersistedBrowseModel>;
autoFlaggerConfigs?: DurableMap<PersistedAutoFlaggerConfig>;
- turnWallClocks?: DurableMap<PersistedTurnWallClock>;
deploymentIdentity?: DurableMap<PersistedDeploymentIdentity>;
connectorSecretKey?: Buffer | string;
defaultSecurityPosture?: SecurityPosture;
@@ -337,7 +330,6 @@ export function createMemoryConfigStore(
const browseMaxSteps = new Map<ScopeId, number>();
const browseModels = new Map<ScopeId, string>();
let autoFlaggerConfig: AutoFlaggerConfig | null = null;
- const turnWallClocks = new Map<ScopeId, number>();
const soulStore = opts.souls ?? createMemoryMap<PersistedSoul>();
const soulHistoryStore = opts.soulHistory ?? createMemoryMap<PersistedSoulRevision>();
const commandPolicyStore = opts.commandPolicies ?? createMemoryMap<PersistedCommandPolicy>();
@@ -363,7 +355,6 @@ export function createMemoryConfigStore(
const browseMaxStepsStore = opts.browseMaxSteps ?? createMemoryMap<PersistedBrowseMaxSteps>();
const browseModelStore = opts.browseModels ?? createMemoryMap<PersistedBrowseModel>();
const autoFlaggerStore = opts.autoFlaggerConfigs ?? createMemoryMap<PersistedAutoFlaggerConfig>();
- const turnWallClockStore = opts.turnWallClocks ?? createMemoryMap<PersistedTurnWallClock>();
const deploymentIdentity = opts.deploymentIdentity ?? createMemoryMap<PersistedDeploymentIdentity>();
const persistWarn = (what: string) => reportFailureAs(`config: persist ${what}`, undefined);
const writeQueue = createKeyedQueue();
@@ -579,7 +570,6 @@ export function createMemoryConfigStore(
rubric: storedAutoFlagger.rubric,
}
: null;
- for (const r of await turnWallClockStore.all()) turnWallClocks.set(r.scopeId, r.sec);
})();
}
return hydrated;
@@ -1133,14 +1123,6 @@ export function createMemoryConfigStore(
);
}
},
- getTurnWallClockSecDurable: async (id) => (await turnWallClockStore.get(id))?.sec ?? null,
- async setTurnWallClockSec(id, sec) {
- await writeQueue(`turnWallClock:${id}`, () =>
- sec === null ? turnWallClockStore.delete(id) : turnWallClockStore.put(id, { scopeId: id, sec }),
- );
- if (sec === null) turnWallClocks.delete(id);
- else turnWallClocks.set(id, sec);
- },
async setConnectorClient(id, provider, input) {
const rec: StoredConnectorClient = {
scopeId: id,
@@ -1311,7 +1293,6 @@ export function createMemoryConfigStore(
`egress:${id}`,
`externalSlack:${id}`,
`model:${id}`,
- `turnWallClock:${id}`,
`branding:${id}`,
...(id === org
? [
diff --git a/src/wiring.ts b/src/wiring.ts
index 61d60491f..41d251ad4 100644
--- a/src/wiring.ts
+++ b/src/wiring.ts
@@ -111,7 +111,6 @@ import {
type PersistedBrowseMaxSteps,
type PersistedBrowseModel,
type PersistedAutoFlaggerConfig,
- type PersistedTurnWallClock,
type PersistedDeploymentIdentity,
} from "./resolution/config-store.ts";
import { createResolutionService } from "./resolution/resolution-service.ts";
@@ -704,7 +703,6 @@ export function buildApp(
browseMaxSteps: artifactMap<PersistedBrowseMaxSteps>("browse_max_steps_configs"),
browseModels: artifactMap<PersistedBrowseModel>("browse_model_configs"),
autoFlaggerConfigs: artifactMap<PersistedAutoFlaggerConfig>("auto_flagger_configs"),
- turnWallClocks: artifactMap<PersistedTurnWallClock>("turn_wall_clock_configs"),
deploymentIdentity: artifactMap<PersistedDeploymentIdentity>("deployment_identity"),
defaultSecurityPosture: config.securityPosture,
defaultSharingPosture: config.sharingPosture,
diff --git a/test/admin-resources.test.ts b/test/admin-resources.test.ts
index e441ba233..586fd3e4b 100644
--- a/test/admin-resources.test.ts
+++ b/test/admin-resources.test.ts
@@ -131,65 +131,6 @@ test("GET /v1/admin/resources returns a manifest entry for every registered reso
}
});
-test("turn wall-clock governance validates, round-trips, clears, and is org-admin-only", async () => {
- const srv = start();
- const url = `${srv.base}/v1/admin/scopes/org:default-org/turn-wall-clock`;
- try {
- assert.equal(
- (
- await fetch(url, {
- method: "PUT",
- headers: { "content-type": "application/json", "x-admin-actor": "nobody@default-org" },
- body: JSON.stringify({ sec: 60 }),
- })
- ).status,
- 403,
- );
- assert.equal(
- (
- await fetch(`${srv.base}/v1/admin/scopes/channel:C1/turn-wall-clock`, {
- method: "PUT",
- headers: ADMIN,
- body: JSON.stringify({ sec: 60 }),
- })
- ).status,
- 400,
- );
- for (const sec of [59, 86_401, 60.5, "nope"]) {
- assert.equal((await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec }) })).status, 400);
- }
- assert.equal(
- (await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec: "120" }) })).status,
- 200,
- );
- let body = (await (await fetch(`${srv.base}/v1/admin/scopes/org:default-org`, { headers: ADMIN })).json()) as {
- turnWallClockSec: number | null;
- };
- assert.equal(body.turnWallClockSec, 120);
- assert.equal((await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec: 0 }) })).status, 200);
- body = (await (await fetch(`${srv.base}/v1/admin/scopes/org:default-org`, { headers: ADMIN })).json()) as {
- turnWallClockSec: number | null;
- };
- assert.equal(body.turnWallClockSec, 0);
- assert.equal((await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec: "" }) })).status, 200);
- body = (await (await fetch(`${srv.base}/v1/admin/scopes/org:default-org`, { headers: ADMIN })).json()) as {
- turnWallClockSec: number | null;
- };
- assert.equal(body.turnWallClockSec, null);
- assert.equal((await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec: 120 }) })).status, 200);
- assert.equal(
- (await fetch(url, { method: "PUT", headers: ADMIN, body: JSON.stringify({ sec: " " }) })).status,
- 200,
- );
- body = (await (await fetch(`${srv.base}/v1/admin/scopes/org:default-org`, { headers: ADMIN })).json()) as {
- turnWallClockSec: number | null;
- };
- assert.equal(body.turnWallClockSec, null);
- } finally {
- await srv.close();
- }
-});
-
test("branding governance validates, round-trips through surface-config, clears, and is org-admin-only", async () => {
const srv = start();
const url = `${srv.base}/v1/admin/scopes/org:default-org/branding`;
diff --git a/test/admin-settings-load.test.ts b/test/admin-settings-load.test.ts
index d2810d322..50545c346 100644
--- a/test/admin-settings-load.test.ts
+++ b/test/admin-settings-load.test.ts
@@ -27,7 +27,6 @@ test("settings projections preserve values while excluding unrelated payloads",
const srv = start();
t.after(srv.close);
srv.built.config.setBranding("org:default-org", { selfLabel: "Test assistant", accent: "#445566" });
- await srv.built.config.setTurnWallClockSec("org:default-org", 120);
await srv.built.config.flushScope("org:default-org");
await srv.built.directory.replaceChannels([{ channelId: "C-settings", name: "settings-test" }]);
const full = (await (await fetch(srv.base + scopePath, { headers: ADMIN })).json()) as Record<string, unknown>;
@@ -56,7 +55,6 @@ test("settings projections preserve values while excluding unrelated payloads",
}
if (view === "customize") {
assert.equal(projected.branding.selfLabel, "Test assistant");
- assert.equal("turnWallClockSec" in projected, false);
assert.equal("orgAmbient" in projected, false);
assert.equal("channelHeaderPinDefault" in projected, false);
assert.equal("soulHistory" in projected, true);
diff --git a/test/orchestrator.test.ts b/test/orchestrator.test.ts
index dcfc708e3..cc5d6d7aa 100644
--- a/test/orchestrator.test.ts
+++ b/test/orchestrator.test.ts
@@ -147,18 +147,14 @@ test("the persisted assistant entry carries authoritative turn timing for transc
assert.ok(p.workStartedAt! >= before && p.workFinishedAt! >= p.workStartedAt!);
});
-test("org turn wall-clock governance reaches the harness and a per-turn cap only tightens", async (t) => {
+test("the deployment turn wall-clock reaches the harness and a per-turn cap replaces it", async (t) => {
t.mock.timers.enable({ apis: ["Date"], now: Date.now() });
- const { app, config } = freshApp();
- await config.setTurnWallClockSec(scopeId("org", "default-org"), 120);
+ const { app } = freshApp({ turnWallClockMs: 120_000 });
assert.equal((await app.turn(dm("!wallclock"))).reply, "wallclock:120000");
assert.equal((await app.turn(dm("!wallclock", { turnWallClockMs: 70_000 }))).reply, "wallclock:70000");
- assert.equal((await app.turn(dm("!wallclock", { turnWallClockMs: 500_000 }))).reply, "wallclock:120000");
+ assert.equal((await app.turn(dm("!wallclock", { turnWallClockMs: 500_000 }))).reply, "wallclock:500000");
assert.equal((await app.turn(dm("!wallclock", { turnWallClockMs: 0 }))).reply, "wallclock:120000");
- await config.setTurnWallClockSec(scopeId("org", "default-org"), 0);
- assert.equal((await app.turn(dm("!wallclock", { turnWallClockMs: 70_000 }))).reply, "wallclock:70000");
- await config.setTurnWallClockSec(scopeId("org", "default-org"), null);
- assert.equal((await app.turn(dm("!wallclock"))).reply, "wallclock:0");
+ assert.equal((await freshApp().app.turn(dm("!wallclock"))).reply, "wallclock:0");
});
test("inbound file problems ride a durable file_event entry — off the reply and the model context", async () => {
diff --git a/test/postgres-config-store.test.ts b/test/postgres-config-store.test.ts
index 1533bff27..e47bf1381 100644
--- a/test/postgres-config-store.test.ts
+++ b/test/postgres-config-store.test.ts
@@ -13,7 +13,6 @@ import {
type PersistedPeopleDirectoryUrl,
type PersistedBrowseMaxSteps,
type PersistedBrowseModel,
- type PersistedTurnWallClock,
type PersistedDeploymentIdentity,
} from "../src/resolution/config-store.ts";
import { settle } from "./support/settle.ts";
@@ -44,7 +43,6 @@ const TABLES = [
"people_directory_urls",
"browse_max_steps_configs",
"browse_model_configs",
- "turn_wall_clock_configs",
"deployment_identity",
];
@@ -69,24 +67,9 @@ const maps = (f: PostgresArtifactMaps) => ({
peopleDirectoryUrls: f.map<PersistedPeopleDirectoryUrl>("people_directory_urls"),
browseMaxSteps: f.map<PersistedBrowseMaxSteps>("browse_max_steps_configs"),
browseModels: f.map<PersistedBrowseModel>("browse_model_configs"),
- turnWallClocks: f.map<PersistedTurnWallClock>("turn_wall_clock_configs"),
deploymentIdentity: f.map<PersistedDeploymentIdentity>("deployment_identity"),
});
-test("turn wall-clock config hydrates after restart and a clear remains cleared", async () => {
- const turnWallClocks = createMemoryMap<PersistedTurnWallClock>();
- const writer = createMemoryConfigStore("default-org", { turnWallClocks });
- const org = scopeId("org", "default-org");
- await writer.setTurnWallClockSec(org, 600);
- const restarted = createMemoryConfigStore("default-org", { turnWallClocks });
- await restarted.hydrate?.();
- assert.equal(await restarted.getTurnWallClockSecDurable(org), 600);
- await restarted.setTurnWallClockSec(org, null);
- const cleared = createMemoryConfigStore("default-org", { turnWallClocks });
- await cleared.hydrate?.();
- assert.equal(await cleared.getTurnWallClockSecDurable(org), null);
-});
-
test("SOUL compare-and-set permits only one writer and keeps current plus history in one durable row", async () => {
const souls = createMemoryMap<PersistedSoul>();
const legacyHistory = createMemoryMap<PersistedSoulRevision>();
@@ -338,7 +321,6 @@ test(
a.setPeopleDirectoryUrl(ch, "https://www.example.com/people");
a.setBrowseMaxSteps(ch, 120);
a.setBrowseModel(ch, "claude-sonnet-4-6");
- await a.setTurnWallClockSec(org, 600);
await settle(
async () =>
(await m.souls.get(ch))?.version === version &&
@@ -350,8 +332,7 @@ test(
(await m.baseModels.get(ch))?.modelId === "claude-opus-4-8" &&
(await m.peopleDirectoryUrls.get(ch))?.url === "https://www.example.com/people" &&
(await m.browseMaxSteps.get(ch))?.steps === 120 &&
- (await m.browseModels.get(ch))?.modelId === "claude-sonnet-4-6" &&
- (await m.turnWallClocks.get(org))?.sec === 600,
+ (await m.browseModels.get(ch))?.modelId === "claude-sonnet-4-6",
);
const b = createMemoryConfigStore("default-org", maps(f));
@@ -373,7 +354,6 @@ test(
assert.equal(b.getPeopleDirectoryUrl(ch), "https://www.example.com/people", "the people-directory url survived");
assert.equal(b.getBrowseMaxSteps(ch), 120, "the browse step limit survived");
assert.equal(b.getBrowseModel(ch), "claude-sonnet-4-6", "the browse model survived");
- assert.equal(await b.getTurnWallClockSecDurable(org), 600, "the turn wall-clock limit survived");
},
);
@@ -399,8 +379,6 @@ test(
a.setBrowseMaxSteps(ch, null);
a.setBrowseModel(ch, "claude-sonnet-4-6");
a.setBrowseModel(ch, null);
- await a.setTurnWallClockSec(scopeId("org", "default-org"), 600);
- await a.setTurnWallClockSec(scopeId("org", "default-org"), null);
await settle(
async () =>
(await m.souls.get(ch))?.content === "soul v8" &&
@@ -408,8 +386,7 @@ test(
!(await m.baseModels.get(ch)) &&
!(await m.peopleDirectoryUrls.get(ch)) &&
!(await m.browseMaxSteps.get(ch)) &&
- !(await m.browseModels.get(ch)) &&
- !(await m.turnWallClocks.get(scopeId("org", "default-org"))),
+ !(await m.browseModels.get(ch)),
);
const b = createMemoryConfigStore("default-org", maps(f));