From d634944df16462a8979b6f722ff9cf45457d55ea Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Fri, 13 Nov 2026 11:19:42 -0800 Subject: [PATCH] Guarantee agent-error candidates in retention fixtures Random UUID ordering could put every error agent into kept or archived retention rows, while the pagination test required an eligible candidate of every kind. Put the retained errors in deterministic positions and seed a separate unretained error after assigning retention. The controlled ordering reproduces the missing-kind failure before the eligible row is added. All ten retention-candidate tests pass afterward. Pagination, filtering, and the independent query oracle stay unchanged. Co-Authored-By: Paperclip --- .../src/__tests__/attention-retention-candidates.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/__tests__/attention-retention-candidates.test.ts b/server/src/__tests__/attention-retention-candidates.test.ts index fc2b0ffa97e..8a31e794c9c 100644 --- a/server/src/__tests__/attention-retention-candidates.test.ts +++ b/server/src/__tests__/attention-retention-candidates.test.ts @@ -61,8 +61,11 @@ function oracle(db: Db, scope: AttentionRetentionScope, cursor?: Cursor, sourceI async function seed(company: string, prefix: string, status: string, size: number) { await db.execute(sql`insert into companies (id, name, issue_prefix, status) values (${company}::uuid, ${prefix}, ${prefix}, ${status})`); - await db.execute(sql`insert into agents (company_id, name, status) - select ${company}::uuid, 'Agent ' || n, case when n % 3 = 0 then 'error' else 'idle' end from generate_series(1, 6) n`); + // Put error agents in the archived and kept retention positions. The + // unretained error added below guarantees a candidate of this kind. + await db.execute(sql`insert into agents (id, company_id, name, status) + select (left(${company}::text, 24) || lpad(n::text, 12, '0'))::uuid, + ${company}::uuid, 'Agent ' || n, case when n in (4, 6) then 'error' else 'idle' end from generate_series(1, 6) n`); // Issues: blocked, in review, hidden, harness-owned and ordinary ones. await db.execute(sql`insert into issues (company_id, title, status, hidden_at, harness_kind, updated_at) select ${company}::uuid, 'Issue ' || n, @@ -108,6 +111,8 @@ function oracle(db: Db, scope: AttentionRetentionScope, cursor?: Cursor, sourceI union all select company_id, 'decision', id::text, row_number() over (order by id) from decisions where company_id = ${company}::uuid union all select company_id, 'agent_error_alert', id::text, row_number() over (order by id) from agents where company_id = ${company}::uuid ) x where n % 2 = 0`); + await db.execute(sql`insert into agents (company_id, name, status) + values (${company}::uuid, 'Unretained error agent', 'error')`); } beforeAll(async () => {