Skip to content

Commit 69c2c06

Browse files
test(agents): assert real ACP task-row ownership contract (#124260)
* test(agents): assert real ACP task-row ownership contract The ACP spawn registration test asserted absence of a `requiresTaskRow` field that has never existed in production, so it protected nothing. Replace it with an assertion on the real contract: ACP registration must leave `taskRowOwnership` undefined so the registry falls back to best-effort task-row creation, contrasted with native/in-process spawn which forwards `taskRowOwnership: "required"` (and `gateway_best_effort` for out-of-process dispatch) on the same registration payload. * test(agents): require ACP registration before checking task-row ownership Mirror the sibling subagent-spawn test's required-registration pattern instead of optional-chaining into the mock call. The old assertion compared undefined?.taskRowOwnership, so it would silently pass even if registerSubagentRun was never invoked.
1 parent f4910cb commit 69c2c06

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎src/agents/subagents/spawn/acp-spawn.test.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,16 @@ describe("spawnAcpDirect", () => {
906906
expect(agentCall?.params?.deliver).toBe(true);
907907
expect(agentCall?.params?.lane).toBe("subagent");
908908
expect(agentCall?.params?.acpTurnSource).toBe("manual_spawn");
909-
expect(hoisted.registerSubagentRunMock.mock.calls[0]?.[0]).not.toHaveProperty(
910-
"requiresTaskRow",
911-
);
909+
// ACP registration must leave taskRowOwnership absent so the registry
910+
// falls back to best-effort task-row creation (subagent-registry-run-launch.ts).
911+
// Native/in-process spawn forwards "required" instead (subagent-spawn.ts);
912+
// if ACP ever claimed "required" here, a failed task-row write would abort
913+
// an ACP run the registry never actually owns.
914+
const registeredAcpRun = expectRecordFields(
915+
firstMockCall(hoisted.registerSubagentRunMock, "ACP subagent registration")[0],
916+
{},
917+
);
918+
expect(registeredAcpRun.taskRowOwnership).toBeUndefined();
912919
const initInput = expectInitializeSessionFields({
913920
agent: "codex",
914921
mode: "persistent",

‎src/agents/subagents/spawn/subagent-spawn.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,9 @@ describe("spawnSubagentDirect seam flow", () => {
11881188
});
11891189
const registerInput = firstRegisteredSubagentRun();
11901190
const requesterOrigin = requireRecord(registerInput.requesterOrigin);
1191+
// Out-of-process dispatch leaves the Gateway-owned task row in place, so
1192+
// registration must not also claim it (contrast with the in-process case above).
1193+
expect(registerInput.taskRowOwnership).toBe("gateway_best_effort");
11911194
expect(registerInput.runId).toBe("run-1");
11921195
expect(registerInput.childSessionKey).toBe(childSessionKey);
11931196
expect(registerInput.requesterSessionKey).toBe("agent:main:main");
@@ -1269,6 +1272,9 @@ describe("spawnSubagentDirect seam flow", () => {
12691272
expect(agentParams.provider).toBeUndefined();
12701273
expect(agentParams.model).toBeUndefined();
12711274
expect(agentOptions.allowSyntheticModelOverride).toBeUndefined();
1275+
// In-process dispatch claims the task row directly, unlike ACP's best-effort
1276+
// registration (see acp-spawn.test.ts).
1277+
expect(firstRegisteredSubagentRun().taskRowOwnership).toBe("required");
12721278
});
12731279

12741280
it("authorizes explicit model overrides for in-process child launches", async () => {

0 commit comments

Comments
 (0)