Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions loopx/control_plane/collaboration/conversation_scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,14 @@ export function boundConversationExecutorMatches(row: Record<string, unknown>, s
const configured = row.executor_endpoint_id;
if (configured !== "antigravity" && configured !== "codex") return false;
const fallback = configured === "antigravity" ? "codex" : "antigravity";
const flexiblePoolMatch =
(allocation?.configured_endpoint === configured && allocation.allocation_reason === "flexible_availability_fallback")
|| (allocation?.configured_endpoint === fallback && allocation.allocation_reason === "flexible_primary_available");
return row.context_kind === "steward" && row.audience !== "group"
&& session.agent_id === fallback && session.executor_endpoint_id === fallback
&& allocation?.schema_version === "manager_executor_allocation_v0"
&& allocation.selection_policy === "flexible" && allocation.configured_endpoint === configured
&& allocation.executor_endpoint === fallback && allocation.allocation_reason === "flexible_availability_fallback"
&& allocation.selection_policy === "flexible"
&& allocation.executor_endpoint === fallback && flexiblePoolMatch
&& typeof allocation.configuration_revision === "string" && allocation.configuration_revision.length > 0
&& Array.isArray(allocation.eligible_endpoints) && allocation.eligible_endpoints.length === 2
&& allocation.eligible_endpoints.includes("antigravity") && allocation.eligible_endpoints.includes("codex")
Expand Down
25 changes: 25 additions & 0 deletions tests/control_plane_ts/conversation_binding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2054,3 +2054,28 @@ test("a steward quota endpoint change preserves its exact bound audience", () =>
}
assert.throws(() => resolveBoundConversation({...packet, sender_ref: "f".repeat(24), session, session_context: context}));
});


test("a steward session migrated via flexible_primary_available preserves web and bound intake audience", () => {
const codexBinding = {...row, context_kind: "steward", grant: "portfolio_read", goal_ids: [], executor_endpoint_id: "codex"};
const configured = planConversationBinding({...request, binding: codexBinding}).state;
const source = {source_ref: "e".repeat(24), sender_ref: row.operator_ref, private_human_message: true};
const packet = {current: configured, binding_id: row.binding_id, observation, available_projects: [project], ...source};
const context = resolveBoundConversation(packet).context;
const primaryAllocation = {schema_version: "manager_executor_allocation_v0", selection_policy: "flexible",
configured_endpoint: "antigravity", executor_endpoint: "antigravity", configuration_revision: "revision-2",
allocation_reason: "flexible_primary_available", eligible_endpoints: ["antigravity", "codex"]};
const migratedSession = {session_id: "original", goal_id: "loopx-manager", agent_id: "antigravity", executor_endpoint_id: "antigravity",
session_mode: "managed_runtime", status: "ready", upstream_thread_id: "antigravity-native",
channel_id: `manager.external.native.${row.binding_id}.${source.source_ref}`, steward_context: context,
manager_executor_allocation: primaryAllocation, upstream_context_history: [{agent_id: "codex", thread_id: "original-codex"}]};
const webPacket = {...packet, origin: "web", private_human_message: false, session: migratedSession, session_context: context};
assert.deepEqual(resolveBoundConversation(webPacket).context, context);
for (const invalid of [
{upstream_context_history: []},
{manager_executor_allocation: {...primaryAllocation, allocation_reason: "flexible_availability_fallback"}},
{manager_executor_allocation: {...primaryAllocation, configured_endpoint: "codex"}},
]) {
assert.throws(() => resolveBoundConversation({...webPacket, session: {...migratedSession, ...invalid}}));
}
});
34 changes: 34 additions & 0 deletions tests/control_plane_ts/conversation_scope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,38 @@ test("boundConversationExecutorMatches validates bidirectional flexible fallback
}), false);
assert.equal(boundConversationExecutorMatches({...row, audience: "group"}, valid), false);
assert.equal(boundConversationExecutorMatches(row, {...valid, executor_endpoint_id: "codex"}), false);

for (const [configured, migrated] of [["codex", "antigravity"], ["antigravity", "codex"]] as const) {
const primaryRow = {context_kind: "steward", audience: "owner", executor_endpoint_id: configured};
const primaryAllocation = {
schema_version: "manager_executor_allocation_v0",
selection_policy: "flexible",
configured_endpoint: migrated,
executor_endpoint: migrated,
allocation_reason: "flexible_primary_available",
configuration_revision: "rev-2",
eligible_endpoints: [migrated, configured],
};
const primaryMigrated = {
agent_id: migrated,
executor_endpoint_id: migrated,
manager_executor_allocation: primaryAllocation,
upstream_context_history: [{agent_id: configured, thread_id: `orig-${configured}-thread`}],
};
assert.equal(boundConversationExecutorMatches(primaryRow, primaryMigrated), true);
assert.equal(boundConversationExecutorMatches(primaryRow, {
...primaryMigrated,
manager_executor_allocation: {...primaryAllocation, configured_endpoint: configured},
}), false);
assert.equal(boundConversationExecutorMatches(primaryRow, {
...primaryMigrated,
manager_executor_allocation: {...primaryAllocation, allocation_reason: "flexible_availability_fallback"},
}), false);
assert.equal(boundConversationExecutorMatches(primaryRow, {...primaryMigrated, upstream_context_history: []}), false);
assert.equal(boundConversationExecutorMatches({...primaryRow, audience: "group"}, primaryMigrated), false);
assert.equal(boundConversationExecutorMatches(primaryRow, {
...primaryMigrated,
manager_executor_allocation: {...primaryAllocation, selection_policy: "preferred"},
}), false);
}
});
16 changes: 16 additions & 0 deletions tests/control_plane_ts/steward_managed_mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,22 @@ test("observeStewardNativeExecutor admits qualified codex-to-antigravity fallbac
...qualifiedFallback,
session: {...qualifiedFallback.session, upstream_context_history: []},
}).execution_available, false);
const flexiblePrimaryMigrated = {
binding: params.binding,
session: {
...qualifiedFallback.session,
manager_executor_allocation: {
schema_version: "manager_executor_allocation_v0",
selection_policy: "flexible",
configured_endpoint: "antigravity",
executor_endpoint: "antigravity",
allocation_reason: "flexible_primary_available",
configuration_revision: "rev-2",
eligible_endpoints: ["antigravity", "codex"],
},
},
};
assert.equal(observeStewardNativeExecutor(flexiblePrimaryMigrated).execution_available, true);
});

test("zero-effect worker exit, storage I/O, and runtime unavailability monitors admit one bounded recovery", () => {
Expand Down
Loading