Preserve commenter role in outreach targeting

This commit is contained in:
jjbrunton committed 2026-08-14 12:59:53 +01:00
1 parent 12e2dc56f1
commit 5e1fc5def9
11 files changed
+35 -26

No files matched your search

+6 -5
View File
@@ -98,7 +98,7 @@ describe('CandidateQueueRepository', () => {
expect(queue.countActive()).toBe(2);
});
it('requeues only unedited commenter preparations from the legacy opener contract', () => {
it('rejects active commenter candidates admitted by the legacy role policy', () => {
const legacyComment = {
...post('comment-legacy', 'alice', 300),
targetComment: {
@@ -112,7 +112,7 @@ describe('CandidateQueueRepository', () => {
targetComment: {
body: 'I want that too', permalink: '/r/test/comment-current/c2',
sourcePostId: 'source', sourcePostAuthor: 'source-author',
expressedGender: 'unknown' as const, confidence: 0.91,
expressedGender: 'unknown' as const, confidence: 0.91, classifierVersion: 'recipient-role-v2' as const,
},
};
const editedComment = {
@@ -136,13 +136,14 @@ describe('CandidateQueueRepository', () => {
}, 1_011);
}
expect(queue.requeueLegacyCommentPreparations(1_020)).toBe(1);
expect(queue.rejectLegacyCommentCandidates(1_020)).toBe(2);
expect(queue.listActive()).toEqual(expect.arrayContaining([
expect.objectContaining({ postId: 'comment-legacy', status: 'discovered', prepared: null }),
expect.objectContaining({ postId: 'comment-current', status: 'ready' }),
expect.objectContaining({ postId: 'comment-edited', status: 'ready' }),
expect.objectContaining({ postId: 'post-author', status: 'ready' }),
]));
const activeIds = queue.listActive().map((candidate) => candidate.postId);
expect(activeIds).not.toContain('comment-legacy');
expect(activeIds).not.toContain('comment-edited');
});
it('admits, screens, and sends the newest posts before older higher-priority posts', () => {
+1
View File
@@ -721,6 +721,7 @@ describe('MonitorService', () => {
targetComment: {
body: "I'd love that to be done to me", sourcePostId: 'post1',
sourcePostAuthor: 'poster', expressedGender: 'female', confidence: 0.94,
classifierVersion: 'recipient-role-v2',
},
});
await monitor.fetchCandidates(config.reddit.subreddits[0]);
+2
View File
@@ -150,6 +150,7 @@ describe('OpenRouterClient', () => {
const request = mockCreate.mock.calls[0][0];
expect(request.temperature).toBe(0);
expect(request.messages[1].content).toContain('<<<UNTRUSTED COMMENT>>>');
expect(request.messages[0].content).toContain('would do to the pictured person does not qualify');
});
});
@@ -669,6 +670,7 @@ describe('OpenRouterClient', () => {
const userPrompt = mockCreate.mock.calls[0][0].messages[1].content as string;
expect(systemPrompt).toContain('The RECIPIENT is the commenter');
expect(systemPrompt).toContain('The SOURCE POST SUBJECT is a different person');
expect(systemPrompt).toContain('never reverse the recipient into the person performing the act');
expect(systemPrompt).toContain('The first sentence MUST explicitly anchor to the public comment');
expect(userPrompt).toContain('I want that too');
expect(`${systemPrompt}\n${userPrompt}`).not.toContain('Write a message for Commenter about');