mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-03 09:37:19 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Auto-archive writes an existing notification outbox in its archive transaction. > - The maintenance sweep polls that outbox even when it is empty. > - The committing producer can wake delivery. Saved rows and claim timestamps can restore unfinished work. > - This PR separates delivery from retention scanning and uses the existing coordinator for retries and deadlines. > - Settled delivery becomes quiet while archive and notification behavior remain intact. ## Linked Issues or Issue Description **What happened?** The retention maintenance sweep calls archive notification delivery on every tick. An empty outbox and retained delivered history still cause database work. **What did you expect?** Committed auto-archive should wake delivery. Pending work and existing claims should retain retry or expiry deadlines. Settled history should cause no recurring delivery SQL. **Steps to reproduce** Start a configured instance with an empty or fully delivered archive outbox. Leave it idle. The old maintenance tick still checks the outbox. This is slice 08 of the sleep migration. It remains stacked on projection repair #17468. Retention eligibility and scanning, decision TTL expiry and decision continuation recovery have separate owners and PRs. ## What Changed - Notify archive delivery before the existing outbox insert in the auto-archive transaction. Preserve outer transaction commit, rollback and uncertainty handling. - Register a delivery worker with the existing coordinator. Remove notification delivery from retention sweeps. - Keep claim recovery, selection, company/agent grouping and timestamp-fenced settlement in the delivery service. Keep the existing service API and payload. - Count a notified group only when it settles rows. Use one timestamp for failure reset. - Add generated concurrent migration `0387_boring_professor_monster.sql`. Its partial index matches pending order: `last_attempt_at NULLS FIRST, created_at, id`. Add no table. - Test real startup registration and prove a retention tick does not send notifications. Preserve the disabled-scheduler no-notification contract. ## Verification Current candidate: `457c70fc6acbd681fcccd90d08b6391efb202bce`, normally merged with pinned master `8161f2a813` after projection #17468 landed. All 39 independent files from that master integration are preserved exactly. Archive owner behavior and migration 0387 are unchanged. - **58 archive/startup/scoped-deadline cases pass** after master reconciliation. Server typecheck and build pass. The preceding projection-parent integration passed all **239** gateway/projection/archive/startup/deadline cases. - All 385 parent journal entries remain an exact prefix, with own migration 0387 appended; the five newest generated snapshots remain. Generated index apply, replay, schema drift and real pending-order query measurements passed in the prior owner verification. - Failure accounting: the broader local command also attempted six upstream heartbeat-session-preparation and 55 native control-plane cases. The embedded PostgreSQL runtime was unavailable: the six heartbeat cases skipped, and native setup failed before its 55 cases could execute. This is an incomplete additional local check, not a passing full run. The owning 58 cases passed with the existing external fixture where applicable. CI must exercise its supported embedded environment. - The first independent-master comparison used the shared mutable remote ref, which another worktree advanced during verification. Pinning the actual merged master SHA confirms all 39 independent files match exactly. No incoming source change was dropped. The behavior audit in `doc/idle-decision-archive-delivery.md` records earlier fixture failures, the stale-claim regression and the index probe. Local tests do not prove deployed suspension or fleet savings. Fresh current-head CI and both reviews remain required. ## Risks - Delivery remains at least once. A wake accepted before an acknowledgement is lost can be retried. - Each pass keeps the existing 500-row limit. Failed or remaining pending work retains the existing thirty-second retry. Saved delivery claims retain their five-minute deadline. - Auto-archive is the existing outbox producer. Manual archive/revive and reviewed-manifest actions do not gain notifications. - Signals use the existing single-active-writer database owner. Independent SQL or another active server needs a wake contract. - Concurrent index creation uses the existing top-level executor and invalid-index retry path. Existing SQL and migration receipts are unchanged. - Cloud sleep guards and external-wake coverage do not change. Local worker quiet is not proof of database or host suspension. ## Model Used OpenAI Codex, GPT-6 family, with reasoning and code execution. The exact serving model identifier and context window were not exposed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge The final projection efficiency parent is integrated normally. All 239 affected gateway/projection, archive, startup and scoped-deadline cases pass, with server typecheck/build. The archive owner behavior and index remain unchanged. Fresh reviews and CI are required on this parent integration. --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
356 lines
17 KiB
TypeScript
356 lines
17 KiB
TypeScript
import { sql } from "drizzle-orm";
|
|
import { resolveExternalTestDatabaseUrl } from "./helpers/external-test-database.js";
|
|
import { registerDecisionArchiveDeliveryWork } from "../services/decision-archive-delivery-work.js";
|
|
import { createDeliveryWorkCoordinator } from "../services/delivery-work-coordinator.js";
|
|
import { idleWorkSnapshot } from "../services/task-admission.js";
|
|
import { randomUUID } from "node:crypto";
|
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
activityLog,
|
|
agents,
|
|
companies,
|
|
createDb,
|
|
decisionArchiveNotificationOutbox,
|
|
decisionRetention,
|
|
issues,
|
|
} from "@paperclipai/db";
|
|
import { getEmbeddedPostgresTestSupport, startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js";
|
|
import { attentionService } from "../services/attention.js";
|
|
import { decisionRetentionService } from "../services/decision-retention.js";
|
|
|
|
const externalUrl = resolveExternalTestDatabaseUrl("PAPERCLIP_RETENTION_TEST_DATABASE_URL");
|
|
const support = externalUrl ? { supported: true } : await getEmbeddedPostgresTestSupport();
|
|
const describePg = support.supported ? describe : describe.skip;
|
|
|
|
describePg("decision retention", () => {
|
|
let tempDb: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>> | null = null;
|
|
let db: ReturnType<typeof createDb>;
|
|
|
|
let stopWorker: (() => Promise<void>) | undefined;
|
|
|
|
beforeAll(async () => {
|
|
if (!externalUrl) tempDb = await startEmbeddedPostgresTestDatabase("paperclip-decision-retention-");
|
|
db = createDb(externalUrl ?? tempDb!.connectionString, { maxConnections: 6, idleTimeoutSeconds: 0, maxLifetimeSeconds: 0 });
|
|
}, 30_000);
|
|
|
|
afterEach(async () => {
|
|
await stopWorker?.(); stopWorker = undefined;
|
|
await db.delete(decisionArchiveNotificationOutbox);
|
|
await db.delete(decisionRetention);
|
|
await db.delete(activityLog);
|
|
await db.delete(issues);
|
|
await db.delete(agents);
|
|
await db.delete(companies);
|
|
});
|
|
|
|
afterAll(async () => { await db?.$client.end({ timeout: 1 }); await tempDb?.cleanup(); });
|
|
|
|
async function seedReviewItems(count: number) {
|
|
const companyId = randomUUID();
|
|
const agentId = randomUUID();
|
|
await db.insert(companies).values({
|
|
id: companyId,
|
|
name: "Retention",
|
|
issuePrefix: `R${companyId.slice(0, 6)}`,
|
|
requireBoardApprovalForNewAgents: false,
|
|
});
|
|
await db.insert(agents).values({
|
|
id: agentId,
|
|
companyId,
|
|
name: "Origin",
|
|
role: "engineer",
|
|
status: "active",
|
|
adapterType: "codex_local",
|
|
adapterConfig: {},
|
|
runtimeConfig: {},
|
|
permissions: {},
|
|
});
|
|
const old = new Date("2026-04-01T00:00:00.000Z");
|
|
const issueIds = Array.from({ length: count }, () => randomUUID());
|
|
await db.insert(issues).values(issueIds.map((id, index) => ({
|
|
id,
|
|
companyId,
|
|
identifier: `R${companyId.slice(0, 6)}-${index + 1}`,
|
|
title: `Old review ${index + 1}`,
|
|
status: "in_review",
|
|
priority: "medium",
|
|
assigneeUserId: "board-user",
|
|
createdByAgentId: agentId,
|
|
createdAt: old,
|
|
updatedAt: old,
|
|
})));
|
|
return { companyId, agentId, issueIds };
|
|
}
|
|
|
|
const boardActor = (companyId: string) => ({
|
|
type: "board" as const,
|
|
source: "local_implicit" as const,
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
isInstanceAdmin: true,
|
|
});
|
|
const mutationActor = {
|
|
actorType: "user" as const,
|
|
actorId: "board-user",
|
|
agentId: null,
|
|
userId: "board-user",
|
|
runId: null,
|
|
agentApiKeyId: null,
|
|
responsibleUserId: "board-user",
|
|
};
|
|
|
|
describe("archive delivery worker", () => {
|
|
let coordinator: ReturnType<typeof createDeliveryWorkCoordinator> | undefined;
|
|
let fixture: Awaited<ReturnType<typeof seedReviewItems>>;
|
|
let service: ReturnType<typeof decisionRetentionService>;
|
|
let draining: boolean;
|
|
const errors: unknown[] = [];
|
|
const notify = vi.fn(async (_batch: unknown) => {});
|
|
|
|
beforeEach(async () => {
|
|
await Promise.all(Array.from({ length: 6 }, () => db.execute(sql`select pg_sleep(0.01)`)));
|
|
fixture = await seedReviewItems(1); draining = false; errors.length = 0; notify.mockReset();
|
|
service = decisionRetentionService(db, { notifyOriginAgent: notify });
|
|
stopWorker = async () => {
|
|
await coordinator?.stop(); coordinator = undefined;
|
|
vi.useRealTimers(); vi.restoreAllMocks();
|
|
await db.execute(sql`drop trigger if exists archive_delivery_fail on decision_archive_notification_outbox`);
|
|
await db.execute(sql`drop function if exists archive_delivery_fail()`);
|
|
expect(errors).toEqual([]);
|
|
};
|
|
vi.useFakeTimers({ toFake: ["Date", "setTimeout", "clearTimeout", "setInterval", "clearInterval"], shouldAdvanceTime: true });
|
|
});
|
|
async function start() {
|
|
coordinator = createDeliveryWorkCoordinator({ owner: db, canRun: () => !draining,
|
|
canReconcile: () => true, onError: error => errors.push(error) });
|
|
await registerDecisionArchiveDeliveryWork(coordinator, service, () => !draining).ready;
|
|
}
|
|
async function archive(source = db) {
|
|
const feed = await attentionService(source).list(fixture.companyId, { limit: 100 });
|
|
return decisionRetentionService(source).autoArchive({ companyId: fixture.companyId, items: feed.items });
|
|
}
|
|
async function settle(ms = 60_000) {
|
|
await vi.advanceTimersByTimeAsync(ms);
|
|
if (!draining) await vi.waitFor(() => expect(idleWorkSnapshot().active).toBe(0), { timeout: 5000 });
|
|
}
|
|
async function quiet() {
|
|
await vi.waitFor(async () => {
|
|
await vi.advanceTimersByTimeAsync(30_000);
|
|
expect(idleWorkSnapshot().active).toBe(0);
|
|
expect(coordinator!.nextWakeAt()).toBeNull();
|
|
}, { timeout: 5000 });
|
|
const reads = vi.spyOn(db, "select"), executes = vi.spyOn(db, "execute"), writes = vi.spyOn(db, "update");
|
|
await settle(60 * 60_000);
|
|
expect(reads).not.toHaveBeenCalled(); expect(executes).not.toHaveBeenCalled(); expect(writes).not.toHaveBeenCalled();
|
|
reads.mockRestore(); executes.mockRestore(); writes.mockRestore();
|
|
}
|
|
async function delivered() {
|
|
const rows = await db.select().from(decisionArchiveNotificationOutbox);
|
|
expect(rows.length).toBeGreaterThan(0); expect(rows.every(row => row.status === "delivered")).toBe(true);
|
|
}
|
|
|
|
it("is quiet with configuration, wakes from real auto-archive, and leaves delivered history quiet", async () => {
|
|
await start(); await quiet();
|
|
expect(await archive()).toBe(1); await settle(); await delivered(); await quiet();
|
|
expect(notify).toHaveBeenCalledTimes(1);
|
|
expect(notify.mock.calls[0][0]).toMatchObject({ companyId: fixture.companyId, agentId: fixture.agentId,
|
|
items: [expect.objectContaining({ issueId: fixture.issueIds[0], archiveVersion: 1 })] });
|
|
});
|
|
|
|
it("reconstructs pending delivery after restart", async () => {
|
|
await archive(); await start(); await quiet(); await delivered(); expect(notify).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("waits until an existing delivery claim expires", async () => {
|
|
await archive(); const attemptedAt = new Date();
|
|
await db.update(decisionArchiveNotificationOutbox).set({ status: "delivering", lastAttemptAt: attemptedAt, attemptCount: 1 });
|
|
await start(); expect(notify).not.toHaveBeenCalled();
|
|
expect(coordinator!.nextWakeAt()).toBe(attemptedAt.getTime() + 5 * 60_000);
|
|
const reads = vi.spyOn(db, "select"); await settle(4 * 60_000); expect(reads).not.toHaveBeenCalled(); reads.mockRestore();
|
|
await settle(2 * 60_000); await delivered(); await quiet(); expect(notify).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("recovers a legacy delivering row with no attempt timestamp", async () => {
|
|
await archive(); await db.update(decisionArchiveNotificationOutbox).set({ status: "delivering" });
|
|
await start(); await delivered(); await quiet();
|
|
});
|
|
|
|
it("retains first enqueue during drain without passive SQL", async () => {
|
|
await start(); await quiet(); draining = true;
|
|
await archive(); await settle();
|
|
const reads = vi.spyOn(db, "select"), writes = vi.spyOn(db, "update");
|
|
await settle(60 * 60_000); expect(reads).not.toHaveBeenCalled(); expect(writes).not.toHaveBeenCalled();
|
|
reads.mockRestore(); writes.mockRestore(); expect(notify).not.toHaveBeenCalled();
|
|
draining = false; await settle(); await delivered(); await quiet();
|
|
});
|
|
|
|
it("retries failed delivery through drain and then becomes quiet", async () => {
|
|
await archive(); notify.mockRejectedValueOnce(new Error("wake unavailable"));
|
|
await start(); expect(notify).toHaveBeenCalledTimes(1); expect(coordinator!.nextWakeAt()).not.toBeNull();
|
|
draining = true; await settle(60 * 60_000); expect(notify).toHaveBeenCalledTimes(1);
|
|
draining = false;
|
|
await vi.waitFor(async () => { await vi.advanceTimersByTimeAsync(30_000); await delivered(); }, { timeout: 5000 });
|
|
await quiet(); expect(notify).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it.each([false, true])("waits for the archive's outer transaction (rollback %s)", async rollback => {
|
|
await start(); await quiet();
|
|
let entered!: () => void, release!: () => void;
|
|
const ready = new Promise<void>(resolve => { entered = resolve; });
|
|
const gate = new Promise<void>(resolve => { release = resolve; });
|
|
const aborted = new Error("fixture rollback");
|
|
const running = db.transaction(async tx => {
|
|
await archive(tx as unknown as typeof db); entered(); await gate; if (rollback) throw aborted;
|
|
}).catch(error => { if (error !== aborted) throw error; });
|
|
await ready;
|
|
try { await vi.advanceTimersByTimeAsync(60_000); expect(notify).not.toHaveBeenCalled(); }
|
|
finally { release(); await running; }
|
|
await vi.waitFor(async () => {
|
|
await vi.advanceTimersByTimeAsync(30_000); expect(idleWorkSnapshot().active).toBe(0);
|
|
if (rollback) expect(await db.select().from(decisionArchiveNotificationOutbox)).toEqual([]);
|
|
else await delivered();
|
|
}, { timeout: 5000 });
|
|
await quiet(); expect(notify).toHaveBeenCalledTimes(rollback ? 0 : 1);
|
|
});
|
|
|
|
it("rolls back archive state when enqueue fails and wakes on a later successful archive", async () => {
|
|
await start(); await quiet();
|
|
await db.execute(sql`create function archive_delivery_fail() returns trigger language plpgsql as $$
|
|
begin raise exception 'archive enqueue fixture failure'; end $$`);
|
|
await db.execute(sql`create trigger archive_delivery_fail before insert on decision_archive_notification_outbox
|
|
for each row execute function archive_delivery_fail()`);
|
|
await expect(archive()).rejects.toThrow();
|
|
await db.execute(sql`drop trigger archive_delivery_fail on decision_archive_notification_outbox`);
|
|
await quiet(); expect(notify).not.toHaveBeenCalled();
|
|
expect(await db.select().from(decisionArchiveNotificationOutbox)).toEqual([]);
|
|
expect((await db.select().from(decisionRetention))[0].archivedAt).toBeNull();
|
|
await archive(); await settle(); await delivered(); await quiet();
|
|
});
|
|
|
|
it("keeps an enqueue committed during delivery and drains it on the next pass", async () => {
|
|
await start(); await quiet();
|
|
let entered!: () => void, release!: () => void;
|
|
const ready = new Promise<void>(resolve => { entered = resolve; });
|
|
const gate = new Promise<void>(resolve => { release = resolve; });
|
|
notify.mockImplementationOnce(async () => { entered(); await gate; });
|
|
await archive();
|
|
await vi.advanceTimersByTimeAsync(30_000); await ready;
|
|
try {
|
|
fixture = await seedReviewItems(1); await archive();
|
|
expect(notify).toHaveBeenCalledTimes(1);
|
|
} finally { release(); }
|
|
await vi.waitFor(async () => { await vi.advanceTimersByTimeAsync(30_000); await delivered(); }, { timeout: 5000 });
|
|
await quiet(); expect(notify).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it("does not let an older failed batch starve rows beyond the batch limit", async () => {
|
|
await archive(); const [row] = await db.select().from(decisionArchiveNotificationOutbox);
|
|
await db.insert(decisionArchiveNotificationOutbox).values(Array.from({ length: 501 }, (_, index) => ({
|
|
...row, id: randomUUID(), sourceId: `additional-${index}` })));
|
|
notify.mockRejectedValueOnce(new Error("first batch unavailable"));
|
|
await start(); expect(notify.mock.calls[0][0]).toMatchObject({ items: expect.any(Array) });
|
|
expect((notify.mock.calls[0][0] as { items: unknown[] }).items).toHaveLength(500);
|
|
await vi.waitFor(async () => { await vi.advanceTimersByTimeAsync(30_000); await delivered(); }, { timeout: 5000 });
|
|
await quiet();
|
|
expect((notify.mock.calls[1][0] as { items: unknown[] }).items).toHaveLength(500);
|
|
expect((notify.mock.calls[2][0] as { items: unknown[] }).items).toHaveLength(2);
|
|
});
|
|
|
|
it("does not settle a replacement claim from an older delivery result", async () => {
|
|
await archive();
|
|
let entered!: () => void, release!: () => void;
|
|
const ready = new Promise<void>(resolve => { entered = resolve; });
|
|
const gate = new Promise<void>(resolve => { release = resolve; });
|
|
notify.mockImplementationOnce(async () => { entered(); await gate; });
|
|
const first = service.deliverNotifications(); await ready;
|
|
const replacementAt = new Date(Date.now() + 6 * 60_000);
|
|
try { await db.update(decisionArchiveNotificationOutbox).set({ lastAttemptAt: replacementAt, attemptCount: 2 }); }
|
|
finally { release(); }
|
|
expect(await first).toEqual({ notifiedAgents: 0, delivered: 0 });
|
|
expect((await db.select().from(decisionArchiveNotificationOutbox))[0]).toMatchObject({ status: "delivering", lastAttemptAt: replacementAt });
|
|
await start(); expect(coordinator!.nextWakeAt()).toBe(replacementAt.getTime() + 5 * 60_000);
|
|
await settle(12 * 60_000); await delivered(); await quiet();
|
|
});
|
|
});
|
|
|
|
it("auto-archives, excludes by default, returns archived rows, and revives", async () => {
|
|
const { companyId, issueIds } = await seedReviewItems(1);
|
|
const now = new Date("2026-08-02T00:00:00.000Z");
|
|
const svc = decisionRetentionService(db);
|
|
const before = await attentionService(db, { now: () => now.getTime() }).list(companyId, { limit: 100 });
|
|
expect(before.items).toHaveLength(1);
|
|
|
|
expect(await svc.autoArchive({ companyId, items: before.items, now })).toBe(1);
|
|
const current = await attentionService(db, { now: () => now.getTime() }).list(companyId, { limit: 100 });
|
|
expect(current.items).toHaveLength(0);
|
|
const archived = await attentionService(db, { now: () => now.getTime() }).list(companyId, { archived: true, limit: 100 });
|
|
expect(archived.items[0]).toMatchObject({ subject: { id: issueIds[0] }, archivedAt: now.toISOString() });
|
|
|
|
await svc.revive({
|
|
companyId,
|
|
sourceKind: "review",
|
|
sourceId: issueIds[0]!,
|
|
authActor: boardActor(companyId),
|
|
actor: mutationActor,
|
|
});
|
|
const revived = await attentionService(db, { now: () => now.getTime() }).list(companyId, { limit: 100 });
|
|
expect(revived.items[0]).toMatchObject({ subject: { id: issueIds[0] }, archivedAt: null });
|
|
});
|
|
|
|
it("exempts Keep rows and batches one notification per origin agent", async () => {
|
|
const { companyId, agentId, issueIds } = await seedReviewItems(3);
|
|
const now = new Date("2026-08-02T00:00:00.000Z");
|
|
const notifications: Array<Record<string, unknown>> = [];
|
|
const svc = decisionRetentionService(db, { notifyOriginAgent: async (batch) => notifications.push(batch) });
|
|
await attentionService(db, { now: () => now.getTime() }).list(companyId, { limit: 100 });
|
|
await svc.setKeep({
|
|
companyId,
|
|
sourceKind: "review",
|
|
sourceId: issueIds[0]!,
|
|
keep: true,
|
|
authActor: boardActor(companyId),
|
|
actor: mutationActor,
|
|
});
|
|
const refreshed = await attentionService(db, { now: () => now.getTime() }).list(companyId, { limit: 100 });
|
|
expect(await svc.autoArchive({ companyId, items: refreshed.items, now })).toBe(2);
|
|
expect(await svc.deliverNotifications()).toEqual({ notifiedAgents: 1, delivered: 2 });
|
|
expect(notifications).toHaveLength(1);
|
|
expect(notifications[0]).toMatchObject({ companyId, agentId, items: expect.arrayContaining([
|
|
expect.objectContaining({ issueId: issueIds[1] }),
|
|
expect.objectContaining({ issueId: issueIds[2] }),
|
|
]) });
|
|
expect((await svc.getState(companyId, "review", issueIds[0]!))?.archivedAt).toBeNull();
|
|
});
|
|
|
|
it("fails the whole reviewed manifest when one expected version changes", async () => {
|
|
const { companyId, issueIds } = await seedReviewItems(2);
|
|
const now = Date.parse("2026-08-02T00:00:00.000Z");
|
|
const svc = decisionRetentionService(db);
|
|
const feed = await attentionService(db, { now: () => now }).list(companyId, { limit: 100 });
|
|
const manifest = feed.items.map((item) => ({
|
|
companyId,
|
|
sourceKind: item.sourceKind,
|
|
sourceId: item.subject.id,
|
|
expectedVersion: item.retentionVersion,
|
|
activityAt: item.activityAt,
|
|
reason: "Reviewed as stale",
|
|
}));
|
|
await svc.setKeep({
|
|
companyId,
|
|
sourceKind: "review",
|
|
sourceId: issueIds[0]!,
|
|
keep: true,
|
|
authActor: boardActor(companyId),
|
|
actor: mutationActor,
|
|
});
|
|
await expect(svc.archiveReviewedManifest({
|
|
companyId,
|
|
manifest,
|
|
originActor: boardActor(companyId),
|
|
decidingActor: boardActor(companyId),
|
|
decidedByUserId: "board-user",
|
|
})).rejects.toThrow("archive_proposal_stale");
|
|
expect((await db.select().from(decisionRetention)).every((row) => row.archivedAt === null)).toBe(true);
|
|
});
|
|
});
|