refactor: land approved runtime cleanup and room binding cutover

This commit is contained in:
ejclaw
2026-04-10 21:04:23 +09:00
parent ce3854745d
commit 4e05f60400
45 changed files with 636 additions and 637 deletions

View File

@@ -398,7 +398,7 @@ describe('createMessageRuntime', () => {
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -468,7 +468,7 @@ describe('createMessageRuntime', () => {
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -545,7 +545,7 @@ describe('createMessageRuntime', () => {
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -596,7 +596,7 @@ describe('createMessageRuntime', () => {
registerProcess: vi.fn(),
closeStdin: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -666,7 +666,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -742,7 +742,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -832,7 +832,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -915,7 +915,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1009,7 +1009,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1130,7 +1130,7 @@ describe('createMessageRuntime', () => {
notifyIdle: vi.fn(),
enqueueMessageCheck: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1229,7 +1229,7 @@ describe('createMessageRuntime', () => {
senderRole === 'reviewer',
),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1320,7 +1320,7 @@ describe('createMessageRuntime', () => {
noteDirectTerminalDelivery,
hasDirectTerminalDeliveryForRun: vi.fn(() => false),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1397,7 +1397,7 @@ describe('createMessageRuntime', () => {
noteDirectTerminalDelivery,
hasDirectTerminalDeliveryForRun,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1513,7 +1513,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1619,7 +1619,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1848,7 +1848,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -1976,7 +1976,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2076,7 +2076,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2161,7 +2161,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2254,7 +2254,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2349,7 +2349,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2462,7 +2462,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2578,7 +2578,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2670,7 +2670,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2759,7 +2759,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
notifyIdle: vi.fn(),
enqueueMessageCheck: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2823,7 +2823,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2896,7 +2896,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -2966,7 +2966,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3085,7 +3085,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3200,7 +3200,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3219,7 +3219,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
expect(agentRunner.runAgentProcess).toHaveBeenCalledTimes(1);
});
it('allows follow-up messages without a trigger after a visible reply in non-main groups', async () => {
it('processes first and follow-up messages without trigger mentions in non-main groups', async () => {
const chatJid = 'group@test';
const group: RegisteredGroup = {
...makeGroup('codex'),
@@ -3236,7 +3236,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
chat_jid: chatJid,
sender: 'user@test',
sender_name: 'User',
content: '@Andy 첫 요청',
content: '첫 요청도 멘션 없이 보냄',
timestamp: '2026-03-18T09:00:00.000Z',
},
])
@@ -3278,7 +3278,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3289,7 +3289,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
});
const first = await runtime.processGroupMessages(chatJid, {
runId: 'run-triggered-first-turn',
runId: 'run-triggerless-first-turn',
reason: 'messages',
});
const second = await runtime.processGroupMessages(chatJid, {
@@ -3362,7 +3362,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin,
notifyIdle,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3440,7 +3440,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin,
notifyIdle,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3527,7 +3527,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3627,7 +3627,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3708,7 +3708,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3810,7 +3810,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin,
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -3921,7 +3921,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4025,7 +4025,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4102,7 +4102,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4163,7 +4163,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4251,7 +4251,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4325,7 +4325,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4431,7 +4431,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4552,7 +4552,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4663,7 +4663,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4743,7 +4743,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4819,7 +4819,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin,
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4902,7 +4902,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -4974,7 +4974,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
closeStdin: vi.fn(),
notifyIdle: vi.fn(),
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -5034,7 +5034,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
enqueueMessageCheck,
enqueueTask,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),
@@ -5094,7 +5094,7 @@ If your first line is DONE_WITH_CONCERNS, the system will reopen review instead
enqueueMessageCheck,
enqueueTask,
} as any,
getRegisteredGroups: () => ({ [chatJid]: group }),
getRoomBindings: () => ({ [chatJid]: group }),
getSessions: () => ({}),
getLastTimestamp: () => '',
setLastTimestamp: vi.fn(),