refactor: prefer room_settings over registered_groups in runtime reads
This commit is contained in:
@@ -1130,7 +1130,7 @@ describe('paired room registration', () => {
|
||||
expect(getEffectiveRuntimeRoomMode('dc:explicit-tribunal')).toBe('single');
|
||||
});
|
||||
|
||||
it('keeps explicit tribunal non-runnable when the configured reviewer service is unavailable', () => {
|
||||
it('trusts stored tribunal mode even when legacy capability rows are incomplete', () => {
|
||||
_setRegisteredGroupForTests('dc:explicit-tribunal-codex', {
|
||||
name: 'Explicit Tribunal Codex',
|
||||
folder: 'explicit-tribunal-codex',
|
||||
@@ -1143,7 +1143,7 @@ describe('paired room registration', () => {
|
||||
|
||||
expect(getEffectiveRoomMode('dc:explicit-tribunal-codex')).toBe('tribunal');
|
||||
expect(getEffectiveRuntimeRoomMode('dc:explicit-tribunal-codex')).toBe(
|
||||
'single',
|
||||
'tribunal',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2770,7 +2770,12 @@ function canRunTribunalFromRegisteredAgentTypes(
|
||||
}
|
||||
|
||||
export function getEffectiveRuntimeRoomMode(chatJid: string): RoomMode {
|
||||
return getEffectiveRoomMode(chatJid) === 'tribunal' &&
|
||||
const stored = getStoredRoomSettings(chatJid);
|
||||
if (stored) {
|
||||
return stored.roomMode;
|
||||
}
|
||||
|
||||
return inferStoredRoomModeForJid(chatJid) === 'tribunal' &&
|
||||
canRunTribunalFromRegisteredAgentTypes(
|
||||
getRegisteredAgentTypesForJid(chatJid),
|
||||
)
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('service-routing global failover', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back to the available service when stored owner agent type is unavailable', () => {
|
||||
it('trusts stored owner agent type over incomplete legacy capability rows', () => {
|
||||
_setRegisteredGroupForTests('dc:stored-owner-fallback', {
|
||||
name: 'Stored Owner Fallback',
|
||||
folder: 'stored-owner-fallback',
|
||||
@@ -150,7 +150,7 @@ describe('service-routing global failover', () => {
|
||||
|
||||
expect(getEffectiveChannelLease('dc:stored-owner-fallback')).toMatchObject({
|
||||
chat_jid: 'dc:stored-owner-fallback',
|
||||
owner_service_id: 'claude',
|
||||
owner_service_id: 'codex-main',
|
||||
reviewer_service_id: null,
|
||||
explicit: false,
|
||||
});
|
||||
@@ -174,7 +174,7 @@ describe('service-routing global failover', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps reviewer lease disabled when explicit tribunal cannot deliver the configured reviewer', () => {
|
||||
it('builds reviewer lease from stored tribunal mode even when legacy rows are incomplete', () => {
|
||||
_setRegisteredGroupForTests('dc:explicit-tribunal-codex', {
|
||||
name: 'Explicit Tribunal Codex',
|
||||
folder: 'explicit-tribunal-codex',
|
||||
@@ -189,7 +189,7 @@ describe('service-routing global failover', () => {
|
||||
).toMatchObject({
|
||||
chat_jid: 'dc:explicit-tribunal-codex',
|
||||
owner_service_id: 'codex-main',
|
||||
reviewer_service_id: null,
|
||||
reviewer_service_id: 'claude',
|
||||
explicit: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,17 +72,14 @@ function inferFallbackOwnerAgentType(
|
||||
}
|
||||
|
||||
function resolveDefaultOwnerAgentType(chatJid: string): AgentType | undefined {
|
||||
const storedOwnerAgentType = getStoredRoomSettings(chatJid)?.ownerAgentType;
|
||||
if (storedOwnerAgentType) {
|
||||
return storedOwnerAgentType;
|
||||
}
|
||||
|
||||
const types = getRegisteredAgentTypesForJid(chatJid);
|
||||
const hasClaude = types.includes('claude-code');
|
||||
const hasCodex = types.includes('codex');
|
||||
const storedOwnerAgentType = getStoredRoomSettings(chatJid)?.ownerAgentType;
|
||||
|
||||
if (storedOwnerAgentType === 'claude-code' && hasClaude) {
|
||||
return 'claude-code';
|
||||
}
|
||||
if (storedOwnerAgentType === 'codex' && hasCodex) {
|
||||
return 'codex';
|
||||
}
|
||||
|
||||
return inferFallbackOwnerAgentType(hasClaude, hasCodex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user