mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-24 18:19:05 +02:00
Give tasks durable company-scoped workspace bindings independent of project assignment, channel defaults and authorized repository preparation. Reuse verified input seeds and sparse output recovery while preserving trust, privacy and controller provisioning boundaries.
Full CI and E2E, Superagent, legacy checks and Greptile Apex 5/5 passed on reviewed head 753680b61c. All review findings are resolved; the PR records focused verification and historical acceptance limits.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
import {
|
|
type AnyPgColumn,
|
|
index,
|
|
jsonb,
|
|
pgTable,
|
|
text,
|
|
timestamp,
|
|
uuid,
|
|
} from "drizzle-orm/pg-core";
|
|
import { companies } from "./companies.js";
|
|
import { issues } from "./issues.js";
|
|
import { projectWorkspaces } from "./project_workspaces.js";
|
|
import { projects } from "./projects.js";
|
|
|
|
export const executionWorkspaces = pgTable(
|
|
"execution_workspaces",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
companyId: uuid("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
|
|
projectId: uuid("project_id").references(() => projects.id, { onDelete: "restrict" }),
|
|
projectWorkspaceId: uuid("project_workspace_id").references(() => projectWorkspaces.id, { onDelete: "set null" }),
|
|
sourceIssueId: uuid("source_issue_id").references((): AnyPgColumn => issues.id, { onDelete: "set null" }),
|
|
mode: text("mode").notNull(),
|
|
strategyType: text("strategy_type").notNull(),
|
|
name: text("name").notNull(),
|
|
status: text("status").notNull().default("active"),
|
|
cwd: text("cwd"),
|
|
repoUrl: text("repo_url"),
|
|
baseRef: text("base_ref"),
|
|
branchName: text("branch_name"),
|
|
providerType: text("provider_type").notNull().default("local_fs"),
|
|
providerRef: text("provider_ref"),
|
|
derivedFromExecutionWorkspaceId: uuid("derived_from_execution_workspace_id")
|
|
.references((): AnyPgColumn => executionWorkspaces.id, { onDelete: "set null" }),
|
|
lastUsedAt: timestamp("last_used_at", { withTimezone: true }).notNull().defaultNow(),
|
|
openedAt: timestamp("opened_at", { withTimezone: true }).notNull().defaultNow(),
|
|
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
cleanupEligibleAt: timestamp("cleanup_eligible_at", { withTimezone: true }),
|
|
cleanupReason: text("cleanup_reason"),
|
|
metadata: jsonb("metadata").$type<Record<string, unknown>>(),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
},
|
|
(table) => ({
|
|
companyProjectStatusIdx: index("execution_workspaces_company_project_status_idx").on(
|
|
table.companyId,
|
|
table.projectId,
|
|
table.status,
|
|
),
|
|
companyProjectWorkspaceStatusIdx: index("execution_workspaces_company_project_workspace_status_idx").on(
|
|
table.companyId,
|
|
table.projectWorkspaceId,
|
|
table.status,
|
|
),
|
|
companySourceIssueIdx: index("execution_workspaces_company_source_issue_idx").on(
|
|
table.companyId,
|
|
table.sourceIssueId,
|
|
),
|
|
companyLastUsedIdx: index("execution_workspaces_company_last_used_idx").on(
|
|
table.companyId,
|
|
table.lastUsedAt,
|
|
),
|
|
companyBranchIdx: index("execution_workspaces_company_branch_idx").on(
|
|
table.companyId,
|
|
table.branchName,
|
|
),
|
|
}),
|
|
);
|