Skip to content

Commit 4d30cdf

Browse files
committed
Stabilize merged runtime proxy verification
1 parent a9c0bf8 commit 4d30cdf

2 files changed

Lines changed: 56 additions & 3 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"lint:fix": "npm run lint:ts:fix && npm run lint:scripts:fix",
8080
"lint:ts:fix": "eslint . --ext .ts --fix",
8181
"lint:scripts:fix": "eslint scripts --ext .js,.mjs --fix",
82-
"test": "vitest run",
82+
"test": "vitest run --maxWorkers=1",
8383
"test:watch": "vitest",
8484
"test:ui": "vitest --ui",
8585
"test:model-matrix": "node scripts/test-model-matrix.js",
@@ -93,8 +93,8 @@
9393
"bench:edit-formats:render": "node scripts/benchmark-render-dashboard.mjs",
9494
"bench:runtime-path": "npm run build && node scripts/benchmark-runtime-path.mjs",
9595
"bench:runtime-path:quick": "node scripts/benchmark-runtime-path.mjs",
96-
"test:coverage": "vitest run --coverage",
97-
"coverage": "npm run build && vitest run --coverage",
96+
"test:coverage": "vitest run --coverage --maxWorkers=1",
97+
"coverage": "npm run build && vitest run --coverage --maxWorkers=1",
9898
"audit:prod": "npm audit --omit=dev --audit-level=high",
9999
"audit:all": "npm audit --audit-level=high",
100100
"audit:dev:allowlist": "node scripts/audit-dev-allowlist.js",

test/runtime-rotation-proxy.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,59 @@ describe("runtime rotation proxy", () => {
683683
]);
684684
});
685685

686+
it("stores null blocked thread goal fallbacks by snake-case body thread id", async () => {
687+
const now = Date.now();
688+
const accountManager = new AccountManager(undefined, createStorage(now));
689+
const { calls, fetchImpl } = createRecordingFetch(
690+
() =>
691+
new Response("<html>blocked</html>", {
692+
status: HTTP_STATUS.FORBIDDEN,
693+
headers: { "content-type": "text/html" },
694+
}),
695+
);
696+
const proxy = await startProxy({ accountManager, fetchImpl });
697+
698+
const setResponse = await postThreadGoal(
699+
proxy,
700+
{ thread_id: "thread-snake" },
701+
"/thread/goal/set",
702+
);
703+
const getResponse = await getThreadGoal(
704+
proxy,
705+
"/thread/goal/get?threadId=thread-snake",
706+
);
707+
708+
expect(setResponse.status).toBe(HTTP_STATUS.OK);
709+
expect(await setResponse.json()).toEqual({ ok: true, goal: null });
710+
expect(getResponse.status).toBe(HTTP_STATUS.OK);
711+
expect(await getResponse.json()).toEqual({ goal: null });
712+
expect(calls).toHaveLength(2);
713+
});
714+
715+
it("prioritizes workspace-disabled 403 handling over thread goal fallback", async () => {
716+
const now = Date.now();
717+
const accountManager = new AccountManager(undefined, createStorage(now, 1));
718+
const { calls, fetchImpl } = createRecordingFetch(() =>
719+
new Response(JSON.stringify({ error: { code: "workspace_disabled" } }), {
720+
status: HTTP_STATUS.FORBIDDEN,
721+
headers: { "content-type": "application/json" },
722+
}),
723+
);
724+
const proxy = await startProxy({ accountManager, fetchImpl });
725+
726+
const response = await postThreadGoal(
727+
proxy,
728+
{ threadId: "thread-disabled", goal: "ship it" },
729+
"/thread/goal/set",
730+
);
731+
const payload = (await response.json()) as { error: { reason: string } };
732+
733+
expect(response.status).toBe(HTTP_STATUS.SERVICE_UNAVAILABLE);
734+
expect(payload.error.reason).toBe("deactivated");
735+
expect(calls).toHaveLength(1);
736+
expect(accountManager.getAccountByIndex(0)?.enabled).toBe(false);
737+
});
738+
686739
it("passes through non-fallback thread goal client errors", async () => {
687740
const now = Date.now();
688741
const accountManager = new AccountManager(undefined, createStorage(now));

0 commit comments

Comments
 (0)