fix: gate paired runtime on dual registrations

This commit is contained in:
Eyejoker
2026-03-31 12:14:24 +09:00
parent 89335ab005
commit 236f7c2fea
4 changed files with 19 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ import {
getAllRegisteredGroups,
getDueTasks,
getEffectiveRoomMode,
getEffectiveRuntimeRoomMode,
getExplicitRoomMode,
getLatestMessageSeqAtOrBefore,
getLatestPairedTaskForChat,
@@ -824,6 +825,7 @@ describe('paired room registration', () => {
expect(getExplicitRoomMode('dc:legacy-paired')).toBeUndefined();
expect(getEffectiveRoomMode('dc:legacy-paired')).toBe('tribunal');
expect(getEffectiveRuntimeRoomMode('dc:legacy-paired')).toBe('tribunal');
expect(isPairedRoomJid('dc:legacy-paired')).toBe(true);
});
@@ -847,10 +849,11 @@ describe('paired room registration', () => {
expect(getExplicitRoomMode('dc:explicit-single')).toBe('single');
expect(getEffectiveRoomMode('dc:explicit-single')).toBe('single');
expect(getEffectiveRuntimeRoomMode('dc:explicit-single')).toBe('single');
expect(isPairedRoomJid('dc:explicit-single')).toBe(false);
});
it('lets explicit tribunal override solo fallback and clears back to inferred mode', () => {
it('keeps explicit tribunal configured but not runnable without dual registration', () => {
setRegisteredGroup('dc:explicit-tribunal', {
name: 'Explicit Tribunal Claude',
folder: 'explicit-tribunal-claude',
@@ -865,12 +868,14 @@ describe('paired room registration', () => {
expect(getExplicitRoomMode('dc:explicit-tribunal')).toBe('tribunal');
expect(getEffectiveRoomMode('dc:explicit-tribunal')).toBe('tribunal');
expect(isPairedRoomJid('dc:explicit-tribunal')).toBe(true);
expect(getEffectiveRuntimeRoomMode('dc:explicit-tribunal')).toBe('single');
expect(isPairedRoomJid('dc:explicit-tribunal')).toBe(false);
clearExplicitRoomMode('dc:explicit-tribunal');
expect(getExplicitRoomMode('dc:explicit-tribunal')).toBeUndefined();
expect(getEffectiveRoomMode('dc:explicit-tribunal')).toBe('single');
expect(getEffectiveRuntimeRoomMode('dc:explicit-tribunal')).toBe('single');
expect(isPairedRoomJid('dc:explicit-tribunal')).toBe(false);
});
});

View File

@@ -1978,8 +1978,15 @@ export function getEffectiveRoomMode(chatJid: string): RoomMode {
return getExplicitRoomMode(chatJid) ?? inferRoomModeForJid(chatJid);
}
export function getEffectiveRuntimeRoomMode(chatJid: string): RoomMode {
return getEffectiveRoomMode(chatJid) === 'tribunal' &&
inferRoomModeForJid(chatJid) === 'tribunal'
? 'tribunal'
: 'single';
}
export function isPairedRoomJid(jid: string): boolean {
return getEffectiveRoomMode(jid) === 'tribunal';
return getEffectiveRuntimeRoomMode(jid) === 'tribunal';
}
// --- Paired task/project/workspace state ---

View File

@@ -108,7 +108,7 @@ describe('service-routing global failover', () => {
});
});
it('uses explicit tribunal room mode to add reviewer lease on solo rooms', () => {
it('does not create reviewer lease for explicit tribunal without dual registration capability', () => {
setRegisteredGroup('dc:explicit-tribunal', {
name: 'Explicit Tribunal Claude',
folder: 'explicit-tribunal-claude',
@@ -121,7 +121,7 @@ describe('service-routing global failover', () => {
expect(getEffectiveChannelLease('dc:explicit-tribunal')).toMatchObject({
chat_jid: 'dc:explicit-tribunal',
owner_service_id: 'claude',
reviewer_service_id: 'claude',
reviewer_service_id: null,
explicit: false,
});
});

View File

@@ -12,7 +12,7 @@ import {
import {
clearChannelOwnerLease,
getAllChannelOwnerLeases,
getEffectiveRoomMode,
getEffectiveRuntimeRoomMode,
getRegisteredAgentTypesForJid,
setChannelOwnerLease,
type ChannelOwnerLeaseRow,
@@ -59,7 +59,7 @@ function getDefaultLease(chatJid: string): EffectiveChannelLease {
const types = getRegisteredAgentTypesForJid(chatJid);
const hasClaude = types.includes('claude-code');
const hasCodex = types.includes('codex');
const roomMode = getEffectiveRoomMode(chatJid);
const roomMode = getEffectiveRuntimeRoomMode(chatJid);
if (roomMode === 'tribunal') {
const ownerServiceId =