Make conversation queues mutually exclusive

This commit is contained in:
Jamie Brunton committed 2026-08-14 09:25:45 +01:00
1 parent 3bb1dda6bb
commit 2447563c60
20 files changed
+386 -220

No files matched your search

+19 -3
View File
@@ -15,6 +15,7 @@ const OPTIONS: SellerSweepOptions = {
killConfidence: 0.8,
flagConfidence: 0.6,
killOnSellerKeyword: true,
offPlatformKill: true,
};
function conversation(overrides: Partial<SellerSweepConversation> = {}): SellerSweepConversation {
@@ -68,7 +69,7 @@ describe('sweepConversationsForSellers', () => {
expect(ai.screenConversationsForSellers).not.toHaveBeenCalled();
expect(summary.deterministic).toBe(2);
expect(summary.aiRequests).toBe(0);
expect(summary.flagged.map((flag) => flag.source)).toEqual(['keyword', 'domain']);
expect(summary.flagged.map((flag) => flag.source)).toEqual(['funnel', 'funnel']);
expect(summary.flagged.every((flag) => flag.killed)).toBe(true);
expect(states.saved.get('room-keyword')?.sellerDetected).toBe(true);
expect(states.saved.get('room-keyword')?.automation.status).toBe('killed');
@@ -87,13 +88,28 @@ describe('sweepConversationsForSellers', () => {
expect(summary.flagged[0].source).toBe('funnel');
});
it('treats contact-platform and payment pushes as deterministic seller outcomes', async () => {
const states = stateStore();
const summary = await sweepConversationsForSellers([
conversation({ conversationId: 'telegram', messages: [{ sender: 'alice', text: 'add me on telegram', isSelf: false }] }),
conversation({ conversationId: 'snap', messages: [{ sender: 'alice', text: 'my snapchat is seller123', isSelf: false }] }),
conversation({ conversationId: 'cash', messages: [{ sender: 'alice', text: 'cash app is $seller123', isSelf: false }] }),
], OPTIONS, { states });
expect(summary.flagged.map((flag) => flag.source)).toEqual([
'off-platform', 'off-platform', 'off-platform',
]);
expect(summary.flagged.every((flag) => flag.killed)).toBe(true);
});
it('hands the deterministic kill decision to the configured policy', async () => {
const states = stateStore();
const triage = { setStatus: vi.fn() };
const summary = await sweepConversationsForSellers(
[conversation({ messages: [{ sender: 'alice', text: 'see my onlyfans', isSelf: false }] })],
{ ...OPTIONS, killOnSellerKeyword: false },
[conversation({ messages: [{ sender: 'alice', text: 'you could spoil me', isSelf: false }] })],
{ ...OPTIONS, sellerKeywords: ['spoil me'], killOnSellerKeyword: false },
{ states, triage },
);