Skip to content

Commit 4e9820f

Browse files
committed
test(responses): cover adapter owner mismatch
1 parent 8bb958e commit 4e9820f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/server/responses/core.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ function bindRouteReasoningReplayScope(args: {
485485
: undefined,
486486
);
487487
if (adapterName === "cursor") {
488+
// The final route owner is authoritative for Cursor and supersedes the account-derived
489+
// seed assigned before route binding. A Cursor conversation must be scoped to the exact
490+
// provider/destination/adapter/model/credential that serves it.
488491
if (continuationOwner) parsed._cursorIdentityScope = providerContinuationRouteScope(continuationOwner);
489492
else if (!parsed._cursorIdentityScope?.startsWith("cursor-unowned:")) {
490493
// Prevent the adapter's token-only fallback from recreating a provider-private id after the
@@ -2344,8 +2347,9 @@ async function handleResponsesInner(
23442347
? `${route.providerName}-${route.codexAccountNamespace}`
23452348
: formatCodexProviderForLog(route.providerName, codexLogAccountId(authCtx), config);
23462349
logCtx.accountLogLabel = codexAuthContextLogLabel(authCtx, config);
2347-
// Prefer Codex pool account as the Cursor thread namespace when present. Cursor routes without
2348-
// codexAccountMode still get a credential-derived scope inside the Cursor adapter.
2350+
// Seed an account-derived scope before final adapter binding. Cursor never treats it as
2351+
// authoritative: bindRouteReasoningReplayScope replaces it with the exact route owner or a
2352+
// per-request fail-closed sentinel after the final provider and credential are known.
23492353
const identityScope = codexLogAccountId(authCtx);
23502354
if (identityScope) parsed._cursorIdentityScope = identityScope;
23512355
subagentFallbackAccountId = authCtx.kind === "pool" || authCtx.kind === "main-pool"

‎tests/server-combo-failover-e2e.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ describe("server combo failover 030 activation matrix", () => {
19181918
expect(seen).toEqual([undefined, undefined]);
19191919
});
19201920

1921-
test.each(["provider", "destination", "model"] as const)(
1921+
test.each(["provider", "destination", "adapter", "model"] as const)(
19221922
"continuation owner rejects an exact %s mismatch",
19231923
async mismatch => {
19241924
const seen: Array<string | undefined> = [];
@@ -1943,6 +1943,10 @@ describe("server combo failover 030 activation matrix", () => {
19431943
config.combos!.free!.targets = [{ provider: "b", model: "m1" }];
19441944
} else if (mismatch === "destination") {
19451945
config.providers.a!.baseUrl = "https://kiro-b.test/v1";
1946+
} else if (mismatch === "adapter") {
1947+
// Keep provider, destination, credential, and model fixed so only the adapter owner
1948+
// component changes. The first test-kiro turn already persisted the owned state.
1949+
config.providers.a!.adapter = "test-owned";
19461950
} else {
19471951
config.combos!.free!.targets = [{ provider: "a", model: "m2" }];
19481952
}

0 commit comments

Comments
 (0)