Multiplayer agent harness for work.
Make sandbox capability token lifetime configurable (#1747)
Joshua Francedc91d0d395ec
diff --git a/.env.example b/.env.exampleindex 848ee54ed..92593bff7 100644--- a/.env.example+++ b/.env.example@@ -31,6 +31,7 @@ PORT=8080CORE_SIGNING_SECRET=CAPABILITY_SECRET=CAPABILITY_TOKEN_COMPRESSION=0+SANDBOX_CAPABILITY_TTL_HOURS=48PORTAL_IDENTITY_SECRET=CONNECTOR_SECRET_KEY=SKILL_SIGNING_SECRET=diff --git a/docs/capability-tokens.md b/docs/capability-tokens.mdindex fcb412770..3cb2c9157 100644--- a/docs/capability-tokens.md+++ b/docs/capability-tokens.md@@ -27,6 +27,24 @@ Compression is off by default for a staged protocol rollout:To disable issuance, set the switch to `0`. Both encodings remain readable regardlessof that switch. Do not roll verifiers back to a version predating compression until-all compressed tokens have expired or been revoked. Sandbox tokens normally live-48 hours; other capability audiences may have longer lifetimes, so inventory those+all compressed tokens have expired or been revoked. Sandbox tokens live 48 hours by+default (see below); other capability audiences may have longer lifetimes, so inventory thosebefore rolling back. Leaving the updated verifiers in place is the safe rollback.++## Sandbox token lifetime++Turn tokens handed to sandboxes (agent API, credential broker, egress proxy, OAuth+consent) expire 48 hours after the turn starts, which bounds how long background jobs+launched by that turn keep their access. Set `SANDBOX_CAPABILITY_TTL_HOURS` on every+process that issues capabilities to change it: a positive number of hours, or `0` /+`none` for no expiry (`exp: 0`). The value is read+once at startup; an invalid value fails startup. Tokens already issued keep the+lifetime they were minted with. Revocation and scope checks still apply to+non-expiring tokens. This does not remove run/lease, background-job, provider, or+credential lifetime limits. Non-expiring bearer tokens increase exposure if leaked;+keep the default unless unattended work requires longer access.++Deploy the updated verifier to every core and worker, and any separately deployed+egress proxy, before enabling no expiry. Older verifiers reject `exp: 0`.+Changing the setting affects newly issued tokens only; rotate the signing secret+if existing non-expiring tokens must be invalidated.diff --git a/src/auth/capability-token.ts b/src/auth/capability-token.tsindex e35cf7ba4..e4b308a6a 100644--- a/src/auth/capability-token.ts+++ b/src/auth/capability-token.ts@@ -5,8 +5,22 @@ import type { CandidateDestination, Destination, EgressPolicy, Principal, ScopeIimport { mintSignedPayload, verifySignedPayload } from "./signed-token.ts";export const CAPABILITY_TTL_MS = 60 * 60_000;-export const SANDBOX_CAPABILITY_TTL_MS = 48 * 60 * 60_000;export const DEPLOYMENT_CREDENTIAL_TTL_MS = 10 * 365 * 24 * 60 * 60_000;+const DEFAULT_SANDBOX_CAPABILITY_TTL_HOURS = 48;++export function parseSandboxCapabilityTtlMs(value: string | undefined): number {+ const raw = value?.trim().toLowerCase();+ if (!raw) return DEFAULT_SANDBOX_CAPABILITY_TTL_HOURS * 3_600_000;+ if (raw === "none" || raw === "0") return 0;+ const hours = Number(raw);+ if (!Number.isFinite(hours) || hours <= 0 || !Number.isSafeInteger(hours * 3_600_000))+ throw new Error(+ `SANDBOX_CAPABILITY_TTL_HOURS=${JSON.stringify(value)} must be a positive number of hours, or 0/none for no expiry.`,+ );+ return hours * 3_600_000;+}++export const SANDBOX_CAPABILITY_TTL_MS = parseSandboxCapabilityTtlMs(undefined);export const BROWSER_MODEL_AUD = "browser-model";@@ -148,7 +162,10 @@ export async function verifyCapabilityToken(if (claims.runLeaseToken !== undefined && (typeof claims.runLeaseToken !== "string" || !claims.runLeaseToken))return null;if (claims.deployment !== undefined && (typeof claims.deployment !== "string" || !claims.deployment)) return null;- if (now >= claims.exp) return null;+ if (claims.exp === 0) {+ if (![CONTROL_PLANE_AUD, OAUTH_CONSENT_AUD, CREDENTIAL_BROKER_AUD, EGRESS_PROXY_AUD].includes(claims.aud ?? ""))+ return null;+ } else if (!Number.isSafeInteger(claims.exp) || now >= claims.exp) return null;return claims;}diff --git a/src/config.ts b/src/config.tsindex e4b7e4043..75fbee7f4 100644--- a/src/config.ts+++ b/src/config.ts@@ -1,5 +1,6 @@import type { ExternalSlackPolicies } from "./resolution/external-slack.ts";import { isStrongSigningSecret } from "./auth/source-auth.ts";+import { parseSandboxCapabilityTtlMs } from "./auth/capability-token.ts";import { parseScopeId } from "./types.ts";import type { SandboxScopeDefaults } from "./sandbox/sandbox-routing.ts";import { existsSync, readdirSync } from "node:fs";@@ -117,6 +118,7 @@ export interface Config {runMaxAgeMs: number;runWaitMs: number;backgroundJobTtlMs: number;+ sandboxCapabilityTtlMs: number;backgroundJobTtlMaxMs: number;backgroundWorkEnabled: boolean;backgroundDeploymentId?: string;@@ -1543,6 +1545,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): Config {swarmDefaults,runMaxAgeMs,runWaitMs: (turnWallClockMs > 0 ? turnWallClockMs : runMaxAgeMs) + 60_000,+ sandboxCapabilityTtlMs: parseSandboxCapabilityTtlMs(env.SANDBOX_CAPABILITY_TTL_HOURS),backgroundJobTtlMs:(numEnvStrict("BACKGROUND_JOB_TTL_SEC", env.BACKGROUND_JOB_TTL_SEC) ?? CONFIG_DEFAULTS.backgroundJobTtlSec) *1000,diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.tsindex 7ba7e101f..9f2224056 100644--- a/src/core/orchestrator.ts+++ b/src/core/orchestrator.ts@@ -1623,6 +1623,8 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {let actorIsOrgAdmin = false;let orgMemoryWrite: ScopeId | undefined;let controlClaims: CapabilityClaims | undefined;+ const sandboxTokenTtlMs = deps.sandboxCapabilityTtlMs ?? SANDBOX_CAPABILITY_TTL_MS;+ const sandboxTokenExpiry = sandboxTokenTtlMs === 0 ? 0 : Date.now() + sandboxTokenTtlMs;const scopeAttestation = {...(external ? { externalSlack: true as const } : {}),actorId: actor.id,@@ -1663,7 +1665,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {(input.origin.kind === "automation" && input.origin.useOwnerKeychain === true))? { ownerConnections: true }: {}),- exp: Date.now() + SANDBOX_CAPABILITY_TTL_MS,+ exp: sandboxTokenExpiry,...(turnTimezone ? { timezone: turnTimezone } : {}),...(destination ? { destination } : {}),...(delivery.candidates.length > 0 ? { destinations: delivery.candidates } : {}),@@ -1709,7 +1711,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {{...scopeAttestation,aud: OAUTH_CONSENT_AUD,- exp: Date.now() + SANDBOX_CAPABILITY_TTL_MS,+ exp: sandboxTokenExpiry,},deps.capabilitySecret ?? deps.signingSecret,deps.capabilityTokenCompression,@@ -1769,7 +1771,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {...scopeAttestation,aud: EGRESS_PROXY_AUD,egress: egressClaimAllowingControlPlane(egress, deps.apiBaseUrl ?? "", securityPolicy.denyPrivateNetworks),- exp: Date.now() + SANDBOX_CAPABILITY_TTL_MS,+ exp: sandboxTokenExpiry,},egressSecret,deps.capabilityTokenCompression,@@ -1823,7 +1825,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {}: {}),credentials: brokerSlugs,- exp: Date.now() + SANDBOX_CAPABILITY_TTL_MS,+ exp: sandboxTokenExpiry,},(deps.capabilitySecret ?? deps.signingSecret)!,deps.capabilityTokenCompression,diff --git a/src/core/orchestrator/types.ts b/src/core/orchestrator/types.tsindex 0ddb25832..d71fb80f8 100644--- a/src/core/orchestrator/types.ts+++ b/src/core/orchestrator/types.ts@@ -143,6 +143,7 @@ export interface OrchestratorDeps {securityScreenTimeoutMs?: number;securityScreener?: SecurityScreener;backgroundJobTtlMs?: number;+ sandboxCapabilityTtlMs?: number;backgroundJobTtlMaxMs?: number;harness: Harness;signingSecret?: string;diff --git a/src/harness/agent-tools.ts b/src/harness/agent-tools.tsindex 49ad5737b..1d686b874 100644--- a/src/harness/agent-tools.ts+++ b/src/harness/agent-tools.ts@@ -324,6 +324,7 @@ export interface AgentToolsOptions {execTimeoutCeilingMs?: number;backgroundJobTtlMs?: number;backgroundJobTtlMaxMs?: number;+ sandboxCapabilityTtlMs?: number;mcpTools?: () => McpToolDescriptor[];controlTools?: boolean;sandboxResources?: boolean;@@ -351,6 +352,7 @@ export function coreToolOptions(config: Config): CoreToolOptions {execTimeoutCeilingMs: config.execTimeoutMaxMs,backgroundJobTtlMs: config.backgroundJobTtlMs,backgroundJobTtlMaxMs: config.backgroundJobTtlMaxMs,+ sandboxCapabilityTtlMs: config.sandboxCapabilityTtlMs,};}@@ -406,7 +408,12 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):const bgTtlMaxSec = Math.round((opts?.backgroundJobTtlMaxMs ?? CONFIG_DEFAULTS.backgroundJobTtlMaxSec * 1000) / 1000);const bgTtlMin = Math.round(bgTtlSec / 60);const bgTtlMaxMin = Math.round(bgTtlMaxSec / 60);- const capabilityTtlHours = Math.round(SANDBOX_CAPABILITY_TTL_MS / 3_600_000);+ const capabilityTtlMs = opts?.sandboxCapabilityTtlMs ?? SANDBOX_CAPABILITY_TTL_MS;+ const capabilityTtlHours = capabilityTtlMs / 3_600_000;+ const capabilityExpiry =+ capabilityTtlMs === 0+ ? "Two limits: this deployment does not expire those turn tokens, but authorization checks still apply (publish checkpoints to durable Files and retain the file ID for the later turn or cron)"+ : `Two limits: those turn tokens expire ${capabilityTtlHours} hours after the turn that launched the job started (past that they 401 — publish checkpoints to durable Files and verify success before expiry, retaining the file ID for the later turn or cron; if publication is unavailable, report it and retain needed local state on a scoped computer)`;const log = async (type: EntryType, payload: unknown, sourceScopeId?: ScopeId | null): Promise<void> => {if (!ref.emit || !ref.scopeLabel) return;const scopeLabel = classifyScopeLabel({@@ -1708,7 +1715,7 @@ export function createAgentTools(ref: ToolContextRef, opts?: AgentToolsOptions):"it's stopped automatically (a watch survives just long enough to tell you) — for anything " +`that finishes within ${execCeilingSec}s, just use \`execute\`. Available on the default sandbox or an authorized explicit sandbox_id; ` +"elsewhere, use `execute`. A background job carries the same environment a foreground `execute` " +- `does — $AGENT_API_URL, $AGENT_API_TOKEN and $AGENT_CREDENTIAL_TOKEN all work, so self-API calls and shared-credential broker calls run fine from background work. Two limits: those turn tokens expire ${capabilityTtlHours} hours after the turn that launched the job started (past that they 401 — publish checkpoints to durable Files and verify success before expiry, retaining the file ID for the later turn or cron; if publication is unavailable, report it and retain needed local state on a scoped computer), and a background job cannot deliver a file itself, so write results to ordinary workspace paths and attach them from a live turn after polling.\n` ++ `does — $AGENT_API_URL, $AGENT_API_TOKEN and $AGENT_CREDENTIAL_TOKEN all work, so self-API calls and shared-credential broker calls run fine from background work. ${capabilityExpiry}, and a background job cannot deliver a file itself, so write results to ordinary workspace paths and attach them from a live turn after polling.\n` +"INTERACTIVE LOGINS: device-flow logins (`gh auth login`, " +"`glab auth login`, `gcloud auth login`, and anything that prints a verification URL/code then " +"blocks waiting on a human) belong here, NOT in `execute`. Run them with action=start, read the " +diff --git a/src/harness/harness-shared.ts b/src/harness/harness-shared.tsindex 7830e99f1..6cd554d39 100644--- a/src/harness/harness-shared.ts+++ b/src/harness/harness-shared.ts@@ -25,6 +25,7 @@ export interface HarnessToolPlumbing {execTimeoutCeilingMs?: number;backgroundJobTtlMs?: number;backgroundJobTtlMaxMs?: number;+ sandboxCapabilityTtlMs?: number;}export type BridgedTool = {@@ -132,6 +133,7 @@ export function harnessToolOptions(opts: HarnessToolPlumbing, turn?: HarnessTurnexecTimeoutCeilingMs: opts.execTimeoutCeilingMs,backgroundJobTtlMs: opts.backgroundJobTtlMs,backgroundJobTtlMaxMs: opts.backgroundJobTtlMaxMs,+ sandboxCapabilityTtlMs: opts.sandboxCapabilityTtlMs,...(turn? {readOnly: turn.readOnly,diff --git a/src/wiring.ts b/src/wiring.tsindex 88db6cd4c..05e3da03b 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -1955,6 +1955,7 @@ export function buildApp(...(securityScreener ? { securityScreener } : {}),backgroundJobTtlMs: config.backgroundJobTtlMs,backgroundJobTtlMaxMs: config.backgroundJobTtlMaxMs,+ sandboxCapabilityTtlMs: config.sandboxCapabilityTtlMs,...(config.signingSecret ? { signingSecret: config.signingSecret } : {}),...(config.capabilitySecret ? { capabilitySecret: config.capabilitySecret } : {}),capabilityTokenCompression: config.capabilityTokenCompression,diff --git a/test/agent-tools.test.ts b/test/agent-tools.test.tsindex 2aa978205..3663b2e23 100644--- a/test/agent-tools.test.ts+++ b/test/agent-tools.test.ts@@ -3995,3 +3995,15 @@ test("thrown execution errors leave pending child messages for the next delivereassert.equal(pending, false);}});++test("background process guidance reflects the configured sandbox token lifetime", () => {+ const guidance = (opts?: { sandboxCapabilityTtlMs?: number }) =>+ createAgentTools({ current: fakeToolContext() }, { sandboxResources: true, ...opts })+ .map((tool) => tool.description)+ .join("\n");+ assert.match(guidance(), /turn tokens expire 48 hours/);+ assert.match(guidance({ sandboxCapabilityTtlMs: 72 * 3_600_000 }), /turn tokens expire 72 hours/);+ const unlimited = guidance({ sandboxCapabilityTtlMs: 0 });+ assert.match(unlimited, /does not expire those turn tokens/);+ assert.doesNotMatch(unlimited, /turn tokens expire \d+ hours/);+});diff --git a/test/capability-token.test.ts b/test/capability-token.test.tsindex 7086bc018..10657183a 100644--- a/test/capability-token.test.ts+++ b/test/capability-token.test.ts@@ -7,6 +7,7 @@ import {BLOB_TRANSFER_AUD,CAPABILITY_TTL_MS,mintCapabilityToken,+ parseSandboxCapabilityTtlMs,verifyBlobTransferCapability,verifyCapabilityToken,type CapabilityClaims,@@ -211,3 +212,25 @@ test("session and run-attempt claims round-trip and reject malformed values", as);}});++test("sandbox capability TTL defaults to 48 hours and accepts hours or no expiry", () => {+ assert.equal(parseSandboxCapabilityTtlMs(undefined), 48 * 3_600_000);+ assert.equal(parseSandboxCapabilityTtlMs(" "), 48 * 3_600_000);+ assert.equal(parseSandboxCapabilityTtlMs("72"), 72 * 3_600_000);+ assert.equal(parseSandboxCapabilityTtlMs("0"), 0);+ assert.equal(parseSandboxCapabilityTtlMs("None"), 0);+ for (const bad of ["-1", "abc", "Infinity", "1e20", "0.00000001"])+ assert.throws(() => parseSandboxCapabilityTtlMs(bad), /SANDBOX_CAPABILITY_TTL_HOURS/);+});++test("no-expiry capabilities are restricted to sandbox audiences and retain signature checks", async () => {+ for (const aud of ["control-plane", "oauth-consent", "credential-broker", "egress-proxy"]) {+ const token = await mintCapabilityToken(claims({ aud, exp: 0 }), SECRET);+ assert.ok(await verifyCapabilityToken(token, SECRET, Number.MAX_SAFE_INTEGER));+ assert.equal(await verifyCapabilityToken(token, "rotated-secret"), null);+ }+ for (const aud of [undefined, "browser-model", "blob-transfer", "secret-drop", "unknown"]) {+ const token = await mintCapabilityToken(claims({ aud, exp: 0 }), SECRET);+ assert.equal(await verifyCapabilityToken(token, SECRET), null);+ }+});diff --git a/test/config.test.ts b/test/config.test.tsindex 8ee32d3cd..f7cb12f6e 100644--- a/test/config.test.ts+++ b/test/config.test.ts@@ -983,3 +983,10 @@ test("screening across postures is explicit and requires an enabled backend", ()assert.throws(() => loadConfig({ SECURITY_SCREEN_ALL_POSTURES: "true" }), /requires an enabled/);assert.throws(() => loadConfig({ SECURITY_SCREEN_ALL_POSTURES: "typo" }), /SECURITY_SCREEN_ALL_POSTURES/);});++test("sandbox capability TTL is deployment-configurable with a 48-hour default", () => {+ assert.equal(loadConfig({}).sandboxCapabilityTtlMs, 48 * 3_600_000);+ assert.equal(loadConfig({ SANDBOX_CAPABILITY_TTL_HOURS: "168" }).sandboxCapabilityTtlMs, 168 * 3_600_000);+ assert.equal(loadConfig({ SANDBOX_CAPABILITY_TTL_HOURS: "none" }).sandboxCapabilityTtlMs, 0);+ assert.throws(() => loadConfig({ SANDBOX_CAPABILITY_TTL_HOURS: "-5" }), /SANDBOX_CAPABILITY_TTL_HOURS/);+});diff --git a/test/orchestrator.test.ts b/test/orchestrator.test.tsindex ab0fbf410..363210060 100644--- a/test/orchestrator.test.ts+++ b/test/orchestrator.test.ts@@ -10,12 +10,7 @@ import { TEST_CAPABILITY_SECRET, testConfig } from "./support/test-config.ts";import { runNowSettled } from "./support/settle.ts";import { loadConfig, type Config } from "../src/config.ts";import type { SandboxHandle, ProvisionOptions, Sandbox } from "../src/sandbox/sandbox.ts";-import {- verifyCapabilityToken,- EGRESS_PROXY_AUD,- CAPABILITY_TTL_MS,- SANDBOX_CAPABILITY_TTL_MS,-} from "../src/auth/capability-token.ts";+import { verifyCapabilityToken, EGRESS_PROXY_AUD } from "../src/auth/capability-token.ts";import { egressClaimAllowingControlPlane } from "../src/core/orchestrator.ts";import { SESSION_BUSY_USER_TEXT } from "../src/core/failure-copy.ts";import { TURN_FILES_DIR, turnFileId } from "../src/core/attachments.ts";@@ -1144,39 +1139,58 @@ test("turn timezone rides the prompt and control-plane capability token", asyncassert.equal(invalidClaims!.timezone, undefined, "invalid surface timezones are omitted from the token");});-test("sandbox-facing turn tokens carry the long sandbox TTL, not the hour-long capability TTL", async () => {- const config = testConfig({- dataDir: mkdtempSync(join(tmpdir(), "ap-")),- signingSecret: "test-secret",- apiBaseUrl: "https://core.example.com",- });- const { app, sandbox } = buildApp(config);- let captured: ProvisionOptions | undefined;- const realProvision = sandbox.provision.bind(sandbox);- sandbox.provision = (layers, opts) => {- captured = opts;- return realProvision(layers, opts);- };-- const before = Date.now();- const res = await app.turn(dm("!run echo ttl", { conversation: { kind: "dm", threadRef: "dm:U1:ttl" } }));- assert.equal(res.status, "ok");- const tokens = {- AGENT_API_TOKEN: captured!.env!.AGENT_API_TOKEN!,- AGENT_OAUTH_CONSENT_TOKEN: captured!.env!.AGENT_OAUTH_CONSENT_TOKEN!,- egressToken: captured!.egressToken!,- };- for (const [name, token] of Object.entries(tokens)) {- const claims = await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET);- assert.ok(claims, `${name} verifies`);- assert.ok(claims.exp > before + CAPABILITY_TTL_MS, `${name} outlives the hour-long TTL`);- assert.ok(claims.exp <= Date.now() + SANDBOX_CAPABILITY_TTL_MS, `${name} is capped at the sandbox TTL`);- assert.ok(- await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET, before + 9 * 3_600_000),- `${name} still verifies nine hours in`,+for (const hours of [undefined, "72", "0", "none"]) {+ test(`sandbox-facing turn tokens honor deployment TTL ${hours ?? "default"}`, async () => {+ const ttl = loadConfig({ SANDBOX_CAPABILITY_TTL_HOURS: hours }).sandboxCapabilityTtlMs;+ const { app, sandbox, serviceCreds, acl } = freshApp({+ signingSecret: "test-secret",+ apiBaseUrl: "https://core.example.com",+ sandboxCapabilityTtlMs: ttl,+ });+ await serviceCreds.setServiceCredential("org:default-org", {+ slug: "test-service",+ name: "Test service",+ secret: "synthetic",+ host: "api.example.com",+ });+ await grantCred(acl, "org:default-org", "test-service");+ let captured: ProvisionOptions | undefined;+ let executed: Record<string, string> | undefined;+ const provision = sandbox.provision.bind(sandbox);+ sandbox.provision = (layers, opts) => {+ captured = opts;+ return provision(layers, opts);+ };+ const run = sandbox.run.bind(sandbox);+ sandbox.run = (handle, command, opts) => {+ if (command === "echo ttl") executed = handle.env;+ return run(handle, command, opts);+ };+ const before = Date.now();+ const res = await app.turn(+ dm(`!execute ${JSON.stringify({ command: "echo ttl", credentials: ["service_test-service"] })}`),);- }-});+ assert.equal(res.status, "ok", res.reason);+ const tokens = {+ AGENT_API_TOKEN: captured!.env!.AGENT_API_TOKEN!,+ AGENT_OAUTH_CONSENT_TOKEN: captured!.env!.AGENT_OAUTH_CONSENT_TOKEN!,+ AGENT_CREDENTIAL_TOKEN: executed!.AGENT_CREDENTIAL_TOKEN!,+ egressToken: captured!.egressToken!,+ };+ for (const [name, token] of Object.entries(tokens)) {+ const claims = await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET);+ assert.ok(claims, `${name} verifies`);+ if (ttl === 0) {+ assert.equal(claims.exp, 0);+ assert.ok(await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET, Number.MAX_SAFE_INTEGER));+ } else {+ assert.ok(claims.exp >= before + ttl && claims.exp <= Date.now() + ttl, name);+ assert.ok(await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET, claims.exp - 1));+ assert.equal(await verifyCapabilityToken(token, TEST_CAPABILITY_SECRET, claims.exp), null);+ }+ }+ });+}test("unattended grants enter capability claims only on non-live turns", async () => {const config = testConfig({diff --git a/test/pi-harness-oneshot.test.ts b/test/pi-harness-oneshot.test.tsindex 1be785bb6..39ff1e28a 100644--- a/test/pi-harness-oneshot.test.ts+++ b/test/pi-harness-oneshot.test.ts@@ -138,6 +138,7 @@ test("piHarnessConfigOptions maps every Config knob the harness consumes, fieldexecTimeoutMaxMs: 33_000,backgroundJobTtlMs: 44_000,backgroundJobTtlMaxMs: 55_000,+ sandboxCapabilityTtlMs: 66_000,}),);assert.deepEqual(opts, {@@ -163,6 +164,7 @@ test("piHarnessConfigOptions maps every Config knob the harness consumes, fieldexecTimeoutCeilingMs: 33_000,backgroundJobTtlMs: 44_000,backgroundJobTtlMaxMs: 55_000,+ sandboxCapabilityTtlMs: 66_000,});});diff --git a/test/service-credential-route.test.ts b/test/service-credential-route.test.tsindex 34411ffe6..ea0f26b6c 100644--- a/test/service-credential-route.test.ts+++ b/test/service-credential-route.test.ts@@ -1381,3 +1381,29 @@ test("credential prompt blocks are byte-identical across inventory and policy orassert.equal(second.status, "ok");assert.equal(second.reply, first.reply);});++test("broker accepts no-expiry sandbox tokens but still enforces credential disablement", async () => {+ let calls = 0;+ const srv = startBroker(async () => {+ calls++;+ return { status: 200, contentType: "text/plain", text: async () => "ok" };+ });+ try {+ const credential = { slug: "probe", name: "Probe", secret: "synthetic", host: "api.example.com" };+ await srv.built.serviceCreds.setServiceCredential("org:default-org", credential);+ const token = (exp: number) =>+ mintCapabilityToken(+ { actorId: "U1", scopeId: "personal:U1", aud: CREDENTIAL_BROKER_AUD, credentials: ["probe"], exp },+ SECRET,+ );+ const request = { credential: "probe", method: "GET", url: "https://api.example.com/probe" };+ assert.equal((await broker(srv.base, await token(Date.now() - 1), request)).status, 401);+ const unlimited = await token(0);+ assert.equal((await broker(srv.base, unlimited, request)).status, 200);+ await srv.built.serviceCreds.setServiceCredential("org:default-org", { ...credential, enabled: false });+ assert.equal((await broker(srv.base, unlimited, request)).status, 404);+ assert.equal(calls, 1);+ } finally {+ await srv.close();+ }+});