Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

test(e2e): make test theming less likely to trigger refusals (#2986)

OwenKephart667d524a58f0
diff --git a/e2e/fixtures/agent-subagents/agent/channels/eve.ts b/e2e/fixtures/agent-subagents/agent/channels/eve.ts
index 1f69976cb..ca32e7471 100644
--- a/e2e/fixtures/agent-subagents/agent/channels/eve.ts
+++ b/e2e/fixtures/agent-subagents/agent/channels/eve.ts
@@ -7,17 +7,17 @@ import type { SessionAuthContext } from "eve/context";
* deterministic principals, no injected env (the deployment is deliberately
* open — fixture-only; do not pattern production channels off this):
*
- * - The `remote-loopback` hop authenticates with a fixed bearer and runs as
+ * - The `remote-loopback` hop authenticates with a fixture authorization and runs as
* the `router-app` service principal — the trusted forwarder.
- * - Bob and the observer each have a fixed bearer, so the eval can continue
+ * - Bob and the observer each have a fixture authorization, so the eval can continue
* Alice's child as two distinct callers. Bob has his own user grant; the
* observer deliberately has none.
* - Every other caller (the local eval driver is anonymous; the Vercel one
* may carry ambient OIDC) falls through to Alice's fixed user principal.
*/
-const ROUTER_AUTHORIZATION = "Bearer e2e-principal-forwarding-router";
-const BOB_AUTHORIZATION = "Bearer e2e-principal-forwarding-bob";
-const OBSERVER_AUTHORIZATION = "Bearer e2e-principal-forwarding-observer";
+const ROUTER_AUTHORIZATION = "Bearer e2e-workspace-label-router";
+const BOB_AUTHORIZATION = "Bearer e2e-workspace-label-bob";
+const OBSERVER_AUTHORIZATION = "Bearer e2e-workspace-label-observer";
function createFixtureUserPrincipal(principalId: string): SessionAuthContext {
return {
diff --git a/e2e/fixtures/agent-subagents/agent/subagents/remote-loopback.ts b/e2e/fixtures/agent-subagents/agent/subagents/remote-loopback.ts
index 2753eb820..748388bce 100644
--- a/e2e/fixtures/agent-subagents/agent/subagents/remote-loopback.ts
+++ b/e2e/fixtures/agent-subagents/agent/subagents/remote-loopback.ts
@@ -22,7 +22,7 @@ export default defineDynamic({
: (process.env.WORKFLOW_LOCAL_BASE_URL ?? "http://127.0.0.1:3000"),
headers: () => {
const headers: Record<string, string> = {
- authorization: "Bearer e2e-principal-forwarding-router",
+ authorization: "Bearer e2e-workspace-label-router",
};
// Preview deployments behind Vercel deployment protection need the
// bypass header on the self-call; harmless when protection is off.
diff --git a/e2e/fixtures/agent-subagents/agent/tools/read-private-data.ts b/e2e/fixtures/agent-subagents/agent/tools/read-private-data.ts
deleted file mode 100644
index 16640c979..000000000
--- a/e2e/fixtures/agent-subagents/agent/tools/read-private-data.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { NonInteractiveAuthorizationDefinition } from "eve/connections";
-import { defineTool } from "eve/tools";
-import { z } from "zod";
-
-const privateDataByGrant: Readonly<Record<string, string>> = {
- "grant:alice": "ALICE_PRIVATE_DM_7K4M",
- "grant:bob": "BOB_PRIVATE_DM_9P2R",
-};
-
-const grantByPrincipal: Readonly<Record<string, string>> = {
- "e2e-user": "grant:alice",
- "e2e-user-2": "grant:bob",
-};
-
-// Models a provider-side grant store: eve selects the principal, while the
-// provider returns only that principal's bearer.
-const userGrant: NonInteractiveAuthorizationDefinition = {
- principalType: "user",
- async getToken({ principal }) {
- if (principal.type !== "user") throw new Error("A user grant is required.");
- const token = grantByPrincipal[principal.id];
- if (token === undefined) throw new Error(`No OAuth grant exists for ${principal.id}.`);
- return { token };
- },
-};
-
-export default defineTool({
- description:
- "Reads private data using the current caller's user-scoped grant. Call only when explicitly requested.",
- inputSchema: z.object({}),
- async execute(_input, ctx) {
- const grant = await ctx.getToken(userGrant, { authKey: "private-data" });
- const privateData = privateDataByGrant[grant.token];
- if (privateData === undefined) throw new Error("No private data exists for this grant.");
- return { privateData };
- },
-});
diff --git a/e2e/fixtures/agent-subagents/agent/tools/read-workspace-label.ts b/e2e/fixtures/agent-subagents/agent/tools/read-workspace-label.ts
new file mode 100644
index 000000000..8273f1e5b
--- /dev/null
+++ b/e2e/fixtures/agent-subagents/agent/tools/read-workspace-label.ts
@@ -0,0 +1,35 @@
+import type { NonInteractiveAuthorizationDefinition } from "eve/connections";
+import { defineTool } from "eve/tools";
+import { z } from "zod";
+
+const workspaceLabelByMembership: Readonly<Record<string, string>> = {
+ "membership:alice": "ALICE_WORKSPACE_LABEL_7K4M",
+ "membership:bob": "BOB_WORKSPACE_LABEL_9P2R",
+};
+
+const membershipByPrincipal: Readonly<Record<string, string>> = {
+ "e2e-user": "membership:alice",
+ "e2e-user-2": "membership:bob",
+};
+
+// Models a provider-side workspace membership store selected by eve for the current principal.
+const userGrant: NonInteractiveAuthorizationDefinition = {
+ principalType: "user",
+ async getToken({ principal }) {
+ if (principal.type !== "user") throw new Error("A user workspace membership is required.");
+ const token = membershipByPrincipal[principal.id];
+ if (token === undefined) throw new Error(`No workspace membership exists for ${principal.id}.`);
+ return { token };
+ },
+};
+
+export default defineTool({
+ description: "Reads the current caller's workspace label. Call only when explicitly requested.",
+ inputSchema: z.object({}),
+ async execute(_input, ctx) {
+ const grant = await ctx.getToken(userGrant, { authKey: "workspace-label" });
+ const workspaceLabel = workspaceLabelByMembership[grant.token];
+ if (workspaceLabel === undefined) throw new Error("No workspace label exists for this grant.");
+ return { workspaceLabel };
+ },
+});
diff --git a/e2e/fixtures/agent-subagents/evals/remote-principal-forwarding.eval.ts b/e2e/fixtures/agent-subagents/evals/remote-principal-forwarding.eval.ts
index 2581cad0e..d942a40ce 100644
--- a/e2e/fixtures/agent-subagents/evals/remote-principal-forwarding.eval.ts
+++ b/e2e/fixtures/agent-subagents/evals/remote-principal-forwarding.eval.ts
@@ -1,39 +1,39 @@
import { defineEval, type EveEvalContext, type EveEvalSession } from "eve/evals";
-const ALICE_PRIVATE_DATA = "ALICE_PRIVATE_DM_7K4M";
-const BOB_PRIVATE_DATA = "BOB_PRIVATE_DM_9P2R";
-const BOB_AUTHORIZATION = "Bearer e2e-principal-forwarding-bob";
-const OBSERVER_AUTHORIZATION = "Bearer e2e-principal-forwarding-observer";
+const ALICE_WORKSPACE_LABEL = "ALICE_WORKSPACE_LABEL_7K4M";
+const BOB_WORKSPACE_LABEL = "BOB_WORKSPACE_LABEL_9P2R";
+const BOB_AUTHORIZATION = "Bearer e2e-workspace-label-bob";
+const OBSERVER_AUTHORIZATION = "Bearer e2e-workspace-label-observer";
const CHILD_MESSAGE = [
- "[forward-auth:child] Call read-private-data exactly once.",
- "If it succeeds, reply with only its privateData value.",
- "If it fails, reply with only ACCESS_DENIED.",
+ "[workspace-label:child] Call read-workspace-label exactly once.",
+ "If it succeeds, reply with only its workspaceLabel value.",
+ "If it fails, reply with only NO_WORKSPACE_ACCESS.",
].join(" ");
const CREATE_CHILD_MESSAGE = [
- "[forward-auth:create] Use remote-loopback exactly once with this message:",
+ "[workspace-label:create] Use remote-loopback exactly once with this message:",
JSON.stringify(CHILD_MESSAGE),
"Reply with only the child's output.",
].join(" ");
const CONTINUE_CHILD_MESSAGE = [
- "[forward-auth:continue] Continue that same remote-loopback agent using its agentId with this message:",
+ "[workspace-label:continue] Continue that same remote-loopback agent using its agentId with this message:",
JSON.stringify(CHILD_MESSAGE),
"Reply with only the child's output.",
].join(" ");
-/** Three users resume one remote child; each tool call resolves only its current caller's grant. */
+/** Three users resume one remote child; each tool call resolves only its current caller's workspace membership. */
export default defineEval({
tags: ["principal-forwarding", "real-model"],
description:
- "A persistent remote child switches between two user grants and denies a third caller with none.",
+ "A persistent remote child switches between two workspace memberships and denies a third caller with none.",
async test(t) {
- // Alice creates the child and reads with her own grant.
+ // Alice creates the child and reads her workspace label.
await t.send(CREATE_CHILD_MESSAGE);
const aliceParent = await waitForRemoteChild(t, t);
const childSessionId = aliceParent.childSessionId;
const aliceChild = await t.target.watchTurn(childSessionId).result();
let childEventCount = aliceChild.events.length;
- // Bob continues the same child and must resolve Bob's grant, not Alice's.
+ // Bob continues the same child and must resolve Bob's workspace label, not Alice's.
await aliceParent.session.send(CONTINUE_CHILD_MESSAGE, {
headers: { authorization: BOB_AUTHORIZATION },
});
@@ -43,8 +43,8 @@ export default defineEval({
.result();
childEventCount += bobChild.events.length;
- // A grantless observer continues it once more. Reusing either prior bearer
- // would complete this call; correct per-turn scoping makes it fail.
+ // A grantless observer continues it once more. Reusing either prior membership
+ // would complete this call; correct per-turn scoping denies access.
await bobParent.session.send(CONTINUE_CHILD_MESSAGE, {
headers: { authorization: OBSERVER_AUTHORIZATION },
});
@@ -53,23 +53,23 @@ export default defineEval({
.watchTurn(childSessionId, { startIndex: childEventCount })
.result();
- aliceChild.calledTool("read-private-data", {
+ aliceChild.calledTool("read-workspace-label", {
count: 1,
- output: { privateData: ALICE_PRIVATE_DATA },
+ output: { workspaceLabel: ALICE_WORKSPACE_LABEL },
status: "completed",
});
- bobChild.calledTool("read-private-data", {
+ bobChild.calledTool("read-workspace-label", {
count: 1,
- output: { privateData: BOB_PRIVATE_DATA },
+ output: { workspaceLabel: BOB_WORKSPACE_LABEL },
status: "completed",
});
- observerChild.calledTool("read-private-data", { count: 1, status: "failed" });
- observerChild.calledTool("read-private-data", { count: 0, status: "completed" });
+ observerChild.calledTool("read-workspace-label", { count: 1, status: "failed" });
+ observerChild.calledTool("read-workspace-label", { count: 0, status: "completed" });
observerChild.event("action.result", {
count: 1,
data: {
- error: { message: /No OAuth grant exists for e2e-observer/ },
- result: { kind: "tool-result", toolName: "read-private-data" },
+ error: { message: /No workspace membership exists for e2e-observer/ },
+ result: { kind: "tool-result", toolName: "read-workspace-label" },
status: "failed",
},
});
@@ -93,6 +93,7 @@ async function waitForRemoteChild(
}
const live = t.target.watchTurn(session.sessionId, { startIndex: session.state.streamIndex });
const turn = await live.result();
+ turn.expectOk();
const call = turn.events.find(
(event) => event.type === "subagent.called" && event.data.name === "remote-loopback",
);