Skip to content

The open-source app everyone uses to manage agents at work

test(server): retire duplicate guards and share issue seed fixtures (#16059)

Dotta1d5e2c89f089
diff --git a/server/src/__tests__/heartbeat-scheduling-suppression.test.ts b/server/src/__tests__/heartbeat-scheduling-suppression.test.ts
index f0259f086b..7cd5e074bf 100644
--- a/server/src/__tests__/heartbeat-scheduling-suppression.test.ts
+++ b/server/src/__tests__/heartbeat-scheduling-suppression.test.ts
@@ -63,14 +63,6 @@ describe("heartbeat scheduling suppression", () => {
});
});
- it("suppresses heartbeat scheduling while a task drain is active", () => {
- startTaskDrain({});
- expect(resolveHeartbeatSchedulingSuppression({})).toEqual({
- suppressed: true,
- reason: "task_drain",
- });
- });
-
it("still suppresses database restore even when a task drain is active", () => {
startTaskDrain({});
expect(
diff --git a/server/src/__tests__/heartbeat-timer-wake-session-reset-pf4.test.ts b/server/src/__tests__/heartbeat-timer-wake-session-reset-pf4.test.ts
index ca419d9e0c..c71a1b8eeb 100644
--- a/server/src/__tests__/heartbeat-timer-wake-session-reset-pf4.test.ts
+++ b/server/src/__tests__/heartbeat-timer-wake-session-reset-pf4.test.ts
@@ -53,10 +53,6 @@ describe("PF-4 shouldResetTaskSessionForWake", () => {
expect(shouldResetTaskSessionForWake({ forceFreshSession: true })).toBe(true);
});
- it("does not reset for issue_commented (preserve continuation context)", () => {
- expect(shouldResetTaskSessionForWake({ wakeReason: "issue_commented" })).toBe(false);
- });
-
it("does not reset for transient_failure_retry (resume in-flight work)", () => {
expect(shouldResetTaskSessionForWake({ wakeReason: "transient_failure_retry" })).toBe(false);
});
diff --git a/server/src/__tests__/issues-service.test.ts b/server/src/__tests__/issues-service.test.ts
index 5f3f8c58ae..ec0cb82b9f 100644
--- a/server/src/__tests__/issues-service.test.ts
+++ b/server/src/__tests__/issues-service.test.ts
@@ -59,6 +59,38 @@ import { buildAgentMentionHref, buildProjectMentionHref, MAX_ISSUE_REQUEST_DEPTH
const embeddedPostgresSupport = await getEmbeddedPostgresTestSupport();
const describeEmbeddedPostgres = embeddedPostgresSupport.supported ? describe : describe.skip;
+async function seedIssueCompany(db: ReturnType<typeof createDb>, companyId: string) {
+ await db.insert(companies).values({
+ id: companyId,
+ name: "Paperclip",
+ issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
+ requireBoardApprovalForNewAgents: false,
+ });
+}
+
+async function seedWorkspaceProject(db: ReturnType<typeof createDb>, companyId: string, projectId: string) {
+ await db.insert(projects).values({
+ id: projectId,
+ companyId,
+ name: "Workspace project",
+ status: "in_progress",
+ });
+}
+
+async function seedCodexCoder(db: ReturnType<typeof createDb>, companyId: string, agentId: string) {
+ await db.insert(agents).values({
+ id: agentId,
+ companyId,
+ name: "CodexCoder",
+ role: "engineer",
+ status: "active",
+ adapterType: "codex_local",
+ adapterConfig: {},
+ runtimeConfig: {},
+ permissions: {},
+ });
+}
+
function deferred<T>() {
let resolve!: (value: T | PromiseLike<T>) => void;
let reject!: (reason?: unknown) => void;
@@ -598,12 +630,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
async function seedAssignableAgentCompany() {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
return companyId;
}
@@ -1120,12 +1147,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const agentId = randomUUID();
const otherAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values([
{
@@ -1237,24 +1259,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const companyId = randomUUID();
const agentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedCodexCoder(db, companyId, agentId);
const matchedIssueId = randomUUID();
const otherIssueId = randomUUID();
@@ -1292,12 +1299,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const assignedIssueId = randomUUID();
const unassignedIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: assigneeAgentId,
@@ -1341,12 +1343,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const assignedIssueId = randomUUID();
const otherIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values([
{
@@ -1398,12 +1395,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
it("rejects malformed assigneeAgentId filter values", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: randomUUID(),
companyId,
@@ -1423,12 +1415,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const assignedIssueId = randomUUID();
const unassignedIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: assigneeAgentId,
@@ -1470,12 +1457,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const assignedIssueId = randomUUID();
const otherIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: assigneeAgentId,
@@ -1512,12 +1494,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
it("rejects malformed assigneeAgentId filter values in count", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await expect(
svc.count(companyId, { assigneeAgentId: "not-a-uuid" }),
@@ -1527,12 +1504,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
it("applies result limits to issue search", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const exactIdentifierId = randomUUID();
const titleMatchId = randomUUID();
@@ -1580,12 +1552,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const otherDocumentId = randomUUID();
const planDocumentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -1648,12 +1615,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const oldCriticalIssueId = randomUUID();
const recentMediumIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -1688,12 +1650,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const commentMatchId = randomUUID();
const descriptionMatchId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -1735,12 +1692,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const grandchildId = randomUUID();
const siblingId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -1787,12 +1739,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const grandchildId = randomUUID();
const outsideMatchId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -1876,19 +1823,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const otherLinkedIssueId = randomUUID();
const unlinkedIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(executionWorkspaces).values([
{
@@ -1956,19 +1893,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const projectLinkedIssueId = randomUUID();
const otherIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -2039,12 +1966,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const typedOperationIssueId = randomUUID();
const legacyContentMachineOperationIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: agentId,
companyId,
@@ -2160,12 +2082,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const normalIssueId = randomUUID();
const operationIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
id: normalIssueId,
@@ -2210,12 +2127,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const inProgressIssueId = randomUUID();
const doneIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
id: todoIssueId,
@@ -2253,12 +2165,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const userId = "user-1";
const otherUserId = "user-2";
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const visibleIssueId = randomUUID();
const archivedIssueId = randomUUID();
@@ -2339,12 +2246,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const otherUserId = "user-2";
const agentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: agentId,
@@ -2523,12 +2425,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const commentIssueId = randomUUID();
const activityIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -2611,12 +2508,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const anchorCommentId = randomUUID();
const latestCommentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -2669,12 +2561,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const anchorCommentId = randomUUID();
const latestCommentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -2725,12 +2612,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const commentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -2764,24 +2646,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const commentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(issues).values({
id: issueId,
@@ -2826,24 +2693,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const commentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(issues).values({
id: issueId,
@@ -2892,12 +2744,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const blockedId = randomUUID();
const unblockedId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
@@ -2954,12 +2801,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const longDescription = "x".repeat(5_000);
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -2988,12 +2830,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const description = "x".repeat(1200);
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -3014,12 +2851,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const companyId = randomUUID();
const issueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -3041,12 +2873,7 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
const issueId = randomUUID();
const description = `${"x".repeat(1199)}— still valid after truncation`;
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values({
id: issueId,
@@ -3226,20 +3053,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -3300,12 +3117,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const agentId = randomUUID();
const runId = randomUUID();
const responsibleUserId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: agentId,
companyId,
@@ -3465,12 +3277,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const companyId = randomUUID();
const creatorUserId = randomUUID();
const requestedResponsibleUserId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const untrusted = await svc.create(companyId, {
title: "Untrusted explicit responsible user",
@@ -3492,12 +3299,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const companyId = randomUUID();
const actorResponsibleUserId = randomUUID();
const requestedResponsibleUserId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const issue = await svc.create(companyId, {
title: "Actor-context responsible user",
@@ -3515,12 +3317,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const assigneeEnvironmentId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(environments).values([
@@ -3589,12 +3386,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const assigneeEnvironmentId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(environments).values([
@@ -3671,12 +3463,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const firstAgentId = randomUUID();
const secondAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(environments).values([
@@ -3778,12 +3565,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const firstAgentId = randomUUID();
const secondAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(environments).values([
@@ -3854,20 +3636,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const explicitProjectWorkspaceId = randomUUID();
const explicitExecutionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values([
{
@@ -3951,20 +3723,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -4023,12 +3785,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(goals).values({
@@ -4120,20 +3877,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const environmentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -4193,12 +3940,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const parentProjectWorkspaceId = randomUUID();
const targetProjectWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(projects).values([
@@ -4256,12 +3998,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const goalId = randomUUID();
const parentIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: false });
await db.insert(goals).values({
@@ -4342,12 +4079,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
const dependentId = randomUUID();
const foreignIssueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: assigneeAgentId,
companyId,
@@ -4435,12 +4167,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
const companyId = randomUUID();
const issueId = randomUUID();
const blockerId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(issues).values([
{
id: issueId,
@@ -4495,12 +4222,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("persists blocked-by relations and exposes both blockedBy and blocks summaries", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const blockerId = randomUUID();
const blockedId = randomUUID();
@@ -4534,12 +4256,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("returns blocked-by summaries on newly created issues", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const blockerId = randomUUID();
await db.insert(issues).values({
@@ -4568,12 +4285,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("returns blocked-by summaries on newly created child issues", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const parentId = randomUUID();
const blockerId = randomUUID();
@@ -4608,12 +4320,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("returns blocks summaries when child creation blocks the parent", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const parentId = randomUUID();
await db.insert(issues).values({
@@ -4642,12 +4349,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("adds terminal blockers to immediate blocked-by summaries", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const issueA = randomUUID();
const issueB = randomUUID();
@@ -4685,12 +4387,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("rejects blocking cycles", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const issueA = randomUUID();
const issueB = randomUUID();
@@ -4709,23 +4406,8 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("only returns dependents once every blocker is done", async () => {
const companyId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: assigneeAgentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, assigneeAgentId);
const blockerA = randomUUID();
const blockerB = randomUUID();
@@ -4933,12 +4615,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
const companyId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: assigneeAgentId,
companyId,
@@ -4979,12 +4656,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("reports dependency readiness for blocked issue chains", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const blockerId = randomUUID();
const blockedId = randomUUID();
@@ -5017,12 +4689,7 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("unblocks a source issue when a liveness escalation recovery issue is marked done", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const sourceIssueId = randomUUID();
const recoveryIssueId = randomUUID();
@@ -5064,23 +4731,8 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("rejects execution when unresolved blockers remain", async () => {
const companyId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: assigneeAgentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, assigneeAgentId);
const blockerId = randomUUID();
const blockedId = randomUUID();
@@ -5120,23 +4772,8 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
it("wakes parents only when all direct children are terminal", async () => {
const companyId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: assigneeAgentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, assigneeAgentId);
const parentId = randomUUID();
const childA = randomUUID();
@@ -5230,20 +4867,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -5300,12 +4927,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const targetProjectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(projects).values([
@@ -5370,12 +4992,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
it("rejects explicitly pinned isolated git worktrees without a project or reusable workspace", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await expect(svc.create(companyId, {
@@ -5399,12 +5016,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
it("does not reject ambiguous inherited git-worktree settings before dispatch", async () => {
const companyId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
const issue = await svc.create(companyId, {
@@ -5430,20 +5042,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const executionWorkspaceId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -5500,20 +5102,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const projectWorkspaceId = randomUUID();
const issueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -5543,12 +5135,7 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const companyId = randomUUID();
const agentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
await db.insert(agents).values({
id: agentId,
@@ -5591,20 +5178,10 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
const executionWorkspaceId = randomUUID();
const issueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true });
- await db.insert(projects).values({
- id: projectId,
- companyId,
- name: "Workspace project",
- status: "in_progress",
- });
+ await seedWorkspaceProject(db, companyId, projectId);
await db.insert(projectWorkspaces).values({
id: projectWorkspaceId,
@@ -5725,12 +5302,7 @@ describeEmbeddedPostgres("issueService.findMentionedProjectIds", () => {
const titleProjectId = randomUUID();
const commentProjectId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(projects).values([
{
@@ -5776,12 +5348,7 @@ describeEmbeddedPostgres("issueService.findMentionedProjectIds", () => {
const secondProjectId = randomUUID();
const thirdProjectId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(projects).values([
{ id: firstProjectId, companyId, name: "First project", status: "in_progress" },
@@ -5895,23 +5462,8 @@ describeEmbeddedPostgres("issueService.clearExecutionRunIfTerminal", () => {
const issueId = randomUUID();
const runId = status ? randomUUID() : null;
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, agentId);
if (runId) {
await db.insert(heartbeatRuns).values({
id: runId,
@@ -5996,23 +5548,8 @@ describeEmbeddedPostgres("issueService.clearExecutionRunIfTerminal", () => {
const failedRunId = randomUUID();
const runningRunId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(heartbeatRuns).values([
{
id: failedRunId,
@@ -6070,23 +5607,8 @@ describeEmbeddedPostgres("issueService.clearExecutionRunIfTerminal", () => {
const releasingRunId = randomUUID();
const successorRunId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(heartbeatRuns).values([
{
id: failedRunId,
@@ -6166,23 +5688,8 @@ describeEmbeddedPostgres("issueService.clearExecutionRunIfTerminal", () => {
const failedRunId = randomUUID();
const successorRunId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(heartbeatRuns).values([
{
id: failedRunId,
@@ -6248,23 +5755,8 @@ describeEmbeddedPostgres("issueService.clearExecutionRunIfTerminal", () => {
const queuedExecutionRunId = randomUUID();
const successorRunId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
- await db.insert(agents).values({
- id: agentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedIssueCompany(db, companyId);
+ await seedCodexCoder(db, companyId, agentId);
await db.insert(heartbeatRuns).values([
{
id: failedCheckoutRunId,
@@ -6369,24 +5861,9 @@ describeEmbeddedPostgres("accepted plan decomposition", () => {
const goalId = randomUUID();
const assigneeAgentId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: false });
- await db.insert(agents).values({
- id: assigneeAgentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedCodexCoder(db, companyId, assigneeAgentId);
await db.insert(goals).values({
id: goalId,
companyId,
@@ -6415,24 +5892,9 @@ describeEmbeddedPostgres("accepted plan decomposition", () => {
const acceptedInteractionId = randomUUID();
if (!args?.companyId || !args?.goalId || !args?.assigneeAgentId) {
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: false });
- await db.insert(agents).values({
- id: assigneeAgentId,
- companyId,
- name: "CodexCoder",
- role: "engineer",
- status: "active",
- adapterType: "codex_local",
- adapterConfig: {},
- runtimeConfig: {},
- permissions: {},
- });
+ await seedCodexCoder(db, companyId, assigneeAgentId);
await db.insert(goals).values({
id: goalId,
companyId,
@@ -7072,12 +6534,7 @@ describeEmbeddedPostgres("issueService.assertCheckoutOwner stale checkout adopti
const issueId = randomUUID();
const actorRunStatus = params.actorRunStatus ?? "running";
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
const agentRows = [
{
id: assigneeAgentId,
@@ -7336,12 +6793,7 @@ describeEmbeddedPostgres("issueService.addComment createdByRunId", () => {
agentId = randomUUID();
issueId = randomUUID();
- await db.insert(companies).values({
- id: companyId,
- name: "Paperclip",
- issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
- requireBoardApprovalForNewAgents: false,
- });
+ await seedIssueCompany(db, companyId);
await db.insert(agents).values({
id: agentId,
companyId,
diff --git a/server/src/services/setup-token-session.test.ts b/server/src/services/setup-token-session.test.ts
index 9b85419fb1..6e579b1945 100644
--- a/server/src/services/setup-token-session.test.ts
+++ b/server/src/services/setup-token-session.test.ts
@@ -1230,30 +1230,6 @@ describe("confidential transport guard (SR-6, SR-7)", () => {
expect(assessment.proxyForwardingEnabled).toBe(true);
expect(assessment.reason).toBe("edge_tls_termination_declared");
});
-
- it("denies a direct non-loopback HTTP receive-token request, so it delivers no token (SR-6)", () => {
- // The route calls this guard before receive-token. A denied decision makes
- // the route return the fixed no-secret error and never read the token.
- const decision = evaluateConfidentialTransport(authenticatedNoProxy, {
- socketEncrypted: false,
- remoteAddress: "203.0.113.7",
- forwardedProto: undefined,
- });
- expect(decision.allowed).toBe(false);
- });
-
- it("denies a spoofed forwarded HTTPS receive-token request under a broad proxy setting (SR-7)", () => {
- // A broad `TRUST_PROXY=true` setting never populates the dedicated allowlist,
- // so the guard reads an empty allowlist and fails closed on the forwarded
- // protocol. The route returns the fixed no-secret error and delivers no
- // token.
- const decision = evaluateConfidentialTransport(authenticatedNoProxy, {
- socketEncrypted: false,
- remoteAddress: "203.0.113.7",
- forwardedProto: "https",
- });
- expect(decision.allowed).toBe(false);
- });
});
describe("SetupTokenSessionService durable state scope", () => {