Skip to content

Commit 487f6c3

Browse files
committed
test(permission): expect gpt shell args to survive dispatch
1 parent a0d094b commit 487f6c3

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎src/permission/worker-grant-dispatch-identity.test.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// gpt-family workers call run_shell as `shell`. Reactor authz sees that raw
2-
// wire call; the permission middleware sees DynamicToolRunner's
3-
// prepareDispatchedToolCall output, whose coerceShellArgs rebuilds the
4-
// arguments. The authorized retry must match the same envelope at both
5-
// stages.
1+
// gpt-family workers call run_shell as `shell` with run_shell's own
2+
// arguments. Reactor authz sees that raw wire call; the permission
3+
// middleware sees prepareDispatchedToolCall, which renames `shell` to
4+
// `run_shell` and leaves cwd, timeout, background, and stop in place.
5+
// The authorized retry must match the same envelope at both stages.
66
import { describe, expect, test } from "bun:test";
77
import type { ToolCall } from "@intx/types/runtime";
88

@@ -68,13 +68,21 @@ describe("gpt-family worker authorized retry identity", () => {
6868
expect(retryAuthz).toEqual({ effect: "allow" });
6969
expect(store.peek(requestId)?.status).toBe("authorized");
7070

71-
// 4. Retry, stage 2: DynamicToolRunner coerces the `shell` call onto
72-
// run_shell, then the posix middleware runs gateToolCall.
71+
// 4. Retry, stage 2: DynamicToolRunner renames `shell` onto run_shell
72+
// and keeps the gpt-native arguments, then the posix middleware runs
73+
// gateToolCall. The grant still matches the authorized envelope.
7374
const dispatched = prepareDispatchedToolCall(
7475
wireCall("call-2"),
7576
"run_shell",
7677
);
77-
expect(dispatched.arguments).not.toEqual(wireCall("x").arguments);
78+
expect(dispatched.name).toBe("run_shell");
79+
expect(dispatched.arguments).toEqual(wireCall("x").arguments);
80+
expect(dispatched.arguments).toMatchObject({
81+
cwd: CWD,
82+
timeout: 120000,
83+
background: false,
84+
stop: "",
85+
});
7886

7987
let executed = 0;
8088
const result = await gateToolCall(

0 commit comments

Comments
 (0)