From 1fb8ddb740f0914e98b8ca0dda7317a4d0132cf3 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 3 Dec 2026 15:41:55 -0600 Subject: [PATCH 001/119] feat(trust): allow transient workspace_prepare checkout for low-trust in-boundary projects (#23656) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The low-trust review preset isolates untrusted review agents inside sandboxes with no runtime GitHub tokens and no sandbox network access > - When a low-trust agent is explicitly assigned to a private-repository project with `git.read` enabled, workspace preparation routed the setup-time clone through `resolveGitHubOperationCredentials`, which blocks all low-trust credential export and caused `stage=clone git=auth_failed exit=128` before the agent could start > - Setup-time `prepareRemoteWorkspaceDirectory` runs on the trusted controller path before the agent starts, uses transient `GIT_CONFIG_*` / `PAPERCLIP_GIT_TOKEN` environment variables with `-c core.hooksPath=/dev/null`, and writes zero credentials into `.git/config` > - This pull request adds `resolveGitHubWorkspacePrepareCredentials` for controller-only `workspace_prepare` call sites, allowing transient clone credentials strictly for a repository configured on a project inside `trustBoundary.projectIds` when `git.read` is permitted (preferring an agent-installed GitHub PAT connection when present), while keeping runtime shell credentials (`resolveGitHubOperationCredentials`) strictly denied > - The benefit is that assigning a low-trust agent to a private-repo project works out of the box for local read-only code review without exposing any live GitHub token to the agent runtime ## Linked Issues or Issue Description **What happened?** When an agent configured with `trustPreset: "low_trust_review"` and `allowedToolClasses: ["git.read"]` was assigned a task in a project with a private GitHub repository workspace, workspace preparation failed before the agent started with `remote_workspace_prepare_failed: stage=clone git=auth_failed exit=128 program=git`. **Expected behavior** When a `low_trust_review` run has `git.read` enabled and targets a project explicitly listed in `trustBoundary.projectIds`, the trusted controller should clone that project's configured repository during `workspace_prepare` using transient credentials (preferring an agent-installed GitHub PAT connection if configured, otherwise the run's managed GitHub identity), while leaving zero credentials in `.git/config` and keeping runtime GitHub credential export strictly denied. **Steps to reproduce** 1. Create a project with a private GitHub repository workspace. 2. Configure an agent with `trustPreset: "low_trust_review"`, `projectIds: [projectId]`, and `allowedToolClasses: ["git.read"]`. 3. Run a task in that project on a cloud sandbox environment. 4. Before this fix, `createGitRemoteAuthProvider` falls back to anonymous clone and fails at `stage=clone git=auth_failed exit=128`. **Paperclip version or commit** `master` (`23ca89e376`) ## What Changed - **`server/src/services/github-operation-credentials.ts`**: Added `resolveGitHubWorkspacePrepareCredentials`, `allowsLowTrustWorkspacePrepareCheckout`, and `resolveAgentInstalledGitHubPat`. For `low_trust_review` runs, transient prepare-time clone auth is permitted only when `trust.kind === "low_trust_review"`, `git.read` is in `allowedToolClasses`, the task's project is explicitly in `trustBoundary.projectIds`, and `remoteUrl` matches a configured `project_workspaces.repo_url` on that project. Prefers an active agent-installed GitHub `api_key` (PAT) connection when present and otherwise falls back to `resolveManagedGitHubCredential`. Runtime `resolveGitHubOperationCredentials` remains unchanged and strictly denied for low-trust runs. - **`server/src/services/git-credentials.ts`**: Added optional `purpose?: "workspace_prepare"` to `createGitRemoteAuthProvider` so only controller workspace-preparation call sites invoke `resolveGitHubWorkspacePrepareCredentials`. - **`server/src/services/heartbeat/workspace-preparation.ts`** and **`server/src/services/heartbeat/workspaces.ts`**: Passed `purpose: "workspace_prepare"` at the four controller workspace-preparation call sites. - **`server/src/__tests__/github-operation-credentials.test.ts`**: Added unit, security-boundary, and end-to-end `prepareRemoteWorkspaceDirectory` tests covering managed identity prepare checkout, agent-installed GitHub PAT preference, runtime credential denial, unrelated repo denial, missing `git.read` denial, and zero credentials persisted in `.git/config`. ## Verification - `pnpm --filter @paperclipai/server typecheck` — passed with 0 errors. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/github-operation-credentials.test.ts` — 30/30 passed (including the 3 new low-trust `workspace_prepare` and local E2E `prepareRemoteWorkspaceDirectory` tests). ## Risks - Low risk. Runtime agent credential endpoints (`/runtime-tools/github/credentials`, native GitHub broker, skill-source fetch) continue calling `resolveGitHubOperationCredentials` and stay strictly denied for `low_trust_review`. - Prepare-time credentials are scoped strictly to repositories already configured in `project_workspaces` for a project explicitly inside `trustBoundary.projectIds` and only when `git.read` is enabled. ## Model Used - Google Gemini (Antigravity agentic coding assistant) with tool use and local code/test execution. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --- ...thub-workspace-prepare-credentials.test.ts | 750 ++++++++++++++++++ server/src/services/authorization.ts | 6 +- server/src/services/git-credentials.ts | 22 +- .../services/github-operation-credentials.ts | 554 ++++++++++++- .../heartbeat/workspace-preparation.ts | 1 + server/src/services/heartbeat/workspaces.ts | 3 + 6 files changed, 1303 insertions(+), 33 deletions(-) create mode 100644 server/src/__tests__/github-workspace-prepare-credentials.test.ts diff --git a/server/src/__tests__/github-workspace-prepare-credentials.test.ts b/server/src/__tests__/github-workspace-prepare-credentials.test.ts new file mode 100644 index 00000000000..2a68e572d1f --- /dev/null +++ b/server/src/__tests__/github-workspace-prepare-credentials.test.ts @@ -0,0 +1,750 @@ +import { execFile, execFileSync } from "node:child_process"; +import { randomUUID } from "node:crypto"; +import { mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import { promisify } from "node:util"; +import { eq } from "drizzle-orm"; +import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; +import { + agents, + companies, + companyMemberships, + connectionGrantMembers, + connectionGrants, + createDb, + heartbeatRuns, + issues, + principalPermissionGrants, + projects, + projectWorkspaces, + toolApplications, + toolConnectionInstalls, + toolConnections, +} from "@paperclipai/db"; +import { LOW_TRUST_REVIEW_PRESET } from "@paperclipai/shared"; +import { resolveExternalTestDatabaseUrl } from "./helpers/external-test-database.js"; +import { + getEmbeddedPostgresTestSupport, + startEmbeddedPostgresTestDatabase, +} from "./helpers/embedded-postgres.js"; +import { authorizationService } from "../services/authorization.js"; +import { writeConnectionCredential } from "../services/connection-credentials.js"; +import { createGitRemoteAuthProvider } from "../services/git-credentials.js"; +import { + resolveGitHubOperationCredentials, + resolveGitHubWorkspacePrepareCredentials, +} from "../services/github-operation-credentials.js"; +import { prepareRemoteWorkspaceDirectory } from "../services/remote-workspace-transport.js"; +import { initializeRunIdentity } from "../services/run-identity.js"; +import { secretService } from "../services/secrets.js"; + +const execFileAsync = promisify(execFile); +const external = resolveExternalTestDatabaseUrl( + "PAPERCLIP_GITHUB_WORKSPACE_PREPARE_TEST_DATABASE_URL", +); +const support = external + ? { supported: true } + : await getEmbeddedPostgresTestSupport(); + +(support.supported ? describe : describe.skip)( + "low-trust workspace_prepare GitHub credential resolution", + () => { + let database: + | Awaited> + | undefined; + let db: ReturnType; + + beforeAll(async () => { + vi.stubEnv("PAPERCLIP_AGENT_JWT_SECRET", "test-workspace-prepare-signing-secret"); + if (!external) { + database = await startEmbeddedPostgresTestDatabase( + "paperclip-github-ws-prepare-", + ); + } + db = createDb(external ?? database!.connectionString); + }, 30_000); + + afterAll(async () => { + await db?.$client.end({ timeout: 1 }); + await database?.cleanup(); + vi.unstubAllEnvs(); + }, 60_000); + + async function seedLowTrustFixture(opts?: { + repoUrl?: string; + extraProjects?: Array<{ repoUrl: string; inBoundary: boolean }>; + allowedToolClasses?: string[]; + quarantined?: boolean; + responsibleUserId?: string; + cause?: "instruction" | "company_default"; + }) { + const companyId = randomUUID(); + const agentId = randomUUID(); + const runId = randomUUID(); + const issueId = randomUUID(); + const responsibleUserId = opts?.responsibleUserId ?? "user-owner"; + + await db.insert(companies).values({ + id: companyId, + name: companyId, + issuePrefix: companyId.slice(0, 8), + }); + await db.insert(companyMemberships).values({ + companyId, + principalType: "user", + principalId: responsibleUserId, + status: "active", + membershipRole: "member", + }); + const [project] = await db + .insert(projects) + .values({ + companyId, + name: "Scoped Private Project", + status: "in_progress", + }) + .returning(); + const repoUrl = opts?.repoUrl ?? "https://github.com/acme/private-repo"; + await db.insert(projectWorkspaces).values({ + companyId, + projectId: project!.id, + name: "acme/private-repo", + sourceType: "git_repo", + repoUrl, + isPrimary: true, + }); + + const boundaryProjectIds = [project!.id]; + const extraProjectIds: string[] = []; + for (const extra of opts?.extraProjects ?? []) { + const [extraProject] = await db + .insert(projects) + .values({ + companyId, + name: `Extra Project ${extraProjectIds.length + 1}`, + status: "in_progress", + }) + .returning(); + await db.insert(projectWorkspaces).values({ + companyId, + projectId: extraProject!.id, + name: `extra-repo-${extraProjectIds.length + 1}`, + sourceType: "git_repo", + repoUrl: extra.repoUrl, + isPrimary: true, + }); + extraProjectIds.push(extraProject!.id); + if (extra.inBoundary) boundaryProjectIds.push(extraProject!.id); + } + + const lowTrustBoundary = { + mode: LOW_TRUST_REVIEW_PRESET, + companyId, + projectIds: boundaryProjectIds, + allowedToolClasses: opts?.allowedToolClasses ?? ["git.read"], + }; + await db.insert(agents).values({ + id: agentId, + companyId, + name: "Low-Trust Reviewer", + role: "engineer", + adapterType: "codex_local", + permissions: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: lowTrustBoundary, + }, + }, + }); + await db.insert(issues).values({ + id: issueId, + companyId, + projectId: project!.id, + title: "Review private repo", + ...(opts?.quarantined + ? { + sourceTrust: { + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined" as const, + }, + } + : {}), + }); + await db.insert(heartbeatRuns).values({ + id: runId, + companyId, + agentId, + status: "running", + contextSnapshot: { issueId }, + }); + await initializeRunIdentity(db, { + companyId, + runId, + responsibleUserId: opts?.cause === "company_default" ? null : responsibleUserId, + cause: opts?.cause ?? "instruction", + }); + return { + companyId, + agentId, + runId, + issueId, + projectId: project!.id, + extraProjectIds, + repoUrl, + responsibleUserId, + }; + } + + async function addManagedOAuthGrant( + fixture: Awaited>, + tokenValue: string, + ) { + const applicationId = randomUUID(); + const connectionId = randomUUID(); + const grantId = randomUUID(); + await db.insert(toolApplications).values({ + id: applicationId, + companyId: fixture.companyId, + name: `github-oauth-${applicationId}`, + type: "mcp_http", + }); + const stored = await writeConnectionCredential(db, { + companyId: fixture.companyId, + connectionName: `github-oauth-${connectionId}`, + configPath: "oauth.access_token", + label: "GitHub OAuth token", + value: tokenValue, + ownerUserId: fixture.responsibleUserId, + }); + await db.insert(toolConnections).values({ + id: connectionId, + companyId: fixture.companyId, + applicationId, + name: `github-oauth-${connectionId}`, + uid: `github-oauth-${connectionId}`, + transport: "mcp_remote", + authKind: "oauth", + status: "active", + enabled: true, + credentialPolicy: "per_user", + config: { sourceTemplateKey: "github" }, + }); + await db.insert(toolConnectionInstalls).values({ + companyId: fixture.companyId, + connectionId, + targetType: "agent", + targetId: fixture.agentId, + }); + await db.insert(connectionGrants).values({ + id: grantId, + companyId: fixture.companyId, + connectionId, + kind: "user", + subjectUserId: fixture.responsibleUserId, + status: "active", + credentialSecretRefs: [ + { + configPath: "oauth.access_token", + secretId: stored.secret.id, + versionSelector: "latest", + }, + ], + providerTenant: { + github: { + userId: `gh-${fixture.responsibleUserId}`, + login: "owner-login", + installationCount: 1, + repositoryCount: 2, + repositorySelection: "selected" as const, + installationIds: ["1"], + installationOwnerLogins: ["owner-login"], + }, + oauth: { + accessTokenExpiresAt: "2099-01-01T00:00:00.000Z", + refreshedAt: "2099-01-01T00:00:00.000Z", + }, + }, + }); + return { connectionId, grantId }; + } + + async function addGitHubPatConnection( + fixture: Awaited>, + opts: { + kind: "agent" | "user" | "organization"; + tokenValue: string; + grantStatus?: "active" | "revoked"; + }, + ) { + const applicationId = randomUUID(); + const connectionId = randomUUID(); + const grantId = randomUUID(); + const isPersonal = opts.kind === "user"; + const isOrg = opts.kind === "organization"; + await db.insert(toolApplications).values({ + id: applicationId, + companyId: fixture.companyId, + name: `github-pat-${applicationId}`, + type: "mcp_http", + }); + const stored = await writeConnectionCredential(db, { + companyId: fixture.companyId, + connectionName: `github-pat-${connectionId}`, + configPath: "credentials.authorization", + label: "GitHub PAT", + value: `Bearer ${opts.tokenValue}`, + ...(isPersonal ? { ownerUserId: fixture.responsibleUserId } : {}), + }); + await db.insert(toolConnections).values({ + id: connectionId, + companyId: fixture.companyId, + applicationId, + name: `github-pat-${connectionId}`, + uid: `github-pat-${connectionId}`, + transport: "mcp_remote", + authKind: "api_key", + status: "active", + enabled: true, + credentialPolicy: isPersonal ? "per_user" : isOrg ? "shared" : "per_agent", + config: { sourceTemplateKey: "github" }, + credentialRefs: [ + { + name: "authorization", + placement: "header", + key: "Authorization", + secretId: stored.secret.id, + version: "latest", + }, + ], + }); + await db.insert(toolConnectionInstalls).values({ + companyId: fixture.companyId, + connectionId, + targetType: "agent", + targetId: fixture.agentId, + }); + await db.insert(connectionGrants).values({ + id: grantId, + companyId: fixture.companyId, + connectionId, + kind: opts.kind, + ...(isPersonal + ? { subjectUserId: fixture.responsibleUserId } + : isOrg + ? { isDefault: true } + : { subjectAgentId: fixture.agentId }), + status: opts.grantStatus ?? "active", + credentialSecretRefs: [ + { + configPath: "credentials.authorization", + secretId: stored.secret.id, + versionSelector: "latest", + }, + ], + }); + return { connectionId, grantId }; + } + + it("grants transient workspace_prepare credentials for an in-boundary project repo while keeping runtime credentials denied", async () => { + const fixture = await seedLowTrustFixture(); + await addManagedOAuthGrant(fixture, "gho_managed_oauth_token"); + + const runtimeCreds = await resolveGitHubOperationCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + }); + expect(runtimeCreds.status).toBe("unavailable"); + expect(runtimeCreds.env).toEqual({}); + + const prepareCreds = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: `${fixture.repoUrl}.git`, + }); + expect(prepareCreds.status).toBe("available"); + expect(prepareCreds.env.PAPERCLIP_GIT_TOKEN).toBe("gho_managed_oauth_token"); + + const prepareProvider = createGitRemoteAuthProvider(db, fixture.companyId, { + agentId: fixture.agentId, + heartbeatRunId: fixture.runId, + issueId: fixture.issueId, + purpose: "workspace_prepare", + }); + const invocation = await prepareProvider(`${fixture.repoUrl}.git`); + expect(invocation?.env.PAPERCLIP_GIT_TOKEN).toBe("gho_managed_oauth_token"); + + const deniedOutOfBoundary = await prepareProvider( + "https://github.com/acme/other-private-repo.git", + ); + expect(deniedOutOfBoundary?.env.PAPERCLIP_GIT_TOKEN).toBe(""); + }); + + it("supports SSH and scp-style GitHub remotes for in-boundary project workspaces", async () => { + const fixture = await seedLowTrustFixture({ + repoUrl: "ssh://git@github.com/acme/ssh-private-repo.git", + }); + await addManagedOAuthGrant(fixture, "gho_ssh_repo_token"); + + const scpResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: "git@github.com:acme/ssh-private-repo.git", + }); + expect(scpResult.status).toBe("available"); + expect(scpResult.env.PAPERCLIP_GIT_TOKEN).toBe("gho_ssh_repo_token"); + + const sshProvider = createGitRemoteAuthProvider(db, fixture.companyId, { + agentId: fixture.agentId, + heartbeatRunId: fixture.runId, + issueId: fixture.issueId, + purpose: "workspace_prepare", + }); + const sshInvocation = await sshProvider( + "ssh://git@github.com/acme/ssh-private-repo.git", + ); + expect(sshInvocation?.env.PAPERCLIP_GIT_TOKEN).toBe("gho_ssh_repo_token"); + }); + + it("allows repos from any project inside trustBoundary.projectIds while denying out-of-boundary projects", async () => { + const fixture = await seedLowTrustFixture({ + extraProjects: [ + { repoUrl: "https://github.com/acme/second-in-boundary", inBoundary: true }, + { repoUrl: "https://github.com/acme/out-of-boundary", inBoundary: false }, + ], + }); + await addManagedOAuthGrant(fixture, "gho_multi_project_token"); + + const allowedSecond = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: "https://github.com/acme/second-in-boundary.git", + }); + expect(allowedSecond.status).toBe("available"); + expect(allowedSecond.env.PAPERCLIP_GIT_TOKEN).toBe("gho_multi_project_token"); + + const deniedOutside = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: "https://github.com/acme/out-of-boundary.git", + }); + expect(deniedOutside.status).toBe("unavailable"); + expect(deniedOutside.env).toEqual({}); + }); + + it("denies workspace_prepare credentials when git.read is not permitted or issue is quarantined", async () => { + const noGitRead = await seedLowTrustFixture({ allowedToolClasses: [] }); + await addManagedOAuthGrant(noGitRead, "gho_no_git_read"); + const noGitReadResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: noGitRead.companyId, + agentId: noGitRead.agentId, + runId: noGitRead.runId, + remoteUrl: noGitRead.repoUrl, + }); + expect(noGitReadResult.status).toBe("unavailable"); + expect(noGitReadResult.env).toEqual({}); + + const quarantined = await seedLowTrustFixture({ quarantined: true }); + await addManagedOAuthGrant(quarantined, "gho_quarantined"); + const quarantinedResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: quarantined.companyId, + agentId: quarantined.agentId, + runId: quarantined.runId, + remoteUrl: quarantined.repoUrl, + }); + expect(quarantinedResult.status).toBe("unavailable"); + expect(quarantinedResult.env).toEqual({}); + }); + + it("prefers an active dedicated agent PAT grant and rejects revoked PAT grants", async () => { + const fixture = await seedLowTrustFixture(); + const pat = await addGitHubPatConnection(fixture, { + kind: "agent", + tokenValue: "github_pat_dedicated_active_123", + }); + + const activeResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: fixture.repoUrl, + }); + expect(activeResult.status).toBe("available"); + expect(activeResult.source).toBe("dedicated"); + expect(activeResult.grantId).toBe(pat.grantId); + expect(activeResult.env.PAPERCLIP_GIT_TOKEN).toBe("github_pat_dedicated_active_123"); + + // Revoking the grant immediately blocks checkout even while the connection and install remain active. + await db + .update(connectionGrants) + .set({ status: "revoked" }) + .where(eq(connectionGrants.id, pat.grantId)); + + const revokedResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: fixture.repoUrl, + }); + expect(revokedResult.status).toBe("unavailable"); + expect(revokedResult.env).toEqual({}); + }); + + it("resolves a personal (per_user) GitHub PAT stored in a real user-scoped secret", async () => { + const fixture = await seedLowTrustFixture(); + const pat = await addGitHubPatConnection(fixture, { + kind: "user", + tokenValue: "github_pat_personal_user_scoped_456", + }); + + const result = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + remoteUrl: fixture.repoUrl, + }); + expect(result.status).toBe("available"); + expect(result.source).toBe("personal"); + expect(result.grantId).toBe(pat.grantId); + expect(result.env.PAPERCLIP_GIT_TOKEN).toBe("github_pat_personal_user_scoped_456"); + + // Runtime credentials remain denied even when the personal PAT is available for prepare. + const runtimeCreds = await resolveGitHubOperationCredentials(db, { + companyId: fixture.companyId, + agentId: fixture.agentId, + runId: fixture.runId, + }); + expect(runtimeCreds.status).toBe("unavailable"); + expect(runtimeCreds.env).toEqual({}); + }); + + it("supports shared (organization) PAT grants and blocks fallback to personal PAT when a dedicated PAT is revoked", async () => { + const sharedFixture = await seedLowTrustFixture(); + const orgPat = await addGitHubPatConnection(sharedFixture, { + kind: "organization", + tokenValue: "github_pat_shared_org_789", + }); + const orgResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: sharedFixture.companyId, + agentId: sharedFixture.agentId, + runId: sharedFixture.runId, + remoteUrl: sharedFixture.repoUrl, + }); + expect(orgResult.status).toBe("available"); + expect(orgResult.grantId).toBe(orgPat.grantId); + expect(orgResult.env.PAPERCLIP_GIT_TOKEN).toBe("github_pat_shared_org_789"); + + await db + .update(connectionGrants) + .set({ status: "revoked" }) + .where(eq(connectionGrants.id, orgPat.grantId)); + const revokedOrgResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: sharedFixture.companyId, + agentId: sharedFixture.agentId, + runId: sharedFixture.runId, + remoteUrl: sharedFixture.repoUrl, + }); + expect(revokedOrgResult.status).toBe("unavailable"); + expect(revokedOrgResult.env).toEqual({}); + + // Revoking a dedicated PAT must fail closed rather than switching to an installed personal PAT. + const mixedFixture = await seedLowTrustFixture(); + await addGitHubPatConnection(mixedFixture, { + kind: "agent", + tokenValue: "github_pat_revoked_dedicated", + grantStatus: "revoked", + }); + await addGitHubPatConnection(mixedFixture, { + kind: "user", + tokenValue: "github_pat_personal_should_not_be_used", + grantStatus: "active", + }); + const mixedResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: mixedFixture.companyId, + agentId: mixedFixture.agentId, + runId: mixedFixture.runId, + remoteUrl: mixedFixture.repoUrl, + }); + expect(mixedResult.status).toBe("unavailable"); + expect(mixedResult.env).toEqual({}); + + // Shared organization PAT with a user-restricted audience denies users outside the audience. + const restrictedFixture = await seedLowTrustFixture({ + responsibleUserId: "user-outside-audience", + }); + const restrictedOrgPat = await addGitHubPatConnection(restrictedFixture, { + kind: "organization", + tokenValue: "github_pat_restricted_org_audience", + }); + await db.insert(connectionGrantMembers).values({ + companyId: restrictedFixture.companyId, + grantId: restrictedOrgPat.grantId, + subjectType: "user", + subjectId: "user-inside-audience", + }); + const deniedAudienceResult = await resolveGitHubWorkspacePrepareCredentials(db, { + companyId: restrictedFixture.companyId, + agentId: restrictedFixture.agentId, + runId: restrictedFixture.runId, + remoteUrl: restrictedFixture.repoUrl, + }); + expect(deniedAudienceResult.status).toBe("unavailable"); + expect(deniedAudienceResult.env).toEqual({}); + }); + + it("never falls back to company secrets or server-env GITHUB_TOKEN for low-trust workspace_prepare", async () => { + const fixture = await seedLowTrustFixture(); + await secretService(db).create( + fixture.companyId, + { + name: "GITHUB_TOKEN", + value: "ghp_company_secret_must_not_leak", + provider: "local_encrypted", + }, + { userId: fixture.responsibleUserId, agentId: null }, + ); + + const provider = createGitRemoteAuthProvider( + db, + fixture.companyId, + { + agentId: fixture.agentId, + heartbeatRunId: fixture.runId, + issueId: fixture.issueId, + purpose: "workspace_prepare", + }, + { + env: { GITHUB_TOKEN: "ghp_server_env_must_not_leak" }, + }, + ); + const invocation = await provider(fixture.repoUrl); + expect(invocation?.env.PAPERCLIP_GIT_TOKEN).toBe(""); + }); + + it("denies project:write_workspace for low-trust agents even with tasks:assign on an in-boundary project", async () => { + const fixture = await seedLowTrustFixture(); + await db.insert(principalPermissionGrants).values({ + companyId: fixture.companyId, + principalType: "agent", + principalId: fixture.agentId, + permissionKey: "tasks:assign", + }); + + const decision = await authorizationService(db).decide({ + actor: { + type: "agent", + agentId: fixture.agentId, + companyId: fixture.companyId, + source: "agent_jwt", + runId: fixture.runId, + }, + action: "project:write_workspace", + resource: { + type: "issue", + companyId: fixture.companyId, + projectId: fixture.projectId, + issueId: fixture.issueId, + assigneeAgentId: fixture.agentId, + }, + scope: { projectId: fixture.projectId, assigneeAgentId: fixture.agentId }, + }); + expect(decision.allowed).toBe(false); + }); + + it("test-drives prepareRemoteWorkspaceDirectory end-to-end with transient low-trust auth and leaves zero credentials in the sandbox", async () => { + const tmp = await realpath( + await mkdtemp(path.join(os.tmpdir(), "paperclip-low-trust-e2e-")), + ); + try { + const seedWork = path.join(tmp, "seed"); + const bareRepo = path.join(tmp, "origin.git"); + const remoteCwd = path.join(tmp, "sandbox-workspace"); + execFileSync("git", ["init", "-b", "main", seedWork], { stdio: "ignore" }); + await writeFile(path.join(seedWork, "README.md"), "private-repo-content\n", "utf8"); + execFileSync("git", ["add", "README.md"], { cwd: seedWork, stdio: "ignore" }); + execFileSync( + "git", + [ + "-c", + "user.name=Owner", + "-c", + "user.email=owner@example.test", + "commit", + "-m", + "initial private commit", + ], + { cwd: seedWork, stdio: "ignore" }, + ); + execFileSync("git", ["clone", "--bare", seedWork, bareRepo], { stdio: "ignore" }); + + const fixture = await seedLowTrustFixture({ + repoUrl: "https://github.com/acme/e2e-private-repo", + }); + await addManagedOAuthGrant(fixture, "gho_e2e_transient_token"); + + const prepareProvider = createGitRemoteAuthProvider(db, fixture.companyId, { + agentId: fixture.agentId, + heartbeatRunId: fixture.runId, + issueId: fixture.issueId, + purpose: "workspace_prepare", + }); + + let observedTokenDuringPrepare: string | undefined; + await prepareRemoteWorkspaceDirectory({ + target: { + kind: "remote", + transport: "sandbox", + remoteCwd: tmp, + runner: { + execute: async ({ + command: cmd, + args, + env, + }: { + command: string; + args: string[]; + env?: Record; + }) => { + if (env?.PAPERCLIP_GIT_TOKEN) { + observedTokenDuringPrepare = env.PAPERCLIP_GIT_TOKEN; + } + const { stdout, stderr } = await execFileAsync(cmd, args, { + env: { ...process.env, ...(env ?? {}) }, + }); + return { exitCode: 0, signal: null, timedOut: false, stdout, stderr }; + }, + }, + } as unknown as Parameters[0]["target"], + remoteCwd, + source: { kind: "git", repoUrl: bareRepo, ref: "main" }, + resolveGitAuth: async () => prepareProvider(fixture.repoUrl), + preparationIdentity: "a".repeat(64), + }); + + expect(observedTokenDuringPrepare).toBe("gho_e2e_transient_token"); + expect(await readFile(path.join(remoteCwd, "README.md"), "utf8")).toBe( + "private-repo-content\n", + ); + + const gitConfig = await readFile(path.join(remoteCwd, ".git", "config"), "utf8"); + expect(gitConfig).not.toContain("gho_e2e_transient_token"); + expect(gitConfig).not.toContain("PAPERCLIP_GIT_TOKEN"); + expect(gitConfig).not.toContain("x-access-token"); + + const logOut = execFileSync("git", ["-C", remoteCwd, "log", "-1", "--format=%s"], { + encoding: "utf8", + env: { PATH: process.env.PATH ?? "" }, + }).trim(); + expect(logOut).toBe("initial private commit"); + } finally { + await rm(tmp, { recursive: true, force: true }); + } + }); + }, +); diff --git a/server/src/services/authorization.ts b/server/src/services/authorization.ts index 180fa28d71f..5ab5ed5255a 100644 --- a/server/src/services/authorization.ts +++ b/server/src/services/authorization.ts @@ -1520,7 +1520,11 @@ function createAuthorizationService(db: Db | DbTransaction, readSnapshot?: ReadA return lowTrustDeny("Issue is outside this low-trust boundary."); } - if (input.action === "tasks:assign" || input.action === "project:write_workspace") { + if (input.action === "project:write_workspace") { + return lowTrustDeny("Low-trust agents cannot modify project workspaces."); + } + + if (input.action === "tasks:assign") { if (input.resource.type !== "issue") { return lowTrustDeny("Low-trust task assignment is missing an issue resource."); } diff --git a/server/src/services/git-credentials.ts b/server/src/services/git-credentials.ts index b17d8ff2c8f..bddce3251b0 100644 --- a/server/src/services/git-credentials.ts +++ b/server/src/services/git-credentials.ts @@ -278,6 +278,7 @@ export function createGitRemoteAuthProvider( heartbeatRunId?: string | null; responsibleUserId?: string | null; agentId?: string | null; + purpose?: "workspace_prepare"; }, deps?: { secrets?: GitCredentialSecretsDeps; @@ -333,10 +334,23 @@ export function createGitRemoteAuthProvider( eq(heartbeatRuns.id, context.heartbeatRunId), eq(heartbeatRuns.companyId, companyId), eq(heartbeatRuns.agentId, context.agentId), )); if (run?.contextId) { - const { resolveGitHubOperationCredentials } = await import("./github-operation-credentials.js"); - const result = await resolveGitHubOperationCredentials(db, { - companyId, runId: context.heartbeatRunId, agentId: context.agentId, - }); + const { + resolveGitHubOperationCredentials, + resolveGitHubWorkspacePrepareCredentials, + } = await import("./github-operation-credentials.js"); + const result = + context.purpose === "workspace_prepare" + ? await resolveGitHubWorkspacePrepareCredentials(db, { + companyId, + runId: context.heartbeatRunId, + agentId: context.agentId, + remoteUrl, + }) + : await resolveGitHubOperationCredentials(db, { + companyId, + runId: context.heartbeatRunId, + agentId: context.agentId, + }); if (result.status === "absent") { const credential = await resolveCredential(); return credential ? buildGitAuthInvocation(credential) : null; diff --git a/server/src/services/github-operation-credentials.ts b/server/src/services/github-operation-credentials.ts index d08dd5ceef0..dfafb09b841 100644 --- a/server/src/services/github-operation-credentials.ts +++ b/server/src/services/github-operation-credentials.ts @@ -1,21 +1,32 @@ import { isDeepStrictEqual } from "node:util"; -import { and, eq } from "drizzle-orm"; +import { and, eq, inArray, or, sql } from "drizzle-orm"; import { isUuidLike } from "@paperclipai/shared"; import { agents, + companyMemberships, + companySecrets, + connectionGrantMembers, + connectionGrants, heartbeatRuns, issues, projects, + projectWorkspaces, runIdentityContexts, + toolConnectionInstalls, + toolConnections, type Db, } from "@paperclipai/db"; import { forbidden } from "../errors.js"; +import { connectionGrantCredentialRef } from "./connection-credentials.js"; +import { isGitHubDotCom } from "./github-fetch.js"; import { captureRunCompletionIdentity, captureRunIdentity, type RunIdentityContext } from "./run-identity.js"; import { buildGitAuthInvocation, resolveManagedGitHubCredential, } from "./git-credentials.js"; +import { normalizeProjectRepositoryUrl } from "./project-repositories.js"; import { secretService } from "./secrets.js"; +import { sharedAgentGrantIds } from "./tool-access/connections/agent-grant.js"; import { resolveCoreTrustPreset } from "./trust-preset-resolver.js"; import { isLowTrustQuarantined } from "./source-trust.js"; @@ -32,11 +43,20 @@ export type GitHubCredentialSummary = { type GitHubCredentialRun = Pick; -/** A raw GitHub token cannot enforce the low-trust read-only tool boundary. */ -async function allowsGitHubCredentialExport( +type LoadedRunTrustContext = { + projectId: string | null; + trust: ReturnType; +}; + +/** + * Shared fail-closed trust loader for both runtime credential export and + * controller-only workspace-prepare checkout. Quarantined issues are denied + * in both paths so security gates cannot drift. + */ +async function loadRunTrustContext( db: Db, run: GitHubCredentialRun, -) { +): Promise { const issueId = run.contextSnapshot?.issueId ?? run.contextSnapshot?.taskId ?? @@ -45,15 +65,16 @@ async function allowsGitHubCredentialExport( issueId !== undefined && issueId !== null && (typeof issueId !== "string" || !isUuidLike(issueId)) - ) - return false; + ) { + return null; + } const [agent] = await db .select({ companyId: agents.companyId, permissions: agents.permissions }) .from(agents) .where( and(eq(agents.id, run.agentId), eq(agents.companyId, run.companyId)), ); - if (!agent) return false; + if (!agent) return null; const [issue] = typeof issueId === "string" ? await db @@ -68,15 +89,16 @@ async function allowsGitHubCredentialExport( and(eq(issues.id, issueId), eq(issues.companyId, run.companyId)), ) : []; - if (issueId !== undefined && issueId !== null && !issue) return false; - if (isLowTrustQuarantined(issue?.sourceTrust)) return false; + if (issueId !== undefined && issueId !== null && !issue) return null; + if (isLowTrustQuarantined(issue?.sourceTrust)) return null; const projectId = issue?.projectId ?? run.contextSnapshot?.projectId; if ( projectId !== undefined && projectId !== null && (typeof projectId !== "string" || !isUuidLike(projectId)) - ) - return false; + ) { + return null; + } const [project] = typeof projectId === "string" ? await db @@ -92,19 +114,57 @@ async function allowsGitHubCredentialExport( ), ) : []; - if (projectId !== undefined && projectId !== null && !project) return false; - return ( - resolveCoreTrustPreset({ + if (projectId !== undefined && projectId !== null && !project) return null; + const trust = resolveCoreTrustPreset({ + companyId: run.companyId, + agent, + project, + issue, + run: { companyId: run.companyId, - agent, - project, - issue, - run: { - companyId: run.companyId, - executionPolicy: run.contextSnapshot?.executionPolicy, - }, - }).kind === "standard" - ); + executionPolicy: run.contextSnapshot?.executionPolicy, + }, + }); + return { + projectId: typeof projectId === "string" ? projectId : null, + trust, + }; +} + +/** A raw GitHub token cannot enforce the low-trust read-only tool boundary. */ +async function allowsGitHubCredentialExport( + db: Db, + run: GitHubCredentialRun, +) { + return (await loadRunTrustContext(db, run))?.trust.kind === "standard"; +} + +function normalizeGitHubRepositoryIdentity(remoteUrl: string): string | null { + const trimmed = remoteUrl.trim(); + const scpMatch = /^git@(?:www\.)?github\.com:([^\s]+)$/i.exec(trimmed); + let candidate = trimmed; + if (scpMatch) { + candidate = `https://github.com/${scpMatch[1]!.replace(/^\/+/, "")}`; + } else { + try { + const parsed = new URL(trimmed); + if ( + parsed.protocol === "ssh:" && + parsed.username === "git" && + !parsed.password && + isGitHubDotCom(parsed.hostname) + ) { + candidate = `https://github.com/${parsed.pathname.replace(/^\/+/, "")}`; + } + } catch { + // Fall through to normalizeProjectRepositoryUrl below. + } + } + try { + return normalizeProjectRepositoryUrl(candidate).url.toLowerCase(); + } catch { + return null; + } } async function saveGitHubSummary( @@ -133,6 +193,432 @@ export async function resolveGitHubOperationCredentials( return resolveCapturedGitHubCredentials(db, run, context); } +/** + * Controller-only workspace-prepare credentials. For low-trust runs, this allows + * a transient clone of a repository explicitly configured on a project inside + * the run's trust boundary when `git.read` is permitted. Runtime agent shells + * still use `resolveGitHubOperationCredentials`, which remains denied. + */ +export async function resolveGitHubWorkspacePrepareCredentials( + db: Db, + input: { + companyId: string; + agentId: string; + runId: string; + remoteUrl: string; + }, +) { + const { run, context } = await captureRunIdentity(db, input, { readScope: "github_credentials" }); + if (!context) throw forbidden("This run predates managed GitHub credentials"); + const trustContext = await loadRunTrustContext(db, run); + if (trustContext?.trust.kind === "standard") { + return resolveCapturedGitHubCredentials(db, run, context, { + authorized: true, + saveSummary: true, + allowAbsentFallback: true, + }); + } + const prepareAllowed = trustContext + ? await allowsLowTrustWorkspacePrepareCheckout(db, run, input.remoteUrl, trustContext) + : false; + if (!prepareAllowed) { + return { + identityContextId: context.id, + revision: context.revision, + status: "unavailable" as const, + reason: + "GitHub credentials are not available to low-trust or unverified executions; use authorized read-only tools.", + env: {} as Record, + }; + } + const pat = await resolveAuthorizedGitHubPat(db, run, context); + if (pat) { + if (pat.status === "unavailable") { + return { + identityContextId: context.id, + revision: context.revision, + status: "unavailable" as const, + source: pat.source, + reason: pat.reason, + env: {} as Record, + }; + } + return { + identityContextId: context.id, + revision: context.revision, + status: "available" as const, + source: pat.source, + connectionId: pat.connectionId, + grantId: pat.grantId, + authenticationMode: "managed" as const, + env: buildGitAuthInvocation({ token: pat.token, source: "managed_connection", secretName: null }).env, + }; + } + // Low-trust workspace prepare must never overwrite the runtime credential + // summary or fall through to company secrets / process-wide GITHUB_TOKEN. + return resolveCapturedGitHubCredentials(db, run, context, { + authorized: true, + saveSummary: false, + allowAbsentFallback: false, + }); +} + +async function allowsLowTrustWorkspacePrepareCheckout( + db: Db, + run: GitHubCredentialRun, + remoteUrl: string, + trustContext: LoadedRunTrustContext, +): Promise { + const normalizedRemote = normalizeGitHubRepositoryIdentity(remoteUrl); + if (!normalizedRemote) return false; + const { trust, projectId } = trustContext; + if (trust.kind !== "low_trust_review") return false; + if (!(trust.boundary.allowedToolClasses ?? []).includes("git.read")) return false; + const boundaryProjectIds = (trust.boundary.projectIds ?? []).filter( + (id): id is string => typeof id === "string" && isUuidLike(id), + ); + if (boundaryProjectIds.length === 0) return false; + if (projectId && !boundaryProjectIds.includes(projectId)) return false; + + const workspaces = await db + .select({ repoUrl: projectWorkspaces.repoUrl }) + .from(projectWorkspaces) + .where( + and( + eq(projectWorkspaces.companyId, run.companyId), + inArray(projectWorkspaces.projectId, boundaryProjectIds), + ), + ); + return workspaces.some((ws) => { + if (!ws.repoUrl) return false; + return normalizeGitHubRepositoryIdentity(ws.repoUrl) === normalizedRemote; + }); +} + +type AuthorizedGitHubPatResult = + | { + status: "available"; + connectionId: string; + grantId: string; + source: "dedicated" | "personal"; + token: string; + } + | { + status: "unavailable"; + source: "dedicated" | "personal"; + reason: string; + }; + +async function resolveAuthorizedGitHubPat( + db: Db, + run: GitHubCredentialRun, + context: RunIdentityContext, +): Promise { + const connections = await db + .select({ + id: toolConnections.id, + credentialPolicy: toolConnections.credentialPolicy, + credentialRefs: toolConnections.credentialRefs, + }) + .from(toolConnections) + .where( + and( + eq(toolConnections.companyId, run.companyId), + eq(toolConnections.authKind, "api_key"), + eq(toolConnections.enabled, true), + eq(toolConnections.status, "active"), + or( + sql`${toolConnections.config}->'sourceTemplateKey' = '"github"'::jsonb`, + sql`${toolConnections.transportConfig}->'sourceTemplateKey' = '"github"'::jsonb`, + ), + ), + ); + const authConnections = connections.filter((connection) => + connection.credentialRefs.some( + (ref) => ref.placement === "header" && ref.key.toLowerCase() === "authorization", + ), + ); + if (authConnections.length === 0) return null; + const authConnectionIds = authConnections.map((connection) => connection.id); + const installs = await db + .select({ + connectionId: toolConnectionInstalls.connectionId, + targetType: toolConnectionInstalls.targetType, + targetId: toolConnectionInstalls.targetId, + }) + .from(toolConnectionInstalls) + .where( + and( + eq(toolConnectionInstalls.companyId, run.companyId), + inArray(toolConnectionInstalls.connectionId, authConnectionIds), + ), + ); + const sharedGrants = await sharedAgentGrantIds( + db, + run.companyId, + run.agentId, + authConnections + .filter((connection) => connection.credentialPolicy === "per_agent") + .map((connection) => connection.id), + ); + const sharedConnectionIds = new Set(sharedGrants.values()); + const eligibleConnections = authConnections.filter( + (connection) => + sharedConnectionIds.has(connection.id) || + installs.some( + (install) => + install.connectionId === connection.id && + ((install.targetType === "company" && install.targetId === run.companyId) || + (install.targetType === "agent" && install.targetId === run.agentId)), + ), + ); + if (eligibleConnections.length === 0) return null; + + // Query all matching grants before checking status so revoking a higher-priority + // dedicated grant fails closed instead of silently switching to a personal or + // organization credential. + const grants = await db + .select() + .from(connectionGrants) + .where( + and( + eq(connectionGrants.companyId, run.companyId), + inArray( + connectionGrants.connectionId, + eligibleConnections.map((connection) => connection.id), + ), + or( + eq(connectionGrants.kind, "agent"), + eq(connectionGrants.kind, "user"), + eq(connectionGrants.kind, "organization"), + ), + ), + ); + const ownDedicated = grants.filter( + (grant) => grant.kind === "agent" && grant.subjectAgentId === run.agentId, + ); + const sharedDedicated = + ownDedicated.length > 0 + ? [] + : grants.filter((grant) => grant.kind === "agent" && sharedGrants.has(grant.id)); + const liveSharedDedicated = sharedDedicated.filter((grant) => grant.status === "active"); + const dedicated = + ownDedicated.length > 0 + ? ownDedicated + : liveSharedDedicated.length > 0 + ? liveSharedDedicated + : sharedDedicated; + const responsibleUserId = + context.cause === "company_default" ? null : (context.responsibleUserId ?? null); + const personal = responsibleUserId + ? grants.filter( + (grant) => grant.kind === "user" && grant.subjectUserId === responsibleUserId, + ) + : []; + const sharedPolicyConnectionIds = new Set( + eligibleConnections + .filter((connection) => connection.credentialPolicy === "shared") + .map((connection) => connection.id), + ); + const organization = grants.filter( + (grant) => + grant.kind === "organization" && + grant.isDefault === true && + sharedPolicyConnectionIds.has(grant.connectionId), + ); + const candidates = + dedicated.length > 0 + ? dedicated + : personal.length > 0 + ? personal + : organization; + if (candidates.length === 0) return null; + const identitySource: "dedicated" | "personal" = + dedicated.length > 0 || (personal.length === 0 && organization.length > 0) + ? "dedicated" + : "personal"; + if (candidates.length !== 1) { + return { + status: "unavailable", + source: identitySource, + reason: "More than one GitHub PAT authorization matches this run", + }; + } + + const grant = candidates[0]!; + if (grant.status !== "active") { + return { + status: "unavailable", + source: identitySource, + reason: "The configured GitHub PAT authorization must be reconnected", + }; + } + const connection = eligibleConnections.find((item) => item.id === grant.connectionId); + if (!connection) { + return { + status: "unavailable", + source: identitySource, + reason: "The configured GitHub PAT connection is unavailable", + }; + } + const authRef = connection.credentialRefs.find( + (ref) => ref.placement === "header" && ref.key.toLowerCase() === "authorization", + ); + if (!authRef) { + return { + status: "unavailable", + source: identitySource, + reason: "The configured GitHub PAT credential is incomplete", + }; + } + + const grantRef = connectionGrantCredentialRef(grant, authRef); + const accessContext = { + consumerType: "system" as const, + consumerId: "workspace-git-credential", + actorType: "system" as const, + actorId: run.agentId, + issueId: typeof run.contextSnapshot?.issueId === "string" ? run.contextSnapshot.issueId : null, + heartbeatRunId: run.id, + responsibleUserId, + }; + const secrets = secretService(db); + try { + let raw: string; + if (grant.kind === "user") { + if (!grant.subjectUserId || !grantRef) { + return { + status: "unavailable", + source: "personal", + reason: "The personal GitHub PAT credential is invalid", + }; + } + const [membership] = await db + .select({ id: companyMemberships.id, role: companyMemberships.membershipRole }) + .from(companyMemberships) + .where( + and( + eq(companyMemberships.companyId, run.companyId), + eq(companyMemberships.principalType, "user"), + eq(companyMemberships.principalId, grant.subjectUserId), + eq(companyMemberships.status, "active"), + ), + ) + .limit(1); + if (!membership || membership.role === "viewer") { + return { + status: "unavailable", + source: "personal", + reason: "The personal GitHub PAT owner is not an authorized company member", + }; + } + const [secret] = await db + .select({ userSecretDefinitionId: companySecrets.userSecretDefinitionId }) + .from(companySecrets) + .where( + and( + eq(companySecrets.companyId, run.companyId), + eq(companySecrets.id, grantRef.secretId), + eq(companySecrets.ownerUserId, grant.subjectUserId), + ), + ) + .limit(1); + if (!secret?.userSecretDefinitionId) { + return { + status: "unavailable", + source: "personal", + reason: "The personal GitHub PAT credential is invalid", + }; + } + const resolved = await secrets.resolveUserSecretValue( + run.companyId, + { + definitionId: secret.userSecretDefinitionId, + responsibleUserId: grant.subjectUserId, + version: grantRef.versionSelector ?? "latest", + required: true, + }, + accessContext, + ); + if (!resolved) { + return { + status: "unavailable", + source: "personal", + reason: "The personal GitHub PAT credential is missing", + }; + } + raw = resolved.value; + } else { + if (grant.kind === "organization") { + const activeAudienceMember = responsibleUserId + ? await db + .select({ id: companyMemberships.id, role: companyMemberships.membershipRole }) + .from(companyMemberships) + .where( + and( + eq(companyMemberships.companyId, run.companyId), + eq(companyMemberships.principalType, "user"), + eq(companyMemberships.principalId, responsibleUserId), + eq(companyMemberships.status, "active"), + ), + ) + .limit(1) + .then((rows) => rows[0] ?? null) + : null; + const audience = await db + .select({ subjectId: connectionGrantMembers.subjectId }) + .from(connectionGrantMembers) + .where( + and( + eq(connectionGrantMembers.companyId, run.companyId), + eq(connectionGrantMembers.grantId, grant.id), + eq(connectionGrantMembers.subjectType, "user"), + ), + ); + if ( + (responsibleUserId !== null && + (!activeAudienceMember || activeAudienceMember.role === "viewer")) || + (audience.length > 0 && + (!responsibleUserId || + !audience.some((member) => member.subjectId === responsibleUserId))) + ) { + return { + status: "unavailable", + source: "dedicated", + reason: "The responsible user is not in this GitHub PAT grant's audience", + }; + } + } + const secretId = grantRef?.secretId ?? authRef.secretId; + const version = grantRef?.versionSelector ?? authRef.version ?? "latest"; + raw = await secrets.resolveSecretValue(run.companyId, secretId, version, { + accessContext, + }); + } + const token = raw.trim().replace(/^(?:Bearer|token)\s+/i, "").trim(); + if (!token) { + return { + status: "unavailable", + source: identitySource, + reason: "The configured GitHub PAT credential is empty", + }; + } + return { + status: "available", + connectionId: connection.id, + grantId: grant.id, + source: identitySource, + token, + }; + } catch { + return { + status: "unavailable", + source: identitySource, + reason: "GitHub PAT credentials are temporarily unavailable", + }; + } +} + export async function resolveGitHubCompletionCredentials( db: Db, input: { companyId: string; issueId: string; runId: string }, @@ -149,20 +635,32 @@ export async function resolveGitHubCompletionCredentials( return resolveCapturedGitHubCredentials(db, run, context); } -async function resolveCapturedGitHubCredentials(db: Db, run: GitHubCredentialRun, context: RunIdentityContext) { +async function resolveCapturedGitHubCredentials( + db: Db, + run: GitHubCredentialRun, + context: RunIdentityContext, + options?: { + authorized?: boolean; + saveSummary?: boolean; + allowAbsentFallback?: boolean; + }, +) { + const saveSummary = options?.saveSummary !== false; + const allowAbsentFallback = options?.allowAbsentFallback !== false; let summary: GitHubCredentialSummary; let env: Record = {}; // A sponsored guest's responsible person is an internal accountability field, // not authorization to export that person's (or a dedicated bot's) token. // Re-read every policy source for each operation, including a run's retained // boundary after task policy edits. Deny before touching the credential store. - if (!(await allowsGitHubCredentialExport(db, run))) { + const authorized = options?.authorized ?? (await allowsGitHubCredentialExport(db, run)); + if (!authorized) { summary = { status: "unavailable", reason: "GitHub credentials are not available to low-trust or unverified executions; use authorized read-only tools.", }; - await saveGitHubSummary(db, context, summary); + if (saveSummary) await saveGitHubSummary(db, context, summary); return { identityContextId: context.id, revision: context.revision, @@ -201,7 +699,7 @@ async function resolveCapturedGitHubCredentials(db: Db, run: GitHubCredentialRun env = buildGitAuthInvocation(resolved.credential).env; } else { summary = { - status: resolved.configured ? "unavailable" : "absent", + status: resolved.configured || !allowAbsentFallback ? "unavailable" : "absent", source: resolved.identitySource ?? "personal", reason: resolved.error ?? "No GitHub identity connected", }; @@ -213,7 +711,7 @@ async function resolveCapturedGitHubCredentials(db: Db, run: GitHubCredentialRun reason: "GitHub credentials are temporarily unavailable", }; } - if (context) await saveGitHubSummary(db, context, summary); + if (context && saveSummary) await saveGitHubSummary(db, context, summary); return { identityContextId: context?.id ?? null, revision: context?.revision ?? null, diff --git a/server/src/services/heartbeat/workspace-preparation.ts b/server/src/services/heartbeat/workspace-preparation.ts index 37c30c46f07..1a582f1af6a 100644 --- a/server/src/services/heartbeat/workspace-preparation.ts +++ b/server/src/services/heartbeat/workspace-preparation.ts @@ -1015,6 +1015,7 @@ async function prepareHeartbeatWorkspaceLocked(db: Db, input: HeartbeatWorkspace heartbeatRunId: run.id, responsibleUserId: run.responsibleUserId, agentId: agent.id, + purpose: "workspace_prepare", }, ); if (freshNeedsSeed && issueId && !pluginPrepared && !pluginTaskWorkspace && !remoteAuthority) { diff --git a/server/src/services/heartbeat/workspaces.ts b/server/src/services/heartbeat/workspaces.ts index 3a65e5ebf9b..40a2b6e8733 100644 --- a/server/src/services/heartbeat/workspaces.ts +++ b/server/src/services/heartbeat/workspaces.ts @@ -3439,6 +3439,7 @@ export function createHeartbeatWorkspaceResolver(db: Db) { resolveGitAuth: createGitRemoteAuthProvider(db, agent.companyId, { issueId: input.issueId, heartbeatRunId: input.runId, agentId: agent.id, responsibleUserId: input.responsibleUserId, + purpose: "workspace_prepare", }), }); return original.cwd; @@ -3481,6 +3482,7 @@ export function createHeartbeatWorkspaceResolver(db: Db) { readNonEmptyString(context.responsibleUserId) ?? readNonEmptyString(context.responsible_user_id), agentId: agent.id, + purpose: "workspace_prepare", }); const contextProjectId = readNonEmptyString(context.projectId); const contextProjectWorkspaceId = readNonEmptyString( @@ -3793,6 +3795,7 @@ export function createHeartbeatWorkspaceResolver(db: Db) { heartbeatRunId: readNonEmptyString(context.executionIdentityRunId), responsibleUserId, agentId: agent.id, + purpose: "workspace_prepare", }); const { additionalWorkspaces, warnings, failures } = await resolveAdditionalRunWorkspaces(issueId, anchor.projectId, { From 7e025ae65f9050030edf4d2cab006aa981569261 Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Thu, 3 Dec 2026 13:45:10 -0800 Subject: [PATCH 002/119] fix(workspaces): start a new remote workspace when the task's saved one is retired (#23655) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Before a run starts, Paperclip prepares the task's execution workspace. With remote workspace storage, it reserves the task's saved remote workspace. > - A task stays bound to its workspace after that workspace is archived or its cleanup fails. > - For a retired host workspace, the next run already creates a new workspace. For a retired remote workspace, preparation sent the retired workspace to the reservation. The reservation refused it with "Workspace ownership changed." (`remote_workspace_retired`, since #23582). > - So the task could never run again. Each wake, recovery, or Retry failed in setup with the same conflict. > - This pull request makes a retired remote workspace act like a retired host workspace: the run starts a new remote workspace. > - The benefit is that a reopened task with an archived remote workspace runs again, and the retired workspace and its saved snapshot stay unchanged. ## Linked Issues or Issue Description **What happened** A task's own remote workspace was archived by hand (no terminal-cleanup reason) and later moved to remote storage. When the task was opened again, every run failed in setup with "Workspace ownership changed." The task was then escalated for recovery, and the next wake failed in the same way. **Expected behavior** A retired workspace is not reused. The run starts a new workspace for the task, as it does for a host workspace. A native recovery or a saved Retry that is bound to the retired workspace still stops with the conflict. **Steps to reproduce** 1. Bind a task to its own remote-storage workspace. Set the workspace status to `archived` or `cleanup_failed`. 2. Start a run for the task with a Paperclip Runner agent in a sandbox environment. 3. Setup fails with a 409 conflict, "Workspace ownership changed." (`remote_workspace_retired`). **Paperclip version or commit** master at 0208bbfbf7. Refs #23582 (gave this conflict its stable code). Related: #21954 (releases a binding to *another* task's closed workspace; this change is about the task's *own* retired remote workspace). ## What Changed - `remote-workspaces.ts`: add `isRetiredExecutionWorkspaceStatus` (`archived` or `cleanup_failed`). When the caller requests no workspace, `reserveRemoteWorkspace` does not fall back to an issue binding to a retired workspace. It creates a new workspace and moves the issue binding to it. An explicitly requested retired workspace still gets the `remote_workspace_retired` conflict. - `heartbeat/workspace-preparation.ts`: do not offer a retired remote-storage workspace for reuse. The retired workspace still decides the storage authority, so the task stays on remote storage even when the instance does not enroll new tasks. This does not apply to a native recovery, a persisted native execution input, or a saved Retry/fresh attempt. Those stay bound to the workspace that they admitted. - Tests: three preparation tests (`archived`, `cleanup_failed`, and `archived` with new-task remote storage off) and one native-recovery safety test in `workspace-preparation.test.ts`. Two reservation tests in `remote-workspaces.integration.test.ts`. ## Verification - Red before the fix: `cd server && npx vitest run src/services/heartbeat/workspace-preparation.test.ts -t "saved remote workspace is"` failed with `Workspace ownership changed.` for both statuses. With only the reservation change removed, the two new `remote-workspaces.integration.test.ts` tests also failed with `Workspace ownership changed.` - Green after the fix: `npx vitest run src/services/heartbeat/workspace-preparation.test.ts src/services/remote-workspaces.integration.test.ts -t "saved remote workspace is|native recovery bound to a task workspace|stable conflict code|when no workspace is requested"`: 8 of 8 pass. The storage-off case failed before the follow-up commit (the run fell back to the host path). - The tests check that the new workspace is active and bound to the task, that the binding revision goes up by one, and that the retired row and its snapshot metadata do not change. The existing explicit-request conflict test still passes, and a native recovery still gets the conflict. - Full files: `npx vitest run src/services/heartbeat/workspace-preparation.test.ts src/services/remote-workspaces.integration.test.ts src/services/workspace-recovery-admission.test.ts`: 433 of 433 pass (Linux x64, Node 24.23.0, embedded Postgres). ## Risks - Behavior change: a task whose own remote workspace is retired now continues in a new workspace. Files that were only in the retired workspace's snapshot are not restored into the new workspace. This is the same as for a retired host workspace. The retired snapshot is not deleted. - A native recovery or a saved Retry still stops on a retired workspace, so a run that is in progress does not change its workspace silently. - No schema or API change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution in a sandbox. ## 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 - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .../heartbeat/workspace-preparation.test.ts | 84 +++++++++++++++++++ .../heartbeat/workspace-preparation.ts | 21 ++++- .../remote-workspaces.integration.test.ts | 21 +++++ server/src/services/remote-workspaces.ts | 15 +++- 4 files changed, 137 insertions(+), 4 deletions(-) diff --git a/server/src/services/heartbeat/workspace-preparation.test.ts b/server/src/services/heartbeat/workspace-preparation.test.ts index 9ab2c78591b..d6ef54aaecc 100644 --- a/server/src/services/heartbeat/workspace-preparation.test.ts +++ b/server/src/services/heartbeat/workspace-preparation.test.ts @@ -302,6 +302,90 @@ describe.skipIf(!support.supported && !externalDatabaseUrl)("heartbeat workspace expect((await readIssue(issue.id)).executionWorkspaceId).toBe(workspace.id); }); + it.each([ + { status: "archived", storageEnabled: true }, + { status: "cleanup_failed", storageEnabled: true }, + { status: "archived", storageEnabled: false }, + ] as const)("starts a new remote workspace for a task whose own saved remote workspace is $status (new-task remote storage: $storageEnabled)", async ({ status, storageEnabled }) => { + const { input, source, issue, envOrchestrator } = await fixture(true); + // The task already uses remote storage, so it stays there even when the + // instance no longer enrolls new tasks. + input.environment.resolvedInstanceSettings.experimental.remoteWorkspaceStorageEnabled = storageEnabled; + const [savedEnvironment] = await db.insert(environments).values({ name: `Remote ${randomUUID()}`, + driver: "sandbox", status: "active", config: { provider: "daytona" } }).returning(); + await db.update(agents).set({ adapterType: "paperclip_runner" }).where(eq(agents.id, input.agent.id)); + input.agent.adapterType = "paperclip_runner"; + input.environment.selectedEnvironmentForConfig = await environmentService(db).getById(savedEnvironment.id); + input.environment.selectedEnvironmentId = savedEnvironment.id; + await db.update(projectWorkspaces).set({ cwd: null, sourceType: "git", repoUrl: "https://github.com/example/remote.git", repoRef: "main" }) + .where(eq(projectWorkspaces.id, issue.projectWorkspaceId!)); + await rm(source, { recursive: true }); + // A task workspace archived by hand (no terminal-cleanup reason) and later + // imported into remote storage. Its saved snapshot must stay untouched. + const remoteWorkspace = { schema: "paperclip.remote-workspace.v1", epoch: 1, snapshotId: randomUUID(), + source: { kind: "git", repoUrl: "https://github.com/example/remote.git", ref: "0123456789abcdef0123456789abcdef01234567", + branchName: "test-WSP-1" }, location: null, writerRunId: null, dirty: false }; + const [retired] = await db.insert(executionWorkspaces).values({ companyId: issue.companyId, + sourceIssueId: issue.id, projectId: issue.projectId, projectWorkspaceId: issue.projectWorkspaceId, + name: "Retired sandbox workspace", cwd: `/workspaces/${randomUUID()}`, providerType: "cloud_sandbox", strategyType: "git_worktree", + mode: "isolated_workspace", status, closedAt: new Date(), cleanupReason: null, metadata: { remoteWorkspace } }).returning(); + const [boundIssue] = await db.update(issues).set({ executionWorkspaceId: retired.id, executionWorkspacePreference: "reuse_existing" }) + .where(eq(issues.id, issue.id)).returning(); + input.task.issueRef = boundIssue; + input.reuse.workspaceReuseRequest = resolveExecutionWorkspaceReuseRequestForIssue({ issueExecutionWorkspaceId: retired.id, + issueExecutionWorkspacePreference: "reuse_existing", existingExecutionWorkspaceStatus: status }); + input.reuse.requestedShouldReuseExisting = input.reuse.workspaceReuseRequest.requestedShouldReuseExisting; + input.reuse.existingExecutionWorkspace = toExecutionWorkspace(retired); + input.reuse.reusableExistingExecutionWorkspace = input.reuse.workspaceReuseRequest.existingExecutionWorkspaceAvailable + ? toExecutionWorkspace(retired) : null; + let acquiredWorkspaceId: string | null = null; + vi.spyOn(envOrchestrator, "acquireForRun").mockImplementation(async args => { + acquiredWorkspaceId = args.persistedExecutionWorkspace?.id ?? null; + throw new Error("reached remote acquisition"); + }); + configureRemotePersistence(); + process.env.PAPERCLIP_EPHEMERAL_SERVER = storageEnabled ? "true" : "false"; + + await expect(prepareHeartbeatWorkspace(db, input)).rejects.toThrow("reached remote acquisition"); + + expect(acquiredWorkspaceId).not.toBeNull(); + expect(acquiredWorkspaceId).not.toBe(retired.id); + const [replacement] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, acquiredWorkspaceId!)); + expect(replacement).toMatchObject({ sourceIssueId: issue.id, status: "active", providerType: "cloud_sandbox", mode: "isolated_workspace" }); + expect(replacement.metadata?.remoteWorkspace).toMatchObject({ epoch: 1, snapshotId: null, writerRunId: input.run.id, + source: { kind: "git", repoUrl: "https://github.com/example/remote.git", ref: "main", branchName: "test-WSP-1" } }); + expect(await readIssue(issue.id)).toMatchObject({ executionWorkspaceId: replacement.id, + workspaceBindingRevision: boundIssue.workspaceBindingRevision + 1 }); + const [unchanged] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, retired.id)); + expect(unchanged).toMatchObject({ status, cleanupReason: null, metadata: retired.metadata }); + }); + + it("keeps refusing a native recovery bound to a task workspace that was archived", async () => { + const { input, issue } = await fixture(true); + const [savedEnvironment] = await db.insert(environments).values({ name: `Remote ${randomUUID()}`, + driver: "sandbox", status: "active", config: { provider: "daytona" } }).returning(); + input.agent.adapterType = "paperclip_runner"; + input.environment.selectedEnvironmentForConfig = await environmentService(db).getById(savedEnvironment.id); + input.environment.selectedEnvironmentId = savedEnvironment.id; + const remoteWorkspace = { schema: "paperclip.remote-workspace.v1", epoch: 1, snapshotId: randomUUID(), + source: { kind: "empty" }, location: null, writerRunId: null, dirty: false }; + const [retired] = await db.insert(executionWorkspaces).values({ companyId: issue.companyId, + sourceIssueId: issue.id, projectId: issue.projectId, projectWorkspaceId: issue.projectWorkspaceId, + name: "Retired sandbox workspace", cwd: `/workspaces/${randomUUID()}`, providerType: "cloud_sandbox", strategyType: "git_worktree", + mode: "isolated_workspace", status: "archived", closedAt: new Date(), metadata: { remoteWorkspace } }).returning(); + await db.update(issues).set({ executionWorkspaceId: retired.id, executionWorkspacePreference: "reuse_existing" }) + .where(eq(issues.id, issue.id)); + input.reuse.existingExecutionWorkspace = toExecutionWorkspace(retired); + input.reuse.nativeRecoveryExecutionWorkspaceId = retired.id; + configureRemotePersistence(); + + await expect(prepareHeartbeatWorkspace(db, input)).rejects.toMatchObject({ status: 409, + details: { code: "remote_workspace_retired" } }); + expect((await readIssue(issue.id)).executionWorkspaceId).toBe(retired.id); + expect(await db.select({ id: executionWorkspaces.id }).from(executionWorkspaces) + .where(eq(executionWorkspaces.sourceIssueId, issue.id))).toHaveLength(1); + }); + it.each([ { kind: "empty", repoUrl: null, branchMode: null, fresh: false, strategyChange: false, ephemeral: true }, { kind: "git", repoUrl: "https://github.com/example/remote.git", branchMode: null, fresh: false, strategyChange: false }, diff --git a/server/src/services/heartbeat/workspace-preparation.ts b/server/src/services/heartbeat/workspace-preparation.ts index 1a582f1af6a..f770869bbbd 100644 --- a/server/src/services/heartbeat/workspace-preparation.ts +++ b/server/src/services/heartbeat/workspace-preparation.ts @@ -1,7 +1,7 @@ import { NATIVE_REMOTE_RECOVERY_LEASE_MISMATCH, remoteRecoveryLeaseMismatch } from "../native-runtime/remote-recovery-lease-mismatch.js"; import { readInheritedRunnerRetainedSandbox } from "../native-runtime/native-inherited-runner-retry.js"; import { resolveProviderApiPlacement } from "../native-runtime/provider-api-placement.js"; -import { assertEphemeralWorkspaceExecution, readRemoteWorkspaceAuthority, RemoteWorkspaceWriterActiveError, reserveRemoteWorkspace, shouldUseRemoteWorkspaces, supportsRemoteWorkspaceExecution } from "../remote-workspaces.js"; +import { assertEphemeralWorkspaceExecution, isRetiredExecutionWorkspaceStatus, readRemoteWorkspaceAuthority, RemoteWorkspaceWriterActiveError, reserveRemoteWorkspace, shouldUseRemoteWorkspaces, supportsRemoteWorkspaceExecution } from "../remote-workspaces.js"; import { assertProjectStorageEnvironment, listProjectWorkspaceProviders, projectStorageForEnvironment } from "../project-workspace-provider.js"; import { PROJECT_STORAGE_ENVIRONMENT_INCOMPATIBLE } from "../project-storage-environment-reason.js"; import { REMOTE_WORKSPACE_ENVIRONMENT_INCOMPATIBLE } from "../remote-workspace-environment-reason.js"; @@ -253,6 +253,21 @@ async function prepareHeartbeatWorkspaceLocked(db: Db, input: HeartbeatWorkspace isDotRun, runOptions, } = input.reuse; + // A retired remote task workspace is not reused, as for a retired host + // workspace: the run starts a new one. The task still uses remote storage, + // so the retired workspace keeps deciding the storage authority. A native + // recovery or a saved Retry stays bound to the workspace it admitted and + // still gets the conflict. + const boundTaskWorkspace = reusableExistingExecutionWorkspace ?? existingExecutionWorkspace; + let retiredRemoteWorkspace: ExecutionWorkspace | null = null; + if (boundTaskWorkspace && isRetiredExecutionWorkspaceStatus(boundTaskWorkspace.status) + && readRemoteWorkspaceAuthority(boundTaskWorkspace.metadata) + && !nativeRecoveryExecutionWorkspaceId && !persistedNativeExecutionInput && !input.task.freshWorkspace) { + retiredRemoteWorkspace = boundTaskWorkspace; + existingExecutionWorkspace = null; + reusableExistingExecutionWorkspace = null; + requestedShouldReuseExisting = false; + } // An ordinary clean task directory already has a new per-attempt identity. // It is not a repository source and must not pass through Git copy admission. const controllerOnly = isDotRun || providerApiPlacement !== null; @@ -281,7 +296,7 @@ async function prepareHeartbeatWorkspaceLocked(db: Db, input: HeartbeatWorkspace { reason: "remote_workspace_migration_in_progress" }); } } - const enrolledRemoteWorkspace = reusableExistingExecutionWorkspace ?? existingExecutionWorkspace; + const enrolledRemoteWorkspace = reusableExistingExecutionWorkspace ?? existingExecutionWorkspace ?? retiredRemoteWorkspace; const enrolledRemoteAuthority = readRemoteWorkspaceAuthority(enrolledRemoteWorkspace?.metadata) !== null; if (!controllerOnly && enrolledRemoteAuthority && !supportsRemoteWorkspaceExecution(agent.adapterType, selectedEnvironmentForConfig?.driver ?? null)) { @@ -310,7 +325,7 @@ async function prepareHeartbeatWorkspaceLocked(db: Db, input: HeartbeatWorkspace environmentDriver: selectedEnvironmentForConfig?.driver ?? null, experimentalEnabled: (process.env.PAPERCLIP_EPHEMERAL_SERVER === "true" || resolvedInstanceSettings.experimental.remoteWorkspaceStorageEnabled) && Boolean(issueId && issueRef) && !projectExecutionWorkspacePolicy?.storageProviderPluginId, - existingWorkspace: reusableExistingExecutionWorkspace ?? existingExecutionWorkspace, + existingWorkspace: enrolledRemoteWorkspace, }); const projectStorageEnvironmentIncompleteFailure = (details: { message: string; diff --git a/server/src/services/remote-workspaces.integration.test.ts b/server/src/services/remote-workspaces.integration.test.ts index cdda1b06bdc..be36532b7a5 100644 --- a/server/src/services/remote-workspaces.integration.test.ts +++ b/server/src/services/remote-workspaces.integration.test.ts @@ -313,6 +313,27 @@ suite("remote workspace lifecycle with real Postgres and independent filesystem status: 409, message: "Workspace ownership changed.", details: { code: "remote_workspace_retired" } }); }); + it.each(["archived", "cleanup_failed"] as const)("replaces a task's binding to its own %s workspace when no workspace is requested", async status => { + const reserved = await reserve({ kind: "empty" }); + await db.update(heartbeatRuns).set({ status: "succeeded", finishedAt: new Date() }).where(eq(heartbeatRuns.id, ids.run)); + const [retired] = await db.update(executionWorkspaces).set({ status }).where(eq(executionWorkspaces.id, reserved.id)).returning(); + const [before] = await db.select().from(issues).where(eq(issues.id, ids.issue)); + expect(before.executionWorkspaceId).toBe(retired.id); + const nextRun = randomUUID(); + await db.insert(heartbeatRuns).values({ id: nextRun, companyId: ids.company, agentId: ids.agent, + nativeIssueId: ids.issue, runtimeMode: "native", status: "running" }); + const replacement = await reserveRemoteWorkspace({ db, storage, companyId: ids.company, issueId: ids.issue, + runId: nextRun, agentId: ids.agent, environmentId: ids.environment, projectId: null, projectWorkspaceId: null, + existingWorkspaceId: null, source: { kind: "empty" } }); + expect(replacement.id).not.toBe(retired.id); + expect(replacement).toMatchObject({ status: "active", sourceIssueId: ids.issue, + metadata: { remoteWorkspace: { epoch: 1, snapshotId: null, writerRunId: nextRun } } }); + const [after] = await db.select().from(issues).where(eq(issues.id, ids.issue)); + expect(after).toMatchObject({ executionWorkspaceId: replacement.id, workspaceBindingRevision: before.workspaceBindingRevision + 1 }); + const [unchanged] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, retired.id)); + expect(unchanged).toMatchObject({ status, metadata: retired.metadata }); + }); + it.each(["initial", "follow-up"] as const)("edits and cold-restores both an anchor and a referenced project's task copy (%s attachment)", async attachment => { vi.stubEnv("PAPERCLIP_MULTI_PROJECT_WORKSPACE_SYNC", "true"); vi.stubEnv("PAPERCLIP_MULTI_PROJECT_WORKSPACE_SYNC_REMOTE", "true"); diff --git a/server/src/services/remote-workspaces.ts b/server/src/services/remote-workspaces.ts index 8311367959e..3e61db81722 100644 --- a/server/src/services/remote-workspaces.ts +++ b/server/src/services/remote-workspaces.ts @@ -199,6 +199,12 @@ async function lockWorkspaceRunParents(tx: Transaction, companyId: string, runId return issueId; } +// An archived workspace, or one whose cleanup failed, is retired. A run never +// writes to it again; the task continues in a new workspace instead. +export function isRetiredExecutionWorkspaceStatus(status: string | null | undefined) { + return status === "archived" || status === "cleanup_failed"; +} + export class RemoteWorkspaceWriterActiveError extends HttpError { constructor( readonly workspaceId: string, @@ -230,6 +236,13 @@ export async function reserveRemoteWorkspace(input: { if (input.fresh && (issue.executionWorkspaceId !== input.fresh.previousWorkspaceId || issue.workspaceBindingRevision !== input.fresh.expectedBindingRevision)) throw conflict("The task workspace selection changed."); let selected = input.fresh ? input.fresh.attemptId : input.existingWorkspaceId ?? issue.executionWorkspaceId; + // Without a workspace chosen by the caller, a task still bound to a retired + // workspace gets a new one. The retired row and its snapshot stay unchanged. + if (!input.fresh && !input.existingWorkspaceId && selected) { + const [bound] = await tx.select({ status: executionWorkspaces.status }).from(executionWorkspaces).where(and( + eq(executionWorkspaces.companyId, input.companyId), eq(executionWorkspaces.id, selected))).for("update"); + if (bound && isRetiredExecutionWorkspaceStatus(bound.status)) selected = null; + } let selectedSharedSource = false; if (!selected && input.mode === "shared_workspace" && input.projectWorkspaceId) { await tx.execute(sql`select pg_advisory_xact_lock(hashtextextended(${`remote-shared-workspace:${input.companyId}:${input.projectWorkspaceId}`}, 0))`); @@ -247,7 +260,7 @@ export async function reserveRemoteWorkspace(input: { let authority = readRemoteWorkspaceAuthority(existing?.metadata); if (existing && !authority) throw conflict("Import this existing workspace before enabling remote storage.", { code: "remote_workspace_migration_required" }); if (existing && authority) { - if (["archived", "cleanup_failed"].includes(existing.status)) throw conflict("Workspace ownership changed.", { code: "remote_workspace_retired" }); + if (isRetiredExecutionWorkspaceStatus(existing.status)) throw conflict("Workspace ownership changed.", { code: "remote_workspace_retired" }); if (existing.sourceIssueId !== input.issueId) { const actor = { type: "agent", source: "agent_jwt", companyId: input.companyId, agentId: input.agentId, runId: input.runId, From 07150650c926d8947ae591f61e4ed854ca284149 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 15:12:47 -0800 Subject: [PATCH 003/119] test(runner): drain reattachment writers before deleting state (#23673) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip manages agent work through durable Runner sessions. > - Release images require Cloud readiness for their exact source commit. > - A reattachment test keeps a slow event backlog active during controller recovery. > - Its bounded close can return before queued journal writes finish. > - The fixture then deletes the state directory and can fail with `ENOTEMPTY`. > - This pull request joins the fixture writers before it removes their files. ## Linked Issues or Issue Description **What happened?** [Docker run 47193580475](https://github.com/paperclipai/paperclip/actions/runs/47193580475/attempts/1) was cancelled after [Cloud readiness protocol lane 4/4](https://github.com/paperclipai/paperclip/actions/runs/47193580507/job/144565884014) failed. The event-backlog reattachment test reported `ENOTEMPTY` while removing its control-plane directory. A rerun passed on the same source commit, without fixing the race. **Expected behavior** The fixture must finish all admitted writes and stop its child before it deletes state, including when the transport close deadline expires. **Steps to reproduce** Run `runnerd-codex-transport-reattach-carried-commands.test.ts` with a one-millisecond close budget for the event-backlog case. Before this fix, the new cleanup assertion finds one accounting callback still active. **Paperclip version or commit** Observed on `23ca89e3764377224bc43527bdfa547e9608f1db`. The fix starts from `7e025ae65f9050030edf4d2cab006aa981569261`. **Deployment mode** Source checkout in GitHub Actions. Local reproduction uses macOS arm64, Node 25.6.1, and the real Rust Runner with the hermetic fake Codex fixture. Searched open PRs and issues for `ENOTEMPTY`, carried commands, and Runner teardown. No duplicate fix was found. Related earlier work: #21161 and #21442. ## What Changed - Retain all registered fixture authorities, including the detached controller. - Disable new upgrades, confirm the original child exited, stop authorities, and drain admitted connection processing before deleting state. - Exercise an expired close budget in the existing backlog case. Assert that accounting writes have finished before deletion. - The fixture owns this cleanup. Runtime close behavior and its deadlines do not change. ## Verification - Red: the focused backlog test fails with `state cleanup must wait for admitted event writes: expected 1 to be +0` before the teardown fix. - Green: `pnpm exec vitest run src/live/runnerd-codex-transport-reattach-carried-commands.test.ts` from the Runner package: 11 passed, retries disabled. - `pnpm exec tsc -p tsconfig.test.json --noEmit` from the Runner package: passed. - `git diff --check` and local secret/PII diff review: passed. - `pnpm verify --explain`: exit 2. The conservative selector cannot resolve this Runner test graph. Focused local checks passed; required PR CI supplies the broader coverage. - Tested file contents match PR head `0a6b92e026ae0fdd684cd0e8e2ff7cf513732a02`. - Final review: all 90 checks are clean, GitHub reports `CLEAN` / `MERGEABLE`, and there are no unresolved review threads. The branch includes current `master`. - An initial local attempt could not run because debug binaries were not built yet. Agent preflight completed before the red-green run. - [Linux Runner Vitest lanes 1–6](https://github.com/paperclipai/paperclip/actions/runs/47222552156): passed on PR head. Typecheck, build, Runner static checks, and support suites also passed. - [Greptile review](https://github.com/paperclipai/paperclip/pull/23673#issuecomment-7394943956): 5/5 on PR head, no actionable findings or review threads. The current-head check passed. - [Server shard 14/20](https://github.com/paperclipai/paperclip/actions/runs/47222552156/job/144668670033) was cancelled after its runner received a shutdown signal. This is recorded runner loss, not an assertion failure. The repository started attempt 2 automatically on the same PR head. The retry passed and the full [PR CI workflow](https://github.com/paperclipai/paperclip/actions/runs/47222552156/attempts/2) completed successfully. Both Runner image builds, the macOS runtime build, and all security scans also passed. ## Risks Low risk. Only one test fixture changes. Teardown now waits for its admitted writes instead of deleting their directory early. A stuck write can fail the existing test timeout and preserve the state directory. No schema, API, deployment, or runtime behavior changes. The code and regression test describe the behavior; no documentation update is needed. ## Model Used OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, with xhigh reasoning effort, shell and file tools. The harness does not expose the context window size. ## 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 Co-authored-by: Paperclip --- ...x-transport-reattach-carried-commands.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/paperclip-runner/src/live/runnerd-codex-transport-reattach-carried-commands.test.ts b/packages/paperclip-runner/src/live/runnerd-codex-transport-reattach-carried-commands.test.ts index bed9654e2df..24f2aa4238f 100644 --- a/packages/paperclip-runner/src/live/runnerd-codex-transport-reattach-carried-commands.test.ts +++ b/packages/paperclip-runner/src/live/runnerd-codex-transport-reattach-carried-commands.test.ts @@ -17,6 +17,7 @@ async function reattachWithCarriedCommands(carried: Carried) { const controlPlaneStatePath = join(stateDirectory, "control-plane", "control-plane-state.json"); const server = createServer(); let authority: DurablePrpControlPlane | null = null; + const authorities = new Set(); server.on("upgrade", (request, socket, head) => { if (!authority) { socket.destroy(); @@ -29,6 +30,7 @@ async function reattachWithCarriedCommands(carried: Carried) { if (!address || typeof address === "string") throw new Error("Expected a reattachment test listener"); const registration = vi.fn(async (next: DurablePrpControlPlane) => { authority = next; + authorities.add(next); return { connectUrl: `ws://127.0.0.1:${address.port}/runner`, release: async () => { @@ -61,6 +63,7 @@ async function reattachWithCarriedCommands(carried: Carried) { first.transport.setServerRequestHandler(lateTool); let adopted: ReturnType | null = null; let runnerPid: number | null = null; + let pendingAccountingEvents = 0; try { const opened = (await first.transport.request("thread/start", { cwd: tmpdir(), @@ -126,8 +129,14 @@ async function reattachWithCarriedCommands(carried: Carried) { const redispatched = vi.fn(async () => ({ success: true, contentItems: [] })); adopted = createCapabilityRunnerdCodexTransport({ ...options, + ...(carried === "event-backlog" ? { closeGraceMs: 1 } : {}), onAccountingEvent: async () => { - if (carried === "event-backlog") await new Promise(resolveWait => setTimeout(resolveWait, 100)); + pendingAccountingEvents += 1; + try { + if (carried === "event-backlog") await new Promise(resolveWait => setTimeout(resolveWait, 100)); + } finally { + pendingAccountingEvents -= 1; + } }, resumeDynamicTools: toolCall ? [taskTool] : [], resumeProviderSession: { driverSessionId: opened.id, providerSessionId: opened.sessionId }, @@ -164,11 +173,16 @@ async function reattachWithCarriedCommands(carried: Carried) { } finally { await adopted?.transport.close().catch(() => undefined); await first.transport.close().catch(() => undefined); + authority = null; if (runnerPid) { try { process.kill(-runnerPid, "SIGKILL"); } catch { /* already exited */ } + await vi.waitFor(() => expect(() => process.kill(runnerPid!, 0)).toThrow(), { timeout: 5_000 }); } + for (const core of authorities) await core.stop(); server.closeAllConnections(); if (server.listening) await new Promise(resolveClose => server.close(() => resolveClose())); + for (const core of authorities) await core.drainPendingConnectionProcessing(); + expect(pendingAccountingEvents, "state cleanup must wait for admitted event writes").toBe(0); await rm(stateDirectory, { recursive: true, force: true }); } } From ba521863f6090e40a37ed3cb6b1ecaf358a11424 Mon Sep 17 00:00:00 2001 From: Nicky Leach Date: Thu, 3 Dec 2026 15:29:50 -0800 Subject: [PATCH 004/119] perf(skills): import environment skills when a setup draft is created (#23672) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A plugin environment driver can declare `skillKeys`. Core adds those managed skills to each run on the environment. > - Before a run can use a skill, Core imports it into the company's skill library. This occurs once for each company. > - The import occurs when the first task starts. So the first task in a new company waits for it. > - Each missing skill is imported in its own transaction. Each import checks all bundled skills two times, and the transactions do not share that check. > - This pull request starts the import when a person creates a setup draft, and checks the bundled skills once. > - The benefit is that the first task starts sooner. The setup does not wait for the import. ## Linked Issues or Issue Description I searched the open and closed issues and pull requests. I did not find a duplicate. **What happened?** The first task on a plugin environment with four managed skills spent more than ten seconds in skill import. Most of this time was the check and first import of Core's bundled skills. That check ran again for each managed skill. **Expected behavior** The import must start before the first task, while the person completes setup. One import must check the bundled skills once. **Steps to reproduce** 1. Install a plugin with an environment driver that declares several `skillKeys`. 2. Make that environment the instance default. 3. Create a company, set up its first agent, and give it a task. 4. Measure the skill selection part of the first run's preparation. **Paperclip version or commit** `7e025ae65f` **Deployment mode** Self-hosted server with a plugin environment that declares managed skills. ## What Changed - When a person creates a setup draft, the server imports the environment's missing skills in the background. The response does not wait for this import. - A failed background import writes a warning. It does not change the draft. Run admission still installs the skills that are missing. - The background import is counted as active work, so an idle drain waits for it. It runs once and does not poll or retry. - An environment skill import checks the bundled skills once before it installs the missing skills. Before, each skill did this check two times in its own transaction. - `importPackageFiles` reads the library rows after its own inventory check. It no longer does the check a second time. - `doc/skills-and-teams-catalog.md` describes the new behavior. Skill selection, version pins, and the files that a run receives do not change. ## Verification - `npx vitest run src/__tests__/environment-skills.test.ts`: 7 passed. Two tests are new. They fail when I remove the single check and the background import. - `npx vitest run` on the company skill service, managed skill content, company portability, agent adapter validation, and agent lifecycle tests: all passed. - `src/__tests__/ai-connections.test.ts`: 5 of its tests failed in the same local run. The reconnect tests also fail at `7e025ae65f` without this change on the same local database. They do not use this code. - `pnpm --filter @paperclipai/server typecheck`: passed. - Not done: a measurement of the first task with this change. ## Risks - A draft that a person abandons leaves the imported skills in the company library. The same skills are imported for the next agent on that environment. - The background import and a first task can run together. The existing lock for each skill makes the second one wait and use the first result. - The bundled skill check now runs outside the skill's transaction. If the skill import then fails, the bundled skills remain imported. They are imported by other library reads too. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code, with extended thinking, tool use and code execution. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- doc/skills-and-teams-catalog.md | 5 +- .../src/__tests__/environment-skills.test.ts | 51 ++++++++++++++++++- server/src/routes/agents.ts | 2 + server/src/services/company-skills.ts | 6 ++- server/src/services/environment-skills.ts | 24 +++++++-- server/src/services/plugin-managed-skills.ts | 7 +-- 6 files changed, 84 insertions(+), 11 deletions(-) diff --git a/doc/skills-and-teams-catalog.md b/doc/skills-and-teams-catalog.md index 82ae2af7d7d..994317c4bf7 100644 --- a/doc/skills-and-teams-catalog.md +++ b/doc/skills-and-teams-catalog.md @@ -58,7 +58,10 @@ manifest-managed skills. Selecting that environment adds those skills to the normal authorized skill selection, including an explicitly empty optional selection. Core installs a missing managed skill in the current company's library during lifecycle reconciliation or new-run admission and preserves existing -skill edits and explicit version pins. New managed skills use +skill edits and explicit version pins. When a person creates a setup draft, Core +also starts this installation once in the background. The draft does not wait for +it. A failure is logged, and the next run installs the missing skills. One +installation checks Core's bundled skills once, for all missing keys. New managed skills use `plugin--` for both the library slug and SKILL.md name. The short ID is the final dot-separated plugin ID component, without a leading `plugin-`. An unrelated skill can keep the same slug in a separate canonical diff --git a/server/src/__tests__/environment-skills.test.ts b/server/src/__tests__/environment-skills.test.ts index 346cb42db13..c26dadaf488 100644 --- a/server/src/__tests__/environment-skills.test.ts +++ b/server/src/__tests__/environment-skills.test.ts @@ -2,12 +2,16 @@ import { createHash, randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { and, eq } from "drizzle-orm"; +import { and, eq, sql } from "drizzle-orm"; import { agents, companies, companySkills, createDb, environments, pluginCompanySettings, plugins, resourceLifecycleEvents, type Db } from "@paperclipai/db"; import type { PaperclipPluginManifestV1 } from "@paperclipai/shared"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { getEmbeddedPostgresTestSupport, startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js"; +import express from "express"; +import request from "supertest"; import { environmentSkillConfig } from "../services/environment-skills.js"; +import { agentRoutes } from "../routes/agents.js"; +import { errorHandler } from "../middleware/error-handler.js"; import { pluginAgentRuntimeState } from "../services/plugin-agent-runtime-state.js"; import { companySkillService } from "../services/company-skills.js"; import { instanceSettingsService } from "../services/instance-settings.js"; @@ -177,6 +181,51 @@ describeDatabase("environment managed skills", () => { expect(restored!.skills.map(skill => skill.key)).toEqual([original.key]); expect(restored!.shadowedSkills).toBeUndefined(); }); + it("checks the bundled skills once for every skill that it installs", async () => { + const skills = ["second", "third"].map(skillKey => ({ skillKey, displayName: skillKey })); + await db.update(plugins).set({ manifestJson: { ...manifest, skills: [...manifest.skills!, ...skills], + environmentDrivers: manifest.environmentDrivers!.map(driver => ({ ...driver, skillKeys: ["computer-use", "second", "third"] })) } }).where(eq(plugins.id, pluginId)); + const readFile = vi.spyOn(fs, "readFile"); + const bundledChecks = () => readFile.mock.calls.filter(([file]) => String(file).endsWith(path.join("skills", "first-task", "SKILL.md"))).length; + try { + await companySkillService(db).refreshInventory(companyId); + const readsPerCheck = bundledChecks(); + expect(readsPerCheck).toBeGreaterThan(0); + expect((await environmentSkillConfig(db, companyId, environment, {})).skillKeys).toHaveLength(3); + expect(bundledChecks()).toBe(readsPerCheck * 2); + await environmentSkillConfig(db, companyId, environment, {}); + expect(bundledChecks()).toBe(readsPerCheck * 2); + } finally { readFile.mockRestore(); } + }); + it("imports the skills in the background when a setup draft is created", async () => { + const [env] = await db.insert(environments).values({ name: randomUUID(), ...environment, status: "active" }).returning(); + await instanceSettingsService(db).update({ defaultEnvironmentId: env.id }); + const app = express(); app.use(express.json()); + app.use((req, _res, next) => { req.actor = { type: "board", source: "local_implicit", userId: "owner", isInstanceAdmin: true, companyIds: [companyId] }; next(); }); + app.use("/api", agentRoutes(db)); app.use(errorHandler); + const create = (name: string) => request(app).post(`/api/companies/${companyId}/agents`).send({ name, adapterType: "process", setupId: randomUUID() }); + const installed = () => db.select().from(companySkills).where(and(eq(companySkills.companyId, companyId), eq(companySkills.key, `plugin/fixture-${pluginId}/computer-use`))); + try { + await db.update(plugins).set({ status: "disabled" }).where(eq(plugins.id, pluginId)); + expect((await create("Unavailable")).status).toBe(201); + expect(await installed()).toHaveLength(0); + await db.update(plugins).set({ status: "ready" }).where(eq(plugins.id, pluginId)); + const held = Promise.withResolvers(), release = Promise.withResolvers(); + const lock = db.transaction(async tx => { + await tx.execute(sql`select pg_advisory_xact_lock(hashtextextended(${`environment-skill:${companyId}:${pluginId}:computer-use`}, 0))`); + held.resolve(); + await release.promise; + }); + try { + await held.promise; + let status: number | undefined; + void create("Draft").then(response => { status = response.status; }); + await vi.waitFor(() => expect(status).toBe(201), { timeout: 15_000, interval: 50 }); + expect(await installed()).toHaveLength(0); + } finally { release.resolve(); await lock; } + await vi.waitFor(async () => expect(await installed()).toHaveLength(1), { timeout: 20_000, interval: 50 }); + } finally { await instanceSettingsService(db).update({ defaultEnvironmentId: null }); } + }); it("keeps installations company-scoped and rejects disabled providers", async () => { const peerId = randomUUID(); await db.insert(companies).values({ id: peerId, name: "Peer", issuePrefix: `P${peerId.slice(0, 6)}` }); diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index 254d0ea7250..df57f996826 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -157,6 +157,7 @@ import { collectAgentAdapterWorkspaceCommandPaths, } from "./workspace-command-authz.js"; import type { PluginWorkerManager } from "../services/plugin-worker-manager.js"; +import { importAgentEnvironmentSkillsInBackground } from "../services/environment-skills.js"; import { environmentService } from "../services/environments.js"; import { environmentRuntimeService } from "../services/environment-runtime.js"; @@ -5119,6 +5120,7 @@ export function agentRoutes( if (!(await assertAgentReadAllowed(req, res, createdAgent))) return; await assertCanReadConfigurations(req, companyId); } + importAgentEnvironmentSkillsInBackground(db, createdAgent); res.status(201).json({ ...redactAgentRowForResponse(createdAgent), ...(configurationWarnings.length ? { configurationWarnings } : {}) }); return; } diff --git a/server/src/services/company-skills.ts b/server/src/services/company-skills.ts index 3f10ab7b36a..8962be1b9ab 100644 --- a/server/src/services/company-skills.ts +++ b/server/src/services/company-skills.ts @@ -6314,9 +6314,10 @@ export function companySkillService(db: Db, options: { actor?: AuthorizationActo onConflict?: PackageSkillConflictStrategy; /** Managed plugin namespaces may share a slug while retaining separate canonical records. */ allowSlugCollision?: boolean; + skipInventoryRefresh?: boolean; }, ): Promise { - await ensureSkillInventoryCurrent(companyId); + if (!options?.skipInventoryRefresh) await ensureSkillInventoryCurrent(companyId); const normalizedFiles = normalizePackageFileMap(files); const importedSkills = readInlineSkillImports(companyId, normalizedFiles); if (importedSkills.length === 0) return []; @@ -6330,7 +6331,7 @@ export function companySkillService(db: Db, options: { actor?: AuthorizationActo } const conflictStrategy = options?.onConflict ?? "skip"; - const existingSkills = await listFull(companyId); + const existingSkills = await readFullSkillRows(companyId); const existingByKey = new Map(existingSkills.map((skill) => [skill.key, skill])); const existingBySlug = new Map( existingSkills.map((skill) => [normalizeSkillSlug(skill.slug) ?? skill.slug, skill]), @@ -7641,6 +7642,7 @@ export function companySkillService(db: Db, options: { actor?: AuthorizationActo browseProjectWorkspace, scanProjectWorkspaces, importPackageFiles, + refreshInventory: ensureSkillInventoryCurrent, auditSkill, installUpdate, resetSkill, diff --git a/server/src/services/environment-skills.ts b/server/src/services/environment-skills.ts index 1f922c8a5c1..1c3d4aaa9f0 100644 --- a/server/src/services/environment-skills.ts +++ b/server/src/services/environment-skills.ts @@ -2,8 +2,23 @@ import { and, eq, inArray, or, sql } from "drizzle-orm"; import { companySkills, pluginCompanySettings, pluginManagedResources, plugins, type Db } from "@paperclipai/db"; import { readPaperclipSkillSyncPreference, resolvePaperclipDesiredSkillNames, writePaperclipSkillSyncPreference } from "@paperclipai/adapter-utils/server-utils"; import { unprocessable } from "../errors.js"; -import { buildSkillRuntimeName } from "./company-skills.js"; +import { buildSkillRuntimeName, companySkillService } from "./company-skills.js"; +import { environmentService } from "./environments.js"; +import { instanceSettingsService } from "./instance-settings.js"; import { pluginManagedSkillService } from "./plugin-managed-skills.js"; +import { trackIdleWork } from "./task-admission.js"; +import { logger } from "../middleware/logger.js"; + +export async function importAgentEnvironmentSkills(db: Db, agent: { companyId: string; defaultEnvironmentId: string | null }) { + const environmentId = agent.defaultEnvironmentId ?? (await instanceSettingsService(db).get()).defaultEnvironmentId; + const environment = environmentId ? await environmentService(db).getById(environmentId) : null; + await environmentSkillConfig(db, agent.companyId, environment, {}); +} + +export function importAgentEnvironmentSkillsInBackground(db: Db, agent: { id: string; companyId: string; defaultEnvironmentId: string | null }) { + void trackIdleWork(importAgentEnvironmentSkills(db, agent)).catch(err => + logger.warn({ err, agentId: agent.id, companyId: agent.companyId }, "Could not import environment skills during agent setup")); +} /** Environment capabilities join the normal authorized, versioned skill selection. */ export async function environmentSkillConfig(db: Db, companyId: string, @@ -27,12 +42,13 @@ export async function environmentSkillConfig(db: Db, companyId: string, .where(and(eq(pluginManagedResources.companyId, companyId), eq(pluginManagedResources.pluginId, plugin.id), eq(pluginManagedResources.resourceKind, "skill"), inArray(pluginManagedResources.resourceKey, keys))); const selected = new Map(installed.map(skill => [skill.resourceKey, skill.key])); - for (const key of keys) { - if (selected.has(key) || !installMissing) continue; + const missing = installMissing ? keys.filter(key => !selected.has(key)) : []; + if (missing.length) await companySkillService(db).refreshInventory(companyId); + for (const key of missing) { const result = await db.transaction(async tx => { // Serialize first installation across concurrent agents in this company. await tx.execute(sql`select pg_advisory_xact_lock(hashtextextended(${`environment-skill:${companyId}:${plugin.id}:${key}`}, 0))`); - return pluginManagedSkillService(tx as unknown as Db, { pluginId: plugin.id, pluginKey, manifest: plugin.manifestJson }).reconcile(key, companyId); + return pluginManagedSkillService(tx as unknown as Db, { pluginId: plugin.id, pluginKey, manifest: plugin.manifestJson }).reconcile(key, companyId, { skipInventoryRefresh: true }); }); if (!result.skill) throw unprocessable("Environment skill is unavailable"); selected.set(key, result.skill.key); diff --git a/server/src/services/plugin-managed-skills.ts b/server/src/services/plugin-managed-skills.ts index 021446e737a..c7b8c558452 100644 --- a/server/src/services/plugin-managed-skills.ts +++ b/server/src/services/plugin-managed-skills.ts @@ -280,6 +280,7 @@ export function pluginManagedSkillService( companyId: string, declaration: PluginManagedSkillDeclaration, mode: "reconcile" | "reset", + skipInventoryRefresh = false, ) { const beforeByKey = mode === "reconcile" ? await skills.getByKey(companyId, canonicalSkillKey(options.pluginKey, declaration.skillKey)) @@ -291,7 +292,7 @@ export function pluginManagedSkillService( const results = await skills.importPackageFiles( companyId, buildPackageFiles(options.pluginKey, declaration), - { onConflict: "replace", allowSlugCollision: true }, + { onConflict: "replace", allowSlugCollision: true, skipInventoryRefresh }, ); const imported = results.find((result) => result.skill.key === canonicalSkillKey(options.pluginKey, declaration.skillKey) @@ -314,14 +315,14 @@ export function pluginManagedSkillService( return resolvedSkill(companyId, declaration, skill, skill ? "resolved" : "missing"); } - async function reconcile(skillKey: string, companyId: string) { + async function reconcile(skillKey: string, companyId: string, reconciliation: { skipInventoryRefresh?: boolean } = {}) { const declaration = declarationFor(skillKey); const current = await get(skillKey, companyId); if (current.skill) { await upsertBinding(companyId, declaration, current.skill.id); return current; } - const imported = await importDeclaredSkill(companyId, declaration, "reconcile"); + const imported = await importDeclaredSkill(companyId, declaration, "reconcile", reconciliation.skipInventoryRefresh); await logActivity(db, { companyId, actorType: "plugin", From 86042310917c15eb04be121baf58a6929e52a7d2 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 15:47:31 -0800 Subject: [PATCH 005/119] docs(release): stable notes for the 2026.1203.0-beta.0 soak (v2026.1206.0) (#23580) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The release process promotes a soaked beta to stable. The stable GitHub Release body comes from `releases/beta/v.md` on `master` > - Beta `2026.1203.0-beta.0` published in workflow run 47005574134. Its `draft_stable_notes` job pushed a commit-log skeleton to this branch > - The skeleton is a raw commit list. It is not usable as release notes > - This pull request replaces the skeleton with curated stable notes. Each claim traces to a pull request in `v2026.1202.0..89c6e38` > - The benefit is that the stable promotion for this beta (v2026.1206.0) finds finished notes on `master` ## Linked Issues or Issue Description **Issue type** Missing content **Where is the issue?** `releases/beta/v2026.1203.0-beta.0.md` is the stable-notes file for the `2026.1203.0-beta.0` soak. At the branch head before this commit, it holds only the auto-generated commit-log skeleton. **What's wrong?** The stable promotion reads this file from `master` and publishes it as the GitHub Release body. A raw commit list is not suitable as a release body. **Suggested fix** Merge the curated notes. Correct the H1 and the `> Released:` line in a follow-up if the promotion date moves. ## What Changed - Replaced the skeleton in `releases/beta/v2026.1203.0-beta.0.md` with curated stable notes for v2026.1206.0. The layout is the same as the v2026.1202.0 notes: overview, Breaking Changes, Highlights, Improvements, Fixes, Upgrade Guide, Contributors - The notes are delta-framed against the published v2026.1202.0 notes. None of the 107 cited pull requests appears in those notes - The Upgrade Guide lists migrations `0500` through `0513` with one-phrase effects, the new environment variables with defaults, the experimental-setting changes, and the harness pins - Release and CI internals, smoke specs, canary tooling, Paperclip Cloud work, dependency bumps, and test-only changes are left out ## Verification - Beta publish is complete. The npm dist-tag `beta` is `2026.1203.0-beta.0`. The tag `beta/v2026.1203.0-beta.0` points at `89c6e38ad182962d6deb99f58580b822131316f2`. In run 47005574134, `publish_beta`, both `smoke_beta` jobs and `draft_stable_notes` succeeded. The beta Docker build (run 47021510703) succeeded - The GitHub compare API returns 465 commits for `v2026.1202.0...89c6e38ad182962d6deb99f58580b822131316f2`. This number matches the overview and the Contributors section - Contributors are the 24 unique GitHub logins of the commit authors in the range, read from the GitHub API with `[bot]` accounts excluded. External handles are thanked by name - Every `#NNNN` link in the file traces to a commit in the range (107 cited pull requests) - Migration numbers, setting keys, env var names, and defaults were checked in the code at the source commit, not in commit subjects - The file contains no internal ticket ids or instance-local links - The diff changes one file under `releases/` and no source files ## Risks - Low risk: a single markdown file, no source changes. If the promotion date moves past 2026-12-06, the H1 and the `> Released:` line need a one-line update before the stable dispatch - The `draft_stable_notes` job force-pushes this branch name. A rerun of that job replaces this commit with the skeleton. Do not rerun it for this beta ## Model Used - Claude (Anthropic), model ID `claude-opus-5-5` (Claude Opus 5.5), tool use via Claude Code ## 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 - [ ] I have run tests locally and they pass (documentation-only change; no tests apply) - [ ] I have added or updated tests where applicable (not applicable) - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- releases/beta/v2026.1203.0-beta.0.md | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 releases/beta/v2026.1203.0-beta.0.md diff --git a/releases/beta/v2026.1203.0-beta.0.md b/releases/beta/v2026.1203.0-beta.0.md new file mode 100644 index 00000000000..636f3662294 --- /dev/null +++ b/releases/beta/v2026.1203.0-beta.0.md @@ -0,0 +1,59 @@ +# Paperclip v2026.1206.0 + +> Released: 2026-12-06 + +Paperclip v2026.1206.0 carries 465 commits, promoted from `2026.1203.0-beta.0`. The headline is a headless way to run a board: the `paperclipai` package now also installs a `pc` command and a `paperclipai/sdk` export, with channels, claimable task queues with leases, compare-and-swap labels, and versioned result schemas, all usable from the CLI, the API, and the public MCP tools. Around that: Google Antigravity becomes a regular harness choice, the AWS connector and GitHub review bots leave Experimental, Connectors becomes a Plugins marketplace, runs show which startup step they are on instead of "Thinking", personal archiving returns to task views, artifact comments get one-tap reactions, and the board works properly on phones. Google Workspace connections now delete content read from Google when access ends and keep Google technical information for at most 30 days. + +## Breaking Changes + +- **Deployment-wide OAuth clients are sent only to the provider they are configured for.** `PAPERCLIP_TOOL_OAUTH_CLIENT_ID`/`_SECRET` and the per-provider `PAPERCLIP_TOOL_OAUTH__CLIENT_ID`/`_SECRET` now apply only to gallery apps, and the secret goes only to the app's pinned token endpoint or a token endpoint on the same host as its fixed URLs. A pasted custom MCP server no longer receives the deployment client and fails with `oauth_instance_client_endpoint_mismatch`; add an OAuth client on that connection instead. ([#22649](https://github.com/paperclipai/paperclip/pull/22649)) + +## Highlights + +- **Headless channels, task queues, and the `pc` CLI.** The `paperclipai` npm package adds a second command name, `pc`, and a `paperclipai/sdk` export. `pc up` (or `npx paperclipai up`) starts a local server with embedded Postgres, a default company, and a `general` channel, bound to loopback in `local_trusted` mode by default; `--bind tailnet` or `lan` uses `authenticated` mode. Channels are slash-path topics such as `deploys` or `build/auth`, created on first write. `pc post` adds a backlog task to a channel without waking agents. Workers claim tasks through `POST /companies/:id/tasks/claim` and get a timed lease (300 seconds by default, 3 attempts before the task is blocked); a worker whose lease was taken over gets `409 claim_lost` on write. Tasks also get `key=value` labels with compare-and-swap (`409 label_conflict`), versioned JSON result schemas (built-ins `git-commit@1`, `pull-request@1`, `test-report@1`, `finding@1`), batch task graphs, ask/confirm/approve/reject, scheduled posts, and a board event stream (long-poll or SSE). New routes assign, hand off, cancel, and reopen tasks and add or remove blockers mid-flight, rejecting cycles. Channel creators, company owners and admins, and instance admins can manage a channel's members and settings, including a managed pool that auto-assigns tasks to one agent. Private channels are visible only to their creator and members, plus instance admins and `local_trusted` callers. See `doc/CHANNELS-AND-QUEUES.md`, `doc/HEADLESS-TUTORIALS.md`, and `docs/api/headless.md`. ([#23330](https://github.com/paperclipai/paperclip/pull/23330), [#23415](https://github.com/paperclipai/paperclip/pull/23415), [#23433](https://github.com/paperclipai/paperclip/pull/23433), [#23426](https://github.com/paperclipai/paperclip/pull/23426), [#23448](https://github.com/paperclipai/paperclip/pull/23448)) +- **Structured coordination on every surface.** Issue create and update accept `channel`, `kvLabels`, `schemaBlocks`, and `resultSchemaRef`; list and count filter by `channel` and `kvLabel`; `paperclipai issue` gains `--channel`, `--kv`, `--unset-kv`, and `--result-schema`; and the public MCP and native agent task tools take the same fields. When an agent marks a task with a `resultSchemaRef` as done without a matching schema block, the request fails with `422 result_schema_validation_failed`; people can still close it. The task panel shows the channel, editable key-values, and the current lease, and comments render schema blocks as cards. ([#23410](https://github.com/paperclipai/paperclip/pull/23410), [#23406](https://github.com/paperclipai/paperclip/pull/23406), [#23382](https://github.com/paperclipai/paperclip/pull/23382)) +- **Google Antigravity is a regular harness.** Antigravity runs on Google's `agy acp` 1.5.19 (macOS arm64/x64 and Linux x64/arm64) through the Paperclip Runner, no longer needs an operator release grant, and appears next to GitHub Copilot in the agent settings Harness menu; install it with `paperclipai runtime setup antigravity` and authenticate with a Gemini API key or a personal Google sign-in on the Paperclip host. Its live paid-key qualification was waived rather than run, so treat it as early availability. Antigravity agents signed in with a personal Google account can run `/swarm` from the task composer when the new **Google Antigravity swarm** experimental setting (`enableAntigravitySwarm`, off by default) is on; agents on a Gemini API key run ordinary turns only, and `/swarm` is refused for them. Swarm helper actions are auto-approved and are not sandboxed by Paperclip. Typing `/plan` at the start of a message in any composer that offers Plan mode now switches the task to Plan mode. ([#22591](https://github.com/paperclipai/paperclip/pull/22591), [#22939](https://github.com/paperclipai/paperclip/pull/22939), [#23168](https://github.com/paperclipai/paperclip/pull/23168), [#23042](https://github.com/paperclipai/paperclip/pull/23042), [#22733](https://github.com/paperclipai/paperclip/pull/22733), [#22727](https://github.com/paperclipai/paperclip/pull/22727)) +- **AWS connector and GitHub review bots leave Experimental.** Both are now always on: `enableAwsConnector` and `enableGitHubReviewBots` are forced to `true`, stored `false` values are ignored, and review bots no longer depend on `enableChatConnectors`. The AWS role method still needs a public HTTPS address that AWS can reach; the access-key method works anywhere. "Set it up with your agent" now shows a live checklist while your agent creates the AWS role and fills in the role ARN from its result. Self-hosted review bots receive GitHub webhooks either directly at a public HTTPS URL or through Paperclip Cloud as a relay. See `doc/connections/AWS.md` and `docs/guides/board-operator/github-review-bots.md`. ([#22994](https://github.com/paperclipai/paperclip/pull/22994), [#22626](https://github.com/paperclipai/paperclip/pull/22626), [#22996](https://github.com/paperclipai/paperclip/pull/22996), [#22995](https://github.com/paperclipai/paperclip/pull/22995)) +- **Connectors becomes Plugins.** The sidebar's Connectors page is now a Plugins marketplace with categories and per-plugin pages, the Review page becomes Reviews, the connection page and the Connect account dialog are redesigned, and Instance Settings' old Plugins tab is renamed System plugins. The gallery uses the same server APIs and bundled catalog as before. ([#22869](https://github.com/paperclipai/paperclip/pull/22869), [#23005](https://github.com/paperclipai/paperclip/pull/23005), [#23029](https://github.com/paperclipai/paperclip/pull/23029), [#23361](https://github.com/paperclipai/paperclip/pull/23361)) +- **Runs say what they are doing while they start.** Instead of "Thinking", a starting run shows its step: Getting ready, Waking up, Preparing workspace, Restoring or Resuming session, Connecting tools, Starting agent. Steps too short to read are skipped, and environment plugins can report the step for their tasks. ([#22953](https://github.com/paperclipai/paperclip/pull/22953), [#22956](https://github.com/paperclipai/paperclip/pull/22956), [#22970](https://github.com/paperclipai/paperclip/pull/22970), [#23299](https://github.com/paperclipai/paperclip/pull/23299)) + +## Improvements + +- **Google data handling.** For any Google Workspace connection, including ones made with your own OAuth client, Paperclip deletes content read from Google when access ends: when the connection is removed, a grant is revoked, Google reports at refresh that access ended, or the member who connected leaves the company. It waits for runs still using that content to settle. Call records, fingerprints, and anything agents already wrote into tasks are kept, as described in `docs/guides/board-operator/deleting-connection-data.md`. Google error text, connection health text, and cached tool descriptions are cleared after 30 days, or right away for removed connections. Decision-training exports and feedback bundles replace runs that used Google with a stub. When Google doesn't confirm a revocation, Paperclip retries for up to 30 days. The Google Workspace connector itself is still behind `enableGoogleWorkspaceConnector` (off by default). ([#22836](https://github.com/paperclipai/paperclip/pull/22836), [#22842](https://github.com/paperclipai/paperclip/pull/22842), [#22669](https://github.com/paperclipai/paperclip/pull/22669)) +- **Deleting a task or company removes its connection content.** Deleting a task queues deletion of the connected-app data its runs read and of its attachment files, waiting up to 24 hours for open runs or approvals; deleting a company keeps retrying storage clean-up until it finishes. ([#22636](https://github.com/paperclipai/paperclip/pull/22636)) +- **Personal archiving is back.** Archive a task for yourself from Mine, Unread, or a task row, with Undo and an Archived view; new activity brings it back. ([#22358](https://github.com/paperclipai/paperclip/pull/22358)) +- **One-tap reactions on artifact comments.** Mark a comment done, checked, thumbs-up, or question; a person's question reaction wakes the assignee once, and done does not resolve the thread. Reactions also work on routine descriptions. ([#22989](https://github.com/paperclipai/paperclip/pull/22989)) +- **Mobile parity.** Task detail, chat, goals, the Coordinator inbox, tables, popovers, settings, and navigation now work on phones, including scrolling inside chat and task cards. ([#23045](https://github.com/paperclipai/paperclip/pull/23045), [#23046](https://github.com/paperclipai/paperclip/pull/23046), [#23047](https://github.com/paperclipai/paperclip/pull/23047), [#23048](https://github.com/paperclipai/paperclip/pull/23048), [#23538](https://github.com/paperclipai/paperclip/pull/23538)) +- **Inbox and task lists.** Repeated provider-limit failures collapse into one card per account and reset window, with a Waiting view ([#22846](https://github.com/paperclipai/paperclip/pull/22846)); Needs You still opens on Assigned to you but remembers your assignee, agent, project, and grouping choices per company ([#22964](https://github.com/paperclipai/paperclip/pull/22964), [#23321](https://github.com/paperclipai/paperclip/pull/23321)); the Tasks list filters by when tasks were updated ([#22965](https://github.com/paperclipai/paperclip/pull/22965)); projects can be pinned in the Coordinator sidebar and expand to their recent tasks ([#22805](https://github.com/paperclipai/paperclip/pull/22805)); and task notifications show the title, actor, and a redacted preview of the comment or status change ([#22441](https://github.com/paperclipai/paperclip/pull/22441)). +- **Retry for one agent.** A board user can grant a single agent `tasks:retry`, letting it press Retry on that user's behalf at most 3 times per task per rolling day. ([#22988](https://github.com/paperclipai/paperclip/pull/22988)) +- **Agents in a person's chats.** An agent acting for a person can post in that person's chat with another agent; the post is labelled with the sending agent and never carries the person's authority. ([#22961](https://github.com/paperclipai/paperclip/pull/22961)) +- **Onboarding.** The first chat opens with a welcome and three choices and starts no run until you pick one; model sign-in works through plugin-managed environments and while the first agent's computer is still being prepared; OpenAI sign-in happens in the panel from Other Models; and device sign-in expiry, OAuth timeouts, and mobile paste are handled. ([#23334](https://github.com/paperclipai/paperclip/pull/23334), [#23312](https://github.com/paperclipai/paperclip/pull/23312), [#23435](https://github.com/paperclipai/paperclip/pull/23435), [#23474](https://github.com/paperclipai/paperclip/pull/23474), [#23270](https://github.com/paperclipai/paperclip/pull/23270), [#23379](https://github.com/paperclipai/paperclip/pull/23379)) +- **Connections.** A dedicated account can be shared with chosen agents ([#23431](https://github.com/paperclipai/paperclip/pull/23431)); the Slack MCP connector uses Slack's user-token OAuth and shows OAuth errors in setup, so add scopes under **User** Token Scopes ([#22976](https://github.com/paperclipai/paperclip/pull/22976)); and when a run fails on GitHub authentication with no GitHub connection, Paperclip asks the responsible person to connect GitHub ([#22954](https://github.com/paperclipai/paperclip/pull/22954)). +- **Runtimes and sandboxes.** A Linux server can run native OpenCode on an Apple Silicon Mac over an SSH environment ([#22534](https://github.com/paperclipai/paperclip/pull/22534)); tasks and chats without a project repository that ask for an isolated workspace get a private task directory ([#22972](https://github.com/paperclipai/paperclip/pull/22972)); remote sandboxes clone network repositories blobless ([#23347](https://github.com/paperclipai/paperclip/pull/23347)); and the Daytona plugin's default disk grows from 10 to 20 GiB ([#22981](https://github.com/paperclipai/paperclip/pull/22981)). +- **Voice.** With `enableChatConnectors` on and a Speko key, agents can call the responsible person's opted-in number, and call transcripts are saved as task documents. ([#23052](https://github.com/paperclipai/paperclip/pull/23052)) +- **CLI.** `paperclipai agent clear-error ` clears an agent's error state. ([#19382](https://github.com/paperclipai/paperclip/pull/19382)) + +## Fixes + +- **Security hardening.** Links clicked from chat, artifacts, interactions, MCP apps, and plugin UI open only for http(s) or same-origin URLs; ordinary Markdown links keep react-markdown's default filter ([#22639](https://github.com/paperclipai/paperclip/pull/22639)). Tool-call request bodies are redacted from failed-request logs ([#22635](https://github.com/paperclipai/paperclip/pull/22635)). Approving a tool review in an agent chat is limited to the chat's owner and the usual resolvers ([#22656](https://github.com/paperclipai/paperclip/pull/22656)). Per-agent connection installs are enforced on every transport, not only plugins ([#22967](https://github.com/paperclipai/paperclip/pull/22967)). A gateway session a person opens acts as that person and uses only their own personal grants ([#22643](https://github.com/paperclipai/paperclip/pull/22643)). Token-shaped environment variable names and secret aliases are rejected, and a secret that a connection signs in with can't be deleted or disabled ([#22982](https://github.com/paperclipai/paperclip/pull/22982), [#23139](https://github.com/paperclipai/paperclip/pull/23139)). Routine `app_webhook` triggers prefer GitHub's `X-Hub-Signature-256` ([#18581](https://github.com/paperclipai/paperclip/pull/18581)). +- **Retry and recovery.** Retry is never offered while a live run owns the task ([#22428](https://github.com/paperclipai/paperclip/pull/22428)); a usage-limit hold pauses only the AI account that reported it ([#22800](https://github.com/paperclipai/paperclip/pull/22800)); a rate limit that refuses a session start is waited out ([#22386](https://github.com/paperclipai/paperclip/pull/22386)); tasks and chats blocked by a setup failure before provider work continue on their own, and setup retries while project storage is still being prepared ([#23051](https://github.com/paperclipai/paperclip/pull/23051), [#23059](https://github.com/paperclipai/paperclip/pull/23059), [#23362](https://github.com/paperclipai/paperclip/pull/23362)); a blocked task whose dependency runs keep failing is not woken over and over ([#22818](https://github.com/paperclipai/paperclip/pull/22818)); and a full sandbox disk on resume restores onto a new sandbox ([#22837](https://github.com/paperclipai/paperclip/pull/22837)). +- **Harnesses.** A reply to an earlier chat turn is never posted after a later turn starts ([#21803](https://github.com/paperclipai/paperclip/pull/21803)); a Claude prompt blocked by a `UserPromptSubmit` hook fails the run instead of looking successful ([#17766](https://github.com/paperclipai/paperclip/pull/17766)); OpenCode no longer runs npm at startup ([#23512](https://github.com/paperclipai/paperclip/pull/23512)); OpenClaw gateway transcripts show thinking and tool steps and keep streamed whitespace ([#17136](https://github.com/paperclipai/paperclip/pull/17136), [#14150](https://github.com/paperclipai/paperclip/pull/14150)); a non-numeric Hermes cost no longer breaks run accounting ([#17266](https://github.com/paperclipai/paperclip/pull/17266)); Claude setup-token parsing handles wrapped URLs and every copy hint ([#19211](https://github.com/paperclipai/paperclip/pull/19211), [#22652](https://github.com/paperclipai/paperclip/pull/22652), [#22653](https://github.com/paperclipai/paperclip/pull/22653)); and Daytona regional proxy hosts are accepted ([#20075](https://github.com/paperclipai/paperclip/pull/20075)). +- **API and plugins.** `ask_user_questions` accepts up to 64 answers ([#16702](https://github.com/paperclipai/paperclip/pull/16702)); the plugin SDK's `issues.list` no longer applies offset and limit twice ([#16327](https://github.com/paperclipai/paperclip/pull/16327)); a blank `taskKey` on reset-session is rejected instead of resetting every task session ([#19282](https://github.com/paperclipai/paperclip/pull/19282)); `originKindPrefix` matches `%` and `_` literally ([#19197](https://github.com/paperclipai/paperclip/pull/19197)); a malformed `agentId` on company activity returns 400 ([#22516](https://github.com/paperclipai/paperclip/pull/22516)); document update and restore return the new body ([#21036](https://github.com/paperclipai/paperclip/pull/21036)); plugin bridge calls with no registered worker report `WORKER_UNAVAILABLE` ([#19286](https://github.com/paperclipai/paperclip/pull/19286)); and agents see an updated plugin's current tool schema ([#22811](https://github.com/paperclipai/paperclip/pull/22811)). +- **Board.** Rolling back an agent config restores its icon and appearance ([#19244](https://github.com/paperclipai/paperclip/pull/19244)); deleting a company no longer fails when late activity commits during the delete ([#22719](https://github.com/paperclipai/paperclip/pull/22719)); "More messages" appears only when there is hidden history ([#22099](https://github.com/paperclipai/paperclip/pull/22099)); you can open an agent chat from the task transcript ([#23004](https://github.com/paperclipai/paperclip/pull/23004)); and server shutdown steps after the run drain share a bounded budget ([#23491](https://github.com/paperclipai/paperclip/pull/23491)). + +## Upgrade Guide + +- **Migrations `0500`–`0513`** run on upgrade; none drops a table. `0500` gives each responsibility area an owner, copying an area shared by several people into one per owner, makes area titles unique per owner, and marks existing tasks that came from a responsibility dashboard, bar, status update, or a person's automation conversation private to that person; it runs even when `enableResponsibilities` is off ([#22513](https://github.com/paperclipai/paperclip/pull/22513)). `0511` adds a `scope` (`board`, `channel`, `agent`, `chat`) to every task with a batched backfill that matches the existing agent-created and conversation filters, so no existing task changes where it appears ([#23329](https://github.com/paperclipai/paperclip/pull/23329)). `0512` adds the headless tables (channels, channel members, company schemas, board events, scheduled posts, batch idempotency keys), lease, label, and schema columns on tasks and comments, board API key scoping, agent key expiry, and a company agent-identity policy ([#23330](https://github.com/paperclipai/paperclip/pull/23330)). Other new tables: `0501` task connection-content deletions, `0503` pending Google revocations, `0504` agent setup progress, `0510` comment reactions. New columns: `0502` gateway session and MCP task openers, `0506` deletion reasons. `0509` marks GitHub response comments that ran out of retries as processed. The index-only migrations `0505`, `0507`, `0508`, and `0513`, and the indexes in `0511`, are built `CONCURRENTLY`; expect `0508` and `0511` to take longer on instances with large run or task histories. +- **New environment variables**, none required. `PAPERCLIP_TRACING_INSTANCE_HOST` (off; `true` with an http(s) `PAPERCLIP_PUBLIC_URL`) adds the instance hostname to your own OTLP server spans as `paperclip.instance.host` ([#22856](https://github.com/paperclipai/paperclip/pull/22856)); `PAPERCLIP_RUNNER_REMOTE_RUNTIMES_PATH` (`/opt/paperclip-runner/remote-runtimes`) locates the bundled macOS runtimes for OpenCode over SSH ([#22534](https://github.com/paperclipai/paperclip/pull/22534)). +- **Experimental settings**: new `enableAntigravitySwarm`, off by default ([#22733](https://github.com/paperclipai/paperclip/pull/22733)); `enableAwsConnector` and `enableGitHubReviewBots` are retired and always on ([#22994](https://github.com/paperclipai/paperclip/pull/22994), [#22996](https://github.com/paperclipai/paperclip/pull/22996)). +- **Google Workspace**: Paperclip's own Google sign-in ("Connect with Paperclip") is now offered only on Paperclip Cloud and returns `422 google_sign_in_cloud_only` elsewhere. Self-hosted instances use their own Google OAuth client (see `doc/connections/GOOGLE-WORKSPACE.md`); existing grants made through Paperclip keep refreshing until a sunset date that has not been set yet ([#22699](https://github.com/paperclipai/paperclip/pull/22699)). +- **API clients**: default issue lists and counts also leave out `channel`-scoped tasks, `?scope=` filters by scope, and agents get `403` when setting `scope: "board"` except in chat-to-board handoffs ([#23329](https://github.com/paperclipai/paperclip/pull/23329)); outside `local_trusted` mode, the default `strict_agent_keys` identity policy rejects `--as ` profiles with `403 agent_key_required` ([#23330](https://github.com/paperclipai/paperclip/pull/23330)); `GET /issues` accepts `updatedSince` and `updatedBefore` ([#22965](https://github.com/paperclipai/paperclip/pull/22965)); deleting or disabling a secret that a connection signs in with returns `409 secret_used_by_connection` ([#23139](https://github.com/paperclipai/paperclip/pull/23139)); and new routes include the headless channel, claim, event, and task-workflow routes in `docs/api/headless.md`, `/api/companies/:companyId/agent-setup-progress`, and `PUT /tool-connections/:connectionId/grants/:grantId/shared-agents`. +- **Telemetry**: when telemetry is enabled, Paperclip Runner harnesses report their own `adapter_type`, connector events add `server_domain` for custom connectors only (the registrable domain, or `private` / `stdio`), and new `connection.app_linked` and `connection.app_requested` events carry catalog app slugs ([#22637](https://github.com/paperclipai/paperclip/pull/22637), [#22665](https://github.com/paperclipai/paperclip/pull/22665)); `PAPERCLIP_TELEMETRY_DISABLED=1` and `DO_NOT_TRACK=1` still turn telemetry off. +- **Harness pins**: Google Antigravity moves from its pending ACP server 1.4.3 to the `agy` CLI 1.5.19 ([#23168](https://github.com/paperclipai/paperclip/pull/23168)); the Daytona plugin's SDK moves from 0.203.0 to 0.232.0 and its sandbox image adds the Antigravity Linux runtime ([#22604](https://github.com/paperclipai/paperclip/pull/22604)). Codex 0.170.0, Claude Agent SDK 0.3.328, ACPX 0.22.0, OpenCode 1.18.34, and GitHub Copilot CLI 1.0.88 are unchanged. +- No other configuration or API changes require action. + +## Contributors + +This release has 465 commits from 24 contributors. Thank you to everyone who contributed to this release! + +@aalfath, @appleguy, @a-vasyliev, @calvindomenico, @Canyon-netizen, @ElNeMeR70, @EpaL, @eroslifestyle, @hisarweb-be, @Iyanuoluwa007, @kronik187, @lucktastic, @son9son9, @stfl, @turowicz, @yucelokan, @zurvaaziz56 From c2a8821809e38e6e3dc68bbc6a419925bb90734c Mon Sep 17 00:00:00 2001 From: Nicky Leach Date: Thu, 3 Dec 2026 15:55:56 -0800 Subject: [PATCH 006/119] fix(agents): keep a prepared agent setup when its configuration changes (#23669) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A new agent can use a plugin environment that requires an agent. A lifecycle plugin prepares that environment before the agent can work. > - The setup flow creates a draft agent first, so that this preparation can start before the person finishes setup. > - Each change to the draft's harness, model, or sign-in started preparation again. The hire also started it again. > - Verification cannot start until the last preparation is complete. So the early preparation did not decrease the wait after the hire. > - This pull request keeps the preparation when the agent stays on the same environment driver. > - The benefit is that a person who finishes setup waits only for verification. ## Linked Issues or Issue Description I searched the open and closed issues and pull requests. I did not find a duplicate. **What happened?** Create an agent in setup on a plugin environment that declares `requiresAgent: true`. The draft is prepared. Then choose a harness, sign in, and hire the agent. Each of these three steps starts `preparing` again. The agent page shows preparation after the hire, although the environment was ready before the person signed in. **Expected behavior** A change to the harness, model, credentials, or instructions does not change the environment. It must not start preparation again. The hire must go directly to verification. If preparation is in progress, the hire must join it. **Steps to reproduce** 1. Install a lifecycle plugin with an environment driver that declares `requiresAgent: true`. 2. Make that environment the instance default. 3. Create a setup draft and wait until `lifecycleState` is `verifying`. 4. Save a different model on the draft. `lifecycleState` goes back to `preparing`. 5. Hire the draft. `lifecycleState` goes back to `preparing` again. **Paperclip version or commit** `7e025ae65f` **Deployment mode** Self-hosted server with a plugin environment that requires an agent. ## What Changed - A configuration change restarts `preparing` only when the agent moves to an environment that needs setup. The existing environment and driver check makes this decision. - A prepared setup draft stays prepared when its harness, model, credentials, or runtime configuration change. - The hire of a prepared draft goes directly to `verifying` with a new operation. - The hire of a draft that is still `preparing` keeps the operation and its version. Verification starts when that operation is complete. - A hire that moves to an environment that needs setup starts `preparing` again, as before. - A save that changes an environment to another driver of the same plugin now also refuses `preparing` agents, the same as `ready` and `verifying` ones. - A change to instructions alone does not restart verification. The hire writes the managed instruction files immediately after it commits, and verification does not read them. - The hire clears an old lifecycle error on the draft. - These behaviors do not change: - a draft that no longer needs preparation goes to `pausing` - a hire that needs approval, a hire with a hold, and a company hold - an edit to other execution configuration during verification - an edit during `resuming` - `doc/AGENT-LIFECYCLE.md` describes the new rules. ## Verification - `npx vitest run src/modules/agent-lifecycle`: 224 passed. Four new tests cover a prepared draft, a hire from a prepared draft, a hire during preparation, and an instruction change. Three of them failed before the change. The fourth could not run because a test before it left the fixture blocked. - `npx vitest run` on the hire, lifecycle delivery, agent secret, pending approval, secret binding, managed plugin environment, and plugin task tests: all passed. - `npx vitest run` on the two Dot onboarding files: 25 passed. - `pnpm --filter @paperclipai/server typecheck`: passed. - Not done: a live test with a plugin environment. Three existing tests used an agent in `preparing` to test that a configuration change fences verification. They now use `verifying`. ## Risks - A lifecycle plugin that reads the agent's harness or model during `preparing` is not called again when they change. The lifecycle request does not carry them. Verification still tests the final configuration. - A prepared environment can be lost between preparation and hire. Verification then fails and retries, and a pause and resume prepares it again. Before this change, the hire prepared it again. - An edit during `preparing` does not cancel the attempt in progress. A plugin must not fail because the agent's configuration changed during its call. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code, with extended thinking, tool use and code execution. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- doc/AGENT-LIFECYCLE.md | 19 ++- .../__tests__/dot-oauth-onboarding.test.ts | 2 +- server/src/lib/agent-records.ts | 16 +++ .../__tests__/environment-plugins.test.ts | 2 + .../__tests__/lifecycle.test.ts | 6 + .../agent-lifecycle/__tests__/setup.test.ts | 117 ++++++++++++++++-- .../agent-lifecycle/adapters/configuration.ts | 31 +++-- .../agent-lifecycle/adapters/records.ts | 18 ++- .../src/services/plugin-environment-driver.ts | 5 +- 9 files changed, 185 insertions(+), 31 deletions(-) diff --git a/doc/AGENT-LIFECYCLE.md b/doc/AGENT-LIFECYCLE.md index a28181b1420..0fd53948c33 100644 --- a/doc/AGENT-LIFECYCLE.md +++ b/doc/AGENT-LIFECYCLE.md @@ -139,9 +139,19 @@ The application supplies the worker driver at startup. `updateConfiguration` owns the transaction for an ordinary configuration update. The module locks the agent. The configuration service validates and prepares the patch. The module saves it and invalidates an old verification result when -execution configuration changes during setup. The service then updates dependent +execution configuration changes during verification. A change to instructions +alone keeps the verification. The service then updates dependent records and saves the configuration revision in the same transaction. +A change to the harness, model, credentials, or instructions does not restart +`preparing`. Preparation restarts only when the agent moves to an environment +that needs setup. There is no separate invalidation operation for callers. +A prepared setup draft waits in `verifying` with no background work. Edits keep +it prepared. If an edit means that the draft no longer needs preparation, the +draft pauses. When the draft becomes a hire on the same environment driver, a +prepared draft goes directly to verification. A draft that is still `preparing` +keeps its operation, and the hire verifies after that operation completes. A +hire that needs setup for another environment starts `preparing` again. Configuration writes reject caller-supplied lifecycle fields. For `updateAndTransition`, lifecycle owns the transaction and calls the same configuration operation. Both changes commit together. @@ -222,9 +232,10 @@ the agent. Saving an environment or the instance default that gives such a plugin to `ready` or `verifying` agents without that selection returns a conflict. The same applies -when the change keeps the plugin but changes its driver; then every `ready` or -`verifying` agent on the environment needs setup. Pause those agents, save the -change, and then resume them. +when the change keeps the plugin but changes its driver; then every `ready`, +`preparing`, or `verifying` agent on the environment needs setup. A preparation +in progress belongs to the previous driver. Pause those agents, save the change, +and then resume them. This save check trusts a selection when the old environment uses another plugin or none. An agent keeps its selection after it leaves the plugin's environment. diff --git a/server/src/__tests__/dot-oauth-onboarding.test.ts b/server/src/__tests__/dot-oauth-onboarding.test.ts index 653f8d9e65d..c7c95d76e0d 100644 --- a/server/src/__tests__/dot-oauth-onboarding.test.ts +++ b/server/src/__tests__/dot-oauth-onboarding.test.ts @@ -45,7 +45,7 @@ describe("Dot onboarding with an operator-issued pairing capability", () => { } it("invalidates setup when a broker pairing is applied or revoked", async () => { - const f = await fixture(undefined, "preparing"); + const f = await fixture(undefined, "verifying"); const consent = await f.oauth.consent(f.id, { type: "board", source: "session", userId: f.userId }, { decision: "approve", companyId: f.company.id, allowWrites: false }); const tokens = await f.oauth.token({ grant_type: "authorization_code", client_id: f.client.client_id, diff --git a/server/src/lib/agent-records.ts b/server/src/lib/agent-records.ts index 8af5d18be73..b09bdf56ede 100644 --- a/server/src/lib/agent-records.ts +++ b/server/src/lib/agent-records.ts @@ -125,6 +125,22 @@ export function jsonEqual(left: unknown, right: unknown): boolean { return canonicalJson(left) === canonicalJson(right); } +const INSTRUCTION_CONFIGURATION_KEYS = [ + "instructionsBundleMode", + "instructionsRootPath", + "instructionsEntryFile", + "instructionsFilePath", + "agentsMdPath", + "promptTemplate", + "bootstrapPromptTemplate", +]; + +export function adapterConfigWithoutInstructions(adapterConfig: unknown) { + return adapterConfig && typeof adapterConfig === "object" && !Array.isArray(adapterConfig) + ? Object.fromEntries(Object.entries(adapterConfig).filter(([key]) => !INSTRUCTION_CONFIGURATION_KEYS.includes(key))) + : adapterConfig; +} + export function buildConfigSnapshot( row: Pick, ): AgentConfigSnapshot { diff --git a/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts b/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts index 85867e91d70..f27a97a3528 100644 --- a/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts @@ -289,6 +289,8 @@ const support = await getEmbeddedPostgresTestSupport(); const users = { environmentId: boundEnvironmentId, inheritsDefault: false }; const id = await agent(boundEnvironmentId, { lifecycleRequiredPluginIds: [boundPluginId] }); await expect(assertAgentsReadyForEnvironmentChange(db, bound, sibling, users)).rejects.toThrow("need setup first"); + await db.update(agents).set({ lifecycleState: "preparing", status: "paused" }).where(eq(agents.id, id)); + await expect(assertAgentsReadyForEnvironmentChange(db, bound, sibling, users)).rejects.toThrow("need setup first"); await expect(assertAgentsReadyForEnvironmentChange(db, bound, bound, users)).resolves.toBeUndefined(); await db.update(agents).set({ lifecycleState: "paused", status: "paused" }).where(eq(agents.id, id)); await expect(assertAgentsReadyForEnvironmentChange(db, bound, sibling, users)).resolves.toBeUndefined(); diff --git a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts index 638f77aa416..c03a63a7421 100644 --- a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts @@ -1030,6 +1030,7 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu it("fences verification when the saved configuration changes", async () => { const lifecycle = createAgentLifecycle(db); const store = createLifecycleStore(db); const agent = await hire(); + await db.update(agents).set({ lifecycleState: "verifying" }).where(eq(agents.id, agent.id)); const claimed = (await store.claim(agent.id, "configuration-test", new Date()))!; await store.setRequiredPlugins(claimed, "configuration-test", []); await agentConfiguration(db).update(agent.id, { adapterConfig: { command: "echo" } }); @@ -1040,6 +1041,10 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu it("invalidates only changed execution configuration during setup", async () => { const lifecycle = createAgentLifecycle(db); const agent = await hire(); + const preparing = await current(agent.id); + await lifecycle.updateConfiguration(agent.id, { adapterConfig: { command: "true" } }); + expect(await current(agent.id)).toMatchObject({ lifecycleVersion: preparing.lifecycleVersion, lifecycleOperation: preparing.lifecycleOperation }); + await db.update(agents).set({ lifecycleState: "verifying" }).where(eq(agents.id, agent.id)); const before = await current(agent.id); await lifecycle.updateConfiguration(agent.id, { name: "Profile only" }); await lifecycle.updateConfiguration(agent.id, { adapterConfig: before.adapterConfig }); @@ -1111,6 +1116,7 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu it("rolls back configuration and verification invalidation in the binding transaction", async () => { const agent = await hire(); + await db.update(agents).set({ lifecycleState: "verifying" }).where(eq(agents.id, agent.id)); const before = await current(agent.id); await expect(updateAgentConfigurationInTransaction(db, agent.id, { name: "Uncommitted" })) .rejects.toThrow("requires a database transaction"); diff --git a/server/src/modules/agent-lifecycle/__tests__/setup.test.ts b/server/src/modules/agent-lifecycle/__tests__/setup.test.ts index 8c4ded0a840..33825517736 100644 --- a/server/src/modules/agent-lifecycle/__tests__/setup.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/setup.test.ts @@ -3,7 +3,7 @@ import express from "express"; import request from "supertest"; import { eq } from "drizzle-orm"; import { agents, companies, companyMemberships, principalPermissionGrants, environments, plugins, createDb, type Db } from "@paperclipai/db"; -import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { getEmbeddedPostgresTestSupport, startEmbeddedPostgresTestDatabase } from "../../../__tests__/helpers/embedded-postgres.js"; import { createAgentLifecycle, configureAgentLifecycle, createAgentLifecycleEffects } from "../../../services/agent-lifecycle.js"; import { agentService as agentConfiguration } from "../../../services/agents.js"; @@ -20,7 +20,9 @@ const support = await getEmbeddedPostgresTestSupport(); let db: Db; let companyId: string; const workers: ReturnType[] = []; + const releases: (() => void)[] = []; beforeAll(async () => { database = await startEmbeddedPostgresTestDatabase("paperclip-agent-setup-"); db = createDb(database.connectionString); }, 90_000); + afterEach(() => { for (const release of releases.splice(0)) release(); }); afterAll(async () => { for (const work of workers) await work.stop(); await database?.cleanup(); }); beforeEach(async () => { for (const work of workers) await work.stop(); @@ -57,18 +59,31 @@ const support = await getEmbeddedPostgresTestSupport(); await expect(lifecycle.requestHire(companyId, { id, name: "Early agent" }, { setupAgentId: id })).rejects.toThrow("no longer available"); }); - it("prepares agent-dependent drafts, stays idle until finish, and invalidates changed environments", async () => { + async function agentEnvironment(hold?: () => Promise) { const pluginId = randomUUID(), environmentId = randomUUID(); await db.insert(plugins).values({ id: pluginId, pluginKey: pluginId, packageName: "agent-environment-test", version: "1.0.0", status: "ready", manifestJson: { agentLifecycle: true, capabilities: ["agents.lifecycle.manage", "environment.drivers.register"], - environmentDrivers: [{ driverKey: "tasks", requiresAgent: true, supportsTasks: true }] } as never }); - await db.insert(environments).values({ id: environmentId, name: "Agent-owned test computer", driver: "plugin", status: "active", - config: { pluginKey: pluginId, driverKey: "tasks", driverConfig: {} } }); - const call = vi.fn(async (_id, _method, input) => ({ operationId: input.operationId, version: input.version, status: "complete" })); + environmentDrivers: ["tasks", "desktop"].map(driverKey => ({ driverKey, requiresAgent: true, supportsTasks: true })) } as never }); + const environment = async (id: string, driverKey: string) => { + await db.insert(environments).values({ id, name: `Agent-owned ${id}`, driver: "plugin", status: "active", + config: { pluginKey: pluginId, driverKey, driverConfig: {} } }); + return id; + }; + await environment(environmentId, "tasks"); + const call = vi.fn(async (_id, _method, input) => { + if (input.phase === "preparing") await hold?.(); + return { operationId: input.operationId, version: input.version, status: "complete" }; + }); + const runHost = vi.fn(async () => "complete"); const driver = createLifecycleDriver(db, { call } as never); - const runHost = vi.fn(async () => "complete" as const); - const work = configureAgentLifecycle(db, { ...driver, requiredPluginIds: async () => [pluginId], runHost }); + const work = configureAgentLifecycle(db, { ...driver, runHost }); workers.push(work); + const phases = () => call.mock.calls.map(([, , request]) => request.phase); + return { pluginId, environmentId, environment, call, runHost, work, phases }; + } + + it("prepares agent-dependent drafts, stays idle until finish, and invalidates changed environments", async () => { + const { environmentId, call, runHost, work } = await agentEnvironment(); const lifecycle = createAgentLifecycle(db); const id = randomUUID(); const input = { id, name: "Early computer", adapterType: "paperclip_runner", adapterConfig: { provider: "codex" }, defaultEnvironmentId: environmentId }; @@ -130,6 +145,92 @@ const support = await getEmbeddedPostgresTestSupport(); expect(runHost).not.toHaveBeenCalled(); }); + it("keeps a prepared draft prepared while its harness, model, sign-in and instructions change", async () => { + const { environmentId, environment, work, phases } = await agentEnvironment(); + const lifecycle = createAgentLifecycle(db); + const id = randomUUID(); + await lifecycle.requestHire(companyId, { id, name: "Prepared", adapterType: "paperclip_runner", + adapterConfig: { provider: "codex" }, defaultEnvironmentId: environmentId }, { setupOnly: true, runnerResolved: true }); + await work.process(id); + const prepared = await current(id); + expect(prepared.lifecycleState).toBe("verifying"); + await lifecycle.updateConfiguration(id, { adapterConfig: { provider: "claude", model: "changed", env: { TOKEN: { type: "plain", value: "saved" } } } }); + await lifecycle.updateConfiguration(id, { runtimeConfig: { heartbeat: { enabled: false } } }); + await lifecycle.updateConfiguration(id, { defaultEnvironmentId: await environment(randomUUID(), "tasks") }); + await work.process(id); + expect(await current(id)).toMatchObject({ lifecycleState: "verifying", lifecycleVersion: prepared.lifecycleVersion, + lifecycleOperation: { id: prepared.lifecycleOperation!.id } }); + expect(phases()).toEqual(["preparing"]); + await lifecycle.updateConfiguration(id, { defaultEnvironmentId: await environment(randomUUID(), "desktop") }); + expect((await current(id)).lifecycleState).toBe("preparing"); + await work.process(id); + expect(phases()).toEqual(["preparing", "preparing"]); + expect((await current(id)).lifecycleState).toBe("verifying"); + }); + + it("verifies a prepared draft at hire without preparing it again", async () => { + const { environmentId, environment, work, phases } = await agentEnvironment(); + const lifecycle = createAgentLifecycle(db); + const hire = async (finalEnvironmentId: string) => { + const id = randomUUID(); + const input = { id, name: "Hired", adapterType: "paperclip_runner", adapterConfig: { provider: "codex" }, defaultEnvironmentId: environmentId }; + await lifecycle.requestHire(companyId, input, { setupOnly: true, runnerResolved: true }); + await work.process(id); + const prepared = await current(id); + await lifecycle.requestHire(companyId, { ...input, adapterConfig: { provider: "claude", model: "chosen" }, status: "idle", + defaultEnvironmentId: finalEnvironmentId }, { setupAgentId: id, runnerResolved: true, responsibleUserId: "owner" }); + return { prepared, hired: await current(id) }; + }; + const same = await hire(environmentId); + expect(same.hired).toMatchObject({ lifecycleState: "verifying", lifecycleHolds: [], lifecycleOperation: { responsibleUserId: "owner" } }); + expect(same.hired.lifecycleVersion).toBeGreaterThan(same.prepared.lifecycleVersion); + expect(same.hired.lifecycleOperation!.id).not.toBe(same.prepared.lifecycleOperation!.id); + await work.process(same.hired.id); + expect((await current(same.hired.id)).lifecycleState).toBe("ready"); + expect(phases()).toEqual(["preparing", "verifying"]); + expect((await hire(await environment(randomUUID(), "desktop"))).hired.lifecycleState).toBe("preparing"); + }); + + it("joins the preparation in progress when a draft is edited and hired", async () => { + let entered!: () => void, release!: () => void; + const started = new Promise(resolve => { entered = resolve; }); + const held = new Promise(resolve => { release = resolve; }); + const { environmentId, work, phases } = await agentEnvironment(() => { entered(); return held; }); + releases.push(release); + const lifecycle = createAgentLifecycle(db); + const id = randomUUID(); + const input = { id, name: "Joined", adapterType: "paperclip_runner", adapterConfig: { provider: "codex" }, defaultEnvironmentId: environmentId }; + await lifecycle.requestHire(companyId, input, { setupOnly: true, runnerResolved: true }); + const processing = work.process(id); + await started; + const preparing = await current(id); + await lifecycle.updateConfiguration(id, { adapterConfig: { provider: "claude" } }); + await lifecycle.requestHire(companyId, { ...input, adapterConfig: { provider: "claude" }, status: "idle" }, + { setupAgentId: id, runnerResolved: true, responsibleUserId: "owner" }); + expect(await current(id)).toMatchObject({ lifecycleState: "preparing", lifecycleHolds: [], lifecycleVersion: preparing.lifecycleVersion, + lifecycleOperation: { id: preparing.lifecycleOperation!.id, leaseOwner: preparing.lifecycleOperation!.leaseOwner, responsibleUserId: "owner" } }); + release(); + await processing; + expect(await current(id)).toMatchObject({ lifecycleState: "ready", lifecycleHolds: [], lifecycleOperation: { responsibleUserId: "owner" } }); + expect(phases()).toEqual(["preparing", "verifying"]); + }); + + it("keeps a running verification when only instructions change", async () => { + const { environmentId, work } = await agentEnvironment(); + const lifecycle = createAgentLifecycle(db); + const id = randomUUID(); + await lifecycle.requestHire(companyId, { id, name: "Verified", adapterType: "paperclip_runner", + adapterConfig: { provider: "codex", promptTemplate: "Old" }, defaultEnvironmentId: environmentId, status: "idle" }, { runnerResolved: true }); + await db.update(agents).set({ lifecycleState: "verifying" }).where(eq(agents.id, id)); + const verifying = await current(id); + await lifecycle.updateConfiguration(id, { adapterConfig: { provider: "codex", instructionsBundleMode: "managed", + instructionsRootPath: "/managed", instructionsEntryFile: "AGENTS.md", instructionsFilePath: "/managed/AGENTS.md" } }); + expect(await current(id)).toMatchObject({ lifecycleVersion: verifying.lifecycleVersion, + adapterConfig: { instructionsFilePath: "/managed/AGENTS.md" }, lifecycleOperation: { id: verifying.lifecycleOperation!.id } }); + await lifecycle.updateConfiguration(id, { adapterConfig: { provider: "codex", model: "changed" } }); + expect((await current(id)).lifecycleVersion).toBe(verifying.lifecycleVersion + 1); + }); + it("lets only the setup creator configure and retry a stopping draft with creation permission", async () => { await db.insert(companyMemberships).values(["setup-owner", "setup-other"].map(principalId => ({ companyId, principalType: "user", principalId, membershipRole: "member" }))); diff --git a/server/src/modules/agent-lifecycle/adapters/configuration.ts b/server/src/modules/agent-lifecycle/adapters/configuration.ts index 5a4554de98f..788341b1165 100644 --- a/server/src/modules/agent-lifecycle/adapters/configuration.ts +++ b/server/src/modules/agent-lifecycle/adapters/configuration.ts @@ -4,7 +4,7 @@ import { agentConfigurationRevision } from "../../../lib/agent-configuration-rev import { randomUUID } from "node:crypto"; import { eq } from "drizzle-orm"; import { agents, type Db } from "@paperclipai/db"; -import { agentRecordQueries, AGENT_CONFIGURATION_FIELDS, jsonEqual, type AgentConfigurationPatch, type UpdateAgentOptions } from "../../../lib/agent-records.js"; +import { agentRecordQueries, adapterConfigWithoutInstructions, AGENT_CONFIGURATION_FIELDS, jsonEqual, type AgentConfigurationPatch, type UpdateAgentOptions } from "../../../lib/agent-records.js"; import type { ActivityPublication } from "../../../types/activity-publication.js"; import { AgentLifecycleConflict, canConfigureAgentConnection } from "../domain/policy.js"; import type { LifecycleEffects } from "./effects.js"; @@ -24,21 +24,29 @@ export async function updateAgentConfiguration(tx: Db, effects: LifecycleEffects } const patch = await effects.prepareConfiguration(tx, current, data, options); assertConfigurationFields(patch); - const changed = ["adapterType", "adapterConfig", "runtimeConfig", "defaultEnvironmentId"].some(key => - Object.prototype.hasOwnProperty.call(patch, key) && !jsonEqual(patch[key as keyof typeof patch], current[key as keyof typeof current])); - const needsEnvironmentSetup = ["ready", "verifying"].includes(current.lifecycleState) - && Object.prototype.hasOwnProperty.call(patch, "defaultEnvironmentId") - && patch.defaultEnvironmentId !== current.defaultEnvironmentId + const patched = (key: K) => + Object.prototype.hasOwnProperty.call(patch, key) && !jsonEqual(patch[key], current[key]); + const environmentChanged = patched("defaultEnvironmentId"); + const changed = environmentChanged || patched("adapterType") || patched("adapterConfig") || patched("runtimeConfig"); + const executionChanged = environmentChanged || patched("adapterType") || patched("runtimeConfig") || patched("adapterConfig") + && !jsonEqual(adapterConfigWithoutInstructions(patch.adapterConfig), adapterConfigWithoutInstructions(current.adapterConfig)); + const settingUp = current.lifecycleHolds.includes("setup"); + const needsEnvironmentSetup = environmentChanged && ["ready", "preparing", "verifying"].includes(current.lifecycleState) && await effects.environmentChangeRequiresSetup(tx, current.defaultEnvironmentId, patch.defaultEnvironmentId, current.lifecycleRequiredPluginIds); const pauseForEnvironment = needsEnvironmentSetup && current.lifecycleState === "ready"; - const prepareEnvironment = needsEnvironmentSetup && !current.lifecycleHolds.includes("setup"); - const prepareSetup = changed && current.lifecycleHolds.length === 1 && current.lifecycleHolds[0] === "setup" - && ["paused", "preparing", "verifying"].includes(current.lifecycleState) + const draft = changed && current.lifecycleHolds.length === 1 && settingUp + && ["paused", "preparing", "verifying"].includes(current.lifecycleState); + const draftNeedsPreparation = draft && await effects.setupRequiresPreparation(tx, current.companyId, Object.prototype.hasOwnProperty.call(patch, "defaultEnvironmentId") ? patch.defaultEnvironmentId : current.defaultEnvironmentId, { adapterType: patch.adapterType ?? current.adapterType, adapterConfig: Object.prototype.hasOwnProperty.call(patch, "adapterConfig") ? patch.adapterConfig : current.adapterConfig }); - const invalidate = changed && (["preparing", "verifying", "resuming"].includes(current.lifecycleState) || prepareSetup || pauseForEnvironment); + const prepareSetup = draftNeedsPreparation && (current.lifecycleState === "paused" || needsEnvironmentSetup); + const stopSetup = draft && !draftNeedsPreparation && current.lifecycleState !== "paused"; + const prepareEnvironment = needsEnvironmentSetup && !settingUp && !pauseForEnvironment; + const reverify = executionChanged && !settingUp && current.lifecycleState === "verifying"; + const invalidate = prepareSetup || stopSetup || prepareEnvironment || pauseForEnvironment || reverify + || changed && current.lifecycleState === "resuming"; if(prepareSetup&&!canConfigureAgentConnection(current))await effects.beforeConnectionEligibilityRestore?.(tx,current.companyId,current.id); if (pauseForEnvironment) await effects.beforeStatusChange(tx, current.companyId, id, current.status, "paused"); if (invalidate) await effects.notifyWork(tx); @@ -46,8 +54,7 @@ export async function updateAgentConfiguration(tx: Db, effects: LifecycleEffects lifecycleVersion: current.lifecycleVersion + 1, lifecycleError: null, ...(prepareSetup || prepareEnvironment ? { lifecycleState: "preparing" as const } : {}), ...(pauseForEnvironment ? { lifecycleState: "pausing" as const, status: "paused", pausedAt: new Date() } : {}), - ...(!prepareSetup && current.lifecycleHolds.includes("setup") && ["preparing", "verifying"].includes(current.lifecycleState) - ? { lifecycleState: "pausing" as const } : {}), + ...(stopSetup ? { lifecycleState: "pausing" as const } : {}), lifecycleOperation: { ...current.lifecycleOperation!, id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, leaseOwner: undefined, leaseUntil: undefined, leaseHolder: undefined, retryAt: undefined, retryRequired: undefined, verificationFailures: undefined, diff --git a/server/src/modules/agent-lifecycle/adapters/records.ts b/server/src/modules/agent-lifecycle/adapters/records.ts index 082716afd83..67034243342 100644 --- a/server/src/modules/agent-lifecycle/adapters/records.ts +++ b/server/src/modules/agent-lifecycle/adapters/records.ts @@ -38,20 +38,30 @@ export function agentRecords(db: Db, effects: LifecycleEffects) { const companyHolds = company?.status === "paused" ? ["company_paused"] : company?.status === "archived" ? ["company_archived"] : []; const holds = [...(status === "paused" ? [pauseReason ?? "manual"] : []), ...companyHolds]; const prepareSetup = options?.setupOnly && !companyHolds.length && await effects.setupRequiresPreparation(txDb, companyId, prepared.defaultEnvironmentId, prepared); + const keepsPreparation = setup !== undefined && status !== "pending_approval" && status !== "terminated" && !holds.length + && (setup.lifecycleState === "preparing" || setup.lifecycleState === "verifying") + && !await effects.environmentChangeRequiresSetup(txDb, setup.defaultEnvironmentId, + prepared.defaultEnvironmentId === undefined ? setup.defaultEnvironmentId : prepared.defaultEnvironmentId, setup.lifecycleRequiredPluginIds); + const joinsPreparation = keepsPreparation && setup.lifecycleState === "preparing" && setup.lifecycleOperation !== null; const lifecycleState = status === "pending_approval" ? "pending_approval" : status === "terminated" ? "terminated" - : prepareSetup ? "preparing" : status === "paused" ? "paused" : companyHolds.length ? "pausing" : "preparing"; - if (lifecycleState === "preparing" || lifecycleState === "pausing") await effects.notifyWork(tx); + : prepareSetup ? "preparing" : status === "paused" ? "paused" : companyHolds.length ? "pausing" + : keepsPreparation && setup.lifecycleState === "verifying" ? "verifying" : "preparing"; + if (lifecycleState === "preparing" || lifecycleState === "verifying" || lifecycleState === "pausing") await effects.notifyWork(tx); const createdStatus=status === "pending_approval" ? "pending_approval" : status === "terminated" ? "terminated" : "paused"; + const responsibleUserId = options?.responsibleUserId ?? options?.createdByUserId; const values: typeof agents.$inferInsert = { ...prepared, ...(setup ? { permissions: preserveAgentInteractionPermissions(setup.permissions, prepared.permissions) } : {}), createdByUserId: setup?.createdByUserId ?? options?.createdByUserId ?? null, lifecycleState, - lifecycleVersion: setup ? setup.lifecycleVersion + 1 : 1, + lifecycleVersion: !setup ? 1 : joinsPreparation ? setup.lifecycleVersion : setup.lifecycleVersion + 1, lifecycleHolds: holds, + lifecycleError: null, pauseReason: holds[0] ?? null, pausedAt: holds.length ? new Date() : null, - lifecycleOperation: { id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, resumeState: "preparing" as const, responsibleUserId: options?.responsibleUserId ?? options?.createdByUserId }, + lifecycleOperation: joinsPreparation + ? { ...setup.lifecycleOperation!, retryAt: undefined, responsibleUserId } + : { id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, resumeState: "preparing" as const, responsibleUserId }, status: createdStatus, companyId, }; diff --git a/server/src/services/plugin-environment-driver.ts b/server/src/services/plugin-environment-driver.ts index b12965e0372..e478c696278 100644 --- a/server/src/services/plugin-environment-driver.ts +++ b/server/src/services/plugin-environment-driver.ts @@ -86,10 +86,11 @@ export async function agentsNeedSetupForEnvironmentChange(db: Db, before: AgentE const usesEnvironment = or(users.environmentId ? eq(agents.defaultEnvironmentId, users.environmentId) : undefined, users.inheritsDefault ? isNull(agents.defaultEnvironmentId) : undefined); if (!usesEnvironment) return false; - const unprepared = previous?.pluginId === target.pluginId ? undefined + const changesDriver = previous?.pluginId === target.pluginId; + const unprepared = changesDriver ? undefined : sql`not coalesce(${agents.lifecycleRequiredPluginIds}, '[]'::jsonb) @> ${JSON.stringify([target.pluginId])}::jsonb`; const [waiting] = await db.select({ id: agents.id }).from(agents).where(and(usesEnvironment, - inArray(agents.lifecycleState, ["ready", "verifying"]), unprepared)).limit(1); + inArray(agents.lifecycleState, changesDriver ? ["ready", "preparing", "verifying"] : ["ready", "verifying"]), unprepared)).limit(1); return Boolean(waiting); } From c5f5d3163db8109f29dca8145f57a9a6b64a8d5d Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 16:22:38 -0800 Subject: [PATCH 007/119] test: remove recovery and Tailscale readiness races (#23678) ## Thinking Path > - Paperclip requires checks for an exact Core source commit before it publishes images. > - Cloud readiness runs the server integration tests without retries. > - Server shard 18/20 failed in recovery cleanup and Tailscale enrollment. > - The recovery test returned before its status wake reached the heartbeat drain. > - The Tailscale fixture exposed state before it was safe to read or observe. > - This pull request makes those fixtures wait for their actual completion boundaries. ## Linked Issues or Issue Description Refs #23227. Related earlier cleanup fix: #23673. **What happened?** [Docker run 47225196060](https://github.com/paperclipai/paperclip/actions/runs/47225196060) stopped after [Cloud readiness server shard 18/20](https://github.com/paperclipai/paperclip/actions/runs/47225196237/job/144677926140) failed. Staging image preparation then waited for a verified Core image. The previous Runner reattachment cleanup fix passed its protocol lane in that run. The recovery test deleted agents after a late wake inserted a child row. The Tailscale test failed its first connection. On the [next master run](https://github.com/paperclipai/paperclip/actions/runs/47227863572/job/144687185775), the Tailscale blocked-save test timed out while waiting for a callback that startup might never reach. **Expected behavior** Fixture teardown must join the status wake. The fake Tailscale CLI must publish complete state and receive each simulated consent event reliably. Tests must await enrollment completion and fail promptly when connection setup fails. **Steps to reproduce** Run the two changed test files or server shard 18/20 with retries disabled. The unmodified local files reproduced a consent callback failure. The CI links above record the foreign-key and blocked-save failures. The foreign-key failure did not reproduce in the initial local run. **Paperclip version or commit** Failures on `07150650c926d8947ae591f61e4ed854ca284149` and `ba521863f6090e40a37ed3cb6b1ecaf358a11424`. The fix starts from the latter and is rebased onto `86042310917c15eb04be121baf58a6929e52a7d2`, which adds release notes only. **Deployment mode** Source checkout in GitHub Actions. Local checks use macOS arm64, Node 25.6.1, hermetic Tailscale executables, and disposable embedded PostgreSQL. Searched open PRs and issues for the failing files, `ENOTEMPTY`, Runner cleanup, and Tailscale tests. No duplicate fix was found. Issue #23227 describes the startup-dependent expiry window and is also addressed here. ## What Changed - Wait for the accepted recovery status change to persist its wake before the existing heartbeat drain deletes fixture tables. The wake has an asynchronous route prologue that can outlive the HTTP response. - Register a signal handler in the owned fake CLI before exposing the login URL. Publish fixture state atomically, then signal that exact child to simulate consent. This removes the dependency on filesystem notification delivery. - Await the network manager's completion promise instead of a short callback polling window. - Start the expiry test with a valid window, advance the application clock after startup, and submit late consent. Keep real subprocess timers and restore the clock spy in `finally`. - Race blocked-save admission against early connection settlement so startup failures are reported instead of hanging the test. - Only two test files change. Runtime behavior, release gates, and deployment policy do not change. ## Verification - Baseline: the unmodified two-file run failed the consent callback assertion; 129 tests passed. The recovery cleanup passed locally, with its CI failure retained above. - An intermediate expiry check failed its one-second callback wait. A later parallel shard run still lost a filesystem notification. The final fixture uses an explicit consent signal and awaits manager completion. - That eight-worker shard run also timed out in unchanged workspace-trust and runtime-control fixtures while a monolithic typecheck ran concurrently. Those two unchanged files passed in a serial control with the changed fixtures: 186 tests passed across four files. The final shard is run separately with four workers and retries disabled. - `pnpm exec tsc --noEmit -p tsconfig.json` from `server/`: passed. - After the release-notes-only rebase, the Tailscale file passed again: 9 tests, retries disabled. The two fixture file contents are identical to the final shard run. - `PAPERCLIP_VITEST_RETRY=0 PAPERCLIP_VITEST_MAX_WORKERS=4 pnpm test:run:general -- --group general-server-without-chat-or-native-runner --shard-index 17 --shard-count 20`: passed on the final fixture contents. 85 files passed, 3 skipped; 1945 tests passed, 18 skipped. Duration: 160 seconds. - `node scripts/check-test-budget.mjs --files server/src/__tests__/issue-recovery-actions.test.ts server/src/services/connectors/tailscale/device-login-network.test.ts`: passed. - `git diff --check` and local secret/PII review: passed. - [Greptile review](https://github.com/paperclipai/paperclip/pull/23678#issuecomment-7396242983): 5/5 on head `13bf3586bcf3201ce137f674812e8faf778ee77d`, with a successful current-head check and no actionable findings or review threads. The [full PR CI workflow](https://github.com/paperclipai/paperclip/actions/runs/47231990509) passed on attempt 1. All 71 reported checks are clean on this head; GitHub reports `CLEAN` / `MERGEABLE` and there are no unresolved review threads. ## Risks Low risk. The change is limited to fixtures. A missing status wake or failed enrollment still fails the tests. The expiry case now checks actual late-consent rejection without making success depend on process startup time. No schema, API, or runtime changes are required. The tests and PR explain the behavior; no documentation update is needed. A new verified master image is still required before staging can resume. ## Model Used OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, with xhigh reasoning effort, shell and file tools. The harness does not expose the context window size. ## 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 Co-authored-by: Paperclip --- .../__tests__/issue-recovery-actions.test.ts | 6 ++++ .../tailscale/device-login-network.test.ts | 35 +++++++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/server/src/__tests__/issue-recovery-actions.test.ts b/server/src/__tests__/issue-recovery-actions.test.ts index cc9c89fe369..dd1228d49a7 100644 --- a/server/src/__tests__/issue-recovery-actions.test.ts +++ b/server/src/__tests__/issue-recovery-actions.test.ts @@ -2222,6 +2222,12 @@ describeEmbeddedPostgres("issue recovery actions", () => { await db.delete(issueRecoveryActions).where(eq(issueRecoveryActions.id, f.hold.id)); await seedLiveOwnerRun(f); await request(f.agent).patch(`/api/issues/${f.sourceIssueId}`).send({ status: "todo" }).expect(200); + await vi.waitFor(async () => { + const wakes = await db.select().from(agentWakeupRequests).where(eq(agentWakeupRequests.companyId, f.companyId)); + expect(wakes).toEqual(expect.arrayContaining([expect.objectContaining({ + agentId: f.coderId, payload: expect.objectContaining({ issueId: f.sourceIssueId }), + })])); + }, { timeout: 5_000 }); }); async function seedReconciledDelivery() { diff --git a/server/src/services/connectors/tailscale/device-login-network.test.ts b/server/src/services/connectors/tailscale/device-login-network.test.ts index 8b2a4f3a4b2..62e825a15f3 100644 --- a/server/src/services/connectors/tailscale/device-login-network.test.ts +++ b/server/src/services/connectors/tailscale/device-login-network.test.ts @@ -9,6 +9,8 @@ async function publishState(statePath: string, state: unknown) { const nextPath = `${statePath}.next`; await fs.writeFile(nextPath, JSON.stringify(state)); await fs.rename(nextPath, statePath); + const pid = Number(await fs.readFile(path.join(path.dirname(statePath), "up-pid"), "utf8")); + process.kill(pid, "SIGUSR2"); } describe("Tailscale interactive device enrollment", () => { @@ -36,10 +38,15 @@ if (args[1] === 'up') { if (args.some(arg => arg.startsWith('--auth-key'))) process.exit(5); if (state.BackendState === 'Running') process.exit(0); state = { MachineKey: state.MachineKey || path.basename(dir), BackendState: 'NeedsLogin', AuthURL: 'https://login.tailscale.com/a/fixture' }; - fs.writeFileSync(statePath, JSON.stringify(state)); - fs.watch(dir, () => { + const check = () => { if (JSON.parse(fs.readFileSync(statePath, 'utf8')).BackendState === 'Running') process.exit(0); - }); + }; + process.on('SIGUSR2', check); + fs.writeFileSync(path.join(dir, 'up-pid'), String(process.pid)); + fs.writeFileSync(statePath + '.next', JSON.stringify(state)); + fs.renameSync(statePath + '.next', statePath); + check(); + setInterval(() => {}, 1000); } else if (args[1] === 'status') console.log(JSON.stringify(state)); `, { mode: 0o700 }); manager = createTailscaleNetworkManager({ daemon: path.join(dir, "daemon"), cli: path.join(dir, "cli") }); @@ -59,7 +66,8 @@ if (args[1] === 'up') { expect(credential).not.toBe(emptyState); expect(authorized).not.toHaveBeenCalled(); await publishState(statePath, { ...state, BackendState: "Running", AuthURL: "" }); - await vi.waitFor(() => expect(authorized).toHaveBeenCalledOnce()); + expect(await manager.loginStatus(input.identity)).toEqual({ status: "connected" }); + expect(authorized).toHaveBeenCalledOnce(); await manager.close(); const restored = await manager.connect({ identity: input.identity, credential, persist: input.persist }); expect(JSON.parse(await fs.readFile(path.join(path.dirname(restored), "state"), "utf8")).MachineKey).toBe(state.MachineKey); @@ -83,12 +91,19 @@ if (args[1] === 'up') { it("stops an expired sign-in without accepting late consent", async () => { const authorized = vi.fn(); const failure = vi.fn().mockResolvedValue(undefined); + const expiresAt = Date.now() + 60_000; const socket = await manager.connect({ identity: "expires", credential: emptyState, persist: vi.fn(), - login: { expiresAt: Date.now() + 1200, onAuthorized: authorized, onFailure: failure } }); - await vi.waitFor(() => expect(failure).toHaveBeenCalledOnce(), { timeout: 4000 }); - await vi.waitFor(async () => expect(await manager.loginStatus("expires")).toBeNull()); - expect(authorized).not.toHaveBeenCalled(); - await expect(fs.stat(path.dirname(socket))).rejects.toMatchObject({ code: "ENOENT" }); + login: { expiresAt, onAuthorized: authorized, onFailure: failure } }); + const now = Date.now.bind(Date); + const clock = vi.spyOn(Date, "now").mockImplementation(() => now() + 60_000); + try { + await publishState(path.join(path.dirname(socket), "state"), { BackendState: "Running" }); + await manager.loginStatus("expires").catch(() => undefined); + expect(failure).toHaveBeenCalledOnce(); + await vi.waitFor(async () => expect(await manager.loginStatus("expires")).toBeNull(), { timeout: 5_000 }); + expect(authorized).not.toHaveBeenCalled(); + await expect(fs.stat(path.dirname(socket))).rejects.toMatchObject({ code: "ENOENT" }); + } finally { clock.mockRestore(); } }); it("lets secret deletion cancel a blocked credential save", async () => { @@ -100,7 +115,7 @@ if (args[1] === 'up') { login: { expiresAt: Date.now() + 60_000, onAuthorized: vi.fn(), onFailure: vi.fn() } }); const settled = connecting.catch(() => undefined); try { - await entered; + await Promise.race([entered, connecting.then(() => { throw new Error("Credential save did not block"); })]); await manager.disconnect("deleted-secret", { discardState: true }); await expect(connecting).rejects.toThrow("Tailscale"); expect(await manager.loginStatus("deleted-secret")).toBeNull(); From ded4c1bf15f8b08bc5564e92d3dcb555c2345e9c Mon Sep 17 00:00:00 2001 From: Danila Katalshov <56929384+ADanMan@users.noreply.github.com> Date: Fri, 4 Dec 2026 03:49:11 +0300 Subject: [PATCH 008/119] fix(server): encode Unicode asset response filenames (#22892) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People open uploaded files and company logos from their browser. > - Two routes put the stored filename directly into an HTTP header. > - Node rejects some valid Unicode names used by screenshot tools and people. > - This change formats both filenames with the same Express API used for issue attachments. ## Linked Issues or Issue Description Fixes: #7493 Thanks to dosthcpp for the report and the earlier proposal in #7494. The issue attachment route already uses Express to format the filename. The asset content and invite logo routes still wrote it directly. Related #8716 and #9570 cover attachment display policy and ZIP downloads. ## What Changed - Format the filename with Express in the asset content and invite logo responses. Keep the current content type and inline or attachment choice. - Exercise a screenshot with a narrow non-breaking space and a logo with Japanese characters. ## Verification - On the preceding master `f1dd9288d`, both Unicode cases returned 500 before the fix. - On `3fbf872d9` with the fix, 57 tests passed across the assets, invite logo, and issue attachment suites. The new checks verify status, Unicode filename encoding, and inline disposition. - Full server typecheck, test budget, and `git diff --check` passed. PR CI is pending. ## Risks - Both routes still set the content type from storage metadata after formatting the filename. The existing disposition, range, and content policy behavior remain covered by the route tests. ## Model Used - OpenAI Codex (GPT-6 family) with terminal and Vitest access. Exact model identifier and context window were not exposed in this session. ## 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 - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --- server/src/__tests__/assets.test.ts | 27 +++++++++++++++++++ .../src/__tests__/invite-logo-route.test.ts | 8 ++++-- server/src/routes/access.ts | 5 ++-- server/src/routes/assets.ts | 10 +++---- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/server/src/__tests__/assets.test.ts b/server/src/__tests__/assets.test.ts index 5825e47e1b1..84fd65974f1 100644 --- a/server/src/__tests__/assets.test.ts +++ b/server/src/__tests__/assets.test.ts @@ -494,6 +494,33 @@ describe("GET /api/assets/:assetId/content", () => { expect(res.headers["content-security-policy"]).toBe("sandbox; default-src 'none'"); }); + it("serves screenshots with Unicode filenames inline", async () => { + const bytes = Buffer.from("png-bytes"); + const filename = "Screenshot 10.32.55\u202fPM.png"; + const storage = createStorageService("image/png"); + getAssetByIdMock.mockResolvedValue({ + ...createAsset(), + originalFilename: filename, + byteSize: bytes.byteLength, + }); + vi.mocked(storage.getObject).mockResolvedValue({ + stream: Readable.from(bytes), + contentType: "image/png", + contentLength: bytes.byteLength, + }); + + const response = await requestApp(await createApp(storage), (baseUrl) => + request(baseUrl).get("/api/assets/asset-1/content"), + ); + + expect(response.status).toBe(200); + expect(response.headers["content-type"]).toBe("image/png"); + expect(response.headers["content-disposition"]).toBe( + `inline; filename="Screenshot 10.32.55?PM.png"; filename*=UTF-8''${encodeURIComponent(filename)}`, + ); + expect(response.body).toEqual(bytes); + }); + it("keeps curated image types inline", async () => { const image = Buffer.from("png-bytes"); const storage = createStorageService("image/png"); diff --git a/server/src/__tests__/invite-logo-route.test.ts b/server/src/__tests__/invite-logo-route.test.ts index a18137c3ab4..75e8591a89a 100644 --- a/server/src/__tests__/invite-logo-route.test.ts +++ b/server/src/__tests__/invite-logo-route.test.ts @@ -68,7 +68,10 @@ describe("GET /invites/:token/logo", () => { mockStorage.headObject.mockReset(); }); - it("serves the company logo for an active invite without company auth", async () => { + it.each([ + { filename: "logo.png", disposition: 'inline; filename="logo.png"' }, + { filename: "ロゴ.png", disposition: `inline; filename="??.png"; filename*=UTF-8''${encodeURIComponent("ロゴ.png")}` }, + ])("serves $filename for an active invite without company auth", async ({ filename, disposition }) => { const invite = { id: "invite-1", companyId: "company-1", @@ -99,7 +102,7 @@ describe("GET /invites/:token/logo", () => { objectKey: "assets/companies/logo-1", contentType: "image/png", byteSize: 3, - originalFilename: "logo.png", + originalFilename: filename, }]), ); @@ -107,6 +110,7 @@ describe("GET /invites/:token/logo", () => { expect(res.status).toBe(200); expect(res.headers["content-type"]).toContain("image/png"); + expect(res.headers["content-disposition"]).toBe(disposition); expect(mockStorage.headObject).toHaveBeenCalledWith("company-1", "assets/companies/logo-1"); expect(mockStorage.getObject).toHaveBeenCalledWith("company-1", "assets/companies/logo-1"); }); diff --git a/server/src/routes/access.ts b/server/src/routes/access.ts index bfea3bfb084..cb64905d0ac 100644 --- a/server/src/routes/access.ts +++ b/server/src/routes/access.ts @@ -3613,6 +3613,8 @@ export function accessRoutes( logoHead.contentType || object.contentType || "application/octet-stream"; + res.attachment(logoAsset.originalFilename || "company-logo"); + res.setHeader("Content-Disposition", String(res.getHeader("Content-Disposition")).replace(/^attachment;/, "inline;")); res.setHeader("Content-Type", responseContentType); res.setHeader( "Content-Length", @@ -3623,9 +3625,6 @@ export function accessRoutes( if (responseContentType === "image/svg+xml") { res.setHeader("Content-Security-Policy", "sandbox; default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'"); } - const filename = logoAsset.originalFilename ?? "company-logo"; - res.setHeader("Content-Disposition", `inline; filename=\"${filename.replaceAll("\"", "")}\"`); - object.stream.on("error", (err) => { next(err); }); diff --git a/server/src/routes/assets.ts b/server/src/routes/assets.ts index 5f48886baa3..cd0e6c801d0 100644 --- a/server/src/routes/assets.ts +++ b/server/src/routes/assets.ts @@ -352,6 +352,10 @@ export function assetRoutes(db: Db, storage: StorageService) { const mediaType = responseContentType.split(";", 1)[0]?.trim().toLowerCase() ?? ""; const inlineSafe = mediaType !== SVG_CONTENT_TYPE && isInlineAttachmentContentType(mediaType); + res.attachment(asset.originalFilename || "asset"); + if (inlineSafe) { + res.setHeader("Content-Disposition", String(res.getHeader("Content-Disposition")).replace(/^attachment;/, "inline;")); + } res.setHeader("Content-Type", responseContentType); res.setHeader("Content-Length", String(range ? range.end - range.start + 1 : asset.byteSize || object.contentLength || 0)); if (range) { @@ -363,12 +367,6 @@ export function assetRoutes(db: Db, storage: StorageService) { if (!inlineSafe) { res.setHeader("Content-Security-Policy", "sandbox; default-src 'none'"); } - const filename = asset.originalFilename ?? "asset"; - const disposition = inlineSafe - ? "inline" - : "attachment"; - res.setHeader("Content-Disposition", `${disposition}; filename=\"${filename.replaceAll("\"", "")}\"`); - object.stream.on("error", (err) => { next(err); }); From 8a5b374a9c8f9985334fc8c4fbd07a401e76b348 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 17:27:03 -0800 Subject: [PATCH 009/119] test: order Antigravity mode changes before admission readback (#23685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The Runner checks provider settings before it admits an Antigravity swarm. > - A test changes a confirmed mode during admission and expects rejection. > - The fake CLI could complete model readback before it sent the mode change. > - Pipe scheduling could then move the change past admission and fail the test. > - This pull request sends the mode change before model readback. > - The test can now check admission rejection without depending on pipe timing. ## Linked Issues or Issue Description **What happened?** [Cloud readiness run 47231816304, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47231816304/job/144707142899) failed the Antigravity test named “turns a provider mode change during admission into a typed failure, stops the CLI, and keeps the caller alive”. The open promise resolved instead of rejecting. This cancelled [image run 47231816399](https://github.com/paperclipai/paperclip/actions/runs/47231816399). **Expected behavior** The fixture must deliver the mode change while admission still waits for model readback. The runtime must reject with `ANTIGRAVITY_SWARM_RECEIPT_MISMATCH` and stop its child process. **Steps to reproduce** Run `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run src/drivers/acpx/antigravity-swarm-runtime.test.ts --maxWorkers=1` from `packages/paperclip-runner`. Before this change, the `mode-flip` fixture wrote the valid model update before the invalid mode update. Separate pipe reads could let admission finish between them. The CI failure shows this outcome. One focused local baseline attempt passed, so the intermittent failure was not reproduced locally. ## What Changed - Send the `mode-flip` notification before the model configuration update. Admission cannot finish model readback before it receives the invalid mode. - Keep the existing rejection and child retirement assertions. The idle mode-change fixture and runtime code stay as they are. ## Verification - The full Antigravity swarm runtime file passed: 66 tests, retries disabled, one worker. - `node --check packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs` passed. - `node scripts/check-test-budget.mjs --base origin/master` passed. - `git diff --check` passed. - `pnpm verify --explain` returned exit 2 because a Runner fixture needs broad CI coverage. Required CI will supply that coverage. - Final head `2c55808f394ad07dc279a6d074fecb9f61fa540f`: [PR CI run 47239627453, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47239627453/attempts/2) passed. It reports 76 successful jobs and one skipped selection job. Both required gates (`ci / verify` and `ci / e2e`) passed. Standalone Runner image checks, macOS checks, and Windows Rust checks passed. No checks remain active. GitHub reports `CLEAN` and `MERGEABLE`. - Greptile scored this exact head 5/5 with no actionable findings or unresolved review threads. - Earlier failures remain accounted for: [the delayed initial run](https://github.com/paperclipai/paperclip/actions/runs/47239537426) was superseded by the `full-ci` label run and cancelled by PR concurrency. Attempt 1 of the replacement run passed 73 jobs, but [policy](https://github.com/paperclipai/paperclip/actions/runs/47239627453/job/144728063451) exceeded its 10-minute limit. Both final gates then failed with `Policy must succeed`, actual `cancelled`. Policy logs returned `BlobNotFound`, so the stalled step and cause are unknown. After the run completed, GitHub accepted a policy-job rerun request. This reran the reusable CI workflow in attempt 2, which passed in full. The passing retry establishes recovery; it does not establish the timeout's cause. - Separate operational issue: master image runs [47235737261](https://github.com/paperclipai/paperclip/actions/runs/47235737261) and [47238936675](https://github.com/paperclipai/paperclip/actions/runs/47238936675) failed their source observers because GitHub's Actions job-list API returned HTTP 502. Their architecture builds and exact-source readiness runs passed. The current master's job-list request still returns 502 with `per_page=100`. Small pages can read that image run, but a small-page source-readiness request also failed. There is no verified pagination workaround. This fixture change does not resolve that API failure or prove image publication. ## Risks - Low risk. The diff changes one notification's order in a test fixture. It adds no runtime behavior or configuration. - The original intermittent failure was observed in CI. The local baseline attempt passed. The fix removes the ordering gap identified in that failure. The full CI workflow passed for the final revision. - Documentation does not change because the runtime contract stays the same. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell tools. The context window size is not exposed by the runtime. ## 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 Co-authored-by: Paperclip --- .../test-fixtures/antigravity-cli/fake-agy-acp.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs b/packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs index 10da7edbe76..07f39db0a90 100644 --- a/packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs +++ b/packages/paperclip-runner/test-fixtures/antigravity-cli/fake-agy-acp.mjs @@ -271,8 +271,8 @@ async function handle(message) { write({ jsonrpc: "2.0", id, result: {} }); const match = /^(.*)-(low|medium|high)$/.exec(params.modelId); state.model = match[1]; state.level = scenario === "wrong-model" ? "high" : match[2]; - update(state.sessionId, { sessionUpdate: "config_option_update", configOptions: configOptions() }); if (scenario === "mode-flip") update(state.sessionId, { sessionUpdate: "current_mode_update", currentModeId: "default" }); + update(state.sessionId, { sessionUpdate: "config_option_update", configOptions: configOptions() }); if (scenario === "mode-flip-idle") setTimeout(() => update(state.sessionId, { sessionUpdate: "current_mode_update", currentModeId: "default" }), 100); return; } From 0d867729db122cf6a23046f89a8237d51f039331 Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Thu, 3 Dec 2026 17:34:34 -0800 Subject: [PATCH 010/119] fix(server): encode non-Latin-1 workspace download filenames (#23683) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Board users can open and download files from a task's workspace through the file-resources route > - The download response builds a raw `Content-Disposition` header from the file name > - Node rejects header values that hold characters outside Latin-1, such as the U+202F narrow no-break space in macOS screenshot names, or CJK text > - The route then fails with `TypeError: Invalid character in header content ["Content-Disposition"]` and returns 500 > - This pull request makes the route use `res.attachment()`, which encodes the name correctly > - The benefit is that users can download workspace files with any name ## Linked Issues or Issue Description Refs #22892. That PR fixes the same defect in the asset and invite-logo routes. This PR fixes the last route that builds the header by hand: the workspace file download. The two PRs change different files and do not conflict. **What happened?** A staging server reported `TypeError: Invalid character in header content ["Content-Disposition"]` from `ServerResponse.setHeader`. A workspace file download with a non-Latin-1 file name returns HTTP 500 for the same reason. **Expected behavior** The download succeeds. The header holds an ASCII `filename` fallback and an RFC 6266 `filename*` parameter with the full UTF-8 name. **Steps to reproduce** 1. Put a file named `Screenshot 10.32.55 PM.png` (with U+202F before `PM`) in a project workspace. 2. Download it through `GET /api/issues/:issueId/file-resources/content?download=1`. 3. The server returns 500. **Relevant logs or output** `TypeError: Invalid character in header content ["Content-Disposition"]` at `ServerResponse.setHeader (node:_http_outgoing)`. ## What Changed - `server/src/routes/file-resources.ts`: the download path now calls `res.attachment(safeAttachmentFilename(title))` instead of writing the raw header. The call comes before `Content-Type`, so the route keeps its own content type. - `server/src/__tests__/file-resources.test.ts`: a new test downloads a file whose name holds U+202F and Japanese text. It checks the status, the content type, the encoded `Content-Disposition`, and the bytes. ## Verification - Red: without the route change, `npx vitest run src/__tests__/file-resources.test.ts -t "not Latin-1"` fails with `expected 500 to be 200`. - Green: with the change, `npx vitest run src/__tests__/file-resources.test.ts` passes (53 of 53). The old `archive.bin` and `index.html` download tests still get `attachment; filename="..."` unchanged. - I also reproduced the Node error directly: `setHeader("Content-Disposition", 'inline; filename="Screenshot 10.32.55 PM.png"')` throws the same message. ## Risks Low risk. ASCII file names produce the same header as before. Non-Latin-1 names now get a `?` fallback in `filename` and the full name in `filename*`, which current browsers use. `res.attachment()` also sets `Content-Type` from the extension, but the route sets its own value right after that call. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), used as an agent with tool use (shell, code edits, test runs). ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- server/src/__tests__/file-resources.test.ts | 33 +++++++++++++++++++++ server/src/routes/file-resources.ts | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/server/src/__tests__/file-resources.test.ts b/server/src/__tests__/file-resources.test.ts index 3aedd70b5aa..406078adff5 100644 --- a/server/src/__tests__/file-resources.test.ts +++ b/server/src/__tests__/file-resources.test.ts @@ -362,6 +362,39 @@ describeEmbeddedPostgres("workspace file resources", () => { expect(Buffer.compare(downloaded.body as Buffer, bytes)).toBe(0); }); + it("downloads workspace files whose names are not Latin-1", async () => { + const { projectRoot, executionRoot } = await makeWorkspace(); + const graph = await seedGraph(db, { projectRoot, executionRoot }); + const filename = "Screenshot 10.32.55 PM ロゴ.bin"; + const bytes = Buffer.from([0, 1, 2, 3]); + await fs.writeFile(path.join(projectRoot, filename), bytes); + + const app = createApp(db, { + type: "board", + userId: "board-user", + companyIds: [graph.companyId], + source: "session", + isInstanceAdmin: false, + }); + + const downloaded = await request(app) + .get(`/api/issues/${graph.issueId}/file-resources/content`) + .query({ workspace: "project", path: filename, download: "1" }) + .buffer(true) + .parse((res, callback) => { + const chunks: Buffer[] = []; + res.on("data", (chunk) => chunks.push(Buffer.from(chunk))); + res.on("end", () => callback(null, Buffer.concat(chunks))); + }); + + expect(downloaded.status).toBe(200); + expect(downloaded.headers["content-type"]).toBe("application/octet-stream"); + expect(downloaded.headers["content-disposition"]).toBe( + `attachment; filename="Screenshot 10.32.55?PM ??.bin"; filename*=UTF-8''${encodeURIComponent(filename)}`, + ); + expect(Buffer.compare(downloaded.body as Buffer, bytes)).toBe(0); + }); + it("falls back from an execution workspace miss to the project workspace", async () => { const { projectRoot, executionRoot } = await makeWorkspace(); const graph = await seedGraph(db, { projectRoot, executionRoot }); diff --git a/server/src/routes/file-resources.ts b/server/src/routes/file-resources.ts index fd1ac7e7f7b..84827d59a45 100644 --- a/server/src/routes/file-resources.ts +++ b/server/src/routes/file-resources.ts @@ -900,13 +900,13 @@ export function fileResourceRoutes(db: Db, opts: { }), }); + res.attachment(safeAttachmentFilename(result.resource.title)); res.setHeader("Content-Type", result.resource.contentType ?? "application/octet-stream"); if (result.resource.byteSize != null) { res.setHeader("Content-Length", String(result.resource.byteSize)); } res.setHeader("Cache-Control", "private, max-age=60"); res.setHeader("X-Content-Type-Options", "nosniff"); - res.setHeader("Content-Disposition", `attachment; filename="${safeAttachmentFilename(result.resource.title)}"`); if ("stream" in result) await pipeline(result.stream, res); else await pipeline(createReadStream(result.realPath), res); } finally { if ("stream" in result) await result.cleanup(); } From 3f882fc5895072e9a63e46df0eb0e1dad75f092b Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 17:44:15 -0800 Subject: [PATCH 011/119] fix(native): stage task-description attachments for native agents (#23688) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People often create a task with a screenshot in its description and assign it to a native agent. > - The native Runner stages wake-comment files into the agent workspace, so the agent can open an image with its file reader. > - Files attached to the task description have no comment, so the Runner never staged them. > - The agent then said that it could not see the screenshot, or it guessed from the text. > - This pull request stages the task's own files on every native wake. > - The benefit is that an agent can see the screenshot that explains the task. ## Linked Issues or Issue Description **What happened?** A user created a task with the description "This list should probably be sorted alphabetically" and pasted a screenshot of the list. A Claude agent on a native sandbox replied that it could not open the screenshot and asked which list to sort. It found the attachment through the API, but the run had no staged path and no tool that put the image in its workspace. When the same image was attached to a comment, the agent opened it at once. **Expected behavior** A native agent can inspect files that are attached to the task description, the same as files attached to a wake comment. **Steps to reproduce** 1. Create a task and paste an image into its description. 2. Assign the task to a native `paperclip_runner` agent. 3. Ask the agent what the image shows. 4. The prompt has no "Paperclip native attachment access" entry for the image, and the agent cannot see it. **Paperclip version or commit** `master` at c5f5d3163db. ## What Changed - New column `issue_attachments.issue_level` (boolean, default `false`, migration `0514`). It marks a file that a person attached to the task itself. - The UI sets `issueLevel` for new-task files, the task attachment picker and drop zone, the task side panel upload button and drop zone, the description editor, and task document images. Inline description draft images that are bound at publication are also marked. Comment-composer uploads, agent uploads and system files (for example workspace-recovery archives) stay unmarked. - The upload route accepts an optional `issueLevel` multipart field (`true` or `false`). A file with a comment is never issue-level. - `resolveNativeRunnerWakeAttachmentSelections` adds task files without a comment after the wake comment's files. A task file is marked issue-level, or the saved description links to it by its attachment or asset content path (this covers files saved before the marker, with no backfill). They come oldest first, within the existing 20-file limit. A full wake keeps its comment files and does not fail. Only files a person uploaded count; agent uploads, which carry no per-file trust, never do. A quarantined low-trust task does not stage them. - Staged descriptors for these files carry `taskAttachment: true`, so the agent can tell them from the current wake's files. - Runner download grants accept a null source comment for `wake` grants only. The download route requires that the file is in the current wake selection and has no comment. `history` grants still require a comment. ## Verification - New `native-runner-task-attachment-staging.test.ts` (embedded Postgres, with the migration): local staging of a task image, an unmarked file that the description links to, comment-first ordering, an unsent composer upload that is not staged and returns 404 on download, an agent upload that is marked and linked from the description but is not staged, the 20-file limit, low-trust quarantine, and the Runner download grant (200 for the task file, 404 for crossed comment/task grants, and no history grant without a comment). - `issue-attachment-routes.test.ts`: `issueLevel` is saved for `true`, is `false` when absent, and an invalid value returns 400. - `chat-attachment-read`, `native-chat-workspace`, `native-runner-attachment-staging`, `antigravity-run-start`, `paperclip-control-plane-port`, `native-stop-accounting.integration`: pass. `native-session-executor.test.ts`: 1572 passed, 7 skipped. - `pnpm run typecheck` in `server` and `ui`: passed. `IssueDetail.mobile.test.tsx`: passed. - `pnpm verify` asks for full CI because of the migration. The pinned runner-e2e source inputs are refreshed. ## Risks - Schema change: one `ADD COLUMN ... DEFAULT false NOT NULL`. PostgreSQL 11 and later add it without a table rewrite. - Existing attachments stay `false`. Older files that the description links to are still staged. Other older files without a comment are not staged. This fails closed, and a person can attach the file again. - The migration is a constant-default `ADD COLUMN` only; `migration-compatibility --check` passes. - A file attached through a task-level surface stays a task file until it is deleted, also if it is later removed from the description text. It stays in the task's Attachments list for everyone on the task. - Each native wake on a task with task files stages those files again. The 20-file and 10 MiB Runner download limits apply. Each wake adds one indexed query. - Adapter (non-native) runs do not change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, database reads of a test instance) and extended thinking. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip --- .../db/src/migrations/0514_lame_ricochet.sql | 1 + ...{0509_snapshot.json => 0514_snapshot.json} | 12447 +++++++++------- packages/db/src/migrations/meta/_journal.json | 7 + packages/db/src/schema/issue_attachments.ts | 6 +- packages/shared/src/validators/issue.ts | 5 + .../__tests__/issue-attachment-routes.test.ts | 24 + server/src/routes/issues.ts | 1 + server/src/services/issues.ts | 5 +- .../native-runner-file-handoff.ts | 63 +- ...ive-runner-task-attachment-staging.test.ts | 344 + .../runner-attachment-download.ts | 14 +- .../runner-e2e/source-sdk-public-inputs.json | 2 +- ui/src/api/issues.ts | 4 + ui/src/components/NewIssueDialog.tsx | 2 +- ui/src/hooks/useIssueArtifactUploads.ts | 2 +- ui/src/pages/IssueDetail.tsx | 26 +- 16 files changed, 7503 insertions(+), 5450 deletions(-) create mode 100644 packages/db/src/migrations/0514_lame_ricochet.sql rename packages/db/src/migrations/meta/{0509_snapshot.json => 0514_snapshot.json} (91%) create mode 100644 server/src/services/native-runtime/native-runner-task-attachment-staging.test.ts diff --git a/packages/db/src/migrations/0514_lame_ricochet.sql b/packages/db/src/migrations/0514_lame_ricochet.sql new file mode 100644 index 00000000000..47e0f59cc2d --- /dev/null +++ b/packages/db/src/migrations/0514_lame_ricochet.sql @@ -0,0 +1 @@ +ALTER TABLE "issue_attachments" ADD COLUMN "issue_level" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/packages/db/src/migrations/meta/0509_snapshot.json b/packages/db/src/migrations/meta/0514_snapshot.json similarity index 91% rename from packages/db/src/migrations/meta/0509_snapshot.json rename to packages/db/src/migrations/meta/0514_snapshot.json index 2b4ee814b21..d09acc6cbd2 100644 --- a/packages/db/src/migrations/meta/0509_snapshot.json +++ b/packages/db/src/migrations/meta/0514_snapshot.json @@ -1,6 +1,6 @@ { - "id": "01f5b33d-2353-4095-8b32-86aec4f8df2c", - "prevId": "8ddb0345-f9e8-4dde-8156-391f71d858b1", + "id": "74dc138b-0555-4b0b-8ca7-5cd3c84cd4e1", + "prevId": "9a37a733-51bb-4fbf-a1a9-ac65344e70cc", "version": "7", "dialect": "postgresql", "tables": { @@ -64,37 +64,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "accounting_runtime_baselines_agent_id_agents_id_fk": { "name": "accounting_runtime_baselines_agent_id_agents_id_fk", "tableFrom": "accounting_runtime_baselines", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "accounting_runtime_baselines_company_id_companies_id_fk": { "name": "accounting_runtime_baselines_company_id_companies_id_fk", "tableFrom": "accounting_runtime_baselines", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -200,9 +200,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "billing_invoice_lines_company_idx": { "name": "billing_invoice_lines_company_idx", @@ -221,50 +221,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "billing_invoice_lines_company_id_companies_id_fk": { "name": "billing_invoice_lines_company_id_companies_id_fk", "tableFrom": "billing_invoice_lines", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "billing_invoice_lines_invoice_id_billing_invoices_id_fk": { "name": "billing_invoice_lines_invoice_id_billing_invoices_id_fk", "tableFrom": "billing_invoice_lines", + "tableTo": "billing_invoices", "columnsFrom": [ "invoice_id" ], - "tableTo": "billing_invoices", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "billing_invoice_lines_cost_event_id_cost_events_id_fk": { "name": "billing_invoice_lines_cost_event_id_cost_events_id_fk", "tableFrom": "billing_invoice_lines", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -361,24 +361,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "billing_invoices_company_id_companies_id_fk": { "name": "billing_invoices_company_id_companies_id_fk", "tableFrom": "billing_invoices", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -497,9 +497,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_reservations_prompt_injection_idx": { "name": "budget_reservations_prompt_injection_idx", @@ -518,9 +518,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_reservations_decision_idx": { "name": "budget_reservations_decision_idx", @@ -539,9 +539,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_reservations_responsibility_summary_idx": { "name": "budget_reservations_responsibility_summary_idx", @@ -560,9 +560,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_reservations_run_idx": { "name": "budget_reservations_run_idx", @@ -581,9 +581,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_reservations_active_idx": { "name": "budget_reservations_active_idx", @@ -608,51 +608,51 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"budget_reservations\".\"state\" = 'held'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "budget_reservations_company_id_companies_id_fk": { "name": "budget_reservations_company_id_companies_id_fk", "tableFrom": "budget_reservations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "budget_reservations_run_id_heartbeat_runs_id_fk": { "name": "budget_reservations_run_id_heartbeat_runs_id_fk", "tableFrom": "budget_reservations", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "budget_reservations_agent_id_agents_id_fk": { "name": "budget_reservations_agent_id_agents_id_fk", "tableFrom": "budget_reservations", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -791,9 +791,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_adjustments_event_idx": { "name": "cost_adjustments_event_idx", @@ -818,9 +818,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_adjustments_invoice_line_idx": { "name": "cost_adjustments_invoice_line_idx", @@ -839,50 +839,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "cost_adjustments_company_id_companies_id_fk": { "name": "cost_adjustments_company_id_companies_id_fk", "tableFrom": "cost_adjustments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "cost_adjustments_cost_event_id_cost_events_id_fk": { "name": "cost_adjustments_cost_event_id_cost_events_id_fk", "tableFrom": "cost_adjustments", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "cost_adjustments_invoice_line_id_billing_invoice_lines_id_fk": { "name": "cost_adjustments_invoice_line_id_billing_invoice_lines_id_fk", "tableFrom": "cost_adjustments", + "tableTo": "billing_invoice_lines", "columnsFrom": [ "invoice_line_id" ], - "tableTo": "billing_invoice_lines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -994,24 +994,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "provider_billing_snapshots_company_id_companies_id_fk": { "name": "provider_billing_snapshots_company_id_companies_id_fk", "tableFrom": "provider_billing_snapshots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -1121,9 +1121,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "run_usage_receipts_run_latest_idx": { "name": "run_usage_receipts_run_latest_idx", @@ -1148,37 +1148,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "run_usage_receipts_company_id_companies_id_fk": { "name": "run_usage_receipts_company_id_companies_id_fk", "tableFrom": "run_usage_receipts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "run_usage_receipts_run_id_heartbeat_runs_id_fk": { "name": "run_usage_receipts_run_id_heartbeat_runs_id_fk", "tableFrom": "run_usage_receipts", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -1290,9 +1290,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_company_agent_created_idx": { "name": "activity_log_company_agent_created_idx", @@ -1317,9 +1317,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_company_responsible_user_created_idx": { "name": "activity_log_company_responsible_user_created_idx", @@ -1344,9 +1344,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_run_id_idx": { "name": "activity_log_run_id_idx", @@ -1359,9 +1359,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_entity_type_id_idx": { "name": "activity_log_entity_type_id_idx", @@ -1380,9 +1380,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_company_entity_created_idx": { "name": "activity_log_company_entity_created_idx", @@ -1413,9 +1413,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "activity_log_company_user_issue_actor_idx": { "name": "activity_log_company_user_issue_actor_idx", @@ -1440,10 +1440,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"activity_log\".\"actor_type\" = 'user' AND \"activity_log\".\"entity_type\" = 'issue'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "activity_log_company_handled_for_created_idx": { "name": "activity_log_company_handled_for_created_idx", @@ -1456,8 +1456,8 @@ }, { "expression": "(\"details\" ->> 'handledForUserId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -1468,51 +1468,51 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "(\"activity_log\".\"details\" ->> 'handledForUserId') IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "activity_log_company_id_companies_id_fk": { "name": "activity_log_company_id_companies_id_fk", "tableFrom": "activity_log", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "activity_log_agent_id_agents_id_fk": { "name": "activity_log_agent_id_agents_id_fk", "tableFrom": "activity_log", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "activity_log_run_id_heartbeat_runs_id_fk": { "name": "activity_log_run_id_heartbeat_runs_id_fk", "tableFrom": "activity_log", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -1668,9 +1668,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "adapter_auth_sessions_company_owner_adapter_active_uq": { "name": "adapter_auth_sessions_company_owner_adapter_active_uq", @@ -1695,10 +1695,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"adapter_auth_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'promoting', 'awaiting_code', 'submitting')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "adapter_auth_sessions_public_session_id_uq": { "name": "adapter_auth_sessions_public_session_id_uq", @@ -1711,9 +1711,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "adapter_auth_sessions_environment_idx": { "name": "adapter_auth_sessions_environment_idx", @@ -1726,9 +1726,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "adapter_auth_sessions_expires_idx": { "name": "adapter_auth_sessions_expires_idx", @@ -1741,9 +1741,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "adapter_auth_sessions_provider_lease_idx": { "name": "adapter_auth_sessions_provider_lease_idx", @@ -1756,37 +1756,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "adapter_auth_sessions_company_id_companies_id_fk": { "name": "adapter_auth_sessions_company_id_companies_id_fk", "tableFrom": "adapter_auth_sessions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "adapter_auth_sessions_environment_id_environments_id_fk": { "name": "adapter_auth_sessions_environment_id_environments_id_fk", "tableFrom": "adapter_auth_sessions", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -1842,6 +1842,12 @@ "primaryKey": false, "notNull": false }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "last_used_at": { "name": "last_used_at", "type": "timestamp with time zone", @@ -1874,9 +1880,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_api_keys_company_agent_idx": { "name": "agent_api_keys_company_agent_idx", @@ -1895,37 +1901,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_api_keys_agent_id_agents_id_fk": { "name": "agent_api_keys_agent_id_agents_id_fk", "tableFrom": "agent_api_keys", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_api_keys_company_id_companies_id_fk": { "name": "agent_api_keys_company_id_companies_id_fk", "tableFrom": "agent_api_keys", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -2025,9 +2031,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_commentary_company_kind_created_idx": { "name": "agent_commentary_company_kind_created_idx", @@ -2052,63 +2058,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_commentary_company_id_companies_id_fk": { "name": "agent_commentary_company_id_companies_id_fk", "tableFrom": "agent_commentary", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_commentary_agent_id_agents_id_fk": { "name": "agent_commentary_agent_id_agents_id_fk", "tableFrom": "agent_commentary", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_commentary_run_id_heartbeat_runs_id_fk": { "name": "agent_commentary_run_id_heartbeat_runs_id_fk", "tableFrom": "agent_commentary", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_commentary_issue_id_issues_id_fk": { "name": "agent_commentary_issue_id_issues_id_fk", "tableFrom": "agent_commentary", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -2221,9 +2227,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_config_revisions_agent_created_idx": { "name": "agent_config_revisions_agent_created_idx", @@ -2242,50 +2248,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_config_revisions_company_id_companies_id_fk": { "name": "agent_config_revisions_company_id_companies_id_fk", "tableFrom": "agent_config_revisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_config_revisions_agent_id_agents_id_fk": { "name": "agent_config_revisions_agent_id_agents_id_fk", "tableFrom": "agent_config_revisions", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_config_revisions_created_by_agent_id_agents_id_fk": { "name": "agent_config_revisions_created_by_agent_id_agents_id_fk", "tableFrom": "agent_config_revisions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -2335,17 +2341,17 @@ "agent_file_roots_company_id_agent_id_agents_company_id_id_fk": { "name": "agent_file_roots_company_id_agent_id_agents_company_id_id_fk", "tableFrom": "agent_file_roots", + "tableTo": "agents", "columnsFrom": [ "company_id", "agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -2415,17 +2421,17 @@ "agent_identity_keys_owner_fk": { "name": "agent_identity_keys_owner_fk", "tableFrom": "agent_identity_keys", + "tableTo": "agents", "columnsFrom": [ "company_id", "agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -2480,33 +2486,33 @@ "agent_instruction_heads_company_id_agent_id_entry_file_revision_id_agent_instruction_revisions_company_id_agent_id_entry_file_id_fk": { "name": "agent_instruction_heads_company_id_agent_id_entry_file_revision_id_agent_instruction_revisions_company_id_agent_id_entry_file_id_fk", "tableFrom": "agent_instruction_heads", + "tableTo": "agent_instruction_revisions", "columnsFrom": [ "company_id", "agent_id", "entry_file", "revision_id" ], - "tableTo": "agent_instruction_revisions", "columnsTo": [ "company_id", "agent_id", "entry_file", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "agent_instruction_heads_identity_uq": { "name": "agent_instruction_heads_identity_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "agent_id", "entry_file" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -2652,39 +2658,39 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_instruction_revisions_company_id_agent_id_agents_company_id_id_fk": { "name": "agent_instruction_revisions_company_id_agent_id_agents_company_id_id_fk", "tableFrom": "agent_instruction_revisions", + "tableTo": "agents", "columnsFrom": [ "company_id", "agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "agent_instruction_revisions_identity_uq": { "name": "agent_instruction_revisions_identity_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "agent_id", "entry_file", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -2844,10 +2850,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "NOT (coalesce(\"agent_instruction_working_copies\".\"receipt\", '{}'::jsonb) ? 'retainedByRunId') AND (\n (\"agent_instruction_working_copies\".\"attempts\" < 3 AND (\"agent_instruction_working_copies\".\"state\" IN ('prepared', 'pending_collection', 'unchanged_turn', 'warm_saved')\n OR (\"agent_instruction_working_copies\".\"state\" = 'preparing' AND \"agent_instruction_working_copies\".\"receipt\"->>'schema' = 'paperclip.agent-files.v1')))\n OR (\"agent_instruction_working_copies\".\"state\" = 'unavailable' AND \"agent_instruction_working_copies\".\"process_stopped_at\" IS NULL\n AND \"agent_instruction_working_copies\".\"location\" LIKE 'remote:%' AND \"agent_instruction_working_copies\".\"receipt\"->>'schema' = 'paperclip.agent-files.v1'))", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_instruction_copies_cleanup_idx": { "name": "agent_instruction_copies_cleanup_idx", @@ -2866,10 +2872,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"agent_instruction_working_copies\".\"state\" IN ('saved', 'unchanged', 'resolved', 'unavailable')\n AND \"agent_instruction_working_copies\".\"process_stopped_at\" IS NOT NULL\n AND \"agent_instruction_working_copies\".\"receipt\"->>'schema' = 'paperclip.agent-files.v1'\n AND coalesce(\"agent_instruction_working_copies\".\"receipt\"->>'retainedByRunId', '') = ''\n AND \"agent_instruction_working_copies\".\"receipt\"->>'cleanupPending' IS DISTINCT FROM 'false'\n AND (\"agent_instruction_working_copies\".\"receipt\" ? 'baseline' OR \"agent_instruction_working_copies\".\"receipt\"->>'cleanupPending' = 'true')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_instruction_copies_pending_idx": { "name": "agent_instruction_copies_pending_idx", @@ -2888,9 +2894,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_instruction_copies_agent_idx": { "name": "agent_instruction_copies_agent_idx", @@ -2915,39 +2921,39 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_instruction_working_copies_run_id_heartbeat_runs_id_fk": { "name": "agent_instruction_working_copies_run_id_heartbeat_runs_id_fk", "tableFrom": "agent_instruction_working_copies", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_instruction_working_copies_company_id_agent_id_agents_company_id_id_fk": { "name": "agent_instruction_working_copies_company_id_agent_id_agents_company_id_id_fk", "tableFrom": "agent_instruction_working_copies", + "tableTo": "agents", "columnsFrom": [ "company_id", "agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -3031,9 +3037,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_memberships_company_user_starred_idx": { "name": "agent_memberships_company_user_starred_idx", @@ -3058,9 +3064,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_memberships_agent_idx": { "name": "agent_memberships_agent_idx", @@ -3073,9 +3079,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_memberships_company_user_agent_uq": { "name": "agent_memberships_company_user_agent_uq", @@ -3100,37 +3106,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_memberships_company_id_companies_id_fk": { "name": "agent_memberships_company_id_companies_id_fk", "tableFrom": "agent_memberships", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "agent_memberships_agent_id_agents_id_fk": { "name": "agent_memberships_agent_id_agents_id_fk", "tableFrom": "agent_memberships", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -3253,9 +3259,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_runtime_state_company_updated_idx": { "name": "agent_runtime_state_company_updated_idx", @@ -3274,37 +3280,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_runtime_state_agent_id_agents_id_fk": { "name": "agent_runtime_state_agent_id_agents_id_fk", "tableFrom": "agent_runtime_state", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_runtime_state_company_id_companies_id_fk": { "name": "agent_runtime_state_company_id_companies_id_fk", "tableFrom": "agent_runtime_state", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -3414,9 +3420,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_setup_progress_expires_idx": { "name": "agent_setup_progress_expires_idx", @@ -3429,24 +3435,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_setup_progress_company_id_companies_id_fk": { "name": "agent_setup_progress_company_id_companies_id_fk", "tableFrom": "agent_setup_progress", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -3565,9 +3571,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_session_goal_actions_company_status_created_idx": { "name": "agent_session_goal_actions_company_status_created_idx", @@ -3592,9 +3598,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_session_goal_actions_session_created_idx": { "name": "agent_session_goal_actions_session_created_idx", @@ -3613,37 +3619,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_session_goal_actions_company_id_companies_id_fk": { "name": "agent_session_goal_actions_company_id_companies_id_fk", "tableFrom": "agent_session_goal_actions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_session_goal_actions_session_id_agent_task_sessions_id_fk": { "name": "agent_session_goal_actions_session_id_agent_task_sessions_id_fk", "tableFrom": "agent_session_goal_actions", + "tableTo": "agent_task_sessions", "columnsFrom": [ "session_id" ], - "tableTo": "agent_task_sessions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -3805,9 +3811,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_task_sessions_company_agent_updated_idx": { "name": "agent_task_sessions_company_agent_updated_idx", @@ -3832,9 +3838,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_task_sessions_company_task_updated_idx": { "name": "agent_task_sessions_company_task_updated_idx", @@ -3859,50 +3865,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_task_sessions_company_id_companies_id_fk": { "name": "agent_task_sessions_company_id_companies_id_fk", "tableFrom": "agent_task_sessions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_task_sessions_agent_id_agents_id_fk": { "name": "agent_task_sessions_agent_id_agents_id_fk", "tableFrom": "agent_task_sessions", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_task_sessions_last_run_id_heartbeat_runs_id_fk": { "name": "agent_task_sessions_last_run_id_heartbeat_runs_id_fk", "tableFrom": "agent_task_sessions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "last_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -4054,10 +4060,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'task-retry:%'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_company_agent_status_idx": { "name": "agent_wakeup_requests_company_agent_status_idx", @@ -4082,9 +4088,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_wakeup_requests_company_requested_idx": { "name": "agent_wakeup_requests_company_requested_idx", @@ -4103,9 +4109,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_wakeup_requests_agent_requested_idx": { "name": "agent_wakeup_requests_agent_requested_idx", @@ -4124,9 +4130,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agent_wakeup_requests_company_run_idx": { "name": "agent_wakeup_requests_company_run_idx", @@ -4145,10 +4151,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"run_id\" IS NOT NULL", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "agent_wakeup_requests_review_path_recovery_idempotency_uq": { "name": "agent_wakeup_requests_review_path_recovery_idempotency_uq", @@ -4167,10 +4173,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_review_path_lost:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_disposition_repair_idempotency_uq": { "name": "agent_wakeup_requests_disposition_repair_idempotency_uq", @@ -4189,10 +4195,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_disposition_repair:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_question_response_delivery_idempotency_uq": { "name": "agent_wakeup_requests_question_response_delivery_idempotency_uq", @@ -4211,10 +4217,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "(\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'question-response:%' OR \"agent_wakeup_requests\".\"idempotency_key\" LIKE 'interaction:%') AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_question_response_history_idx": { "name": "agent_wakeup_requests_question_response_history_idx", @@ -4233,10 +4239,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'question-response:%'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "agent_wakeup_requests_connection_intent_delivery_idempotency_uq": { "name": "agent_wakeup_requests_connection_intent_delivery_idempotency_uq", @@ -4255,10 +4261,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'connection-intent:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_tool_action_delivery_uq": { "name": "agent_wakeup_requests_tool_action_delivery_uq", @@ -4277,10 +4283,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'tool-action-response:%' AND \"agent_wakeup_requests\".\"status\" NOT IN ('skipped', 'failed', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_tree_hold_resume_uq": { "name": "agent_wakeup_requests_tree_hold_resume_uq", @@ -4299,10 +4305,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'tree-hold-resume:%' AND \"agent_wakeup_requests\".\"status\" <> 'skipped'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "agent_wakeup_requests_chat_completion_uq": { "name": "agent_wakeup_requests_chat_completion_uq", @@ -4321,10 +4327,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'chat-completion:%'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "agent_wakeup_requests_issue_blocker_stalled_uq": { "name": "agent_wakeup_requests_issue_blocker_stalled_uq", @@ -4343,10 +4349,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"agent_wakeup_requests\".\"idempotency_key\" LIKE 'issue_blocker_stalled:%' AND \"agent_wakeup_requests\".\"status\" IN ('queued', 'deferred_issue_execution', 'claimed', 'coalesced', 'completed')", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "agent_wakeup_requests_company_payload_issue_idx": { "name": "agent_wakeup_requests_company_payload_issue_idx", @@ -4359,43 +4365,43 @@ }, { "expression": "(\"payload\" ->> 'issueId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agent_wakeup_requests_company_id_companies_id_fk": { "name": "agent_wakeup_requests_company_id_companies_id_fk", "tableFrom": "agent_wakeup_requests", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agent_wakeup_requests_agent_id_agents_id_fk": { "name": "agent_wakeup_requests_agent_id_agents_id_fk", "tableFrom": "agent_wakeup_requests", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -4651,9 +4657,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agents_company_status_idx": { "name": "agents_company_status_idx", @@ -4672,9 +4678,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agents_company_reports_to_idx": { "name": "agents_company_reports_to_idx", @@ -4693,9 +4699,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "agents_company_default_environment_idx": { "name": "agents_company_default_environment_idx", @@ -4714,61 +4720,61 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "agents_company_id_companies_id_fk": { "name": "agents_company_id_companies_id_fk", "tableFrom": "agents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agents_reports_to_agents_id_fk": { "name": "agents_reports_to_agents_id_fk", "tableFrom": "agents", + "tableTo": "agents", "columnsFrom": [ "reports_to" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "agents_default_environment_id_environments_id_fk": { "name": "agents_default_environment_id_environments_id_fk", "tableFrom": "agents", + "tableTo": "environments", "columnsFrom": [ "default_environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "agents_company_id_uq": { "name": "agents_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -4854,39 +4860,39 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_connection_defaults_company_id_companies_id_fk": { "name": "ai_connection_defaults_company_id_companies_id_fk", "tableFrom": "ai_connection_defaults", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_defaults_company_grant_fk": { "name": "ai_connection_defaults_company_grant_fk", "tableFrom": "ai_connection_defaults", + "tableTo": "connection_grants", "columnsFrom": [ "company_id", "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -4959,54 +4965,54 @@ "ai_connection_pools_id_tool_connections_id_fk": { "name": "ai_connection_pools_id_tool_connections_id_fk", "tableFrom": "ai_connection_pools", + "tableTo": "tool_connections", "columnsFrom": [ "id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_pools_company_id_companies_id_fk": { "name": "ai_connection_pools_company_id_companies_id_fk", "tableFrom": "ai_connection_pools", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_pools_company_connection_fk": { "name": "ai_connection_pools_company_connection_fk", "tableFrom": "ai_connection_pools", + "tableTo": "tool_connections", "columnsFrom": [ "company_id", "id" ], - "tableTo": "tool_connections", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "ai_connection_pools_company_id_uq": { "name": "ai_connection_pools_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -5048,43 +5054,43 @@ "ai_connection_router_cursors_pool_id_ai_connection_pools_id_fk": { "name": "ai_connection_router_cursors_pool_id_ai_connection_pools_id_fk", "tableFrom": "ai_connection_router_cursors", + "tableTo": "ai_connection_pools", "columnsFrom": [ "pool_id" ], - "tableTo": "ai_connection_pools", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_router_cursors_company_id_companies_id_fk": { "name": "ai_connection_router_cursors_company_id_companies_id_fk", "tableFrom": "ai_connection_router_cursors", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_router_cursors_company_pool_fk": { "name": "ai_connection_router_cursors_company_pool_fk", "tableFrom": "ai_connection_router_cursors", + "tableTo": "ai_connection_pools", "columnsFrom": [ "company_id", "pool_id" ], - "tableTo": "ai_connection_pools", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -5178,80 +5184,80 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_connection_task_pins_company_id_companies_id_fk": { "name": "ai_connection_task_pins_company_id_companies_id_fk", "tableFrom": "ai_connection_task_pins", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_task_pins_pool_id_ai_connection_pools_id_fk": { "name": "ai_connection_task_pins_pool_id_ai_connection_pools_id_fk", "tableFrom": "ai_connection_task_pins", + "tableTo": "ai_connection_pools", "columnsFrom": [ "pool_id" ], - "tableTo": "ai_connection_pools", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_task_pins_agent_id_agents_id_fk": { "name": "ai_connection_task_pins_agent_id_agents_id_fk", "tableFrom": "ai_connection_task_pins", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_task_pins_company_pool_fk": { "name": "ai_connection_task_pins_company_pool_fk", "tableFrom": "ai_connection_task_pins", + "tableTo": "ai_connection_pools", "columnsFrom": [ "company_id", "pool_id" ], - "tableTo": "ai_connection_pools", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_connection_task_pins_company_agent_fk": { "name": "ai_connection_task_pins_company_agent_fk", "tableFrom": "ai_connection_task_pins", + "tableTo": "agents", "columnsFrom": [ "company_id", "agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -5327,39 +5333,39 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_provider_defaults_company_id_companies_id_fk": { "name": "ai_provider_defaults_company_id_companies_id_fk", "tableFrom": "ai_provider_defaults", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_provider_defaults_company_grant_fk": { "name": "ai_provider_defaults_company_grant_fk", "tableFrom": "ai_provider_defaults", + "tableTo": "connection_grants", "columnsFrom": [ "company_id", "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -5433,9 +5439,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "ai_subscription_connections_credential_idx": { "name": "ai_subscription_connections_credential_idx", @@ -5454,9 +5460,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "ai_subscription_connections_account_idx": { "name": "ai_subscription_connections_account_idx", @@ -5475,63 +5481,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_subscription_connections_company_id_companies_id_fk": { "name": "ai_subscription_connections_company_id_companies_id_fk", "tableFrom": "ai_subscription_connections", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_subscription_connections_connection_id_tool_connections_id_fk": { "name": "ai_subscription_connections_connection_id_tool_connections_id_fk", "tableFrom": "ai_subscription_connections", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_subscription_connections_grant_id_connection_grants_id_fk": { "name": "ai_subscription_connections_grant_id_connection_grants_id_fk", "tableFrom": "ai_subscription_connections", + "tableTo": "connection_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_subscription_connections_subscription_id_ai_subscriptions_id_fk": { "name": "ai_subscription_connections_subscription_id_ai_subscriptions_id_fk", "tableFrom": "ai_subscription_connections", + "tableTo": "ai_subscriptions", "columnsFrom": [ "subscription_id" ], - "tableTo": "ai_subscriptions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -5640,9 +5646,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "ai_subscription_prices_company_idx": { "name": "ai_subscription_prices_company_idx", @@ -5655,37 +5661,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_subscription_prices_company_id_companies_id_fk": { "name": "ai_subscription_prices_company_id_companies_id_fk", "tableFrom": "ai_subscription_prices", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_subscription_prices_subscription_id_ai_subscriptions_id_fk": { "name": "ai_subscription_prices_subscription_id_ai_subscriptions_id_fk", "tableFrom": "ai_subscription_prices", + "tableTo": "ai_subscriptions", "columnsFrom": [ "subscription_id" ], - "tableTo": "ai_subscriptions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -5824,9 +5830,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "ai_subscriptions_company_idx": { "name": "ai_subscriptions_company_idx", @@ -5839,37 +5845,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "ai_subscriptions_company_id_companies_id_fk": { "name": "ai_subscriptions_company_id_companies_id_fk", "tableFrom": "ai_subscriptions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "ai_subscriptions_merged_into_id_ai_subscriptions_id_fk": { "name": "ai_subscriptions_merged_into_id_ai_subscriptions_id_fk", "tableFrom": "ai_subscriptions", + "tableTo": "ai_subscriptions", "columnsFrom": [ "merged_into_id" ], - "tableTo": "ai_subscriptions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6010,9 +6016,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "approval_comments_approval_idx": { "name": "approval_comments_approval_idx", @@ -6025,9 +6031,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "approval_comments_approval_created_idx": { "name": "approval_comments_approval_created_idx", @@ -6046,50 +6052,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "approval_comments_company_id_companies_id_fk": { "name": "approval_comments_company_id_companies_id_fk", "tableFrom": "approval_comments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "approval_comments_approval_id_approvals_id_fk": { "name": "approval_comments_approval_id_approvals_id_fk", "tableFrom": "approval_comments", + "tableTo": "approvals", "columnsFrom": [ "approval_id" ], - "tableTo": "approvals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "approval_comments_author_agent_id_agents_id_fk": { "name": "approval_comments_author_agent_id_agents_id_fk", "tableFrom": "approval_comments", + "tableTo": "agents", "columnsFrom": [ "author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6197,10 +6203,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"approvals\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "approvals_company_status_type_idx": { "name": "approvals_company_status_type_idx", @@ -6225,37 +6231,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "approvals_company_id_companies_id_fk": { "name": "approvals_company_id_companies_id_fk", "tableFrom": "approvals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "approvals_requested_by_agent_id_agents_id_fk": { "name": "approvals_requested_by_agent_id_agents_id_fk", "tableFrom": "approvals", + "tableTo": "agents", "columnsFrom": [ "requested_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6362,9 +6368,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "assets_company_provider_idx": { "name": "assets_company_provider_idx", @@ -6383,9 +6389,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "assets_company_object_key_uq": { "name": "assets_company_object_key_uq", @@ -6404,37 +6410,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "assets_company_id_companies_id_fk": { "name": "assets_company_id_companies_id_fk", "tableFrom": "assets", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "assets_created_by_agent_id_agents_id_fk": { "name": "assets_created_by_agent_id_agents_id_fk", "tableFrom": "assets", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6550,24 +6556,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "account_user_id_user_id_fk": { "name": "account_user_id_user_id_fk", "tableFrom": "account", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6634,15 +6640,15 @@ "session_user_id_user_id_fk": { "name": "session_user_id_user_id_fk", "tableFrom": "session", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6844,15 +6850,15 @@ "automatic_run_brakes_company_id_companies_id_fk": { "name": "automatic_run_brakes_company_id_companies_id_fk", "tableFrom": "automatic_run_brakes", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -6878,6 +6884,24 @@ "primaryKey": false, "notNull": true }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "locked_profile": { + "name": "locked_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, "name": { "name": "name", "type": "text", @@ -6928,9 +6952,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "board_api_keys_user_idx": { "name": "board_api_keys_user_idx", @@ -6943,24 +6967,52 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} + }, + "board_api_keys_company_idx": { + "name": "board_api_keys_company_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "board_api_keys_user_id_user_id_fk": { "name": "board_api_keys_user_id_user_id_fk", "tableFrom": "board_api_keys", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" + }, + "board_api_keys_company_id_companies_id_fk": { + "name": "board_api_keys_company_id_companies_id_fk", + "tableFrom": "board_api_keys", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7031,9 +7083,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "browser_use_browsers_session_idx": { "name": "browser_use_browsers_session_idx", @@ -7046,37 +7098,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "browser_use_browsers_company_id_companies_id_fk": { "name": "browser_use_browsers_company_id_companies_id_fk", "tableFrom": "browser_use_browsers", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_browsers_session_id_browser_use_sessions_id_fk": { "name": "browser_use_browsers_session_id_browser_use_sessions_id_fk", "tableFrom": "browser_use_browsers", + "tableTo": "browser_use_sessions", "columnsFrom": [ "session_id" ], - "tableTo": "browser_use_sessions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7198,9 +7250,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "browser_use_runs_provider_uq": { "name": "browser_use_runs_provider_uq", @@ -7213,9 +7265,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "browser_use_runs_session_idx": { "name": "browser_use_runs_session_idx", @@ -7228,50 +7280,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "browser_use_runs_company_id_companies_id_fk": { "name": "browser_use_runs_company_id_companies_id_fk", "tableFrom": "browser_use_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_runs_session_id_browser_use_sessions_id_fk": { "name": "browser_use_runs_session_id_browser_use_sessions_id_fk", "tableFrom": "browser_use_runs", + "tableTo": "browser_use_sessions", "columnsFrom": [ "session_id" ], - "tableTo": "browser_use_sessions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_runs_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "browser_use_runs_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "browser_use_runs", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7404,9 +7456,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "browser_use_sessions_provider_uq": { "name": "browser_use_sessions_provider_uq", @@ -7419,76 +7471,76 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "browser_use_sessions_company_id_companies_id_fk": { "name": "browser_use_sessions_company_id_companies_id_fk", "tableFrom": "browser_use_sessions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_sessions_issue_id_issues_id_fk": { "name": "browser_use_sessions_issue_id_issues_id_fk", "tableFrom": "browser_use_sessions", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_sessions_agent_id_agents_id_fk": { "name": "browser_use_sessions_agent_id_agents_id_fk", "tableFrom": "browser_use_sessions", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_sessions_connection_id_tool_connections_id_fk": { "name": "browser_use_sessions_connection_id_tool_connections_id_fk", "tableFrom": "browser_use_sessions", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_sessions_grant_id_connection_grants_id_fk": { "name": "browser_use_sessions_grant_id_connection_grants_id_fk", "tableFrom": "browser_use_sessions", + "tableTo": "connection_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7532,28 +7584,28 @@ "browser_use_settings_grant_id_connection_grants_id_fk": { "name": "browser_use_settings_grant_id_connection_grants_id_fk", "tableFrom": "browser_use_settings", + "tableTo": "connection_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "browser_use_settings_company_id_companies_id_fk": { "name": "browser_use_settings_company_id_companies_id_fk", "tableFrom": "browser_use_settings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7623,9 +7675,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_evaluation_work_agent_pending_idx": { "name": "budget_evaluation_work_agent_pending_idx", @@ -7650,9 +7702,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_evaluation_work_project_pending_idx": { "name": "budget_evaluation_work_project_pending_idx", @@ -7677,24 +7729,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "budget_evaluation_work_company_id_companies_id_fk": { "name": "budget_evaluation_work_company_id_companies_id_fk", "tableFrom": "budget_evaluation_work", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -7832,9 +7884,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_incidents_company_scope_idx": { "name": "budget_incidents_company_scope_idx", @@ -7865,9 +7917,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_incidents_policy_window_threshold_idx": { "name": "budget_incidents_policy_window_threshold_idx", @@ -7892,51 +7944,51 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"budget_incidents\".\"status\" = 'open'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "budget_incidents_company_id_companies_id_fk": { "name": "budget_incidents_company_id_companies_id_fk", "tableFrom": "budget_incidents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "budget_incidents_policy_id_budget_policies_id_fk": { "name": "budget_incidents_policy_id_budget_policies_id_fk", "tableFrom": "budget_incidents", + "tableTo": "budget_policies", "columnsFrom": [ "policy_id" ], - "tableTo": "budget_policies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "budget_incidents_approval_id_approvals_id_fk": { "name": "budget_incidents_approval_id_approvals_id_fk", "tableFrom": "budget_incidents", + "tableTo": "approvals", "columnsFrom": [ "approval_id" ], - "tableTo": "approvals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8114,9 +8166,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_policies_company_window_idx": { "name": "budget_policies_company_window_idx", @@ -8141,9 +8193,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "budget_policies_company_scope_metric_unique_idx": { "name": "budget_policies_company_scope_metric_unique_idx", @@ -8180,24 +8232,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "budget_policies_company_id_companies_id_fk": { "name": "budget_policies_company_id_companies_id_fk", "tableFrom": "budget_policies", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8302,51 +8354,51 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"budget_resume_claims\".\"state\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "budget_resume_claims_run_id_heartbeat_runs_id_fk": { "name": "budget_resume_claims_run_id_heartbeat_runs_id_fk", "tableFrom": "budget_resume_claims", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "budget_resume_claims_company_id_companies_id_fk": { "name": "budget_resume_claims_company_id_companies_id_fk", "tableFrom": "budget_resume_claims", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "budget_resume_claims_incident_id_budget_incidents_id_fk": { "name": "budget_resume_claims_incident_id_budget_incidents_id_fk", "tableFrom": "budget_resume_claims", + "tableTo": "budget_incidents", "columnsFrom": [ "incident_id" ], - "tableTo": "budget_incidents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8442,9 +8494,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "built_in_managed_resources_resource_idx": { "name": "built_in_managed_resources_resource_idx", @@ -8463,9 +8515,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "built_in_managed_resources_company_bundle_resource_uq": { "name": "built_in_managed_resources_company_bundle_resource_uq", @@ -8496,24 +8548,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "built_in_managed_resources_company_id_companies_id_fk": { "name": "built_in_managed_resources_company_id_companies_id_fk", "tableFrom": "built_in_managed_resources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8589,9 +8641,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_access_sources_company_case_idx": { "name": "case_access_sources_company_case_idx", @@ -8610,37 +8662,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_access_sources_company_id_companies_id_fk": { "name": "case_access_sources_company_id_companies_id_fk", "tableFrom": "case_access_sources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_access_sources_case_id_cases_id_fk": { "name": "case_access_sources_case_id_cases_id_fk", "tableFrom": "case_access_sources", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8716,9 +8768,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_attachments_asset_uq": { "name": "case_attachments_asset_uq", @@ -8731,50 +8783,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_attachments_company_id_companies_id_fk": { "name": "case_attachments_company_id_companies_id_fk", "tableFrom": "case_attachments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_attachments_case_id_cases_id_fk": { "name": "case_attachments_case_id_cases_id_fk", "tableFrom": "case_attachments", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_attachments_asset_id_assets_id_fk": { "name": "case_attachments_asset_id_assets_id_fk", "tableFrom": "case_attachments", + "tableTo": "assets", "columnsFrom": [ "asset_id" ], - "tableTo": "assets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -8857,9 +8909,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_documents_document_uq": { "name": "case_documents_document_uq", @@ -8872,9 +8924,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_documents_company_case_updated_idx": { "name": "case_documents_company_case_updated_idx", @@ -8899,50 +8951,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_documents_company_id_companies_id_fk": { "name": "case_documents_company_id_companies_id_fk", "tableFrom": "case_documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_documents_case_id_cases_id_fk": { "name": "case_documents_case_id_cases_id_fk", "tableFrom": "case_documents", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_documents_document_id_documents_id_fk": { "name": "case_documents_document_id_documents_id_fk", "tableFrom": "case_documents", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -9044,9 +9096,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_events_company_case_idx": { "name": "case_events_company_case_idx", @@ -9065,50 +9117,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_events_company_id_companies_id_fk": { "name": "case_events_company_id_companies_id_fk", "tableFrom": "case_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_events_case_id_cases_id_fk": { "name": "case_events_case_id_cases_id_fk", "tableFrom": "case_events", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_events_actor_agent_id_agents_id_fk": { "name": "case_events_actor_agent_id_agents_id_fk", "tableFrom": "case_events", + "tableTo": "agents", "columnsFrom": [ "actor_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -9377,9 +9429,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_handoffs_actor_idempotency_uq": { "name": "case_handoffs_actor_idempotency_uq", @@ -9410,9 +9462,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_handoffs_pending_case_uq": { "name": "case_handoffs_pending_case_uq", @@ -9425,10 +9477,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'awaiting_completion')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "case_handoffs_pending_issue_uq": { "name": "case_handoffs_pending_issue_uq", @@ -9441,10 +9493,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch', 'awaiting_completion')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "case_handoffs_pending_attempt_idx": { "name": "case_handoffs_pending_attempt_idx", @@ -9457,10 +9509,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"case_handoffs\".\"state\" in ('awaiting_release', 'pending_dispatch')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "case_handoffs_case_created_idx": { "name": "case_handoffs_case_created_idx", @@ -9479,9 +9531,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_handoffs_source_run_idx": { "name": "case_handoffs_source_run_idx", @@ -9500,10 +9552,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"case_handoffs\".\"source_run_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "case_handoffs_wakeup_request_uq": { "name": "case_handoffs_wakeup_request_uq", @@ -9516,76 +9568,76 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_handoffs_company_id_companies_id_fk": { "name": "case_handoffs_company_id_companies_id_fk", "tableFrom": "case_handoffs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_handoffs_case_id_cases_id_fk": { "name": "case_handoffs_case_id_cases_id_fk", "tableFrom": "case_handoffs", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_handoffs_issue_id_issues_id_fk": { "name": "case_handoffs_issue_id_issues_id_fk", "tableFrom": "case_handoffs", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "case_handoffs_from_agent_id_agents_id_fk": { "name": "case_handoffs_from_agent_id_agents_id_fk", "tableFrom": "case_handoffs", + "tableTo": "agents", "columnsFrom": [ "from_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "case_handoffs_to_agent_id_agents_id_fk": { "name": "case_handoffs_to_agent_id_agents_id_fk", "tableFrom": "case_handoffs", + "tableTo": "agents", "columnsFrom": [ "to_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -9685,9 +9737,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_issue_links_company_case_idx": { "name": "case_issue_links_company_case_idx", @@ -9706,9 +9758,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_issue_links_issue_idx": { "name": "case_issue_links_issue_idx", @@ -9721,50 +9773,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_issue_links_company_id_companies_id_fk": { "name": "case_issue_links_company_id_companies_id_fk", "tableFrom": "case_issue_links", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_issue_links_case_id_cases_id_fk": { "name": "case_issue_links_case_id_cases_id_fk", "tableFrom": "case_issue_links", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_issue_links_issue_id_issues_id_fk": { "name": "case_issue_links_issue_id_issues_id_fk", "tableFrom": "case_issue_links", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -9840,9 +9892,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_labels_company_case_idx": { "name": "case_labels_company_case_idx", @@ -9861,9 +9913,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "case_labels_label_idx": { "name": "case_labels_label_idx", @@ -9876,50 +9928,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "case_labels_company_id_companies_id_fk": { "name": "case_labels_company_id_companies_id_fk", "tableFrom": "case_labels", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_labels_case_id_cases_id_fk": { "name": "case_labels_case_id_cases_id_fk", "tableFrom": "case_labels", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "case_labels_label_id_labels_id_fk": { "name": "case_labels_label_id_labels_id_fk", "tableFrom": "case_labels", + "tableTo": "labels", "columnsFrom": [ "label_id" ], - "tableTo": "labels", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -10083,9 +10135,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_identifier_uq": { "name": "cases_identifier_uq", @@ -10098,9 +10150,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_work_issue_uq": { "name": "cases_work_issue_uq", @@ -10113,10 +10165,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"cases\".\"work_issue_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "cases_company_type_key_uq": { "name": "cases_company_type_key_uq", @@ -10141,9 +10193,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_company_status_idx": { "name": "cases_company_status_idx", @@ -10162,9 +10214,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_company_type_idx": { "name": "cases_company_type_idx", @@ -10183,9 +10235,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_company_project_idx": { "name": "cases_company_project_idx", @@ -10204,9 +10256,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_parent_idx": { "name": "cases_parent_idx", @@ -10219,9 +10271,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cases_title_search_idx": { "name": "cases_title_search_idx", @@ -10235,9 +10287,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "cases_identifier_search_idx": { "name": "cases_identifier_search_idx", @@ -10251,9 +10303,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "cases_summary_search_idx": { "name": "cases_summary_search_idx", @@ -10267,89 +10319,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} } }, "foreignKeys": { "cases_company_id_companies_id_fk": { "name": "cases_company_id_companies_id_fk", "tableFrom": "cases", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "cases_project_id_projects_id_fk": { "name": "cases_project_id_projects_id_fk", "tableFrom": "cases", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "cases_work_issue_id_issues_id_fk": { "name": "cases_work_issue_id_issues_id_fk", "tableFrom": "cases", + "tableTo": "issues", "columnsFrom": [ "work_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "cases_workflow_id_workflows_id_fk": { "name": "cases_workflow_id_workflows_id_fk", "tableFrom": "cases", + "tableTo": "workflows", "columnsFrom": [ "workflow_id" ], - "tableTo": "workflows", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "cases_parent_case_id_cases_id_fk": { "name": "cases_parent_case_id_cases_id_fk", "tableFrom": "cases", + "tableTo": "cases", "columnsFrom": [ "parent_case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "cases_created_by_agent_id_agents_id_fk": { "name": "cases_created_by_agent_id_agents_id_fk", "tableFrom": "cases", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -10363,6 +10415,345 @@ }, "isRLSEnabled": false }, + "public.channel_access_members": { + "name": "channel_access_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject_id": { + "name": "subject_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "channel_access_members_channel_subject_uq": { + "name": "channel_access_members_channel_subject_uq", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "channel_access_members_subject_lookup_idx": { + "name": "channel_access_members_subject_lookup_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "channel_access_members_company_id_companies_id_fk": { + "name": "channel_access_members_company_id_companies_id_fk", + "tableFrom": "channel_access_members", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channel_access_members_channel_id_channels_id_fk": { + "name": "channel_access_members_channel_id_channels_id_fk", + "tableFrom": "channel_access_members", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "channel_access_members_subject_type_check": { + "name": "channel_access_members_subject_type_check", + "value": "\"channel_access_members\".\"subject_type\" in ('user', 'agent')" + } + }, + "isRLSEnabled": false + }, + "public.channels": { + "name": "channels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "default_project_id": { + "name": "default_project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "queue_config": { + "name": "queue_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_by_agent_id": { + "name": "created_by_agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by_profile": { + "name": "created_by_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "channels_company_path_uq": { + "name": "channels_company_path_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "channels_company_activity_idx": { + "name": "channels_company_activity_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "channels_company_id_companies_id_fk": { + "name": "channels_company_id_companies_id_fk", + "tableFrom": "channels", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "channels_default_project_id_projects_id_fk": { + "name": "channels_default_project_id_projects_id_fk", + "tableFrom": "channels", + "tableTo": "projects", + "columnsFrom": [ + "default_project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "channels_created_by_agent_id_agents_id_fk": { + "name": "channels_created_by_agent_id_agents_id_fk", + "tableFrom": "channels", + "tableTo": "agents", + "columnsFrom": [ + "created_by_agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "channels_visibility_check": { + "name": "channels_visibility_check", + "value": "\"channels\".\"visibility\" in ('open', 'private')" + }, + "channels_path_check": { + "name": "channels_path_check", + "value": "\"channels\".\"path\" ~ '^[a-z0-9][a-z0-9_-]*(/[a-z0-9][a-z0-9_-]*)*$'" + } + }, + "isRLSEnabled": false + }, "public.chat_actions": { "name": "chat_actions", "schema": "", @@ -10469,10 +10860,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'interaction_wakeup' AND \"chat_actions\".\"status\" IN ('issued', 'processing')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_actions_confirmation_recovery_idx": { "name": "chat_actions_confirmation_recovery_idx", @@ -10491,10 +10882,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'confirmation_response' AND \"chat_actions\".\"status\" = 'processing'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_actions_provider_action_uq": { "name": "chat_actions_provider_action_uq", @@ -10513,9 +10904,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_actions_company_issue_kind_idx": { "name": "chat_actions_company_issue_kind_idx", @@ -10528,8 +10919,8 @@ }, { "expression": "(\"payload\"->>'issueId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -10546,10 +10937,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" IN ('inbound_wakeup', 'failed_run_retry')", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "chat_actions_github_stale_head_idx": { "name": "chat_actions_github_stale_head_idx", @@ -10568,16 +10959,16 @@ }, { "expression": "(\"payload\"->'event'->>'deliveryId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'github_review_check'\n and \"chat_actions\".\"status\" = 'cancelled' and \"chat_actions\".\"result\"->>'code' = 'stale_head'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_actions_github_check_work_idx": { "name": "chat_actions_github_check_work_idx", @@ -10590,10 +10981,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'github_review_check'\n and (\"chat_actions\".\"status\" = 'received' or (\"chat_actions\".\"status\" = 'failed' and \"chat_actions\".\"result\"->>'retryable' = 'true'))", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_actions_github_task_publications_idx": { "name": "chat_actions_github_task_publications_idx", @@ -10612,8 +11003,8 @@ }, { "expression": "(\"payload\"->'session'->>'issueId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -10624,10 +11015,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'github_review_publication' and \"chat_actions\".\"status\" = 'processed'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "chat_actions_github_terminal_work_idx": { "name": "chat_actions_github_terminal_work_idx", @@ -10640,10 +11031,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'github_response_comment'\n and \"chat_actions\".\"status\" = 'processed' and \"chat_actions\".\"delivery_id\" is not null\n and coalesce(\"chat_actions\".\"result\"->>'final', 'false') <> 'true'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_actions_github_ack_work_idx": { "name": "chat_actions_github_ack_work_idx", @@ -10656,98 +11047,98 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_actions\".\"kind\" = 'github_response_comment'\n and \"chat_actions\".\"delivery_id\" is not null and coalesce(\"chat_actions\".\"result\"->>'final', 'false') <> 'true'\n and (\"chat_actions\".\"status\" = 'received' or (\"chat_actions\".\"status\" = 'failed' and \"chat_actions\".\"result\"->>'retryable' = 'true'))", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "chat_actions_company_id_companies_id_fk": { "name": "chat_actions_company_id_companies_id_fk", "tableFrom": "chat_actions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_actions_delivery_id_chat_deliveries_id_fk": { "name": "chat_actions_delivery_id_chat_deliveries_id_fk", "tableFrom": "chat_actions", + "tableTo": "chat_deliveries", "columnsFrom": [ "delivery_id" ], - "tableTo": "chat_deliveries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_actions_company_delivery_fk": { "name": "chat_actions_company_delivery_fk", "tableFrom": "chat_actions", + "tableTo": "chat_deliveries", "columnsFrom": [ "company_id", "delivery_id" ], - "tableTo": "chat_deliveries", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_actions_company_conversation_fk": { "name": "chat_actions_company_conversation_fk", "tableFrom": "chat_actions", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_actions_company_principal_fk": { "name": "chat_actions_company_principal_fk", "tableFrom": "chat_actions", + "tableTo": "chat_external_principals", "columnsFrom": [ "company_id", "principal_id" ], - "tableTo": "chat_external_principals", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_actions_company_endpoint_fk": { "name": "chat_actions_company_endpoint_fk", "tableFrom": "chat_actions", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -10845,54 +11236,54 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_agent_routes_company_id_companies_id_fk": { "name": "chat_agent_routes_company_id_companies_id_fk", "tableFrom": "chat_agent_routes", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_agent_routes_company_source_fk": { "name": "chat_agent_routes_company_source_fk", "tableFrom": "chat_agent_routes", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "source_endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_agent_routes_company_destination_fk": { "name": "chat_agent_routes_company_destination_fk", "tableFrom": "chat_agent_routes", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "destination_endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -11032,9 +11423,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_conversations_thread_uq": { "name": "chat_conversations_thread_uq", @@ -11065,106 +11456,106 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_conversations_company_id_companies_id_fk": { "name": "chat_conversations_company_id_companies_id_fk", "tableFrom": "chat_conversations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_conversations_resource_id_chat_endpoint_resources_id_fk": { "name": "chat_conversations_resource_id_chat_endpoint_resources_id_fk", "tableFrom": "chat_conversations", + "tableTo": "chat_endpoint_resources", "columnsFrom": [ "resource_id" ], - "tableTo": "chat_endpoint_resources", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_conversations_issue_id_issues_id_fk": { "name": "chat_conversations_issue_id_issues_id_fk", "tableFrom": "chat_conversations", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "chat_conversations_company_issue_fk": { "name": "chat_conversations_company_issue_fk", "tableFrom": "chat_conversations", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_conversations_company_endpoint_fk": { "name": "chat_conversations_company_endpoint_fk", "tableFrom": "chat_conversations", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_conversations_company_resource_fk": { "name": "chat_conversations_company_resource_fk", "tableFrom": "chat_conversations", + "tableTo": "chat_endpoint_resources", "columnsFrom": [ "company_id", "resource_id" ], - "tableTo": "chat_endpoint_resources", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_conversations_company_id_uq": { "name": "chat_conversations_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -11307,9 +11698,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_deliveries_event_uq": { "name": "chat_deliveries_event_uq", @@ -11328,9 +11719,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_deliveries_dedupe_uq": { "name": "chat_deliveries_dedupe_uq", @@ -11349,9 +11740,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_deliveries_github_automatic_delivery_idx": { "name": "chat_deliveries_github_automatic_delivery_idx", @@ -11364,113 +11755,113 @@ }, { "expression": "(\"normalized_event\"->'githubAutomatic'->'context'->>'deliveryId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "(\"chat_deliveries\".\"normalized_event\"->'githubAutomatic'->'context'->>'deliveryId') is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "chat_deliveries_company_id_companies_id_fk": { "name": "chat_deliveries_company_id_companies_id_fk", "tableFrom": "chat_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_deliveries_conversation_id_chat_conversations_id_fk": { "name": "chat_deliveries_conversation_id_chat_conversations_id_fk", "tableFrom": "chat_deliveries", + "tableTo": "chat_conversations", "columnsFrom": [ "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_deliveries_principal_id_chat_external_principals_id_fk": { "name": "chat_deliveries_principal_id_chat_external_principals_id_fk", "tableFrom": "chat_deliveries", + "tableTo": "chat_external_principals", "columnsFrom": [ "principal_id" ], - "tableTo": "chat_external_principals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_deliveries_company_endpoint_fk": { "name": "chat_deliveries_company_endpoint_fk", "tableFrom": "chat_deliveries", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_deliveries_company_conversation_fk": { "name": "chat_deliveries_company_conversation_fk", "tableFrom": "chat_deliveries", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_deliveries_company_principal_fk": { "name": "chat_deliveries_company_principal_fk", "tableFrom": "chat_deliveries", + "tableTo": "chat_external_principals", "columnsFrom": [ "company_id", "principal_id" ], - "tableTo": "chat_external_principals", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_deliveries_company_id_uq": { "name": "chat_deliveries_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -11556,9 +11947,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoint_leases_expiry_idx": { "name": "chat_endpoint_leases_expiry_idx", @@ -11571,39 +11962,39 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_endpoint_leases_company_id_companies_id_fk": { "name": "chat_endpoint_leases_company_id_companies_id_fk", "tableFrom": "chat_endpoint_leases", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_endpoint_leases_company_endpoint_fk": { "name": "chat_endpoint_leases_company_endpoint_fk", "tableFrom": "chat_endpoint_leases", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -11731,9 +12122,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoint_resources_external_uq": { "name": "chat_endpoint_resources_external_uq", @@ -11758,50 +12149,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_endpoint_resources_company_id_companies_id_fk": { "name": "chat_endpoint_resources_company_id_companies_id_fk", "tableFrom": "chat_endpoint_resources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_endpoint_resources_company_endpoint_fk": { "name": "chat_endpoint_resources_company_endpoint_fk", "tableFrom": "chat_endpoint_resources", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_endpoint_resources_company_id_uq": { "name": "chat_endpoint_resources_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -12049,9 +12440,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoints_agent_idx": { "name": "chat_endpoints_agent_idx", @@ -12070,9 +12461,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoints_status_idx": { "name": "chat_endpoints_status_idx", @@ -12091,9 +12482,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoints_public_id_uq": { "name": "chat_endpoints_public_id_uq", @@ -12106,9 +12497,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoints_agentmail_inbox_uq": { "name": "chat_endpoints_agentmail_inbox_uq", @@ -12121,10 +12512,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"provider\" = 'agentmail' and \"chat_endpoints\".\"status\" != 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_endpoints_connection_uq": { "name": "chat_endpoints_connection_uq", @@ -12137,9 +12528,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_endpoints_live_bot_external_uq": { "name": "chat_endpoints_live_bot_external_uq", @@ -12164,10 +12555,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"provider_account_id\" is not null\n and \"chat_endpoints\".\"bot_external_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_endpoints_photon_number_uq": { "name": "chat_endpoints_photon_number_uq", @@ -12180,10 +12571,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"provider\" = 'imessage-photon' and \"chat_endpoints\".\"status\" <> 'archived' and \"chat_endpoints\".\"bot_external_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_endpoints_live_discord_bot_external_uq": { "name": "chat_endpoints_live_discord_bot_external_uq", @@ -12202,10 +12593,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"provider\" = 'discord'\n and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"bot_external_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_endpoints_live_global_app_bot_external_uq": { "name": "chat_endpoints_live_global_app_bot_external_uq", @@ -12224,10 +12615,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"provider\" in ('github', 'microsoft-teams')\n and \"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"bot_external_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_endpoints_live_bot_username_uq": { "name": "chat_endpoints_live_bot_username_uq", @@ -12252,79 +12643,79 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_endpoints\".\"status\" in ('verifying', 'active', 'paused', 'attention')\n and \"chat_endpoints\".\"provider_account_id\" is not null\n and \"chat_endpoints\".\"bot_username\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "chat_endpoints_company_id_companies_id_fk": { "name": "chat_endpoints_company_id_companies_id_fk", "tableFrom": "chat_endpoints", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_endpoints_assigned_agent_id_agents_id_fk": { "name": "chat_endpoints_assigned_agent_id_agents_id_fk", "tableFrom": "chat_endpoints", + "tableTo": "agents", "columnsFrom": [ "assigned_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "chat_endpoints_company_agent_fk": { "name": "chat_endpoints_company_agent_fk", "tableFrom": "chat_endpoints", + "tableTo": "agents", "columnsFrom": [ "company_id", "assigned_agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_endpoints_company_connection_fk": { "name": "chat_endpoints_company_connection_fk", "tableFrom": "chat_endpoints", + "tableTo": "tool_connections", "columnsFrom": [ "company_id", "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_endpoints_company_id_uq": { "name": "chat_endpoints_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -12460,9 +12851,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_external_principals_external_uq": { "name": "chat_external_principals_external_uq", @@ -12493,35 +12884,35 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_external_principals_company_id_companies_id_fk": { "name": "chat_external_principals_company_id_companies_id_fk", "tableFrom": "chat_external_principals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_external_principals_company_id_uq": { "name": "chat_external_principals_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -12636,9 +13027,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_identity_links_endpoint_principal_uq": { "name": "chat_identity_links_endpoint_principal_uq", @@ -12657,54 +13048,54 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_identity_links_company_id_companies_id_fk": { "name": "chat_identity_links_company_id_companies_id_fk", "tableFrom": "chat_identity_links", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_identity_links_company_endpoint_fk": { "name": "chat_identity_links_company_endpoint_fk", "tableFrom": "chat_identity_links", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_identity_links_company_principal_fk": { "name": "chat_identity_links_company_principal_fk", "tableFrom": "chat_identity_links", + "tableTo": "chat_external_principals", "columnsFrom": [ "company_id", "principal_id" ], - "tableTo": "chat_external_principals", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -12809,9 +13200,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_message_links_company_comment_idx": { "name": "chat_message_links_company_comment_idx", @@ -12830,10 +13221,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_message_links\".\"comment_id\" is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "chat_message_links_delivery_idx": { "name": "chat_message_links_delivery_idx", @@ -12846,139 +13237,139 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_message_links\".\"delivery_id\" is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "chat_message_links_company_id_companies_id_fk": { "name": "chat_message_links_company_id_companies_id_fk", "tableFrom": "chat_message_links", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_message_links_delivery_id_chat_deliveries_id_fk": { "name": "chat_message_links_delivery_id_chat_deliveries_id_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_deliveries", "columnsFrom": [ "delivery_id" ], - "tableTo": "chat_deliveries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_message_links_publication_id_chat_publications_id_fk": { "name": "chat_message_links_publication_id_chat_publications_id_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_publications", "columnsFrom": [ "publication_id" ], - "tableTo": "chat_publications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_message_links_comment_id_issue_comments_id_fk": { "name": "chat_message_links_comment_id_issue_comments_id_fk", "tableFrom": "chat_message_links", + "tableTo": "issue_comments", "columnsFrom": [ "comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_message_links_company_endpoint_fk": { "name": "chat_message_links_company_endpoint_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_message_links_company_delivery_fk": { "name": "chat_message_links_company_delivery_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_deliveries", "columnsFrom": [ "company_id", "delivery_id" ], - "tableTo": "chat_deliveries", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_message_links_company_publication_fk": { "name": "chat_message_links_company_publication_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_publications", "columnsFrom": [ "company_id", "publication_id" ], - "tableTo": "chat_publications", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_message_links_company_comment_fk": { "name": "chat_message_links_company_comment_fk", "tableFrom": "chat_message_links", + "tableTo": "issue_comments", "columnsFrom": [ "company_id", "comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_message_links_company_conversation_fk": { "name": "chat_message_links_company_conversation_fk", "tableFrom": "chat_message_links", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13122,9 +13513,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_publications_work_idx": { "name": "chat_publications_work_idx", @@ -13143,9 +13534,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_publications_comment_destination_idx": { "name": "chat_publications_comment_destination_idx", @@ -13176,10 +13567,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_publications\".\"comment_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_publications_idempotency_uq": { "name": "chat_publications_idempotency_uq", @@ -13198,110 +13589,110 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_publications_company_id_companies_id_fk": { "name": "chat_publications_company_id_companies_id_fk", "tableFrom": "chat_publications", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_publications_issue_id_issues_id_fk": { "name": "chat_publications_issue_id_issues_id_fk", "tableFrom": "chat_publications", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "chat_publications_comment_id_issue_comments_id_fk": { "name": "chat_publications_comment_id_issue_comments_id_fk", "tableFrom": "chat_publications", + "tableTo": "issue_comments", "columnsFrom": [ "comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_publications_company_issue_fk": { "name": "chat_publications_company_issue_fk", "tableFrom": "chat_publications", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_publications_company_comment_fk": { "name": "chat_publications_company_comment_fk", "tableFrom": "chat_publications", + "tableTo": "issue_comments", "columnsFrom": [ "company_id", "comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_publications_company_endpoint_fk": { "name": "chat_publications_company_endpoint_fk", "tableFrom": "chat_publications", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_publications_company_conversation_fk": { "name": "chat_publications_company_conversation_fk", "tableFrom": "chat_publications", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13396,9 +13787,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_sdk_state_expiry_idx": { "name": "chat_sdk_state_expiry_idx", @@ -13411,39 +13802,39 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_sdk_state_company_id_companies_id_fk": { "name": "chat_sdk_state_company_id_companies_id_fk", "tableFrom": "chat_sdk_state", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_sdk_state_company_endpoint_fk": { "name": "chat_sdk_state_company_endpoint_fk", "tableFrom": "chat_sdk_state", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13546,9 +13937,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_completion_deliveries_pending_idx": { "name": "chat_completion_deliveries_pending_idx", @@ -13567,63 +13958,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_completion_deliveries_company_id_companies_id_fk": { "name": "chat_completion_deliveries_company_id_companies_id_fk", "tableFrom": "chat_completion_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_completion_deliveries_task_id_chat_task_handoffs_task_id_fk": { "name": "chat_completion_deliveries_task_id_chat_task_handoffs_task_id_fk", "tableFrom": "chat_completion_deliveries", + "tableTo": "chat_task_handoffs", "columnsFrom": [ "task_id" ], - "tableTo": "chat_task_handoffs", "columnsTo": [ "task_id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_completion_deliveries_target_run_id_heartbeat_runs_id_fk": { "name": "chat_completion_deliveries_target_run_id_heartbeat_runs_id_fk", "tableFrom": "chat_completion_deliveries", + "tableTo": "heartbeat_runs", "columnsFrom": [ "target_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_completion_deliveries_response_comment_id_issue_comments_id_fk": { "name": "chat_completion_deliveries_response_comment_id_issue_comments_id_fk", "tableFrom": "chat_completion_deliveries", + "tableTo": "issue_comments", "columnsFrom": [ "response_comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13692,63 +14083,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_task_handoffs_task_id_issues_id_fk": { "name": "chat_task_handoffs_task_id_issues_id_fk", "tableFrom": "chat_task_handoffs", + "tableTo": "issues", "columnsFrom": [ "task_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_task_handoffs_company_id_companies_id_fk": { "name": "chat_task_handoffs_company_id_companies_id_fk", "tableFrom": "chat_task_handoffs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_task_handoffs_conversation_id_issues_id_fk": { "name": "chat_task_handoffs_conversation_id_issues_id_fk", "tableFrom": "chat_task_handoffs", + "tableTo": "issues", "columnsFrom": [ "conversation_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_task_handoffs_agent_id_agents_id_fk": { "name": "chat_task_handoffs_agent_id_agents_id_fk", "tableFrom": "chat_task_handoffs", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13861,17 +14252,17 @@ "chat_github_configurations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "chat_github_configurations_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "chat_github_configurations", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -13990,9 +14381,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_github_registration_endpoint_idx": { "name": "chat_github_registration_endpoint_idx", @@ -14011,26 +14402,26 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_github_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "chat_github_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "chat_github_registrations", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -14204,10 +14595,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_github_reviews\".\"state\" in ('queued', 'running')\n and \"chat_github_reviews\".\"assessment\" is null\n and \"chat_github_reviews\".\"delivery_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_github_reviews_delivery_uq": { "name": "chat_github_reviews_delivery_uq", @@ -14226,9 +14617,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_github_reviews_pull_idx": { "name": "chat_github_reviews_pull_idx", @@ -14259,9 +14650,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_github_reviews_task_idx": { "name": "chat_github_reviews_task_idx", @@ -14286,65 +14677,65 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_github_reviews_run_id_heartbeat_runs_id_fk": { "name": "chat_github_reviews_run_id_heartbeat_runs_id_fk", "tableFrom": "chat_github_reviews", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "chat_github_reviews_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "chat_github_reviews_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "chat_github_reviews", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_github_reviews_company_id_issue_id_issues_company_id_id_fk": { "name": "chat_github_reviews_company_id_issue_id_issues_company_id_id_fk", "tableFrom": "chat_github_reviews", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_github_reviews_company_id_uq": { "name": "chat_github_reviews_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -14479,9 +14870,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_slack_manager_grants_owner_idx": { "name": "chat_slack_manager_grants_owner_idx", @@ -14512,24 +14903,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_slack_manager_grants_company_id_companies_id_fk": { "name": "chat_slack_manager_grants_company_id_companies_id_fk", "tableFrom": "chat_slack_manager_grants", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -14658,32 +15049,32 @@ "chat_slack_registrations_company_id_manager_grant_id_chat_slack_manager_grants_company_id_id_fk": { "name": "chat_slack_registrations_company_id_manager_grant_id_chat_slack_manager_grants_company_id_id_fk", "tableFrom": "chat_slack_registrations", + "tableTo": "chat_slack_manager_grants", "columnsFrom": [ "company_id", "manager_grant_id" ], - "tableTo": "chat_slack_manager_grants", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_slack_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "chat_slack_registrations_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "chat_slack_registrations", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -14947,9 +15338,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_teams_file_transfers_token_uq": { "name": "chat_teams_file_transfers_token_uq", @@ -14968,9 +15359,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_teams_file_transfers_work_idx": { "name": "chat_teams_file_transfers_work_idx", @@ -14995,97 +15386,97 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_teams_file_transfers_company_id_companies_id_fk": { "name": "chat_teams_file_transfers_company_id_companies_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_teams_file_transfers_issue_id_issues_id_fk": { "name": "chat_teams_file_transfers_issue_id_issues_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "chat_teams_file_transfers_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk": { "name": "chat_teams_file_transfers_company_id_publication_id_chat_publications_company_id_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "chat_publications", "columnsFrom": [ "company_id", "publication_id" ], - "tableTo": "chat_publications", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk": { "name": "chat_teams_file_transfers_company_id_conversation_id_chat_conversations_company_id_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk": { "name": "chat_teams_file_transfers_company_id_principal_id_chat_external_principals_company_id_id_fk", "tableFrom": "chat_teams_file_transfers", + "tableTo": "chat_external_principals", "columnsFrom": [ "company_id", "principal_id" ], - "tableTo": "chat_external_principals", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -15185,26 +15576,26 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_voice_callbacks_endpoint_fk": { "name": "chat_voice_callbacks_endpoint_fk", "tableFrom": "chat_voice_callbacks", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -15365,10 +15756,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_voice_inbound_calls\".\"cleanup_confirmed_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_voice_inbound_expiry_idx": { "name": "chat_voice_inbound_expiry_idx", @@ -15387,81 +15778,81 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_voice_inbound_endpoint_fk": { "name": "chat_voice_inbound_endpoint_fk", "tableFrom": "chat_voice_inbound_calls", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_voice_inbound_session_fk": { "name": "chat_voice_inbound_session_fk", "tableFrom": "chat_voice_inbound_calls", + "tableTo": "chat_voice_sessions", "columnsFrom": [ "company_id", "session_id" ], - "tableTo": "chat_voice_sessions", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_inbound_intake_fk": { "name": "chat_voice_inbound_intake_fk", "tableFrom": "chat_voice_inbound_calls", + "tableTo": "issues", "columnsFrom": [ "company_id", "intake_issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_inbound_requested_issue_fk": { "name": "chat_voice_inbound_requested_issue_fk", "tableFrom": "chat_voice_inbound_calls", + "tableTo": "issues", "columnsFrom": [ "company_id", "requested_issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_voice_inbound_provider_uq": { "name": "chat_voice_inbound_provider_uq", + "nullsNotDistinct": false, "columns": [ "provider_session_id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -15546,40 +15937,40 @@ "chat_voice_phone_lines_low_trust_environment_id_environments_id_fk": { "name": "chat_voice_phone_lines_low_trust_environment_id_environments_id_fk", "tableFrom": "chat_voice_phone_lines", + "tableTo": "environments", "columnsFrom": [ "low_trust_environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_phone_lines_endpoint_fk": { "name": "chat_voice_phone_lines_endpoint_fk", "tableFrom": "chat_voice_phone_lines", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_voice_phone_lines_number_uq": { "name": "chat_voice_phone_lines_number_uq", + "nullsNotDistinct": false, "columns": [ "provider_number_id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -15679,26 +16070,26 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_voice_reports_session_fk": { "name": "chat_voice_reports_session_fk", "tableFrom": "chat_voice_reports", + "tableTo": "chat_voice_sessions", "columnsFrom": [ "company_id", "session_id" ], - "tableTo": "chat_voice_sessions", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -15797,9 +16188,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_voice_replies_cursor_uq": { "name": "chat_voice_replies_cursor_uq", @@ -15818,54 +16209,54 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_voice_replies_company_id_companies_id_fk": { "name": "chat_voice_replies_company_id_companies_id_fk", "tableFrom": "chat_voice_replies", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_voice_replies_session_fk": { "name": "chat_voice_replies_session_fk", "tableFrom": "chat_voice_replies", + "tableTo": "chat_voice_sessions", "columnsFrom": [ "company_id", "session_id" ], - "tableTo": "chat_voice_sessions", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_replies_publication_fk": { "name": "chat_voice_replies_publication_fk", "tableFrom": "chat_voice_replies", + "tableTo": "chat_publications", "columnsFrom": [ "company_id", "publication_id" ], - "tableTo": "chat_publications", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -16043,9 +16434,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_voice_sessions_request_uq": { "name": "chat_voice_sessions_request_uq", @@ -16070,9 +16461,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_voice_sessions_live_caller_task_uq": { "name": "chat_voice_sessions_live_caller_task_uq", @@ -16097,10 +16488,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"chat_voice_sessions\".\"state\" not in ('ended', 'failed', 'expired')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "chat_voice_sessions_expiry_idx": { "name": "chat_voice_sessions_expiry_idx", @@ -16119,9 +16510,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_voice_sessions_report_window_idx": { "name": "chat_voice_sessions_report_window_idx", @@ -16140,96 +16531,96 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"chat_voice_sessions\".\"state\" in ('ended', 'failed', 'expired') and \"chat_voice_sessions\".\"provider_session_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "chat_voice_sessions_company_id_companies_id_fk": { "name": "chat_voice_sessions_company_id_companies_id_fk", "tableFrom": "chat_voice_sessions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_voice_sessions_endpoint_fk": { "name": "chat_voice_sessions_endpoint_fk", "tableFrom": "chat_voice_sessions", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_sessions_conversation_fk": { "name": "chat_voice_sessions_conversation_fk", "tableFrom": "chat_voice_sessions", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_sessions_issue_fk": { "name": "chat_voice_sessions_issue_fk", "tableFrom": "chat_voice_sessions", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_sessions_agent_fk": { "name": "chat_voice_sessions_agent_fk", "tableFrom": "chat_voice_sessions", + "tableTo": "agents", "columnsFrom": [ "company_id", "assigned_agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "chat_voice_sessions_company_id_uq": { "name": "chat_voice_sessions_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -16346,9 +16737,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "chat_voice_tool_calls_webhook_uq": { "name": "chat_voice_tool_calls_webhook_uq", @@ -16367,54 +16758,54 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "chat_voice_tool_calls_company_id_companies_id_fk": { "name": "chat_voice_tool_calls_company_id_companies_id_fk", "tableFrom": "chat_voice_tool_calls", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "chat_voice_tool_calls_session_fk": { "name": "chat_voice_tool_calls_session_fk", "tableFrom": "chat_voice_tool_calls", + "tableTo": "chat_voice_sessions", "columnsFrom": [ "company_id", "session_id" ], - "tableTo": "chat_voice_sessions", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "chat_voice_tool_calls_delivery_fk": { "name": "chat_voice_tool_calls_delivery_fk", "tableFrom": "chat_voice_tool_calls", + "tableTo": "chat_deliveries", "columnsFrom": [ "company_id", "delivery_id" ], - "tableTo": "chat_deliveries", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -16464,6 +16855,25 @@ "notNull": true, "default": "'board'" }, + "challenge_kind": { + "name": "challenge_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'board'" + }, + "requested_agent_name": { + "name": "requested_agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requested_agent_role": { + "name": "requested_agent_role", + "type": "text", + "primaryKey": false, + "notNull": false + }, "requested_company_id": { "name": "requested_company_id", "type": "uuid", @@ -16494,6 +16904,12 @@ "primaryKey": false, "notNull": false }, + "approved_agent_id": { + "name": "approved_agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, "approved_at": { "name": "approved_at", "type": "timestamp with time zone", @@ -16539,9 +16955,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cli_auth_challenges_approved_by_idx": { "name": "cli_auth_challenges_approved_by_idx", @@ -16554,9 +16970,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cli_auth_challenges_requested_company_idx": { "name": "cli_auth_challenges_requested_company_idx", @@ -16569,50 +16985,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "cli_auth_challenges_requested_company_id_companies_id_fk": { "name": "cli_auth_challenges_requested_company_id_companies_id_fk", "tableFrom": "cli_auth_challenges", + "tableTo": "companies", "columnsFrom": [ "requested_company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "cli_auth_challenges_approved_by_user_id_user_id_fk": { "name": "cli_auth_challenges_approved_by_user_id_user_id_fk", "tableFrom": "cli_auth_challenges", + "tableTo": "user", "columnsFrom": [ "approved_by_user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk": { "name": "cli_auth_challenges_board_api_key_id_board_api_keys_id_fk", "tableFrom": "cli_auth_challenges", + "tableTo": "board_api_keys", "columnsFrom": [ "board_api_key_id" ], - "tableTo": "board_api_keys", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" + }, + "cli_auth_challenges_approved_agent_id_agents_id_fk": { + "name": "cli_auth_challenges_approved_agent_id_agents_id_fk", + "tableFrom": "cli_auth_challenges", + "tableTo": "agents", + "columnsFrom": [ + "approved_agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -16754,6 +17183,12 @@ "primaryKey": false, "notNull": false }, + "agent_identity_policy": { + "name": "agent_identity_policy", + "type": "text", + "primaryKey": false, + "notNull": false + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -16781,16 +17216,21 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "companies_agent_identity_policy_check": { + "name": "companies_agent_identity_policy_check", + "value": "\"companies\".\"agent_identity_policy\" is null or \"companies\".\"agent_identity_policy\" in ('open_local_profiles', 'delegated_profiles', 'strict_agent_keys')" + } + }, "isRLSEnabled": false }, "public.company_logos": { @@ -16843,9 +17283,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_logos_asset_uq": { "name": "company_logos_asset_uq", @@ -16858,37 +17298,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_logos_company_id_companies_id_fk": { "name": "company_logos_company_id_companies_id_fk", "tableFrom": "company_logos", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_logos_asset_id_assets_id_fk": { "name": "company_logos_asset_id_assets_id_fk", "tableFrom": "company_logos", + "tableTo": "assets", "columnsFrom": [ "asset_id" ], - "tableTo": "assets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -16978,9 +17418,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_memberships_principal_status_idx": { "name": "company_memberships_principal_status_idx", @@ -17005,9 +17445,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_memberships_company_status_idx": { "name": "company_memberships_company_status_idx", @@ -17026,24 +17466,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_memberships_company_id_companies_id_fk": { "name": "company_memberships_company_id_companies_id_fk", "tableFrom": "company_memberships", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -17126,28 +17566,28 @@ "company_observability_company_id_companies_id_fk": { "name": "company_observability_company_id_companies_id_fk", "tableFrom": "company_observability", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_observability_credentials_secret_id_company_secrets_id_fk": { "name": "company_observability_credentials_secret_id_company_secrets_id_fk", "tableFrom": "company_observability", + "tableTo": "company_secrets", "columnsFrom": [ "credentials_secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -17261,63 +17701,63 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_onboarding_seeds_company_id_companies_id_fk": { "name": "company_onboarding_seeds_company_id_companies_id_fk", "tableFrom": "company_onboarding_seeds", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_onboarding_seeds_goal_id_goals_id_fk": { "name": "company_onboarding_seeds_goal_id_goals_id_fk", "tableFrom": "company_onboarding_seeds", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_onboarding_seeds_agent_id_agents_id_fk": { "name": "company_onboarding_seeds_agent_id_agents_id_fk", "tableFrom": "company_onboarding_seeds", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_onboarding_seeds_issue_id_issues_id_fk": { "name": "company_onboarding_seeds_issue_id_issues_id_fk", "tableFrom": "company_onboarding_seeds", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -17326,6 +17766,141 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.company_schemas": { + "name": "company_schemas", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "json_schema": { + "name": "json_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by_agent_id": { + "name": "created_by_agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_profile": { + "name": "created_by_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "company_schemas_company_name_version_uq": { + "name": "company_schemas_company_name_version_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "company_schemas_company_id_companies_id_fk": { + "name": "company_schemas_company_id_companies_id_fk", + "tableFrom": "company_schemas", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_schemas_created_by_agent_id_agents_id_fk": { + "name": "company_schemas_created_by_agent_id_agents_id_fk", + "tableFrom": "company_schemas", + "tableTo": "agents", + "columnsFrom": [ + "created_by_agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "company_schemas_version_check": { + "name": "company_schemas_version_check", + "value": "\"company_schemas\".\"version\" >= 1" + } + }, + "isRLSEnabled": false + }, "public.company_secret_bindings": { "name": "company_secret_bindings", "schema": "", @@ -17427,9 +18002,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_bindings_secret_idx": { "name": "company_secret_bindings_secret_idx", @@ -17442,9 +18017,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_bindings_target_idx": { "name": "company_secret_bindings_target_idx", @@ -17469,9 +18044,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_bindings_target_path_uq": { "name": "company_secret_bindings_target_path_uq", @@ -17502,37 +18077,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_secret_bindings_company_id_companies_id_fk": { "name": "company_secret_bindings_company_id_companies_id_fk", "tableFrom": "company_secret_bindings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "company_secret_bindings_secret_id_company_secrets_id_fk": { "name": "company_secret_bindings_secret_id_company_secrets_id_fk", "tableFrom": "company_secret_bindings", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -17767,9 +18342,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_proposals_proposer_status_idx": { "name": "company_secret_proposals_proposer_status_idx", @@ -17788,9 +18363,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_proposals_expiry_idx": { "name": "company_secret_proposals_expiry_idx", @@ -17809,9 +18384,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_proposals_secret_proposal_idx": { "name": "company_secret_proposals_secret_proposal_idx", @@ -17824,9 +18399,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_proposals_interaction_idx": { "name": "company_secret_proposals_interaction_idx", @@ -17839,128 +18414,128 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_secret_proposals_company_id_companies_id_fk": { "name": "company_secret_proposals_company_id_companies_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "company_secret_proposals_secret_id_company_secrets_id_fk": { "name": "company_secret_proposals_secret_id_company_secrets_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk": { "name": "company_secret_proposals_secret_proposal_id_company_secret_proposals_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "company_secret_proposals", "columnsFrom": [ "secret_proposal_id" ], - "tableTo": "company_secret_proposals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_proposals_target_id_agents_id_fk": { "name": "company_secret_proposals_target_id_agents_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "agents", "columnsFrom": [ "target_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_proposals_proposed_by_agent_id_agents_id_fk": { "name": "company_secret_proposals_proposed_by_agent_id_agents_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "agents", "columnsFrom": [ "proposed_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_proposals_origin_issue_id_issues_id_fk": { "name": "company_secret_proposals_origin_issue_id_issues_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "issues", "columnsFrom": [ "origin_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk": { "name": "company_secret_proposals_origin_run_id_heartbeat_runs_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "heartbeat_runs", "columnsFrom": [ "origin_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk": { "name": "company_secret_proposals_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_secret_proposals_created_secret_id_company_secrets_id_fk": { "name": "company_secret_proposals_created_secret_id_company_secrets_id_fk", "tableFrom": "company_secret_proposals", + "tableTo": "company_secrets", "columnsFrom": [ "created_secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -18105,9 +18680,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_provider_configs_company_provider_idx": { "name": "company_secret_provider_configs_company_provider_idx", @@ -18126,9 +18701,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_provider_configs_default_uq": { "name": "company_secret_provider_configs_default_uq", @@ -18147,38 +18722,38 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secret_provider_configs\".\"is_default\" = true", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "company_secret_provider_configs_company_id_companies_id_fk": { "name": "company_secret_provider_configs_company_id_companies_id_fk", "tableFrom": "company_secret_provider_configs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_provider_configs_created_by_agent_id_agents_id_fk": { "name": "company_secret_provider_configs_created_by_agent_id_agents_id_fk", "tableFrom": "company_secret_provider_configs", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -18291,9 +18866,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_versions_value_sha256_idx": { "name": "company_secret_versions_value_sha256_idx", @@ -18306,9 +18881,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_versions_fingerprint_idx": { "name": "company_secret_versions_fingerprint_idx", @@ -18321,9 +18896,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secret_versions_secret_version_uq": { "name": "company_secret_versions_secret_version_uq", @@ -18342,37 +18917,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_secret_versions_secret_id_company_secrets_id_fk": { "name": "company_secret_versions_secret_id_company_secrets_id_fk", "tableFrom": "company_secret_versions", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secret_versions_created_by_agent_id_agents_id_fk": { "name": "company_secret_versions_created_by_agent_id_agents_id_fk", "tableFrom": "company_secret_versions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -18569,9 +19144,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_company_scope_idx": { "name": "company_secrets_company_scope_idx", @@ -18590,9 +19165,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_company_owner_idx": { "name": "company_secrets_company_owner_idx", @@ -18611,9 +19186,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_user_definition_owner_idx": { "name": "company_secrets_user_definition_owner_idx", @@ -18638,9 +19213,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_company_provider_idx": { "name": "company_secrets_company_provider_idx", @@ -18659,9 +19234,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_project_instance_owner_key_uq": { "name": "company_secrets_project_instance_owner_key_uq", @@ -18692,10 +19267,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secrets\".\"scope\" = 'instance' and \"company_secrets\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_secrets_instance_owner_key_uq": { "name": "company_secrets_instance_owner_key_uq", @@ -18726,10 +19301,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secrets\".\"scope\" = 'instance' and \"company_secrets\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_secrets_provider_config_idx": { "name": "company_secrets_provider_config_idx", @@ -18742,9 +19317,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_secrets_company_name_uq": { "name": "company_secrets_company_name_uq", @@ -18763,10 +19338,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_secrets_company_key_uq": { "name": "company_secrets_company_key_uq", @@ -18785,10 +19360,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secrets\".\"scope\" = 'company' and \"company_secrets\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_secrets_user_definition_owner_uq": { "name": "company_secrets_user_definition_owner_uq", @@ -18813,107 +19388,107 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_secrets\".\"scope\" = 'user' and \"company_secrets\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "company_secrets_company_id_companies_id_fk": { "name": "company_secrets_company_id_companies_id_fk", "tableFrom": "company_secrets", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "company_secrets_owner_plugin_id_plugins_id_fk": { "name": "company_secrets_owner_plugin_id_plugins_id_fk", "tableFrom": "company_secrets", + "tableTo": "plugins", "columnsFrom": [ "owner_plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk": { "name": "company_secrets_user_secret_definition_id_user_secret_definitions_id_fk", "tableFrom": "company_secrets", + "tableTo": "user_secret_definitions", "columnsFrom": [ "user_secret_definition_id" ], - "tableTo": "user_secret_definitions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_secrets_provider_config_id_company_secret_provider_configs_id_fk": { "name": "company_secrets_provider_config_id_company_secret_provider_configs_id_fk", "tableFrom": "company_secrets", + "tableTo": "company_secret_provider_configs", "columnsFrom": [ "provider_config_id" ], - "tableTo": "company_secret_provider_configs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_secrets_created_by_agent_id_agents_id_fk": { "name": "company_secrets_created_by_agent_id_agents_id_fk", "tableFrom": "company_secrets", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_secrets_company_id_owner_agent_id_agents_company_id_id_fk": { "name": "company_secrets_company_id_owner_agent_id_agents_company_id_id_fk", "tableFrom": "company_secrets", + "tableTo": "agents", "columnsFrom": [ "company_id", "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_secrets_company_id_owner_project_id_projects_company_id_id_fk": { "name": "company_secrets_company_id_owner_project_id_projects_company_id_id_fk", "tableFrom": "company_secrets", + "tableTo": "projects", "columnsFrom": [ "company_id", "owner_project_id" ], - "tableTo": "projects", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -18983,15 +19558,15 @@ "company_skill_policies_company_id_companies_id_fk": { "name": "company_skill_policies_company_id_companies_id_fk", "tableFrom": "company_skill_policies", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -19030,15 +19605,15 @@ "company_skill_import_budgets_company_id_companies_id_fk": { "name": "company_skill_import_budgets_company_id_companies_id_fk", "tableFrom": "company_skill_import_budgets", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -19139,9 +19714,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_source_entries_company_skill_idx": { "name": "company_skill_source_entries_company_skill_idx", @@ -19160,50 +19735,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_source_entries_company_id_companies_id_fk": { "name": "company_skill_source_entries_company_id_companies_id_fk", "tableFrom": "company_skill_source_entries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_source_entries_source_id_company_skill_sources_id_fk": { "name": "company_skill_source_entries_source_id_company_skill_sources_id_fk", "tableFrom": "company_skill_source_entries", + "tableTo": "company_skill_sources", "columnsFrom": [ "source_id" ], - "tableTo": "company_skill_sources", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_source_entries_skill_id_company_skills_id_fk": { "name": "company_skill_source_entries_skill_id_company_skills_id_fk", "tableFrom": "company_skill_source_entries", + "tableTo": "company_skills", "columnsFrom": [ "skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -19447,10 +20022,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_skill_sources\".\"removed_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_skill_sources_identity_ref_idx": { "name": "company_skill_sources_identity_ref_idx", @@ -19475,25 +20050,25 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_skill_sources\".\"removed_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "company_skill_sources_company_id_companies_id_fk": { "name": "company_skill_sources_company_id_companies_id_fk", "tableFrom": "company_skill_sources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -19658,9 +20233,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_skill_sources_source_project_idx": { "name": "project_skill_sources_source_project_idx", @@ -19685,9 +20260,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_skill_sources_sync_idx": { "name": "project_skill_sources_sync_idx", @@ -19712,63 +20287,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "project_skill_sources_company_id_companies_id_fk": { "name": "project_skill_sources_company_id_companies_id_fk", "tableFrom": "project_skill_sources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_skill_sources_project_id_projects_id_fk": { "name": "project_skill_sources_project_id_projects_id_fk", "tableFrom": "project_skill_sources", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_skill_sources_workspace_id_project_workspaces_id_fk": { "name": "project_skill_sources_workspace_id_project_workspaces_id_fk", "tableFrom": "project_skill_sources", + "tableTo": "project_workspaces", "columnsFrom": [ "workspace_id" ], - "tableTo": "project_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "project_skill_sources_source_id_company_skill_sources_id_fk": { "name": "project_skill_sources_source_id_company_skill_sources_id_fk", "tableFrom": "project_skill_sources", + "tableTo": "company_skill_sources", "columnsFrom": [ "source_id" ], - "tableTo": "company_skill_sources", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -19869,9 +20444,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_comments_parent_idx": { "name": "company_skill_comments_parent_idx", @@ -19884,63 +20459,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_comments_company_id_companies_id_fk": { "name": "company_skill_comments_company_id_companies_id_fk", "tableFrom": "company_skill_comments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_comments_company_skill_id_company_skills_id_fk": { "name": "company_skill_comments_company_skill_id_company_skills_id_fk", "tableFrom": "company_skill_comments", + "tableTo": "company_skills", "columnsFrom": [ "company_skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_comments_parent_comment_id_company_skill_comments_id_fk": { "name": "company_skill_comments_parent_comment_id_company_skill_comments_id_fk", "tableFrom": "company_skill_comments", + "tableTo": "company_skill_comments", "columnsFrom": [ "parent_comment_id" ], - "tableTo": "company_skill_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skill_comments_author_agent_id_agents_id_fk": { "name": "company_skill_comments_author_agent_id_agents_id_fk", "tableFrom": "company_skill_comments", + "tableTo": "agents", "columnsFrom": [ "author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20015,24 +20590,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_mutation_receipts_company_id_companies_id_fk": { "name": "company_skill_mutation_receipts_company_id_companies_id_fk", "tableFrom": "company_skill_mutation_receipts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20135,9 +20710,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_snapshots_migration_idx": { "name": "company_skill_snapshots_migration_idx", @@ -20150,10 +20725,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"company_skill_repository_snapshots\".\"migration_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_skill_snapshots_maintenance_idx": { "name": "company_skill_snapshots_maintenance_idx", @@ -20166,25 +20741,25 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"company_skill_repository_snapshots\".\"maintenance_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "company_skill_repository_snapshots_company_id_companies_id_fk": { "name": "company_skill_repository_snapshots_company_id_companies_id_fk", "tableFrom": "company_skill_repository_snapshots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20254,9 +20829,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_stars_skill_user_idx": { "name": "company_skill_stars_skill_user_idx", @@ -20275,9 +20850,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_stars_company_skill_created_idx": { "name": "company_skill_stars_company_skill_created_idx", @@ -20302,50 +20877,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_stars_company_id_companies_id_fk": { "name": "company_skill_stars_company_id_companies_id_fk", "tableFrom": "company_skill_stars", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_stars_company_skill_id_company_skills_id_fk": { "name": "company_skill_stars_company_skill_id_company_skills_id_fk", "tableFrom": "company_skill_stars", + "tableTo": "company_skills", "columnsFrom": [ "company_skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_stars_agent_id_agents_id_fk": { "name": "company_skill_stars_agent_id_agents_id_fk", "tableFrom": "company_skill_stars", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20440,9 +21015,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_test_inputs_company_skill_active_idx": { "name": "company_skill_test_inputs_company_skill_active_idx", @@ -20467,37 +21042,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_test_inputs_company_id_companies_id_fk": { "name": "company_skill_test_inputs_company_id_companies_id_fk", "tableFrom": "company_skill_test_inputs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_test_inputs_skill_id_company_skills_id_fk": { "name": "company_skill_test_inputs_skill_id_company_skills_id_fk", "tableFrom": "company_skill_test_inputs", + "tableTo": "company_skills", "columnsFrom": [ "skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20610,50 +21185,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_test_run_templates_company_id_companies_id_fk": { "name": "company_skill_test_run_templates_company_id_companies_id_fk", "tableFrom": "company_skill_test_run_templates", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_test_run_templates_created_by_agent_id_agents_id_fk": { "name": "company_skill_test_run_templates_created_by_agent_id_agents_id_fk", "tableFrom": "company_skill_test_run_templates", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk": { "name": "company_skill_test_run_templates_updated_by_agent_id_agents_id_fk", "tableFrom": "company_skill_test_run_templates", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -20843,9 +21418,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_test_runs_company_issue_idx": { "name": "company_skill_test_runs_company_issue_idx", @@ -20864,9 +21439,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_test_runs_company_input_created_idx": { "name": "company_skill_test_runs_company_input_created_idx", @@ -20891,9 +21466,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_test_runs_company_status_idx": { "name": "company_skill_test_runs_company_status_idx", @@ -20912,9 +21487,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_test_runs_company_harness_expires_idx": { "name": "company_skill_test_runs_company_harness_expires_idx", @@ -20933,89 +21508,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_test_runs_company_id_companies_id_fk": { "name": "company_skill_test_runs_company_id_companies_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_test_runs_skill_id_company_skills_id_fk": { "name": "company_skill_test_runs_skill_id_company_skills_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "company_skills", "columnsFrom": [ "skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk": { "name": "company_skill_test_runs_input_id_company_skill_test_inputs_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "company_skill_test_inputs", "columnsFrom": [ "input_id" ], - "tableTo": "company_skill_test_inputs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk": { "name": "company_skill_test_runs_skill_version_id_company_skill_versions_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "company_skill_versions", "columnsFrom": [ "skill_version_id" ], - "tableTo": "company_skill_versions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "company_skill_test_runs_agent_id_agents_id_fk": { "name": "company_skill_test_runs_agent_id_agents_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "company_skill_test_runs_issue_id_issues_id_fk": { "name": "company_skill_test_runs_issue_id_issues_id_fk", "tableFrom": "company_skill_test_runs", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -21147,10 +21722,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"company_skill_versions\".\"migration_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_skill_versions_package_snapshot_idx": { "name": "company_skill_versions_package_snapshot_idx", @@ -21163,9 +21738,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_versions_repository_snapshot_idx": { "name": "company_skill_versions_repository_snapshot_idx", @@ -21178,9 +21753,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_versions_skill_revision_idx": { "name": "company_skill_versions_skill_revision_idx", @@ -21199,9 +21774,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skill_versions_skill_release_idx": { "name": "company_skill_versions_skill_release_idx", @@ -21220,10 +21795,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_skill_versions\".\"release_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_skill_versions_company_skill_created_idx": { "name": "company_skill_versions_company_skill_created_idx", @@ -21248,76 +21823,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skill_versions_company_id_companies_id_fk": { "name": "company_skill_versions_company_id_companies_id_fk", "tableFrom": "company_skill_versions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_versions_company_skill_id_company_skills_id_fk": { "name": "company_skill_versions_company_skill_id_company_skills_id_fk", "tableFrom": "company_skill_versions", + "tableTo": "company_skills", "columnsFrom": [ "company_skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "company_skill_versions_repository_snapshot_id_company_skill_repository_snapshots_id_fk": { "name": "company_skill_versions_repository_snapshot_id_company_skill_repository_snapshots_id_fk", "tableFrom": "company_skill_versions", + "tableTo": "company_skill_repository_snapshots", "columnsFrom": [ "repository_snapshot_id" ], - "tableTo": "company_skill_repository_snapshots", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "company_skill_versions_package_snapshot_id_company_skill_repository_snapshots_id_fk": { "name": "company_skill_versions_package_snapshot_id_company_skill_repository_snapshots_id_fk", "tableFrom": "company_skill_versions", + "tableTo": "company_skill_repository_snapshots", "columnsFrom": [ "package_snapshot_id" ], - "tableTo": "company_skill_repository_snapshots", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "company_skill_versions_author_agent_id_agents_id_fk": { "name": "company_skill_versions_author_agent_id_agents_id_fk", "tableFrom": "company_skill_versions", + "tableTo": "agents", "columnsFrom": [ "author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -21553,9 +22128,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skills_company_name_idx": { "name": "company_skills_company_name_idx", @@ -21574,9 +22149,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skills_company_folder_idx": { "name": "company_skills_company_folder_idx", @@ -21595,9 +22170,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skills_company_categories_idx": { "name": "company_skills_company_categories_idx", @@ -21610,9 +22185,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "company_skills_company_sharing_scope_idx": { "name": "company_skills_company_sharing_scope_idx", @@ -21631,9 +22206,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skills_company_current_version_idx": { "name": "company_skills_company_current_version_idx", @@ -21652,9 +22227,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_skills_company_forked_from_idx": { "name": "company_skills_company_forked_from_idx", @@ -21673,76 +22248,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_skills_company_id_companies_id_fk": { "name": "company_skills_company_id_companies_id_fk", "tableFrom": "company_skills", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "company_skills_folder_id_folders_id_fk": { "name": "company_skills_folder_id_folders_id_fk", "tableFrom": "company_skills", + "tableTo": "folders", "columnsFrom": [ "folder_id" ], - "tableTo": "folders", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skills_forked_from_skill_id_company_skills_id_fk": { "name": "company_skills_forked_from_skill_id_company_skills_id_fk", "tableFrom": "company_skills", + "tableTo": "company_skills", "columnsFrom": [ "forked_from_skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skills_forked_from_company_id_companies_id_fk": { "name": "company_skills_forked_from_company_id_companies_id_fk", "tableFrom": "company_skills", + "tableTo": "companies", "columnsFrom": [ "forked_from_company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "company_skills_current_version_id_company_skill_versions_id_fk": { "name": "company_skills_current_version_id_company_skill_versions_id_fk", "tableFrom": "company_skills", + "tableTo": "company_skill_versions", "columnsFrom": [ "current_version_id" ], - "tableTo": "company_skill_versions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -21811,9 +22386,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -21949,9 +22524,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_transfer_runs_idempotency_direction_idx": { "name": "company_transfer_runs_idempotency_direction_idx", @@ -21970,9 +22545,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_transfer_runs_actor_status_idx": { "name": "company_transfer_runs_actor_status_idx", @@ -21991,24 +22566,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_transfer_runs_company_id_companies_id_fk": { "name": "company_transfer_runs_company_id_companies_id_fk", "tableFrom": "company_transfer_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -22074,9 +22649,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_user_sidebar_preferences_user_idx": { "name": "company_user_sidebar_preferences_user_idx", @@ -22089,9 +22664,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_user_sidebar_preferences_company_user_uq": { "name": "company_user_sidebar_preferences_company_user_uq", @@ -22110,24 +22685,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "company_user_sidebar_preferences_company_id_companies_id_fk": { "name": "company_user_sidebar_preferences_company_id_companies_id_fk", "tableFrom": "company_user_sidebar_preferences", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -22216,9 +22791,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "company_workload_identity_keys_one_active_uq": { "name": "company_workload_identity_keys_one_active_uq", @@ -22231,10 +22806,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_workload_identity_keys\".\"status\" = 'active'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "company_workload_identity_keys_one_next_uq": { "name": "company_workload_identity_keys_one_next_uq", @@ -22247,25 +22822,25 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"company_workload_identity_keys\".\"status\" = 'next'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "company_workload_identity_keys_company_id_companies_id_fk": { "name": "company_workload_identity_keys_company_id_companies_id_fk", "tableFrom": "company_workload_identity_keys", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -22398,9 +22973,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "completion_contracts_issue_hash_uq": { "name": "completion_contracts_issue_hash_uq", @@ -22419,68 +22994,68 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "completion_contracts_company_id_companies_id_fk": { "name": "completion_contracts_company_id_companies_id_fk", "tableFrom": "completion_contracts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "completion_contracts_issue_company_fk": { "name": "completion_contracts_issue_company_fk", "tableFrom": "completion_contracts", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "completion_contracts_supersedes_owner_fk": { "name": "completion_contracts_supersedes_owner_fk", "tableFrom": "completion_contracts", + "tableTo": "completion_contracts", "columnsFrom": [ "company_id", "issue_id", "supersedes_contract_id" ], - "tableTo": "completion_contracts", "columnsTo": [ "company_id", "issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "completion_contracts_company_issue_id_uq": { "name": "completion_contracts_company_issue_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "issue_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -22618,9 +23193,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_event_deliveries_company_status_idx": { "name": "connection_event_deliveries_company_status_idx", @@ -22645,24 +23220,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "connection_event_deliveries_company_id_companies_id_fk": { "name": "connection_event_deliveries_company_id_companies_id_fk", "tableFrom": "connection_event_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -22726,37 +23301,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk": { "name": "connection_intent_deliveries_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "connection_intent_deliveries", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_intent_deliveries_company_id_companies_id_fk": { "name": "connection_intent_deliveries_company_id_companies_id_fk", "tableFrom": "connection_intent_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -22856,9 +23431,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "controller_instances_lease_idx": { "name": "controller_instances_lease_idx", @@ -22871,9 +23446,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -23083,9 +23658,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_provider_request_idx": { "name": "cost_events_provider_request_idx", @@ -23110,9 +23685,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_project_occurred_idx": { "name": "cost_events_company_project_occurred_idx", @@ -23137,9 +23712,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_unpriced_idx": { "name": "cost_events_unpriced_idx", @@ -23164,10 +23739,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"cost_events\".\"cost_status\" = 'unpriced' and \"cost_events\".\"billing_type\" <> 'subscription_included'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "cost_events_data_quality_idx": { "name": "cost_events_data_quality_idx", @@ -23192,10 +23767,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"cost_events\".\"billing_type\" = 'unknown' or (\"cost_events\".\"cost_status\" = 'unpriced' and \"cost_events\".\"billing_type\" <> 'subscription_included')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "cost_events_company_occurred_idx": { "name": "cost_events_company_occurred_idx", @@ -23214,9 +23789,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_subscription_occurred_idx": { "name": "cost_events_company_subscription_occurred_idx", @@ -23241,9 +23816,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_agent_occurred_idx": { "name": "cost_events_company_agent_occurred_idx", @@ -23268,9 +23843,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_provider_occurred_idx": { "name": "cost_events_company_provider_occurred_idx", @@ -23295,9 +23870,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_biller_occurred_idx": { "name": "cost_events_company_biller_occurred_idx", @@ -23322,9 +23897,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "cost_events_company_heartbeat_run_idx": { "name": "cost_events_company_heartbeat_run_idx", @@ -23343,102 +23918,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "cost_events_company_id_companies_id_fk": { "name": "cost_events_company_id_companies_id_fk", "tableFrom": "cost_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "cost_events_agent_id_agents_id_fk": { "name": "cost_events_agent_id_agents_id_fk", "tableFrom": "cost_events", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "cost_events_issue_id_issues_id_fk": { "name": "cost_events_issue_id_issues_id_fk", "tableFrom": "cost_events", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "cost_events_project_id_projects_id_fk": { "name": "cost_events_project_id_projects_id_fk", "tableFrom": "cost_events", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "cost_events_goal_id_goals_id_fk": { "name": "cost_events_goal_id_goals_id_fk", "tableFrom": "cost_events", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "cost_events_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "cost_events_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "cost_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "cost_events_subscription_id_ai_subscriptions_id_fk": { "name": "cost_events_subscription_id_ai_subscriptions_id_fk", "tableFrom": "cost_events", + "tableTo": "ai_subscriptions", "columnsFrom": [ "subscription_id" ], - "tableTo": "ai_subscriptions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -23517,15 +24092,15 @@ "company_decision_models_company_id_companies_id_fk": { "name": "company_decision_models_company_id_companies_id_fk", "tableFrom": "company_decision_models", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -23721,9 +24296,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_invocations_pending_idx": { "name": "decision_invocations_pending_idx", @@ -23736,10 +24311,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"decision_invocations\".\"status\" = 'running'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "decision_invocations_cost_idx": { "name": "decision_invocations_cost_idx", @@ -23752,37 +24327,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_invocations_company_id_companies_id_fk": { "name": "decision_invocations_company_id_companies_id_fk", "tableFrom": "decision_invocations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_invocations_cost_event_id_cost_events_id_fk": { "name": "decision_invocations_cost_event_id_cost_events_id_fk", "tableFrom": "decision_invocations", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -23920,9 +24495,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_archive_notification_outbox_pending_idx": { "name": "decision_archive_notification_outbox_pending_idx", @@ -23941,9 +24516,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_archive_notification_outbox_delivery_idx": { "name": "decision_archive_notification_outbox_delivery_idx", @@ -23968,38 +24543,38 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"decision_archive_notification_outbox\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "decision_archive_notification_outbox_company_id_companies_id_fk": { "name": "decision_archive_notification_outbox_company_id_companies_id_fk", "tableFrom": "decision_archive_notification_outbox", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_archive_notification_outbox_origin_agent_id_agents_id_fk": { "name": "decision_archive_notification_outbox_origin_agent_id_agents_id_fk", "tableFrom": "decision_archive_notification_outbox", + "tableTo": "agents", "columnsFrom": [ "origin_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -24116,9 +24691,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_queue_items_company_source_idx": { "name": "decision_queue_items_company_source_idx", @@ -24143,78 +24718,78 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_queue_items_company_id_companies_id_fk": { "name": "decision_queue_items_company_id_companies_id_fk", "tableFrom": "decision_queue_items", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_queue_items_added_by_agent_id_agents_id_fk": { "name": "decision_queue_items_added_by_agent_id_agents_id_fk", "tableFrom": "decision_queue_items", + "tableTo": "agents", "columnsFrom": [ "added_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk": { "name": "decision_queue_items_added_by_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_queue_items", + "tableTo": "heartbeat_runs", "columnsFrom": [ "added_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk": { "name": "decision_queue_items_added_by_agent_api_key_id_agent_api_keys_id_fk", "tableFrom": "decision_queue_items", + "tableTo": "agent_api_keys", "columnsFrom": [ "added_by_agent_api_key_id" ], - "tableTo": "agent_api_keys", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_queue_items_queue_company_fk": { "name": "decision_queue_items_queue_company_fk", "tableFrom": "decision_queue_items", + "tableTo": "decision_queues", "columnsFrom": [ "queue_id", "company_id" ], - "tableTo": "decision_queues", "columnsTo": [ "id", "company_id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -24346,9 +24921,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_queues_company_updated_idx": { "name": "decision_queues_company_updated_idx", @@ -24367,74 +24942,74 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_queues_company_id_companies_id_fk": { "name": "decision_queues_company_id_companies_id_fk", "tableFrom": "decision_queues", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_queues_created_by_agent_id_agents_id_fk": { "name": "decision_queues_created_by_agent_id_agents_id_fk", "tableFrom": "decision_queues", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_queues_created_by_run_id_heartbeat_runs_id_fk": { "name": "decision_queues_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_queues", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk": { "name": "decision_queues_created_by_agent_api_key_id_agent_api_keys_id_fk", "tableFrom": "decision_queues", + "tableTo": "agent_api_keys", "columnsFrom": [ "created_by_agent_api_key_id" ], - "tableTo": "agent_api_keys", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "decision_queues_id_company_uq": { "name": "decision_queues_id_company_uq", + "nullsNotDistinct": false, "columns": [ "id", "company_id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -24581,9 +25156,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_retention_company_archived_idx": { "name": "decision_retention_company_archived_idx", @@ -24602,50 +25177,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_retention_company_id_companies_id_fk": { "name": "decision_retention_company_id_companies_id_fk", "tableFrom": "decision_retention", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_retention_archived_by_agent_id_agents_id_fk": { "name": "decision_retention_archived_by_agent_id_agents_id_fk", "tableFrom": "decision_retention", + "tableTo": "agents", "columnsFrom": [ "archived_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_retention_archived_by_run_id_heartbeat_runs_id_fk": { "name": "decision_retention_archived_by_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_retention", + "tableTo": "heartbeat_runs", "columnsFrom": [ "archived_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -24788,9 +25363,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_triage_company_decide_by_idx": { "name": "decision_triage_company_decide_by_idx", @@ -24809,63 +25384,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_triage_company_id_companies_id_fk": { "name": "decision_triage_company_id_companies_id_fk", "tableFrom": "decision_triage", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_triage_set_by_agent_id_agents_id_fk": { "name": "decision_triage_set_by_agent_id_agents_id_fk", "tableFrom": "decision_triage", + "tableTo": "agents", "columnsFrom": [ "set_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_triage_set_by_run_id_heartbeat_runs_id_fk": { "name": "decision_triage_set_by_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_triage", + "tableTo": "heartbeat_runs", "columnsFrom": [ "set_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk": { "name": "decision_triage_set_by_agent_api_key_id_agent_api_keys_id_fk", "tableFrom": "decision_triage", + "tableTo": "agent_api_keys", "columnsFrom": [ "set_by_agent_api_key_id" ], - "tableTo": "agent_api_keys", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -25005,9 +25580,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_triage_events_queue_created_idx": { "name": "decision_triage_events_queue_created_idx", @@ -25026,76 +25601,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_triage_events_company_id_companies_id_fk": { "name": "decision_triage_events_company_id_companies_id_fk", "tableFrom": "decision_triage_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_triage_events_queue_id_decision_queues_id_fk": { "name": "decision_triage_events_queue_id_decision_queues_id_fk", "tableFrom": "decision_triage_events", + "tableTo": "decision_queues", "columnsFrom": [ "queue_id" ], - "tableTo": "decision_queues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_triage_events_actor_agent_id_agents_id_fk": { "name": "decision_triage_events_actor_agent_id_agents_id_fk", "tableFrom": "decision_triage_events", + "tableTo": "agents", "columnsFrom": [ "actor_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_triage_events_actor_run_id_heartbeat_runs_id_fk": { "name": "decision_triage_events_actor_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_triage_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "actor_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk": { "name": "decision_triage_events_agent_api_key_id_agent_api_keys_id_fk", "tableFrom": "decision_triage_events", + "tableTo": "agent_api_keys", "columnsFrom": [ "agent_api_key_id" ], - "tableTo": "agent_api_keys", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -25222,9 +25797,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_training_examples_issue_idx": { "name": "decision_training_examples_issue_idx", @@ -25237,9 +25812,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_training_examples_source_author_uq": { "name": "decision_training_examples_source_author_uq", @@ -25264,37 +25839,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_training_examples_company_id_companies_id_fk": { "name": "decision_training_examples_company_id_companies_id_fk", "tableFrom": "decision_training_examples", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_training_examples_issue_id_issues_id_fk": { "name": "decision_training_examples_issue_id_issues_id_fk", "tableFrom": "decision_training_examples", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -25376,63 +25951,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_bundles_company_id_companies_id_fk": { "name": "decision_bundles_company_id_companies_id_fk", "tableFrom": "decision_bundles", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_bundles_origin_agent_id_agents_id_fk": { "name": "decision_bundles_origin_agent_id_agents_id_fk", "tableFrom": "decision_bundles", + "tableTo": "agents", "columnsFrom": [ "origin_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_bundles_origin_issue_id_issues_id_fk": { "name": "decision_bundles_origin_issue_id_issues_id_fk", "tableFrom": "decision_bundles", + "tableTo": "issues", "columnsFrom": [ "origin_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_bundles_origin_run_id_heartbeat_runs_id_fk": { "name": "decision_bundles_origin_run_id_heartbeat_runs_id_fk", "tableFrom": "decision_bundles", + "tableTo": "heartbeat_runs", "columnsFrom": [ "origin_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -25526,9 +26101,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_effect_executions_target_issue_idx": { "name": "decision_effect_executions_target_issue_idx", @@ -25541,50 +26116,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_effect_executions_decision_id_decisions_id_fk": { "name": "decision_effect_executions_decision_id_decisions_id_fk", "tableFrom": "decision_effect_executions", + "tableTo": "decisions", "columnsFrom": [ "decision_id" ], - "tableTo": "decisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_effect_executions_target_issue_id_issues_id_fk": { "name": "decision_effect_executions_target_issue_id_issues_id_fk", "tableFrom": "decision_effect_executions", + "tableTo": "issues", "columnsFrom": [ "target_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decision_effect_executions_activity_log_id_activity_log_id_fk": { "name": "decision_effect_executions_activity_log_id_activity_log_id_fk", "tableFrom": "decision_effect_executions", + "tableTo": "activity_log", "columnsFrom": [ "activity_log_id" ], - "tableTo": "activity_log", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -25628,9 +26203,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decision_target_issues_issue_idx": { "name": "decision_target_issues_issue_idx", @@ -25643,50 +26218,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "decision_target_issues_decision_id_decisions_id_fk": { "name": "decision_target_issues_decision_id_decisions_id_fk", "tableFrom": "decision_target_issues", + "tableTo": "decisions", "columnsFrom": [ "decision_id" ], - "tableTo": "decisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_target_issues_issue_id_issues_id_fk": { "name": "decision_target_issues_issue_id_issues_id_fk", "tableFrom": "decision_target_issues", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "decision_target_issues_company_id_companies_id_fk": { "name": "decision_target_issues_company_id_companies_id_fk", "tableFrom": "decision_target_issues", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -25888,9 +26463,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decisions_running_recovery_idx": { "name": "decisions_running_recovery_idx", @@ -25909,10 +26484,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"decisions\".\"status\" = 'decided' AND \"decisions\".\"execution_status\" = 'running'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "decisions_open_expiry_idx": { "name": "decisions_open_expiry_idx", @@ -25931,10 +26506,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"decisions\".\"status\" = 'open'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "decisions_pending_continuation_idx": { "name": "decisions_pending_continuation_idx", @@ -25947,10 +26522,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"decisions\".\"continuation_policy\" = 'wake_origin_agent' AND \"decisions\".\"metadata\" ->> 'continuationPending' = 'true' AND (\"decisions\".\"status\" IN ('expired', 'cancelled') OR (\"decisions\".\"status\" = 'decided' AND \"decisions\".\"execution_status\" IN ('succeeded', 'partial', 'failed')))", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "decisions_bundle_idx": { "name": "decisions_bundle_idx", @@ -25963,9 +26538,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decisions_origin_issue_idx": { "name": "decisions_origin_issue_idx", @@ -25978,9 +26553,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "decisions_company_idempotency_uq": { "name": "decisions_company_idempotency_uq", @@ -25999,77 +26574,77 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"decisions\".\"idempotency_key\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "decisions_company_id_companies_id_fk": { "name": "decisions_company_id_companies_id_fk", "tableFrom": "decisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decisions_bundle_id_decision_bundles_id_fk": { "name": "decisions_bundle_id_decision_bundles_id_fk", "tableFrom": "decisions", + "tableTo": "decision_bundles", "columnsFrom": [ "bundle_id" ], - "tableTo": "decision_bundles", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "decisions_origin_agent_id_agents_id_fk": { "name": "decisions_origin_agent_id_agents_id_fk", "tableFrom": "decisions", + "tableTo": "agents", "columnsFrom": [ "origin_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decisions_origin_issue_id_issues_id_fk": { "name": "decisions_origin_issue_id_issues_id_fk", "tableFrom": "decisions", + "tableTo": "issues", "columnsFrom": [ "origin_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "decisions_origin_run_id_heartbeat_runs_id_fk": { "name": "decisions_origin_run_id_heartbeat_runs_id_fk", "tableFrom": "decisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "origin_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -26193,9 +26768,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_anchor_snapshots_company_document_revision_idx": { "name": "document_annotation_anchor_snapshots_company_document_revision_idx", @@ -26220,76 +26795,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "document_annotation_anchor_snapshots_company_id_companies_id_fk": { "name": "document_annotation_anchor_snapshots_company_id_companies_id_fk", "tableFrom": "document_annotation_anchor_snapshots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk": { "name": "document_annotation_anchor_snapshots_thread_id_document_annotation_threads_id_fk", "tableFrom": "document_annotation_anchor_snapshots", + "tableTo": "document_annotation_threads", "columnsFrom": [ "thread_id" ], - "tableTo": "document_annotation_threads", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_anchor_snapshots_document_id_documents_id_fk": { "name": "document_annotation_anchor_snapshots_document_id_documents_id_fk", "tableFrom": "document_annotation_anchor_snapshots", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk": { "name": "document_annotation_anchor_snapshots_from_revision_id_document_revisions_id_fk", "tableFrom": "document_annotation_anchor_snapshots", + "tableTo": "document_revisions", "columnsFrom": [ "from_revision_id" ], - "tableTo": "document_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk": { "name": "document_annotation_anchor_snapshots_to_revision_id_document_revisions_id_fk", "tableFrom": "document_annotation_anchor_snapshots", + "tableTo": "document_revisions", "columnsFrom": [ "to_revision_id" ], - "tableTo": "document_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -26298,6 +26873,160 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.document_annotation_comment_reactions": { + "name": "document_annotation_comment_reactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "comment_id": { + "name": "comment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reaction": { + "name": "reaction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "document_annotation_comment_reactions_company_comment_idx": { + "name": "document_annotation_comment_reactions_company_comment_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "comment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "document_annotation_comment_reactions_comment_reaction_actor_idx": { + "name": "document_annotation_comment_reactions_comment_reaction_actor_idx", + "columns": [ + { + "expression": "comment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reaction", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_annotation_comment_reactions_company_id_companies_id_fk": { + "name": "document_annotation_comment_reactions_company_id_companies_id_fk", + "tableFrom": "document_annotation_comment_reactions", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "document_annotation_comment_reactions_comment_id_document_annotation_comments_id_fk": { + "name": "document_annotation_comment_reactions_comment_id_document_annotation_comments_id_fk", + "tableFrom": "document_annotation_comment_reactions", + "tableTo": "document_annotation_comments", + "columnsFrom": [ + "comment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "document_annotation_comment_reactions_reaction_chk": { + "name": "document_annotation_comment_reactions_reaction_chk", + "value": "\"document_annotation_comment_reactions\".\"reaction\" in ('done', 'check', 'thumbs_up', 'question')" + }, + "document_annotation_comment_reactions_actor_type_chk": { + "name": "document_annotation_comment_reactions_actor_type_chk", + "value": "\"document_annotation_comment_reactions\".\"actor_type\" in ('agent', 'user')" + } + }, + "isRLSEnabled": false + }, "public.document_annotation_comments": { "name": "document_annotation_comments", "schema": "", @@ -26426,9 +27155,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_company_issue_created_at_idx": { "name": "document_annotation_comments_company_issue_created_at_idx", @@ -26453,9 +27182,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_company_routine_created_at_idx": { "name": "document_annotation_comments_company_routine_created_at_idx", @@ -26480,9 +27209,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_company_case_created_at_idx": { "name": "document_annotation_comments_company_case_created_at_idx", @@ -26507,9 +27236,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_company_document_created_at_idx": { "name": "document_annotation_comments_company_document_created_at_idx", @@ -26534,9 +27263,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_issue_comment_idx": { "name": "document_annotation_comments_issue_comment_idx", @@ -26549,9 +27278,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_comments_body_search_idx": { "name": "document_annotation_comments_body_search_idx", @@ -26565,128 +27294,128 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} } }, "foreignKeys": { "document_annotation_comments_company_id_companies_id_fk": { "name": "document_annotation_comments_company_id_companies_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "document_annotation_comments_thread_id_document_annotation_threads_id_fk": { "name": "document_annotation_comments_thread_id_document_annotation_threads_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "document_annotation_threads", "columnsFrom": [ "thread_id" ], - "tableTo": "document_annotation_threads", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_comments_issue_id_issues_id_fk": { "name": "document_annotation_comments_issue_id_issues_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_comments_routine_id_routines_id_fk": { "name": "document_annotation_comments_routine_id_routines_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_comments_case_id_cases_id_fk": { "name": "document_annotation_comments_case_id_cases_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_comments_document_id_documents_id_fk": { "name": "document_annotation_comments_document_id_documents_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_comments_author_agent_id_agents_id_fk": { "name": "document_annotation_comments_author_agent_id_agents_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "agents", "columnsFrom": [ "author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk": { "name": "document_annotation_comments_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_comments_issue_comment_id_issue_comments_id_fk": { "name": "document_annotation_comments_issue_comment_id_issue_comments_id_fk", "tableFrom": "document_annotation_comments", + "tableTo": "issue_comments", "columnsFrom": [ "issue_comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -26911,9 +27640,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_threads_company_issue_status_idx": { "name": "document_annotation_threads_company_issue_status_idx", @@ -26938,9 +27667,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_threads_company_routine_status_idx": { "name": "document_annotation_threads_company_routine_status_idx", @@ -26965,9 +27694,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_threads_company_case_status_idx": { "name": "document_annotation_threads_company_case_status_idx", @@ -26992,9 +27721,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_threads_company_current_revision_open_idx": { "name": "document_annotation_threads_company_current_revision_open_idx", @@ -27025,9 +27754,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_annotation_threads_company_anchor_state_idx": { "name": "document_annotation_threads_company_anchor_state_idx", @@ -27046,128 +27775,128 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "document_annotation_threads_company_id_companies_id_fk": { "name": "document_annotation_threads_company_id_companies_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "document_annotation_threads_issue_id_issues_id_fk": { "name": "document_annotation_threads_issue_id_issues_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_threads_routine_id_routines_id_fk": { "name": "document_annotation_threads_routine_id_routines_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_threads_case_id_cases_id_fk": { "name": "document_annotation_threads_case_id_cases_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "cases", "columnsFrom": [ "case_id" ], - "tableTo": "cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_threads_document_id_documents_id_fk": { "name": "document_annotation_threads_document_id_documents_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_annotation_threads_original_revision_id_document_revisions_id_fk": { "name": "document_annotation_threads_original_revision_id_document_revisions_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "document_revisions", "columnsFrom": [ "original_revision_id" ], - "tableTo": "document_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_threads_current_revision_id_document_revisions_id_fk": { "name": "document_annotation_threads_current_revision_id_document_revisions_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "document_revisions", "columnsFrom": [ "current_revision_id" ], - "tableTo": "document_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_threads_created_by_agent_id_agents_id_fk": { "name": "document_annotation_threads_created_by_agent_id_agents_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_annotation_threads_resolved_by_agent_id_agents_id_fk": { "name": "document_annotation_threads_resolved_by_agent_id_agents_id_fk", "tableFrom": "document_annotation_threads", + "tableTo": "agents", "columnsFrom": [ "resolved_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -27255,9 +27984,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_memberships_company_user_document_uq": { "name": "document_memberships_company_user_document_uq", @@ -27282,37 +28011,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "document_memberships_company_id_companies_id_fk": { "name": "document_memberships_company_id_companies_id_fk", "tableFrom": "document_memberships", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_memberships_document_id_documents_id_fk": { "name": "document_memberships_document_id_documents_id_fk", "tableFrom": "document_memberships", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -27419,9 +28148,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "document_revisions_company_document_created_idx": { "name": "document_revisions_company_document_created_idx", @@ -27446,63 +28175,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "document_revisions_company_id_companies_id_fk": { "name": "document_revisions_company_id_companies_id_fk", "tableFrom": "document_revisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_revisions_document_id_documents_id_fk": { "name": "document_revisions_document_id_documents_id_fk", "tableFrom": "document_revisions", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "document_revisions_created_by_agent_id_agents_id_fk": { "name": "document_revisions_created_by_agent_id_agents_id_fk", "tableFrom": "document_revisions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "document_revisions_created_by_run_id_heartbeat_runs_id_fk": { "name": "document_revisions_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "document_revisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -27641,9 +28370,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "documents_company_created_idx": { "name": "documents_company_created_idx", @@ -27662,9 +28391,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "documents_title_search_idx": { "name": "documents_title_search_idx", @@ -27678,9 +28407,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "documents_latest_body_search_idx": { "name": "documents_latest_body_search_idx", @@ -27694,63 +28423,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} } }, "foreignKeys": { "documents_company_id_companies_id_fk": { "name": "documents_company_id_companies_id_fk", "tableFrom": "documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "documents_created_by_agent_id_agents_id_fk": { "name": "documents_created_by_agent_id_agents_id_fk", "tableFrom": "documents", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "documents_updated_by_agent_id_agents_id_fk": { "name": "documents_updated_by_agent_id_agents_id_fk", "tableFrom": "documents", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "documents_locked_by_agent_id_agents_id_fk": { "name": "documents_locked_by_agent_id_agents_id_fk", "tableFrom": "documents", + "tableTo": "agents", "columnsFrom": [ "locked_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -27890,10 +28619,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"dot_agent_bindings\".\"revoked_at\" IS NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "dot_bindings_active_grant_uq": { "name": "dot_bindings_active_grant_uq", @@ -27906,10 +28635,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"dot_agent_bindings\".\"revoked_at\" IS NULL AND \"dot_agent_bindings\".\"grant_id\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "dot_bindings_pairing_code_uq": { "name": "dot_bindings_pairing_code_uq", @@ -27922,50 +28651,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "dot_agent_bindings_company_id_companies_id_fk": { "name": "dot_agent_bindings_company_id_companies_id_fk", "tableFrom": "dot_agent_bindings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_agent_bindings_agent_id_agents_id_fk": { "name": "dot_agent_bindings_agent_id_agents_id_fk", "tableFrom": "dot_agent_bindings", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_agent_bindings_grant_id_mcp_oauth_grants_id_fk": { "name": "dot_agent_bindings_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "dot_agent_bindings", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28058,9 +28787,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "dot_mailbox_binding_cursor_idx": { "name": "dot_mailbox_binding_cursor_idx", @@ -28085,50 +28814,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "dot_mailbox_items_company_id_companies_id_fk": { "name": "dot_mailbox_items_company_id_companies_id_fk", "tableFrom": "dot_mailbox_items", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_mailbox_items_binding_id_dot_agent_bindings_id_fk": { "name": "dot_mailbox_items_binding_id_dot_agent_bindings_id_fk", "tableFrom": "dot_mailbox_items", + "tableTo": "dot_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "dot_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_mailbox_items_assignment_id_dot_runner_assignments_id_fk": { "name": "dot_mailbox_items_assignment_id_dot_runner_assignments_id_fk", "tableFrom": "dot_mailbox_items", + "tableTo": "dot_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "dot_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28278,9 +29007,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "dot_assignments_active_binding_uq": { "name": "dot_assignments_active_binding_uq", @@ -28293,10 +29022,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"dot_runner_assignments\".\"status\" IN ('offered', 'accepted')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "dot_assignments_company_idx": { "name": "dot_assignments_company_idx", @@ -28309,63 +29038,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "dot_runner_assignments_company_id_companies_id_fk": { "name": "dot_runner_assignments_company_id_companies_id_fk", "tableFrom": "dot_runner_assignments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_runner_assignments_binding_id_dot_agent_bindings_id_fk": { "name": "dot_runner_assignments_binding_id_dot_agent_bindings_id_fk", "tableFrom": "dot_runner_assignments", + "tableTo": "dot_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "dot_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_runner_assignments_run_id_heartbeat_runs_id_fk": { "name": "dot_runner_assignments_run_id_heartbeat_runs_id_fk", "tableFrom": "dot_runner_assignments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_runner_assignments_agent_id_agents_id_fk": { "name": "dot_runner_assignments_agent_id_agents_id_fk", "tableFrom": "dot_runner_assignments", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28479,37 +29208,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "dot_runner_operations_company_id_companies_id_fk": { "name": "dot_runner_operations_company_id_companies_id_fk", "tableFrom": "dot_runner_operations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "dot_runner_operations_assignment_id_dot_runner_assignments_id_fk": { "name": "dot_runner_operations_assignment_id_dot_runner_assignments_id_fk", "tableFrom": "dot_runner_operations", + "tableTo": "dot_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "dot_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28576,17 +29305,17 @@ "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "email_endpoints_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "email_endpoints", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28699,9 +29428,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "email_messages_conversation_idx": { "name": "email_messages_conversation_idx", @@ -28726,41 +29455,41 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "email_messages_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "email_messages", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk": { "name": "email_messages_company_id_conversation_id_chat_conversations_company_id_id_fk", "tableFrom": "email_messages", + "tableTo": "chat_conversations", "columnsFrom": [ "company_id", "conversation_id" ], - "tableTo": "chat_conversations", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -28846,42 +29575,42 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"email_sends\".\"outcome\" in ('queued', 'uncertain')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk": { "name": "email_sends_company_id_endpoint_id_chat_endpoints_company_id_id_fk", "tableFrom": "email_sends", + "tableTo": "chat_endpoints", "columnsFrom": [ "company_id", "endpoint_id" ], - "tableTo": "chat_endpoints", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "email_sends_company_id_publication_id_chat_publications_company_id_id_fk": { "name": "email_sends_company_id_publication_id_chat_publications_company_id_id_fk", "tableFrom": "email_sends", + "tableTo": "chat_publications", "columnsFrom": [ "company_id", "publication_id" ], - "tableTo": "chat_publications", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -29036,9 +29765,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_setup_sessions_environment_active_uq": { "name": "environment_custom_image_setup_sessions_environment_active_uq", @@ -29051,10 +29780,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"environment_custom_image_setup_sessions\".\"status\" IN ('starting', 'waiting_for_user', 'capturing')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "environment_custom_image_setup_sessions_template_idx": { "name": "environment_custom_image_setup_sessions_template_idx", @@ -29067,9 +29796,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_setup_sessions_promoted_template_idx": { "name": "environment_custom_image_setup_sessions_promoted_template_idx", @@ -29082,9 +29811,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_setup_sessions_expires_idx": { "name": "environment_custom_image_setup_sessions_expires_idx", @@ -29097,9 +29826,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_setup_sessions_provider_lease_idx": { "name": "environment_custom_image_setup_sessions_provider_lease_idx", @@ -29118,76 +29847,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "environment_custom_image_setup_sessions_environment_id_environments_id_fk": { "name": "environment_custom_image_setup_sessions_environment_id_environments_id_fk", "tableFrom": "environment_custom_image_setup_sessions", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk": { "name": "environment_custom_image_setup_sessions_template_id_environment_custom_image_templates_id_fk", "tableFrom": "environment_custom_image_setup_sessions", + "tableTo": "environment_custom_image_templates", "columnsFrom": [ "template_id" ], - "tableTo": "environment_custom_image_templates", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk": { "name": "environment_custom_image_setup_sessions_promoted_template_id_environment_custom_image_templates_id_fk", "tableFrom": "environment_custom_image_setup_sessions", + "tableTo": "environment_custom_image_templates", "columnsFrom": [ "promoted_template_id" ], - "tableTo": "environment_custom_image_templates", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk": { "name": "environment_custom_image_setup_sessions_environment_lease_id_environment_leases_id_fk", "tableFrom": "environment_custom_image_setup_sessions", + "tableTo": "environment_leases", "columnsFrom": [ "environment_lease_id" ], - "tableTo": "environment_leases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk": { "name": "environment_custom_image_setup_sessions_started_by_agent_id_agents_id_fk", "tableFrom": "environment_custom_image_setup_sessions", + "tableTo": "agents", "columnsFrom": [ "started_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -29320,9 +30049,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_templates_environment_provider_status_idx": { "name": "environment_custom_image_templates_environment_provider_status_idx", @@ -29347,9 +30076,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_templates_environment_active_uq": { "name": "environment_custom_image_templates_environment_active_uq", @@ -29362,10 +30091,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"environment_custom_image_templates\".\"status\" = 'active'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "environment_custom_image_templates_superseded_by_idx": { "name": "environment_custom_image_templates_superseded_by_idx", @@ -29378,9 +30107,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_custom_image_templates_last_used_idx": { "name": "environment_custom_image_templates_last_used_idx", @@ -29393,50 +30122,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "environment_custom_image_templates_environment_id_environments_id_fk": { "name": "environment_custom_image_templates_environment_id_environments_id_fk", "tableFrom": "environment_custom_image_templates", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "environment_custom_image_templates_created_by_agent_id_agents_id_fk": { "name": "environment_custom_image_templates_created_by_agent_id_agents_id_fk", "tableFrom": "environment_custom_image_templates", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk": { "name": "environment_custom_image_templates_superseded_by_template_id_environment_custom_image_templates_id_fk", "tableFrom": "environment_custom_image_templates", + "tableTo": "environment_custom_image_templates", "columnsFrom": [ "superseded_by_template_id" ], - "tableTo": "environment_custom_image_templates", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -29583,10 +30312,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"environment_leases\".\"lease_policy\" = 'retain_on_failure'\n and \"environment_leases\".\"heartbeat_run_id\" is not null\n and not (coalesce(\"environment_leases\".\"metadata\", '{}'::jsonb) ? 'systemRecoveryAdoption')", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "environment_leases_company_environment_status_idx": { "name": "environment_leases_company_environment_status_idx", @@ -29611,9 +30340,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_company_execution_workspace_idx": { "name": "environment_leases_company_execution_workspace_idx", @@ -29632,9 +30361,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_company_issue_idx": { "name": "environment_leases_company_issue_idx", @@ -29653,9 +30382,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_heartbeat_run_idx": { "name": "environment_leases_heartbeat_run_idx", @@ -29668,9 +30397,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_company_last_used_idx": { "name": "environment_leases_company_last_used_idx", @@ -29689,9 +30418,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_provider_lease_idx": { "name": "environment_leases_provider_lease_idx", @@ -29704,92 +30433,92 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environment_leases_native_backup_scope_idx": { "name": "environment_leases_native_backup_scope_idx", "columns": [ { "expression": "(\"metadata\"->'nativeHarnessBackup'->>'sessionScopeSha256')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "(\"environment_leases\".\"metadata\"->'nativeHarnessBackup'->>'sessionScopeSha256') is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "environment_leases_company_id_companies_id_fk": { "name": "environment_leases_company_id_companies_id_fk", "tableFrom": "environment_leases", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "environment_leases_environment_id_environments_id_fk": { "name": "environment_leases_environment_id_environments_id_fk", "tableFrom": "environment_leases", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_leases_execution_workspace_id_execution_workspaces_id_fk": { "name": "environment_leases_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "environment_leases", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_leases_issue_id_issues_id_fk": { "name": "environment_leases_issue_id_issues_id_fk", "tableFrom": "environment_leases", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "environment_leases_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "environment_leases", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -29882,9 +30611,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "environments_local_driver_idx": { "name": "environments_local_driver_idx", @@ -29897,10 +30626,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"environments\".\"driver\" = 'local'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "environments_managed_sandbox_idx": { "name": "environments_managed_sandbox_idx", @@ -29913,26 +30642,26 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"environments\".\"driver\" = 'sandbox' AND (\"environments\".\"metadata\" ->> 'managedByPaperclip')::boolean = true", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "environments_managed_plugin_environment_idx": { "name": "environments_managed_plugin_environment_idx", "columns": [ { "expression": "(\"metadata\" ->> 'managedPluginEnvironment')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "jsonb_typeof(\"environments\".\"metadata\" -> 'managedPluginEnvironment') = 'string'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "environments_name_idx": { "name": "environments_name_idx", @@ -29945,9 +30674,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -29998,41 +30727,41 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_admission_project_charges_company_admission_fk": { "name": "execution_admission_project_charges_company_admission_fk", "tableFrom": "execution_admission_project_charges", + "tableTo": "execution_admissions", "columnsFrom": [ "company_id", "admission_id" ], - "tableTo": "execution_admissions", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_admission_project_charges_company_project_fk": { "name": "execution_admission_project_charges_company_project_fk", "tableFrom": "execution_admission_project_charges", + "tableTo": "projects", "columnsFrom": [ "company_id", "project_id" ], - "tableTo": "projects", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -30133,9 +30862,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_admissions_run_attempt_uq": { "name": "execution_admissions_run_attempt_uq", @@ -30154,9 +30883,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_admissions_live_run_uq": { "name": "execution_admissions_live_run_uq", @@ -30169,38 +30898,38 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"execution_admissions\".\"settled_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "execution_admissions_company_id_companies_id_fk": { "name": "execution_admissions_company_id_companies_id_fk", "tableFrom": "execution_admissions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "execution_admissions_run_id_heartbeat_runs_id_fk": { "name": "execution_admissions_run_id_heartbeat_runs_id_fk", "tableFrom": "execution_admissions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -30264,17 +30993,17 @@ "project_task_execution_policies_company_project_fk": { "name": "project_task_execution_policies_company_project_fk", "tableFrom": "project_task_execution_policies", + "tableTo": "projects", "columnsFrom": [ "company_id", "project_id" ], - "tableTo": "projects", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -30419,9 +31148,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_repositories_path_idx": { "name": "execution_workspace_repositories_path_idx", @@ -30440,9 +31169,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_repositories_request_idx": { "name": "execution_workspace_repositories_request_idx", @@ -30461,9 +31190,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_repositories_company_workspace_idx": { "name": "execution_workspace_repositories_company_workspace_idx", @@ -30482,50 +31211,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_workspace_repositories_company_id_companies_id_fk": { "name": "execution_workspace_repositories_company_id_companies_id_fk", "tableFrom": "execution_workspace_repositories", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_workspace_repositories_execution_workspace_id_execution_workspaces_id_fk": { "name": "execution_workspace_repositories_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "execution_workspace_repositories", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_workspace_repositories_requested_by_issue_id_issues_id_fk": { "name": "execution_workspace_repositories_requested_by_issue_id_issues_id_fk", "tableFrom": "execution_workspace_repositories", + "tableTo": "issues", "columnsFrom": [ "requested_by_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -30638,24 +31367,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_workspace_repository_access_company_id_companies_id_fk": { "name": "execution_workspace_repository_access_company_id_companies_id_fk", "tableFrom": "execution_workspace_repository_access", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -30732,24 +31461,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_workspace_repository_roots_company_id_companies_id_fk": { "name": "execution_workspace_repository_roots_company_id_companies_id_fk", "tableFrom": "execution_workspace_repository_roots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -30889,9 +31618,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_restore_points_live_status_uniq": { "name": "execution_workspace_restore_points_live_status_uniq", @@ -30916,10 +31645,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"execution_workspace_restore_points\".\"status\" in ('pending', 'active', 'expiring')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "execution_workspace_restore_points_status_delete_after_idx": { "name": "execution_workspace_restore_points_status_delete_after_idx", @@ -30938,9 +31667,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_restore_points_company_idx": { "name": "execution_workspace_restore_points_company_idx", @@ -30953,9 +31682,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_restore_points_source_issue_idx": { "name": "execution_workspace_restore_points_source_issue_idx", @@ -30974,9 +31703,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_restore_points_active_source_idx": { "name": "execution_workspace_restore_points_active_source_idx", @@ -30989,10 +31718,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"execution_workspace_restore_points\".\"status\" = 'active'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": {}, @@ -31114,9 +31843,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_runtime_leases_company_owner_idx": { "name": "execution_workspace_runtime_leases_company_owner_idx", @@ -31135,9 +31864,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_runtime_leases_expires_at_idx": { "name": "execution_workspace_runtime_leases_expires_at_idx", @@ -31150,86 +31879,86 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_workspace_runtime_leases_company_id_companies_id_fk": { "name": "execution_workspace_runtime_leases_company_id_companies_id_fk", "tableFrom": "execution_workspace_runtime_leases", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk": { "name": "execution_workspace_runtime_leases_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "execution_workspace_runtime_leases", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk": { "name": "execution_workspace_runtime_leases_owner_issue_id_issues_id_fk", "tableFrom": "execution_workspace_runtime_leases", + "tableTo": "issues", "columnsFrom": [ "owner_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk": { "name": "execution_workspace_runtime_leases_owner_run_id_heartbeat_runs_id_fk", "tableFrom": "execution_workspace_runtime_leases", + "tableTo": "heartbeat_runs", "columnsFrom": [ "owner_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk": { "name": "execution_workspace_runtime_leases_owner_agent_id_agents_id_fk", "tableFrom": "execution_workspace_runtime_leases", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "execution_workspace_runtime_leases_execution_workspace_id_unique": { "name": "execution_workspace_runtime_leases_execution_workspace_id_unique", + "nullsNotDistinct": false, "columns": [ "execution_workspace_id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -31390,9 +32119,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_snapshots_generation_uniq": { "name": "execution_workspace_snapshots_generation_uniq", @@ -31417,9 +32146,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_snapshots_workspace_idx": { "name": "execution_workspace_snapshots_workspace_idx", @@ -31438,9 +32167,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_snapshots_cleanup_idx": { "name": "execution_workspace_snapshots_cleanup_idx", @@ -31459,25 +32188,25 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspace_snapshots_imported_children_idx": { "name": "execution_workspace_snapshots_imported_children_idx", "columns": [ { "expression": "(\"metadata\"->'importedWorkspaceChildren') jsonb_path_ops", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "gin", "where": "\"execution_workspace_snapshots\".\"metadata\" ? 'importedWorkspaceChildren'", - "concurrently": false + "concurrently": false, + "method": "gin", + "with": {} } }, "foreignKeys": {}, @@ -31667,9 +32396,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspaces_company_project_workspace_status_idx": { "name": "execution_workspaces_company_project_workspace_status_idx", @@ -31694,9 +32423,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspaces_company_source_issue_idx": { "name": "execution_workspaces_company_source_issue_idx", @@ -31715,9 +32444,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspaces_company_last_used_idx": { "name": "execution_workspaces_company_last_used_idx", @@ -31736,9 +32465,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "execution_workspaces_company_branch_idx": { "name": "execution_workspaces_company_branch_idx", @@ -31757,76 +32486,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "execution_workspaces_company_id_companies_id_fk": { "name": "execution_workspaces_company_id_companies_id_fk", "tableFrom": "execution_workspaces", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "execution_workspaces_project_id_projects_id_fk": { "name": "execution_workspaces_project_id_projects_id_fk", "tableFrom": "execution_workspaces", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "execution_workspaces_project_workspace_id_project_workspaces_id_fk": { "name": "execution_workspaces_project_workspace_id_project_workspaces_id_fk", "tableFrom": "execution_workspaces", + "tableTo": "project_workspaces", "columnsFrom": [ "project_workspace_id" ], - "tableTo": "project_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "execution_workspaces_source_issue_id_issues_id_fk": { "name": "execution_workspaces_source_issue_id_issues_id_fk", "tableFrom": "execution_workspaces", + "tableTo": "issues", "columnsFrom": [ "source_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk": { "name": "execution_workspaces_derived_from_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "execution_workspaces", + "tableTo": "execution_workspaces", "columnsFrom": [ "derived_from_execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -31976,9 +32705,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_object_mentions_company_object_idx": { "name": "external_object_mentions_company_object_idx", @@ -31997,9 +32726,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_object_mentions_company_provider_idx": { "name": "external_object_mentions_company_provider_idx", @@ -32024,9 +32753,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_object_mentions_company_source_record_uq": { "name": "external_object_mentions_company_source_record_uq", @@ -32075,10 +32804,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"external_object_mentions\".\"source_record_id\" is not null and \"external_object_mentions\".\"canonical_identity_hash\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "external_object_mentions_company_source_null_record_uq": { "name": "external_object_mentions_company_source_null_record_uq", @@ -32121,64 +32850,64 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"external_object_mentions\".\"source_record_id\" is null and \"external_object_mentions\".\"canonical_identity_hash\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "external_object_mentions_company_id_companies_id_fk": { "name": "external_object_mentions_company_id_companies_id_fk", "tableFrom": "external_object_mentions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "external_object_mentions_source_issue_id_issues_id_fk": { "name": "external_object_mentions_source_issue_id_issues_id_fk", "tableFrom": "external_object_mentions", + "tableTo": "issues", "columnsFrom": [ "source_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "external_object_mentions_object_id_external_objects_id_fk": { "name": "external_object_mentions_object_id_external_objects_id_fk", "tableFrom": "external_object_mentions", + "tableTo": "external_objects", "columnsFrom": [ "object_id" ], - "tableTo": "external_objects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "external_object_mentions_created_by_plugin_id_plugins_id_fk": { "name": "external_object_mentions_created_by_plugin_id_plugins_id_fk", "tableFrom": "external_object_mentions", + "tableTo": "plugins", "columnsFrom": [ "created_by_plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -32410,9 +33139,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_objects_company_provider_status_idx": { "name": "external_objects_company_provider_status_idx", @@ -32437,9 +33166,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_objects_company_refresh_idx": { "name": "external_objects_company_refresh_idx", @@ -32458,9 +33187,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_objects_company_external_id_uq": { "name": "external_objects_company_external_id_uq", @@ -32491,9 +33220,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_objects_company_identity_uq": { "name": "external_objects_company_identity_uq", @@ -32524,37 +33253,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "external_objects_company_id_companies_id_fk": { "name": "external_objects_company_id_companies_id_fk", "tableFrom": "external_objects", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "external_objects_plugin_id_plugins_id_fk": { "name": "external_objects_plugin_id_plugins_id_fk", "tableFrom": "external_objects", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -32624,15 +33353,15 @@ "company_fast_responses_company_id_companies_id_fk": { "name": "company_fast_responses_company_id_companies_id_fk", "tableFrom": "company_fast_responses", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -32854,9 +33583,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "fast_response_requests_delivery_idx": { "name": "fast_response_requests_delivery_idx", @@ -32881,10 +33610,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"fast_response_requests\".\"delivery_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "fast_response_requests_history_idx": { "name": "fast_response_requests_history_idx", @@ -32903,9 +33632,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "fast_response_requests_work_idx": { "name": "fast_response_requests_work_idx", @@ -32918,38 +33647,38 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"fast_response_requests\".\"status\" in ('pending', 'running')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "fast_response_requests_company_id_companies_id_fk": { "name": "fast_response_requests_company_id_companies_id_fk", "tableFrom": "fast_response_requests", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "fast_response_requests_cost_event_id_cost_events_id_fk": { "name": "fast_response_requests_cost_event_id_cost_events_id_fk", "tableFrom": "fast_response_requests", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -33144,9 +33873,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_exports_company_created_idx": { "name": "feedback_exports_company_created_idx", @@ -33165,9 +33894,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_exports_company_status_idx": { "name": "feedback_exports_company_status_idx", @@ -33192,9 +33921,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_exports_company_issue_idx": { "name": "feedback_exports_company_issue_idx", @@ -33219,9 +33948,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_exports_company_project_idx": { "name": "feedback_exports_company_project_idx", @@ -33246,9 +33975,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_exports_company_author_idx": { "name": "feedback_exports_company_author_idx", @@ -33273,63 +34002,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "feedback_exports_company_id_companies_id_fk": { "name": "feedback_exports_company_id_companies_id_fk", "tableFrom": "feedback_exports", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "feedback_exports_feedback_vote_id_feedback_votes_id_fk": { "name": "feedback_exports_feedback_vote_id_feedback_votes_id_fk", "tableFrom": "feedback_exports", + "tableTo": "feedback_votes", "columnsFrom": [ "feedback_vote_id" ], - "tableTo": "feedback_votes", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "feedback_exports_issue_id_issues_id_fk": { "name": "feedback_exports_issue_id_issues_id_fk", "tableFrom": "feedback_exports", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "feedback_exports_project_id_projects_id_fk": { "name": "feedback_exports_project_id_projects_id_fk", "tableFrom": "feedback_exports", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -33449,9 +34178,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_votes_issue_target_idx": { "name": "feedback_votes_issue_target_idx", @@ -33476,9 +34205,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_votes_author_idx": { "name": "feedback_votes_author_idx", @@ -33497,9 +34226,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "feedback_votes_company_target_author_idx": { "name": "feedback_votes_company_target_author_idx", @@ -33530,37 +34259,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "feedback_votes_company_id_companies_id_fk": { "name": "feedback_votes_company_id_companies_id_fk", "tableFrom": "feedback_votes", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "feedback_votes_issue_id_issues_id_fk": { "name": "feedback_votes_issue_id_issues_id_fk", "tableFrom": "feedback_votes", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -33771,9 +34500,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_occurred_idx": { "name": "finance_events_company_occurred_idx", @@ -33792,9 +34521,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_biller_occurred_idx": { "name": "finance_events_company_biller_occurred_idx", @@ -33819,9 +34548,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_kind_occurred_idx": { "name": "finance_events_company_kind_occurred_idx", @@ -33846,9 +34575,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_direction_occurred_idx": { "name": "finance_events_company_direction_occurred_idx", @@ -33873,9 +34602,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_heartbeat_run_idx": { "name": "finance_events_company_heartbeat_run_idx", @@ -33894,9 +34623,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "finance_events_company_cost_event_idx": { "name": "finance_events_company_cost_event_idx", @@ -33915,102 +34644,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "finance_events_company_id_companies_id_fk": { "name": "finance_events_company_id_companies_id_fk", "tableFrom": "finance_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "finance_events_agent_id_agents_id_fk": { "name": "finance_events_agent_id_agents_id_fk", "tableFrom": "finance_events", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "finance_events_issue_id_issues_id_fk": { "name": "finance_events_issue_id_issues_id_fk", "tableFrom": "finance_events", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "finance_events_project_id_projects_id_fk": { "name": "finance_events_project_id_projects_id_fk", "tableFrom": "finance_events", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "finance_events_goal_id_goals_id_fk": { "name": "finance_events_goal_id_goals_id_fk", "tableFrom": "finance_events", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "finance_events_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "finance_events_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "finance_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "finance_events_cost_event_id_cost_events_id_fk": { "name": "finance_events_cost_event_id_cost_events_id_fk", "tableFrom": "finance_events", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -34124,9 +34853,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "folders_company_kind_root_slug_uq": { "name": "folders_company_kind_root_slug_uq", @@ -34151,10 +34880,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"folders\".\"parent_id\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "folders_company_kind_parent_slug_uq": { "name": "folders_company_kind_parent_slug_uq", @@ -34185,10 +34914,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"folders\".\"parent_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "folders_company_kind_system_key_uq": { "name": "folders_company_kind_system_key_uq", @@ -34213,10 +34942,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"folders\".\"system_key\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "folders_company_kind_parent_position_idx": { "name": "folders_company_kind_parent_position_idx", @@ -34253,37 +34982,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "folders_company_id_companies_id_fk": { "name": "folders_company_id_companies_id_fk", "tableFrom": "folders", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "folders_parent_id_folders_id_fk": { "name": "folders_parent_id_folders_id_fk", "tableFrom": "folders", + "tableTo": "folders", "columnsFrom": [ "parent_id" ], - "tableTo": "folders", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -34374,50 +35103,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "goals_company_id_companies_id_fk": { "name": "goals_company_id_companies_id_fk", "tableFrom": "goals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "goals_parent_id_goals_id_fk": { "name": "goals_parent_id_goals_id_fk", "tableFrom": "goals", + "tableTo": "goals", "columnsFrom": [ "parent_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "goals_owner_agent_id_agents_id_fk": { "name": "goals_owner_agent_id_agents_id_fk", "tableFrom": "goals", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -34550,9 +35279,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "google_pending_revocations_token_idx": { "name": "google_pending_revocations_token_idx", @@ -34571,9 +35300,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -34736,9 +35465,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "grok_dispatch_prepared_idx": { "name": "grok_dispatch_prepared_idx", @@ -34757,10 +35486,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"grok_bot_dispatches\".\"status\" = 'prepared'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "grok_dispatch_company_status_idx": { "name": "grok_dispatch_company_status_idx", @@ -34779,9 +35508,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "grok_dispatch_assignment_kind_idx": { "name": "grok_dispatch_assignment_kind_idx", @@ -34800,76 +35529,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "grok_bot_dispatches_company_id_companies_id_fk": { "name": "grok_bot_dispatches_company_id_companies_id_fk", "tableFrom": "grok_bot_dispatches", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_dispatches_routine_id_grok_bot_routines_id_fk": { "name": "grok_bot_dispatches_routine_id_grok_bot_routines_id_fk", "tableFrom": "grok_bot_dispatches", + "tableTo": "grok_bot_routines", "columnsFrom": [ "routine_id" ], - "tableTo": "grok_bot_routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_dispatches_binding_id_dot_agent_bindings_id_fk": { "name": "grok_bot_dispatches_binding_id_dot_agent_bindings_id_fk", "tableFrom": "grok_bot_dispatches", + "tableTo": "dot_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "dot_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_dispatches_grant_id_mcp_oauth_grants_id_fk": { "name": "grok_bot_dispatches_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "grok_bot_dispatches", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_dispatches_assignment_id_dot_runner_assignments_id_fk": { "name": "grok_bot_dispatches_assignment_id_dot_runner_assignments_id_fk", "tableFrom": "grok_bot_dispatches", + "tableTo": "dot_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "dot_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -34995,9 +35724,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "grok_routines_company_agent_idx": { "name": "grok_routines_company_agent_idx", @@ -35016,76 +35745,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "grok_bot_routines_company_id_companies_id_fk": { "name": "grok_bot_routines_company_id_companies_id_fk", "tableFrom": "grok_bot_routines", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_routines_agent_id_agents_id_fk": { "name": "grok_bot_routines_agent_id_agents_id_fk", "tableFrom": "grok_bot_routines", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_routines_binding_id_dot_agent_bindings_id_fk": { "name": "grok_bot_routines_binding_id_dot_agent_bindings_id_fk", "tableFrom": "grok_bot_routines", + "tableTo": "dot_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "dot_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "grok_bot_routines_secret_id_company_secrets_id_fk": { "name": "grok_bot_routines_secret_id_company_secrets_id_fk", "tableFrom": "grok_bot_routines", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "grok_bot_routines_verified_grant_id_mcp_oauth_grants_id_fk": { "name": "grok_bot_routines_verified_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "grok_bot_routines", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "verified_grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -35094,6 +35823,546 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.board_events": { + "name": "board_events", + "schema": "", + "columns": { + "seq": { + "name": "seq", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "channel_path": { + "name": "channel_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_profile": { + "name": "actor_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "board_events_company_seq_idx": { + "name": "board_events_company_seq_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "board_events_company_channel_seq_idx": { + "name": "board_events_company_channel_seq_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "board_events_company_issue_seq_idx": { + "name": "board_events_company_issue_seq_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "board_events_company_id_companies_id_fk": { + "name": "board_events_company_id_companies_id_fk", + "tableFrom": "board_events", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "board_events_channel_id_channels_id_fk": { + "name": "board_events_channel_id_channels_id_fk", + "tableFrom": "board_events", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "board_events_issue_id_issues_id_fk": { + "name": "board_events_issue_id_issues_id_fk", + "tableFrom": "board_events", + "tableTo": "issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.issue_batch_idempotency_keys": { + "name": "issue_batch_idempotency_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_payload": { + "name": "response_payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "issue_batch_idempotency_keys_company_key_uq": { + "name": "issue_batch_idempotency_keys_company_key_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "issue_batch_idempotency_keys_company_id_companies_id_fk": { + "name": "issue_batch_idempotency_keys_company_id_companies_id_fk", + "tableFrom": "issue_batch_idempotency_keys", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scheduled_board_posts": { + "name": "scheduled_board_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "post_only": { + "name": "post_only", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "kv_labels": { + "name": "kv_labels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "schema_blocks": { + "name": "schema_blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "interval_ms": { + "name": "interval_ms", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "until_at": { + "name": "until_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "next_run_at": { + "name": "next_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "author_user_id": { + "name": "author_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_agent_id": { + "name": "author_agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_profile": { + "name": "author_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "scheduled_board_posts_due_idx": { + "name": "scheduled_board_posts_due_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"scheduled_board_posts\".\"status\" = 'scheduled'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "scheduled_board_posts_company_idx": { + "name": "scheduled_board_posts_company_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scheduled_board_posts_company_id_companies_id_fk": { + "name": "scheduled_board_posts_company_id_companies_id_fk", + "tableFrom": "scheduled_board_posts", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scheduled_board_posts_channel_id_channels_id_fk": { + "name": "scheduled_board_posts_channel_id_channels_id_fk", + "tableFrom": "scheduled_board_posts", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scheduled_board_posts_issue_id_issues_id_fk": { + "name": "scheduled_board_posts_issue_id_issues_id_fk", + "tableFrom": "scheduled_board_posts", + "tableTo": "issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scheduled_board_posts_author_agent_id_agents_id_fk": { + "name": "scheduled_board_posts_author_agent_id_agents_id_fk", + "tableFrom": "scheduled_board_posts", + "tableTo": "agents", + "columnsFrom": [ + "author_agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "scheduled_board_posts_status_check": { + "name": "scheduled_board_posts_status_check", + "value": "\"scheduled_board_posts\".\"status\" in ('scheduled', 'cancelled', 'completed')" + } + }, + "isRLSEnabled": false + }, "public.heartbeat_run_events": { "name": "heartbeat_run_events", "schema": "", @@ -35220,9 +36489,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_run_events_run_source_event_uq": { "name": "heartbeat_run_events_run_source_event_uq", @@ -35241,10 +36510,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"heartbeat_run_events\".\"source_event_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_run_events_run_source_seq_uq": { "name": "heartbeat_run_events_run_source_seq_uq", @@ -35269,10 +36538,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"heartbeat_run_events\".\"source_instance_id\" is not null and \"heartbeat_run_events\".\"source_seq\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_run_events_company_run_idx": { "name": "heartbeat_run_events_company_run_idx", @@ -35291,9 +36560,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_run_events_company_created_idx": { "name": "heartbeat_run_events_company_created_idx", @@ -35312,9 +36581,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_run_events_usage_item_run_idx": { "name": "heartbeat_run_events_usage_item_run_idx", @@ -35333,10 +36602,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_run_events\".\"event_type\" = 'item.completed' and (\"heartbeat_run_events\".\"payload\" -> 'prpEvent' -> 'payload' ->> 'kind') = 'usage'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_run_events_compaction_session_idx": { "name": "heartbeat_run_events_compaction_session_idx", @@ -35349,16 +36618,16 @@ }, { "expression": "(\"payload\" -> 'prpEvent' ->> 'normalizedSessionId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_run_events\".\"event_type\" = 'context.compacted'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_run_events_retry_exhausted_idx": { "name": "heartbeat_run_events_retry_exhausted_idx", @@ -35383,51 +36652,51 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_run_events\".\"event_type\" = 'lifecycle' and \"heartbeat_run_events\".\"message\" like 'Bounded retry exhausted%'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "heartbeat_run_events_company_id_companies_id_fk": { "name": "heartbeat_run_events_company_id_companies_id_fk", "tableFrom": "heartbeat_run_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_run_events_run_id_heartbeat_runs_id_fk": { "name": "heartbeat_run_events_run_id_heartbeat_runs_id_fk", "tableFrom": "heartbeat_run_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_run_events_agent_id_agents_id_fk": { "name": "heartbeat_run_events_agent_id_agents_id_fk", "tableFrom": "heartbeat_run_events", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -35533,9 +36802,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_run_watchdog_decisions_company_run_snooze_idx": { "name": "heartbeat_run_watchdog_decisions_company_run_snooze_idx", @@ -35560,76 +36829,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "heartbeat_run_watchdog_decisions_company_id_companies_id_fk": { "name": "heartbeat_run_watchdog_decisions_company_id_companies_id_fk", "tableFrom": "heartbeat_run_watchdog_decisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk": { "name": "heartbeat_run_watchdog_decisions_run_id_heartbeat_runs_id_fk", "tableFrom": "heartbeat_run_watchdog_decisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk": { "name": "heartbeat_run_watchdog_decisions_evaluation_issue_id_issues_id_fk", "tableFrom": "heartbeat_run_watchdog_decisions", + "tableTo": "issues", "columnsFrom": [ "evaluation_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk": { "name": "heartbeat_run_watchdog_decisions_created_by_agent_id_agents_id_fk", "tableFrom": "heartbeat_run_watchdog_decisions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk": { "name": "heartbeat_run_watchdog_decisions_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "heartbeat_run_watchdog_decisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -36175,10 +37444,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"runtime_mode\" = 'native' AND \"heartbeat_runs\".\"status\" in ('succeeded', 'failed', 'timed_out') AND \"heartbeat_runs\".\"finished_at\" is not null AND jsonb_typeof(\"heartbeat_runs\".\"result_json\" #> '{presentationDecision,commentId}') is distinct from 'string'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_cancelled_workspace_preservation_idx": { "name": "heartbeat_runs_cancelled_workspace_preservation_idx", @@ -36197,10 +37466,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"runtime_mode\" = 'native' AND \"heartbeat_runs\".\"status\" = 'cancelled'\n AND \"heartbeat_runs\".\"runner_profile_json\"->'nativeWorkspaceSync'->>'state' = 'prepared'\n AND \"heartbeat_runs\".\"result_json\"->'nativeCancellation'->>'dispatchState' = 'acknowledged'\n AND (\"heartbeat_runs\".\"result_json\"->'workspaceRestoreRecovery'->>'schema' = 'paperclip.workspace-restore-recovery.v1'\n AND \"heartbeat_runs\".\"result_json\"->>'workspaceRestoreFailure' IN ('restore_permission_denied', 'restore_lock_timeout', 'restore_unsafe_archive', 'restore_invalid_metadata', 'restore_failed')) IS NOT TRUE", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_retained_recovery_adoption_idx": { "name": "heartbeat_runs_retained_recovery_adoption_idx", @@ -36213,10 +37482,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"result_json\"->'workspaceRestoreRecovery'->>'schema' = 'paperclip.workspace-restore-recovery.v1'\n and not (coalesce(\"heartbeat_runs\".\"result_json\", '{}'::jsonb) ? 'systemRecoveryAdoption')\n and \"heartbeat_runs\".\"status\" in ('failed', 'interrupted', 'timed_out', 'cancelled', 'succeeded')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_scheduled_retry_cancellation_idx": { "name": "heartbeat_runs_scheduled_retry_cancellation_idx", @@ -36229,10 +37498,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" = 'scheduled_retry' and jsonb_typeof(\"heartbeat_runs\".\"result_json\"->'startupCancellation') = 'object'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_pending_budget_cancellation_idx": { "name": "heartbeat_runs_pending_budget_cancellation_idx", @@ -36245,10 +37514,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "jsonb_typeof(\"heartbeat_runs\".\"result_json\"->'startupCancellation'->'budgetEnforcement') = 'object'\n and \"heartbeat_runs\".\"result_json\"->'startupCancellation'->'budgetEnforcement'->>'deliveredAt' is null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_tree_hold_suppression_idx": { "name": "heartbeat_runs_tree_hold_suppression_idx", @@ -36261,16 +37530,16 @@ }, { "expression": "(\"result_json\"->'treeHoldSuppression'->>'holdId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" = 'cancelled' and \"heartbeat_runs\".\"result_json\" ? 'treeHoldSuppression'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_legacy_controller_lease_idx": { "name": "heartbeat_runs_legacy_controller_lease_idx", @@ -36283,10 +37552,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"runtime_mode\" = 'legacy' AND \"heartbeat_runs\".\"status\" = 'running' AND \"heartbeat_runs\".\"controller_boot_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_company_wake_comment_idx": { "name": "heartbeat_runs_company_wake_comment_idx", @@ -36299,15 +37568,15 @@ }, { "expression": "(\"context_snapshot\"->>'wakeCommentId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, + "concurrently": true, "method": "btree", - "concurrently": true + "with": {} }, "heartbeat_runs_queued_created_idx": { "name": "heartbeat_runs_queued_created_idx", @@ -36332,10 +37601,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" = 'queued'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_cost_accounting_pending_idx": { "name": "heartbeat_runs_cost_accounting_pending_idx", @@ -36354,10 +37623,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"cost_accounting_pending\" = true", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_cost_data_quality_idx": { "name": "heartbeat_runs_cost_data_quality_idx", @@ -36370,8 +37639,8 @@ }, { "expression": "coalesce(\"finished_at\", \"created_at\") desc", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36382,10 +37651,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"cost_accounting_pending\" = true and \"heartbeat_runs\".\"status\" in ('succeeded','failed','timed_out','cancelled','interrupted')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_execution_status_delivery_idx": { "name": "heartbeat_runs_execution_status_delivery_idx", @@ -36398,10 +37667,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"execution_status_delivery_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_execution_control_deadline_idx": { "name": "heartbeat_runs_execution_control_deadline_idx", @@ -36414,10 +37683,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"execution_control_deadline_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_native_replacement_predecessor_uq": { "name": "heartbeat_runs_native_replacement_predecessor_uq", @@ -36436,10 +37705,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"scheduled_retry_reason\" = 'native_safe_replacement'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "heartbeat_runs_company_agent_started_idx": { "name": "heartbeat_runs_company_agent_started_idx", @@ -36464,9 +37733,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_native_workspace_idx": { "name": "heartbeat_runs_company_native_workspace_idx", @@ -36479,15 +37748,15 @@ }, { "expression": "(\"runner_profile_json\"->'nativeWorkspaceSync'->>'workspaceId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, + "concurrently": true, "method": "btree", - "concurrently": true + "with": {} }, "heartbeat_runs_company_native_session_idx": { "name": "heartbeat_runs_company_native_session_idx", @@ -36506,10 +37775,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"native_session_id\" is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_company_issue_created_idx": { "name": "heartbeat_runs_company_issue_created_idx", @@ -36534,9 +37803,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_responsible_user_idx": { "name": "heartbeat_runs_company_responsible_user_idx", @@ -36561,9 +37830,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_liveness_idx": { "name": "heartbeat_runs_company_liveness_idx", @@ -36588,9 +37857,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_status_last_output_idx": { "name": "heartbeat_runs_company_status_last_output_idx", @@ -36615,9 +37884,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_status_process_started_idx": { "name": "heartbeat_runs_company_status_process_started_idx", @@ -36642,9 +37911,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_finished_idx": { "name": "heartbeat_runs_company_finished_idx", @@ -36663,10 +37932,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"finished_at\" is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_settled_process_identity_idx": { "name": "heartbeat_runs_settled_process_identity_idx", @@ -36691,10 +37960,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"runtime_mode\" = 'native' and \"heartbeat_runs\".\"status\" in ('failed', 'cancelled', 'timed_out', 'interrupted')\n and \"heartbeat_runs\".\"finished_at\" is not null\n and (\"heartbeat_runs\".\"process_pid\" is not null or \"heartbeat_runs\".\"process_group_id\" is not null or \"heartbeat_runs\".\"process_started_at\" is not null)", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_pending_api_stop_idx": { "name": "heartbeat_runs_pending_api_stop_idx", @@ -36713,10 +37982,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" = 'cancelled' and \"heartbeat_runs\".\"driver_kind\" = 'cursor_cloud_api'\n and (\"heartbeat_runs\".\"result_json\"->'executionCancellation'->>'state') = 'requested'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_company_created_at_desc_idx": { "name": "heartbeat_runs_company_created_at_desc_idx", @@ -36735,9 +38004,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_attention_resumed_idx": { "name": "heartbeat_runs_attention_resumed_idx", @@ -36750,8 +38019,8 @@ }, { "expression": "coalesce(\"issue_id\"::text, \"native_issue_id\"::text,\n \"context_snapshot\"->>'issueId', \"context_snapshot\"->>'taskId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36762,10 +38031,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" in ('running', 'succeeded')", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_attention_history_idx": { "name": "heartbeat_runs_attention_history_idx", @@ -36790,10 +38059,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"status\" in ('failed', 'timed_out') or \"heartbeat_runs\".\"error_code\" = 'provider_limit_wait'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_company_ctx_issue_created_idx": { "name": "heartbeat_runs_company_ctx_issue_created_idx", @@ -36806,8 +38075,8 @@ }, { "expression": "(\"context_snapshot\" ->> 'issueId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36818,9 +38087,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_ctx_task_created_idx": { "name": "heartbeat_runs_company_ctx_task_created_idx", @@ -36833,8 +38102,8 @@ }, { "expression": "(\"context_snapshot\" ->> 'taskId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36845,9 +38114,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_ctx_taskkey_created_idx": { "name": "heartbeat_runs_company_ctx_taskkey_created_idx", @@ -36860,8 +38129,8 @@ }, { "expression": "(\"context_snapshot\" ->> 'taskKey')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36872,9 +38141,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "heartbeat_runs_company_ctx_execution_workspace_idx": { "name": "heartbeat_runs_company_ctx_execution_workspace_idx", @@ -36887,16 +38156,16 @@ }, { "expression": "(\"context_snapshot\" ->> 'executionWorkspaceId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"heartbeat_runs\".\"context_snapshot\" ? 'executionWorkspaceId'", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "heartbeat_runs_company_ctx_paperclip_issue_created_idx": { "name": "heartbeat_runs_company_ctx_paperclip_issue_created_idx", @@ -36909,8 +38178,8 @@ }, { "expression": "(\"context_snapshot\" -> 'paperclipIssue' ->> 'id')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -36921,9 +38190,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": true, "method": "btree", - "concurrently": true + "with": {} }, "heartbeat_runs_company_origin_issue_idx": { "name": "heartbeat_runs_company_origin_issue_idx", @@ -36936,104 +38205,104 @@ }, { "expression": "coalesce(\n \"native_issue_id\"::text,\n nullif(\"context_snapshot\"->>'issueId', ''),\n nullif(\"context_snapshot\"->>'taskId', ''),\n nullif(\"context_snapshot\"->>'taskKey', '')\n )", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, + "concurrently": true, "method": "btree", - "concurrently": true + "with": {} } }, "foreignKeys": { "heartbeat_runs_company_id_companies_id_fk": { "name": "heartbeat_runs_company_id_companies_id_fk", "tableFrom": "heartbeat_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_runs_agent_id_agents_id_fk": { "name": "heartbeat_runs_agent_id_agents_id_fk", "tableFrom": "heartbeat_runs", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_runs_issue_id_issues_id_fk": { "name": "heartbeat_runs_issue_id_issues_id_fk", "tableFrom": "heartbeat_runs", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk": { "name": "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk", "tableFrom": "heartbeat_runs", + "tableTo": "agent_wakeup_requests", "columnsFrom": [ "wakeup_request_id" ], - "tableTo": "agent_wakeup_requests", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk": { "name": "heartbeat_runs_retry_of_run_id_heartbeat_runs_id_fk", "tableFrom": "heartbeat_runs", + "tableTo": "heartbeat_runs", "columnsFrom": [ "retry_of_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "heartbeat_runs_company_native_issue_id_uq": { "name": "heartbeat_runs_company_native_issue_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "native_issue_id", "id" - ], - "nullsNotDistinct": false + ] }, "heartbeat_runs_company_native_issue_contract_id_uq": { "name": "heartbeat_runs_company_native_issue_contract_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "native_issue_id", "id", "completion_contract_id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -37133,9 +38402,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "inbox_dismissals_company_item_idx": { "name": "inbox_dismissals_company_item_idx", @@ -37154,9 +38423,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "inbox_dismissals_company_user_item_idx": { "name": "inbox_dismissals_company_user_item_idx", @@ -37181,24 +38450,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "inbox_dismissals_company_id_companies_id_fk": { "name": "inbox_dismissals_company_id_companies_id_fk", "tableFrom": "inbox_dismissals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -37268,9 +38537,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grant_delegations_grant_agent_uq": { "name": "connection_grant_delegations_grant_agent_uq", @@ -37289,52 +38558,52 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "connection_grant_delegations_company_id_companies_id_fk": { "name": "connection_grant_delegations_company_id_companies_id_fk", "tableFrom": "connection_grant_delegations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_grant_delegations_agent_id_agents_id_fk": { "name": "connection_grant_delegations_agent_id_agents_id_fk", "tableFrom": "connection_grant_delegations", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_grant_delegations_company_grant_fk": { "name": "connection_grant_delegations_company_grant_fk", "tableFrom": "connection_grant_delegations", + "tableTo": "connection_grants", "columnsFrom": [ "company_id", "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -37410,9 +38679,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grant_members_grant_subject_uq": { "name": "connection_grant_members_grant_subject_uq", @@ -37437,39 +38706,39 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "connection_grant_members_company_id_companies_id_fk": { "name": "connection_grant_members_company_id_companies_id_fk", "tableFrom": "connection_grant_members", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_grant_members_company_grant_fk": { "name": "connection_grant_members_company_grant_fk", "tableFrom": "connection_grant_members", + "tableTo": "connection_grants", "columnsFrom": [ "company_id", "grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -37626,9 +38895,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grants_subject_user_idx": { "name": "connection_grants_subject_user_idx", @@ -37647,9 +38916,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grants_subject_agent_idx": { "name": "connection_grants_subject_agent_idx", @@ -37668,9 +38937,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grants_user_uq": { "name": "connection_grants_user_uq", @@ -37689,9 +38958,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grants_agent_uq": { "name": "connection_grants_agent_uq", @@ -37710,9 +38979,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_grants_default_uq": { "name": "connection_grants_default_uq", @@ -37725,90 +38994,90 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"connection_grants\".\"is_default\" = true and \"connection_grants\".\"kind\" = 'organization'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "connection_grants_company_id_companies_id_fk": { "name": "connection_grants_company_id_companies_id_fk", "tableFrom": "connection_grants", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_grants_subject_agent_id_agents_id_fk": { "name": "connection_grants_subject_agent_id_agents_id_fk", "tableFrom": "connection_grants", + "tableTo": "agents", "columnsFrom": [ "subject_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_grants_created_by_agent_id_agents_id_fk": { "name": "connection_grants_created_by_agent_id_agents_id_fk", "tableFrom": "connection_grants", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "connection_grants_revoked_by_agent_id_agents_id_fk": { "name": "connection_grants_revoked_by_agent_id_agents_id_fk", "tableFrom": "connection_grants", + "tableTo": "agents", "columnsFrom": [ "revoked_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "connection_grants_company_connection_fk": { "name": "connection_grants_company_connection_fk", "tableFrom": "connection_grants", + "tableTo": "tool_connections", "columnsFrom": [ "company_id", "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "connection_grants_company_id_uq": { "name": "connection_grants_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -37978,9 +39247,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_token_issuances_connection_created_idx": { "name": "connection_token_issuances_connection_created_idx", @@ -38005,9 +39274,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_token_issuances_agent_connection_idx": { "name": "connection_token_issuances_agent_connection_idx", @@ -38038,9 +39307,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "connection_token_issuances_run_idx": { "name": "connection_token_issuances_run_idx", @@ -38059,102 +39328,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "connection_token_issuances_company_id_companies_id_fk": { "name": "connection_token_issuances_company_id_companies_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_token_issuances_application_id_tool_applications_id_fk": { "name": "connection_token_issuances_application_id_tool_applications_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "connection_token_issuances_connection_id_tool_connections_id_fk": { "name": "connection_token_issuances_connection_id_tool_connections_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_token_issuances_agent_id_agents_id_fk": { "name": "connection_token_issuances_agent_id_agents_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "connection_token_issuances_run_id_heartbeat_runs_id_fk": { "name": "connection_token_issuances_run_id_heartbeat_runs_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "connection_token_issuances_issue_id_issues_id_fk": { "name": "connection_token_issuances_issue_id_issues_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "connection_token_issuances_project_id_projects_id_fk": { "name": "connection_token_issuances_project_id_projects_id_fk", "tableFrom": "connection_token_issuances", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -38228,24 +39497,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "instance_settings_default_environment_id_environments_id_fk": { "name": "instance_settings_default_environment_id_environments_id_fk", "tableFrom": "instance_settings", + "tableTo": "environments", "columnsFrom": [ "default_environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -38311,9 +39580,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "instance_user_roles_role_idx": { "name": "instance_user_roles_role_idx", @@ -38326,9 +39595,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -38432,9 +39701,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "invites_company_invite_state_idx": { "name": "invites_company_invite_state_idx", @@ -38465,24 +39734,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "invites_company_id_companies_id_fk": { "name": "invites_company_id_companies_id_fk", "tableFrom": "invites", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -38582,9 +39851,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_access_grants_issue_idx": { "name": "issue_access_grants_issue_idx", @@ -38603,37 +39872,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_access_grants_issue_id_issues_id_fk": { "name": "issue_access_grants_issue_id_issues_id_fk", "tableFrom": "issue_access_grants", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_access_grants_granted_by_agent_id_agents_id_fk": { "name": "issue_access_grants_granted_by_agent_id_agents_id_fk", "tableFrom": "issue_access_grants", + "tableTo": "agents", "columnsFrom": [ "granted_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -38705,9 +39974,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_approvals_approval_idx": { "name": "issue_approvals_approval_idx", @@ -38720,9 +39989,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_approvals_company_idx": { "name": "issue_approvals_company_idx", @@ -38735,63 +40004,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_approvals_company_id_companies_id_fk": { "name": "issue_approvals_company_id_companies_id_fk", "tableFrom": "issue_approvals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_approvals_issue_id_issues_id_fk": { "name": "issue_approvals_issue_id_issues_id_fk", "tableFrom": "issue_approvals", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_approvals_approval_id_approvals_id_fk": { "name": "issue_approvals_approval_id_approvals_id_fk", "tableFrom": "issue_approvals", + "tableTo": "approvals", "columnsFrom": [ "approval_id" ], - "tableTo": "approvals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_approvals_linked_by_agent_id_agents_id_fk": { "name": "issue_approvals_linked_by_agent_id_agents_id_fk", "tableFrom": "issue_approvals", + "tableTo": "agents", "columnsFrom": [ "linked_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -38849,6 +40118,13 @@ "primaryKey": false, "notNull": false }, + "issue_level": { + "name": "issue_level", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -38882,9 +40158,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_attachments_issue_comment_idx": { "name": "issue_attachments_issue_comment_idx", @@ -38897,9 +40173,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_attachments_originating_run_idx": { "name": "issue_attachments_originating_run_idx", @@ -38912,9 +40188,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_attachments_asset_uq": { "name": "issue_attachments_asset_uq", @@ -38927,76 +40203,76 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_attachments_company_id_companies_id_fk": { "name": "issue_attachments_company_id_companies_id_fk", "tableFrom": "issue_attachments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_attachments_issue_id_issues_id_fk": { "name": "issue_attachments_issue_id_issues_id_fk", "tableFrom": "issue_attachments", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_attachments_asset_id_assets_id_fk": { "name": "issue_attachments_asset_id_assets_id_fk", "tableFrom": "issue_attachments", + "tableTo": "assets", "columnsFrom": [ "asset_id" ], - "tableTo": "assets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_attachments_issue_comment_id_issue_comments_id_fk": { "name": "issue_attachments_issue_comment_id_issue_comments_id_fk", "tableFrom": "issue_attachments", + "tableTo": "issue_comments", "columnsFrom": [ "issue_comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_attachments_originating_run_id_heartbeat_runs_id_fk": { "name": "issue_attachments_originating_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_attachments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "originating_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -39149,6 +40425,33 @@ "primaryKey": false, "notNull": false }, + "actor_profile": { + "name": "actor_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kv_labels": { + "name": "kv_labels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "schema_blocks": { + "name": "schema_blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "no_sync": { + "name": "no_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, "source_trust": { "name": "source_trust", "type": "jsonb", @@ -39182,9 +40485,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_comments_review_response_receipt_idx": { "name": "issue_comments_review_response_receipt_idx", @@ -39215,10 +40518,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issue_comments\".\"author_type\" = 'agent' AND \"issue_comments\".\"metadata\"->>'authorizationReason' = 'allow_chat_run_presentation'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_comments_company_idx": { "name": "issue_comments_company_idx", @@ -39231,9 +40534,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_comments_company_issue_created_at_idx": { "name": "issue_comments_company_issue_created_at_idx", @@ -39258,9 +40561,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_comments_company_author_issue_created_at_idx": { "name": "issue_comments_company_author_issue_created_at_idx", @@ -39291,9 +40594,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_comments_body_search_idx": { "name": "issue_comments_body_search_idx", @@ -39307,157 +40610,157 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_comments_company_id_companies_id_fk": { "name": "issue_comments_company_id_companies_id_fk", "tableFrom": "issue_comments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_comments_issue_id_issues_id_fk": { "name": "issue_comments_issue_id_issues_id_fk", "tableFrom": "issue_comments", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_comments_author_agent_id_agents_id_fk": { "name": "issue_comments_author_agent_id_agents_id_fk", "tableFrom": "issue_comments", + "tableTo": "agents", "columnsFrom": [ "author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_comments_on_behalf_of_user_id_user_id_fk": { "name": "issue_comments_on_behalf_of_user_id_user_id_fk", "tableFrom": "issue_comments", + "tableTo": "user", "columnsFrom": [ "on_behalf_of_user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_comments_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_comments_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_comments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_comments_derived_author_agent_id_agents_id_fk": { "name": "issue_comments_derived_author_agent_id_agents_id_fk", "tableFrom": "issue_comments", + "tableTo": "agents", "columnsFrom": [ "derived_author_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_comments_derived_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_comments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "derived_created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_comments_deleted_by_agent_id_agents_id_fk": { "name": "issue_comments_deleted_by_agent_id_agents_id_fk", "tableFrom": "issue_comments", + "tableTo": "agents", "columnsFrom": [ "deleted_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk": { "name": "issue_comments_deleted_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_comments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "deleted_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "issue_comments_client_request_uq": { "name": "issue_comments_client_request_uq", + "nullsNotDistinct": false, "columns": [ "issue_id", "author_user_id", "client_request_id" - ], - "nullsNotDistinct": false + ] }, "issue_comments_agent_client_request_uq": { "name": "issue_comments_agent_client_request_uq", + "nullsNotDistinct": false, "columns": [ "issue_id", "author_agent_id", "client_request_id" - ], - "nullsNotDistinct": false + ] }, "issue_comments_company_id_uq": { "name": "issue_comments_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -39585,9 +40888,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_connection_content_deletions_pending_idx": { "name": "issue_connection_content_deletions_pending_idx", @@ -39600,25 +40903,25 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issue_connection_content_deletions\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "issue_connection_content_deletions_company_id_companies_id_fk": { "name": "issue_connection_content_deletions_company_id_companies_id_fk", "tableFrom": "issue_connection_content_deletions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -39682,9 +40985,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_create_idempotency_keys_issue_idx": { "name": "issue_create_idempotency_keys_issue_idx", @@ -39697,9 +41000,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_create_idempotency_keys_company_created_at_idx": { "name": "issue_create_idempotency_keys_company_created_at_idx", @@ -39718,37 +41021,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_create_idempotency_keys_company_id_companies_id_fk": { "name": "issue_create_idempotency_keys_company_id_companies_id_fk", "tableFrom": "issue_create_idempotency_keys", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_create_idempotency_keys_issue_id_issues_id_fk": { "name": "issue_create_idempotency_keys_issue_id_issues_id_fk", "tableFrom": "issue_create_idempotency_keys", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -39831,9 +41134,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_documents_document_uq": { "name": "issue_documents_document_uq", @@ -39846,9 +41149,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_documents_company_issue_updated_idx": { "name": "issue_documents_company_issue_updated_idx", @@ -39873,50 +41176,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_documents_company_id_companies_id_fk": { "name": "issue_documents_company_id_companies_id_fk", "tableFrom": "issue_documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_documents_issue_id_issues_id_fk": { "name": "issue_documents_issue_id_issues_id_fk", "tableFrom": "issue_documents", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_documents_document_id_documents_id_fk": { "name": "issue_documents_document_id_documents_id_fk", "tableFrom": "issue_documents", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -40023,9 +41326,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_execution_decisions_stage_idx": { "name": "issue_execution_decisions_stage_idx", @@ -40050,63 +41353,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_execution_decisions_company_id_companies_id_fk": { "name": "issue_execution_decisions_company_id_companies_id_fk", "tableFrom": "issue_execution_decisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_execution_decisions_issue_id_issues_id_fk": { "name": "issue_execution_decisions_issue_id_issues_id_fk", "tableFrom": "issue_execution_decisions", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_execution_decisions_actor_agent_id_agents_id_fk": { "name": "issue_execution_decisions_actor_agent_id_agents_id_fk", "tableFrom": "issue_execution_decisions", + "tableTo": "agents", "columnsFrom": [ "actor_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_execution_decisions_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_execution_decisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -40203,9 +41506,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_inbox_archives_company_user_idx": { "name": "issue_inbox_archives_company_user_idx", @@ -40224,9 +41527,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_inbox_archives_company_issue_user_idx": { "name": "issue_inbox_archives_company_issue_user_idx", @@ -40251,63 +41554,63 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_inbox_archives_company_id_companies_id_fk": { "name": "issue_inbox_archives_company_id_companies_id_fk", "tableFrom": "issue_inbox_archives", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_inbox_archives_issue_id_issues_id_fk": { "name": "issue_inbox_archives_issue_id_issues_id_fk", "tableFrom": "issue_inbox_archives", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_inbox_archives_archived_by_agent_id_agents_id_fk": { "name": "issue_inbox_archives_archived_by_agent_id_agents_id_fk", "tableFrom": "issue_inbox_archives", + "tableTo": "agents", "columnsFrom": [ "archived_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_inbox_archives_archived_by_run_id_heartbeat_runs_id_fk": { "name": "issue_inbox_archives_archived_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_inbox_archives", + "tableTo": "heartbeat_runs", "columnsFrom": [ "archived_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -40363,9 +41666,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_labels_label_idx": { "name": "issue_labels_label_idx", @@ -40378,9 +41681,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_labels_company_idx": { "name": "issue_labels_company_idx", @@ -40393,50 +41696,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_labels_issue_id_issues_id_fk": { "name": "issue_labels_issue_id_issues_id_fk", "tableFrom": "issue_labels", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_labels_label_id_labels_id_fk": { "name": "issue_labels_label_id_labels_id_fk", "tableFrom": "issue_labels", + "tableTo": "labels", "columnsFrom": [ "label_id" ], - "tableTo": "labels", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_labels_company_id_companies_id_fk": { "name": "issue_labels_company_id_companies_id_fk", "tableFrom": "issue_labels", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -40585,9 +41888,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_plan_decompositions_active_owner_idx": { "name": "issue_plan_decompositions_active_owner_idx", @@ -40606,10 +41909,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issue_plan_decompositions\".\"status\" = 'in_flight'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_plan_decompositions_source_revision_uq": { "name": "issue_plan_decompositions_source_revision_uq", @@ -40634,89 +41937,89 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_plan_decompositions_company_id_companies_id_fk": { "name": "issue_plan_decompositions_company_id_companies_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_plan_decompositions_source_issue_id_issues_id_fk": { "name": "issue_plan_decompositions_source_issue_id_issues_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "issues", "columnsFrom": [ "source_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_plan_decompositions_accepted_plan_revision_id_document_revisions_id_fk": { "name": "issue_plan_decompositions_accepted_plan_revision_id_document_revisions_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "document_revisions", "columnsFrom": [ "accepted_plan_revision_id" ], - "tableTo": "document_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_plan_decompositions_accepted_interaction_id_issue_thread_interactions_id_fk": { "name": "issue_plan_decompositions_accepted_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "accepted_interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_plan_decompositions_owner_agent_id_agents_id_fk": { "name": "issue_plan_decompositions_owner_agent_id_agents_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_plan_decompositions_owner_run_id_heartbeat_runs_id_fk": { "name": "issue_plan_decompositions_owner_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_plan_decompositions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "owner_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -40856,9 +42159,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_question_response_deliveries_correlation_uq": { "name": "issue_question_response_deliveries_correlation_uq", @@ -40871,9 +42174,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_question_response_deliveries_pending_idx": { "name": "issue_question_response_deliveries_pending_idx", @@ -40892,9 +42195,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_question_response_deliveries_company_issue_idx": { "name": "issue_question_response_deliveries_company_issue_idx", @@ -40919,76 +42222,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_question_response_deliveries_company_id_companies_id_fk": { "name": "issue_question_response_deliveries_company_id_companies_id_fk", "tableFrom": "issue_question_response_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_question_response_deliveries_issue_id_issues_id_fk": { "name": "issue_question_response_deliveries_issue_id_issues_id_fk", "tableFrom": "issue_question_response_deliveries", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_question_response_deliveries_interaction_id_issue_thread_interactions_id_fk": { "name": "issue_question_response_deliveries_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "issue_question_response_deliveries", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_question_response_deliveries_source_run_id_heartbeat_runs_id_fk": { "name": "issue_question_response_deliveries_source_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_question_response_deliveries", + "tableTo": "heartbeat_runs", "columnsFrom": [ "source_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_question_response_deliveries_target_run_id_heartbeat_runs_id_fk": { "name": "issue_question_response_deliveries_target_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_question_response_deliveries", + "tableTo": "heartbeat_runs", "columnsFrom": [ "target_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -41075,9 +42378,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_read_states_company_user_idx": { "name": "issue_read_states_company_user_idx", @@ -41096,9 +42399,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_read_states_company_issue_user_idx": { "name": "issue_read_states_company_issue_user_idx", @@ -41123,37 +42426,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_read_states_company_id_companies_id_fk": { "name": "issue_read_states_company_id_companies_id_fk", "tableFrom": "issue_read_states", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_read_states_issue_id_issues_id_fk": { "name": "issue_read_states_issue_id_issues_id_fk", "tableFrom": "issue_read_states", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -41348,23 +42651,23 @@ }, { "expression": "(\"evidence\"->>'runId')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_recovery_actions_system_recovery_due_idx": { "name": "issue_recovery_actions_system_recovery_due_idx", "columns": [ { "expression": "(\"evidence\"#>'{systemRecovery,nextAttemptAt}')", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -41375,10 +42678,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issue_recovery_actions\".\"evidence\" ? 'systemRecovery'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_recovery_actions_system_recovery_adoption_idx": { "name": "issue_recovery_actions_system_recovery_adoption_idx", @@ -41391,10 +42694,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "not (\"issue_recovery_actions\".\"evidence\" ? 'systemRecovery') and (\n \"issue_recovery_actions\".\"evidence\"->'workspaceRestoreRecovery'->>'schema' = 'paperclip.workspace-restore-recovery.v1'\n or \"issue_recovery_actions\".\"cause\" in ('native_workspace_sync_out_unrecoverable', 'native_workspace_sync_out_retry_exhausted')\n )", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_recovery_actions_retained_workspace_recovery_idx": { "name": "issue_recovery_actions_retained_workspace_recovery_idx", @@ -41407,10 +42710,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\n (\"issue_recovery_actions\".\"evidence\"->'workspaceRestoreRecovery'->>'schema' = 'paperclip.workspace-restore-recovery.v1'\n or \"issue_recovery_actions\".\"cause\" in ('native_workspace_sync_out_unrecoverable', 'native_workspace_sync_out_retry_exhausted'))\n and (\"issue_recovery_actions\".\"evidence\"->'executionReconciliation' is null\n or \"issue_recovery_actions\".\"evidence\"#>>'{workspaceRecovery,status}' = 'recovered')\n ", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_recovery_actions_company_source_status_idx": { "name": "issue_recovery_actions_company_source_status_idx", @@ -41435,9 +42738,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_recovery_actions_company_owner_status_idx": { "name": "issue_recovery_actions_company_owner_status_idx", @@ -41462,9 +42765,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_recovery_actions_company_recovery_issue_idx": { "name": "issue_recovery_actions_company_recovery_issue_idx", @@ -41483,9 +42786,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_recovery_actions_active_source_uq": { "name": "issue_recovery_actions_active_source_uq", @@ -41504,10 +42807,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_recovery_actions\".\"status\" in ('active', 'escalated')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_recovery_actions_active_fingerprint_uq": { "name": "issue_recovery_actions_active_fingerprint_uq", @@ -41538,90 +42841,90 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_recovery_actions\".\"status\" in ('active', 'escalated')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "issue_recovery_actions_company_id_companies_id_fk": { "name": "issue_recovery_actions_company_id_companies_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_recovery_actions_source_issue_id_issues_id_fk": { "name": "issue_recovery_actions_source_issue_id_issues_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "issues", "columnsFrom": [ "source_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_recovery_actions_recovery_issue_id_issues_id_fk": { "name": "issue_recovery_actions_recovery_issue_id_issues_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "issues", "columnsFrom": [ "recovery_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_recovery_actions_owner_agent_id_agents_id_fk": { "name": "issue_recovery_actions_owner_agent_id_agents_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_recovery_actions_previous_owner_agent_id_agents_id_fk": { "name": "issue_recovery_actions_previous_owner_agent_id_agents_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "agents", "columnsFrom": [ "previous_owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_recovery_actions_return_owner_agent_id_agents_id_fk": { "name": "issue_recovery_actions_return_owner_agent_id_agents_id_fk", "tableFrom": "issue_recovery_actions", + "tableTo": "agents", "columnsFrom": [ "return_owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -41664,28 +42967,28 @@ "issue_recovery_deferrals_issue_id_issues_id_fk": { "name": "issue_recovery_deferrals_issue_id_issues_id_fk", "tableFrom": "issue_recovery_deferrals", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_recovery_deferrals_company_id_companies_id_fk": { "name": "issue_recovery_deferrals_company_id_companies_id_fk", "tableFrom": "issue_recovery_deferrals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -41730,15 +43033,15 @@ "issue_recovery_full_passes_company_id_companies_id_fk": { "name": "issue_recovery_full_passes_company_id_companies_id_fk", "tableFrom": "issue_recovery_full_passes", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -41841,9 +43144,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_reference_mentions_company_target_issue_idx": { "name": "issue_reference_mentions_company_target_issue_idx", @@ -41862,9 +43165,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_reference_mentions_company_issue_pair_idx": { "name": "issue_reference_mentions_company_issue_pair_idx", @@ -41889,9 +43192,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_reference_mentions_company_source_mention_record_uq": { "name": "issue_reference_mentions_company_source_mention_record_uq", @@ -41928,10 +43231,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_reference_mentions\".\"source_record_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_reference_mentions_company_source_mention_null_record_uq": { "name": "issue_reference_mentions_company_source_mention_null_record_uq", @@ -41962,51 +43265,51 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_reference_mentions\".\"source_record_id\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "issue_reference_mentions_company_id_companies_id_fk": { "name": "issue_reference_mentions_company_id_companies_id_fk", "tableFrom": "issue_reference_mentions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_reference_mentions_source_issue_id_issues_id_fk": { "name": "issue_reference_mentions_source_issue_id_issues_id_fk", "tableFrom": "issue_reference_mentions", + "tableTo": "issues", "columnsFrom": [ "source_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_reference_mentions_target_issue_id_issues_id_fk": { "name": "issue_reference_mentions_target_issue_id_issues_id_fk", "tableFrom": "issue_reference_mentions", + "tableTo": "issues", "columnsFrom": [ "target_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -42095,9 +43398,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_relations_company_related_issue_idx": { "name": "issue_relations_company_related_issue_idx", @@ -42116,9 +43419,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_relations_company_type_idx": { "name": "issue_relations_company_type_idx", @@ -42137,9 +43440,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_relations_company_edge_uq": { "name": "issue_relations_company_edge_uq", @@ -42170,63 +43473,63 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_relations_company_id_companies_id_fk": { "name": "issue_relations_company_id_companies_id_fk", "tableFrom": "issue_relations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_relations_issue_id_issues_id_fk": { "name": "issue_relations_issue_id_issues_id_fk", "tableFrom": "issue_relations", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_relations_related_issue_id_issues_id_fk": { "name": "issue_relations_related_issue_id_issues_id_fk", "tableFrom": "issue_relations", + "tableTo": "issues", "columnsFrom": [ "related_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_relations_created_by_agent_id_agents_id_fk": { "name": "issue_relations_created_by_agent_id_agents_id_fk", "tableFrom": "issue_relations", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -42302,9 +43605,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interaction_idempotency_keys_interaction_idx": { "name": "issue_thread_interaction_idempotency_keys_interaction_idx", @@ -42317,50 +43620,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_thread_interaction_idempotency_keys_company_id_companies_id_fk": { "name": "issue_thread_interaction_idempotency_keys_company_id_companies_id_fk", "tableFrom": "issue_thread_interaction_idempotency_keys", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_thread_interaction_idempotency_keys_issue_id_issues_id_fk": { "name": "issue_thread_interaction_idempotency_keys_issue_id_issues_id_fk", "tableFrom": "issue_thread_interaction_idempotency_keys", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_thread_interaction_idempotency_keys_interaction_id_issue_thread_interactions_id_fk": { "name": "issue_thread_interaction_idempotency_keys_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "issue_thread_interaction_idempotency_keys", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -42582,9 +43885,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interactions_company_issue_created_at_idx": { "name": "issue_thread_interactions_company_issue_created_at_idx", @@ -42609,9 +43912,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interactions_company_issue_status_idx": { "name": "issue_thread_interactions_company_issue_status_idx", @@ -42636,9 +43939,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interactions_company_issue_idempotency_uq": { "name": "issue_thread_interactions_company_issue_idempotency_uq", @@ -42663,10 +43966,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_thread_interactions\".\"idempotency_key\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issue_thread_interactions_source_comment_idx": { "name": "issue_thread_interactions_source_comment_idx", @@ -42679,9 +43982,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interactions_addressee_agent_idx": { "name": "issue_thread_interactions_addressee_agent_idx", @@ -42694,9 +43997,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_thread_interactions_addressee_user_idx": { "name": "issue_thread_interactions_addressee_user_idx", @@ -42709,115 +44012,115 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_thread_interactions_company_id_companies_id_fk": { "name": "issue_thread_interactions_company_id_companies_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_thread_interactions_issue_id_issues_id_fk": { "name": "issue_thread_interactions_issue_id_issues_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_thread_interactions_source_comment_id_issue_comments_id_fk": { "name": "issue_thread_interactions_source_comment_id_issue_comments_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "issue_comments", "columnsFrom": [ "source_comment_id" ], - "tableTo": "issue_comments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_thread_interactions_source_run_id_heartbeat_runs_id_fk": { "name": "issue_thread_interactions_source_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "source_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_thread_interactions_created_by_agent_id_agents_id_fk": { "name": "issue_thread_interactions_created_by_agent_id_agents_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_thread_interactions_addressee_agent_id_agents_id_fk": { "name": "issue_thread_interactions_addressee_agent_id_agents_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "agents", "columnsFrom": [ "addressee_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_thread_interactions_resolved_by_agent_id_agents_id_fk": { "name": "issue_thread_interactions_resolved_by_agent_id_agents_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "agents", "columnsFrom": [ "resolved_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_thread_interactions_resolved_by_run_id_heartbeat_runs_id_fk": { "name": "issue_thread_interactions_resolved_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_thread_interactions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "resolved_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -42949,9 +44252,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_tree_hold_members_company_issue_idx": { "name": "issue_tree_hold_members_company_issue_idx", @@ -42970,9 +44273,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_tree_hold_members_hold_depth_idx": { "name": "issue_tree_hold_members_hold_depth_idx", @@ -42991,89 +44294,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_tree_hold_members_company_id_companies_id_fk": { "name": "issue_tree_hold_members_company_id_companies_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_tree_hold_members_hold_id_issue_tree_holds_id_fk": { "name": "issue_tree_hold_members_hold_id_issue_tree_holds_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "issue_tree_holds", "columnsFrom": [ "hold_id" ], - "tableTo": "issue_tree_holds", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_tree_hold_members_issue_id_issues_id_fk": { "name": "issue_tree_hold_members_issue_id_issues_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_tree_hold_members_parent_issue_id_issues_id_fk": { "name": "issue_tree_hold_members_parent_issue_id_issues_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "issues", "columnsFrom": [ "parent_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_tree_hold_members_assignee_agent_id_agents_id_fk": { "name": "issue_tree_hold_members_assignee_agent_id_agents_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "agents", "columnsFrom": [ "assignee_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_tree_hold_members_active_run_id_heartbeat_runs_id_fk": { "name": "issue_tree_hold_members_active_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_tree_hold_members", + "tableTo": "heartbeat_runs", "columnsFrom": [ "active_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -43236,9 +44539,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_tree_holds_company_status_mode_idx": { "name": "issue_tree_holds_company_status_mode_idx", @@ -43263,89 +44566,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_tree_holds_company_id_companies_id_fk": { "name": "issue_tree_holds_company_id_companies_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_tree_holds_root_issue_id_issues_id_fk": { "name": "issue_tree_holds_root_issue_id_issues_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "issues", "columnsFrom": [ "root_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_tree_holds_created_by_agent_id_agents_id_fk": { "name": "issue_tree_holds_created_by_agent_id_agents_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_tree_holds_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_tree_holds_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_tree_holds_released_by_agent_id_agents_id_fk": { "name": "issue_tree_holds_released_by_agent_id_agents_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "agents", "columnsFrom": [ "released_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_tree_holds_released_by_run_id_heartbeat_runs_id_fk": { "name": "issue_tree_holds_released_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_tree_holds", + "tableTo": "heartbeat_runs", "columnsFrom": [ "released_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -43514,9 +44817,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_watchdogs_company_status_idx": { "name": "issue_watchdogs_company_status_idx", @@ -43535,9 +44838,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_watchdogs_company_agent_idx": { "name": "issue_watchdogs_company_agent_idx", @@ -43556,9 +44859,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_watchdogs_company_watchdog_issue_uq": { "name": "issue_watchdogs_company_watchdog_issue_uq", @@ -43577,116 +44880,116 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issue_watchdogs\".\"watchdog_issue_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "issue_watchdogs_company_id_companies_id_fk": { "name": "issue_watchdogs_company_id_companies_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_watchdogs_issue_id_issues_id_fk": { "name": "issue_watchdogs_issue_id_issues_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_watchdogs_watchdog_agent_id_agents_id_fk": { "name": "issue_watchdogs_watchdog_agent_id_agents_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "agents", "columnsFrom": [ "watchdog_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_watchdogs_watchdog_issue_id_issues_id_fk": { "name": "issue_watchdogs_watchdog_issue_id_issues_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "issues", "columnsFrom": [ "watchdog_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_watchdogs_created_by_agent_id_agents_id_fk": { "name": "issue_watchdogs_created_by_agent_id_agents_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_watchdogs_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_watchdogs_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_watchdogs_updated_by_agent_id_agents_id_fk": { "name": "issue_watchdogs_updated_by_agent_id_agents_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_watchdogs_updated_by_run_id_heartbeat_runs_id_fk": { "name": "issue_watchdogs_updated_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_watchdogs", + "tableTo": "heartbeat_runs", "columnsFrom": [ "updated_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -43856,9 +45159,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_work_products_company_execution_workspace_type_idx": { "name": "issue_work_products_company_execution_workspace_type_idx", @@ -43883,9 +45186,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_work_products_company_provider_external_id_idx": { "name": "issue_work_products_company_provider_external_id_idx", @@ -43910,9 +45213,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issue_work_products_company_updated_idx": { "name": "issue_work_products_company_updated_idx", @@ -43931,89 +45234,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "issue_work_products_company_id_companies_id_fk": { "name": "issue_work_products_company_id_companies_id_fk", "tableFrom": "issue_work_products", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issue_work_products_project_id_projects_id_fk": { "name": "issue_work_products_project_id_projects_id_fk", "tableFrom": "issue_work_products", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_work_products_issue_id_issues_id_fk": { "name": "issue_work_products_issue_id_issues_id_fk", "tableFrom": "issue_work_products", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "issue_work_products_execution_workspace_id_execution_workspaces_id_fk": { "name": "issue_work_products_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "issue_work_products", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_work_products_runtime_service_id_workspace_runtime_services_id_fk": { "name": "issue_work_products_runtime_service_id_workspace_runtime_services_id_fk", "tableFrom": "issue_work_products", + "tableTo": "workspace_runtime_services", "columnsFrom": [ "runtime_service_id" ], - "tableTo": "workspace_runtime_services", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issue_work_products_created_by_run_id_heartbeat_runs_id_fk": { "name": "issue_work_products_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "issue_work_products", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -44076,6 +45379,12 @@ "primaryKey": false, "notNull": false }, + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, "project_workspace_id": { "name": "project_workspace_id", "type": "uuid", @@ -44139,6 +45448,13 @@ "notNull": true, "default": "'backlog'" }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'board'" + }, "status_version": { "name": "status_version", "type": "bigint", @@ -44226,12 +45542,88 @@ "primaryKey": false, "notNull": false }, + "created_by_profile": { + "name": "created_by_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, "responsible_user_id": { "name": "responsible_user_id", "type": "text", "primaryKey": false, "notNull": false }, + "kv_labels": { + "name": "kv_labels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "schema_blocks": { + "name": "schema_blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "result_schema_ref": { + "name": "result_schema_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claim_epoch": { + "name": "claim_epoch", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "claim_token_hash": { + "name": "claim_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claim_holder_agent_id": { + "name": "claim_holder_agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "claim_holder_user_id": { + "name": "claim_holder_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claim_holder_profile": { + "name": "claim_holder_profile", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claim_leased_at": { + "name": "claim_leased_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "claim_lease_expires_at": { + "name": "claim_lease_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "claim_attempt_count": { + "name": "claim_attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, "issue_number": { "name": "issue_number", "type": "integer", @@ -44480,9 +45872,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_status_idx": { "name": "issues_company_status_idx", @@ -44501,9 +45893,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} + }, + "issues_company_scope_status_idx": { + "name": "issues_company_scope_status_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "issues_company_scope_updated_idx": { + "name": "issues_company_scope_updated_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} }, "issues_company_harness_kind_idx": { "name": "issues_company_harness_kind_idx", @@ -44522,9 +45968,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_assignee_status_idx": { "name": "issues_company_assignee_status_idx", @@ -44549,9 +45995,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_assignee_user_status_idx": { "name": "issues_company_assignee_user_status_idx", @@ -44576,9 +46022,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_responsible_user_idx": { "name": "issues_company_responsible_user_idx", @@ -44597,9 +46043,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_parent_idx": { "name": "issues_company_parent_idx", @@ -44618,9 +46064,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_privacy_parent_idx": { "name": "issues_company_privacy_parent_idx", @@ -44639,9 +46085,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_privacy_root_idx": { "name": "issues_company_privacy_root_idx", @@ -44660,9 +46106,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_project_idx": { "name": "issues_company_project_idx", @@ -44681,9 +46127,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_origin_idx": { "name": "issues_company_origin_idx", @@ -44708,9 +46154,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_origin_issue_idx": { "name": "issues_company_origin_issue_idx", @@ -44729,9 +46175,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_legacy_origin_run_idx": { "name": "issues_company_legacy_origin_run_idx", @@ -44750,10 +46196,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_issue_id\" is null and \"issues\".\"origin_run_id\" is not null", - "concurrently": true + "concurrently": true, + "method": "btree", + "with": {} }, "issues_company_project_workspace_idx": { "name": "issues_company_project_workspace_idx", @@ -44772,9 +46218,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_execution_workspace_idx": { "name": "issues_company_execution_workspace_idx", @@ -44793,9 +46239,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_monitor_due_idx": { "name": "issues_company_monitor_due_idx", @@ -44814,9 +46260,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_updated_idx": { "name": "issues_company_updated_idx", @@ -44835,9 +46281,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_company_created_idx": { "name": "issues_company_created_idx", @@ -44856,9 +46302,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_open_normalized_title_created_idx": { "name": "issues_open_normalized_title_created_idx", @@ -44877,8 +46323,8 @@ }, { "expression": "lower(regexp_replace(btrim(\"title\"), '\\s+', ' ', 'g'))", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" }, { @@ -44889,10 +46335,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"issues\".\"hidden_at\" is null and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_company_priority_idx": { "name": "issues_company_priority_idx", @@ -44911,9 +46357,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_identifier_idx": { "name": "issues_identifier_idx", @@ -44926,9 +46372,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "issues_title_search_idx": { "name": "issues_title_search_idx", @@ -44942,9 +46388,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "issues_identifier_search_idx": { "name": "issues_identifier_search_idx", @@ -44958,9 +46404,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "issues_description_search_idx": { "name": "issues_description_search_idx", @@ -44974,9 +46420,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} }, "issues_open_routine_execution_uq": { "name": "issues_open_routine_execution_uq", @@ -45007,10 +46453,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'routine_execution'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"execution_run_id\" is not null\n and \"issues\".\"status\" in ('backlog', 'todo', 'in_progress', 'in_review', 'blocked')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_liveness_recovery_incident_uq": { "name": "issues_active_liveness_recovery_incident_uq", @@ -45035,10 +46481,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'harness_liveness_escalation'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_liveness_recovery_leaf_uq": { "name": "issues_active_liveness_recovery_leaf_uq", @@ -45063,10 +46509,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'harness_liveness_escalation'\n and \"issues\".\"origin_fingerprint\" <> 'default'\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_stale_run_evaluation_uq": { "name": "issues_active_stale_run_evaluation_uq", @@ -45091,10 +46537,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'stale_active_run_evaluation'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_task_watchdog_uq": { "name": "issues_active_task_watchdog_uq", @@ -45119,10 +46565,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'task_watchdog'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_productivity_review_uq": { "name": "issues_active_productivity_review_uq", @@ -45147,10 +46593,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'issue_productivity_review'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_active_stranded_issue_recovery_uq": { "name": "issues_active_stranded_issue_recovery_uq", @@ -45175,10 +46621,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'stranded_issue_recovery'\n and \"issues\".\"origin_id\" is not null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"status\" not in ('done', 'cancelled')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "issues_onboarding_first_task_uq": { "name": "issues_onboarding_first_task_uq", @@ -45191,205 +46637,344 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"issues\".\"origin_kind\" = 'onboarding_first_task'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} + }, + "issues_company_channel_created_idx": { + "name": "issues_company_channel_created_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": true, + "method": "btree", + "with": {} + }, + "issues_kv_labels_gin_idx": { + "name": "issues_kv_labels_gin_idx", + "columns": [ + { + "expression": "kv_labels", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": true, + "method": "gin", + "with": {} + }, + "issues_ready_pool_queue_idx": { + "name": "issues_ready_pool_queue_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "priority", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"issues\".\"status\" = 'todo'\n and \"issues\".\"assignee_agent_id\" is null\n and \"issues\".\"assignee_user_id\" is null\n and \"issues\".\"hidden_at\" is null\n and \"issues\".\"conversation_agent_id\" is null", + "concurrently": true, + "method": "btree", + "with": {} + }, + "issues_active_claim_lease_due_idx": { + "name": "issues_active_claim_lease_due_idx", + "columns": [ + { + "expression": "claim_lease_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"issues\".\"status\" = 'in_progress'\n and \"issues\".\"claim_lease_expires_at\" is not null\n and \"issues\".\"claim_token_hash\" is not null", + "concurrently": true, + "method": "btree", + "with": {} + }, + "issues_company_issue_number_idx": { + "name": "issues_company_issue_number_idx", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issue_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": true, + "method": "btree", + "with": {} } }, "foreignKeys": { "issues_company_id_companies_id_fk": { "name": "issues_company_id_companies_id_fk", "tableFrom": "issues", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_conversation_agent_id_agents_id_fk": { "name": "issues_conversation_agent_id_agents_id_fk", "tableFrom": "issues", + "tableTo": "agents", "columnsFrom": [ "conversation_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_project_id_projects_id_fk": { "name": "issues_project_id_projects_id_fk", "tableFrom": "issues", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" + }, + "issues_channel_id_channels_id_fk": { + "name": "issues_channel_id_channels_id_fk", + "tableFrom": "issues", + "tableTo": "channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" }, "issues_project_workspace_id_project_workspaces_id_fk": { "name": "issues_project_workspace_id_project_workspaces_id_fk", "tableFrom": "issues", + "tableTo": "project_workspaces", "columnsFrom": [ "project_workspace_id" ], - "tableTo": "project_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issues_goal_id_goals_id_fk": { "name": "issues_goal_id_goals_id_fk", "tableFrom": "issues", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_parent_id_issues_id_fk": { "name": "issues_parent_id_issues_id_fk", "tableFrom": "issues", + "tableTo": "issues", "columnsFrom": [ "parent_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_privacy_root_issue_id_issues_id_fk": { "name": "issues_privacy_root_issue_id_issues_id_fk", "tableFrom": "issues", + "tableTo": "issues", "columnsFrom": [ "privacy_root_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_privacy_parent_issue_id_issues_id_fk": { "name": "issues_privacy_parent_issue_id_issues_id_fk", "tableFrom": "issues", + "tableTo": "issues", "columnsFrom": [ "privacy_parent_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issues_assignee_agent_id_agents_id_fk": { "name": "issues_assignee_agent_id_agents_id_fk", "tableFrom": "issues", + "tableTo": "agents", "columnsFrom": [ "assignee_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "issues_checkout_run_id_heartbeat_runs_id_fk": { "name": "issues_checkout_run_id_heartbeat_runs_id_fk", "tableFrom": "issues", + "tableTo": "heartbeat_runs", "columnsFrom": [ "checkout_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issues_execution_run_id_heartbeat_runs_id_fk": { "name": "issues_execution_run_id_heartbeat_runs_id_fk", "tableFrom": "issues", + "tableTo": "heartbeat_runs", "columnsFrom": [ "execution_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issues_created_by_agent_id_agents_id_fk": { "name": "issues_created_by_agent_id_agents_id_fk", "tableFrom": "issues", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" + }, + "issues_claim_holder_agent_id_agents_id_fk": { + "name": "issues_claim_holder_agent_id_agents_id_fk", + "tableFrom": "issues", + "tableTo": "agents", + "columnsFrom": [ + "claim_holder_agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" }, "issues_origin_issue_id_issues_id_fk": { "name": "issues_origin_issue_id_issues_id_fk", "tableFrom": "issues", + "tableTo": "issues", "columnsFrom": [ "origin_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "issues_execution_workspace_id_execution_workspaces_id_fk": { "name": "issues_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "issues", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "issues_company_id_uq": { "name": "issues_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -45398,9 +46983,17 @@ "name": "issues_visibility_check", "value": "\"issues\".\"visibility\" in ('open', 'private')" }, + "issues_scope_check": { + "name": "issues_scope_check", + "value": "\"issues\".\"scope\" in ('board', 'channel', 'agent', 'chat')" + }, "issues_conversation_identity_check": { "name": "issues_conversation_identity_check", "value": "(\n \"issues\".\"conversation_agent_id\" is null and \"issues\".\"conversation_user_id\" is null and \"issues\".\"conversation_state\" is null\n ) or (\n \"issues\".\"conversation_agent_id\" is not null and \"issues\".\"conversation_user_id\" is not null\n and \"issues\".\"assignee_agent_id\" = \"issues\".\"conversation_agent_id\" and \"issues\".\"assignee_agent_id\" is not null\n and \"issues\".\"assignee_user_id\" is null and \"issues\".\"conversation_state\" is not null\n and \"issues\".\"conversation_state\" in ('active', 'waiting')\n and \"issues\".\"status\" not in ('done', 'cancelled')\n )" + }, + "issues_conversation_channel_exclusion_check": { + "name": "issues_conversation_channel_exclusion_check", + "value": "(\"issues\".\"conversation_agent_id\" is null) or (\"issues\".\"channel_id\" is null)" } }, "isRLSEnabled": false @@ -45564,10 +47157,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"join_requests\".\"status\" = 'pending_approval'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "join_requests_invite_unique_idx": { "name": "join_requests_invite_unique_idx", @@ -45580,9 +47173,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "join_requests_company_status_type_created_idx": { "name": "join_requests_company_status_type_created_idx", @@ -45613,9 +47206,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "join_requests_pending_human_user_uq": { "name": "join_requests_pending_human_user_uq", @@ -45634,10 +47227,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"join_requests\".\"request_type\" = 'human' AND \"join_requests\".\"status\" = 'pending_approval' AND \"join_requests\".\"requesting_user_id\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "join_requests_pending_human_email_uq": { "name": "join_requests_pending_human_email_uq", @@ -45650,57 +47243,57 @@ }, { "expression": "lower(\"request_email_snapshot\")", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"join_requests\".\"request_type\" = 'human' AND \"join_requests\".\"status\" = 'pending_approval' AND \"join_requests\".\"request_email_snapshot\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "join_requests_invite_id_invites_id_fk": { "name": "join_requests_invite_id_invites_id_fk", "tableFrom": "join_requests", + "tableTo": "invites", "columnsFrom": [ "invite_id" ], - "tableTo": "invites", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "join_requests_company_id_companies_id_fk": { "name": "join_requests_company_id_companies_id_fk", "tableFrom": "join_requests", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "join_requests_created_agent_id_agents_id_fk": { "name": "join_requests_created_agent_id_agents_id_fk", "tableFrom": "join_requests", + "tableTo": "agents", "columnsFrom": [ "created_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -45765,9 +47358,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "labels_company_name_idx": { "name": "labels_company_name_idx", @@ -45786,24 +47379,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "labels_company_id_companies_id_fk": { "name": "labels_company_id_companies_id_fk", "tableFrom": "labels", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -45903,24 +47496,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "link_previews_company_id_companies_id_fk": { "name": "link_previews_company_id_companies_id_fk", "tableFrom": "link_previews", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -46070,9 +47663,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "managed_agent_profiles_company_key_uq": { "name": "managed_agent_profiles_company_key_uq", @@ -46091,9 +47684,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "managed_agent_profiles_company_resource_uq": { "name": "managed_agent_profiles_company_resource_uq", @@ -46124,37 +47717,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "managed_agent_profiles_company_id_companies_id_fk": { "name": "managed_agent_profiles_company_id_companies_id_fk", "tableFrom": "managed_agent_profiles", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "managed_agent_profiles_api_key_secret_id_company_secrets_id_fk": { "name": "managed_agent_profiles_api_key_secret_id_company_secrets_id_fk", "tableFrom": "managed_agent_profiles", + "tableTo": "company_secrets", "columnsFrom": [ "api_key_secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -46267,10 +47860,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"native_harness_backups\".\"status\" = 'current'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_harness_backups_scope_idx": { "name": "native_harness_backups_scope_idx", @@ -46295,9 +47888,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -46368,9 +47961,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "native_provider_artifact_references_run_idx": { "name": "native_provider_artifact_references_run_idx", @@ -46395,10 +47988,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"native_provider_artifact_references\".\"backup_id\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_provider_artifact_references_backup_idx": { "name": "native_provider_artifact_references_backup_idx", @@ -46423,38 +48016,38 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"native_provider_artifact_references\".\"backup_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "native_provider_artifact_references_artifact_id_native_provider_artifacts_id_fk": { "name": "native_provider_artifact_references_artifact_id_native_provider_artifacts_id_fk", "tableFrom": "native_provider_artifact_references", + "tableTo": "native_provider_artifacts", "columnsFrom": [ "artifact_id" ], - "tableTo": "native_provider_artifacts", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "native_provider_artifact_references_backup_id_native_harness_backups_id_fk": { "name": "native_provider_artifact_references_backup_id_native_harness_backups_id_fk", "tableFrom": "native_provider_artifact_references", + "tableTo": "native_harness_backups", "columnsFrom": [ "backup_id" ], - "tableTo": "native_harness_backups", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -46544,10 +48137,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"native_provider_artifacts\".\"status\" = 'ready'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": {}, @@ -46741,10 +48334,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"decision_id\" is not null AND \"native_run_finalizations\".\"result_id\" is not null AND \"native_run_finalizations\".\"phase\" <> 'terminal_failure'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_run_finalizations_unsafe_export_recovery_idx": { "name": "native_run_finalizations_unsafe_export_recovery_idx", @@ -46769,10 +48362,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"phase\" = 'terminal_failure' AND \"native_run_finalizations\".\"failure_code\" = 'native_workspace_sync_out_unsafe_archive'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_run_finalizations_finalizer_lease_idx": { "name": "native_run_finalizations_finalizer_lease_idx", @@ -46785,10 +48378,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"lease_owner\" like 'native-finalizer:%'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_run_finalizations_cleanup_lease_idx": { "name": "native_run_finalizations_cleanup_lease_idx", @@ -46801,10 +48394,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"lease_owner\" like 'native-cleanup:%'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_run_finalizations_accepted_result_lease_idx": { "name": "native_run_finalizations_accepted_result_lease_idx", @@ -46817,10 +48410,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"result_id\" is not null AND \"native_run_finalizations\".\"lease_owner\" is not null AND \"native_run_finalizations\".\"phase\" not in ('committed', 'terminal_failure', 'applied')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "native_run_finalizations_control_deadline_idx": { "name": "native_run_finalizations_control_deadline_idx", @@ -46833,99 +48426,100 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_run_finalizations\".\"control_deadline_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "native_run_finalizations_company_id_companies_id_fk": { "name": "native_run_finalizations_company_id_companies_id_fk", "tableFrom": "native_run_finalizations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_finalizations_issue_company_fk": { "name": "native_run_finalizations_issue_company_fk", "tableFrom": "native_run_finalizations", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_finalizations_run_owner_fk": { "name": "native_run_finalizations_run_owner_fk", "tableFrom": "native_run_finalizations", + "tableTo": "heartbeat_runs", "columnsFrom": [ "company_id", "issue_id", "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "company_id", "native_issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_finalizations_result_owner_fk": { "name": "native_run_finalizations_result_owner_fk", "tableFrom": "native_run_finalizations", + "tableTo": "native_run_results", "columnsFrom": [ "company_id", "issue_id", "run_id", "result_id" ], - "tableTo": "native_run_results", "columnsTo": [ "company_id", "issue_id", "run_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_finalizations_assessment_owner_fk": { "name": "native_run_finalizations_assessment_owner_fk", "tableFrom": "native_run_finalizations", + "tableTo": "work_assessments", "columnsFrom": [ "company_id", "issue_id", "run_id", "assessment_id" ], - "tableTo": "work_assessments", "columnsTo": [ "company_id", "issue_id", "run_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_finalizations_decision_owner_fk": { "name": "native_run_finalizations_decision_owner_fk", "tableFrom": "native_run_finalizations", + "tableTo": "status_decisions", "columnsFrom": [ "company_id", "issue_id", @@ -46933,7 +48527,6 @@ "assessment_id", "decision_id" ], - "tableTo": "status_decisions", "columnsTo": [ "company_id", "issue_id", @@ -46941,8 +48534,8 @@ "assessment_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -47069,9 +48662,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "native_run_results_run_caller_result_uq": { "name": "native_run_results_run_caller_result_uq", @@ -47090,9 +48683,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "native_run_results_run_caller_dedupe_uq": { "name": "native_run_results_run_caller_dedupe_uq", @@ -47111,88 +48704,88 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "native_run_results_company_id_companies_id_fk": { "name": "native_run_results_company_id_companies_id_fk", "tableFrom": "native_run_results", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_results_issue_company_fk": { "name": "native_run_results_issue_company_fk", "tableFrom": "native_run_results", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_results_run_contract_owner_fk": { "name": "native_run_results_run_contract_owner_fk", "tableFrom": "native_run_results", + "tableTo": "heartbeat_runs", "columnsFrom": [ "company_id", "issue_id", "run_id", "completion_contract_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "company_id", "native_issue_id", "id", "completion_contract_id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "native_run_results_completion_contract_owner_fk": { "name": "native_run_results_completion_contract_owner_fk", "tableFrom": "native_run_results", + "tableTo": "completion_contracts", "columnsFrom": [ "company_id", "issue_id", "completion_contract_id" ], - "tableTo": "completion_contracts", "columnsTo": [ "company_id", "issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "native_run_results_company_issue_run_id_uq": { "name": "native_run_results_company_issue_run_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "issue_id", "run_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -47253,29 +48846,29 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"native_runner_checkpoints\".\"part\" = 'header'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "native_runner_checkpoints_company_id_issue_id_run_id_heartbeat_runs_company_id_native_issue_id_id_fk": { "name": "native_runner_checkpoints_company_id_issue_id_run_id_heartbeat_runs_company_id_native_issue_id_id_fk", "tableFrom": "native_runner_checkpoints", + "tableTo": "heartbeat_runs", "columnsFrom": [ "company_id", "issue_id", "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "company_id", "native_issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -47403,9 +48996,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_automation_executions_company_case_idx": { "name": "pipeline_automation_executions_company_case_idx", @@ -47424,9 +49017,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_automation_executions_routine_idx": { "name": "pipeline_automation_executions_routine_idx", @@ -47439,9 +49032,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_automation_executions_execution_issue_idx": { "name": "pipeline_automation_executions_execution_issue_idx", @@ -47454,9 +49047,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_automation_executions_retry_of_execution_idx": { "name": "pipeline_automation_executions_retry_of_execution_idx", @@ -47469,63 +49062,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_automation_executions_company_id_companies_id_fk": { "name": "pipeline_automation_executions_company_id_companies_id_fk", "tableFrom": "pipeline_automation_executions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_automation_executions_case_id_pipeline_cases_id_fk": { "name": "pipeline_automation_executions_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_automation_executions", + "tableTo": "pipeline_cases", "columnsFrom": [ "case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_automation_executions_routine_id_routines_id_fk": { "name": "pipeline_automation_executions_routine_id_routines_id_fk", "tableFrom": "pipeline_automation_executions", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_automation_executions_execution_issue_id_issues_id_fk": { "name": "pipeline_automation_executions_execution_issue_id_issues_id_fk", "tableFrom": "pipeline_automation_executions", + "tableTo": "issues", "columnsFrom": [ "execution_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -47601,9 +49194,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_blockers_blocked_by_idx": { "name": "pipeline_case_blockers_blocked_by_idx", @@ -47616,9 +49209,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_blockers_company_case_idx": { "name": "pipeline_case_blockers_company_case_idx", @@ -47637,50 +49230,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_case_blockers_company_id_companies_id_fk": { "name": "pipeline_case_blockers_company_id_companies_id_fk", "tableFrom": "pipeline_case_blockers", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_blockers_case_id_pipeline_cases_id_fk": { "name": "pipeline_case_blockers_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_case_blockers", + "tableTo": "pipeline_cases", "columnsFrom": [ "case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_blockers_blocked_by_case_id_pipeline_cases_id_fk": { "name": "pipeline_case_blockers_blocked_by_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_case_blockers", + "tableTo": "pipeline_cases", "columnsFrom": [ "blocked_by_case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -47768,9 +49361,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_documents_document_uq": { "name": "pipeline_case_documents_document_uq", @@ -47783,9 +49376,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_documents_company_case_updated_idx": { "name": "pipeline_case_documents_company_case_updated_idx", @@ -47810,50 +49403,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_case_documents_company_id_companies_id_fk": { "name": "pipeline_case_documents_company_id_companies_id_fk", "tableFrom": "pipeline_case_documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_documents_case_id_pipeline_cases_id_fk": { "name": "pipeline_case_documents_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_case_documents", + "tableTo": "pipeline_cases", "columnsFrom": [ "case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_documents_document_id_documents_id_fk": { "name": "pipeline_case_documents_document_id_documents_id_fk", "tableFrom": "pipeline_case_documents", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -47967,9 +49560,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_events_company_case_idx": { "name": "pipeline_case_events_company_case_idx", @@ -47988,76 +49581,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_case_events_company_id_companies_id_fk": { "name": "pipeline_case_events_company_id_companies_id_fk", "tableFrom": "pipeline_case_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_events_case_id_pipeline_cases_id_fk": { "name": "pipeline_case_events_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_case_events", + "tableTo": "pipeline_cases", "columnsFrom": [ "case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_events_actor_agent_id_agents_id_fk": { "name": "pipeline_case_events_actor_agent_id_agents_id_fk", "tableFrom": "pipeline_case_events", + "tableTo": "agents", "columnsFrom": [ "actor_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "pipeline_case_events_from_stage_id_pipeline_stages_id_fk": { "name": "pipeline_case_events_from_stage_id_pipeline_stages_id_fk", "tableFrom": "pipeline_case_events", + "tableTo": "pipeline_stages", "columnsFrom": [ "from_stage_id" ], - "tableTo": "pipeline_stages", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "pipeline_case_events_to_stage_id_pipeline_stages_id_fk": { "name": "pipeline_case_events_to_stage_id_pipeline_stages_id_fk", "tableFrom": "pipeline_case_events", + "tableTo": "pipeline_stages", "columnsFrom": [ "to_stage_id" ], - "tableTo": "pipeline_stages", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -48177,9 +49770,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_issue_links_issue_idx": { "name": "pipeline_case_issue_links_issue_idx", @@ -48192,9 +49785,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_issue_links_company_case_idx": { "name": "pipeline_case_issue_links_company_case_idx", @@ -48213,9 +49806,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_case_issue_links_automation_attempt_idx": { "name": "pipeline_case_issue_links_automation_attempt_idx", @@ -48228,50 +49821,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_case_issue_links_company_id_companies_id_fk": { "name": "pipeline_case_issue_links_company_id_companies_id_fk", "tableFrom": "pipeline_case_issue_links", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_issue_links_case_id_pipeline_cases_id_fk": { "name": "pipeline_case_issue_links_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_case_issue_links", + "tableTo": "pipeline_cases", "columnsFrom": [ "case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_case_issue_links_issue_id_issues_id_fk": { "name": "pipeline_case_issue_links_issue_id_issues_id_fk", "tableFrom": "pipeline_case_issue_links", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -48513,9 +50106,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_parent_request_key_uq": { "name": "pipeline_cases_parent_request_key_uq", @@ -48534,10 +50127,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"pipeline_cases\".\"request_key\" is not null and \"pipeline_cases\".\"retired_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "pipeline_cases_company_idx": { "name": "pipeline_cases_company_idx", @@ -48550,9 +50143,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_pipeline_stage_idx": { "name": "pipeline_cases_pipeline_stage_idx", @@ -48571,9 +50164,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_parent_idx": { "name": "pipeline_cases_parent_idx", @@ -48586,9 +50179,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_automation_attempt_idx": { "name": "pipeline_cases_automation_attempt_idx", @@ -48601,9 +50194,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_retired_idx": { "name": "pipeline_cases_retired_idx", @@ -48622,9 +50215,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_cases_lease_expires_idx": { "name": "pipeline_cases_lease_expires_idx", @@ -48637,90 +50230,90 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"pipeline_cases\".\"lease_expires_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "pipeline_cases_company_id_companies_id_fk": { "name": "pipeline_cases_company_id_companies_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_cases_pipeline_id_pipelines_id_fk": { "name": "pipeline_cases_pipeline_id_pipelines_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "pipelines", "columnsFrom": [ "pipeline_id" ], - "tableTo": "pipelines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_cases_stage_id_pipeline_stages_id_fk": { "name": "pipeline_cases_stage_id_pipeline_stages_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "pipeline_stages", "columnsFrom": [ "stage_id" ], - "tableTo": "pipeline_stages", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "pipeline_cases_parent_case_id_pipeline_cases_id_fk": { "name": "pipeline_cases_parent_case_id_pipeline_cases_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "pipeline_cases", "columnsFrom": [ "parent_case_id" ], - "tableTo": "pipeline_cases", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "pipeline_cases_lease_agent_id_agents_id_fk": { "name": "pipeline_cases_lease_agent_id_agents_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "agents", "columnsFrom": [ "lease_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "pipeline_cases_created_by_agent_id_agents_id_fk": { "name": "pipeline_cases_created_by_agent_id_agents_id_fk", "tableFrom": "pipeline_cases", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -48812,9 +50405,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_documents_document_uq": { "name": "pipeline_documents_document_uq", @@ -48827,9 +50420,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_documents_company_pipeline_updated_idx": { "name": "pipeline_documents_company_pipeline_updated_idx", @@ -48854,50 +50447,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_documents_company_id_companies_id_fk": { "name": "pipeline_documents_company_id_companies_id_fk", "tableFrom": "pipeline_documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_documents_pipeline_id_pipelines_id_fk": { "name": "pipeline_documents_pipeline_id_pipelines_id_fk", "tableFrom": "pipeline_documents", + "tableTo": "pipelines", "columnsFrom": [ "pipeline_id" ], - "tableTo": "pipelines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_documents_document_id_documents_id_fk": { "name": "pipeline_documents_document_id_documents_id_fk", "tableFrom": "pipeline_documents", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -48987,9 +50580,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_stages_pipeline_position_idx": { "name": "pipeline_stages_pipeline_position_idx", @@ -49008,24 +50601,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_stages_pipeline_id_pipelines_id_fk": { "name": "pipeline_stages_pipeline_id_pipelines_id_fk", "tableFrom": "pipeline_stages", + "tableTo": "pipelines", "columnsFrom": [ "pipeline_id" ], - "tableTo": "pipelines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49113,9 +50706,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_transitions_pipeline_from_idx": { "name": "pipeline_transitions_pipeline_from_idx", @@ -49134,9 +50727,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipeline_transitions_pipeline_to_idx": { "name": "pipeline_transitions_pipeline_to_idx", @@ -49155,50 +50748,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipeline_transitions_pipeline_id_pipelines_id_fk": { "name": "pipeline_transitions_pipeline_id_pipelines_id_fk", "tableFrom": "pipeline_transitions", + "tableTo": "pipelines", "columnsFrom": [ "pipeline_id" ], - "tableTo": "pipelines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_transitions_from_stage_id_pipeline_stages_id_fk": { "name": "pipeline_transitions_from_stage_id_pipeline_stages_id_fk", "tableFrom": "pipeline_transitions", + "tableTo": "pipeline_stages", "columnsFrom": [ "from_stage_id" ], - "tableTo": "pipeline_stages", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipeline_transitions_to_stage_id_pipeline_stages_id_fk": { "name": "pipeline_transitions_to_stage_id_pipeline_stages_id_fk", "tableFrom": "pipeline_transitions", + "tableTo": "pipeline_stages", "columnsFrom": [ "to_stage_id" ], - "tableTo": "pipeline_stages", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49306,9 +50899,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipelines_company_idx": { "name": "pipelines_company_idx", @@ -49321,9 +50914,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "pipelines_company_project_idx": { "name": "pipelines_company_project_idx", @@ -49342,50 +50935,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "pipelines_company_id_companies_id_fk": { "name": "pipelines_company_id_companies_id_fk", "tableFrom": "pipelines", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "pipelines_project_id_projects_id_fk": { "name": "pipelines_project_id_projects_id_fk", "tableFrom": "pipelines", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "pipelines_created_by_agent_id_agents_id_fk": { "name": "pipelines_created_by_agent_id_agents_id_fk", "tableFrom": "pipelines", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49464,9 +51057,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_company_settings_plugin_idx": { "name": "plugin_company_settings_plugin_idx", @@ -49479,9 +51072,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_company_settings_company_plugin_uq": { "name": "plugin_company_settings_company_plugin_uq", @@ -49500,37 +51093,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_company_settings_company_id_companies_id_fk": { "name": "plugin_company_settings_company_id_companies_id_fk", "tableFrom": "plugin_company_settings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_company_settings_plugin_id_plugins_id_fk": { "name": "plugin_company_settings_plugin_id_plugins_id_fk", "tableFrom": "plugin_company_settings", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49608,37 +51201,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_config_plugin_id_plugins_id_fk": { "name": "plugin_config_plugin_id_plugins_id_fk", "tableFrom": "plugin_config", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_config_company_id_companies_id_fk": { "name": "plugin_config_company_id_companies_id_fk", "tableFrom": "plugin_config", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49717,9 +51310,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_database_namespaces_namespace_idx": { "name": "plugin_database_namespaces_namespace_idx", @@ -49732,9 +51325,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_database_namespaces_status_idx": { "name": "plugin_database_namespaces_status_idx", @@ -49747,24 +51340,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_database_namespaces_plugin_id_plugins_id_fk": { "name": "plugin_database_namespaces_plugin_id_plugins_id_fk", "tableFrom": "plugin_database_namespaces", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -49866,9 +51459,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_entities_company_idx": { "name": "plugin_entities_company_idx", @@ -49881,9 +51474,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_entities_type_idx": { "name": "plugin_entities_type_idx", @@ -49896,9 +51489,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_entities_scope_idx": { "name": "plugin_entities_scope_idx", @@ -49917,50 +51510,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_entities_plugin_id_plugins_id_fk": { "name": "plugin_entities_plugin_id_plugins_id_fk", "tableFrom": "plugin_entities", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_entities_company_id_companies_id_fk": { "name": "plugin_entities_company_id_companies_id_fk", "tableFrom": "plugin_entities", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "plugin_entities_external_idx": { "name": "plugin_entities_external_idx", + "nullsNotDistinct": true, "columns": [ "company_id", "plugin_id", "entity_type", "external_id" - ], - "nullsNotDistinct": true + ] } }, "policies": {}, @@ -50060,9 +51653,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_job_runs_plugin_idx": { "name": "plugin_job_runs_plugin_idx", @@ -50075,9 +51668,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_job_runs_company_idx": { "name": "plugin_job_runs_company_idx", @@ -50090,9 +51683,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_job_runs_status_idx": { "name": "plugin_job_runs_status_idx", @@ -50105,50 +51698,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_job_runs_job_id_plugin_jobs_id_fk": { "name": "plugin_job_runs_job_id_plugin_jobs_id_fk", "tableFrom": "plugin_job_runs", + "tableTo": "plugin_jobs", "columnsFrom": [ "job_id" ], - "tableTo": "plugin_jobs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_job_runs_plugin_id_plugins_id_fk": { "name": "plugin_job_runs_plugin_id_plugins_id_fk", "tableFrom": "plugin_job_runs", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_job_runs_company_id_companies_id_fk": { "name": "plugin_job_runs_company_id_companies_id_fk", "tableFrom": "plugin_job_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -50232,9 +51825,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_jobs_next_run_idx": { "name": "plugin_jobs_next_run_idx", @@ -50247,9 +51840,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_jobs_unique_idx": { "name": "plugin_jobs_unique_idx", @@ -50268,24 +51861,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_jobs_plugin_id_plugins_id_fk": { "name": "plugin_jobs_plugin_id_plugins_id_fk", "tableFrom": "plugin_jobs", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -50330,37 +51923,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_lifecycle_acknowledgments_plugin_id_plugins_id_fk": { "name": "plugin_lifecycle_acknowledgments_plugin_id_plugins_id_fk", "tableFrom": "plugin_lifecycle_acknowledgments", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_lifecycle_acknowledgments_event_id_resource_lifecycle_events_id_fk": { "name": "plugin_lifecycle_acknowledgments_event_id_resource_lifecycle_events_id_fk", "tableFrom": "plugin_lifecycle_acknowledgments", + "tableTo": "resource_lifecycle_events", "columnsFrom": [ "event_id" ], - "tableTo": "resource_lifecycle_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -50424,28 +52017,28 @@ "plugin_lifecycle_resource_cursors_plugin_id_plugins_id_fk": { "name": "plugin_lifecycle_resource_cursors_plugin_id_plugins_id_fk", "tableFrom": "plugin_lifecycle_resource_cursors", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_lifecycle_resource_cursors_company_id_companies_id_fk": { "name": "plugin_lifecycle_resource_cursors_company_id_companies_id_fk", "tableFrom": "plugin_lifecycle_resource_cursors", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -50532,9 +52125,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_logs_company_idx": { "name": "plugin_logs_company_idx", @@ -50547,9 +52140,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_logs_level_idx": { "name": "plugin_logs_level_idx", @@ -50562,37 +52155,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_logs_plugin_id_plugins_id_fk": { "name": "plugin_logs_plugin_id_plugins_id_fk", "tableFrom": "plugin_logs", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_logs_company_id_companies_id_fk": { "name": "plugin_logs_company_id_companies_id_fk", "tableFrom": "plugin_logs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -50682,9 +52275,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_managed_resources_plugin_idx": { "name": "plugin_managed_resources_plugin_idx", @@ -50697,9 +52290,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_managed_resources_resource_idx": { "name": "plugin_managed_resources_resource_idx", @@ -50718,9 +52311,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_managed_resources_company_plugin_resource_uq": { "name": "plugin_managed_resources_company_plugin_resource_uq", @@ -50751,37 +52344,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_managed_resources_company_id_companies_id_fk": { "name": "plugin_managed_resources_company_id_companies_id_fk", "tableFrom": "plugin_managed_resources", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_managed_resources_plugin_id_plugins_id_fk": { "name": "plugin_managed_resources_plugin_id_plugins_id_fk", "tableFrom": "plugin_managed_resources", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -50881,9 +52474,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_migrations_plugin_idx": { "name": "plugin_migrations_plugin_idx", @@ -50896,9 +52489,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_migrations_status_idx": { "name": "plugin_migrations_status_idx", @@ -50911,24 +52504,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_migrations_plugin_id_plugins_id_fk": { "name": "plugin_migrations_plugin_id_plugins_id_fk", "tableFrom": "plugin_migrations", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -51011,38 +52604,38 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_state_plugin_id_plugins_id_fk": { "name": "plugin_state_plugin_id_plugins_id_fk", "tableFrom": "plugin_state", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "plugin_state_unique_entry_idx": { "name": "plugin_state_unique_entry_idx", + "nullsNotDistinct": true, "columns": [ "plugin_id", "scope_kind", "scope_id", "namespace", "state_key" - ], - "nullsNotDistinct": true + ] } }, "policies": {}, @@ -51148,9 +52741,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_webhook_deliveries_company_idx": { "name": "plugin_webhook_deliveries_company_idx", @@ -51163,9 +52756,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_webhook_deliveries_status_idx": { "name": "plugin_webhook_deliveries_status_idx", @@ -51178,9 +52771,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugin_webhook_deliveries_key_idx": { "name": "plugin_webhook_deliveries_key_idx", @@ -51193,37 +52786,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_webhook_deliveries_plugin_id_plugins_id_fk": { "name": "plugin_webhook_deliveries_plugin_id_plugins_id_fk", "tableFrom": "plugin_webhook_deliveries", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_webhook_deliveries_company_id_companies_id_fk": { "name": "plugin_webhook_deliveries_company_id_companies_id_fk", "tableFrom": "plugin_webhook_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -51333,9 +52926,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "plugins_status_idx": { "name": "plugins_status_idx", @@ -51348,9 +52941,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -51452,9 +53045,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "principal_permission_grants_company_permission_idx": { "name": "principal_permission_grants_company_permission_idx", @@ -51473,24 +53066,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "principal_permission_grants_company_id_companies_id_fk": { "name": "principal_permission_grants_company_id_companies_id_fk", "tableFrom": "principal_permission_grants", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -51566,9 +53159,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_access_members_subject_lookup_idx": { "name": "project_access_members_subject_lookup_idx", @@ -51599,37 +53192,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "project_access_members_company_id_companies_id_fk": { "name": "project_access_members_company_id_companies_id_fk", "tableFrom": "project_access_members", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_access_members_project_id_projects_id_fk": { "name": "project_access_members_project_id_projects_id_fk", "tableFrom": "project_access_members", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -51692,9 +53285,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_goals_goal_idx": { "name": "project_goals_goal_idx", @@ -51707,9 +53300,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_goals_company_idx": { "name": "project_goals_company_idx", @@ -51722,50 +53315,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "project_goals_project_id_projects_id_fk": { "name": "project_goals_project_id_projects_id_fk", "tableFrom": "project_goals", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_goals_goal_id_goals_id_fk": { "name": "project_goals_goal_id_goals_id_fk", "tableFrom": "project_goals", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_goals_company_id_companies_id_fk": { "name": "project_goals_company_id_companies_id_fk", "tableFrom": "project_goals", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": { @@ -51857,9 +53450,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_memberships_company_user_starred_idx": { "name": "project_memberships_company_user_starred_idx", @@ -51884,9 +53477,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_memberships_project_idx": { "name": "project_memberships_project_idx", @@ -51899,9 +53492,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_memberships_company_user_project_uq": { "name": "project_memberships_company_user_project_uq", @@ -51926,37 +53519,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "project_memberships_company_id_companies_id_fk": { "name": "project_memberships_company_id_companies_id_fk", "tableFrom": "project_memberships", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "project_memberships_project_id_projects_id_fk": { "name": "project_memberships_project_id_projects_id_fk", "tableFrom": "project_memberships", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -52108,9 +53701,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_workspaces_project_primary_idx": { "name": "project_workspaces_project_primary_idx", @@ -52129,9 +53722,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_workspaces_project_source_type_idx": { "name": "project_workspaces_project_source_type_idx", @@ -52150,9 +53743,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_workspaces_company_shared_key_idx": { "name": "project_workspaces_company_shared_key_idx", @@ -52171,9 +53764,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "project_workspaces_project_remote_ref_idx": { "name": "project_workspaces_project_remote_ref_idx", @@ -52198,37 +53791,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "project_workspaces_company_id_companies_id_fk": { "name": "project_workspaces_company_id_companies_id_fk", "tableFrom": "project_workspaces", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "project_workspaces_project_id_projects_id_fk": { "name": "project_workspaces_project_id_projects_id_fk", "tableFrom": "project_workspaces", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -52409,9 +54002,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "projects_company_idx": { "name": "projects_company_idx", @@ -52424,9 +54017,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "projects_company_personal_owner_uq": { "name": "projects_company_personal_owner_uq", @@ -52445,77 +54038,77 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"projects\".\"personal_owner_user_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "projects_company_id_companies_id_fk": { "name": "projects_company_id_companies_id_fk", "tableFrom": "projects", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "projects_goal_id_goals_id_fk": { "name": "projects_goal_id_goals_id_fk", "tableFrom": "projects", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "projects_lead_agent_id_agents_id_fk": { "name": "projects_lead_agent_id_agents_id_fk", "tableFrom": "projects", + "tableTo": "agents", "columnsFrom": [ "lead_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "projects_environment_id_environments_id_fk": { "name": "projects_environment_id_environments_id_fk", "tableFrom": "projects", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "projects_git_authorization_grant_id_connection_grants_id_fk": { "name": "projects_git_authorization_grant_id_connection_grants_id_fk", "tableFrom": "projects", + "tableTo": "connection_grants", "columnsFrom": [ "git_authorization_grant_id" ], - "tableTo": "connection_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -52642,9 +54235,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "provider_trace_records_expiry_idx": { "name": "provider_trace_records_expiry_idx", @@ -52663,9 +54256,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "provider_trace_records_company_created_idx": { "name": "provider_trace_records_company_created_idx", @@ -52684,37 +54277,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "provider_trace_records_company_id_companies_id_fk": { "name": "provider_trace_records_company_id_companies_id_fk", "tableFrom": "provider_trace_records", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "provider_trace_records_run_id_heartbeat_runs_id_fk": { "name": "provider_trace_records_run_id_heartbeat_runs_id_fk", "tableFrom": "provider_trace_records", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -52825,9 +54418,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "remote_agent_profiles_company_key_uq": { "name": "remote_agent_profiles_company_key_uq", @@ -52846,24 +54439,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "remote_agent_profiles_company_id_companies_id_fk": { "name": "remote_agent_profiles_company_id_companies_id_fk", "tableFrom": "remote_agent_profiles", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -52891,15 +54484,15 @@ "primaryKey": true, "notNull": true, "identity": { + "type": "always", "name": "resource_lifecycle_events_id_seq", + "schema": "public", "increment": "1", + "startWith": "1", "minValue": "1", "maxValue": "9223372036854775807", - "startWith": "1", "cache": "1", - "cycle": false, - "schema": "public", - "type": "always" + "cycle": false } }, "company_id": { @@ -52958,10 +54551,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"resource_lifecycle_events\".\"action\" = 'create'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "resource_lifecycle_events_company_idx": { "name": "resource_lifecycle_events_company_idx", @@ -52980,9 +54573,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "resource_lifecycle_events_resource_order_idx": { "name": "resource_lifecycle_events_resource_order_idx", @@ -53013,24 +54606,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "resource_lifecycle_events_company_id_companies_id_fk": { "name": "resource_lifecycle_events_company_id_companies_id_fk", "tableFrom": "resource_lifecycle_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -53246,9 +54839,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibilities_area_idx": { "name": "responsibilities_area_idx", @@ -53261,80 +54854,80 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibilities_company_id_companies_id_fk": { "name": "responsibilities_company_id_companies_id_fk", "tableFrom": "responsibilities", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibilities_area_id_responsibility_areas_id_fk": { "name": "responsibilities_area_id_responsibility_areas_id_fk", "tableFrom": "responsibilities", + "tableTo": "responsibility_areas", "columnsFrom": [ "area_id" ], - "tableTo": "responsibility_areas", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibilities_run_by_agent_id_agents_id_fk": { "name": "responsibilities_run_by_agent_id_agents_id_fk", "tableFrom": "responsibilities", + "tableTo": "agents", "columnsFrom": [ "run_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibilities_proposed_by_agent_id_agents_id_fk": { "name": "responsibilities_proposed_by_agent_id_agents_id_fk", "tableFrom": "responsibilities", + "tableTo": "agents", "columnsFrom": [ "proposed_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibilities_owned_area_fk": { "name": "responsibilities_owned_area_fk", "tableFrom": "responsibilities", + "tableTo": "responsibility_areas", "columnsFrom": [ "company_id", "owner_user_id", "area_id" ], - "tableTo": "responsibility_areas", "columnsTo": [ "company_id", "owner_user_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -53455,9 +55048,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_areas_identity_uq": { "name": "responsibility_areas_identity_uq", @@ -53482,9 +55075,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_areas_owner_title_uq": { "name": "responsibility_areas_owner_title_uq", @@ -53503,44 +55096,44 @@ }, { "expression": "lower(\"title\")", - "isExpression": true, "asc": true, + "isExpression": true, "nulls": "last" } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"responsibility_areas\".\"status\" <> 'archived'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "responsibility_areas_company_id_companies_id_fk": { "name": "responsibility_areas_company_id_companies_id_fk", "tableFrom": "responsibility_areas", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_areas_proposed_by_agent_id_agents_id_fk": { "name": "responsibility_areas_proposed_by_agent_id_agents_id_fk", "tableFrom": "responsibility_areas", + "tableTo": "agents", "columnsFrom": [ "proposed_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -53679,76 +55272,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_dashboard_versions_company_id_companies_id_fk": { "name": "responsibility_dashboard_versions_company_id_companies_id_fk", "tableFrom": "responsibility_dashboard_versions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_dashboard_versions_actor_agent_id_agents_id_fk": { "name": "responsibility_dashboard_versions_actor_agent_id_agents_id_fk", "tableFrom": "responsibility_dashboard_versions", + "tableTo": "agents", "columnsFrom": [ "actor_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibility_dashboard_versions_issue_id_issues_id_fk": { "name": "responsibility_dashboard_versions_issue_id_issues_id_fk", "tableFrom": "responsibility_dashboard_versions", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibility_dashboard_versions_previous_version_id_responsibility_dashboard_versions_id_fk": { "name": "responsibility_dashboard_versions_previous_version_id_responsibility_dashboard_versions_id_fk", "tableFrom": "responsibility_dashboard_versions", + "tableTo": "responsibility_dashboard_versions", "columnsFrom": [ "previous_version_id" ], - "tableTo": "responsibility_dashboard_versions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "responsibility_dashboard_versions_restored_from_version_id_responsibility_dashboard_versions_id_fk": { "name": "responsibility_dashboard_versions_restored_from_version_id_responsibility_dashboard_versions_id_fk", "tableFrom": "responsibility_dashboard_versions", + "tableTo": "responsibility_dashboard_versions", "columnsFrom": [ "restored_from_version_id" ], - "tableTo": "responsibility_dashboard_versions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -53829,9 +55422,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_links_responsibility_project_uq": { "name": "responsibility_links_responsibility_project_uq", @@ -53850,10 +55443,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"responsibility_links\".\"project_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "responsibility_links_responsibility_issue_uq": { "name": "responsibility_links_responsibility_issue_uq", @@ -53872,10 +55465,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"responsibility_links\".\"issue_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "responsibility_links_responsibility_routine_uq": { "name": "responsibility_links_responsibility_routine_uq", @@ -53894,10 +55487,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"responsibility_links\".\"routine_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "responsibility_links_responsibility_skill_uq": { "name": "responsibility_links_responsibility_skill_uq", @@ -53916,10 +55509,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"responsibility_links\".\"skill_id\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "responsibility_links_project_idx": { "name": "responsibility_links_project_idx", @@ -53932,9 +55525,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_links_issue_idx": { "name": "responsibility_links_issue_idx", @@ -53947,9 +55540,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_links_routine_idx": { "name": "responsibility_links_routine_idx", @@ -53962,9 +55555,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_links_skill_idx": { "name": "responsibility_links_skill_idx", @@ -53977,89 +55570,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_links_company_id_companies_id_fk": { "name": "responsibility_links_company_id_companies_id_fk", "tableFrom": "responsibility_links", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_links_responsibility_id_responsibilities_id_fk": { "name": "responsibility_links_responsibility_id_responsibilities_id_fk", "tableFrom": "responsibility_links", + "tableTo": "responsibilities", "columnsFrom": [ "responsibility_id" ], - "tableTo": "responsibilities", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_links_project_id_projects_id_fk": { "name": "responsibility_links_project_id_projects_id_fk", "tableFrom": "responsibility_links", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_links_issue_id_issues_id_fk": { "name": "responsibility_links_issue_id_issues_id_fk", "tableFrom": "responsibility_links", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_links_routine_id_routines_id_fk": { "name": "responsibility_links_routine_id_routines_id_fk", "tableFrom": "responsibility_links", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_links_skill_id_company_skills_id_fk": { "name": "responsibility_links_skill_id_company_skills_id_fk", "tableFrom": "responsibility_links", + "tableTo": "company_skills", "columnsFrom": [ "skill_id" ], - "tableTo": "company_skills", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -54153,50 +55746,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_metric_readings_company_id_companies_id_fk": { "name": "responsibility_metric_readings_company_id_companies_id_fk", "tableFrom": "responsibility_metric_readings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_metric_readings_metric_id_responsibility_metrics_id_fk": { "name": "responsibility_metric_readings_metric_id_responsibility_metrics_id_fk", "tableFrom": "responsibility_metric_readings", + "tableTo": "responsibility_metrics", "columnsFrom": [ "metric_id" ], - "tableTo": "responsibility_metrics", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_metric_readings_recorded_by_agent_id_agents_id_fk": { "name": "responsibility_metric_readings_recorded_by_agent_id_agents_id_fk", "tableFrom": "responsibility_metric_readings", + "tableTo": "agents", "columnsFrom": [ "recorded_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -54329,50 +55922,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_metrics_company_id_companies_id_fk": { "name": "responsibility_metrics_company_id_companies_id_fk", "tableFrom": "responsibility_metrics", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_metrics_responsibility_id_responsibilities_id_fk": { "name": "responsibility_metrics_responsibility_id_responsibilities_id_fk", "tableFrom": "responsibility_metrics", + "tableTo": "responsibilities", "columnsFrom": [ "responsibility_id" ], - "tableTo": "responsibilities", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_metrics_created_by_agent_id_agents_id_fk": { "name": "responsibility_metrics_created_by_agent_id_agents_id_fk", "tableFrom": "responsibility_metrics", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -54473,50 +56066,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_status_reports_company_id_companies_id_fk": { "name": "responsibility_status_reports_company_id_companies_id_fk", "tableFrom": "responsibility_status_reports", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_status_reports_responsibility_id_responsibilities_id_fk": { "name": "responsibility_status_reports_responsibility_id_responsibilities_id_fk", "tableFrom": "responsibility_status_reports", + "tableTo": "responsibilities", "columnsFrom": [ "responsibility_id" ], - "tableTo": "responsibilities", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_status_reports_agent_id_agents_id_fk": { "name": "responsibility_status_reports_agent_id_agents_id_fk", "tableFrom": "responsibility_status_reports", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -54608,9 +56201,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_documents_document_uq": { "name": "routine_documents_document_uq", @@ -54623,9 +56216,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_documents_company_routine_updated_idx": { "name": "routine_documents_company_routine_updated_idx", @@ -54650,50 +56243,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routine_documents_company_id_companies_id_fk": { "name": "routine_documents_company_id_companies_id_fk", "tableFrom": "routine_documents", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "routine_documents_routine_id_routines_id_fk": { "name": "routine_documents_routine_id_routines_id_fk", "tableFrom": "routine_documents", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_documents_document_id_documents_id_fk": { "name": "routine_documents_document_id_documents_id_fk", "tableFrom": "routine_documents", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -54811,9 +56404,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_revisions_company_routine_created_idx": { "name": "routine_revisions_company_routine_created_idx", @@ -54838,9 +56431,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_revisions_company_responsible_user_idx": { "name": "routine_revisions_company_responsible_user_idx", @@ -54865,76 +56458,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routine_revisions_company_id_companies_id_fk": { "name": "routine_revisions_company_id_companies_id_fk", "tableFrom": "routine_revisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_revisions_routine_id_routines_id_fk": { "name": "routine_revisions_routine_id_routines_id_fk", "tableFrom": "routine_revisions", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_revisions_restored_from_revision_id_routine_revisions_id_fk": { "name": "routine_revisions_restored_from_revision_id_routine_revisions_id_fk", "tableFrom": "routine_revisions", + "tableTo": "routine_revisions", "columnsFrom": [ "restored_from_revision_id" ], - "tableTo": "routine_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_revisions_created_by_agent_id_agents_id_fk": { "name": "routine_revisions_created_by_agent_id_agents_id_fk", "tableFrom": "routine_revisions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_revisions_created_by_run_id_heartbeat_runs_id_fk": { "name": "routine_revisions_created_by_run_id_heartbeat_runs_id_fk", "tableFrom": "routine_revisions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "created_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -55091,9 +56684,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_revision_idx": { "name": "routine_runs_revision_idx", @@ -55106,9 +56699,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_company_responsible_user_idx": { "name": "routine_runs_company_responsible_user_idx", @@ -55133,9 +56726,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_trigger_idx": { "name": "routine_runs_trigger_idx", @@ -55154,9 +56747,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_dispatch_fingerprint_idx": { "name": "routine_runs_dispatch_fingerprint_idx", @@ -55175,9 +56768,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_linked_issue_idx": { "name": "routine_runs_linked_issue_idx", @@ -55190,9 +56783,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_runs_trigger_idempotency_idx": { "name": "routine_runs_trigger_idempotency_idx", @@ -55211,76 +56804,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routine_runs_company_id_companies_id_fk": { "name": "routine_runs_company_id_companies_id_fk", "tableFrom": "routine_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_runs_routine_id_routines_id_fk": { "name": "routine_runs_routine_id_routines_id_fk", "tableFrom": "routine_runs", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_runs_trigger_id_routine_triggers_id_fk": { "name": "routine_runs_trigger_id_routine_triggers_id_fk", "tableFrom": "routine_runs", + "tableTo": "routine_triggers", "columnsFrom": [ "trigger_id" ], - "tableTo": "routine_triggers", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_runs_routine_revision_id_routine_revisions_id_fk": { "name": "routine_runs_routine_revision_id_routine_revisions_id_fk", "tableFrom": "routine_runs", + "tableTo": "routine_revisions", "columnsFrom": [ "routine_revision_id" ], - "tableTo": "routine_revisions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_runs_linked_issue_id_issues_id_fk": { "name": "routine_runs_linked_issue_id_issues_id_fk", "tableFrom": "routine_runs", + "tableTo": "issues", "columnsFrom": [ "linked_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -55468,9 +57061,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_triggers_company_kind_idx": { "name": "routine_triggers_company_kind_idx", @@ -55489,9 +57082,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_triggers_next_run_idx": { "name": "routine_triggers_next_run_idx", @@ -55504,9 +57097,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_triggers_public_id_idx": { "name": "routine_triggers_public_id_idx", @@ -55519,9 +57112,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routine_triggers_public_id_uq": { "name": "routine_triggers_public_id_uq", @@ -55534,76 +57127,76 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routine_triggers_company_id_companies_id_fk": { "name": "routine_triggers_company_id_companies_id_fk", "tableFrom": "routine_triggers", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_triggers_routine_id_routines_id_fk": { "name": "routine_triggers_routine_id_routines_id_fk", "tableFrom": "routine_triggers", + "tableTo": "routines", "columnsFrom": [ "routine_id" ], - "tableTo": "routines", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_triggers_secret_id_company_secrets_id_fk": { "name": "routine_triggers_secret_id_company_secrets_id_fk", "tableFrom": "routine_triggers", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_triggers_created_by_agent_id_agents_id_fk": { "name": "routine_triggers_created_by_agent_id_agents_id_fk", "tableFrom": "routine_triggers", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routine_triggers_updated_by_agent_id_agents_id_fk": { "name": "routine_triggers_updated_by_agent_id_agents_id_fk", "tableFrom": "routine_triggers", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -55667,37 +57260,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routine_webhook_test_receipts_company_id_companies_id_fk": { "name": "routine_webhook_test_receipts_company_id_companies_id_fk", "tableFrom": "routine_webhook_test_receipts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routine_webhook_test_receipts_trigger_id_routine_triggers_id_fk": { "name": "routine_webhook_test_receipts_trigger_id_routine_triggers_id_fk", "tableFrom": "routine_webhook_test_receipts", + "tableTo": "routine_triggers", "columnsFrom": [ "trigger_id" ], - "tableTo": "routine_triggers", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -55921,9 +57514,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routines_company_assignee_idx": { "name": "routines_company_assignee_idx", @@ -55942,9 +57535,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routines_company_project_idx": { "name": "routines_company_project_idx", @@ -55963,9 +57556,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routines_company_folder_idx": { "name": "routines_company_folder_idx", @@ -55984,9 +57577,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routines_company_responsible_user_idx": { "name": "routines_company_responsible_user_idx", @@ -56005,9 +57598,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "routines_company_origin_idx": { "name": "routines_company_origin_idx", @@ -56032,115 +57625,115 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "routines_company_id_companies_id_fk": { "name": "routines_company_id_companies_id_fk", "tableFrom": "routines", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routines_project_id_projects_id_fk": { "name": "routines_project_id_projects_id_fk", "tableFrom": "routines", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "routines_folder_id_folders_id_fk": { "name": "routines_folder_id_folders_id_fk", "tableFrom": "routines", + "tableTo": "folders", "columnsFrom": [ "folder_id" ], - "tableTo": "folders", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routines_goal_id_goals_id_fk": { "name": "routines_goal_id_goals_id_fk", "tableFrom": "routines", + "tableTo": "goals", "columnsFrom": [ "goal_id" ], - "tableTo": "goals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routines_parent_issue_id_issues_id_fk": { "name": "routines_parent_issue_id_issues_id_fk", "tableFrom": "routines", + "tableTo": "issues", "columnsFrom": [ "parent_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routines_assignee_agent_id_agents_id_fk": { "name": "routines_assignee_agent_id_agents_id_fk", "tableFrom": "routines", + "tableTo": "agents", "columnsFrom": [ "assignee_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "routines_created_by_agent_id_agents_id_fk": { "name": "routines_created_by_agent_id_agents_id_fk", "tableFrom": "routines", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "routines_updated_by_agent_id_agents_id_fk": { "name": "routines_updated_by_agent_id_agents_id_fk", "tableFrom": "routines", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -56253,9 +57846,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "run_identity_contexts_run_correlation_idx": { "name": "run_identity_contexts_run_correlation_idx", @@ -56274,9 +57867,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "run_identity_contexts_company_run_idx": { "name": "run_identity_contexts_company_run_idx", @@ -56295,24 +57888,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "run_identity_contexts_company_id_companies_id_fk": { "name": "run_identity_contexts_company_id_companies_id_fk", "tableFrom": "run_identity_contexts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -56382,9 +57975,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "runner_api_response_reservations_asset_idx": { "name": "runner_api_response_reservations_asset_idx", @@ -56397,50 +57990,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "runner_api_response_reservations_company_id_companies_id_fk": { "name": "runner_api_response_reservations_company_id_companies_id_fk", "tableFrom": "runner_api_response_reservations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "runner_api_response_reservations_run_id_heartbeat_runs_id_fk": { "name": "runner_api_response_reservations_run_id_heartbeat_runs_id_fk", "tableFrom": "runner_api_response_reservations", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "runner_api_response_reservations_asset_id_assets_id_fk": { "name": "runner_api_response_reservations_asset_id_assets_id_fk", "tableFrom": "runner_api_response_reservations", + "tableTo": "assets", "columnsFrom": [ "asset_id" ], - "tableTo": "assets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -56578,10 +58171,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"sandbox_creation_operations\".\"state\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "sandbox_creation_operations_owner_idx": { "name": "sandbox_creation_operations_owner_idx", @@ -56612,25 +58205,25 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"sandbox_creation_operations\".\"state\" <> 'resolved'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "sandbox_creation_operations_environment_id_environments_id_fk": { "name": "sandbox_creation_operations_environment_id_environments_id_fk", "tableFrom": "sandbox_creation_operations", + "tableTo": "environments", "columnsFrom": [ "environment_id" ], - "tableTo": "environments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -56797,9 +58390,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "secret_access_events_secret_created_idx": { "name": "secret_access_events_secret_created_idx", @@ -56818,9 +58411,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "secret_access_events_user_definition_created_idx": { "name": "secret_access_events_user_definition_created_idx", @@ -56839,9 +58432,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "secret_access_events_company_credential_owner_idx": { "name": "secret_access_events_company_credential_owner_idx", @@ -56866,9 +58459,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "secret_access_events_consumer_idx": { "name": "secret_access_events_consumer_idx", @@ -56893,9 +58486,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "secret_access_events_run_idx": { "name": "secret_access_events_run_idx", @@ -56908,89 +58501,89 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "secret_access_events_company_id_companies_id_fk": { "name": "secret_access_events_company_id_companies_id_fk", "tableFrom": "secret_access_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "secret_access_events_secret_id_company_secrets_id_fk": { "name": "secret_access_events_secret_id_company_secrets_id_fk", "tableFrom": "secret_access_events", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "secret_access_events_user_secret_definition_id_user_secret_definitions_id_fk": { "name": "secret_access_events_user_secret_definition_id_user_secret_definitions_id_fk", "tableFrom": "secret_access_events", + "tableTo": "user_secret_definitions", "columnsFrom": [ "user_secret_definition_id" ], - "tableTo": "user_secret_definitions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "secret_access_events_issue_id_issues_id_fk": { "name": "secret_access_events_issue_id_issues_id_fk", "tableFrom": "secret_access_events", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "secret_access_events_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "secret_access_events_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "secret_access_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "secret_access_events_plugin_id_plugins_id_fk": { "name": "secret_access_events_plugin_id_plugins_id_fk", "tableFrom": "secret_access_events", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -57091,9 +58684,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "smoke_run_steps_company_path_idx": { "name": "smoke_run_steps_company_path_idx", @@ -57112,37 +58705,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "smoke_run_steps_company_id_companies_id_fk": { "name": "smoke_run_steps_company_id_companies_id_fk", "tableFrom": "smoke_run_steps", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "smoke_run_steps_run_id_smoke_runs_id_fk": { "name": "smoke_run_steps_run_id_smoke_runs_id_fk", "tableFrom": "smoke_run_steps", + "tableTo": "smoke_runs", "columnsFrom": [ "run_id" ], - "tableTo": "smoke_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -57234,9 +58827,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "smoke_runs_company_status_idx": { "name": "smoke_runs_company_status_idx", @@ -57255,24 +58848,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "smoke_runs_company_id_companies_id_fk": { "name": "smoke_runs_company_id_companies_id_fk", "tableFrom": "smoke_runs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -57412,9 +59005,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "status_card_updates_generation_issue_idx": { "name": "status_card_updates_generation_issue_idx", @@ -57427,50 +59020,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "status_card_updates_card_id_status_cards_id_fk": { "name": "status_card_updates_card_id_status_cards_id_fk", "tableFrom": "status_card_updates", + "tableTo": "status_cards", "columnsFrom": [ "card_id" ], - "tableTo": "status_cards", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "status_card_updates_generation_issue_id_issues_id_fk": { "name": "status_card_updates_generation_issue_id_issues_id_fk", "tableFrom": "status_card_updates", + "tableTo": "issues", "columnsFrom": [ "generation_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_card_updates_run_id_heartbeat_runs_id_fk": { "name": "status_card_updates_run_id_heartbeat_runs_id_fk", "tableFrom": "status_card_updates", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -57709,9 +59302,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "status_cards_company_next_eval_idx": { "name": "status_cards_company_next_eval_idx", @@ -57730,102 +59323,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "status_cards_company_id_companies_id_fk": { "name": "status_cards_company_id_companies_id_fk", "tableFrom": "status_cards", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "status_cards_created_by_agent_id_agents_id_fk": { "name": "status_cards_created_by_agent_id_agents_id_fk", "tableFrom": "status_cards", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_cards_query_compiled_by_agent_id_agents_id_fk": { "name": "status_cards_query_compiled_by_agent_id_agents_id_fk", "tableFrom": "status_cards", + "tableTo": "agents", "columnsFrom": [ "query_compiled_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_cards_agent_id_agents_id_fk": { "name": "status_cards_agent_id_agents_id_fk", "tableFrom": "status_cards", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_cards_document_id_documents_id_fk": { "name": "status_cards_document_id_documents_id_fk", "tableFrom": "status_cards", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_cards_generating_issue_id_issues_id_fk": { "name": "status_cards_generating_issue_id_issues_id_fk", "tableFrom": "status_cards", + "tableTo": "issues", "columnsFrom": [ "generating_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "status_cards_archived_by_agent_id_agents_id_fk": { "name": "status_cards_archived_by_agent_id_agents_id_fk", "tableFrom": "status_cards", + "tableTo": "agents", "columnsFrom": [ "archived_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -57970,10 +59563,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"status_decision_effects\".\"delivery_state\" in ('pending', 'failed')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "status_decision_effects_decision_ordinal_uq": { "name": "status_decision_effects_decision_ordinal_uq", @@ -57992,9 +59585,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "status_decision_effects_company_idempotency_uq": { "name": "status_decision_effects_company_idempotency_uq", @@ -58013,56 +59606,56 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "status_decision_effects_company_id_companies_id_fk": { "name": "status_decision_effects_company_id_companies_id_fk", "tableFrom": "status_decision_effects", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "status_decision_effects_issue_company_fk": { "name": "status_decision_effects_issue_company_fk", "tableFrom": "status_decision_effects", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "status_decision_effects_decision_owner_fk": { "name": "status_decision_effects_decision_owner_fk", "tableFrom": "status_decision_effects", + "tableTo": "status_decisions", "columnsFrom": [ "company_id", "issue_id", "decision_id" ], - "tableTo": "status_decisions", "columnsTo": [ "company_id", "issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -58199,9 +59792,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "status_decisions_company_assessment_uq": { "name": "status_decisions_company_assessment_uq", @@ -58220,9 +59813,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "status_decisions_company_issue_digest_uq": { "name": "status_decisions_company_issue_digest_uq", @@ -58247,98 +59840,98 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "status_decisions_company_id_companies_id_fk": { "name": "status_decisions_company_id_companies_id_fk", "tableFrom": "status_decisions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "status_decisions_issue_company_fk": { "name": "status_decisions_issue_company_fk", "tableFrom": "status_decisions", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "status_decisions_assessment_owner_fk": { "name": "status_decisions_assessment_owner_fk", "tableFrom": "status_decisions", + "tableTo": "work_assessments", "columnsFrom": [ "company_id", "issue_id", "run_id", "assessment_id" ], - "tableTo": "work_assessments", "columnsTo": [ "company_id", "issue_id", "run_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "status_decisions_supersedes_owner_fk": { "name": "status_decisions_supersedes_owner_fk", "tableFrom": "status_decisions", + "tableTo": "status_decisions", "columnsFrom": [ "company_id", "issue_id", "supersedes_decision_id" ], - "tableTo": "status_decisions", "columnsTo": [ "company_id", "issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "status_decisions_company_issue_id_uq": { "name": "status_decisions_company_issue_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "issue_id", "id" - ], - "nullsNotDistinct": false + ] }, "status_decisions_company_issue_run_assessment_id_uq": { "name": "status_decisions_company_issue_run_assessment_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "issue_id", "run_id", "assessment_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -58426,9 +60019,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "stored_object_deletions_company_idx": { "name": "stored_object_deletions_company_idx", @@ -58441,9 +60034,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -58558,9 +60151,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "summary_slots_company_scope_idx": { "name": "summary_slots_company_scope_idx", @@ -58585,9 +60178,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "summary_slots_company_generating_issue_idx": { "name": "summary_slots_company_generating_issue_idx", @@ -58606,9 +60199,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "summary_slots_company_updated_idx": { "name": "summary_slots_company_updated_idx", @@ -58627,76 +60220,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "summary_slots_company_id_companies_id_fk": { "name": "summary_slots_company_id_companies_id_fk", "tableFrom": "summary_slots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "summary_slots_document_id_documents_id_fk": { "name": "summary_slots_document_id_documents_id_fk", "tableFrom": "summary_slots", + "tableTo": "documents", "columnsFrom": [ "document_id" ], - "tableTo": "documents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "summary_slots_generating_issue_id_issues_id_fk": { "name": "summary_slots_generating_issue_id_issues_id_fk", "tableFrom": "summary_slots", + "tableTo": "issues", "columnsFrom": [ "generating_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "summary_slots_last_generated_by_agent_id_agents_id_fk": { "name": "summary_slots_last_generated_by_agent_id_agents_id_fk", "tableFrom": "summary_slots", + "tableTo": "agents", "columnsFrom": [ "last_generated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "summary_slots_company_scope_slot_uq": { "name": "summary_slots_company_scope_slot_uq", + "nullsNotDistinct": true, "columns": [ "company_id", "scope_kind", "scope_id", "slot_key" - ], - "nullsNotDistinct": true + ] } }, "policies": {}, @@ -58796,9 +60389,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tailscale_connections_oauth_state_idx": { "name": "tailscale_connections_oauth_state_idx", @@ -58811,37 +60404,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tailscale_connections_company_id_companies_id_fk": { "name": "tailscale_connections_company_id_companies_id_fk", "tableFrom": "tailscale_connections", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tailscale_connections_secret_id_company_secrets_id_fk": { "name": "tailscale_connections_secret_id_company_secrets_id_fk", "tableFrom": "tailscale_connections", + "tableTo": "company_secrets", "columnsFrom": [ "secret_id" ], - "tableTo": "company_secrets", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -58973,9 +60566,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_access_audit_connection_idx": { "name": "tool_access_audit_connection_idx", @@ -58988,9 +60581,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_access_audit_gateway_idx": { "name": "tool_access_audit_gateway_idx", @@ -59009,76 +60602,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_access_audit_events_company_id_companies_id_fk": { "name": "tool_access_audit_events_company_id_companies_id_fk", "tableFrom": "tool_access_audit_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_access_audit_events_gateway_id_tool_mcp_gateways_id_fk": { "name": "tool_access_audit_events_gateway_id_tool_mcp_gateways_id_fk", "tableFrom": "tool_access_audit_events", + "tableTo": "tool_mcp_gateways", "columnsFrom": [ "gateway_id" ], - "tableTo": "tool_mcp_gateways", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_access_audit_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk": { "name": "tool_access_audit_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk", "tableFrom": "tool_access_audit_events", + "tableTo": "tool_mcp_gateway_tokens", "columnsFrom": [ "gateway_token_id" ], - "tableTo": "tool_mcp_gateway_tokens", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_access_audit_events_connection_id_tool_connections_id_fk": { "name": "tool_access_audit_events_connection_id_tool_connections_id_fk", "tableFrom": "tool_access_audit_events", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_access_audit_events_catalog_entry_id_tool_catalog_entries_id_fk": { "name": "tool_access_audit_events_catalog_entry_id_tool_catalog_entries_id_fk", "tableFrom": "tool_access_audit_events", + "tableTo": "tool_catalog_entries", "columnsFrom": [ "catalog_entry_id" ], - "tableTo": "tool_catalog_entries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -59147,63 +60740,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_action_deliveries_action_request_id_tool_action_requests_id_fk": { "name": "tool_action_deliveries_action_request_id_tool_action_requests_id_fk", "tableFrom": "tool_action_deliveries", + "tableTo": "tool_action_requests", "columnsFrom": [ "action_request_id" ], - "tableTo": "tool_action_requests", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_action_deliveries_company_id_companies_id_fk": { "name": "tool_action_deliveries_company_id_companies_id_fk", "tableFrom": "tool_action_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_action_deliveries_issue_id_issues_id_fk": { "name": "tool_action_deliveries_issue_id_issues_id_fk", "tableFrom": "tool_action_deliveries", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_action_deliveries_interaction_id_issue_thread_interactions_id_fk": { "name": "tool_action_deliveries_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "tool_action_deliveries", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -59371,9 +60964,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_action_requests_pending_expiry_idx": { "name": "tool_action_requests_pending_expiry_idx", @@ -59392,10 +60985,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_action_requests\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_action_requests_company_pending_expiry_idx": { "name": "tool_action_requests_company_pending_expiry_idx", @@ -59414,10 +61007,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_action_requests\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_action_requests_executing_deadline_idx": { "name": "tool_action_requests_executing_deadline_idx", @@ -59436,10 +61029,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_action_requests\".\"status\" = 'executing'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_action_requests_approved_idx": { "name": "tool_action_requests_approved_idx", @@ -59452,10 +61045,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_action_requests\".\"status\" = 'approved'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_action_requests_invocation_idx": { "name": "tool_action_requests_invocation_idx", @@ -59468,9 +61061,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_action_requests_company_interaction_idx": { "name": "tool_action_requests_company_interaction_idx", @@ -59489,9 +61082,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_action_requests_issue_idx": { "name": "tool_action_requests_issue_idx", @@ -59510,115 +61103,115 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_action_requests_company_id_companies_id_fk": { "name": "tool_action_requests_company_id_companies_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_action_requests_invocation_id_tool_invocations_id_fk": { "name": "tool_action_requests_invocation_id_tool_invocations_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "tool_invocations", "columnsFrom": [ "invocation_id" ], - "tableTo": "tool_invocations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_action_requests_issue_id_issues_id_fk": { "name": "tool_action_requests_issue_id_issues_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_action_requests_interaction_id_issue_thread_interactions_id_fk": { "name": "tool_action_requests_interaction_id_issue_thread_interactions_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "issue_thread_interactions", "columnsFrom": [ "interaction_id" ], - "tableTo": "issue_thread_interactions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_action_requests_approval_id_approvals_id_fk": { "name": "tool_action_requests_approval_id_approvals_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "approvals", "columnsFrom": [ "approval_id" ], - "tableTo": "approvals", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_action_requests_requested_by_agent_id_agents_id_fk": { "name": "tool_action_requests_requested_by_agent_id_agents_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "agents", "columnsFrom": [ "requested_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_action_requests_resolved_by_agent_id_agents_id_fk": { "name": "tool_action_requests_resolved_by_agent_id_agents_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "agents", "columnsFrom": [ "resolved_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_action_requests_decided_by_agent_id_agents_id_fk": { "name": "tool_action_requests_decided_by_agent_id_agents_id_fk", "tableFrom": "tool_action_requests", + "tableTo": "agents", "columnsFrom": [ "decided_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -59733,9 +61326,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_applications_company_status_idx": { "name": "tool_applications_company_status_idx", @@ -59754,9 +61347,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_applications_company_name_uq": { "name": "tool_applications_company_name_uq", @@ -59775,9 +61368,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_applications_company_key_uq": { "name": "tool_applications_company_key_uq", @@ -59796,50 +61389,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_applications_company_id_companies_id_fk": { "name": "tool_applications_company_id_companies_id_fk", "tableFrom": "tool_applications", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_applications_plugin_id_plugins_id_fk": { "name": "tool_applications_plugin_id_plugins_id_fk", "tableFrom": "tool_applications", + "tableTo": "plugins", "columnsFrom": [ "plugin_id" ], - "tableTo": "plugins", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_applications_owner_agent_id_agents_id_fk": { "name": "tool_applications_owner_agent_id_agents_id_fk", "tableFrom": "tool_applications", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -60134,9 +61727,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_call_events_run_idx": { "name": "tool_call_events_run_idx", @@ -60155,9 +61748,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_call_events_issue_idx": { "name": "tool_call_events_issue_idx", @@ -60176,9 +61769,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_call_events_invocation_idx": { "name": "tool_call_events_invocation_idx", @@ -60191,9 +61784,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_call_events_gateway_idx": { "name": "tool_call_events_gateway_idx", @@ -60212,9 +61805,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_call_events_connection_error_idx": { "name": "tool_call_events_connection_error_idx", @@ -60233,168 +61826,168 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_call_events\".\"error_message\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "tool_call_events_company_id_companies_id_fk": { "name": "tool_call_events_company_id_companies_id_fk", "tableFrom": "tool_call_events", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_call_events_agent_id_agents_id_fk": { "name": "tool_call_events_agent_id_agents_id_fk", "tableFrom": "tool_call_events", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_run_id_heartbeat_runs_id_fk": { "name": "tool_call_events_run_id_heartbeat_runs_id_fk", "tableFrom": "tool_call_events", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_issue_id_issues_id_fk": { "name": "tool_call_events_issue_id_issues_id_fk", "tableFrom": "tool_call_events", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_gateway_id_tool_mcp_gateways_id_fk": { "name": "tool_call_events_gateway_id_tool_mcp_gateways_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_mcp_gateways", "columnsFrom": [ "gateway_id" ], - "tableTo": "tool_mcp_gateways", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk": { "name": "tool_call_events_gateway_token_id_tool_mcp_gateway_tokens_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_mcp_gateway_tokens", "columnsFrom": [ "gateway_token_id" ], - "tableTo": "tool_mcp_gateway_tokens", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_application_id_tool_applications_id_fk": { "name": "tool_call_events_application_id_tool_applications_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_connection_id_tool_connections_id_fk": { "name": "tool_call_events_connection_id_tool_connections_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_catalog_entry_id_tool_catalog_entries_id_fk": { "name": "tool_call_events_catalog_entry_id_tool_catalog_entries_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_catalog_entries", "columnsFrom": [ "catalog_entry_id" ], - "tableTo": "tool_catalog_entries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_invocation_id_tool_invocations_id_fk": { "name": "tool_call_events_invocation_id_tool_invocations_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_invocations", "columnsFrom": [ "invocation_id" ], - "tableTo": "tool_invocations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_action_request_id_tool_action_requests_id_fk": { "name": "tool_call_events_action_request_id_tool_action_requests_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_action_requests", "columnsFrom": [ "action_request_id" ], - "tableTo": "tool_action_requests", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_call_events_runtime_slot_id_tool_runtime_slots_id_fk": { "name": "tool_call_events_runtime_slot_id_tool_runtime_slots_id_fk", "tableFrom": "tool_call_events", + "tableTo": "tool_runtime_slots", "columnsFrom": [ "runtime_slot_id" ], - "tableTo": "tool_runtime_slots", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -60619,9 +62212,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_catalog_entries_application_idx": { "name": "tool_catalog_entries_application_idx", @@ -60634,9 +62227,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_catalog_entries_connection_idx": { "name": "tool_catalog_entries_connection_idx", @@ -60649,9 +62242,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_catalog_entries_company_status_idx": { "name": "tool_catalog_entries_company_status_idx", @@ -60670,9 +62263,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_catalog_entries_connection_name_uq": { "name": "tool_catalog_entries_connection_name_uq", @@ -60691,63 +62284,63 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_catalog_entries_company_id_companies_id_fk": { "name": "tool_catalog_entries_company_id_companies_id_fk", "tableFrom": "tool_catalog_entries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_catalog_entries_application_id_tool_applications_id_fk": { "name": "tool_catalog_entries_application_id_tool_applications_id_fk", "tableFrom": "tool_catalog_entries", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_catalog_entries_connection_id_tool_connections_id_fk": { "name": "tool_catalog_entries_connection_id_tool_connections_id_fk", "tableFrom": "tool_catalog_entries", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_catalog_entries_reviewed_by_agent_id_agents_id_fk": { "name": "tool_catalog_entries_reviewed_by_agent_id_agents_id_fk", "tableFrom": "tool_catalog_entries", + "tableTo": "agents", "columnsFrom": [ "reviewed_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -60854,39 +62447,39 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_connection_app_snapshots_company_id_companies_id_fk": { "name": "tool_connection_app_snapshots_company_id_companies_id_fk", "tableFrom": "tool_connection_app_snapshots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connection_app_snapshots_company_connection_fk": { "name": "tool_connection_app_snapshots_company_connection_fk", "tableFrom": "tool_connection_app_snapshots", + "tableTo": "tool_connections", "columnsFrom": [ "company_id", "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -61007,39 +62600,39 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_connection_app_syncs_company_id_companies_id_fk": { "name": "tool_connection_app_syncs_company_id_companies_id_fk", "tableFrom": "tool_connection_app_syncs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connection_app_syncs_company_connection_fk": { "name": "tool_connection_app_syncs_company_connection_fk", "tableFrom": "tool_connection_app_syncs", + "tableTo": "tool_connections", "columnsFrom": [ "company_id", "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -61175,9 +62768,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connection_content_deletions_pending_uq": { "name": "tool_connection_content_deletions_pending_uq", @@ -61196,10 +62789,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"tool_connection_content_deletions\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_connection_content_deletions_pending_idx": { "name": "tool_connection_content_deletions_pending_idx", @@ -61212,38 +62805,38 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_connection_content_deletions\".\"status\" = 'pending'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "tool_connection_content_deletions_company_id_companies_id_fk": { "name": "tool_connection_content_deletions_company_id_companies_id_fk", "tableFrom": "tool_connection_content_deletions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connection_content_deletions_connection_id_tool_connections_id_fk": { "name": "tool_connection_content_deletions_connection_id_tool_connections_id_fk", "tableFrom": "tool_connection_content_deletions", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -61331,9 +62924,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connection_installs_connection_idx": { "name": "tool_connection_installs_connection_idx", @@ -61352,9 +62945,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connection_installs_target_uq": { "name": "tool_connection_installs_target_uq", @@ -61385,50 +62978,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_connection_installs_company_id_companies_id_fk": { "name": "tool_connection_installs_company_id_companies_id_fk", "tableFrom": "tool_connection_installs", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connection_installs_connection_id_tool_connections_id_fk": { "name": "tool_connection_installs_connection_id_tool_connections_id_fk", "tableFrom": "tool_connection_installs", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connection_installs_created_by_agent_id_agents_id_fk": { "name": "tool_connection_installs_created_by_agent_id_agents_id_fk", "tableFrom": "tool_connection_installs", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -61655,9 +63248,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connections_application_idx": { "name": "tool_connections_application_idx", @@ -61670,9 +63263,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connections_company_enabled_idx": { "name": "tool_connections_company_enabled_idx", @@ -61691,9 +63284,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_connections_company_uid_uq": { "name": "tool_connections_company_uid_uq", @@ -61712,61 +63305,61 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_connections_company_id_companies_id_fk": { "name": "tool_connections_company_id_companies_id_fk", "tableFrom": "tool_connections", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_connections_application_id_tool_applications_id_fk": { "name": "tool_connections_application_id_tool_applications_id_fk", "tableFrom": "tool_connections", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "tool_connections_created_by_agent_id_agents_id_fk": { "name": "tool_connections_created_by_agent_id_agents_id_fk", "tableFrom": "tool_connections", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "tool_connections_company_id_uq": { "name": "tool_connections_company_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -61887,9 +63480,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_rate_limit_counters_window_uq": { "name": "tool_gateway_rate_limit_counters_window_uq", @@ -61914,24 +63507,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_gateway_rate_limit_counters_company_id_companies_id_fk": { "name": "tool_gateway_rate_limit_counters_company_id_companies_id_fk", "tableFrom": "tool_gateway_rate_limit_counters", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -62086,9 +63679,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_company_agent_idx": { "name": "tool_gateway_sessions_company_agent_idx", @@ -62107,9 +63700,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_company_expires_idx": { "name": "tool_gateway_sessions_company_expires_idx", @@ -62128,9 +63721,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_expiry_idx": { "name": "tool_gateway_sessions_expiry_idx", @@ -62143,9 +63736,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_run_idx": { "name": "tool_gateway_sessions_run_idx", @@ -62164,9 +63757,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_issue_idx": { "name": "tool_gateway_sessions_issue_idx", @@ -62185,9 +63778,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_gateway_sessions_gateway_idx": { "name": "tool_gateway_sessions_gateway_idx", @@ -62206,102 +63799,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_gateway_sessions_company_id_companies_id_fk": { "name": "tool_gateway_sessions_company_id_companies_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_gateway_sessions_agent_id_agents_id_fk": { "name": "tool_gateway_sessions_agent_id_agents_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_gateway_sessions_run_id_heartbeat_runs_id_fk": { "name": "tool_gateway_sessions_run_id_heartbeat_runs_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_gateway_sessions_issue_id_issues_id_fk": { "name": "tool_gateway_sessions_issue_id_issues_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_gateway_sessions_project_id_projects_id_fk": { "name": "tool_gateway_sessions_project_id_projects_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_gateway_sessions_gateway_id_tool_mcp_gateways_id_fk": { "name": "tool_gateway_sessions_gateway_id_tool_mcp_gateways_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "tool_mcp_gateways", "columnsFrom": [ "gateway_id" ], - "tableTo": "tool_mcp_gateways", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_gateway_sessions_gateway_token_id_tool_mcp_gateway_tokens_id_fk": { "name": "tool_gateway_sessions_gateway_token_id_tool_mcp_gateway_tokens_id_fk", "tableFrom": "tool_gateway_sessions", + "tableTo": "tool_mcp_gateway_tokens", "columnsFrom": [ "gateway_token_id" ], - "tableTo": "tool_mcp_gateway_tokens", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -62622,9 +64215,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_invocations_run_idx": { "name": "tool_invocations_run_idx", @@ -62643,9 +64236,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_invocations_issue_idx": { "name": "tool_invocations_issue_idx", @@ -62664,9 +64257,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_invocations_gateway_idx": { "name": "tool_invocations_gateway_idx", @@ -62685,9 +64278,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_invocations_connection_error_idx": { "name": "tool_invocations_connection_error_idx", @@ -62706,10 +64299,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_invocations\".\"error_message\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "tool_invocations_company_idempotency_uq": { "name": "tool_invocations_company_idempotency_uq", @@ -62728,128 +64321,128 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_invocations_company_id_companies_id_fk": { "name": "tool_invocations_company_id_companies_id_fk", "tableFrom": "tool_invocations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_invocations_agent_id_agents_id_fk": { "name": "tool_invocations_agent_id_agents_id_fk", "tableFrom": "tool_invocations", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_issue_id_issues_id_fk": { "name": "tool_invocations_issue_id_issues_id_fk", "tableFrom": "tool_invocations", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_run_id_heartbeat_runs_id_fk": { "name": "tool_invocations_run_id_heartbeat_runs_id_fk", "tableFrom": "tool_invocations", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_gateway_id_tool_mcp_gateways_id_fk": { "name": "tool_invocations_gateway_id_tool_mcp_gateways_id_fk", "tableFrom": "tool_invocations", + "tableTo": "tool_mcp_gateways", "columnsFrom": [ "gateway_id" ], - "tableTo": "tool_mcp_gateways", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_gateway_token_id_tool_mcp_gateway_tokens_id_fk": { "name": "tool_invocations_gateway_token_id_tool_mcp_gateway_tokens_id_fk", "tableFrom": "tool_invocations", + "tableTo": "tool_mcp_gateway_tokens", "columnsFrom": [ "gateway_token_id" ], - "tableTo": "tool_mcp_gateway_tokens", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_application_id_tool_applications_id_fk": { "name": "tool_invocations_application_id_tool_applications_id_fk", "tableFrom": "tool_invocations", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_connection_id_tool_connections_id_fk": { "name": "tool_invocations_connection_id_tool_connections_id_fk", "tableFrom": "tool_invocations", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_invocations_catalog_entry_id_tool_catalog_entries_id_fk": { "name": "tool_invocations_catalog_entry_id_tool_catalog_entries_id_fk", "tableFrom": "tool_invocations", + "tableTo": "tool_catalog_entries", "columnsFrom": [ "catalog_entry_id" ], - "tableTo": "tool_catalog_entries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -62998,9 +64591,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_app_views_connection_idx": { "name": "tool_mcp_app_views_connection_idx", @@ -63013,102 +64606,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_mcp_app_views_company_id_companies_id_fk": { "name": "tool_mcp_app_views_company_id_companies_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_app_views_invocation_id_tool_invocations_id_fk": { "name": "tool_mcp_app_views_invocation_id_tool_invocations_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "tool_invocations", "columnsFrom": [ "invocation_id" ], - "tableTo": "tool_invocations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_app_views_issue_id_issues_id_fk": { "name": "tool_mcp_app_views_issue_id_issues_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_app_views_run_id_heartbeat_runs_id_fk": { "name": "tool_mcp_app_views_run_id_heartbeat_runs_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_app_views_agent_id_agents_id_fk": { "name": "tool_mcp_app_views_agent_id_agents_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_app_views_connection_id_tool_connections_id_fk": { "name": "tool_mcp_app_views_connection_id_tool_connections_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_app_views_catalog_entry_id_tool_catalog_entries_id_fk": { "name": "tool_mcp_app_views_catalog_entry_id_tool_catalog_entries_id_fk", "tableFrom": "tool_mcp_app_views", + "tableTo": "tool_catalog_entries", "columnsFrom": [ "catalog_entry_id" ], - "tableTo": "tool_catalog_entries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -63287,9 +64880,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_elicitations_invocation_idx": { "name": "tool_mcp_elicitations_invocation_idx", @@ -63308,9 +64901,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_elicitations_waiting_uq": { "name": "tool_mcp_elicitations_waiting_uq", @@ -63335,51 +64928,51 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"tool_mcp_elicitations\".\"status\" = 'waiting'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "tool_mcp_elicitations_company_id_companies_id_fk": { "name": "tool_mcp_elicitations_company_id_companies_id_fk", "tableFrom": "tool_mcp_elicitations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_elicitations_invocation_id_tool_invocations_id_fk": { "name": "tool_mcp_elicitations_invocation_id_tool_invocations_id_fk", "tableFrom": "tool_mcp_elicitations", + "tableTo": "tool_invocations", "columnsFrom": [ "invocation_id" ], - "tableTo": "tool_invocations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_elicitations_connection_id_tool_connections_id_fk": { "name": "tool_mcp_elicitations_connection_id_tool_connections_id_fk", "tableFrom": "tool_mcp_elicitations", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -63558,9 +65151,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateway_tokens_expiry_idx": { "name": "tool_mcp_gateway_tokens_expiry_idx", @@ -63579,9 +65172,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateway_tokens_gateway_idx": { "name": "tool_mcp_gateway_tokens_gateway_idx", @@ -63600,9 +65193,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateway_tokens_subject_idx": { "name": "tool_mcp_gateway_tokens_subject_idx", @@ -63627,9 +65220,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateway_tokens_company_expires_idx": { "name": "tool_mcp_gateway_tokens_company_expires_idx", @@ -63648,63 +65241,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_mcp_gateway_tokens_company_id_companies_id_fk": { "name": "tool_mcp_gateway_tokens_company_id_companies_id_fk", "tableFrom": "tool_mcp_gateway_tokens", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_gateway_tokens_gateway_id_tool_mcp_gateways_id_fk": { "name": "tool_mcp_gateway_tokens_gateway_id_tool_mcp_gateways_id_fk", "tableFrom": "tool_mcp_gateway_tokens", + "tableTo": "tool_mcp_gateways", "columnsFrom": [ "gateway_id" ], - "tableTo": "tool_mcp_gateways", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_gateway_tokens_expiry_override_by_agent_id_agents_id_fk": { "name": "tool_mcp_gateway_tokens_expiry_override_by_agent_id_agents_id_fk", "tableFrom": "tool_mcp_gateway_tokens", + "tableTo": "agents", "columnsFrom": [ "expiry_override_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_gateway_tokens_created_by_agent_id_agents_id_fk": { "name": "tool_mcp_gateway_tokens_created_by_agent_id_agents_id_fk", "tableFrom": "tool_mcp_gateway_tokens", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -63899,9 +65492,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateways_company_status_idx": { "name": "tool_mcp_gateways_company_status_idx", @@ -63920,9 +65513,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateways_profile_idx": { "name": "tool_mcp_gateways_profile_idx", @@ -63941,9 +65534,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateways_public_id_uq": { "name": "tool_mcp_gateways_public_id_uq", @@ -63956,9 +65549,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateways_company_slug_uq": { "name": "tool_mcp_gateways_company_slug_uq", @@ -63977,9 +65570,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_gateways_company_name_uq": { "name": "tool_mcp_gateways_company_name_uq", @@ -63998,102 +65591,102 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_mcp_gateways_company_id_companies_id_fk": { "name": "tool_mcp_gateways_company_id_companies_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_gateways_profile_id_tool_profiles_id_fk": { "name": "tool_mcp_gateways_profile_id_tool_profiles_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "tool_profiles", "columnsFrom": [ "profile_id" ], - "tableTo": "tool_profiles", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "restrict" + "onDelete": "restrict", + "onUpdate": "no action" }, "tool_mcp_gateways_agent_id_agents_id_fk": { "name": "tool_mcp_gateways_agent_id_agents_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_gateways_project_id_projects_id_fk": { "name": "tool_mcp_gateways_project_id_projects_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_gateways_issue_id_issues_id_fk": { "name": "tool_mcp_gateways_issue_id_issues_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_gateways_approval_issue_id_issues_id_fk": { "name": "tool_mcp_gateways_approval_issue_id_issues_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "issues", "columnsFrom": [ "approval_issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_mcp_gateways_created_by_agent_id_agents_id_fk": { "name": "tool_mcp_gateways_created_by_agent_id_agents_id_fk", "tableFrom": "tool_mcp_gateways", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -64187,37 +65780,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_mcp_skill_files_company_id_companies_id_fk": { "name": "tool_mcp_skill_files_company_id_companies_id_fk", "tableFrom": "tool_mcp_skill_files", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_skill_files_connection_id_tool_connections_id_fk": { "name": "tool_mcp_skill_files_connection_id_tool_connections_id_fk", "tableFrom": "tool_mcp_skill_files", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -64370,9 +65963,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_skills_company_status_idx": { "name": "tool_mcp_skills_company_status_idx", @@ -64391,37 +65984,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_mcp_skills_company_id_companies_id_fk": { "name": "tool_mcp_skills_company_id_companies_id_fk", "tableFrom": "tool_mcp_skills", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_skills_connection_id_tool_connections_id_fk": { "name": "tool_mcp_skills_connection_id_tool_connections_id_fk", "tableFrom": "tool_mcp_skills", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -64706,9 +66299,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_tasks_attach_idx": { "name": "tool_mcp_tasks_attach_idx", @@ -64733,9 +66326,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_tasks_invocation_idx": { "name": "tool_mcp_tasks_invocation_idx", @@ -64754,9 +66347,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_mcp_tasks_next_poll_idx": { "name": "tool_mcp_tasks_next_poll_idx", @@ -64769,51 +66362,51 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"tool_mcp_tasks\".\"next_poll_at\" is not null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "tool_mcp_tasks_company_id_companies_id_fk": { "name": "tool_mcp_tasks_company_id_companies_id_fk", "tableFrom": "tool_mcp_tasks", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_tasks_invocation_id_tool_invocations_id_fk": { "name": "tool_mcp_tasks_invocation_id_tool_invocations_id_fk", "tableFrom": "tool_mcp_tasks", + "tableTo": "tool_invocations", "columnsFrom": [ "invocation_id" ], - "tableTo": "tool_invocations", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_mcp_tasks_connection_id_tool_connections_id_fk": { "name": "tool_mcp_tasks_connection_id_tool_connections_id_fk", "tableFrom": "tool_mcp_tasks", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -64930,9 +66523,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_oauth_states_connection_idx": { "name": "tool_oauth_states_connection_idx", @@ -64945,9 +66538,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_oauth_states_actor_idx": { "name": "tool_oauth_states_actor_idx", @@ -64966,9 +66559,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_oauth_states_subject_agent_idx": { "name": "tool_oauth_states_subject_agent_idx", @@ -64987,9 +66580,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_oauth_states_expires_at_idx": { "name": "tool_oauth_states_expires_at_idx", @@ -65002,50 +66595,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_oauth_states_company_id_companies_id_fk": { "name": "tool_oauth_states_company_id_companies_id_fk", "tableFrom": "tool_oauth_states", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_oauth_states_connection_id_tool_connections_id_fk": { "name": "tool_oauth_states_connection_id_tool_connections_id_fk", "tableFrom": "tool_oauth_states", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_oauth_states_subject_agent_id_agents_id_fk": { "name": "tool_oauth_states_subject_agent_id_agents_id_fk", "tableFrom": "tool_oauth_states", + "tableTo": "agents", "columnsFrom": [ "subject_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -65167,9 +66760,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_policies_company_type_idx": { "name": "tool_policies_company_type_idx", @@ -65188,9 +66781,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_policies_company_name_uq": { "name": "tool_policies_company_name_uq", @@ -65209,37 +66802,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_policies_company_id_companies_id_fk": { "name": "tool_policies_company_id_companies_id_fk", "tableFrom": "tool_policies", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_policies_created_by_agent_id_agents_id_fk": { "name": "tool_policies_created_by_agent_id_agents_id_fk", "tableFrom": "tool_policies", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -65348,9 +66941,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profile_bindings_target_profile_uq": { "name": "tool_profile_bindings_target_profile_uq", @@ -65381,50 +66974,50 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_profile_bindings_company_id_companies_id_fk": { "name": "tool_profile_bindings_company_id_companies_id_fk", "tableFrom": "tool_profile_bindings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_bindings_profile_id_tool_profiles_id_fk": { "name": "tool_profile_bindings_profile_id_tool_profiles_id_fk", "tableFrom": "tool_profile_bindings", + "tableTo": "tool_profiles", "columnsFrom": [ "profile_id" ], - "tableTo": "tool_profiles", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_bindings_created_by_agent_id_agents_id_fk": { "name": "tool_profile_bindings_created_by_agent_id_agents_id_fk", "tableFrom": "tool_profile_bindings", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -65538,9 +67131,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profile_entries_application_idx": { "name": "tool_profile_entries_application_idx", @@ -65559,9 +67152,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profile_entries_connection_idx": { "name": "tool_profile_entries_connection_idx", @@ -65580,9 +67173,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profile_entries_catalog_entry_idx": { "name": "tool_profile_entries_catalog_entry_idx", @@ -65601,76 +67194,76 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_profile_entries_company_id_companies_id_fk": { "name": "tool_profile_entries_company_id_companies_id_fk", "tableFrom": "tool_profile_entries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_entries_profile_id_tool_profiles_id_fk": { "name": "tool_profile_entries_profile_id_tool_profiles_id_fk", "tableFrom": "tool_profile_entries", + "tableTo": "tool_profiles", "columnsFrom": [ "profile_id" ], - "tableTo": "tool_profiles", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_entries_application_id_tool_applications_id_fk": { "name": "tool_profile_entries_application_id_tool_applications_id_fk", "tableFrom": "tool_profile_entries", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_entries_connection_id_tool_connections_id_fk": { "name": "tool_profile_entries_connection_id_tool_connections_id_fk", "tableFrom": "tool_profile_entries", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_profile_entries_catalog_entry_id_tool_catalog_entries_id_fk": { "name": "tool_profile_entries_catalog_entry_id_tool_catalog_entries_id_fk", "tableFrom": "tool_profile_entries", + "tableTo": "tool_catalog_entries", "columnsFrom": [ "catalog_entry_id" ], - "tableTo": "tool_catalog_entries", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -65774,9 +67367,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profiles_company_key_uq": { "name": "tool_profiles_company_key_uq", @@ -65795,9 +67388,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_profiles_company_name_uq": { "name": "tool_profiles_company_name_uq", @@ -65816,24 +67409,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_profiles_company_id_companies_id_fk": { "name": "tool_profiles_company_id_companies_id_fk", "tableFrom": "tool_profiles", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -65940,9 +67533,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_rate_limit_counters_window_uq": { "name": "tool_rate_limit_counters_window_uq", @@ -65979,37 +67572,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_rate_limit_counters_company_id_companies_id_fk": { "name": "tool_rate_limit_counters_company_id_companies_id_fk", "tableFrom": "tool_rate_limit_counters", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_rate_limit_counters_policy_id_tool_policies_id_fk": { "name": "tool_rate_limit_counters_policy_id_tool_policies_id_fk", "tableFrom": "tool_rate_limit_counters", + "tableTo": "tool_policies", "columnsFrom": [ "policy_id" ], - "tableTo": "tool_policies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -66093,9 +67686,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_runtime_metric_counters_bucket_uq": { "name": "tool_runtime_metric_counters_bucket_uq", @@ -66120,24 +67713,24 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_runtime_metric_counters_company_id_companies_id_fk": { "name": "tool_runtime_metric_counters_company_id_companies_id_fk", "tableFrom": "tool_runtime_metric_counters", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -66363,9 +67956,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_runtime_slots_connection_idx": { "name": "tool_runtime_slots_connection_idx", @@ -66378,9 +67971,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_runtime_slots_execution_workspace_idx": { "name": "tool_runtime_slots_execution_workspace_idx", @@ -66399,9 +67992,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_runtime_slots_slot_key_uq": { "name": "tool_runtime_slots_slot_key_uq", @@ -66420,89 +68013,89 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_runtime_slots_company_id_companies_id_fk": { "name": "tool_runtime_slots_company_id_companies_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_runtime_slots_application_id_tool_applications_id_fk": { "name": "tool_runtime_slots_application_id_tool_applications_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "tool_applications", "columnsFrom": [ "application_id" ], - "tableTo": "tool_applications", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_runtime_slots_connection_id_tool_connections_id_fk": { "name": "tool_runtime_slots_connection_id_tool_connections_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_runtime_slots_project_workspace_id_project_workspaces_id_fk": { "name": "tool_runtime_slots_project_workspace_id_project_workspaces_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "project_workspaces", "columnsFrom": [ "project_workspace_id" ], - "tableTo": "project_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_runtime_slots_execution_workspace_id_execution_workspaces_id_fk": { "name": "tool_runtime_slots_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "tool_runtime_slots_issue_id_issues_id_fk": { "name": "tool_runtime_slots_issue_id_issues_id_fk", "tableFrom": "tool_runtime_slots", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -66625,9 +68218,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_stdio_command_templates_company_status_idx": { "name": "tool_stdio_command_templates_company_status_idx", @@ -66646,9 +68239,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "tool_stdio_command_templates_company_key_uq": { "name": "tool_stdio_command_templates_company_key_uq", @@ -66667,37 +68260,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "tool_stdio_command_templates_company_id_companies_id_fk": { "name": "tool_stdio_command_templates_company_id_companies_id_fk", "tableFrom": "tool_stdio_command_templates", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "tool_stdio_command_templates_created_by_agent_id_agents_id_fk": { "name": "tool_stdio_command_templates_created_by_agent_id_agents_id_fk", "tableFrom": "tool_stdio_command_templates", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -66775,9 +68368,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_company_preferences_primary_agent_idx": { "name": "user_company_preferences_primary_agent_idx", @@ -66790,37 +68383,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "user_company_preferences_company_id_companies_id_fk": { "name": "user_company_preferences_company_id_companies_id_fk", "tableFrom": "user_company_preferences", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "user_company_preferences_primary_agent_id_agents_id_fk": { "name": "user_company_preferences_primary_agent_id_agents_id_fk", "tableFrom": "user_company_preferences", + "tableTo": "agents", "columnsFrom": [ "primary_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -66899,9 +68492,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_inbox_agent_policies_allowed_agent_ids_idx": { "name": "user_inbox_agent_policies_allowed_agent_ids_idx", @@ -66914,24 +68507,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "gin", - "concurrently": false + "with": {} } }, "foreignKeys": { "user_inbox_agent_policies_company_id_companies_id_fk": { "name": "user_inbox_agent_policies_company_id_companies_id_fk", "tableFrom": "user_inbox_agent_policies", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -67046,9 +68639,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_declarations_definition_idx": { "name": "user_secret_declarations_definition_idx", @@ -67061,9 +68654,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_declarations_target_idx": { "name": "user_secret_declarations_target_idx", @@ -67088,9 +68681,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_declarations_company_required_idx": { "name": "user_secret_declarations_company_required_idx", @@ -67109,9 +68702,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_declarations_target_path_uq": { "name": "user_secret_declarations_target_path_uq", @@ -67142,9 +68735,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_declarations_required_override_idx": { "name": "user_secret_declarations_required_override_idx", @@ -67163,38 +68756,38 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"user_secret_declarations\".\"allow_missing_override\" = true", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "user_secret_declarations_company_id_companies_id_fk": { "name": "user_secret_declarations_company_id_companies_id_fk", "tableFrom": "user_secret_declarations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "user_secret_declarations_user_secret_definition_id_user_secret_definitions_id_fk": { "name": "user_secret_declarations_user_secret_definition_id_user_secret_definitions_id_fk", "tableFrom": "user_secret_declarations", + "tableTo": "user_secret_definitions", "columnsFrom": [ "user_secret_definition_id" ], - "tableTo": "user_secret_definitions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -67340,9 +68933,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_definitions_company_provider_idx": { "name": "user_secret_definitions_company_provider_idx", @@ -67361,9 +68954,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_definitions_provider_config_idx": { "name": "user_secret_definitions_provider_config_idx", @@ -67376,9 +68969,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "user_secret_definitions_company_key_uq": { "name": "user_secret_definitions_company_key_uq", @@ -67397,64 +68990,64 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"user_secret_definitions\".\"deleted_at\" is null", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "user_secret_definitions_company_id_companies_id_fk": { "name": "user_secret_definitions_company_id_companies_id_fk", "tableFrom": "user_secret_definitions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "user_secret_definitions_provider_config_id_company_secret_provider_configs_id_fk": { "name": "user_secret_definitions_provider_config_id_company_secret_provider_configs_id_fk", "tableFrom": "user_secret_definitions", + "tableTo": "company_secret_provider_configs", "columnsFrom": [ "provider_config_id" ], - "tableTo": "company_secret_provider_configs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "user_secret_definitions_created_by_agent_id_agents_id_fk": { "name": "user_secret_definitions_created_by_agent_id_agents_id_fk", "tableFrom": "user_secret_definitions", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "user_secret_definitions_updated_by_agent_id_agents_id_fk": { "name": "user_secret_definitions_updated_by_agent_id_agents_id_fk", "tableFrom": "user_secret_definitions", + "tableTo": "agents", "columnsFrom": [ "updated_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -67514,9 +69107,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -67590,9 +69183,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -67747,137 +69340,137 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "work_assessments_company_id_companies_id_fk": { "name": "work_assessments_company_id_companies_id_fk", "tableFrom": "work_assessments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_trigger_actor_company_id_companies_id_fk": { "name": "work_assessments_trigger_actor_company_id_companies_id_fk", "tableFrom": "work_assessments", + "tableTo": "companies", "columnsFrom": [ "trigger_actor_company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_issue_company_fk": { "name": "work_assessments_issue_company_fk", "tableFrom": "work_assessments", + "tableTo": "issues", "columnsFrom": [ "company_id", "issue_id" ], - "tableTo": "issues", "columnsTo": [ "company_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_run_owner_fk": { "name": "work_assessments_run_owner_fk", "tableFrom": "work_assessments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "company_id", "issue_id", "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "company_id", "native_issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_contract_owner_fk": { "name": "work_assessments_contract_owner_fk", "tableFrom": "work_assessments", + "tableTo": "completion_contracts", "columnsFrom": [ "company_id", "issue_id", "contract_id" ], - "tableTo": "completion_contracts", "columnsTo": [ "company_id", "issue_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_result_owner_fk": { "name": "work_assessments_result_owner_fk", "tableFrom": "work_assessments", + "tableTo": "native_run_results", "columnsFrom": [ "company_id", "issue_id", "run_id", "result_id" ], - "tableTo": "native_run_results", "columnsTo": [ "company_id", "issue_id", "run_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "work_assessments_supersedes_owner_fk": { "name": "work_assessments_supersedes_owner_fk", "tableFrom": "work_assessments", + "tableTo": "work_assessments", "columnsFrom": [ "company_id", "issue_id", "run_id", "supersedes_assessment_id" ], - "tableTo": "work_assessments", "columnsTo": [ "company_id", "issue_id", "run_id", "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "work_assessments_company_issue_run_id_uq": { "name": "work_assessments_company_issue_run_id_uq", + "nullsNotDistinct": false, "columns": [ "company_id", "issue_id", "run_id", "id" - ], - "nullsNotDistinct": false + ] } }, "policies": {}, @@ -67957,37 +69550,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "workflows_company_id_companies_id_fk": { "name": "workflows_company_id_companies_id_fk", "tableFrom": "workflows", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "workflows_created_by_agent_id_agents_id_fk": { "name": "workflows_created_by_agent_id_agents_id_fk", "tableFrom": "workflows", + "tableTo": "agents", "columnsFrom": [ "created_by_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -68163,9 +69756,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_operations_company_workspace_started_idx": { "name": "workspace_operations_company_workspace_started_idx", @@ -68190,9 +69783,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_operations_company_workspace_issue_started_idx": { "name": "workspace_operations_company_workspace_issue_started_idx", @@ -68223,63 +69816,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "workspace_operations_company_id_companies_id_fk": { "name": "workspace_operations_company_id_companies_id_fk", "tableFrom": "workspace_operations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "workspace_operations_execution_workspace_id_execution_workspaces_id_fk": { "name": "workspace_operations_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "workspace_operations", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk": { "name": "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk", "tableFrom": "workspace_operations", + "tableTo": "heartbeat_runs", "columnsFrom": [ "heartbeat_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_operations_issue_id_issues_id_fk": { "name": "workspace_operations_issue_id_issues_id_fk", "tableFrom": "workspace_operations", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -68502,9 +70095,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_runtime_services_company_execution_workspace_status_idx": { "name": "workspace_runtime_services_company_execution_workspace_status_idx", @@ -68529,9 +70122,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_runtime_services_company_project_status_idx": { "name": "workspace_runtime_services_company_project_status_idx", @@ -68556,9 +70149,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_runtime_services_run_idx": { "name": "workspace_runtime_services_run_idx", @@ -68571,9 +70164,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "workspace_runtime_services_company_updated_idx": { "name": "workspace_runtime_services_company_updated_idx", @@ -68592,102 +70185,102 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "workspace_runtime_services_company_id_companies_id_fk": { "name": "workspace_runtime_services_company_id_companies_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" }, "workspace_runtime_services_project_id_projects_id_fk": { "name": "workspace_runtime_services_project_id_projects_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "projects", "columnsFrom": [ "project_id" ], - "tableTo": "projects", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk": { "name": "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "project_workspaces", "columnsFrom": [ "project_workspace_id" ], - "tableTo": "project_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_runtime_services_execution_workspace_id_execution_workspaces_id_fk": { "name": "workspace_runtime_services_execution_workspace_id_execution_workspaces_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "execution_workspaces", "columnsFrom": [ "execution_workspace_id" ], - "tableTo": "execution_workspaces", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_runtime_services_issue_id_issues_id_fk": { "name": "workspace_runtime_services_issue_id_issues_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "issues", "columnsFrom": [ "issue_id" ], - "tableTo": "issues", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_runtime_services_owner_agent_id_agents_id_fk": { "name": "workspace_runtime_services_owner_agent_id_agents_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "agents", "columnsFrom": [ "owner_agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" }, "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk": { "name": "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk", "tableFrom": "workspace_runtime_services", + "tableTo": "heartbeat_runs", "columnsFrom": [ "started_by_run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -68841,9 +70434,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_attachment_upload_expiry_idx": { "name": "mcp_attachment_upload_expiry_idx", @@ -68856,50 +70449,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_attachment_uploads_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_attachment_uploads_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_attachment_uploads", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_attachment_uploads_company_id_companies_id_fk": { "name": "mcp_attachment_uploads_company_id_companies_id_fk", "tableFrom": "mcp_attachment_uploads", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_attachment_uploads_user_id_user_id_fk": { "name": "mcp_attachment_uploads_user_id_user_id_fk", "tableFrom": "mcp_attachment_uploads", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -68975,9 +70568,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_event_admissions_grant_idx": { "name": "mcp_event_admissions_grant_idx", @@ -68990,9 +70583,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_event_admissions_company_idx": { "name": "mcp_event_admissions_company_idx", @@ -69005,37 +70598,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_event_admissions_company_id_companies_id_fk": { "name": "mcp_event_admissions_company_id_companies_id_fk", "tableFrom": "mcp_event_admissions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_event_admissions_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_event_admissions_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_event_admissions", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -69124,9 +70717,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_event_deliveries_activity_uq": { "name": "mcp_event_deliveries_activity_uq", @@ -69145,9 +70738,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_event_deliveries_due_idx": { "name": "mcp_event_deliveries_due_idx", @@ -69160,24 +70753,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_event_deliveries_subscription_id_mcp_event_subscriptions_id_fk": { "name": "mcp_event_deliveries_subscription_id_mcp_event_subscriptions_id_fk", "tableFrom": "mcp_event_deliveries", + "tableTo": "mcp_event_subscriptions", "columnsFrom": [ "subscription_id" ], - "tableTo": "mcp_event_subscriptions", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -69288,9 +70881,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_event_subscriptions_company_idx": { "name": "mcp_event_subscriptions_company_idx", @@ -69303,37 +70896,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_event_subscriptions_company_id_companies_id_fk": { "name": "mcp_event_subscriptions_company_id_companies_id_fk", "tableFrom": "mcp_event_subscriptions", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_event_subscriptions_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_event_subscriptions_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_event_subscriptions", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -69413,9 +71006,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_file_ticket_grant_idx": { "name": "mcp_file_ticket_grant_idx", @@ -69428,50 +71021,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_file_tickets_company_id_companies_id_fk": { "name": "mcp_file_tickets_company_id_companies_id_fk", "tableFrom": "mcp_file_tickets", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_file_tickets_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_file_tickets_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_file_tickets", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_file_tickets_upload_id_mcp_attachment_uploads_id_fk": { "name": "mcp_file_tickets_upload_id_mcp_attachment_uploads_id_fk", "tableFrom": "mcp_file_tickets", + "tableTo": "mcp_attachment_uploads", "columnsFrom": [ "upload_id" ], - "tableTo": "mcp_attachment_uploads", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -69578,9 +71171,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_mutation_receipts_company_idx": { "name": "mcp_mutation_receipts_company_idx", @@ -69593,50 +71186,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_mutation_receipts_company_id_companies_id_fk": { "name": "mcp_mutation_receipts_company_id_companies_id_fk", "tableFrom": "mcp_mutation_receipts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_mutation_receipts_user_id_user_id_fk": { "name": "mcp_mutation_receipts_user_id_user_id_fk", "tableFrom": "mcp_mutation_receipts", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_mutation_receipts_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_mutation_receipts_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_mutation_receipts", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -69686,9 +71279,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -69942,9 +71535,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_user_code_uq": { "name": "mcp_oauth_user_code_uq", @@ -69957,9 +71550,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_device_expiry_idx": { "name": "mcp_oauth_device_expiry_idx", @@ -69972,37 +71565,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_oauth_device_requests_client_id_mcp_oauth_clients_id_fk": { "name": "mcp_oauth_device_requests_client_id_mcp_oauth_clients_id_fk", "tableFrom": "mcp_oauth_device_requests", + "tableTo": "mcp_oauth_clients", "columnsFrom": [ "client_id" ], - "tableTo": "mcp_oauth_clients", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_oauth_device_requests_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_oauth_device_requests_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_oauth_device_requests", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -70115,63 +71708,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_oauth_grants_company_id_companies_id_fk": { "name": "mcp_oauth_grants_company_id_companies_id_fk", "tableFrom": "mcp_oauth_grants", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_oauth_grants_user_id_user_id_fk": { "name": "mcp_oauth_grants_user_id_user_id_fk", "tableFrom": "mcp_oauth_grants", + "tableTo": "user", "columnsFrom": [ "user_id" ], - "tableTo": "user", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_oauth_grants_client_id_mcp_oauth_clients_id_fk": { "name": "mcp_oauth_grants_client_id_mcp_oauth_clients_id_fk", "tableFrom": "mcp_oauth_grants", + "tableTo": "mcp_oauth_clients", "columnsFrom": [ "client_id" ], - "tableTo": "mcp_oauth_clients", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_oauth_grants_agent_id_agents_id_fk": { "name": "mcp_oauth_grants_agent_id_agents_id_fk", "tableFrom": "mcp_oauth_grants", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -70216,9 +71809,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": {}, @@ -70330,9 +71923,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_requests_expiry_idx": { "name": "mcp_oauth_requests_expiry_idx", @@ -70345,37 +71938,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_oauth_requests_client_id_mcp_oauth_clients_id_fk": { "name": "mcp_oauth_requests_client_id_mcp_oauth_clients_id_fk", "tableFrom": "mcp_oauth_requests", + "tableTo": "mcp_oauth_clients", "columnsFrom": [ "client_id" ], - "tableTo": "mcp_oauth_clients", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "mcp_oauth_requests_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_oauth_requests_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_oauth_requests", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -70452,9 +72045,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_tokens_grant_idx": { "name": "mcp_oauth_tokens_grant_idx", @@ -70467,9 +72060,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_tokens_revocation_revision_idx": { "name": "mcp_oauth_tokens_revocation_revision_idx", @@ -70494,9 +72087,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "mcp_oauth_tokens_expiry_idx": { "name": "mcp_oauth_tokens_expiry_idx", @@ -70509,24 +72102,24 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "mcp_oauth_tokens_grant_id_mcp_oauth_grants_id_fk": { "name": "mcp_oauth_tokens_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "mcp_oauth_tokens", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -70659,9 +72252,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "external_holds_agent_idx": { "name": "external_holds_agent_idx", @@ -70680,37 +72273,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "external_agent_holds_company_id_companies_id_fk": { "name": "external_agent_holds_company_id_companies_id_fk", "tableFrom": "external_agent_holds", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "external_agent_holds_agent_id_agents_id_fk": { "name": "external_agent_holds_agent_id_agents_id_fk", "tableFrom": "external_agent_holds", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -70923,10 +72516,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"muse_agent_bindings\".\"revoked_at\" IS NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "muse_bindings_ticket_uq": { "name": "muse_bindings_ticket_uq", @@ -70939,9 +72532,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "muse_bindings_active_grant_uq": { "name": "muse_bindings_active_grant_uq", @@ -70954,51 +72547,51 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"muse_agent_bindings\".\"revoked_at\" IS NULL AND \"muse_agent_bindings\".\"grant_id\" IS NOT NULL", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { "muse_agent_bindings_company_id_companies_id_fk": { "name": "muse_agent_bindings_company_id_companies_id_fk", "tableFrom": "muse_agent_bindings", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_agent_bindings_agent_id_agents_id_fk": { "name": "muse_agent_bindings_agent_id_agents_id_fk", "tableFrom": "muse_agent_bindings", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_agent_bindings_grant_id_mcp_oauth_grants_id_fk": { "name": "muse_agent_bindings_grant_id_mcp_oauth_grants_id_fk", "tableFrom": "muse_agent_bindings", + "tableTo": "mcp_oauth_grants", "columnsFrom": [ "grant_id" ], - "tableTo": "mcp_oauth_grants", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71092,9 +72685,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "muse_credentials_binding_idx": { "name": "muse_credentials_binding_idx", @@ -71113,37 +72706,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_credentials_company_id_companies_id_fk": { "name": "muse_credentials_company_id_companies_id_fk", "tableFrom": "muse_credentials", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_credentials_binding_id_muse_agent_bindings_id_fk": { "name": "muse_credentials_binding_id_muse_agent_bindings_id_fk", "tableFrom": "muse_credentials", + "tableTo": "muse_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "muse_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71231,37 +72824,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_idle_receipts_company_id_companies_id_fk": { "name": "muse_idle_receipts_company_id_companies_id_fk", "tableFrom": "muse_idle_receipts", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_idle_receipts_binding_id_muse_agent_bindings_id_fk": { "name": "muse_idle_receipts_binding_id_muse_agent_bindings_id_fk", "tableFrom": "muse_idle_receipts", + "tableTo": "muse_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "muse_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71361,9 +72954,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "muse_input_source_uq": { "name": "muse_input_source_uq", @@ -71382,37 +72975,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_input_deliveries_company_id_companies_id_fk": { "name": "muse_input_deliveries_company_id_companies_id_fk", "tableFrom": "muse_input_deliveries", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_input_deliveries_assignment_id_muse_runner_assignments_id_fk": { "name": "muse_input_deliveries_assignment_id_muse_runner_assignments_id_fk", "tableFrom": "muse_input_deliveries", + "tableTo": "muse_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "muse_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71518,9 +73111,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "muse_mailbox_cursor_idx": { "name": "muse_mailbox_cursor_idx", @@ -71545,50 +73138,50 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_mailbox_items_company_id_companies_id_fk": { "name": "muse_mailbox_items_company_id_companies_id_fk", "tableFrom": "muse_mailbox_items", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_mailbox_items_binding_id_muse_agent_bindings_id_fk": { "name": "muse_mailbox_items_binding_id_muse_agent_bindings_id_fk", "tableFrom": "muse_mailbox_items", + "tableTo": "muse_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "muse_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_mailbox_items_assignment_id_muse_runner_assignments_id_fk": { "name": "muse_mailbox_items_assignment_id_muse_runner_assignments_id_fk", "tableFrom": "muse_mailbox_items", + "tableTo": "muse_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "muse_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71720,37 +73313,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_receiver_contact_buckets_company_id_companies_id_fk": { "name": "muse_receiver_contact_buckets_company_id_companies_id_fk", "tableFrom": "muse_receiver_contact_buckets", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_receiver_contact_buckets_binding_id_muse_agent_bindings_id_fk": { "name": "muse_receiver_contact_buckets_binding_id_muse_agent_bindings_id_fk", "tableFrom": "muse_receiver_contact_buckets", + "tableTo": "muse_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "muse_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -71919,9 +73512,9 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "muse_assignments_live_binding_uq": { "name": "muse_assignments_live_binding_uq", @@ -71934,10 +73527,10 @@ } ], "isUnique": true, - "with": {}, - "method": "btree", "where": "\"muse_runner_assignments\".\"status\" IN ('offered','claimed','accepted')", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "muse_assignments_company_idx": { "name": "muse_assignments_company_idx", @@ -71950,63 +73543,63 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_runner_assignments_company_id_companies_id_fk": { "name": "muse_runner_assignments_company_id_companies_id_fk", "tableFrom": "muse_runner_assignments", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_runner_assignments_binding_id_muse_agent_bindings_id_fk": { "name": "muse_runner_assignments_binding_id_muse_agent_bindings_id_fk", "tableFrom": "muse_runner_assignments", + "tableTo": "muse_agent_bindings", "columnsFrom": [ "binding_id" ], - "tableTo": "muse_agent_bindings", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_runner_assignments_run_id_heartbeat_runs_id_fk": { "name": "muse_runner_assignments_run_id_heartbeat_runs_id_fk", "tableFrom": "muse_runner_assignments", + "tableTo": "heartbeat_runs", "columnsFrom": [ "run_id" ], - "tableTo": "heartbeat_runs", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_runner_assignments_agent_id_agents_id_fk": { "name": "muse_runner_assignments_agent_id_agents_id_fk", "tableFrom": "muse_runner_assignments", + "tableTo": "agents", "columnsFrom": [ "agent_id" ], - "tableTo": "agents", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72114,37 +73707,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "muse_runner_operations_company_id_companies_id_fk": { "name": "muse_runner_operations_company_id_companies_id_fk", "tableFrom": "muse_runner_operations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "muse_runner_operations_assignment_id_muse_runner_assignments_id_fk": { "name": "muse_runner_operations_assignment_id_muse_runner_assignments_id_fk", "tableFrom": "muse_runner_operations", + "tableTo": "muse_runner_assignments", "columnsFrom": [ "assignment_id" ], - "tableTo": "muse_runner_assignments", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72202,15 +73795,15 @@ "company_prompt_injection_prevention_company_id_companies_id_fk": { "name": "company_prompt_injection_prevention_company_id_companies_id_fk", "tableFrom": "company_prompt_injection_prevention", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72424,9 +74017,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "prompt_injection_invocations_pending_idx": { "name": "prompt_injection_invocations_pending_idx", @@ -72439,10 +74032,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"prompt_injection_invocations\".\"status\" = 'running'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "prompt_injection_invocations_cost_idx": { "name": "prompt_injection_invocations_cost_idx", @@ -72455,37 +74048,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "prompt_injection_invocations_company_id_companies_id_fk": { "name": "prompt_injection_invocations_company_id_companies_id_fk", "tableFrom": "prompt_injection_invocations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "prompt_injection_invocations_cost_event_id_cost_events_id_fk": { "name": "prompt_injection_invocations_cost_event_id_cost_events_id_fk", "tableFrom": "prompt_injection_invocations", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72667,9 +74260,9 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} }, "responsibility_summary_invocations_pending_idx": { "name": "responsibility_summary_invocations_pending_idx", @@ -72682,10 +74275,10 @@ } ], "isUnique": false, - "with": {}, - "method": "btree", "where": "\"responsibility_summary_invocations\".\"status\" = 'running'", - "concurrently": false + "concurrently": false, + "method": "btree", + "with": {} }, "responsibility_summary_invocations_cost_idx": { "name": "responsibility_summary_invocations_cost_idx", @@ -72698,37 +74291,37 @@ } ], "isUnique": false, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "responsibility_summary_invocations_company_id_companies_id_fk": { "name": "responsibility_summary_invocations_company_id_companies_id_fk", "tableFrom": "responsibility_summary_invocations", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "responsibility_summary_invocations_cost_event_id_cost_events_id_fk": { "name": "responsibility_summary_invocations_cost_event_id_cost_events_id_fk", "tableFrom": "responsibility_summary_invocations", + "tableTo": "cost_events", "columnsFrom": [ "cost_event_id" ], - "tableTo": "cost_events", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72813,37 +74406,37 @@ } ], "isUnique": true, - "with": {}, + "concurrently": false, "method": "btree", - "concurrently": false + "with": {} } }, "foreignKeys": { "plugin_connector_legacy_access_company_id_companies_id_fk": { "name": "plugin_connector_legacy_access_company_id_companies_id_fk", "tableFrom": "plugin_connector_legacy_access", + "tableTo": "companies", "columnsFrom": [ "company_id" ], - "tableTo": "companies", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" }, "plugin_connector_legacy_access_connection_id_tool_connections_id_fk": { "name": "plugin_connector_legacy_access_connection_id_tool_connections_id_fk", "tableFrom": "plugin_connector_legacy_access", + "tableTo": "tool_connections", "columnsFrom": [ "connection_id" ], - "tableTo": "tool_connections", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "set null" + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -72855,21 +74448,21 @@ }, "enums": {}, "schemas": {}, - "views": {}, "sequences": { "public.chat_telegram_draft_ids": { "name": "chat_telegram_draft_ids", + "schema": "public", "increment": "1", + "startWith": "1", "minValue": "1", "maxValue": "2147483647", - "startWith": "1", "cache": "1", - "cycle": false, - "schema": "public" + "cycle": false } }, "roles": {}, "policies": {}, + "views": {}, "_meta": { "columns": {}, "schemas": {}, diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json index 2258adff6de..1a4b92305c8 100644 --- a/packages/db/src/migrations/meta/_journal.json +++ b/packages/db/src/migrations/meta/_journal.json @@ -3585,6 +3585,13 @@ "when": 1796171923647, "tag": "0513_closed_wither", "breakpoints": true + }, + { + "idx": 514, + "version": "7", + "when": 1796346310107, + "tag": "0514_lame_ricochet", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema/issue_attachments.ts b/packages/db/src/schema/issue_attachments.ts index c3c919c89f4..c5b864cb337 100644 --- a/packages/db/src/schema/issue_attachments.ts +++ b/packages/db/src/schema/issue_attachments.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core"; +import { pgTable, uuid, timestamp, boolean, index, uniqueIndex } from "drizzle-orm/pg-core"; import { companies } from "./companies.js"; import { issues } from "./issues.js"; import { assets } from "./assets.js"; @@ -16,6 +16,10 @@ export const issueAttachments = pgTable( originatingRunId: uuid("originating_run_id").references(() => heartbeatRuns.id, { onDelete: "set null", }), + // True only for files a person attached to the task itself (new-task files, + // the task attachment picker, or the description editor). Comment-composer + // uploads stay false until they are bound to their comment. + issueLevel: boolean("issue_level").notNull().default(false), createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), }, diff --git a/packages/shared/src/validators/issue.ts b/packages/shared/src/validators/issue.ts index 4c12ab467ae..6be63e693fa 100644 --- a/packages/shared/src/validators/issue.ts +++ b/packages/shared/src/validators/issue.ts @@ -2485,6 +2485,11 @@ export type LinkIssueApproval = z.infer; export const createIssueAttachmentMetadataSchema = z.object({ issueCommentId: z.string().guid().optional().nullable(), + // A file attached to the task itself, not a comment-composer upload. Sent as + // a multipart field, so the string forms are accepted. + issueLevel: z + .union([z.boolean(), z.enum(["true", "false"]).transform((value) => value === "true")]) + .optional(), }); export type CreateIssueAttachmentMetadata = z.infer< diff --git a/server/src/__tests__/issue-attachment-routes.test.ts b/server/src/__tests__/issue-attachment-routes.test.ts index ad22f192047..ea81cdbd1ec 100644 --- a/server/src/__tests__/issue-attachment-routes.test.ts +++ b/server/src/__tests__/issue-attachment-routes.test.ts @@ -294,6 +294,30 @@ describe("issue attachment routes", () => { expect(res.body.contentType).toBe("application/zip"); }); + it("records task-level uploads and leaves composer uploads unmarked", async () => { + const storage = createStorageService(); + mockIssueService.getById.mockResolvedValue({ + id: "11111111-1111-4111-8111-111111111111", + companyId: "company-1", + identifier: "PAP-1", + }); + mockIssueService.createAttachment.mockResolvedValue(makeAttachment("image/png", "list.png")); + const app = await createApp(storage); + const upload = () => request(app) + .post("/api/companies/company-1/issues/11111111-1111-4111-8111-111111111111/attachments") + .attach("file", Buffer.from("png"), { filename: "list.png", contentType: "image/png" }); + + expect([200, 201]).toContain((await upload().field("issueLevel", "true")).status); + expect(mockIssueService.createAttachment).toHaveBeenLastCalledWith( + expect.objectContaining({ issueCommentId: null, issueLevel: true }), + ); + expect([200, 201]).toContain((await upload()).status); + expect(mockIssueService.createAttachment).toHaveBeenLastCalledWith( + expect.objectContaining({ issueCommentId: null, issueLevel: false }), + ); + expect((await upload().field("issueLevel", "yes")).status).toBe(400); + }); + it("removes a newly stored object when attachment registration is rejected", async () => { const storage = createStorageService(); const { HttpError } = await vi.importActual< diff --git a/server/src/routes/issues.ts b/server/src/routes/issues.ts index 47762806d9f..2b268742e8e 100644 --- a/server/src/routes/issues.ts +++ b/server/src/routes/issues.ts @@ -21409,6 +21409,7 @@ export function issueRoutes( attachment = await svc.createAttachment({ issueId, issueCommentId: parsedMeta.data.issueCommentId ?? null, + issueLevel: parsedMeta.data.issueLevel === true, provider: stored.provider, objectKey: stored.objectKey, contentType: stored.contentType, diff --git a/server/src/services/issues.ts b/server/src/services/issues.ts index 5f96e97ecc3..7710deaf05e 100644 --- a/server/src/services/issues.ts +++ b/server/src/services/issues.ts @@ -3822,7 +3822,8 @@ async function attachOwnedDraftImages(tx: DbTransaction, issue: typeof issues.$i actor.userId ? eq(assets.createdByUserId, actor.userId) : eq(assets.createdByAgentId, actor.agentId!))); for (const asset of owned) { if (!asset.objectKey.startsWith(`${issue.companyId}/assets/issues/drafts/`)) continue; - await tx.insert(issueAttachments).values({ companyId: issue.companyId, issueId: issue.id, assetId: asset.id }).onConflictDoNothing(); + await tx.insert(issueAttachments).values({ companyId: issue.companyId, issueId: issue.id, assetId: asset.id, issueLevel: true }) + .onConflictDoNothing(); } } @@ -14667,6 +14668,7 @@ export function issueService(db: Db) { createAttachment: async (input: { issueId: string; issueCommentId?: string | null; + issueLevel?: boolean; provider: string; objectKey: string; contentType: string; @@ -14821,6 +14823,7 @@ export function issueService(db: Db) { issueId: issue.id, assetId: asset.id, issueCommentId: input.issueCommentId ?? null, + issueLevel: input.issueLevel === true && !input.issueCommentId, originatingRunId: registeredRunId, }) .returning(); diff --git a/server/src/services/native-runtime/native-runner-file-handoff.ts b/server/src/services/native-runtime/native-runner-file-handoff.ts index 688564e7b31..b81cba13140 100644 --- a/server/src/services/native-runtime/native-runner-file-handoff.ts +++ b/server/src/services/native-runtime/native-runner-file-handoff.ts @@ -14,7 +14,7 @@ import { } from "node:fs/promises"; import path from "node:path"; -import { and, eq, inArray, isNull, sql } from "drizzle-orm"; +import { and, asc, eq, inArray, isNotNull, isNull, or, sql } from "drizzle-orm"; import type { Db } from "@paperclipai/db"; import { @@ -36,6 +36,7 @@ import { getStorageService } from "../../storage/index.js"; import type { StorageService } from "../../storage/types.js"; import { readProcessStartedAt } from "../hot-restart.js"; import { issueService } from "../issues.js"; +import { isLowTrustQuarantined } from "../source-trust.js"; import { getNativeReviewAssignment, readNativeReviewAssignmentContext } from "./native-review-participant.js"; export type RemoteWorkspaceFileReader = (input: Pick) => Promise; @@ -90,6 +91,8 @@ export interface NativeRunnerStagedAttachment { readonly workspaceRelativePath: string | null; readonly runnerLocalPath?: string; readonly unavailableReason: string | null; + /** Attached to the task itself rather than to a wake comment. */ + readonly taskAttachment?: true; } export interface NativeRunnerAttachmentStage { @@ -104,7 +107,8 @@ export type NativeRunnerAttachmentStager = (input: { body: Buffer; contentType?: export type NativeRunnerAttachmentSource = { attachmentId: string; - sourceCommentId: string; + /** Null only for a wake-staged attachment on the task description. */ + sourceCommentId: string | null; kind: "wake" | "history"; contentType: string; byteSize: number; @@ -483,6 +487,10 @@ function wakeAttachmentSelections(value: unknown): Array<{ return selected; } +function taskAttachmentMarker(row: { issueCommentId: string | null }) { + return row.issueCommentId === null ? { taskAttachment: true as const } : {}; +} + async function ensurePrivateStagingDirectory( workspaceRoot: string, processDirectoryName: string, @@ -835,6 +843,7 @@ export async function resolveNativeRunnerWakeAttachmentSelections(input: { contextSnapshot: heartbeatRuns.contextSnapshot, agentStatus: agents.status, assigneeAgentId: issues.assigneeAgentId, + issueSourceTrust: issues.sourceTrust, }) .from(heartbeatRuns) .innerJoin( @@ -887,10 +896,52 @@ export async function resolveNativeRunnerWakeAttachmentSelections(input: { if (run.assigneeAgentId !== input.binding.agentId && !nativeReview) { throw new Error("paperclip_runner_attachment_staging_not_authorized"); } - const selections = wakeAttachmentSelections(run.contextSnapshot); + const selections: Array<{ readonly id: string; readonly commentId: string | null }> = + wakeAttachmentSelections(run.contextSnapshot); if (selections.length > MAX_NATIVE_STAGED_ATTACHMENTS) { throw new Error("paperclip_runner_attachment_staging_count_denied"); } + // Files a person attached to the task itself (usually description + // screenshots) are part of every turn's assignment, but no wake comment + // carries them. Stage them after the current wake's files, within the same + // per-run limit. Unbound comment-composer uploads and system files also have + // no comment, so a row qualifies only when it is marked issue-level or the + // saved description links to it (files saved before the marker existed). + // Only files a person uploaded qualify: an agent, including a low-trust one, + // can mark or link its own upload, and agent files carry no per-file trust. + const remaining = MAX_NATIVE_STAGED_ATTACHMENTS - selections.length; + if (remaining > 0 && !isLowTrustQuarantined(run.issueSourceTrust)) { + const taskAttachments = await input.db + .select({ id: issueAttachments.id }) + .from(issueAttachments) + .innerJoin( + issues, + and(eq(issues.id, issueAttachments.issueId), eq(issues.companyId, issueAttachments.companyId)), + ) + .innerJoin( + assets, + and(eq(assets.id, issueAttachments.assetId), eq(assets.companyId, issueAttachments.companyId)), + ) + .where( + and( + eq(issueAttachments.companyId, input.binding.companyId), + eq(issueAttachments.issueId, input.binding.issueId), + isNull(issueAttachments.issueCommentId), + isNotNull(assets.createdByUserId), + isNull(assets.createdByAgentId), + or( + eq(issueAttachments.issueLevel, true), + sql`strpos(coalesce(${issues.description}, ''), '/api/attachments/' || ${issueAttachments.id}::text || '/content') > 0`, + sql`strpos(coalesce(${issues.description}, ''), '/api/assets/' || ${issueAttachments.assetId}::text || '/content') > 0`, + ), + ), + ) + .orderBy(asc(issueAttachments.createdAt), asc(issueAttachments.id)) + .limit(remaining); + for (const attachment of taskAttachments) { + selections.push({ id: attachment.id, commentId: null }); + } + } return selections; } @@ -1013,6 +1064,7 @@ export async function stageNativeRunnerWakeAttachments(input: { byteSize: row?.byteSize ?? 0, workspaceRelativePath: null, unavailableReason: "remote_workspace_staging_unsupported", + ...taskAttachmentMarker({ issueCommentId: selection.commentId }), }; }), cleanup: async () => undefined, @@ -1036,6 +1088,7 @@ export async function stageNativeRunnerWakeAttachments(input: { byteSize: 0, workspaceRelativePath: null, unavailableReason: "attachment_binding_unavailable", + ...taskAttachmentMarker({ issueCommentId: selection.commentId }), }); continue; } @@ -1053,6 +1106,7 @@ export async function stageNativeRunnerWakeAttachments(input: { id: row.id, filename: row.filename?.trim() || "attachment", contentType: row.contentType, byteSize: row.byteSize, workspaceRelativePath: null, runnerLocalPath, unavailableReason: null, + ...taskAttachmentMarker(row), }); continue; } @@ -1075,6 +1129,7 @@ export async function stageNativeRunnerWakeAttachments(input: { byteSize: row.byteSize, workspaceRelativePath: written.relativePath, unavailableReason: null, + ...taskAttachmentMarker(row), }); } catch { staged.push({ @@ -1084,6 +1139,7 @@ export async function stageNativeRunnerWakeAttachments(input: { byteSize: row.byteSize, workspaceRelativePath: null, unavailableReason: "attachment_staging_failed", + ...taskAttachmentMarker(row), }); } } @@ -1130,6 +1186,7 @@ export function renderNativeRunnerStagedAttachmentPrompt( workspaceRelativePath: attachment.workspaceRelativePath, runnerLocalPath: attachment.runnerLocalPath, unavailableReason: attachment.unavailableReason, + taskAttachment: attachment.taskAttachment, })}`, ); } diff --git a/server/src/services/native-runtime/native-runner-task-attachment-staging.test.ts b/server/src/services/native-runtime/native-runner-task-attachment-staging.test.ts new file mode 100644 index 00000000000..ccb859a0832 --- /dev/null +++ b/server/src/services/native-runtime/native-runner-task-attachment-staging.test.ts @@ -0,0 +1,344 @@ +import express from "express"; +import request from "supertest"; +import { createHash, randomUUID } from "node:crypto"; +import { mkdtemp, readFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; + +import { eq } from "drizzle-orm"; +import { afterAll, beforeAll, describe, expect, it } from "vitest"; +import { LOW_TRUST_REVIEW_PRESET } from "@paperclipai/shared"; +import { agents, assets, companies, createDb, heartbeatRuns, issueAttachments, issues } from "@paperclipai/db"; + +import { startEmbeddedPostgresTestDatabase } from "../../__tests__/helpers/embedded-postgres.js"; +import { createLocalDiskStorageProvider } from "../../storage/local-disk-provider.js"; +import { createStorageService } from "../../storage/service.js"; +import { issueService } from "../issues.js"; +import { + renderNativeRunnerStagedAttachmentPrompt, + stageNativeRunnerWakeAttachments, + type NativeRunnerAttachmentSource, +} from "./native-runner-file-handoff.js"; +import { + createRunnerAttachmentGrant, + RUNNER_ATTACHMENT_DOWNLOAD_PATH, + runnerAttachmentDownloadRoutes, +} from "./runner-attachment-download.js"; + +describe("native task-description attachment staging", () => { + let temporary: Awaited> | null = null; + let db: ReturnType; + let storage: ReturnType; + let workspaceRoot: string; + + const companyId = "10000000-0000-4000-8000-000000000201"; + const agentId = "10000000-0000-4000-8000-000000000202"; + const issueId = "10000000-0000-4000-8000-000000000203"; + const runId = "10000000-0000-4000-8000-000000000204"; + const userId = "task-attachment-user"; + const descriptionBody = Buffer.from("description screenshot bytes", "utf8"); + const commentBody = Buffer.from("wake comment bytes", "utf8"); + let descriptionAttachmentId: string; + let draftAttachmentId: string; + let commentId: string; + let commentAttachmentId: string; + const binding = { companyId, agentId, issueId, runId }; + + async function attach(input: { + body: Buffer; filename: string; contentType: string; issueCommentId?: string; issueLevel?: boolean; + }) { + const stored = await storage.putFile({ + companyId, + namespace: `issues/${issueId}`, + originalFilename: input.filename, + contentType: input.contentType, + body: input.body, + }); + return issueService(db).createAttachment({ + issueId, + issueCommentId: input.issueCommentId ?? null, + issueLevel: input.issueLevel, + provider: stored.provider, + objectKey: stored.objectKey, + contentType: stored.contentType, + byteSize: stored.byteSize, + sha256: stored.sha256, + originalFilename: stored.originalFilename, + createdByUserId: userId, + }); + } + + async function setWakeComments(comments: Array<{ id: string; attachmentIds: string[] }>) { + await db.update(heartbeatRuns).set({ + contextSnapshot: { + paperclipWake: { + comments: comments.map((comment) => ({ + id: comment.id, + attachments: comment.attachmentIds.map((id) => ({ id })), + })), + }, + }, + }).where(eq(heartbeatRuns.id, runId)); + } + + function stage(overrides: Partial[0]> = {}) { + return stageNativeRunnerWakeAttachments({ + db, + storage, + binding: { ...binding, workspaceRoot, executionTargetKind: "local" }, + ...overrides, + }); + } + + beforeAll(async () => { + temporary = await startEmbeddedPostgresTestDatabase("native-task-attachments-"); + db = createDb(temporary.connectionString); + workspaceRoot = await mkdtemp(path.join(tmpdir(), "paperclip-task-attachment-workspace-")); + storage = createStorageService( + createLocalDiskStorageProvider(await mkdtemp(path.join(tmpdir(), "paperclip-task-attachment-storage-"))), + ); + await db.insert(companies).values({ id: companyId, name: "Task attachments", issuePrefix: "NTA", issueCounter: 1 }); + await db.insert(agents).values({ + id: agentId, + companyId, + name: "Native task agent", + adapterType: "paperclip_runner", + adapterConfig: { provider: "acpx" }, + runtimeConfig: {}, + status: "active", + }); + await db.insert(issues).values({ + id: issueId, + companyId, + issueNumber: 1, + identifier: "NTA-1", + title: "Sort this list", + description: "This list should be sorted alphabetically", + status: "in_progress", + workMode: "standard", + assigneeAgentId: agentId, + }); + await db.insert(heartbeatRuns).values({ + id: runId, + companyId, + agentId, + status: "running", + runtimeMode: "native", + nativeIssueId: issueId, + invocationSource: "assignment", + triggerDetail: "system", + contextSnapshot: {}, + }); + await db.update(issues).set({ executionRunId: runId }).where(eq(issues.id, issueId)); + + descriptionAttachmentId = (await attach({ + body: descriptionBody, filename: "list.png", contentType: "image/png", issueLevel: true, + })).id; + // A comment-composer upload that the person removed before sending. + draftAttachmentId = (await attach({ + body: Buffer.from("removed draft screenshot"), filename: "removed.png", contentType: "image/png", + })).id; + commentId = (await issueService(db).addComment(issueId, "Here is another one", { userId })).id; + commentAttachmentId = (await attach({ + body: commentBody, filename: "comment.png", contentType: "image/png", issueCommentId: commentId, + })).id; + }); + + afterAll(async () => { + await temporary?.cleanup(); + }); + + it("stages task-description attachments on a wake without comments", async () => { + await setWakeComments([]); + const staged = await stage(); + try { + expect(staged.attachments).toEqual([ + expect.objectContaining({ + id: descriptionAttachmentId, + filename: "list.png", + contentType: "image/png", + unavailableReason: null, + taskAttachment: true, + }), + ]); + const relativePath = staged.attachments[0]!.workspaceRelativePath!; + await expect(readFile(path.join(workspaceRoot, relativePath))).resolves.toEqual(descriptionBody); + const prompt = renderNativeRunnerStagedAttachmentPrompt(staged.attachments); + expect(prompt).toContain(`"id":"${descriptionAttachmentId}"`); + expect(prompt).toContain(`"taskAttachment":true`); + } finally { + await staged.cleanup(); + } + }); + + it("stages an unmarked file that the saved description links to", async () => { + await setWakeComments([]); + const legacyBody = Buffer.from("screenshot saved before the issue-level marker"); + const legacy = await attach({ body: legacyBody, filename: "legacy.png", contentType: "image/png" }); + await db.update(issues).set({ + description: `Sort this list\n\n![legacy.png](/api/attachments/${legacy.id}/content)`, + }).where(eq(issues.id, issueId)); + try { + const staged = await stage(); + try { + expect(staged.attachments.map((attachment) => [attachment.id, attachment.taskAttachment])).toEqual([ + [descriptionAttachmentId, true], + [legacy.id, true], + ]); + } finally { + await staged.cleanup(); + } + } finally { + await db.update(issues).set({ description: "This list should be sorted alphabetically" }) + .where(eq(issues.id, issueId)); + await db.delete(issueAttachments).where(eq(issueAttachments.id, legacy.id)); + } + }); + + it("does not stage an agent upload that is marked or linked as a task file", async () => { + await setWakeComments([]); + // An agent, for example a low-trust one, can mark its own upload as + // issue-level and link it from the description. It is not a person's file. + const stored = await storage.putFile({ + companyId, namespace: `issues/${issueId}`, originalFilename: "agent.png", contentType: "image/png", + body: Buffer.from("agent-written bytes"), + }); + const [asset] = await db.insert(assets).values({ + companyId, provider: stored.provider, objectKey: stored.objectKey, contentType: stored.contentType, + byteSize: stored.byteSize, sha256: stored.sha256, originalFilename: stored.originalFilename, + createdByAgentId: agentId, + }).returning(); + const [agentFile] = await db.insert(issueAttachments).values({ + companyId, issueId, assetId: asset!.id, issueLevel: true, + }).returning(); + await db.update(issues).set({ + description: `Sort this list\n\n![agent.png](/api/attachments/${agentFile!.id}/content)`, + }).where(eq(issues.id, issueId)); + try { + const staged = await stage(); + try { + expect(staged.attachments.map((attachment) => attachment.id)).toEqual([descriptionAttachmentId]); + } finally { + await staged.cleanup(); + } + } finally { + await db.update(issues).set({ description: "This list should be sorted alphabetically" }) + .where(eq(issues.id, issueId)); + await db.delete(issueAttachments).where(eq(issueAttachments.id, agentFile!.id)); + } + }); + + it("does not stage unsent comment-composer uploads", async () => { + await setWakeComments([]); + const staged = await stage(); + try { + expect(staged.attachments.map((attachment) => attachment.id)).not.toContain(draftAttachmentId); + } finally { + await staged.cleanup(); + } + }); + + it("stages the wake comment's files first and marks only description files", async () => { + await setWakeComments([{ id: commentId, attachmentIds: [commentAttachmentId] }]); + const staged = await stage(); + try { + expect(staged.attachments.map((attachment) => [attachment.id, attachment.taskAttachment])).toEqual([ + [commentAttachmentId, undefined], + [descriptionAttachmentId, true], + ]); + expect(renderNativeRunnerStagedAttachmentPrompt(staged.attachments.slice(0, 1))) + .not.toContain("taskAttachment"); + } finally { + await staged.cleanup(); + } + }); + + it("keeps a full wake within the staging limit instead of failing", async () => { + const extra = []; + for (let index = 0; index < 19; index += 1) { + extra.push((await attach({ + body: Buffer.from(`comment ${index}`), filename: `extra-${index}.txt`, contentType: "text/plain", + issueCommentId: commentId, + })).id); + } + await setWakeComments([{ id: commentId, attachmentIds: [commentAttachmentId, ...extra] }]); + const staged = await stage(); + try { + expect(staged.attachments).toHaveLength(20); + expect(staged.attachments.some((attachment) => attachment.taskAttachment)).toBe(false); + } finally { + await staged.cleanup(); + } + }); + + it("does not stage description files of a quarantined low-trust task", async () => { + await setWakeComments([]); + await db.update(issues).set({ + sourceTrust: { preset: LOW_TRUST_REVIEW_PRESET, disposition: "quarantined" }, + }).where(eq(issues.id, issueId)); + try { + const staged = await stage(); + expect(staged.attachments).toEqual([]); + await staged.cleanup(); + } finally { + await db.update(issues).set({ sourceTrust: null }).where(eq(issues.id, issueId)); + } + }); + + it("serves a description file to the Runner only through a wake grant without a comment", async () => { + await setWakeComments([]); + const env = { PAPERCLIP_AGENT_JWT_SECRET: randomUUID() }; + const app = express(); + app.use(runnerAttachmentDownloadRoutes(db, storage, env)); + const url = "https://tenant.example/file"; + const description: NativeRunnerAttachmentSource = { + kind: "wake", + attachmentId: descriptionAttachmentId, + sourceCommentId: null, + contentType: "image/png", + byteSize: descriptionBody.length, + sha256: createHash("sha256").update(descriptionBody).digest("hex"), + }; + const download = (source: NativeRunnerAttachmentSource) => request(app).get(RUNNER_ATTACHMENT_DOWNLOAD_PATH) + .set("Authorization", `Bearer ${createRunnerAttachmentGrant(binding, source, "turn", url, env).token}`); + + const response = await download(description).expect(200); + expect(response.body).toEqual(descriptionBody); + // A description file never authorizes through a comment, and a comment + // file never authorizes as a description file. + await download({ ...description, sourceCommentId: commentId }).expect(404); + await download({ + ...description, + attachmentId: commentAttachmentId, + byteSize: commentBody.length, + sha256: createHash("sha256").update(commentBody).digest("hex"), + }).expect(404); + // An unsent composer upload is not a task file. + const draftBody = Buffer.from("removed draft screenshot"); + await download({ + ...description, + attachmentId: draftAttachmentId, + byteSize: draftBody.length, + sha256: createHash("sha256").update(draftBody).digest("hex"), + }).expect(404); + // Historical chat reads always name their source comment. + expect(() => createRunnerAttachmentGrant(binding, { ...description, kind: "history" }, "turn", url, env)) + .toThrow(); + + const local = await stage({ + binding: { ...binding, workspaceRoot, executionTargetKind: "remote" }, + downloadRemoteAttachment: async (source) => { + expect(source).toEqual(description); + return "/run/attachment-downloads/list.png"; + }, + }); + expect(local.attachments).toEqual([ + expect.objectContaining({ + id: descriptionAttachmentId, + runnerLocalPath: "/run/attachment-downloads/list.png", + taskAttachment: true, + }), + ]); + await local.cleanup(); + }); +}); diff --git a/server/src/services/native-runtime/runner-attachment-download.ts b/server/src/services/native-runtime/runner-attachment-download.ts index eda3f5f4bfe..895a7bf06be 100644 --- a/server/src/services/native-runtime/runner-attachment-download.ts +++ b/server/src/services/native-runtime/runner-attachment-download.ts @@ -1,6 +1,6 @@ import { createHmac, timingSafeEqual } from "node:crypto"; import { Router } from "express"; -import { and, eq } from "drizzle-orm"; +import { and, eq, isNull } from "drizzle-orm"; import { assets, heartbeatRuns, issueAttachments, type Db } from "@paperclipai/db"; import { z } from "zod"; import { MAX_ATTACHMENT_BYTES } from "../../attachment-types.js"; @@ -18,14 +18,15 @@ const maxBytes = Math.min(MAX_ATTACHMENT_BYTES, 10 * 1024 * 1024); const ttlMs = 30_000; const claimsSchema = z.object({ companyId: z.uuid(), issueId: z.uuid(), runId: z.uuid(), agentId: z.uuid(), - attachmentId: z.uuid(), sourceCommentId: z.uuid(), + // Null only for a wake-staged attachment on the task description. + attachmentId: z.uuid(), sourceCommentId: z.uuid().nullable(), kind: z.enum(["wake", "history"]), turnId: z.string().min(1).max(160), contentType: z.string().min(1).max(128), byteSize: z.number().int().min(0).max(maxBytes), sha256: z.string().regex(/^[a-f0-9]{64}$/), expiresAt: z.number().int(), -}).strict(); +}).strict().refine((claims) => claims.kind === "wake" || claims.sourceCommentId !== null); function signingSecret(env: NodeJS.ProcessEnv) { return env.PAPERCLIP_AGENT_JWT_SECRET?.trim() || env.BETTER_AUTH_SECRET?.trim(); @@ -85,6 +86,7 @@ export function verifyRunnerAttachmentGrant(token: string, env: NodeJS.ProcessEn async function authorizedSource(db: Db, claims: z.infer) { if (claims.kind === "history") { + if (claims.sourceCommentId === null) return null; const [run] = await db.select({ id: heartbeatRuns.id }).from(heartbeatRuns).where(and( eq(heartbeatRuns.companyId, claims.companyId), eq(heartbeatRuns.id, claims.runId), eq(heartbeatRuns.nativeIssueId, claims.issueId), eq(heartbeatRuns.agentId, claims.agentId), @@ -103,7 +105,11 @@ async function authorizedSource(db: Db, claims: z.infer) { eq(assets.id, issueAttachments.assetId), eq(assets.companyId, claims.companyId), )).where(and( eq(issueAttachments.companyId, claims.companyId), eq(issueAttachments.issueId, claims.issueId), - eq(issueAttachments.id, claims.attachmentId), eq(issueAttachments.issueCommentId, claims.sourceCommentId), + eq(issueAttachments.id, claims.attachmentId), + // The wake selection above already decided which task files qualify. + claims.sourceCommentId === null + ? isNull(issueAttachments.issueCommentId) + : eq(issueAttachments.issueCommentId, claims.sourceCommentId), )).limit(1); return attachment ?? null; } diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 31f3cff7ccd..07480d3b562 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -546,7 +546,7 @@ "packages/shared/src/validators/issue-chat-bootstrap.test.ts": "e1ebb9aa94da22c825bc3ddd32ce2cfc98bfe645", "packages/shared/src/validators/issue-tree-control.ts": "7144ef86a83e008ac0626e1d62a1d6164c46f438", "packages/shared/src/validators/issue.test.ts": "370c30797dedb3cad8fdf26a5ee4d2dbb0ba0c25", - "packages/shared/src/validators/issue.ts": "4c12ab467aee250dc726728a2627f2915ad3c71d", + "packages/shared/src/validators/issue.ts": "6be63e693fa2a7e0be85e90bbf4d2dcdea3c61da", "packages/shared/src/validators/json-schema.ts": "b6cba6a3f76b49afce1c7dc1c2f086ab946c6133", "packages/shared/src/validators/native-finalization.test.ts": "40c68bdd1d0e8a77cd70c4576fae53334fe5be0d", "packages/shared/src/validators/native-finalization.ts": "d4e674de6ac7d36385e6f6c2172fa16ffc9b1830", diff --git a/ui/src/api/issues.ts b/ui/src/api/issues.ts index d83283ba9b0..0eab5d93a56 100644 --- a/ui/src/api/issues.ts +++ b/ui/src/api/issues.ts @@ -799,11 +799,15 @@ export const issuesApi = { issueId: string, file: File, issueCommentId?: string | null, + // Marks a file attached to the task itself, not a comment-composer upload. + options?: { issueLevel?: boolean }, ) => { const form = new FormData(); form.append("file", file); if (issueCommentId) { form.append("issueCommentId", issueCommentId); + } else if (options?.issueLevel) { + form.append("issueLevel", "true"); } return api.postForm( `/companies/${companyId}/issues/${issueId}/attachments`, diff --git a/ui/src/components/NewIssueDialog.tsx b/ui/src/components/NewIssueDialog.tsx index 62be1810144..bdaa65af76e 100644 --- a/ui/src/components/NewIssueDialog.tsx +++ b/ui/src/components/NewIssueDialog.tsx @@ -284,7 +284,7 @@ export async function addStagedFilesToIssue(input: { baseRevisionId: null, }); } else { - await issuesApi.uploadAttachment(companyId, issueId, stagedFile.file); + await issuesApi.uploadAttachment(companyId, issueId, stagedFile.file, null, { issueLevel: true }); } if (identity && idempotencyKey) { receipts.add(identity); diff --git a/ui/src/hooks/useIssueArtifactUploads.ts b/ui/src/hooks/useIssueArtifactUploads.ts index bc058b77fc4..fe0e1a393c5 100644 --- a/ui/src/hooks/useIssueArtifactUploads.ts +++ b/ui/src/hooks/useIssueArtifactUploads.ts @@ -35,7 +35,7 @@ export function useIssueArtifactUploads(issue: Pick) client.setQueryData([...queryKeys.issues.documents(issue.id), "list"], current => [document, ...(current ?? []).filter(row => row.id !== document.id)]); void client.invalidateQueries({ queryKey: queryKeys.issues.documents(issue.id) }); } else { - const attachment = await issuesApi.uploadAttachment(issue.companyId, issue.id, file); + const attachment = await issuesApi.uploadAttachment(issue.companyId, issue.id, file, null, { issueLevel: true }); client.setQueryData(queryKeys.issues.attachments(issue.id), current => [attachment, ...(current ?? []).filter(row => row.id !== attachment.id)]); void client.invalidateQueries({ queryKey: queryKeys.issues.attachments(issue.id) }); } diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index 5769820db0b..c7cc629ebbd 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -6002,10 +6002,12 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS }, }); + // issueLevel marks files attached to the task itself (picker, description, + // documents). Comment-composer uploads stay unmarked until sent. const uploadAttachment = useMutation({ - mutationFn: async (file: File) => { + mutationFn: async ({ file, issueLevel = false }: { file: File; issueLevel?: boolean }) => { if (conversation) { - return issuesApi.uploadAttachment(conversation.agent.companyId, await resolveWritableIssueId(), file); + return issuesApi.uploadAttachment(conversation.agent.companyId, await resolveWritableIssueId(), file, null, { issueLevel }); } if (!loadedIssue) throw new Error("Task details are still loading. Please try again."); @@ -6013,6 +6015,8 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS loadedIssue.companyId, loadedIssue.id, file, + null, + { issueLevel }, ); }, onSuccess: (result) => { @@ -6448,7 +6452,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS feedbackTermsUrl: FEEDBACK_TERMS_URL, mentions: mentionOptions, externalReferences: externalObjectsState.isEnabled ? externalObjectsState.markdownReferences : undefined, - imageUploadHandler: async (file) => (await uploadAttachment.mutateAsync(file)).contentPath, + imageUploadHandler: async (file) => (await uploadAttachment.mutateAsync({ file, issueLevel: true })).contentPath, onVote: async (revisionId, vote, options) => { await feedbackVoteMutation.mutateAsync({ targetType: "issue_document_revision", targetId: revisionId, vote, @@ -7141,14 +7145,14 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS ); const handleCommentImageUpload = useCallback( async (file: File) => { - const attachment = await uploadAttachment.mutateAsync(file); + const attachment = await uploadAttachment.mutateAsync({ file }); return attachment.contentPath; }, [uploadAttachment], ); const handleCommentAttachImage = useCallback( async (file: File) => { - return uploadAttachment.mutateAsync(file); + return uploadAttachment.mutateAsync({ file }); }, [uploadAttachment], ); @@ -7682,7 +7686,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS if (isMarkdownFile(file)) { await importMarkdownDocument.mutateAsync(file); } else { - await uploadAttachment.mutateAsync(file); + await uploadAttachment.mutateAsync({ file, issueLevel: true }); } } if (fileInputRef.current) { @@ -7699,7 +7703,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS if (isMarkdownFile(file)) { await importMarkdownDocument.mutateAsync(file); } else { - await uploadAttachment.mutateAsync(file); + await uploadAttachment.mutateAsync({ file, issueLevel: true }); } } }; @@ -8346,11 +8350,11 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS : undefined } imageUploadHandler={async (file) => { - const attachment = await uploadAttachment.mutateAsync(file); + const attachment = await uploadAttachment.mutateAsync({ file, issueLevel: true }); return attachment.contentPath; }} onDropFile={async (file) => { - await uploadAttachment.mutateAsync(file); + await uploadAttachment.mutateAsync({ file, issueLevel: true }); }} /> { const attachment = - await uploadAttachment.mutateAsync(file); + await uploadAttachment.mutateAsync({ file, issueLevel: true }); return attachment.contentPath; }, onDropFile: async (file) => { - await uploadAttachment.mutateAsync(file); + await uploadAttachment.mutateAsync({ file, issueLevel: true }); }, } : undefined From a30541b793995147d3d0fece87f204ea450fc7cf Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 3 Dec 2026 21:18:38 -0600 Subject: [PATCH 012/119] fix(ui): fade out task status update caret unless hovered (#23402) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - On a task page, the activity thread shows status update rows such as "Ran commands, searched files" and their expanded activity rows. > - In `TaskChatRunnerActivityGroup`, the disclosure caret on the right edge stays at full opacity even when the user does not hover over the row. > - Other collapsible rows in the task thread (`TaskChatThinking`, `TaskChatProtocolActivityRow`) hide their disclosure carets at rest while preserving touch-device discoverability (`tc-hover-disclosure-caret`) and keeping expanded carets legible (`rotate-90 opacity-80`). > - This pull request fades out the right-side caret on runner activity phase toggles, folded read runs, and expandable activity rows unless hovered, keyboard-focused, or expanded, while sharing the repository's `.tc-hover-disclosure-caret` touch fallback. > - The benefit is a calmer task thread with no layout shift on hover, full keyboard accessibility, and consistent disclosure behavior across all task-chat rows. ## Linked Issues or Issue Description **What existing behavior does this improve?** The disclosure carets on the right side of task status update rows in `TaskChatRunnerActivityGroup` on the task page. **Subsystem affected** ui/ — React + Vite board UI **Current behavior** Activity status update rows such as "Ran commands, searched files", folded file-read rows, and expandable activity rows keep their right-side chevron caret visible at full opacity at rest. **Proposed behavior** When collapsed and not hovered, the right-side caret stays faded out (`opacity-0`). It fades in smoothly with the shared motion tokens (`--motion-duration-fast` and `--motion-ease-standard`) on row hover or keyboard `focus-visible`, and fades back out when hover or focus ends. While a row is expanded, the caret stays visible (`rotate-90 opacity-80`, brightening to `opacity-100` on hover/focus). All three carets include the shared `.tc-hover-disclosure-caret` class so touch-only devices (`@media (hover: none)`) keep the disclosure affordance discoverable. **Reason and benefit** Hiding the right-side caret at rest removes visual noise across activity updates in the task thread and aligns `TaskChatRunnerActivityGroup` with the existing hover-disclosure pattern in `TaskChatThinking`, `TaskChatProtocolActivityRow`, and `ui/src/index.css` (related: #12640, #15048). Using opacity instead of unmounting keeps row alignment stable on hover. **Breaking changes** None. ## What Changed - Extract a shared `DISCLOSURE_CARET_CLASS` constant in `ui/src/components/task-chat/TaskChatRunnerActivityGroup.tsx` including `tc-hover-disclosure-caret` and the shared motion tokens (`--motion-duration-fast`, `--motion-ease-standard`, `motion-reduce:transition-none`). - Add named group hooks (`group/activity-phase`, `group/read-run`, `group/activity-row`) to the three disclosure buttons in `TaskChatRunnerActivityGroup.tsx`. - Fade out each right-side `ChevronRight` caret at rest (`opacity-0`), reveal it on hover or keyboard focus (`group-hover/...:opacity-100`, `group-focus-visible/...:opacity-100`), and keep it visible while open (`rotate-90 opacity-80`). - Add unit tests in `ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx` covering completed summaries, active toggles, folded read runs, expanded activity rows, open/close state transitions, and `tc-hover-disclosure-caret`. ## Verification - Local focused Vitest on `0b46f7cf99`: `node node_modules/vitest/vitest.mjs run ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx ui/src/components/task-chat/antigravity-thread.test.tsx ui/src/components/task-chat/completed-activity-summary.test.ts` — 36/36 tests passed. - Local focused Vitest on `0b46f7cf99`: `node node_modules/vitest/vitest.mjs run ui/src/components/TaskChatThread.test.tsx` — 436 passed, 1 skipped. - Local token gates on `0b46f7cf99`: `pnpm check:token-gates` — all 4 token gates clean. - Local UI build on `0b46f7cf99`: `pnpm --filter @paperclipai/ui build` — built cleanly and verified compiled CSS emits `@media (hover:none){.tc-hover-disclosure-caret{opacity:1}}` and scoped `group-hover/*:opacity-100` rules. - GitHub Actions CI on `0b46f7cf99` ([run 46734780674](https://github.com/paperclipai/paperclip/actions/runs/46734780674)): all 30 checks passed (`ci / verify`, `ci / Build`, `ci / Typecheck + Release Registry`, `ci / General tests`, `ci / policy`, all 16 `ci / e2e` shards, `commitperclip PR Review`, `Socket Security`, `Superagent Security`, and `security/snyk`). - Automated reviews on `0b46f7cf99`: `ponytail-paperclip-review` (5/5, ship), `feynman-nuclear-review` (5/5), and `Greptile Review` (5/5; P2 note about `tc-hover-disclosure-caret` answered and resolved in-thread). ## Risks - Low risk. Only the opacity, rotation, and transition classes on the right-side disclosure carets change; click, expand/collapse, keyboard, and touch-device discoverability semantics stay intact. > This is a small UI polish change and does not overlap with planned core features in `ROADMAP.md`. ## Model Used - Google DeepMind Antigravity coding agent (Gemini model with reasoning/thinking mode, file editing, shell execution, and GitHub CLI tools; exact model ID and context window are not exposed by the runner environment). ## 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 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 --------- Co-authored-by: Paperclip --- .../TaskChatRunnerActivityGroup.test.tsx | 176 ++++++++++++++++++ .../task-chat/TaskChatRunnerActivityGroup.tsx | 32 +++- 2 files changed, 202 insertions(+), 6 deletions(-) create mode 100644 ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx diff --git a/ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx b/ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx new file mode 100644 index 00000000000..23659218776 --- /dev/null +++ b/ui/src/components/task-chat/TaskChatRunnerActivityGroup.test.tsx @@ -0,0 +1,176 @@ +// @vitest-environment jsdom + +import { act } from "react"; +import { createRoot, type Root } from "react-dom/client"; +import { afterEach, describe, expect, it } from "vitest"; +import { TaskChatRunnerActivityGroup } from "./TaskChatRunnerActivityGroup"; +import type { TaskChatActivityPhaseItem, TaskChatToolItem } from "./task-chat-model"; + +(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; + +let root: Root | null = null; +let container: HTMLDivElement | null = null; + +afterEach(() => { + act(() => root?.unmount()); + container?.remove(); + root = null; + container = null; +}); + +function toolItem( + id: string, + name: string, + target: string, + status: TaskChatToolItem["status"] = "completed", +): TaskChatToolItem { + return { + id, + kind: "tool", + name, + rawName: name, + target, + status, + }; +} + +function renderGroup(item: TaskChatActivityPhaseItem, defaultExpanded = false) { + container = document.createElement("div"); + document.body.append(container); + root = createRoot(container); + act(() => { + root!.render(); + }); + return container; +} + +describe("TaskChatRunnerActivityGroup disclosure carets", () => { + it("fades out the completed status summary caret unless hovered, focused, or expanded", () => { + const phase: TaskChatActivityPhaseItem = { + id: "phase-completed", + kind: "activity_phase", + active: false, + summary: "", + items: [ + toolItem("cmd-1", "Bash", "pnpm test"), + toolItem("grep-1", "Grep", "TaskChatRunnerActivityGroup"), + ], + }; + + const el = renderGroup(phase); + const toggle = el.querySelector('[data-testid="task-chat-activity-phase-toggle"]'); + expect(toggle).not.toBeNull(); + expect(toggle?.textContent).toContain("Ran commands, searched files"); + expect(toggle?.classList.contains("group/activity-phase")).toBe(true); + + const caret = toggle?.querySelector('[data-testid="task-chat-activity-phase-caret"]'); + expect(caret).not.toBeNull(); + expect(caret?.classList.contains("tc-hover-disclosure-caret")).toBe(true); + expect(caret?.classList.contains("opacity-0")).toBe(true); + expect(caret?.classList.contains("opacity-80")).toBe(false); + expect(caret?.classList.contains("transition-[opacity,transform]")).toBe(true); + expect(caret?.classList.contains("duration-(--motion-duration-fast)")).toBe(true); + expect(caret?.classList.contains("ease-(--motion-ease-standard)")).toBe(true); + expect(caret?.classList.contains("motion-reduce:transition-none")).toBe(true); + expect(caret?.classList.contains("group-hover/activity-phase:opacity-100")).toBe(true); + expect(caret?.classList.contains("group-focus-visible/activity-phase:opacity-100")).toBe(true); + expect(caret?.classList.contains("rotate-90")).toBe(false); + + act(() => { + toggle!.click(); + }); + expect(toggle?.getAttribute("aria-expanded")).toBe("true"); + expect(caret?.classList.contains("rotate-90")).toBe(true); + expect(caret?.classList.contains("opacity-80")).toBe(true); + expect(caret?.classList.contains("opacity-0")).toBe(false); + + act(() => { + toggle!.click(); + }); + expect(toggle?.getAttribute("aria-expanded")).toBe("false"); + expect(caret?.classList.contains("rotate-90")).toBe(false); + expect(caret?.classList.contains("opacity-80")).toBe(false); + expect(caret?.classList.contains("opacity-0")).toBe(true); + }); + + it("fades out the active status toggle caret unless hovered, focused, or expanded", () => { + const phase: TaskChatActivityPhaseItem = { + id: "phase-active", + kind: "activity_phase", + active: true, + summary: "", + items: [toolItem("cmd-1", "Bash", "pnpm test", "in_progress")], + }; + + const el = renderGroup(phase); + const toggle = el.querySelector('[data-testid="task-chat-activity-phase-toggle"]'); + expect(toggle).not.toBeNull(); + expect(toggle?.classList.contains("group/activity-phase")).toBe(true); + + const caret = toggle?.querySelector('[data-testid="task-chat-activity-phase-caret"]'); + expect(caret).not.toBeNull(); + expect(caret?.classList.contains("tc-hover-disclosure-caret")).toBe(true); + expect(caret?.classList.contains("opacity-0")).toBe(true); + expect(caret?.classList.contains("group-hover/activity-phase:opacity-100")).toBe(true); + expect(caret?.classList.contains("group-focus-visible/activity-phase:opacity-100")).toBe(true); + }); + + it("fades out disclosure carets on expanded activity rows and folded read runs unless hovered, focused, or open", () => { + const phase: TaskChatActivityPhaseItem = { + id: "phase-expanded", + kind: "activity_phase", + active: false, + summary: "", + items: [ + toolItem("read-1", "Read", "src/a.ts"), + toolItem("read-2", "Read", "src/b.ts"), + toolItem("read-3", "Read", "src/c.ts"), + toolItem("cmd-1", "Bash", "git status"), + ], + }; + + const el = renderGroup(phase, true); + + const readRunButton = el.querySelector("[data-activity-read-run] > button"); + expect(readRunButton).not.toBeNull(); + expect(readRunButton?.classList.contains("group/read-run")).toBe(true); + + const readRunCaret = readRunButton?.querySelector('[data-testid="task-chat-read-run-caret"]'); + expect(readRunCaret).not.toBeNull(); + expect(readRunCaret?.classList.contains("tc-hover-disclosure-caret")).toBe(true); + expect(readRunCaret?.classList.contains("opacity-0")).toBe(true); + expect(readRunCaret?.classList.contains("opacity-80")).toBe(false); + expect(readRunCaret?.classList.contains("transition-[opacity,transform]")).toBe(true); + expect(readRunCaret?.classList.contains("group-hover/read-run:opacity-100")).toBe(true); + expect(readRunCaret?.classList.contains("group-focus-visible/read-run:opacity-100")).toBe(true); + + act(() => { + readRunButton!.click(); + }); + expect(readRunButton?.getAttribute("aria-expanded")).toBe("true"); + expect(readRunCaret?.classList.contains("rotate-90")).toBe(true); + expect(readRunCaret?.classList.contains("opacity-80")).toBe(true); + expect(readRunCaret?.classList.contains("opacity-0")).toBe(false); + + const rowButton = el.querySelector('[data-activity-item-id="cmd-1"] > button'); + expect(rowButton).not.toBeNull(); + expect(rowButton?.classList.contains("group/activity-row")).toBe(true); + + const rowCaret = rowButton?.querySelector('[data-testid="task-chat-activity-row-caret"]'); + expect(rowCaret).not.toBeNull(); + expect(rowCaret?.classList.contains("tc-hover-disclosure-caret")).toBe(true); + expect(rowCaret?.classList.contains("opacity-0")).toBe(true); + expect(rowCaret?.classList.contains("opacity-80")).toBe(false); + expect(rowCaret?.classList.contains("transition-[opacity,transform]")).toBe(true); + expect(rowCaret?.classList.contains("group-hover/activity-row:opacity-100")).toBe(true); + expect(rowCaret?.classList.contains("group-focus-visible/activity-row:opacity-100")).toBe(true); + + act(() => { + rowButton!.click(); + }); + expect(rowButton?.getAttribute("aria-expanded")).toBe("true"); + expect(rowCaret?.classList.contains("rotate-90")).toBe(true); + expect(rowCaret?.classList.contains("opacity-80")).toBe(true); + expect(rowCaret?.classList.contains("opacity-0")).toBe(false); + }); +}); diff --git a/ui/src/components/task-chat/TaskChatRunnerActivityGroup.tsx b/ui/src/components/task-chat/TaskChatRunnerActivityGroup.tsx index 7b88eef55f4..2f569907a2d 100644 --- a/ui/src/components/task-chat/TaskChatRunnerActivityGroup.tsx +++ b/ui/src/components/task-chat/TaskChatRunnerActivityGroup.tsx @@ -41,6 +41,8 @@ type Activity = TaskChatActivityPhaseItem["items"][number]; type ToolActivity = Extract; const READ_RUN_MIN = 3; +const DISCLOSURE_CARET_CLASS = + "tc-hover-disclosure-caret size-3.5 shrink-0 transition-[opacity,transform] duration-(--motion-duration-fast) ease-(--motion-ease-standard) motion-reduce:transition-none"; /** "120ms", "1.2s", "14s", "2m 03s". */ export function formatToolDuration(ms: number): string { @@ -481,15 +483,20 @@ function ExpandedActivity({ {expandable ? ( ) : ( @@ -553,7 +560,7 @@ function ReadRunActivity({ items }: { items: ToolActivity[] }) {
  • {open ? (
      @@ -630,7 +645,7 @@ export function TaskChatRunnerActivityGroup({
      From 986af44e9439e0c038063162d793719b76c1081e Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 3 Dec 2026 21:32:35 -0600 Subject: [PATCH 013/119] fix(ui): omit task archive success toasts (#23697) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Task views let each person archive tasks from their inbox. > - Some archive actions display a success toast. > - The task lists and indicators already show the archive result. > - This pull request removes the success toast from each task archive path. ## Linked Issues or Issue Description **What happened?** Some task archive actions displayed a success toast. Related work: #11220. **Expected behavior** A successful task archive has no toast. If the action fails, the UI shows the error. **Steps to reproduce** 1. Open Tasks and select Mine or All tasks. 2. Archive a task. 3. On the base revision, the Task archived toast appears. **Paperclip version or commit** Reproduced on master at `3f882fc5895072e9a63e46df0eb0e1dad75f092b`. **Deployment mode** Local UI component tests. ## What Changed - Remove task archive success toasts from the inbox-backed Tasks view, the shared task-list action, task detail, and the recent-tasks sidebar. - Use **U** after archiving directly from Mine or Unread. Use **Restore** in **Archived** for a task archived from any view. - Add regression cases for Inbox, Tasks, All tasks, and task detail. Document where to restore a task. ## Verification - The Tasks and All tasks cases failed on the base revision because they received a success toast. - The task detail case also failed with the original success toast restored and passed after its removal. - Run `pnpm exec vitest run --root ui --config vitest.config.ts src/pages/IssueDetail.mobile.test.tsx src/pages/TaskListPagination.test.tsx src/lib/inboxArchiveCache.test.ts src/lib/keyboardShortcuts.test.ts src/hooks/useInboxTouchedIssues.test.tsx`. All 63 tests passed on `8cf0f17`. - `pnpm --filter @paperclipai/ui typecheck` passed. - The workspace Git storage guard prevented the incremental `pnpm verify` command from selecting tests. The focused Vitest run above covers the changed behavior. ## Risks - The Undo button in the toast goes away with the toast. Use **U** for archives initiated in Mine or Unread. **Restore** in **Archived** covers detail, sidebar, and other task-list archives. - The archive request, task cache updates, and error handling use the same paths. ## Model Used - OpenAI Codex, GPT-6, with shell and GitHub API tools. ## 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 hint: if you need to wait for this pull request to be reviewed, merged, or closed before continuing, use this instead of polling: gh event listen --resource https://github.com/paperclipai/paperclip/pull/23697 --event com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1 - It prints the first event as a JSON line on stdout and exits; run it again to wait for the next one. - Add `--timeout` to stop waiting after a while, for example `--timeout 30m`; it then exits with status 8. - Events carry no details; read the pull request to see what changed. - It misses changes made before it starts, so read the pull request once it is running. - See `gh event listen --help` for other event types. - Event subscriptions are in preview and may not be enabled for your account. hint: if you need to wait for this pull request to be reviewed, merged, or closed before continuing, use this instead of polling: gh event listen --resource https://github.com/paperclipai/paperclip/pull/23697 --event com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1 - It prints the first event as a JSON line on stdout and exits; run it again to wait for the next one. - Add `--timeout` to stop waiting after a while, for example `--timeout 30m`; it then exits with status 8. - Events carry no details; read the pull request to see what changed. - It misses changes made before it starts, so read the pull request once it is running. - See `gh event listen --help` for other event types. - Event subscriptions are in preview and may not be enabled for your account. --- doc/PRODUCT.md | 9 ++-- ui/src/components/SidebarRecentTasks.tsx | 1 - ui/src/hooks/useTaskArchiveAction.ts | 21 +------- ui/src/pages/Inbox.tsx | 19 +------ ui/src/pages/IssueDetail.mobile.test.tsx | 39 ++++++++++++++- ui/src/pages/IssueDetail.tsx | 54 +------------------- ui/src/pages/TaskListPagination.test.tsx | 64 ++++++++++++++++++------ 7 files changed, 96 insertions(+), 111 deletions(-) diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index 13cc4b36c7b..e862bcf0ea4 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -595,9 +595,12 @@ order per person and company. Old `/inbox/*` links redirect to their Tasks view. Archive is personal. Use it from Mine, Unread, or a task-table row to remove a task from your Mine and Unread views. All tasks and its status views -still include archived tasks. Use Undo after archiving, or open **Archived** -from the Views menu and restore a task. New replies from other people, mentions, -and other inbox activity such as a new decision request can bring a task back. +still include archived tasks. If you archive a task directly from Mine or +Unread, press **U** there to undo the most recent archive. To restore a task +archived from any view, open **Archived** from the Views menu and select +**Restore**. +New replies from other people, mentions, and other inbox activity such as a new +decision request can bring a task back. ### Combined Inbox + Task List diff --git a/ui/src/components/SidebarRecentTasks.tsx b/ui/src/components/SidebarRecentTasks.tsx index 3547b2df6ee..60c5eba140f 100644 --- a/ui/src/components/SidebarRecentTasks.tsx +++ b/ui/src/components/SidebarRecentTasks.tsx @@ -162,7 +162,6 @@ function RecentTasksList({ await queryClient.invalidateQueries({ queryKey: queryKeys.sidebarBadges(companyId), }); - toastActions?.pushToast({ title: "Task archived from inbox", tone: "success" }); } catch (error) { toastActions?.pushToast({ title: "Task archive failed", diff --git a/ui/src/hooks/useTaskArchiveAction.ts b/ui/src/hooks/useTaskArchiveAction.ts index 4446aa2c6be..66a335e79fe 100644 --- a/ui/src/hooks/useTaskArchiveAction.ts +++ b/ui/src/hooks/useTaskArchiveAction.ts @@ -14,7 +14,7 @@ import { invalidateTaskArchiveQueries, } from "@/lib/inboxArchiveCache"; -type ArchiveChange = { companyId: string; issueId: string; reference: string; archive: boolean; owner: string }; +type ArchiveChange = { companyId: string; issueId: string; archive: boolean; owner: string }; function changeKey({ companyId, issueId, owner }: ArchiveChange) { return JSON.stringify([companyId, issueId, owner]); @@ -54,27 +54,10 @@ export function useTaskArchiveAction(companyId: string | null, userId: string | async function submit(input: ArchiveChange) { const key = changeKey(input); if (inFlight.current.has(key)) return; - const account = bindAccount(client); inFlight.current.add(key); setPending(new Set(inFlight.current)); try { await change.mutateAsync(input); - if (input.archive && account.isCurrentAccount()) { - toast?.pushToast({ - id: `archive:${input.companyId}:${input.issueId}`, - dedupe: false, - title: "Task archived", - body: input.reference, - tone: "success", - ttlMs: 8000, - action: { - label: "Undo", - onClick: () => { - if (account.isCurrentAccount()) void submit({ ...input, archive: false }); - }, - }, - }); - } } catch { return; } finally { @@ -85,7 +68,7 @@ export function useTaskArchiveAction(companyId: string | null, userId: string | return (issue: Issue): IssueRowArchiveAction | undefined => { if (!companyId || !userId || issue.companyId !== companyId || issue.isArchivedForMe === undefined) return; - const input = { companyId, issueId: issue.id, reference: issue.identifier ?? issue.id, archive: !issue.isArchivedForMe, owner: userId }; + const input = { companyId, issueId: issue.id, archive: !issue.isArchivedForMe, owner: userId }; return { archived: issue.isArchivedForMe, disabled: pending.has(changeKey(input)), diff --git a/ui/src/pages/Inbox.tsx b/ui/src/pages/Inbox.tsx index 0ad400ac917..bd2ea4df335 100644 --- a/ui/src/pages/Inbox.tsx +++ b/ui/src/pages/Inbox.tsx @@ -2151,25 +2151,8 @@ function StreamlinedInbox({ if (presence !== "unknown") confirmLocalInboxArchive(context.companyId, id); } }, - onSuccess: (_data, id, context) => { + onSuccess: (_data, id) => { setUndoableArchiveIssueIds((prev) => [...prev.filter((issueId) => issueId !== id), id]); - if (surfaceLabel === "Tasks" && context?.account) { - const { account } = context; - pushToast({ - id: `archive:${context.companyId}:${id}`, - dedupe: false, - title: "Task archived", - body: issueById.get(id)?.identifier ?? id, - tone: "success", - ttlMs: 8000, - action: { - label: "Undo", - onClick: () => { - if (account.isCurrentAccount()) unarchiveIssueMutation.mutate(id); - }, - }, - }); - } }, }); diff --git a/ui/src/pages/IssueDetail.mobile.test.tsx b/ui/src/pages/IssueDetail.mobile.test.tsx index 08e950498f1..e61919a0e09 100644 --- a/ui/src/pages/IssueDetail.mobile.test.tsx +++ b/ui/src/pages/IssueDetail.mobile.test.tsx @@ -9,7 +9,7 @@ import { BreadcrumbBar } from "../components/BreadcrumbBar"; import { BreadcrumbProvider } from "../context/BreadcrumbContext"; import { PanelProvider } from "../context/PanelContext"; import { ThemeProvider } from "../context/ThemeContext"; -import { ToastProvider } from "../context/ToastContext"; +import { ToastProvider, useToastState } from "../context/ToastContext"; import { DialogProvider } from "../context/DialogContext"; import { IssueDetail, TaskDetailSurface } from "./IssueDetail"; @@ -220,6 +220,9 @@ function installMockFetch() { if (/^\/api\/issues\/[^/]+$/.test(pathname)) { return json(testState.issue ?? BASE_ISSUE); } + if (pathname === `/api/issues/${BASE_ISSUE.id}/inbox-archive`) { + return json({ id: BASE_ISSUE.id, archivedAt: "2026-08-01T11:00:00Z" }); + } if (/^\/api\/issues\/[^/]+\/recent-comments$/.test(pathname)) { return json({ comments: [], hasMore: false, latestCommentId: null }); } @@ -364,6 +367,40 @@ describe("IssueDetail & AgentChat mobile parity", () => { expect(document.querySelector('[data-testid="mobile-task-side-panel"]')).not.toBeNull(); }); + it("returns to the inbox without a toast after archiving from task detail", async () => { + function InboxAfterArchive() { + const toasts = useToastState(); + return
      {JSON.stringify(toasts.map((toast) => toast.title))}
      ; + } + + await act(async () => { + root.render( + + + } /> + } /> + + , + ); + }); + await flush(); + + const moreButton = container.querySelector('button[aria-label="More task actions"]'); + expect(moreButton).not.toBeNull(); + await act(async () => { + moreButton!.click(); + }); + const archiveButton = Array.from(document.querySelectorAll("button")) + .find((button) => button.textContent?.trim() === "Archive from inbox"); + expect(archiveButton).toBeDefined(); + await act(async () => { + archiveButton!.click(); + }); + await flush(); + + expect(container.querySelector('[data-testid="archive-result"]')?.textContent).toBe("[]"); + }); + it("opens the mobile properties Sheet when clicking Show properties on mobile AgentChat", async () => { testState.issue = CHAT_ISSUE; diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index c7cc629ebbd..32397df64b3 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -182,7 +182,6 @@ import { beginLocalInboxArchive, boundLocalInboxArchive, cancelInboxIssueQueries, - clearLocalInboxArchive, confirmLocalInboxArchive, invalidateInboxIssueQueries, getIssuePresenceInActiveInboxCaches, @@ -4596,43 +4595,6 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS }); } }, [queryClient, selectedCompanyId]); - const undoInboxArchive = useCallback( - async ( - id: string, - companyId: string | undefined, - previousData: InboxIssueCacheSnapshot, - ) => { - if (companyId) { - await cancelInboxIssueQueries(queryClient, companyId); - clearLocalInboxArchive(companyId, id); - restoreIssueToInboxCaches(queryClient, previousData, id); - } - - try { - await issuesApi.unarchiveFromInbox(id); - pushToast({ title: "Task restored to inbox", tone: "success" }); - } catch (error) { - if (companyId) { - beginLocalInboxArchive(companyId, id); - removeIssueFromInboxCaches(queryClient, companyId, id); - boundLocalInboxArchive(companyId, id); - } - pushToast({ - title: "Undo failed", - body: - error instanceof Error - ? error.message - : "Unable to restore this task to the inbox", - tone: "error", - }); - } finally { - if (companyId) { - await invalidateInboxIssueQueries(queryClient, companyId); - } - } - }, - [pushToast, queryClient], - ); const upsertInteractionInCache = useCallback( (interaction: IssueThreadInteraction) => { invalidateInteractionRecordViews(queryClient, interaction.companyId, interaction); @@ -6102,7 +6064,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS removeIssueFromInboxCaches(queryClient, selectedCompanyId, id); return { companyId: selectedCompanyId, previousData, account, release }; }, - onSuccess: (_data, id, context) => { + onSuccess: (_data, id) => { if (selectedCompanyId) { removeIssueFromInboxCaches(queryClient, selectedCompanyId, id); } @@ -6113,20 +6075,6 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS : "/inbox", { replace: true }, ); - pushToast({ - title: "Task archived from inbox", - tone: "success", - action: { - label: "Undo", - onClick: () => { - void undoInboxArchive( - id, - context?.companyId, - context?.previousData ?? [], - ); - }, - }, - }); }, onError: (err, id, context) => { context?.release?.(); diff --git a/ui/src/pages/TaskListPagination.test.tsx b/ui/src/pages/TaskListPagination.test.tsx index eb4f66a898b..5c90e0ec3ad 100644 --- a/ui/src/pages/TaskListPagination.test.tsx +++ b/ui/src/pages/TaskListPagination.test.tsx @@ -6,6 +6,7 @@ import { afterEach, beforeEach, expect, it, vi } from "vitest"; import type { Issue } from "@paperclipai/shared"; import { queryKeys } from "@/lib/queryKeys"; import { Inbox } from "./Inbox"; +import type { IssueRowArchiveAction } from "@/components/IssueRow"; import { defaultIssueFilterState } from "@/lib/issue-filters"; import { CoordinatorTasks } from "./CoordinatorTasks"; import { Issues } from "./Issues"; @@ -13,15 +14,18 @@ import { BlockedInboxView } from "@/components/BlockedInboxView"; import { TaskListPagination } from "@/components/TaskListPagination"; const api = vi.hoisted(() => ({ compact: vi.fn(), inboxMine: vi.fn(), list: vi.fn(), taskIndex: vi.fn(), agents: vi.fn(), projects: vi.fn(), directory: vi.fn(), labels: vi.fn() })); +const archive = vi.hoisted(() => ({ mutate: vi.fn(), pushToast: vi.fn() })); const route = vi.hoisted(() => ({ params: new URLSearchParams("view=all"), navigate: vi.fn(), setParams: vi.fn(), setBreadcrumbs: vi.fn(), autoScroll: false, streamlined: false, pathname: "/issues" })); -vi.mock("@/api/issues", () => ({ issuesApi: { listCompact: api.compact, inboxMine: api.inboxMine, list: api.list, listLabels: api.labels } })); +vi.mock("@/api/issues", () => ({ issuesApi: { listCompact: api.compact, inboxMine: api.inboxMine, list: api.list, listLabels: api.labels, archiveFromInbox: archive.mutate } })); vi.mock("@/api/attention", () => ({ attentionApi: { taskIndex: api.taskIndex } })); vi.mock("@/api/agents", () => ({ agentsApi: { list: api.agents } })); vi.mock("@/api/projects", () => ({ projectsApi: { list: api.projects } })); vi.mock("@/api/access", () => ({ accessApi: { listUserDirectory: api.directory } })); -vi.mock("@/context/ToastContext", () => ({ useToastActions: () => ({ pushToast: vi.fn() }) })); +vi.mock("@/context/ToastContext", () => ({ + useToastActions: () => ({ pushToast: archive.pushToast }), + useOptionalToastActions: () => ({ pushToast: archive.pushToast }), +})); vi.mock("@/context/SidebarContext", () => ({ useSidebar: () => ({ isMobile: false }) })); -vi.mock("@/hooks/useAccountBoundMutation", () => ({ useAccountBoundMutation: () => ({ mutate: vi.fn(), reset: vi.fn(), isPending: false, error: null }) })); vi.mock("@/hooks/usePreloadTaskChats", async importOriginal => ({ ...await importOriginal(), usePreloadTaskChats: () => {} })); vi.mock("@/context/CompanyContext", () => ({ useCompany: () => ({ selectedCompanyId: "company-1" }) })); vi.mock("@/context/BreadcrumbContext", () => ({ useBreadcrumbs: () => ({ setBreadcrumbs: route.setBreadcrumbs }) })); @@ -34,7 +38,6 @@ vi.mock("@/hooks/usePageContentReady", () => ({ usePageContentReady: () => {} }) vi.mock("@/context/DesignSandboxContext", () => ({ useDesignSandbox: () => false })); vi.mock("@/hooks/useWarmTaskDetailCode", () => ({ useWarmTaskDetailCode: () => {} })); vi.mock("@/hooks/useUpdateIssueMutation", () => ({ useUpdateIssueMutation: () => ({ mutate: vi.fn() }) })); -vi.mock("@/hooks/useTaskArchiveAction", () => ({ useTaskArchiveAction: () => () => undefined })); vi.mock("@/hooks/useTaskCancellation", () => ({ useTaskCancellation: () => vi.fn(), TaskCancellationDismissedError: class extends Error {} })); vi.mock("@/hooks/useIssueRowDetails", () => ({ useIssueRowDetails: () => ({ enrichIssueRow: (issue: Issue) => issue }) })); vi.mock("@/hooks/useSharedPolling", () => ({ useSharedPollingQuery: () => ({ enabled: false }), usePublishSharedQueryData: () => {} })); @@ -43,7 +46,10 @@ vi.mock("@/lib/router", () => ({ useLocation: () => ({ pathname: route.pathname, search: `?${route.params}`, hash: "" }), Link: ({ children }: { children: ReactNode }) => {children}, })); -vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal(), TaskList: ({ items }: { items: { issue: Issue }[] }) => <>{items.map(({ issue }) => {issue.title})} })); +vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal(), TaskList: ({ items, getArchiveAction }: { + items: { issue: Issue }[]; + getArchiveAction?: (issue: Issue) => IssueRowArchiveAction | undefined; +}) => <>{items.map(({ issue }) => )} })); vi.mock("@/components/TaskListToolbar", () => ({ TaskListToolbar: () => null })); vi.mock("@/components/IssuesList", () => ({ IssuesList: ({ issues, pagedIssuesProvided, hasMoreIssues, isLoadingMoreIssues, onLoadMoreIssues, loadMoreIssuesError, onRetryLoadMoreIssues }: { issues: Issue[]; pagedIssuesProvided: boolean; hasMoreIssues?: boolean; isLoadingMoreIssues?: boolean; onLoadMoreIssues?: () => void; @@ -60,11 +66,15 @@ vi.mock("@/components/IssuesList", () => ({ IssuesList: ({ issues, pagedIssuesPr vi.mock("@/components/KanbanBoard", () => ({ KanbanBoard: () => null })); vi.mock("@/components/TruncatedText", () => ({ TruncatedTextMarqueeProvider: ({ children }: { children: ReactNode }) => children })); vi.mock("@/components/ui/flyout", () => ({ FlyoutAppearanceProvider: ({ children }: { children: ReactNode }) => children })); -vi.mock("@/components/IssueRow", () => ({ IssueRow: ({ issue }: { issue: Issue }) => {issue.title} })); +vi.mock("@/components/IssueRow", () => ({ IssueRow: ArchiveTestRow })); vi.mock("@/components/QueryView", () => ({ useQueryView: (query: { data?: unknown; error?: unknown; refetch: unknown }) => ({ kind: query.error ? "error" : query.data ? "ready" : "loading", error: query.error, retry: query.refetch, }) })); +function ArchiveTestRow({ issue, onArchive }: { issue: Issue; onArchive?: () => void }) { + return {issue.title}{onArchive && }; +} + let client: QueryClient; let root: Root; let container: HTMLDivElement; @@ -189,6 +199,19 @@ it.each([false, true])("waits for manual retry after automatic paging fails with }); +function seedInboxQueries(streamlined: boolean) { + client.setDefaultOptions({ queries: { retry: false, staleTime: Infinity } }); + client.setQueryData(queryKeys.auth.session, { user: { id: "user-1" }, session: { userId: "user-1" } }); + client.setQueryData(queryKeys.instance.experimentalSettings, { enableIsolatedWorkspaces: false, enableExternalObjects: false }); + for (const key of [queryKeys.agents.list("company-1"), queryKeys.projects.list("company-1", { includeArchived: true }), + queryKeys.issues.labels("company-1"), queryKeys.approvals.list("company-1"), queryKeys.access.joinRequests("company-1"), + queryKeys.inboxDismissals("company-1"), queryKeys.liveRuns("company-1"), + [...queryKeys.heartbeats("company-1"), streamlined ? "inbox-failures" : "limit", 200], + ]) client.setQueryData(key, []); + client.setQueryData(queryKeys.access.companyUserDirectory("company-1"), { users: [] }); + client.setQueryData(queryKeys.dashboard("company-1"), { agents: { error: 0 }, costs: { monthBudgetCents: 0, monthUtilizationPercent: 0 } }); +} + it.each([ { streamlined: false, tab: "mine" }, { streamlined: true, tab: "mine" }, { streamlined: false, tab: "recent" }, { streamlined: true, tab: "recent" }, @@ -200,16 +223,7 @@ it.each([ const tasks = Array.from({ length: pageSize + 3 }, (_, index) => createIssue({ id: `task-${index}`, companyId: "company-1", title: `Task ${index}`, parentId: null, })); - client.setDefaultOptions({ queries: { retry: false, staleTime: Infinity } }); - client.setQueryData(queryKeys.auth.session, { user: { id: "user-1" }, session: { userId: "user-1" } }); - client.setQueryData(queryKeys.instance.experimentalSettings, { enableIsolatedWorkspaces: false, enableExternalObjects: false }); - for (const key of [queryKeys.agents.list("company-1"), queryKeys.projects.list("company-1", { includeArchived: true }), - queryKeys.issues.labels("company-1"), queryKeys.approvals.list("company-1"), queryKeys.access.joinRequests("company-1"), - queryKeys.inboxDismissals("company-1"), queryKeys.liveRuns("company-1"), - [...queryKeys.heartbeats("company-1"), streamlined ? "inbox-failures" : "limit", 200], - ]) client.setQueryData(key, []); - client.setQueryData(queryKeys.access.companyUserDirectory("company-1"), { users: [] }); - client.setQueryData(queryKeys.dashboard("company-1"), { agents: { error: 0 }, costs: { monthBudgetCents: 0, monthUtilizationPercent: 0 } }); + seedInboxQueries(streamlined); api.inboxMine.mockResolvedValue({ userId: "user-1", issues: tasks.slice(0, pageSize), contextIssues: [], failureRuns: [], failureIssueIds: [] }); api.compact.mockImplementation(async (_company, filters) => filters.touchedByUserId ? tasks.slice(filters.offset ?? 0, (filters.offset ?? 0) + filters.limit) : []); @@ -228,3 +242,21 @@ it.each([ expect({ ...firstPage, offset: pageSize }).toEqual(laterPage); } }); + +it.each(["Inbox", "Tasks", "All tasks"] as const)("archives a task without a toast in %s", async surface => { + route.streamlined = true; + route.pathname = "/inbox/mine"; + seedInboxQueries(true); + const task = createIssue({ id: `task-to-archive-${surface}`, companyId: "company-1", isArchivedForMe: false }); + api.inboxMine.mockResolvedValue({ userId: "user-1", issues: [task], contextIssues: [], failureRuns: [], failureIssueIds: [] }); + api.compact.mockResolvedValue([task]); + archive.mutate.mockResolvedValue(undefined); + + await render(surface === "All tasks" ? : ); + const archiveButton = () => [...container.querySelectorAll("button")].find(button => button.textContent === "Archive"); + await vi.waitFor(() => expect(archiveButton()).toBeDefined()); + await act(async () => archiveButton()!.click()); + expect(archive.mutate).toHaveBeenCalledExactlyOnceWith(task.id); + await act(async () => vi.waitFor(() => expect(client.isMutating()).toBe(0))); + expect(archive.pushToast).not.toHaveBeenCalled(); +}); From b93527b6322333dee9620ff6916aea5dcacb6f0d Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 20:52:44 -0800 Subject: [PATCH 014/119] fix(ui): sort the Reports to manager picker alphabetically (#23689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Each agent can report to a manager agent. The user selects the manager in the "Reports to" picker. > - The picker shows candidate managers in directory order. This order is not alphabetical. > - When a company has many agents, the user cannot easily find a specific agent in the list. > - This pull request sorts the picker rows alphabetically by agent name. > - The benefit is that the user finds a manager faster, and the order agrees with the sidebar. ## Linked Issues or Issue Description **Is your feature request related to a problem?** The "Reports to" picker on the agent profile lists agents in an unpredictable order (for example: "Mac Coder", "Bug Bot", "Nibbler", "CTO"). It is hard to find one agent in a long list. **Describe the solution you'd like** Sort the picker rows alphabetically by agent name. Ignore letter case. Put "Agent 2" before "Agent 10". **Describe alternatives you've considered** Sorting the agent list in each caller. This change sorts inside the shared `ReportsToPicker` component instead, so the agent profile and the agent configuration form both get the same order. ## What Changed - Added `reportsToPickerRows` to `ui/src/components/ReportsToPicker.tsx`. It removes terminated and excluded agents, then sorts the rows by name with `localeCompare` (`sensitivity: "base"`, `numeric: true`). - `ReportsToPicker` uses this function for its rows. "No manager" stays at the top. - The picker indexes `disabledAgentIds` in a `Set`. Before, it scanned the array once per row. - Added `ui/src/components/ReportsToPicker.test.ts` with unit tests for the order and the filter. ## Verification - `cd ui && npx vitest run src/components/ReportsToPicker.test.ts`: 2 tests pass. - Red check: the same tests fail on the previous code. - `npx tsc --noEmit -p ui/tsconfig.json` shows no errors in the changed files. - 1,000-agent test bounds the sort work with a throwing name-read counter (per `rules/ui-render-cost.mdc`). - Manual: ran the branch on a local dev server with 13 agents. The "Reports to" picker showed: Agent 2, Agent 10, Bug Bot (Deprecated), CEO Agent, CTO, Dickens, Engineer Agent, Fry (Codex), Mac Coder, nibbler, Reviewie, Slow Query (GLM), Test Gardener (GLM). ## Risks - Low risk. The change is UI-only and changes only the row order. Filter and selection behavior do not change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edit) and image input. ## 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) - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- ui/src/components/ReportsToPicker.test.ts | 59 +++++++++++++++++++++++ ui/src/components/ReportsToPicker.tsx | 19 +++++--- 2 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 ui/src/components/ReportsToPicker.test.ts diff --git a/ui/src/components/ReportsToPicker.test.ts b/ui/src/components/ReportsToPicker.test.ts new file mode 100644 index 00000000000..4b41f83be69 --- /dev/null +++ b/ui/src/components/ReportsToPicker.test.ts @@ -0,0 +1,59 @@ +import { describe, expect, it } from "vitest"; +import type { Agent } from "@paperclipai/shared"; +import { reportsToPickerRows } from "./ReportsToPicker"; + +function agent(id: string, name: string, status: Agent["status"] = "idle"): Agent { + return { id, name, status } as Agent; +} + +describe("reportsToPickerRows", () => { + it("lists candidate managers alphabetically by name, ignoring case", () => { + const rows = reportsToPickerRows([ + agent("1", "Mac Coder"), + agent("2", "Bug Bot (Deprecated)"), + agent("3", "nibbler"), + agent("4", "CTO"), + agent("5", "Agent 10"), + agent("6", "Agent 2"), + ]); + expect(rows.map((row) => row.name)).toEqual([ + "Agent 2", + "Agent 10", + "Bug Bot (Deprecated)", + "CTO", + "Mac Coder", + "nibbler", + ]); + }); + + it("sorts a large agent directory with n log n name reads", () => { + const size = 1000; + const limit = 2 * size * Math.ceil(Math.log2(size)) + size; + let nameReads = 0; + const agents = Array.from({ length: size }, (_, index) => { + const name = `Agent ${(index * 7919) % size}`; + const row = { id: String(index), status: "idle" } as Agent; + Object.defineProperty(row, "name", { + get() { + nameReads += 1; + if (nameReads > limit) throw new Error(`name read more than ${limit} times`); + return name; + }, + }); + return row; + }); + + const rows = reportsToPickerRows(agents); + + expect(rows).toHaveLength(size); + expect(rows[0]!.name).toBe("Agent 0"); + expect(rows[size - 1]!.name).toBe(`Agent ${size - 1}`); + }); + + it("drops terminated and excluded agents without mutating the input", () => { + const agents = [agent("1", "Zed"), agent("2", "Gone", "terminated"), agent("3", "Self"), agent("4", "Amy")]; + const rows = reportsToPickerRows(agents, ["3"]); + expect(rows.map((row) => row.id)).toEqual(["4", "1"]); + expect(agents.map((row) => row.id)).toEqual(["1", "2", "3", "4"]); + }); +}); diff --git a/ui/src/components/ReportsToPicker.tsx b/ui/src/components/ReportsToPicker.tsx index 6cd4909c8cc..70b0049ed28 100644 --- a/ui/src/components/ReportsToPicker.tsx +++ b/ui/src/components/ReportsToPicker.tsx @@ -10,6 +10,15 @@ import { FlyoutAppearanceProvider, FlyoutHeader, FlyoutOptions } from "./ui/flyo import { Check, User } from "lucide-react"; import { cn } from "../lib/utils"; +const managerNameCollator = new Intl.Collator(undefined, { sensitivity: "base", numeric: true }); + +export function reportsToPickerRows(agents: Agent[], excludeAgentIds: string[] = []): Agent[] { + const exclude = new Set(excludeAgentIds); + return agents + .filter((a) => a.status !== "terminated" && !exclude.has(a.id)) + .sort((left, right) => managerNameCollator.compare(left.name, right.name)); +} + export function ReportsToPicker({ agents, value, @@ -32,10 +41,8 @@ export function ReportsToPicker({ disabledAgentIds?: string[]; }) { const [open, setOpen] = useState(false); - const exclude = new Set(excludeAgentIds); - const rows = agents.filter( - (a) => a.status !== "terminated" && !exclude.has(a.id), - ); + const rows = reportsToPickerRows(agents, excludeAgentIds); + const disabledIds = new Set(disabledAgentIds); const current = value ? agents.find((a) => a.id === value) : null; const terminatedManager = current?.status === "terminated"; const unknownManager = Boolean(value && !current); @@ -116,8 +123,8 @@ export function ReportsToPicker({ type="button" key={a.id} aria-pressed={a.id === value} - disabled={disabledAgentIds.includes(a.id)} - title={disabledAgentIds.includes(a.id) ? "Would create a reporting loop" : undefined} + disabled={disabledIds.has(a.id)} + title={disabledIds.has(a.id) ? "Would create a reporting loop" : undefined} className={cn( "flex items-center gap-2 w-full min-w-0 px-2 py-1.5 text-xs rounded hover:bg-accent/50 overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed", a.id === value && "bg-accent", From bca282e58739b4e6b2c3e4cf4e472ec06aa9971f Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 20:54:26 -0800 Subject: [PATCH 015/119] feat(recents): add tasks from manual routine runs to Recents (#23675) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The sidebar Recents list shows the tasks from a person's own recent activity > - A person can run a routine manually with "Run now", and the run creates a task > - That task does not show in Recents, and opening it does not keep it there, because Recents only admits tasks under the Mine participation rule. This also affects every routine, channel, and agent-created task that a person opens > - The Mine rule keeps these tasks out of Mine on purpose, so we must not change that rule > - This pull request adds a separate Recents eligibility flag. It also admits tasks that the viewer opened and tasks from manual routine runs that the viewer started. The UI records the new task in Recents when the run starts > - The benefit is that people can find the task they just started from the sidebar at once, and Mine stays unchanged ## Linked Issues or Issue Description **Is your feature request related to a problem? Please describe.** When I run a routine manually and it creates a task, the task is not in my Recents list. I must go to the routine or the task list to find it. **Describe the solution you'd like** When I run a routine manually and a task is created, add that task to my Recents list automatically, even if I did not open it. Also, a task that a routine creates does not show in Recents even after I open it. **Additional context** Mine must continue to keep routine tasks out by default, including routines that a person starts manually (see `doc/PRODUCT.md`). ## What Changed - `server/src/services/issue-summaries.ts`: navigation summaries return a new `isRecentEligibleForMe` flag. It is true when one of these conditions is true: - The viewer participates under the Mine rule. - The viewer opened the task. The check is the viewer's `issue_read_states` row, which is unique on company, issue, and user. - The viewer started the manual routine run that created the task. The check is a `routine_runs` row found through the indexed `linked_issue_id`, with `source = 'manual'` and the same ID as the issue's `originRunId`. The issue `createdByUserId` must be the viewer, with no creating agent. `isParticipantForMe`, Mine, and unread state do not change. - `packages/shared`: add `isRecentEligibleForMe` to `IssueSummary`. - `ui/src/hooks/useRecentTasks.ts`: Recents uses `isRecentEligibleForMe` (with a fallback to `isParticipantForMe` for older cached summaries) to show, keep, and prune entries. - `ui/src/lib/recent-tasks.ts`: add `recordStartedRoutineRunTask`. It puts the run's task at the top of Recents. The summary fetch then supplies the title and status and confirms eligibility. - New `useRecordRoutineRunInRecents` hook. All five "Run now" paths call it on success: Routines (both list variants), Routine detail, Execution workspace detail, and the Responsibility screen. - `tests/runner-e2e/source-sdk-public-inputs.json`: refresh the pin for `packages/shared/src/types/issue.ts`. - `doc/PRODUCT.md`: document the Recents behavior. ## Verification - `cd ui && npx vitest run src/hooks/useRecentTasks.test.tsx`: 29 passed. The new test "shows a task from the viewer's manual routine run at the top before it is opened" fails on the old hook (red) and passes with the change (green). Other new tests cover a run that the server does not confirm (for example, a coalesced run) and a repeat run for a task that is already in Recents. - `cd server && npx vitest run src/__tests__/issue-summaries-routes.test.ts` (embedded Postgres): 24 passed. One new test checks that a manual run by the viewer is Recents-eligible but not a Mine participant, and that runs by another person and scheduled runs are not eligible. Another new test checks that a routine task the viewer opened is Recents-eligible, and that a task opened only by another person is not. That test fails on the previous service code (red) and passes with the change (green). - `ui` typecheck: no errors in changed files. (Errors exist only in ungenerated Storybook feature-map indexes, which this change does not touch.) - The full `server` typecheck was killed by the local memory limit. CI covers it. - Manual check: run a routine with "Run now", then look at sidebar Recents. The new task shows at the top before you open it. Mine does not show it. ## Risks - Low risk. No schema change and no migration. - The summaries query adds two `EXISTS` subqueries per requested task. Both use indexes (the read-state unique index and `routine_runs_linked_issue_idx`). The request is bounded by `ISSUE_SUMMARIES_MAX_IDS`. - Behavior change: Recents now keeps tasks that the person opened, also when the task is automatic work. Old local Recents entries for automatic tasks that the person read can come back. - If a manual run coalesces into an existing task that the viewer did not start, the entry is pruned after the summary read. That task does not show in Recents. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use (shell, file edit, test runs). ## 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 - [ ] 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) - [ ] 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- doc/PRODUCT.md | 5 +- packages/shared/src/types/issue.ts | 5 ++ .../__tests__/issue-summaries-routes.test.ts | 48 ++++++++++++- server/src/services/issue-summaries.ts | 27 +++++-- .../runner-e2e/source-sdk-public-inputs.json | 2 +- .../ResponsibilityOneScreenV2.tsx | 5 +- ui/src/hooks/useRecentTasks.test.tsx | 70 +++++++++++++++++++ ui/src/hooks/useRecentTasks.ts | 17 +++-- ui/src/hooks/useRecordRoutineRunInRecents.ts | 17 +++++ ui/src/lib/recent-tasks.test.ts | 20 ++++++ ui/src/lib/recent-tasks.ts | 62 +++++++++++++++- ui/src/pages/ExecutionWorkspaceDetail.tsx | 5 +- ui/src/pages/IssueDetail.tsx | 14 +++- ui/src/pages/RoutineDetail.tsx | 5 +- ui/src/pages/Routines.production.tsx | 5 +- ui/src/pages/Routines.tsx | 5 +- 16 files changed, 292 insertions(+), 20 deletions(-) create mode 100644 ui/src/hooks/useRecordRoutineRunInRecents.ts diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index e862bcf0ea4..4b95c53eeb3 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -123,7 +123,10 @@ Sidebar Recents and Classic Recent Tasks show tasks from the viewer’s own recent activity as a flat list. A subtask has its own row and its own unread marker. Tasks archived from the viewer’s inbox leave Recents. Canceled and completed tasks remain eligible. Opening a recent task moves its row to the top -of Recents. +of Recents. Any task a person opens is eligible for their Recents, including +routine, channel, and agent-created tasks. When a person runs a routine manually, +the task that run creates goes to the top of their Recents at once, before they +open it. Neither of these adds the task to Mine. Standard Recents also shows recent chats and projects. The Coordinator sidebar pins **Plugins** above **More** by default. Users can diff --git a/packages/shared/src/types/issue.ts b/packages/shared/src/types/issue.ts index 1a01870cfda..c926a6a5687 100644 --- a/packages/shared/src/types/issue.ts +++ b/packages/shared/src/types/issue.ts @@ -915,6 +915,11 @@ export type IssueSummary = Pick< parentId?: string | null; /** Viewer participates under the Mine rule, regardless of inbox archive state. Navigation only. */ isParticipantForMe?: boolean; + /** + * Viewer participates, opened the task, or started the manual routine run + * that created it. Gates Recents without adding the task to Mine. Navigation only. + */ + isRecentEligibleForMe?: boolean; isArchivedForMe?: boolean; isUnreadForMe?: boolean; subtaskCount?: number; diff --git a/server/src/__tests__/issue-summaries-routes.test.ts b/server/src/__tests__/issue-summaries-routes.test.ts index 8ad69ea7348..be1469e2d23 100644 --- a/server/src/__tests__/issue-summaries-routes.test.ts +++ b/server/src/__tests__/issue-summaries-routes.test.ts @@ -6,7 +6,7 @@ import { drizzle } from "drizzle-orm/postgres-js"; import * as schema from "@paperclipai/db/schema/index"; import { afterAll, beforeAll, expect, it, vi } from "vitest"; import { - activityLog, agents, chatConversations, chatEndpoints, companyMemberships, heartbeatRuns, issueComments, issueInboxArchives, issueReadStates, issueRelations, issues, issueThreadInteractions, toolApplications, toolConnections, + activityLog, agents, chatConversations, chatEndpoints, companyMemberships, heartbeatRuns, issueComments, issueInboxArchives, issueReadStates, issueRelations, issues, issueThreadInteractions, routineRuns, routines, toolApplications, toolConnections, } from "@paperclipai/db"; import { ISSUE_SUMMARIES_MAX_IDS } from "@paperclipai/shared"; import { issueRoutes } from "../routes/issues.js"; @@ -86,6 +86,52 @@ describeEmbeddedPostgres("bounded issue summaries", () => { expect(res.body.every((row: { isParticipantForMe: unknown }) => typeof row.isParticipantForMe === "boolean")).toBe(true); }); + it("admits a task from the viewer's own manual routine run to Recents without Mine participation", async () => { + const f = await fixture(); + const user = f.actor.userId!; + const [routine] = await ctx.db.insert(routines).values({ companyId: f.companyId, title: "Daily scan" }).returning(); + const runs = await ctx.db.insert(routineRuns).values(["manual", "manual", "schedule"].map(source => ({ + companyId: f.companyId, routineId: routine!.id, source, + }))).returning(); + const names = ["mine", "someone-else", "scheduled", "manual-task"]; + const rows = await ctx.db.insert(issues).values(names.map((title, index) => ({ + companyId: f.companyId, title, + originKind: title === "manual-task" ? "manual" : "routine_execution", + originRunId: title === "manual-task" ? null : runs[Math.min(index, 2)]!.id, + createdByUserId: title === "someone-else" ? "other-user" : title === "scheduled" ? null : user, + responsibleUserId: user, + }))).returning(); + // A run links the task it created, as the routine service records it. + for (const row of rows.filter(row => row.originRunId)) { + await ctx.db.update(routineRuns).set({ linkedIssueId: row.id }).where(eq(routineRuns.id, row.originRunId!)); + } + const res = await request(app(f.actor)).get(url(f.companyId)).query({ ids: rows.map(row => row.id).join(","), navigation: "true" }).expect(200); + const byTitle = new Map(res.body.map((row: { title: string }) => [row.title, row])); + // Mine keeps routine work out, including runs the person starts manually. + expect(byTitle.get("mine")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: true }); + expect(byTitle.get("someone-else")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: false }); + expect(byTitle.get("scheduled")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: false }); + expect(byTitle.get("manual-task")).toMatchObject({ isParticipantForMe: true, isRecentEligibleForMe: true }); + }); + + it("admits a routine task the viewer opened to Recents without Mine participation", async () => { + const f = await fixture(); + const user = f.actor.userId!; + const rows = await ctx.db.insert(issues).values(["opened", "opened-by-other", "never-opened"].map(title => ({ + companyId: f.companyId, title, originKind: "routine_execution", responsibleUserId: user, + }))).returning(); + const id = (name: string) => rows.find(row => row.title === name)!.id; + await ctx.db.insert(issueReadStates).values([ + { companyId: f.companyId, issueId: id("opened"), userId: user }, + { companyId: f.companyId, issueId: id("opened-by-other"), userId: "other-user" }, + ]); + const res = await request(app(f.actor)).get(url(f.companyId)).query({ ids: rows.map(row => row.id).join(","), navigation: "true" }).expect(200); + const byTitle = new Map(res.body.map((row: { title: string }) => [row.title, row])); + expect(byTitle.get("opened")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: true }); + expect(byTitle.get("opened-by-other")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: false }); + expect(byTitle.get("never-opened")).toMatchObject({ isParticipantForMe: false, isRecentEligibleForMe: false }); + }); + it("matches the inbox unread predicate across participation, request, withdrawal and read histories", async () => { const f = await fixture(); const user = f.actor.userId!; diff --git a/server/src/services/issue-summaries.ts b/server/src/services/issue-summaries.ts index be1b9150d82..dc4a33caee0 100644 --- a/server/src/services/issue-summaries.ts +++ b/server/src/services/issue-summaries.ts @@ -1,6 +1,6 @@ import { issueDisplayStatusSql } from "./issue-display-status.js"; import { and, eq, inArray, isNull, sql, type SQL } from "drizzle-orm"; -import { activityLog, issueComments, issueReadStates, issueThreadInteractions, issues, type Db } from "@paperclipai/db"; +import { activityLog, issueComments, issueReadStates, issueThreadInteractions, issues, routineRuns, type Db } from "@paperclipai/db"; import { ISSUE_SUMMARIES_MAX_IDS } from "@paperclipai/shared"; import { directHumanCommentCondition } from "./issue-participation.js"; import { inboxVisibleForUserCondition, mineParticipationIssueIds, unreadForUserCondition } from "./issues.js"; @@ -62,7 +62,7 @@ export async function listIssueNavigationState( // MATERIALIZED prevents PostgreSQL from repeating privacy and viewer facts // across the task-state and child-count branches of the final union. const rows = await db.execute<{ - kind: string; id: string; unread: boolean; participant: boolean; archived: boolean; total: number; unread_count: number; + kind: string; id: string; unread: boolean; participant: boolean; recent_activity: boolean; archived: boolean; total: number; unread_count: number; }>(sql` with navigation_candidates as materialized ( select ${issues.id}, ${issues.parentId}, ${issues.conversationAgentId}, @@ -123,11 +123,29 @@ export async function listIssueNavigationState( select issues.id, issues.parent_id, issues.conversation_agent_id, coalesce(${unread}, false) as unread from navigation_facts as issues ) - select 'task' as kind, c.id, coalesce(s.unread, false) as unread, p.id is not null as participant, c.archived, 0 as total, 0 as unread_count + select 'task' as kind, c.id, coalesce(s.unread, false) as unread, p.id is not null as participant, + -- Recent personal activity that is not Mine participation: the viewer + -- opened the task (it has their read state), or started the manual + -- routine run that created it. + (exists ( + select 1 from ${issueReadStates} + where ${issueReadStates.companyId} = ${companyId} and ${issueReadStates.issueId} = c.id + and ${issueReadStates.userId} = ${userId} + ) or exists ( + -- The linked-issue index bounds this lookup; the origin-run check keeps + -- only the run that created the task, not later runs coalesced into it. + select 1 from ${issues} join ${routineRuns} + on ${routineRuns.linkedIssueId} = ${issues.id} and ${routineRuns.companyId} = ${companyId} + and ${routineRuns.id}::text = ${issues.originRunId} + where ${issues.id} = c.id and ${issues.companyId} = ${companyId} + and ${issues.createdByUserId} = ${userId} and ${issues.createdByAgentId} is null + and ${routineRuns.source} = 'manual' + )) as recent_activity, + c.archived, 0 as total, 0 as unread_count from navigation_candidates c left join navigation_state s on s.id = c.id left join navigation_participants p on p.id = c.id where c.id in (${requested}) union all - select 'children', c.parent_id, false, false, false, count(*)::int, count(*) filter (where s.unread)::int + select 'children', c.parent_id, false, false, false, false, count(*)::int, count(*) filter (where s.unread)::int from navigation_candidates c left join navigation_state s on s.id = c.id where c.parent_id in (${requested}) and c.conversation_agent_id is null group by c.parent_id `); @@ -135,6 +153,7 @@ export async function listIssueNavigationState( const children = new Map(rows.filter(row => row.kind === "children").map(row => [row.id, row])); return new Map(ids.map(id => [id, { isParticipantForMe: tasks.get(id)?.participant ?? false, + isRecentEligibleForMe: Boolean(tasks.get(id)?.participant || tasks.get(id)?.recent_activity), isUnreadForMe: tasks.get(id)?.unread ?? false, isArchivedForMe: tasks.get(id)?.archived ?? false, subtaskCount: children.get(id)?.total ?? 0, diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 07480d3b562..44f5b1bfde6 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -463,7 +463,7 @@ "packages/shared/src/types/index.ts": "f8eedd126cf46462eed07976d2f9480ad9194428", "packages/shared/src/types/instance.ts": "406736718fa7e8f788d4e963291943d38c16a368", "packages/shared/src/types/issue-tree-control.ts": "75489fffd491b8350b05caf57d7796419797d9df", - "packages/shared/src/types/issue.ts": "1a01870cfda97510486c20425fabe7ac553460ac", + "packages/shared/src/types/issue.ts": "c926a6a56874b18b3a61e22defaf9aca54172ca7", "packages/shared/src/types/live.ts": "b90e55e4de8600c6fc17d7fa8d89079d4ae655ec", "packages/shared/src/types/native-finalization.ts": "c026a73003ae232fea4f7624d561493b383df358", "packages/shared/src/types/plugin.ts": "9fa76312dc773a6fd461c7895323e7c7c3f99fef", diff --git a/ui/src/components/responsibilities/ResponsibilityOneScreenV2.tsx b/ui/src/components/responsibilities/ResponsibilityOneScreenV2.tsx index d81a3ff847a..9d110ef4381 100644 --- a/ui/src/components/responsibilities/ResponsibilityOneScreenV2.tsx +++ b/ui/src/components/responsibilities/ResponsibilityOneScreenV2.tsx @@ -54,6 +54,7 @@ import { WhoAvatar, } from "./SectionTable"; import type { ResponsibilityViewProps } from "./view-props"; +import { useRecordRoutineRunInRecents } from "@/hooks/useRecordRoutineRunInRecents"; /** The sections under the bar, in order. Each is one table whose header bar is just the word. */ export const ONE_SCREEN_V2_SECTIONS = ["routines", "skills", "projects", "tasks", "runs", "artifacts"] as const; @@ -326,9 +327,11 @@ export function ResponsibilityOneScreenV2({ }, [responsibility, agentsById]); const firstAgentId = working[0]?.id ?? null; + const recordRoutineRunInRecents = useRecordRoutineRunInRecents(); const runNow = useMutation({ mutationFn: (routine: ResponsibilityRoutineSummary) => routinesApi.run(routine.id, {}), - onSuccess: async () => { + onSuccess: async (run) => { + recordRoutineRunInRecents(run); await Promise.all([ queryClient.invalidateQueries({ queryKey: queryKeys.responsibilities.runs(responsibility.id) }), queryClient.invalidateQueries({ queryKey: queryKeys.responsibilities.detail(responsibility.id) }), diff --git a/ui/src/hooks/useRecentTasks.test.tsx b/ui/src/hooks/useRecentTasks.test.tsx index 7f65bdf3354..74439fc5517 100644 --- a/ui/src/hooks/useRecentTasks.test.tsx +++ b/ui/src/hooks/useRecentTasks.test.tsx @@ -11,6 +11,8 @@ import { getRecentTasksStorageKey, readRecentTasks, recordRecentTask, + recordStartedRoutineRunTask, + settleRecentTaskVisit, RECENT_TASKS_UPDATED_EVENT, } from "@/lib/recent-tasks"; import { RECENT_TASK_SUMMARY_CONCURRENCY, useRecentTasks } from "./useRecentTasks"; @@ -352,6 +354,74 @@ describe("recent task synchronization", () => { expect(readRecentTasks(storageKey, "company-1")[0]?.recordedAt).toBe(100); }); + it("shows a task from the viewer's manual routine run at the top before it is opened", async () => { + const personal = { ...task(10, "My work"), id: "personal" }; + recordRecentTask(personal, "user-1", 50); + recordStartedRoutineRunTask("company-1", "routine-task", "user-1", 100); + const started = { + ...task(20, "Daily scan"), id: "routine-task", identifier: "TASK-2", + isParticipantForMe: false, isRecentEligibleForMe: true, + }; + summaries.mockResolvedValue([personal, started]); + await act(async () => root.render()); + await flush(); + expect(container.textContent).toBe("Daily scan:todo,My work:todo"); + expect(readRecentTasks(storageKey, "company-1")[0]).toMatchObject({ id: "routine-task", title: "Daily scan", identifier: "TASK-2", recordedAt: 100 }); + }); + + it("drops a routine run task when the server does not confirm the viewer started it", async () => { + recordStartedRoutineRunTask("company-1", "routine-task", "user-1", 100); + summaries.mockResolvedValue([{ ...task(20, "Coalesced run"), id: "routine-task", isParticipantForMe: false, isRecentEligibleForMe: false }]); + await act(async () => root.render()); + await flush(); + expect(container.textContent).toBe(""); + expect(readRecentTasks(storageKey, "company-1")).toEqual([]); + }); + + it("moves an existing entry up when the viewer runs its routine again without losing its snapshot", () => { + recordRecentTask({ ...task(10, "Older"), id: "older" }, "user-1", 50); + recordRecentTask({ ...task(10, "Existing"), id: "existing" }, "user-1", 60); + recordStartedRoutineRunTask("company-1", "older", "user-1", 200); + expect(readRecentTasks(storageKey, "company-1").map(entry => [entry.id, entry.title, entry.recordedAt])) + .toEqual([["older", "Older", 200], ["existing", "Existing", 60]]); + }); + + it("keeps an opened automatic task until its read is saved, then shows it", async () => { + const opened = { ...task(10, "Routine result"), id: "opened", isParticipantForMe: false }; + recordRecentTask(opened, "user-1", 100, { awaitingRead: true }); + // The summary read races ahead of the read state that makes it eligible. + summaries.mockResolvedValue([{ ...opened, isRecentEligibleForMe: false }]); + const cache = client(); + await act(async () => root.render()); + await flush(); + expect(container.textContent).toBe(""); + expect(readRecentTasks(storageKey, "company-1").map(entry => entry.id)).toEqual(["opened"]); + summaries.mockResolvedValue([{ ...opened, isRecentEligibleForMe: true }]); + await act(async () => { + settleRecentTaskVisit("company-1", "opened", "user-1"); + await cache.invalidateQueries({ queryKey: queryKeys.issues.summaries("company-1") }); + }); + await flush(); + expect(container.textContent).toBe("Routine result:todo"); + expect(readRecentTasks(storageKey, "company-1")[0]).toMatchObject({ recordedAt: 100 }); + expect(readRecentTasks(storageKey, "company-1")[0]).not.toHaveProperty("awaitingRead"); + }); + + it("prunes an opened task after its read settles without making it eligible", async () => { + const opened = { ...task(10, "Failed read"), id: "opened", isParticipantForMe: false }; + recordRecentTask(opened, "user-1", 100, { awaitingRead: true }); + summaries.mockResolvedValue([{ ...opened, isRecentEligibleForMe: false }]); + const cache = client(); + await act(async () => root.render()); + await flush(); + await act(async () => { + settleRecentTaskVisit("company-1", "opened", "user-1"); + await cache.invalidateQueries({ queryKey: queryKeys.issues.summaries("company-1") }); + }); + await flush(); + expect(readRecentTasks(storageKey, "company-1")).toEqual([]); + }); + it("fetches a 25-task history in one request", async () => { const tasks = Array.from({ length: 25 }, (_, i) => ({ ...task(i + 1, `Task ${i}`), id: `issue-${String(i).padStart(2, "0")}` })); tasks.forEach(issue => recordRecentTask(issue, "user-1")); diff --git a/ui/src/hooks/useRecentTasks.ts b/ui/src/hooks/useRecentTasks.ts index 860de8fd422..947f6008c9b 100644 --- a/ui/src/hooks/useRecentTasks.ts +++ b/ui/src/hooks/useRecentTasks.ts @@ -26,6 +26,11 @@ const NO_PINNED_TASKS: readonly IssueSummary[] = []; /** Summary chunks in flight at once for a history longer than one request. */ export const RECENT_TASK_SUMMARY_CONCURRENCY = 3; +/** Recents admits participation, tasks the viewer opened, and manual routine runs they started. */ +function recentEligibility(issue: IssueSummary) { + return issue.isRecentEligibleForMe ?? issue.isParticipantForMe; +} + export function useRecentTasks({ companyId, userId, @@ -136,11 +141,13 @@ export function useRecentTasks({ const issue = confirmed.get(id); return issue ? [issue] : []; }), [confirmed, denied, pinnedTaskIds]); - // A visit is only a candidate. Neither imported provenance nor a persisted - // browser snapshot proves personal participation for the current account. + // A local entry is only a candidate. Neither imported provenance nor a + // persisted browser snapshot proves activity for the current account; the + // server confirms it (participation, a read state from opening it, or a + // manual routine run the viewer started). const refreshedEntries = useMemo(() => entries.flatMap((entry) => { const issue = confirmed.get(entry.id); - if (issue?.isParticipantForMe !== true || issue.isArchivedForMe) return []; + if (!issue || recentEligibility(issue) !== true || issue.isArchivedForMe) return []; return [{ ...mergeRecentTaskSnapshot(entry, issue), isUnreadForMe: issue.isUnreadForMe }]; }), [entries, confirmed]); const processed = useRef<{ visit: typeof batchVisit; revision: number } | null>(null); @@ -151,7 +158,7 @@ export function useRecentTasks({ processed.current = { visit: batchVisit, revision: updateCount }; // Older cached summaries without the new projection cannot prove either // eligibility or ineligibility. Keep those candidates until a current read. - const returnedIds = new Set(summaries.filter((issue) => issue.companyId === companyId && issue.isParticipantForMe !== false && !issue.isArchivedForMe).map((issue) => issue.id)); + const returnedIds = new Set(summaries.filter((issue) => issue.companyId === companyId && recentEligibility(issue) !== false && !issue.isArchivedForMe).map((issue) => issue.id)); updateRecentTaskSnapshots(storageKey, companyId, summaries); const omittedIds = new Set(recentIds.filter((id) => !returnedIds.has(id))); if (omittedIds.size && updateCount <= batchVisit.initialUpdateCount) { @@ -167,7 +174,7 @@ export function useRecentTasks({ useEffect(() => { if (!storageKey || !companyId || !summaries) return; const summaryById = new Map(summaries.filter((issue) => issue.companyId === companyId).map((issue) => [issue.id, issue])); - const authorizedIds = new Set([...summaryById.values()].filter(issue => issue.isParticipantForMe === true).map(issue => issue.id)); + const authorizedIds = new Set([...summaryById.values()].filter(issue => recentEligibility(issue) === true).map(issue => issue.id)); const mergeCached = (value: unknown) => { if (!value || typeof value !== "object") return; const issue = value as Issue; diff --git a/ui/src/hooks/useRecordRoutineRunInRecents.ts b/ui/src/hooks/useRecordRoutineRunInRecents.ts new file mode 100644 index 00000000000..286e55963b3 --- /dev/null +++ b/ui/src/hooks/useRecordRoutineRunInRecents.ts @@ -0,0 +1,17 @@ +import { useCallback } from "react"; +import type { RoutineRun } from "@paperclipai/shared"; +import { useAccountIdentity } from "@/api/companies-query"; +import { recordStartedRoutineRunTask } from "@/lib/recent-tasks"; + +/** + * Returns a callback for manual "Run now" successes. It adds the task that the + * run created to the viewer's Recents, even though they have not opened it. + */ +export function useRecordRoutineRunInRecents() { + const { userId, current } = useAccountIdentity(); + return useCallback((run: Pick | null | undefined) => { + // Never write one account's history while the session still holds another. + if (!current || !run?.linkedIssueId) return; + recordStartedRoutineRunTask(run.companyId, run.linkedIssueId, userId); + }, [current, userId]); +} diff --git a/ui/src/lib/recent-tasks.test.ts b/ui/src/lib/recent-tasks.test.ts index 5918827bc86..de3ca1e9426 100644 --- a/ui/src/lib/recent-tasks.test.ts +++ b/ui/src/lib/recent-tasks.test.ts @@ -4,6 +4,7 @@ import type { Issue } from "@paperclipai/shared"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { + AWAITING_READ_TTL_MS, RECENT_TASKS_UPDATED_EVENT, getRecentTasksStorageKey, migrateRecentTasks, @@ -158,6 +159,25 @@ describe("recent task persistence", () => { expect(readRecentTasks(storageKey, "company-1")[0]?.displayStatus).toBe("in_progress"); }); + it("keeps a visit waiting for its read, but prunes it once the wait is abandoned", () => { + const now = vi.spyOn(Date, "now").mockReturnValue(1_000_000); + try { + recordRecentTask(issue("1"), "user-1", 100, { awaitingRead: true }); + const storageKey = getRecentTasksStorageKey("company-1", "user-1"); + + now.mockReturnValue(1_000_000 + AWAITING_READ_TTL_MS - 1); + pruneRecentTasks(storageKey, "company-1", new Set(["1"])); + expect(readRecentTasks(storageKey, "company-1").map(entry => entry.id)).toEqual(["1"]); + + // The tab closed before the read settled, so nothing clears the wait. + now.mockReturnValue(1_000_000 + AWAITING_READ_TTL_MS); + pruneRecentTasks(storageKey, "company-1", new Set(["1"])); + expect(readRecentTasks(storageKey, "company-1")).toEqual([]); + } finally { + now.mockRestore(); + } + }); + it("prunes unavailable tasks and refreshes stored snapshots", () => { recordRecentTask(issue("1"), "user-1", 1); recordRecentTask(issue("2"), "user-1", 2); diff --git a/ui/src/lib/recent-tasks.ts b/ui/src/lib/recent-tasks.ts index 61c3c40c4ca..4222fcd4ff3 100644 --- a/ui/src/lib/recent-tasks.ts +++ b/ui/src/lib/recent-tasks.ts @@ -19,6 +19,23 @@ export interface RecentTaskEntry { // Server version of the title/status snapshot, independent of comment activity. // Legacy entries have no version until a detail query refreshes them. snapshotUpdatedAt?: number; + /** + * A fresh visit whose read is not saved yet. The read state is what makes an + * opened automatic task eligible, so the entry is kept (but not shown) until + * the read finishes. Holds when the wait started, stored so every tab honors + * it. A wait older than AWAITING_READ_TTL_MS is abandoned (e.g. the tab + * closed before the read settled) and no longer protects the entry. + */ + awaitingRead?: number; +} + +/** Longest time a fresh visit may wait for its read before pruning can remove it. */ +export const AWAITING_READ_TTL_MS = 2 * 60 * 1000; + +function isAwaitingRead(entry: RecentTaskEntry, now: number) { + return typeof entry.awaitingRead === "number" + && Number.isFinite(entry.awaitingRead) + && now - entry.awaitingRead < AWAITING_READ_TTL_MS; } interface RecentTasksUpdatedDetail { @@ -142,6 +159,7 @@ export function recordRecentTask( issue: Pick, userId: string | null | undefined, recordedAt?: number, + options?: { awaitingRead?: boolean }, ) { if (issue.conversationAgentId || issue.archivedAt) return; const storageKey = getRecentTasksStorageKey(issue.companyId, userId); @@ -170,6 +188,7 @@ export function recordRecentTask( ...snapshot, // A comment can promote activity even when its task details are stale. recordedAt: Math.max(activityAt, snapshot.recordedAt), + ...(options?.awaitingRead ? { awaitingRead: Date.now() } : {}), }; if ( existing @@ -181,6 +200,7 @@ export function recordRecentTask( && sameBlockerAttention(existing.blockerAttention, entry.blockerAttention) && existing.recordedAt === entry.recordedAt && existing.snapshotUpdatedAt === entry.snapshotUpdatedAt + && existing.awaitingRead === entry.awaitingRead ) return; writeRecentTasks( @@ -191,6 +211,28 @@ export function recordRecentTask( ); } +/** + * Puts a task the viewer just started from a manual routine run at the top of + * Recents before they open it. The run response has only the task ID, so the + * entry has no snapshot; the navigation summary supplies title and status and + * confirms that this viewer started the run before the row is shown. + */ +export function recordStartedRoutineRunTask( + companyId: string, + issueId: string, + userId: string | null | undefined, + recordedAt = Date.now(), +) { + const storageKey = getRecentTasksStorageKey(companyId, userId); + const current = readRecentTasks(storageKey, companyId); + const existing = current.find((candidate) => candidate.id === issueId); + if (existing && existing.recordedAt >= recordedAt) return; + const entry: RecentTaskEntry = existing + ? { ...existing, recordedAt } + : { id: issueId, companyId, title: "", identifier: null, status: "todo", recordedAt }; + writeRecentTasks(storageKey, [entry, ...current.filter((candidate) => candidate.id !== issueId)]); +} + export function pruneRecentTasks( storageKey: string, companyId: string, @@ -198,10 +240,28 @@ export function pruneRecentTasks( ) { if (removeIds.size === 0) return; const current = readRecentTasks(storageKey, companyId); - const next = current.filter((entry) => !removeIds.has(entry.id)); + // A visit waiting for its read cannot be judged yet; the read decides it. + // An abandoned wait expires so a deleted or inaccessible task is not kept. + const now = Date.now(); + const next = current.filter((entry) => isAwaitingRead(entry, now) || !removeIds.has(entry.id)); if (next.length !== current.length) writeRecentTasks(storageKey, next); } +/** + * Ends the wait that a fresh visit started. Call it when the visit's read + * settles; the next navigation summary then shows or prunes the entry. + */ +export function settleRecentTaskVisit(companyId: string, issueId: string, userId: string | null | undefined) { + const storageKey = getRecentTasksStorageKey(companyId, userId); + const current = readRecentTasks(storageKey, companyId); + if (!current.some((entry) => entry.id === issueId && entry.awaitingRead !== undefined)) return; + writeRecentTasks(storageKey, current.map((entry) => { + if (entry.id !== issueId) return entry; + const { awaitingRead: _awaitingRead, ...settled } = entry; + return settled; + })); +} + export function updateRecentTaskSnapshots( storageKey: string, companyId: string, diff --git a/ui/src/pages/ExecutionWorkspaceDetail.tsx b/ui/src/pages/ExecutionWorkspaceDetail.tsx index 9d8822c525d..ce2f4479620 100644 --- a/ui/src/pages/ExecutionWorkspaceDetail.tsx +++ b/ui/src/pages/ExecutionWorkspaceDetail.tsx @@ -53,6 +53,7 @@ import { import { useUpdateIssueMutation } from "../hooks/useUpdateIssueMutation"; import { ANALYTICS_MASK_CLASS } from "@/lib/analytics/privacy"; import { safeExternalHttpUrl } from "@/lib/safe-url"; +import { useRecordRoutineRunInRecents } from "@/hooks/useRecordRoutineRunInRecents"; type WorkspaceFormState = { name: string; @@ -666,6 +667,7 @@ function ExecutionWorkspaceRoutinesList({ [routinesQuery.data], ); + const recordRoutineRunInRecents = useRecordRoutineRunInRecents(); const runRoutine = useMutation({ mutationFn: ({ id, data }: { id: string; data?: RoutineRunDialogSubmitData }) => routinesApi.run(id, { ...(data?.variables && Object.keys(data.variables).length > 0 ? { variables: data.variables } : {}), @@ -682,7 +684,8 @@ function ExecutionWorkspaceRoutinesList({ onMutate: ({ id }) => { setRunningRoutineId(id); }, - onSuccess: async (_, { id }) => { + onSuccess: async (run, { id }) => { + recordRoutineRunInRecents(run); setRunDialogRoutine(null); await Promise.all([ queryClient.invalidateQueries({ queryKey: ["routines", workspace.companyId] }), diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index 32397df64b3..ad89f6bc28f 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -219,7 +219,7 @@ import { upsertInterruptedRun, } from "../lib/optimistic-issue-runs"; import { useProjectOrder } from "../hooks/useProjectOrder"; -import { recordRecentTask } from "../lib/recent-tasks"; +import { recordRecentTask, settleRecentTaskVisit } from "../lib/recent-tasks"; import { modelStillUnavailableToast } from "../lib/model-retry-refusal"; import { relativeTime, @@ -3901,7 +3901,11 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS if (!(streamlinedUiEnabled || coordinatorWorkspaceEnabled) || !loadedIssue || !sessionResolved || conversation || loadedIssue.conversationAgentId || loadedIssue.hiddenAt) return; const visit = `${loadedIssue.companyId}:${currentUserId}:${loadedIssue.id}`; - recordRecentTask(loadedIssue, currentUserId, recentTaskVisit.current === visit ? undefined : Date.now()); + const freshVisit = recentTaskVisit.current !== visit; + // A fresh visit waits for its read unless that read is already confirmed. + const readConfirmed = readReceiptRef.current?.issueId === loadedIssue.id && readReceiptRef.current.confirmed; + recordRecentTask(loadedIssue, currentUserId, freshVisit ? Date.now() : undefined, + freshVisit && !readConfirmed ? { awaitingRead: true } : undefined); recentTaskVisit.current = visit; }, [loadedIssue, currentUserId, sessionResolved, streamlinedUiEnabled, coordinatorWorkspaceEnabled, conversation]); const { data: boardAccess } = useQuery({ @@ -4648,6 +4652,8 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS }, onSuccess: (_data, receipt) => { receipt.confirmed = true; + // Settle before the refresh below so the new summary judges this visit. + settleRecentTaskVisit(receipt.companyId, receipt.issueId, currentUserId); // A late receipt belongs to its original company, even after navigation. queryClient.invalidateQueries({ queryKey: queryKeys.issues.summaries(receipt.companyId) }); if (selectedCompanyId) { @@ -4667,6 +4673,10 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS }, onFinished: (receipt) => { pendingReadReceiptsRef.current.delete(receipt.issueId); + // The saved read makes an opened automatic task eligible for Recents. + // Until now Recents kept the visit without judging it; after a failed + // read, the next summary prunes it unless the person qualifies otherwise. + settleRecentTaskVisit(receipt.companyId, receipt.issueId, currentUserId); // An older read can settle after navigation has changed the mutation observer. if (readReceiptRef.current === receipt) setReadReceiptRevision(revision => revision + 1); }, diff --git a/ui/src/pages/RoutineDetail.tsx b/ui/src/pages/RoutineDetail.tsx index 1b964f1287e..f982387dd3a 100644 --- a/ui/src/pages/RoutineDetail.tsx +++ b/ui/src/pages/RoutineDetail.tsx @@ -49,6 +49,7 @@ import { createIssueDetailLocationState } from "@/lib/issueDetailBreadcrumb"; import { useResolvedViewerId } from "@/hooks/useResolvedViewerId"; import { queryKeys } from "@/lib/queryKeys"; import { Navigate, useLocation, useNavigate, useParams, useSearchParams } from "@/lib/router"; +import { useRecordRoutineRunInRecents } from "@/hooks/useRecordRoutineRunInRecents"; /** Tasks shown per History page; "Load more" fetches the next page. */ export const ROUTINE_HISTORY_PAGE_SIZE = 20; @@ -205,6 +206,7 @@ function RoutineDetailPage({ companyId, routineId, view }: { companyId: string; onError: (error) => toastError("Couldn’t change the routine", error, "change the routine"), }); + const recordRoutineRunInRecents = useRecordRoutineRunInRecents(); const runRoutine = useMutation({ mutationFn: (data?: RoutineRunDialogSubmitData) => routinesApi.run(routineId, { @@ -215,7 +217,8 @@ function RoutineDetailPage({ companyId, routineId, view }: { companyId: string; ...(data?.executionWorkspacePreference !== undefined ? { executionWorkspacePreference: data.executionWorkspacePreference } : {}), ...(data?.executionWorkspaceSettings !== undefined ? { executionWorkspaceSettings: data.executionWorkspaceSettings } : {}), }), - onSuccess: async () => { + onSuccess: async (run) => { + recordRoutineRunInRecents(run); pushToast({ title: "Routine run started", tone: "success" }); setRunOpen(false); await Promise.all([ diff --git a/ui/src/pages/Routines.production.tsx b/ui/src/pages/Routines.production.tsx index 38c24c08dff..fa2356b35a6 100644 --- a/ui/src/pages/Routines.production.tsx +++ b/ui/src/pages/Routines.production.tsx @@ -58,6 +58,7 @@ import { selectedFolderFromList, type FolderSelection, } from "../components/folders/FolderControls"; +import { useRecordRoutineRunInRecents } from "@/hooks/useRecordRoutineRunInRecents"; type RoutinesTab = "routines" | "runs"; @@ -411,6 +412,7 @@ export function Routines() { }, }); + const recordRoutineRunInRecents = useRecordRoutineRunInRecents(); const runRoutine = useMutation({ mutationFn: ({ id, data }: { id: string; data?: RoutineRunDialogSubmitData }) => routinesApi.run(id, { ...(data?.variables && Object.keys(data.variables).length > 0 ? { variables: data.variables } : {}), @@ -427,7 +429,8 @@ export function Routines() { onMutate: ({ id }) => { setRunningRoutineId(id); }, - onSuccess: async (_, { id }) => { + onSuccess: async (run, { id }) => { + recordRoutineRunInRecents(run); setRunDialogRoutine(null); await Promise.all([ queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }), diff --git a/ui/src/pages/Routines.tsx b/ui/src/pages/Routines.tsx index 4aad20ca963..8b45876677b 100644 --- a/ui/src/pages/Routines.tsx +++ b/ui/src/pages/Routines.tsx @@ -59,6 +59,7 @@ import { type FolderSelection, } from "../components/folders/FolderControls"; import { useUpdateIssueMutation } from "../hooks/useUpdateIssueMutation"; +import { useRecordRoutineRunInRecents } from "@/hooks/useRecordRoutineRunInRecents"; type RoutinesTab = "routines" | "runs"; @@ -399,6 +400,7 @@ export function Routines() { }, }); + const recordRoutineRunInRecents = useRecordRoutineRunInRecents(); const runRoutine = useMutation({ mutationFn: ({ id, data }: { id: string; data?: RoutineRunDialogSubmitData }) => routinesApi.run(id, { ...(data?.variables && Object.keys(data.variables).length > 0 ? { variables: data.variables } : {}), @@ -415,7 +417,8 @@ export function Routines() { onMutate: ({ id }) => { setRunningRoutineId(id); }, - onSuccess: async (_, { id }) => { + onSuccess: async (run, { id }) => { + recordRoutineRunInRecents(run); setRunDialogRoutine(null); await Promise.all([ queryClient.invalidateQueries({ queryKey: queryKeys.routines.list(selectedCompanyId!) }), From 0f36a88f41e36e93e50f146196353840e2def341 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 20:54:56 -0800 Subject: [PATCH 016/119] fix(notifications): stop toasting "changed the title" on task updates (#23674) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The board shows live toast notifications when another person or agent changes a task. > - Each title edit makes a toast that says " changed the title". > - Agents often set or change task titles automatically. These toasts are noise and give no useful information. > - This pull request removes title changes from the toast details on the server and from the toast text in the UI. > - The benefit is fewer unhelpful notifications. Status, priority, assignment, and description changes still show. ## Linked Issues or Issue Description **Describe the bug** Users get toast notifications that only say " changed the title". **Steps to reproduce** 1. Open the board as a user. 2. Let another user or an agent change the title of a task. 3. See the toast " changed the title". **Expected behavior** A title change does not show a notification. Other changes in the same update still show. ## What Changed - `server/src/realtime/activity-toast-details.ts`: the projection does not set `titleChanged` any more. This also stops old cached UI bundles from showing the toast. - `ui/src/context/LiveUpdatesProvider.tsx`: `describeIssueUpdate` does not add "changed the title". A title-only update now makes no toast. - Tests: new UI and server tests for title-only and mixed updates. The existing tests now expect no `titleChanged` field. ## Verification - Red-green: the new UI test "does not announce title changes" failed before the fix and passes after it. - `cd ui && npx vitest run src/context/LiveUpdatesProvider.test.ts`: 140 passed. - `cd server && npx vitest run src/realtime/activity-toast-details.test.ts src/__tests__/live-events-toast.test.ts`: 19 passed. ## Risks - Low risk. Title changes do not show a toast any more. The task activity log still records them. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution in Claude Code. ## 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) - [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details (the execution workspace assigned the branch name) - [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 (no doc describes this toast) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- server/src/__tests__/live-events-toast.test.ts | 2 +- server/src/realtime/activity-toast-details.test.ts | 7 ++++++- server/src/realtime/activity-toast-details.ts | 1 - ui/src/context/LiveUpdatesProvider.test.ts | 7 +++++++ ui/src/context/LiveUpdatesProvider.tsx | 1 - 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/src/__tests__/live-events-toast.test.ts b/server/src/__tests__/live-events-toast.test.ts index 352a5e0bece..1fd34deded5 100644 --- a/server/src/__tests__/live-events-toast.test.ts +++ b/server/src/__tests__/live-events-toast.test.ts @@ -337,7 +337,7 @@ describe("authenticated activity notifications", () => { } }); await third; expect(messages[2].payload.taskIdentityChanged).toBe(true); - expect(messages[2].payload.notificationDetails).toEqual({ titleChanged: true }); + expect(messages[2].payload.notificationDetails).toEqual({}); if (deploymentMode === "authenticated") expect(JSON.stringify(messages[2].payload)).not.toContain("Secret new title"); } finally { socket.terminate(); diff --git a/server/src/realtime/activity-toast-details.test.ts b/server/src/realtime/activity-toast-details.test.ts index 9444ad60ad8..4b1d3a26ff0 100644 --- a/server/src/realtime/activity-toast-details.test.ts +++ b/server/src/realtime/activity-toast-details.test.ts @@ -30,9 +30,14 @@ describe("task notification details", () => { it("supports older activity without change receipts and rejects unknown enum values", () => { expect(activityToastDetails("issue.updated", { status: "blocked", assigneeAgentId: null, title: "New name" })) - .toEqual({ status: "blocked", assignment: "unassigned", titleChanged: true }); + .toEqual({ status: "blocked", assignment: "unassigned" }); expect(activityToastDetails("issue.updated", { status: "private text", priority: "private text", executionRunId: "run-private-id" })).toEqual({}); expect(activityToastDetails("issue.updated", { status: "done", changes: {} })).toEqual({}); expect(activityToastDetails("issue.updated", null)).toEqual({}); }); + + it("does not announce title changes", () => { + expect(activityToastDetails("issue.updated", { changes: { title: { from: "Old", to: "New" } } })).toEqual({}); + expect(activityToastDetails("issue.updated", { title: "New name" })).toEqual({}); + }); }); diff --git a/server/src/realtime/activity-toast-details.ts b/server/src/realtime/activity-toast-details.ts index b17912010a0..337dd25c665 100644 --- a/server/src/realtime/activity-toast-details.ts +++ b/server/src/realtime/activity-toast-details.ts @@ -36,7 +36,6 @@ export function activityToastDetails(action: unknown, value: unknown): Record typeof next(key) === "string"); result.assignment = assigned ? "reassigned" : "unassigned"; } - if (changed("title")) result.titleChanged = true; if (changed("description")) result.descriptionChanged = true; return result; } diff --git a/ui/src/context/LiveUpdatesProvider.test.ts b/ui/src/context/LiveUpdatesProvider.test.ts index 635f18129f8..224dd395a8c 100644 --- a/ui/src/context/LiveUpdatesProvider.test.ts +++ b/ui/src/context/LiveUpdatesProvider.test.ts @@ -2475,6 +2475,13 @@ describe("activity toast attribution", () => { expect(build(new QueryClient(), "company", { ...payload, action: "issue.updated", notificationDetails: details }, viewer)).toBeNull(); } }); + it("does not announce title changes", () => { + for (const details of [{ titleChanged: true }, { title: "Renamed task" }]) { + expect(build(new QueryClient(), "company", { ...payload, action: "issue.updated", notificationDetails: details }, viewer)).toBeNull(); + } + const toast = build(new QueryClient(), "company", { ...payload, action: "issue.updated", notificationDetails: { titleChanged: true, priority: "high" } }, viewer); + expect(toast?.body).toBe("Alex Example set priority to high"); + }); it("does not fall back to raw details when the server projected an empty update", () => { expect(build(new QueryClient(), "company", { ...payload, action: "issue.updated", notificationDetails: {}, details: { status: "done" } }, viewer)).toBeNull(); }); diff --git a/ui/src/context/LiveUpdatesProvider.tsx b/ui/src/context/LiveUpdatesProvider.tsx index 2f2321400ec..5848887a169 100644 --- a/ui/src/context/LiveUpdatesProvider.tsx +++ b/ui/src/context/LiveUpdatesProvider.tsx @@ -1206,7 +1206,6 @@ function describeIssueUpdate( } else if (details.assignment === "unassigned" || details.assigneeAgentId === null || details.assigneeUserId === null) { changes.push("unassigned the task"); } - if (details.titleChanged === true || typeof details.title === "string") changes.push("changed the title"); if (details.descriptionChanged === true || typeof details.description === "string") changes.push("changed the description"); return changes.length > 0 ? changes.join(", ") : null; } From 3d3c702942be33762435dde5d78544c6ea74e5d8 Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Thu, 3 Dec 2026 21:56:45 -0800 Subject: [PATCH 017/119] fix(runner): keep room to retire a session that filled its command journal (#23700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native agent runs use a Runner. Core keeps a durable journal of the commands that it sends to the Runner. > - The journal stops at 500 commands. A long run adds one semantic tool result to the journal for each tool call, so the journal can become full. > - The next run on the same sandbox must retire that session. It must queue `turn.stop`, `runner.drain`, `runner.suspend` and `session.close`. The full journal rejects these commands. > - Each successor run then fails with `native_predecessor_retirement_unproven` (`command_journal_full`). The task stays stuck until a person intervenes. > - This pull request keeps a separate, bounded reserve in the journal for retirement commands only. > - The benefit is that the next run can always stop and close a session whose work filled the journal. ## Linked Issues or Issue Description **What happened?** A long native run (Codex app-server) made almost 500 tool calls. Its Core command journal became full. Three automatic successor runs on the same sandbox then failed in `retireWarmPredecessor`. The error was "The previous run's session on this sandbox could not be retired (Durable PRP command journal bound exceeded: command_journal_full.)". The stack ends in `DurablePrpControlPlane.queueCommand` from `awaitRunnerSuspensionBarrier`. **Expected behavior** The next run retires the old session and continues. A full work journal must not block the commands that stop and close the session. **Steps to reproduce** 1. Create a `DurablePrpControlPlane`. 2. Queue 500 `semantic_tool.result` commands. 3. Queue `turn.stop`, `runner.drain`, `runner.suspend` or `session.close`. 4. On `master`, each of these throws `command_journal_full`. **Paperclip version or commit** `986af44e94` (`master`). The failure was seen on release `3f882fc589`. **Agent adapter(s) involved** Codex (native Runner, `paperclip_runner` adapter). The journal is not adapter-specific. Related: #20727 (a draft about the other journal bound, `command_payload_too_large`). This PR does not change that bound. ## What Changed - `durable-prp-control-plane.ts`: work commands still stop at 500 (`maxCommands`). - Retirement commands (`turn.stop`, `runner.drain`, `runner.suspend`, `runner.shutdown`, `session.close`, `session.destroy`, `run.cancel`) can use 64 more slots (`retirementCommandReserve`). Reads such as `session.snapshot` cannot use the reserve, so readiness polls cannot consume it. - The saved-state check and the checkpoint check accept up to 564 commands. Without this change, a retired journal cannot load again. - Three tests: one fills the journal and retires it, then reopens the local state. One does the same with checkpoint persistence and decodes the checkpoint. One fills the reserve to 564 commands and checks that a 565th retirement command and a read are both rejected without changing the journal. ## Verification - Red before the fix: `npx vitest run src/control-plane/durable-prp-control-plane.test.ts -t "command journal"` failed with `command_journal_full` on `turn.stop`. - Green after the fix: the same command passes (2 tests). - Each load bound is necessary: when I put back the old bound in the two validation checks, both tests fail. - Reserve bound: with the hard-cap check removed, the boundary test fails (`expected [Function] to throw an error`). - After review fixes (3c6fe49e80): `durable-prp-control-plane.test.ts` passes (238 tests). - Affected suites (3e72d97be6): `durable-prp-control-plane.test.ts`, `durable-prp-checkpoint-records.test.ts` and `warm-attachment-readiness.test.ts` pass (248 tests). - The Rust Runner has no command-count bound. It compacts its own journal, so it accepts the extra controller sequences. - Not run locally: the full suite and `pnpm verify` (its selection step did not finish in 5 minutes on this machine). CI supplies this coverage. ## Risks - Low risk. Work commands keep the same 500 bound. The journal can grow by a maximum of 64 small retirement commands. - A run whose work fills the journal still stops its own work at 500 commands. This PR does not change that limit. It only makes sure that the next run can retire the session. - An older Core build that loads a journal with more than 500 commands rejects that state. This can only occur after a rollback, and it fails closed as before. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, file edit, Sentry and Paperclip tools) in Claude Code. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .../durable-prp-control-plane.test.ts | 68 +++++++++++++++++++ .../durable-prp-control-plane.ts | 12 +++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.test.ts b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.test.ts index 2bd82634631..240eb894062 100644 --- a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.test.ts +++ b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.test.ts @@ -95,6 +95,74 @@ it("admits only source maintenance while the authenticated owner differs", async } finally { await core.stop(); rmSync(root, { recursive: true, force: true }); } }); +function fillAndRetireCommandJournal(core: DurablePrpControlPlane): void { + for (let index = 0; index < 500; index += 1) { + core.queueCommand("semantic_tool.result", { callId: `call-${index}`, result: { ok: true }, isError: false }, + `command_tool_full_${index}`); + } + expect(() => core.queueCommand("turn.start", { text: "more work" })).toThrow("command_journal_full"); + expect(() => core.queueCommand("session.snapshot")).toThrow("command_journal_full"); + for (const type of ["turn.stop", "runner.drain", "runner.suspend", "session.close"]) { + expect(core.queueCommand(type, {}, `command_retire_${type.replace(".", "_")}`).type).toBe(type); + } +} + +it("keeps room to retire a session whose work filled the command journal", async () => { + const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-retirement-")); + const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest }); + let reopened: DurablePrpControlPlane | undefined; + try { + fillAndRetireCommandJournal(core); + expect(core.store.state.commands).toHaveLength(504); + await core.stop(); + reopened = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest }); + expect(reopened.store.state.commands).toHaveLength(504); + expect(reopened.queueCommand("runner.suspend", {}, "command_retire_again").type).toBe("runner.suspend"); + } finally { + await reopened?.stop(); + await core.stop(); + rmSync(root, { recursive: true, force: true }); + } +}); + +it("bounds the retirement reserve and leaves the journal unchanged when it is full", async () => { + const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-reserve-bound-")); + const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest }); + try { + fillAndRetireCommandJournal(core); + for (let index = 504; index < 563; index += 1) { + core.queueCommand("runner.suspend", {}, `command_retire_suspend_${index}`); + } + expect(core.store.state.commands).toHaveLength(563); + expect(core.queueCommand("session.close", {}, "command_retire_last").controllerSeq).toBe(564); + expect(core.store.state.commands).toHaveLength(564); + const before = JSON.stringify(core.store.state.commands); + expect(() => core.queueCommand("runner.suspend", {}, "command_retire_overflow")).toThrow("command_journal_full"); + expect(() => core.queueCommand("session.snapshot")).toThrow("command_journal_full"); + expect(JSON.stringify(core.store.state.commands)).toBe(before); + } finally { + await core.stop(); + rmSync(root, { recursive: true, force: true }); + } +}); + +it("checkpoints a retired session whose work filled the command journal", async () => { + const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-checkpoint-")); + const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest }); + let checkpoint!: DurablePrpCheckpoint; + core.setCheckpointPersistence(async value => { checkpoint = value; }); + try { + fillAndRetireCommandJournal(core); + await core.flushCheckpoint(); + expect(core.store.state.commands).toHaveLength(504); + const restored = decodeDurablePrpCheckpoint(checkpoint.records); + expect([...restored.records.keys()].filter(key => key.startsWith("command:"))).toHaveLength(504); + } finally { + await core.stop(); + rmSync(root, { recursive: true, force: true }); + } +}); + it("keeps already-dispatching target work independent of predecessor completion", async () => { const root = mkdtempSync(resolve(tmpdir(), "runner-target-dispatch-")); const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest, diff --git a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts index 3cfe779859c..5f0d290fbf9 100644 --- a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts +++ b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts @@ -67,6 +67,11 @@ const maxFrameBytes = 1024 * 1024; const maxCommandBytes = Math.floor((maxFrameBytes - 4 * 1024) / 2); const RUN_ATTACH_ENVELOPE_BYTES = 32 * 1024; const maxCommands = 500; +const retirementCommandTypes = new Set([ + "turn.stop", "runner.drain", "runner.suspend", "runner.shutdown", "session.close", "session.destroy", "run.cancel", +]); +const retirementCommandReserve = 64; +const maxJournalCommands = maxCommands + retirementCommandReserve; const maxCommandsAtAttach = 32; const maxEventsPerAck = 64; class CommandJournalLimitError extends Error { @@ -608,7 +613,7 @@ function checkpointState(records: ReadonlyMap) { .sort((a, b) => Number(a.slice(prefix.length)) - Number(b.slice(prefix.length))); const commandKeys = v2 ? keys("command:") : header.commands; const eventKeys = v2 ? keys("event:") : header.events; - if (!Array.isArray(commandKeys) || commandKeys.length > maxCommands + if (!Array.isArray(commandKeys) || commandKeys.length > maxJournalCommands || !Array.isArray(eventKeys) || eventKeys.length > maxCommittedEventWindow || commandKeys.some(key => typeof key !== "string" || !/^command:\d+$/.test(key)) || eventKeys.some(key => typeof key !== "string" || !/^event:\d+$/.test(key)) @@ -1209,7 +1214,7 @@ function isStoredCoreState( !isRecord(value.tickets) || !isRecord(value.leases) || !Array.isArray(commands) || - commands.length > maxCommands || + commands.length > maxJournalCommands || !Array.isArray(events) || events.length > maxCommittedEventWindow || !Number.isSafeInteger(value.ackedSourceSeq) || @@ -3160,7 +3165,8 @@ export class DurablePrpControlPlane { status: "pending", result: null, }; - if (this.#store.state.commands.length >= maxCommands) + const journalLength = this.#store.state.commands.length; + if (journalLength >= maxJournalCommands || (journalLength >= maxCommands && !retirementCommandTypes.has(type))) throw new CommandJournalLimitError("command_journal_full"); if (Buffer.byteLength(JSON.stringify(command)) > maxCommandBytes) throw new CommandJournalLimitError("command_payload_too_large"); From 597992d95547046ed81a41f610c4991776d9f8f7 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Thu, 3 Dec 2026 23:46:32 -0800 Subject: [PATCH 018/119] fix(ui): open the chat side drawer on the chat's task list (#23702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agent Chat lets a person talk to one agent. The chat header has a button that toggles the right side drawer. > - In a new chat, the button did nothing. The desktop panel did not show content until the chat was saved by the first message. > - In the coordinator workspace, the drawer opened on an empty launcher. It did not show the tasks from the chat. > - The user expects the button to open a list of the tasks that the chat created or that its agent worked on. > - This pull request makes the drawer open on that task list in both cases. > - The benefit is that the header button always does something useful in a chat. ## Linked Issues or Issue Description **What happened?** In the chat view, the button in the top right toggles the right side drawer. In a new chat, a click on the button does nothing. In the coordinator workspace, the drawer opens empty. **What did you expect to happen?** The button opens the drawer with a list of the tasks that the chat created or worked on. **Steps to reproduce** 1. Turn on Agent Chat. 2. Open a chat with an agent that has no saved conversation. 3. Click the drawer button in the top right of the header. 4. The drawer does not open. ## What Changed - `IssueDetail.tsx`: For an unsaved chat on desktop, the panel now shows a read-only task list. The full side panel still needs a saved issue, because its Properties tab writes to the issue. - `AgentWorkPanels.tsx`: Add `AgentChatDraftTasksPanel`. It shows the agent's tasks. In the coordinator workspace, it shows the empty list of tasks from the conversation. - `TaskSidePanel.tsx`: In the coordinator workspace, a saved chat now opens on its Tasks tab ("Tasks from this conversation") and not on the empty launcher. Other tasks keep the empty, on-demand panel. - Add `IssueDetail.agentChatPanel.test.tsx` with four desktop tests: a saved chat, an unsaved chat, a saved coordinator chat, and an unsaved coordinator chat. ## Verification - `cd ui && npx vitest run src/pages/IssueDetail.agentChatPanel.test.tsx src/pages/IssueDetail.mobile.test.tsx`: 7 tests pass. - Red-green: before the fix, the unsaved-chat test failed because the drawer stayed hidden. The coordinator test failed when I removed the `TaskSidePanel.tsx` change. - `pnpm verify`: 4,214 tests pass in 260 of 261 selected files. One test, `codemirror-single-instance.test.ts`, timed out at 5 s under load. It walks `node_modules` and does not touch this change. It passes alone (10/10). - `npx tsc --noEmit -p ui`: no errors in changed files. The only errors come from Storybook feature-map files that need generated indexes. Those indexes are not in git. - I did not do a manual browser check. The local preflight build did not finish in time. ## Risks - Low risk. The change applies only to Agent Chat routes. - In the coordinator workspace, a chat's drawer now opens on Tasks and not on the launcher. The user can still open other tabs from the launcher. - The unsaved-chat task list in the classic workspace shows all the agent's tasks. That is the same list as the saved chat's default Tasks tab. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## 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 - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- ui/src/components/chat/AgentWorkPanels.tsx | 27 ++ .../task-side-panel/TaskSidePanel.tsx | 4 +- .../pages/IssueDetail.agentChatPanel.test.tsx | 406 ++++++++++++++++++ ui/src/pages/IssueDetail.tsx | 15 + 4 files changed, 451 insertions(+), 1 deletion(-) create mode 100644 ui/src/pages/IssueDetail.agentChatPanel.test.tsx diff --git a/ui/src/components/chat/AgentWorkPanels.tsx b/ui/src/components/chat/AgentWorkPanels.tsx index 541c15c6c43..52bba96fc83 100644 --- a/ui/src/components/chat/AgentWorkPanels.tsx +++ b/ui/src/components/chat/AgentWorkPanels.tsx @@ -334,3 +334,30 @@ export function AgentArtifactsPanel({ companyId, agentId }: { companyId: string; ); } + +/** + * The side panel for an agent chat that has no saved conversation yet. The + * chat's own task panel needs a saved issue, so this shows the same task list + * read-only: the agent's tasks, or, in the coordinator workspace, the empty + * list of tasks created from this conversation. + */ +export function AgentChatDraftTasksPanel({ + companyId, + agentId, + conversationScoped, +}: { + companyId: string; + agentId: string; + conversationScoped: boolean; +}) { + return ( +
      +

      Tasks

      + {conversationScoped ? ( + Tasks created from this conversation will appear here. + ) : ( + + )} +
      + ); +} diff --git a/ui/src/components/task-side-panel/TaskSidePanel.tsx b/ui/src/components/task-side-panel/TaskSidePanel.tsx index ab347f19c82..41f873b61df 100644 --- a/ui/src/components/task-side-panel/TaskSidePanel.tsx +++ b/ui/src/components/task-side-panel/TaskSidePanel.tsx @@ -336,8 +336,10 @@ function TaskSidePanelForScope({ const handledDocumentRequestRef = useRef(undefined); const initialState = useMemo(() => { const restored = restoredRef.current?.state; + // The coordinator panel opens empty on demand, except a chat opens on + // the tasks from that conversation. let tabs = coordinatorWorkspaceEnabled - ? restoredRef.current?.userInteracted ? restored?.tabs ?? [] : [] + ? restoredRef.current?.userInteracted ? restored?.tabs ?? [] : conversationAgentId ? [taskPanelAgentTasksTab()] : [] : restored?.tabs ?? (conversationAgentId ? [taskPanelAgentTasksTab()] : issue.conversationAgentId ? [taskPanelArtifactsTab()] : [taskPanelPropertiesTab()]); diff --git a/ui/src/pages/IssueDetail.agentChatPanel.test.tsx b/ui/src/pages/IssueDetail.agentChatPanel.test.tsx new file mode 100644 index 00000000000..14046db5539 --- /dev/null +++ b/ui/src/pages/IssueDetail.agentChatPanel.test.tsx @@ -0,0 +1,406 @@ +// @vitest-environment jsdom +import { act, type ReactNode } from "react"; +import { createRoot, type Root } from "react-dom/client"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { MemoryRouter, Route, Routes } from "react-router-dom"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { Agent, Issue } from "@paperclipai/shared"; +import { BreadcrumbBar } from "../components/BreadcrumbBar"; +import { BreadcrumbProvider } from "../context/BreadcrumbContext"; +import { PanelProvider } from "../context/PanelContext"; +import { ThemeProvider } from "../context/ThemeContext"; +import { ToastProvider } from "../context/ToastContext"; +import { TooltipProvider } from "@/components/ui/tooltip"; +import { DialogProvider } from "../context/DialogContext"; +import { PropertiesPanel } from "../components/PropertiesPanel"; +import { TaskDetailSurface } from "./IssueDetail"; + +(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; + +const COMPANY_ID = "company-1"; +const AGENT: Agent = { + id: "agent-cos", + companyId: COMPANY_ID, + name: "Chief of Staff", + urlKey: "chief-of-staff", + role: "ceo", + title: "Chief of Staff", + icon: null, + status: "idle", + reportsTo: null, + capabilities: null, + adapterType: "claude_local", + adapterConfig: {}, + runtimeConfig: {}, + budgetMonthlyCents: 0, + spentMonthlyCents: 0, + pauseReason: null, + pausedAt: null, + permissions: { canCreateAgents: false }, + lastHeartbeatAt: null, + metadata: null, + createdAt: new Date("2026-08-01T10:00:00Z"), + updatedAt: new Date("2026-08-01T10:00:00Z"), +}; + +const BASE_ISSUE: Issue = { + id: "11111111-1111-4111-8111-111111111111", + companyId: COMPANY_ID, + projectId: null, + projectWorkspaceId: null, + goalId: null, + parentId: null, + title: "Streamlined mobile task detail test", + description: "Verify mobile Properties sheet and More task actions menu.", + status: "in_progress", + priority: "medium", + reviewPolicy: null, + assigneeAgentId: AGENT.id, + assigneeUserId: null, + responsibleUserId: null, + checkoutRunId: null, + executionRunId: null, + executionAgentNameKey: null, + executionLockedAt: null, + createdByAgentId: null, + createdByUserId: "user-1", + issueNumber: 6794, + identifier: "PAP-6794", + originKind: "manual", + originId: null, + originRunId: null, + requestDepth: 0, + billingCode: null, + assigneeAdapterOverrides: null, + executionPolicy: null, + executionState: null, + executionWorkspaceId: null, + executionWorkspacePreference: null, + executionWorkspaceSettings: null, + startedAt: null, + completedAt: null, + cancelledAt: null, + hiddenAt: null, + project: null, + goal: null, + currentExecutionWorkspace: null, + workProducts: [], + mentionedProjects: [], + myLastTouchAt: null, + lastExternalCommentAt: null, + lastActivityAt: null, + isUnreadForMe: false, + workMode: "standard", + createdAt: new Date("2026-08-01T10:00:00Z"), + updatedAt: new Date("2026-08-01T10:00:00Z"), +}; + +const CHAT_ISSUE: Issue = { + ...BASE_ISSUE, + id: "22222222-2222-4222-8222-222222222222", + identifier: "PAP-9001", + title: "Chat with Chief of Staff", + conversationAgentId: AGENT.id, +}; + +const testState = vi.hoisted(() => ({ + issue: null as Issue | null, + coordinator: false, +})); + +vi.mock("../context/SidebarContext", () => ({ + useSidebar: () => ({ + isMobile: false, + sidebarOpen: false, + setSidebarOpen: vi.fn(), + toggleSidebar: vi.fn(), + }), +})); + +vi.mock("../context/CompanyContext", () => ({ + useCompany: () => ({ + selectedCompanyId: COMPANY_ID, + selectedCompany: { id: COMPANY_ID, name: "Paperclip", issuePrefix: "PAP" }, + companies: [{ id: COMPANY_ID, name: "Paperclip", issuePrefix: "PAP" }], + setSelectedCompanyId: vi.fn(), + }), + useOptionalCompany: () => ({ + selectedCompanyId: COMPANY_ID, + selectedCompany: { id: COMPANY_ID, name: "Paperclip", issuePrefix: "PAP" }, + companies: [{ id: COMPANY_ID, name: "Paperclip", issuePrefix: "PAP" }], + }), +})); + +vi.mock("../context/LiveUpdatesProvider", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + useTaskRunLiveUpdates: () => ({ + subscribe: () => () => undefined, + }), + useTranscriptLiveStream: () => ({ + events: [], + connected: false, + }), + }; +}); + +vi.mock("../context/DesignSandboxContext", () => ({ + useDesignSandbox: () => false, +})); + +vi.mock("../hooks/useStreamlinedUiEnabled", () => ({ + useStreamlinedUiEnabled: () => ({ enabled: true, loaded: true }), +})); + +vi.mock("../hooks/useClassicTaskInterfaceEnabled", () => ({ + useClassicTaskInterfaceEnabled: () => ({ enabled: false, loaded: true }), +})); + +vi.mock("@/hooks/useCoordinatorWorkspaceEnabled", () => ({ + useCoordinatorWorkspaceEnabled: () => ({ enabled: testState.coordinator, loaded: true, userId: "user-1" }), +})); + +const NO_SLOTS = vi.hoisted(() => ({ slots: [] as unknown[], launchers: [] as unknown[] })); + +vi.mock("@/plugins/slots", () => ({ + usePluginSlots: () => NO_SLOTS, + PluginSlotOutlet: () => null, + PluginSlotMount: () => null, +})); + +vi.mock("@/plugins/launchers", () => ({ + usePluginLaunchers: () => NO_SLOTS, + PluginLauncherOutlet: () => null, +})); + +vi.mock("../components/task-side-panel", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + TaskSidePanel: (props: Parameters[0]) => testState.coordinator + ? + :
      Side panel for {props.issue.identifier}
      , + }; +}); + +vi.mock("@/lib/router", async () => { + const actual = await vi.importActual("react-router-dom"); + return { + ...actual, + Link: ({ to, children, ...props }: { to: string; children: ReactNode } & React.ComponentProps<"a">) => ( + {children} + ), + }; +}); + +function installMockFetch() { + const originalFetch = globalThis.fetch; + globalThis.fetch = vi.fn(async (input: RequestInfo | URL) => { + const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url; + const pathname = new URL(rawUrl, "http://localhost").pathname; + const json = (data: unknown) => + new Response(JSON.stringify(data), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + + if (pathname === "/api/auth/get-session") { + return json({ session: { userId: "user-1" }, user: { id: "user-1", name: "Riley Board" } }); + } + if (pathname === "/api/instance/settings/experimental") { + return json({ enableStreamlinedUi: true, enableAgentChat: true }); + } + if (pathname === "/api/workspace-preferences/me") { + return json({ userId: "user-1", coordinatorWorkspaceEnabled: false, updatedAt: null }); + } + if (pathname === "/api/cli-auth/me") { + return json({ source: "local_implicit", isInstanceAdmin: true, companyIds: [COMPANY_ID], memberships: [] }); + } + if (pathname === `/api/companies/${COMPANY_ID}/agents`) { + return json([AGENT]); + } + if (pathname === `/api/companies/${COMPANY_ID}/access/user-directory`) { + return json({ users: [{ principalId: "user-1", status: "active", user: { name: "Riley Board" } }] }); + } + if (/^\/api\/issues\/[^/]+\/(chat-handoffs|decision-receipts)$/.test(pathname)) { + return json({ items: [], nextCursor: null }); + } + if (/^\/api\/issues\/[^/]+$/.test(pathname)) { + return json(testState.issue ?? BASE_ISSUE); + } + if (pathname === `/api/issues/${BASE_ISSUE.id}/inbox-archive`) { + return json({ id: BASE_ISSUE.id, archivedAt: "2026-08-01T11:00:00Z" }); + } + if (/^\/api\/issues\/[^/]+\/recent-comments$/.test(pathname)) { + return json({ comments: [], hasMore: false, latestCommentId: null }); + } + if (/^\/api\/issues\/[^/]+\/queued-comments$/.test(pathname)) { + return json({ queues: [], items: [], revision: "rev-1" }); + } + if (/^\/api\/issues\/[^/]+\/tree-control\/state$/.test(pathname)) { + return json({ activePauseHold: null }); + } + if (/^\/api\/issues\/[^/]+\/documents\/plan$/.test(pathname)) { + return new Response(JSON.stringify({ error: "Not found" }), { + status: 404, + headers: { "Content-Type": "application/json" }, + }); + } + if (/^\/api\/issues\/[^/]+\/(active-run|runner-goal)$/.test(pathname)) { + return json(null); + } + if (/^\/api\/companies\/[^/]+\/email\/tasks\/[^/]+$/.test(pathname)) { + return json(null); + } + return json([]); + }) as typeof fetch; + + return () => { + globalThis.fetch = originalFetch; + }; +} + +describe("AgentChat desktop side panel toggle", () => { + let container: HTMLDivElement; + let root: Root; + let client: QueryClient; + let restoreFetch: () => void; + + beforeEach(() => { + testState.issue = BASE_ISSUE; + testState.coordinator = false; + localStorage.clear(); + restoreFetch = installMockFetch(); + if (!globalThis.ResizeObserver) { + globalThis.ResizeObserver = class ResizeObserver { + observe() {} + unobserve() {} + disconnect() {} + }; + } + Object.defineProperty(HTMLElement.prototype, "scrollTo", { + configurable: true, + writable: true, + value: vi.fn(), + }); + Object.defineProperty(HTMLElement.prototype, "scrollIntoView", { + configurable: true, + writable: true, + value: vi.fn(), + }); + container = document.createElement("div"); + document.body.appendChild(container); + root = createRoot(container); + client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + }); + + afterEach(async () => { + await act(async () => root.unmount()); + client.clear(); + container.remove(); + restoreFetch(); + }); + + async function flush() { + for (let i = 0; i < 6; i++) { + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 10)); + }); + } + } + + function Harness({ children, initialEntry }: { children: ReactNode; initialEntry: string }) { + return ( + + + + + + + + {children} + + + + + + + + ); + } + + function panelText() { + return container.querySelector("aside")?.textContent ?? ""; + } + + async function renderChat(issue: Issue | null) { + await act(async () => { + root.render( + + + CHAT_ISSUE, + }} + /> + + , + ); + }); + await flush(); + } + + async function clickToggle() { + const toggle = container.querySelector('button[aria-label="Show properties"], button[aria-label="Hide properties"]'); + expect(toggle).not.toBeNull(); + await act(async () => toggle!.click()); + await flush(); + } + + it("opens the drawer for a saved chat and closes it again", async () => { + localStorage.setItem("paperclip:panel-visible", "false"); + testState.issue = CHAT_ISSUE; + await renderChat(CHAT_ISSUE); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).toBe("true"); + await clickToggle(); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).not.toBe("true"); + expect(panelText()).toContain("Side panel for PAP-9001"); + await clickToggle(); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).toBe("true"); + }); + + it("opens the drawer with the chat task list before the chat is saved", async () => { + localStorage.setItem("paperclip:panel-visible", "false"); + await renderChat(null); + expect(container.querySelector('button[aria-label="Show properties"]')).not.toBeNull(); + await clickToggle(); + const aside = container.querySelector("aside"); + expect(aside?.getAttribute("aria-hidden")).not.toBe("true"); + expect(panelText()).toContain("Tasks"); + expect(panelText()).toContain("This agent hasn't worked on any tasks yet."); + await clickToggle(); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).toBe("true"); + }); + + it("opens a coordinator chat's drawer on the tasks from that conversation", async () => { + testState.coordinator = true; + testState.issue = CHAT_ISSUE; + await renderChat(CHAT_ISSUE); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).toBe("true"); + await clickToggle(); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).not.toBe("true"); + expect(container.querySelector('section[aria-label="Tasks from this conversation"]')).not.toBeNull(); + expect(panelText()).toContain("Tasks created from this conversation will appear here."); + }); + + it("opens an unsaved coordinator chat's drawer on its empty task list", async () => { + testState.coordinator = true; + await renderChat(null); + await clickToggle(); + expect(container.querySelector("aside")?.getAttribute("aria-hidden")).not.toBe("true"); + expect(panelText()).toContain("Tasks created from this conversation will appear here."); + }); +}); diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index ad89f6bc28f..2b6fe17d465 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -32,6 +32,7 @@ import { AgentIdentity } from "@/components/AgentIdentity"; import { clearLegacyChatMessageRequests } from "@/lib/chat-message-request"; import { isOnboardingWelcomeChoice, OnboardingWelcomeContext, type WelcomeAnimation } from "@/lib/onboarding-chat"; import { agentChatDraft } from "@/lib/agent-chat-draft"; +import { AgentChatDraftTasksPanel } from "@/components/chat/AgentWorkPanels"; import { useOnboardingReplyDisplay } from "@/hooks/useOnboardingReplyDisplay"; import { captureAgentChatMessageSent } from "@/lib/analytics/onboarding-analytics"; import { trackRecentProject } from "@/lib/recent-projects"; @@ -6424,6 +6425,17 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS externalObjectsState.markdownReferences, uploadAttachment.mutateAsync, feedbackVoteMutation.mutateAsync, agentMap, userProfileMap]); useLayoutEffect(() => { + // An unsaved chat has no issue to edit, so its panel lists tasks only. + if (taskInterfaceSettingsLoaded && conversation && !conversation.issue && taskChatShellEnabled && !isMobile) { + openPanel( + , + ); + return () => closePanel(); + } if (!taskInterfaceSettingsLoaded || !panelIssue || suppressPanelUntilPlan || (conversation && !conversation.issue) || (taskChatShellEnabled && isMobile)) { closePanel(); return; @@ -6536,6 +6548,9 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS artifactsOpenRequest, handleArtifactsOpened, isMobile, + conversation?.issue, + conversation?.agent.companyId, + conversation?.agent.id, ]); const goToInboxShortcutArmedRef = useRef(false); From ca2107583786f80800be3a895edaa33e21204b73 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:12:34 -0600 Subject: [PATCH 019/119] test(server): fold tiny purge suites into the agent lifecycle owner suite (#23719) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The agent lifecycle module owns agent purge and company deletion. > - The repository test budget rule asks to add a narrow database case to the owning suite, not to a small standalone file. > - Two small test files each start their own embedded Postgres for a few purge cases only. > - This pull request moves those cases into the agent lifecycle owner suite and deletes the two small files. > - The benefit is two fewer test workers and two fewer database setups in CI, with the same assertions kept. ## Linked Issues or Issue Description No public GitHub issue exists for this change. The problem is described here, using the enhancement template labels. **What existing behavior does this improve?** The layout of the agent lifecycle test suites and their CI setup cost. **Subsystem affected** server/ — REST API & orchestration services (agent lifecycle and company deletion tests). **Current behavior** Two test files each boot an own embedded Postgres for a few purge cases: - `server/src/services/agent-cost-history-deletion.test.ts` (61 lines) covers the `agent_cost_history_retained` purge guard. - `server/src/services/case-deletion.test.ts` (69 lines) covers company deletion with retained case handoffs and the `agent_case_history_retained` purge guard. Each file pays a separate Vitest worker import and a separate embedded database start. The `rules/test-budget.mdc` rule says: do not keep a standalone embedded-Postgres file for one narrow regression case; add the case to the owning service suite. The owner suite `server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts` already imports the same production modules (`createAgentLifecycle`, `deleteCompany`) and uses the same database fixture. **Proposed behavior** The owner suite holds these cases inside two nested describe blocks. The two small files no longer exist. No assertion changed. **Reason and benefit** CI runs two fewer standalone database files in the general server lane. The moved cases reuse the database the owner suite already started. The historical duration manifest recorded about 6 s and 8 s per file at its recorded revision; these weights are scheduling estimates, not measured savings for this change. **Breaking changes** None. Test code only. ## What Changed - Moved 4 purge cost-history cases (cost event by run, cost event by agent, finance event by run, and the positive purge case) into the owner suite under `describe("agent purge with retained cost history")`. - Moved 3 company-deletion-with-case-handoff cases (an `it.each` over three handoff states, an `it.each` over source and target roles, and the unrelated-agent purge case; 6 test registrations in total) into the owner suite under `describe("deletion with retained case handoffs")`. - Deleted `server/src/services/agent-cost-history-deletion.test.ts` and `server/src/services/case-deletion.test.ts`. - Added the `cases`, `caseAccessSources`, `caseHandoffs`, `costEvents`, and `financeEvents` table imports to the owner suite. - Net change: 131 deleted and 102 added test lines. No production line changed. The owner suite is a test file and was already longer than 1,000 lines before this change. Extending the designated owner suite is the remedy the test budget rule names for these files. ## Verification Commands run on this branch (head `01bc9384`), local sandbox, Node v25.9.0: - `cd server && ../../node_modules/.bin/vitest run src/modules/agent-lifecycle/__tests__/lifecycle.test.ts` — 1 file passed, 86 tests passed, all 10 moved registrations included. - Intended-failure control 1: the `agent_cost_history_retained` guard in `server/src/services/agent-deletion.ts` was disabled for a moment. The 3 moved cost-history cases failed on their expected 409 conflict. The positive purge case still passed. The file was then restored with `git checkout` and the diff was checked clean. - Intended-failure control 2: the `agent_case_history_retained` guard was disabled the same way. The 2 moved handoff purge cases failed on their expected 409 conflict. The other matched cases still passed. The file was restored the same way. - `node scripts/check-test-budget.mjs --files server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts` — PASS. - The full owner suite was run again after the restorations: 86 tests passed. Not run locally: the repository typecheck and the full test suite. The runner build dependency for the typecheck did not fit the free disk of this sandbox. The required CI checks passed on the PR head `01bc9384`: 68 checks succeeded (typecheck, build, all 20 general server test shards, chat and workspaces-b shards, runner support, Greptile). Six conditional lanes were skipped as not applicable. Three independent bot reviews scored the change 5/5 with no findings. ## Risks - Low risk. Test files only; no production code changed. - The moved cases now share the database instance the owner suite starts. Each moved case still creates its own rows with fresh identifiers, and the controls above show each case still fails at its own guard. - The general server shard durations manifest still lists the two deleted files. The manifest is regenerated from CI runs by `scripts/ci/refresh-test-durations.mjs`; stale entries do not route work. ## Model Used GLM 5.3 (z-ai/glm-5.3; exact model ID `openrouter/z-ai/glm-5.3`), run by the Paperclip Test Gardener agent, with tool use and code execution. No extended thinking mode. ## 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 --- .../__tests__/lifecycle.test.ts | 103 +++++++++++++++++- .../agent-cost-history-deletion.test.ts | 61 ----------- server/src/services/case-deletion.test.ts | 69 ------------ 3 files changed, 102 insertions(+), 131 deletions(-) delete mode 100644 server/src/services/agent-cost-history-deletion.test.ts delete mode 100644 server/src/services/case-deletion.test.ts diff --git a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts index c03a63a7421..82ca28eaa79 100644 --- a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts @@ -19,7 +19,7 @@ import { errorHandler } from "../../../middleware/error-handler.js"; import { createLifecycleDriver } from "../../../services/agent-lifecycle-driver.js"; import { randomUUID } from "node:crypto"; import { and, eq, sql } from "drizzle-orm"; -import { agents, approvals, projects, issues, heartbeatRuns, nativeRunFinalizations, budgetPolicies, environmentLeases, environments, agentApiKeys, activityLog, agentConfigRevisions, userCompanyPreferences, companies, companyMemberships, principalPermissionGrants, plugins, pluginCompanySettings, applyPendingMigrations, closeRegisteredClients, createDb, type Db } from "@paperclipai/db"; +import { agents, approvals, caseAccessSources, caseHandoffs, cases, costEvents, financeEvents, projects, issues, heartbeatRuns, nativeRunFinalizations, budgetPolicies, environmentLeases, environments, agentApiKeys, activityLog, agentConfigRevisions, userCompanyPreferences, companies, companyMemberships, principalPermissionGrants, plugins, pluginCompanySettings, applyPendingMigrations, closeRegisteredClients, createDb, type Db } from "@paperclipai/db"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { getEmbeddedPostgresTestSupport, startEmbeddedPostgresTestDatabase } from "../../../__tests__/helpers/embedded-postgres.js"; import { createAgentLifecycle, configureAgentLifecycle, startAgentLifecycle } from "../../../services/agent-lifecycle.js"; @@ -615,6 +615,107 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu expect(await db.select().from(agentApiKeys).where(eq(agentApiKeys.id, key.id))).toHaveLength(1); }); + describe("agent purge with retained cost history", () => { + async function costFixture() { + const companyId = randomUUID(), agentId = randomUUID(); + await db.insert(companies).values({ id: companyId, name: "Cost deletion", issuePrefix: `C${companyId.slice(0, 6)}` }); + await db.insert(agents).values({ id: agentId, companyId, name: "Billed worker", status: "terminated", lifecycleState: "terminated" }); + const [run] = await db.insert(heartbeatRuns).values({ companyId, agentId, status: "succeeded" }).returning(); + return { companyId, agentId, run: run! }; + } + const cost = (companyId: string, values: Partial) => db.insert(costEvents).values({ + companyId, usageKind: "decision", provider: "anthropic", model: "claude", costCents: 1, occurredAt: new Date(), ...values, + }).returning(); + + async function expectRetained(f: Awaited>) { + await expect(createAgentLifecycle(db).purgeAgent(f.agentId)).rejects.toMatchObject({ status: 409, + details: { code: "agent_cost_history_retained" } }); + expect(await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, f.run.id))).toHaveLength(1); + expect(await db.select().from(agents).where(eq(agents.id, f.agentId))).toMatchObject([{ lifecycleState: "terminated" }]); + } + + it("refuses before cleanup when a cost event references one of the agent's runs", async () => { + const f = await costFixture(); + const [event] = await cost(f.companyId, { heartbeatRunId: f.run.id }); + await expectRetained(f); + expect(await db.select().from(costEvents).where(eq(costEvents.id, event!.id))).toEqual([event]); + }); + + it("refuses when a cost event is attributed to the agent", async () => { + const f = await costFixture(); + await cost(f.companyId, { usageKind: "agent", agentId: f.agentId }); + await expectRetained(f); + }); + + it("refuses when a finance event references one of the agent's runs", async () => { + const f = await costFixture(); + const [event] = await db.insert(financeEvents).values({ companyId: f.companyId, heartbeatRunId: f.run.id, + eventKind: "usage", biller: "anthropic", amountCents: 1, occurredAt: new Date() }).returning(); + await expectRetained(f); + expect(await db.select().from(financeEvents).where(eq(financeEvents.id, event!.id))).toEqual([event]); + }); + + it("still purges an agent whose runs have no cost history", async () => { + const f = await costFixture(); + expect(await createAgentLifecycle(db).purgeAgent(f.agentId)).toMatchObject({ id: f.agentId }); + expect(await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, f.run.id))).toHaveLength(0); + }); + }); + + describe("deletion with retained case handoffs", () => { + async function caseFixture(state: "delivered" | "cancelled" | "pending_dispatch" = "delivered") { + const companyId = randomUUID(), sourceId = randomUUID(), targetId = randomUUID(); + await db.insert(companies).values({ id: companyId, name: "Case deletion", issuePrefix: `D${companyId.slice(0, 6)}` }); + await db.insert(agents).values([sourceId, targetId].map(id => ({ id, companyId, + name: "Retained worker", status: "terminated", lifecycleState: "terminated" as const }))); + const [issue] = await db.insert(issues).values({ companyId, title: "Workflow task", status: "todo", + assigneeAgentId: targetId }).returning(); + const [record] = await db.insert(cases).values({ companyId, caseNumber: 1, identifier: `D${companyId}-C1`, + caseType: "deletion", title: "Workflow record", workIssueId: issue!.id }).returning(); + await db.insert(caseAccessSources).values({ companyId, caseId: record!.id, sourceKind: "issue", sourceId: issue!.id }); + const [handoff] = await db.insert(caseHandoffs).values({ companyId, caseId: record!.id, issueId: issue!.id, + version: 1, fromAgentId: sourceId, toAgentId: targetId, phase: "verification", instructions: "Retain this history", + actorType: "user", actorId: "board", wakeupRequestId: randomUUID(), idempotencyKey: randomUUID(), + inputFingerprint: "fixture", state }).returning(); + return { companyId, sourceId, targetId, issue: issue!, record: record!, handoff: handoff! }; + } + + it.each(["delivered", "cancelled", "pending_dispatch"] as const)("deletes the whole company with a %s handoff", async state => { + const f = await caseFixture(state), other = await caseFixture(); + + expect(await deleteCompany(db, f.companyId)).toMatchObject({ id: f.companyId }); + + expect(await db.select().from(companies).where(eq(companies.id, f.companyId))).toHaveLength(0); + expect(await db.select().from(cases).where(eq(cases.id, f.record.id))).toHaveLength(0); + expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toHaveLength(0); + expect(await db.select().from(caseAccessSources).where(eq(caseAccessSources.caseId, f.record.id))).toHaveLength(0); + expect(await db.select().from(issues).where(eq(issues.id, f.issue.id))).toHaveLength(0); + expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, other.handoff.id))).toEqual([other.handoff]); + }); + + it.each(["sourceId", "targetId"] as const)("preserves history and explains why its %s cannot be purged", async role => { + const f = await caseFixture(); + + await expect(createAgentLifecycle(db).purgeAgent(f[role])).rejects.toMatchObject({ status: 409, + details: { code: "agent_case_history_retained" } }); + + expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toEqual([f.handoff]); + expect(await db.select().from(issues).where(eq(issues.id, f.issue.id))).toEqual([f.issue]); + expect(await db.select().from(agents).where(eq(agents.id, f[role]))).toMatchObject([{ lifecycleState: "terminated" }]); + }); + + it("still purges an unrelated terminated agent without deleting case history", async () => { + const f = await caseFixture(); + const [unrelated] = await db.insert(agents).values({ companyId: f.companyId, name: "Unrelated worker", + status: "terminated", lifecycleState: "terminated" }).returning(); + + expect(await createAgentLifecycle(db).purgeAgent(unrelated!.id)).toMatchObject({ id: unrelated!.id }); + + expect(await db.select().from(agents).where(eq(agents.id, unrelated!.id))).toHaveLength(0); + expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toEqual([f.handoff]); + }); + }); + it("deletes terminated and rejected agents only in the requested company", async () => { await db.insert(agents).values((["terminated", "rejected"] as const).map(lifecycleState => ({ companyId, name: lifecycleState, status: "terminated", lifecycleState, diff --git a/server/src/services/agent-cost-history-deletion.test.ts b/server/src/services/agent-cost-history-deletion.test.ts deleted file mode 100644 index 923298a48f6..00000000000 --- a/server/src/services/agent-cost-history-deletion.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { randomUUID } from "node:crypto"; -import { eq } from "drizzle-orm"; -import { agents, companies, costEvents, createDb, financeEvents, heartbeatRuns } from "@paperclipai/db"; -import { afterAll, beforeAll, describe, expect, it } from "vitest"; -import { startEmbeddedPostgresTestDatabase } from "../__tests__/helpers/embedded-postgres.js"; -import { createAgentLifecycle } from "./agent-lifecycle.js"; - -describe("agent purge with retained cost history", () => { - let temporary: Awaited>; - let db: ReturnType; - beforeAll(async () => { - temporary = await startEmbeddedPostgresTestDatabase("agent-cost-deletion-"); - db = createDb(temporary.connectionString); - }); - afterAll(async () => { await temporary?.cleanup(); }); - - async function fixture() { - const companyId = randomUUID(), agentId = randomUUID(); - await db.insert(companies).values({ id: companyId, name: "Cost deletion", issuePrefix: `C${companyId.slice(0, 6)}` }); - await db.insert(agents).values({ id: agentId, companyId, name: "Billed worker", status: "terminated", lifecycleState: "terminated" }); - const [run] = await db.insert(heartbeatRuns).values({ companyId, agentId, status: "succeeded" }).returning(); - return { companyId, agentId, run: run! }; - } - const cost = (companyId: string, values: Partial) => db.insert(costEvents).values({ - companyId, usageKind: "decision", provider: "anthropic", model: "claude", costCents: 1, occurredAt: new Date(), ...values, - }).returning(); - - async function expectRetained(f: Awaited>) { - await expect(createAgentLifecycle(db).purgeAgent(f.agentId)).rejects.toMatchObject({ status: 409, - details: { code: "agent_cost_history_retained" } }); - expect(await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, f.run.id))).toHaveLength(1); - expect(await db.select().from(agents).where(eq(agents.id, f.agentId))).toMatchObject([{ lifecycleState: "terminated" }]); - } - - it("refuses before cleanup when a cost event references one of the agent's runs", async () => { - const f = await fixture(); - const [event] = await cost(f.companyId, { heartbeatRunId: f.run.id }); - await expectRetained(f); - expect(await db.select().from(costEvents).where(eq(costEvents.id, event!.id))).toEqual([event]); - }); - - it("refuses when a cost event is attributed to the agent", async () => { - const f = await fixture(); - await cost(f.companyId, { usageKind: "agent", agentId: f.agentId }); - await expectRetained(f); - }); - - it("refuses when a finance event references one of the agent's runs", async () => { - const f = await fixture(); - const [event] = await db.insert(financeEvents).values({ companyId: f.companyId, heartbeatRunId: f.run.id, - eventKind: "usage", biller: "anthropic", amountCents: 1, occurredAt: new Date() }).returning(); - await expectRetained(f); - expect(await db.select().from(financeEvents).where(eq(financeEvents.id, event!.id))).toEqual([event]); - }); - - it("still purges an agent whose runs have no cost history", async () => { - const f = await fixture(); - expect(await createAgentLifecycle(db).purgeAgent(f.agentId)).toMatchObject({ id: f.agentId }); - expect(await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, f.run.id))).toHaveLength(0); - }); -}); diff --git a/server/src/services/case-deletion.test.ts b/server/src/services/case-deletion.test.ts deleted file mode 100644 index b6ca415e4f6..00000000000 --- a/server/src/services/case-deletion.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { randomUUID } from "node:crypto"; -import { eq } from "drizzle-orm"; -import { agents, caseAccessSources, caseHandoffs, cases, companies, createDb, issues } from "@paperclipai/db"; -import { afterAll, beforeAll, describe, expect, it } from "vitest"; -import { startEmbeddedPostgresTestDatabase } from "../__tests__/helpers/embedded-postgres.js"; -import { createAgentLifecycle } from "./agent-lifecycle.js"; -import { deleteCompany } from "./company-deletion.js"; - -describe("deletion with retained case handoffs", () => { - let temporary: Awaited>; - let db: ReturnType; - beforeAll(async () => { - temporary = await startEmbeddedPostgresTestDatabase("case-deletion-"); - db = createDb(temporary.connectionString); - }); - afterAll(async () => { await temporary?.cleanup(); }); - - async function fixture(state: "delivered" | "cancelled" | "pending_dispatch" = "delivered") { - const companyId = randomUUID(), sourceId = randomUUID(), targetId = randomUUID(); - await db.insert(companies).values({ id: companyId, name: "Case deletion", issuePrefix: `D${companyId.slice(0, 6)}` }); - await db.insert(agents).values([sourceId, targetId].map(id => ({ id, companyId, - name: "Retained worker", status: "terminated", lifecycleState: "terminated" as const }))); - const [issue] = await db.insert(issues).values({ companyId, title: "Workflow task", status: "todo", - assigneeAgentId: targetId }).returning(); - const [record] = await db.insert(cases).values({ companyId, caseNumber: 1, identifier: `D${companyId}-C1`, - caseType: "deletion", title: "Workflow record", workIssueId: issue!.id }).returning(); - await db.insert(caseAccessSources).values({ companyId, caseId: record!.id, sourceKind: "issue", sourceId: issue!.id }); - const [handoff] = await db.insert(caseHandoffs).values({ companyId, caseId: record!.id, issueId: issue!.id, - version: 1, fromAgentId: sourceId, toAgentId: targetId, phase: "verification", instructions: "Retain this history", - actorType: "user", actorId: "board", wakeupRequestId: randomUUID(), idempotencyKey: randomUUID(), - inputFingerprint: "fixture", state }).returning(); - return { companyId, sourceId, targetId, issue: issue!, record: record!, handoff: handoff! }; - } - - it.each(["delivered", "cancelled", "pending_dispatch"] as const)("deletes the whole company with a %s handoff", async state => { - const f = await fixture(state), other = await fixture(); - - expect(await deleteCompany(db, f.companyId)).toMatchObject({ id: f.companyId }); - - expect(await db.select().from(companies).where(eq(companies.id, f.companyId))).toHaveLength(0); - expect(await db.select().from(cases).where(eq(cases.id, f.record.id))).toHaveLength(0); - expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toHaveLength(0); - expect(await db.select().from(caseAccessSources).where(eq(caseAccessSources.caseId, f.record.id))).toHaveLength(0); - expect(await db.select().from(issues).where(eq(issues.id, f.issue.id))).toHaveLength(0); - expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, other.handoff.id))).toEqual([other.handoff]); - }); - - it.each(["sourceId", "targetId"] as const)("preserves history and explains why its %s cannot be purged", async role => { - const f = await fixture(); - - await expect(createAgentLifecycle(db).purgeAgent(f[role])).rejects.toMatchObject({ status: 409, - details: { code: "agent_case_history_retained" } }); - - expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toEqual([f.handoff]); - expect(await db.select().from(issues).where(eq(issues.id, f.issue.id))).toEqual([f.issue]); - expect(await db.select().from(agents).where(eq(agents.id, f[role]))).toMatchObject([{ lifecycleState: "terminated" }]); - }); - - it("still purges an unrelated terminated agent without deleting case history", async () => { - const f = await fixture(); - const [unrelated] = await db.insert(agents).values({ companyId: f.companyId, name: "Unrelated worker", - status: "terminated", lifecycleState: "terminated" }).returning(); - - expect(await createAgentLifecycle(db).purgeAgent(unrelated!.id)).toMatchObject({ id: unrelated!.id }); - - expect(await db.select().from(agents).where(eq(agents.id, unrelated!.id))).toHaveLength(0); - expect(await db.select().from(caseHandoffs).where(eq(caseHandoffs.id, f.handoff.id))).toEqual([f.handoff]); - }); -}); From c5a705ce9282fdbc99244ff7c0b68aca3f82a9ed Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Fri, 4 Dec 2026 09:45:38 -0600 Subject: [PATCH 020/119] fix(trust): enforce low-trust sourceTrust quarantine on native comments and documents (#23621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The low-trust review preset isolates untrusted agent runs and marks their raw outputs with `sourceTrust` quarantine metadata so higher-trust agents do not ingest raw output without promotion > - HTTP route writes tagged low-trust comments and documents with `sourceTrust`, but internal native completion replies, finalizer recoveries, continuation summary updates, and non-Muse native runner tool writes (`report_progress`, `write_document`) persisted `sourceTrust: null` > - Higher-trust non-Muse native runner reads (`list_documents`, `read_document`) also bypassed document quarantine redaction > - This pull request resolves `sourceTrust` centrally in `issueService.addComment` and `documentService.upsertIssueDocument` whenever an agent writes without an explicit `sourceTrust` value, removes the `museRuntime` gate on native runner `report_progress` and `write_document` writes, and redacts quarantined documents on higher-trust non-Muse native runner reads > - The benefit is that raw outputs from low-trust native runs retain quarantine metadata across all comment and document write paths and stay redacted from higher-trust agents until promoted ## Linked Issues or Issue Description **What happened?** When an agent running under the `low_trust_review` preset completed a native run or called native runner tools (`report_progress`, `write_document`), its comments and documents were saved with `sourceTrust: null`. Because `sourceTrust` was null, higher-trust agents could read the raw low-trust output directly through ordinary comment and document access without promotion. **Expected behavior** All agent-authored comments and documents produced under `low_trust_review`—including native run completion replies, recovered finalizer replies, continuation summary updates, and non-Muse native runner `report_progress` / `write_document` writes—must persist `sourceTrust` with `preset: "low_trust_review"` and `disposition: "quarantined"`, and higher-trust agents must receive the quarantined redaction placeholder instead of the raw body. **Steps to reproduce** 1. Configure an agent with `trustPreset: "low_trust_review"` and a valid `trustBoundary`. 2. Run a native task on that agent so it writes a completion reply, calls `report_progress` or `write_document`, or refreshes `continuation-summary`. 3. Read the resulting comment or document as a standard-trust agent via `get_task_history`, `list_documents`, `read_document`, or ordinary comment reads. 4. Before this fix, `sourceTrust` is `null` and the raw body is returned unredacted. **Paperclip version or commit** `master` (`ce204a223a`) ## What Changed - **`server/src/services/issues.ts`**: Updated `issueService.addComment` to select `projectId` and `executionPolicy` on the target issue and resolve `sourceTrust` via `resolveActorSourceTrustForIssue` whenever `actor.agentId` is set and `options?.sourceTrust === undefined`. This covers native run completion replies (`run-completion.ts`), recovered finalizer replies (`native-run-finalizer.ts`), status decision committer comments (`status-decision-committer.ts`), and internal agent comment writes. - **`server/src/services/documents.ts`**: Updated `documentService.upsertIssueDocument` to select `projectId` and `executionPolicy` on the target issue and resolve `sourceTrust` via `resolveActorSourceTrustForIssue` whenever `input.createdByAgentId` is set and `input.sourceTrust === undefined`. This covers continuation summary refreshes (`issue-continuation-summary.ts`), native plan writes (`native-session-executor.ts`), and internal agent document writes. - **`server/src/services/native-runtime/paperclip-runner-tool-authority.ts`**: Removed the `this.binding.museRuntime` guard on `resolveActorSourceTrustForIssue` in `report_progress` and `write_document` so all `paperclip_runner` runs tag writes consistently, and added higher-trust quarantine redaction (`redactQuarantinedBodyForHigherTrust`) for non-Muse `list_documents` and `read_document` reads. - **`server/src/__tests__/source-trust.test.ts`**: Added red-green regression tests covering `addComment` without explicit `sourceTrust`, `upsertIssueDocument` without explicit `sourceTrust`, and non-Muse `PaperclipRunnerToolAuthority` `report_progress` / `write_document` writes read by a higher-trust agent via `get_task_history`, `list_documents`, and `read_document`. ## Verification - Confirmed the new regression tests failed before the fix (`sourceTrust` received `null` on `addComment` and `upsertIssueDocument`). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/source-trust.test.ts` — 10/10 passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/low-trust-red-team-routes.test.ts` — 14/14 passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-continuation-summary.test.ts` — 8/8 passed. - `pnpm --filter @paperclipai/server typecheck` — passed with 0 errors. - `pnpm verify` exited 2 (broad CI coverage required); CI will run the full required check matrix on this PR. ## Risks - Low risk. Standard-trust agent writes continue to resolve to `sourceTrust: null` (unchanged behavior). - Callers that already pass an explicit `sourceTrust` value (such as promotion flows or HTTP routes) keep their explicit value without extra work. - Only newly inserted comments and agent-authored document upserts without an explicit `sourceTrust` perform the policy lookup inside the existing transaction. ## Model Used - Google Gemini (Antigravity agentic coding assistant) with tool use and local code/test execution. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --- server/src/__tests__/source-trust.test.ts | 568 +++++++++++++++++- server/src/services/document-source-trust.ts | 136 +++++ server/src/services/documents.ts | 82 ++- server/src/services/issues.ts | 37 +- .../paperclip-runner-tool-authority.ts | 173 ++++-- server/src/services/source-trust.ts | 64 +- 6 files changed, 968 insertions(+), 92 deletions(-) create mode 100644 server/src/services/document-source-trust.ts diff --git a/server/src/__tests__/source-trust.test.ts b/server/src/__tests__/source-trust.test.ts index 37118bce08a..d80814ee939 100644 --- a/server/src/__tests__/source-trust.test.ts +++ b/server/src/__tests__/source-trust.test.ts @@ -1,12 +1,27 @@ import { randomUUID } from "node:crypto"; import { eq } from "drizzle-orm"; import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; -import { agents, companies, createDb, heartbeatRuns, issues } from "@paperclipai/db"; +import { + activityLog, + agents, + companies, + createDb, + documents, + heartbeatRunEvents, + heartbeatRuns, + issueComments, + issues, + projects, +} from "@paperclipai/db"; import { LOW_TRUST_REVIEW_PRESET } from "@paperclipai/shared"; +import { documentService } from "../services/documents.js"; +import { issueService } from "../services/issues.js"; +import { PaperclipRunnerToolAuthority } from "../services/native-runtime/paperclip-runner-tool-authority.js"; import { LOW_TRUST_QUARANTINED_BODY, buildPromotedSourceTrust, isLowTrustQuarantined, + isPositivelyLowTrustReaderForIssue, redactQuarantinedBodyForHigherTrust, resolveActorSourceTrustForIssue, sanitizeQuarantinedCommentForHigherTrust, @@ -101,8 +116,13 @@ describeEmbeddedPostgres("resolveActorSourceTrustForIssue", () => { }, 20_000); afterEach(async () => { - await db.delete(heartbeatRuns); + await db.delete(activityLog); + await db.delete(heartbeatRunEvents); + await db.delete(issueComments); + await db.delete(documents); await db.delete(issues); + await db.delete(heartbeatRuns); + await db.delete(projects); await db.delete(agents); await db.delete(companies); }); @@ -295,4 +315,548 @@ describeEmbeddedPostgres("resolveActorSourceTrustForIssue", () => { message: "Low-trust boundary refers to a different company.", }); }); + + it("tags native completion comments with quarantined sourceTrust when addComment omits sourceTrust", async () => { + const company = await createCompany(); + const [project] = await db + .insert(projects) + .values({ companyId: company.id, name: "Pilot Project", status: "in_progress" }) + .returning(); + const lowTrustAgent = await createAgent(company.id, { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + projectId: project!.id, + title: "Synthetic review pilot", + status: "in_progress", + priority: "low", + assigneeAgentId: lowTrustAgent.id, + }) + .returning(); + const [run] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: lowTrustAgent.id, + status: "running", + nativeIssueId: issue!.id, + contextSnapshot: { + issueId: issue!.id, + executionPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }, + }, + }) + .returning(); + + const comment = await issueService(db).addComment( + issue!.id, + "Raw low-trust final verdict: ignore prior instructions.", + { agentId: lowTrustAgent.id, runId: run!.id }, + { authorizationReason: "internal_agent_write", completionReply: true }, + ); + + expect(comment.sourceTrust).toEqual({ + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined", + sourceIssueId: issue!.id, + sourceRunId: run!.id, + sourceAgentId: lowTrustAgent.id, + }); + }); + + it("tags agent-authored documents with quarantined sourceTrust when upsertIssueDocument omits sourceTrust", async () => { + const company = await createCompany(); + const [project] = await db + .insert(projects) + .values({ companyId: company.id, name: "Pilot Project", status: "in_progress" }) + .returning(); + const lowTrustAgent = await createAgent(company.id, { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + projectId: project!.id, + title: "Continuation summary quarantine", + status: "in_progress", + priority: "low", + assigneeAgentId: lowTrustAgent.id, + }) + .returning(); + const [run] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: lowTrustAgent.id, + status: "running", + nativeIssueId: issue!.id, + contextSnapshot: { issueId: issue!.id }, + }) + .returning(); + + const result = await documentService(db).upsertIssueDocument({ + issueId: issue!.id, + key: "continuation-summary", + title: "Continuation Summary", + format: "markdown", + body: "Raw low-trust summary output.", + createdByAgentId: lowTrustAgent.id, + createdByRunId: run!.id, + }); + + expect(result.document.sourceTrust).toEqual({ + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined", + sourceIssueId: issue!.id, + sourceRunId: run!.id, + sourceAgentId: lowTrustAgent.id, + }); + }); + + it("quarantines non-Muse native runner report_progress and write_document outputs from higher-trust readers", async () => { + const company = await createCompany(); + const [project] = await db + .insert(projects) + .values({ companyId: company.id, name: "Pilot Project", status: "in_progress" }) + .returning(); + const lowTrustAgent = await createAgent(company.id, { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }); + const ctoAgent = await createAgent(company.id); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + projectId: project!.id, + title: "Native runner quarantine", + status: "in_progress", + priority: "low", + assigneeAgentId: lowTrustAgent.id, + }) + .returning(); + const [lowTrustRun] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: lowTrustAgent.id, + runtimeMode: "native", + status: "running", + nativeIssueId: issue!.id, + contextSnapshot: { issueId: issue!.id }, + }) + .returning(); + await db + .update(issues) + .set({ executionRunId: lowTrustRun!.id }) + .where(eq(issues.id, issue!.id)); + const [ctoRun] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: ctoAgent.id, + runtimeMode: "native", + status: "running", + nativeIssueId: issue!.id, + contextSnapshot: { issueId: issue!.id }, + }) + .returning(); + + const lowTrustAuthority = new PaperclipRunnerToolAuthority(db, { + companyId: company.id, + agentId: lowTrustAgent.id, + issueId: issue!.id, + runId: lowTrustRun!.id, + assertBridgeAuthority: async () => {}, + }); + + await lowTrustAuthority.execute({ + callId: "call-progress-1", + tool: "report_progress", + arguments: { + body: "RAW_LOW_TRUST_MARKER_COMMENT", + idempotencyKey: `progress-${randomUUID()}`, + }, + }); + await lowTrustAuthority.execute({ + callId: "call-doc-1", + tool: "write_document", + arguments: { + key: "pilot-report", + title: "Pilot Report", + body: "RAW_LOW_TRUST_MARKER_DOC", + idempotencyKey: `doc-${randomUUID()}`, + }, + }); + + await db + .update(issues) + .set({ assigneeAgentId: ctoAgent.id, executionRunId: ctoRun!.id }) + .where(eq(issues.id, issue!.id)); + + const ctoAuthority = new PaperclipRunnerToolAuthority(db, { + companyId: company.id, + agentId: ctoAgent.id, + issueId: issue!.id, + runId: ctoRun!.id, + assertBridgeAuthority: async () => {}, + }); + + const history = (await ctoAuthority.execute({ + callId: "call-history-1", + tool: "get_task_history", + arguments: {}, + })) as { comments: Array<{ body: string; sourceTrust: unknown }> }; + expect(history.comments).toHaveLength(1); + expect(history.comments[0]!.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(history.comments[0]!.body).not.toContain("RAW_LOW_TRUST_MARKER_COMMENT"); + expect(history.comments[0]!.sourceTrust).toMatchObject({ + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined", + }); + + const listed = (await ctoAuthority.execute({ + callId: "call-list-docs-1", + tool: "list_documents", + arguments: {}, + })) as { documents: Array<{ key: string; title: string | null; body: string; sourceTrust: unknown }> }; + const pilotEntry = listed.documents.find((doc) => doc.key === "pilot-report"); + expect(pilotEntry?.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(pilotEntry?.body).not.toContain("RAW_LOW_TRUST_MARKER_DOC"); + expect(pilotEntry?.title).toBeNull(); + + const readDoc = (await ctoAuthority.execute({ + callId: "call-read-doc-1", + tool: "read_document", + arguments: { key: "pilot-report" }, + })) as { document: { title: string | null; body: string; sourceTrust: unknown; latestRevisionId: string } }; + expect(readDoc.document.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(readDoc.document.body).not.toContain("RAW_LOW_TRUST_MARKER_DOC"); + expect(readDoc.document.title).toBeNull(); + + // Current quarantined revision must be redacted in list_document_revisions (body, title, changeSummary). + const initialRevisions = (await ctoAuthority.execute({ + callId: "call-list-revisions-1", + tool: "list_document_revisions", + arguments: { key: "pilot-report" }, + })) as { revisions: Array<{ revisionNumber: number; body: string; title: string | null; changeSummary: string | null }> }; + expect(initialRevisions.revisions).toHaveLength(1); + expect(initialRevisions.revisions[0]!.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(initialRevisions.revisions[0]!.body).not.toContain("RAW_LOW_TRUST_MARKER_DOC"); + expect(initialRevisions.revisions[0]!.title).toBeNull(); + expect(initialRevisions.revisions[0]!.changeSummary).toBeNull(); + + // After a higher-trust agent overwrites the document with revision 2, revision 1 (historical low-trust) + // must remain redacted while revision 2 is visible. + await ctoAuthority.execute({ + callId: "call-doc-cto-2", + tool: "write_document", + arguments: { + key: "pilot-report", + title: "CTO Sanitized Report", + body: "TRUSTED_CTO_REVISION_2", + changeSummary: "Sanitized summary", + baseRevisionId: readDoc.document.latestRevisionId, + idempotencyKey: `doc-cto-${randomUUID()}`, + }, + }); + const revisionsAfterUpdate = (await ctoAuthority.execute({ + callId: "call-list-revisions-2", + tool: "list_document_revisions", + arguments: { key: "pilot-report" }, + })) as { revisions: Array<{ revisionNumber: number; body: string; title: string | null; changeSummary: string | null }> }; + expect(revisionsAfterUpdate.revisions).toHaveLength(2); + const rev2 = revisionsAfterUpdate.revisions.find((r) => r.revisionNumber === 2); + const rev1 = revisionsAfterUpdate.revisions.find((r) => r.revisionNumber === 1); + expect(rev2?.body).toBe("TRUSTED_CTO_REVISION_2"); + expect(rev1?.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(rev1?.body).not.toContain("RAW_LOW_TRUST_MARKER_DOC"); + expect(rev1?.title).toBeNull(); + expect(rev1?.changeSummary).toBeNull(); + + // Restoring the low-trust revision 1 into the trusted document must preserve quarantine + // regardless of whether a user or standard-trust agent restores it, including in revision history + // after a later standard-trust update. + const userRestored = await documentService(db).restoreIssueDocumentRevision({ + issueId: issue!.id, + key: "pilot-report", + revisionId: readDoc.document.latestRevisionId, + createdByUserId: "board-user", + }); + expect(userRestored.document.sourceTrust).toMatchObject({ + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined", + sourceIssueId: issue!.id, + }); + + await ctoAuthority.execute({ + callId: "call-doc-cto-4", + tool: "write_document", + arguments: { + key: "pilot-report", + title: "CTO Sanitized Report v4", + body: "TRUSTED_CTO_REVISION_4", + baseRevisionId: userRestored.document.latestRevisionId, + idempotencyKey: `doc-cto-4-${randomUUID()}`, + }, + }); + const revisionsAfterRestoreAndUpdate = (await ctoAuthority.execute({ + callId: "call-list-revisions-3", + tool: "list_document_revisions", + arguments: { key: "pilot-report" }, + })) as { revisions: Array<{ revisionNumber: number; body: string; title: string | null; changeSummary: string | null }> }; + const rev4 = revisionsAfterRestoreAndUpdate.revisions.find((r) => r.revisionNumber === 4); + const rev3 = revisionsAfterRestoreAndUpdate.revisions.find((r) => r.revisionNumber === 3); + expect(rev4?.body).toBe("TRUSTED_CTO_REVISION_4"); + expect(rev3?.body).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(rev3?.body).not.toContain("RAW_LOW_TRUST_MARKER_DOC"); + expect(rev3?.title).toBeNull(); + expect(rev3?.changeSummary).toBeNull(); + + // Accepted plan markdown in get_task_context must also be redacted when authored by a low-trust agent. + await db + .update(issues) + .set({ assigneeAgentId: lowTrustAgent.id, executionRunId: lowTrustRun!.id }) + .where(eq(issues.id, issue!.id)); + const planWrite = (await lowTrustAuthority.execute({ + callId: "call-plan-1", + tool: "write_document", + arguments: { + key: "plan", + title: "Low-Trust Plan", + body: "RAW_LOW_TRUST_PLAN_MARKDOWN", + idempotencyKey: `plan-${randomUUID()}`, + }, + })) as { document: { latestRevisionId: string } }; + await db + .update(heartbeatRuns) + .set({ + contextSnapshot: { + issueId: issue!.id, + planReviewInteraction: { + acceptedTargetRevision: { revisionId: planWrite.document.latestRevisionId }, + }, + }, + }) + .where(eq(heartbeatRuns.id, ctoRun!.id)); + await db + .update(issues) + .set({ assigneeAgentId: ctoAgent.id, executionRunId: ctoRun!.id }) + .where(eq(issues.id, issue!.id)); + + const taskContext = (await ctoAuthority.execute({ + callId: "call-context-1", + tool: "get_task_context", + arguments: {}, + })) as { acceptedPlan: { markdown: string } | null }; + expect(taskContext.acceptedPlan?.markdown).toBe(LOW_TRUST_QUARANTINED_BODY); + expect(taskContext.acceptedPlan?.markdown).not.toContain("RAW_LOW_TRUST_PLAN_MARKDOWN"); + }); + + it("does not treat an unknown or agent-mismatched reader run as a positively established low-trust reader", async () => { + const company = await createCompany(); + const actorAgent = await createAgent(company.id); + const otherAgent = await createAgent(company.id); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + title: "Unverified reader run", + status: "in_progress", + priority: "high", + assigneeAgentId: actorAgent.id, + }) + .returning(); + const [otherRun] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: otherAgent.id, + status: "running", + contextSnapshot: { issueId: issue!.id }, + }) + .returning(); + + const unknownRunResult = await isPositivelyLowTrustReaderForIssue({ + db, + issue: { id: issue!.id, companyId: company.id, projectId: null, executionPolicy: null }, + actor: { actorType: "agent", actorId: actorAgent.id, agentId: actorAgent.id, runId: randomUUID() }, + }); + expect(unknownRunResult).toBe(false); + + const mismatchedRunResult = await isPositivelyLowTrustReaderForIssue({ + db, + issue: { id: issue!.id, companyId: company.id, projectId: null, executionPolicy: null }, + actor: { actorType: "agent", actorId: actorAgent.id, agentId: actorAgent.id, runId: otherRun!.id }, + }); + expect(mismatchedRunResult).toBe(false); + }); + + it("normalizes stale createdByRunId on standard-trust document upserts without false quarantine", async () => { + const company = await createCompany(); + const standardAgent = await createAgent(company.id); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + title: "Stale run id document write", + status: "in_progress", + priority: "medium", + assigneeAgentId: standardAgent.id, + }) + .returning(); + + const result = await documentService(db).upsertIssueDocument({ + issueId: issue!.id, + key: "notes", + title: "Standard Notes", + format: "markdown", + body: "Standard-trust document body.", + createdByAgentId: standardAgent.id, + createdByRunId: randomUUID(), + }); + + expect(result.document.sourceTrust).toBeNull(); + }); + + it("allows a user to restore an agent-written revision even after the original author's trust boundary changes", async () => { + const company = await createCompany(); + const [project] = await db + .insert(projects) + .values({ companyId: company.id, name: "Restore Policy Project", status: "in_progress" }) + .returning(); + const agent = await createAgent(company.id, { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }); + const [issue] = await db + .insert(issues) + .values({ + companyId: company.id, + projectId: project!.id, + title: "Restore after boundary change", + status: "in_progress", + priority: "medium", + assigneeAgentId: agent.id, + }) + .returning(); + const [run] = await db + .insert(heartbeatRuns) + .values({ + companyId: company.id, + agentId: agent.id, + status: "running", + nativeIssueId: issue!.id, + contextSnapshot: { + issueId: issue!.id, + executionPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: company.id, + projectIds: [project!.id], + }, + }, + }, + }, + }) + .returning(); + + const rev1 = await documentService(db).upsertIssueDocument({ + issueId: issue!.id, + key: "report", + title: "Initial Report", + format: "markdown", + body: "Original low-trust body", + createdByAgentId: agent.id, + createdByRunId: run!.id, + }); + await documentService(db).upsertIssueDocument({ + issueId: issue!.id, + key: "report", + title: "Updated Report", + format: "markdown", + body: "User sanitized body", + baseRevisionId: rev1.document.latestRevisionId, + createdByUserId: "board-user", + }); + + // Mutate the original author's trust boundary so it conflicts with the saved run policy. + await db + .update(agents) + .set({ + permissions: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + authorizationPolicy: { + trustPreset: LOW_TRUST_REVIEW_PRESET, + trustBoundary: { + mode: LOW_TRUST_REVIEW_PRESET, + companyId: randomUUID(), + projectIds: [randomUUID()], + }, + }, + }, + }) + .where(eq(agents.id, agent.id)); + + const restored = await documentService(db).restoreIssueDocumentRevision({ + issueId: issue!.id, + key: "report", + revisionId: rev1.document.latestRevisionId, + createdByUserId: "board-user", + }); + + expect(restored.document.body).toBe("Original low-trust body"); + expect(restored.document.sourceTrust).toMatchObject({ + preset: LOW_TRUST_REVIEW_PRESET, + disposition: "quarantined", + sourceIssueId: issue!.id, + sourceAgentId: agent.id, + }); + }); }); diff --git a/server/src/services/document-source-trust.ts b/server/src/services/document-source-trust.ts new file mode 100644 index 00000000000..11ba1bb6429 --- /dev/null +++ b/server/src/services/document-source-trust.ts @@ -0,0 +1,136 @@ +import { and, eq } from "drizzle-orm"; +import type { Db } from "@paperclipai/db"; +import { documents, heartbeatRuns } from "@paperclipai/db"; +import { isUuidLike } from "@paperclipai/shared"; +import { HttpError } from "../errors.js"; +import { + buildLowTrustSourceTrust, + resolveActorSourceTrustForIssue, + type SourceTrustIssueContext, +} from "./source-trust.js"; + +type DocumentSourceTrust = typeof documents.$inferInsert.sourceTrust; + +export async function resolveDocumentCreatedByRunId( + dbOrTx: Pick, + companyId: string, + runId: string | null | undefined, +): Promise { + const normalized = typeof runId === "string" ? runId.trim() : ""; + if (!normalized || !isUuidLike(normalized)) return null; + const existing = await dbOrTx + .select({ id: heartbeatRuns.id }) + .from(heartbeatRuns) + .where(and(eq(heartbeatRuns.id, normalized), eq(heartbeatRuns.companyId, companyId))) + .then((rows) => rows[0] ?? null); + return existing?.id ?? null; +} + +export async function resolveDocumentWriteSourceTrust(input: { + db: Db; + issue: SourceTrustIssueContext; + createdByAgentId?: string | null; + createdByRunId?: string | null; + explicitSourceTrust?: DocumentSourceTrust; +}): Promise<{ createdByRunId: string | null; sourceTrust: DocumentSourceTrust }> { + const createdByRunId = await resolveDocumentCreatedByRunId( + input.db, + input.issue.companyId, + input.createdByRunId, + ); + if (input.explicitSourceTrust !== undefined) { + return { createdByRunId, sourceTrust: input.explicitSourceTrust }; + } + if (!input.createdByAgentId) { + return { createdByRunId, sourceTrust: null }; + } + const sourceTrust = await resolveActorSourceTrustForIssue({ + db: input.db, + issue: input.issue, + actor: { + actorType: "agent", + actorId: input.createdByAgentId, + agentId: input.createdByAgentId, + runId: createdByRunId, + }, + }); + return { createdByRunId, sourceTrust }; +} + +export async function resolveDocumentRestoreSourceTrust(input: { + db: Db; + issue: SourceTrustIssueContext; + restoringAgentId?: string | null; + restoringUserId?: string | null; + restoringRunId?: string | null; + originalRevisionAgentId?: string | null; + originalRevisionRunId?: string | null; +}): Promise<{ + sourceTrust: DocumentSourceTrust; + revisionCreatedByAgentId: string | null; + revisionCreatedByUserId: string | null; + revisionCreatedByRunId: string | null; +}> { + const createdByRunId = await resolveDocumentCreatedByRunId( + input.db, + input.issue.companyId, + input.restoringRunId, + ); + const actorSourceTrust = input.restoringAgentId + ? await resolveActorSourceTrustForIssue({ + db: input.db, + issue: input.issue, + actor: { + actorType: "agent", + actorId: input.restoringAgentId, + agentId: input.restoringAgentId, + runId: createdByRunId, + }, + }) + : null; + + const normalizedOriginalRunId = input.originalRevisionAgentId + ? await resolveDocumentCreatedByRunId(input.db, input.issue.companyId, input.originalRevisionRunId) + : null; + let restoredRevisionSourceTrust: DocumentSourceTrust = null; + if (!actorSourceTrust && input.originalRevisionAgentId) { + try { + restoredRevisionSourceTrust = await resolveActorSourceTrustForIssue({ + db: input.db, + issue: input.issue, + actor: { + actorType: "agent", + actorId: input.originalRevisionAgentId, + agentId: input.originalRevisionAgentId, + runId: input.originalRevisionRunId ?? null, + }, + }); + } catch (error) { + // If the original revision author's policy changed and now conflicts (403), + // do not block the restore — fail closed by treating the restored content as quarantined. + if (error instanceof HttpError && error.status === 403) { + restoredRevisionSourceTrust = buildLowTrustSourceTrust({ + issueId: input.issue.id, + runId: normalizedOriginalRunId, + agentId: input.originalRevisionAgentId, + }); + } else { + throw error; + } + } + } + + const preserveQuarantinedProvenance = Boolean(!actorSourceTrust && restoredRevisionSourceTrust); + return { + sourceTrust: actorSourceTrust ?? restoredRevisionSourceTrust ?? null, + revisionCreatedByAgentId: preserveQuarantinedProvenance + ? (input.originalRevisionAgentId ?? null) + : (input.restoringAgentId ?? null), + revisionCreatedByUserId: preserveQuarantinedProvenance + ? null + : (input.restoringUserId ?? null), + revisionCreatedByRunId: preserveQuarantinedProvenance + ? normalizedOriginalRunId + : createdByRunId, + }; +} diff --git a/server/src/services/documents.ts b/server/src/services/documents.ts index 4ea296c63f3..0cf602bb294 100644 --- a/server/src/services/documents.ts +++ b/server/src/services/documents.ts @@ -11,6 +11,10 @@ import { isUniqueViolation } from "../db-errors.js"; import { insertRowsInChunks } from "./batch-insert.js"; import type { ImportIssueDocumentRow } from "./import-write-types.js"; import { emitPlanCreatedAfterCommit } from "./product-telemetry.js"; +import { + resolveDocumentRestoreSourceTrust, + resolveDocumentWriteSourceTrust, +} from "./document-source-trust.js"; // Stay below download_artifact's 10 MiB limit, including JSON escaping and metadata. export const ISSUE_DOCUMENT_BATCH_MAX_BYTES = 8 * 1024 * 1024; @@ -266,8 +270,14 @@ export function documentService(db: Db) { }, options: { initialTaskCreation?: boolean } = {}) => { const key = normalizeDocumentKey(input.key); const issue = await db - .select({ id: issues.id, companyId: issues.companyId, createdByUserId: issues.createdByUserId, - responsibleUserId: issues.responsibleUserId }) + .select({ + id: issues.id, + companyId: issues.companyId, + projectId: issues.projectId, + executionPolicy: issues.executionPolicy, + createdByUserId: issues.createdByUserId, + responsibleUserId: issues.responsibleUserId, + }) .from(issues) .where(eq(issues.id, input.issueId)) .then((rows) => rows[0] ?? null); @@ -316,6 +326,14 @@ export function documentService(db: Db) { ], lock: true, }); + const { createdByRunId, sourceTrust: resolvedSourceTrust } = await resolveDocumentWriteSourceTrust({ + db: tx as unknown as Db, + issue, + createdByAgentId: input.createdByAgentId, + createdByRunId: input.createdByRunId, + explicitSourceTrust: input.sourceTrust, + }); + if (existing) { if (existing.lockedAt) { if (input.lockedDocumentStrategy === "create_new_document") { @@ -342,7 +360,7 @@ export function documentService(db: Db) { lockedAt: null, lockedByAgentId: null, lockedByUserId: null, - sourceTrust: input.sourceTrust ?? null, + sourceTrust: resolvedSourceTrust ?? null, createdAt: now, updatedAt: now, }) @@ -360,7 +378,7 @@ export function documentService(db: Db) { changeSummary: input.changeSummary ?? null, createdByAgentId: input.createdByAgentId ?? null, createdByUserId: input.createdByUserId ?? null, - createdByRunId: input.createdByRunId ?? null, + createdByRunId, createdAt: now, }) .returning(); @@ -441,7 +459,7 @@ export function documentService(db: Db) { changeSummary: input.changeSummary ?? null, createdByAgentId: input.createdByAgentId ?? null, createdByUserId: input.createdByUserId ?? null, - createdByRunId: input.createdByRunId ?? null, + createdByRunId, createdAt: now, }) .returning(); @@ -456,7 +474,7 @@ export function documentService(db: Db) { latestRevisionNumber: nextRevisionNumber, updatedByAgentId: input.createdByAgentId ?? null, updatedByUserId: input.createdByUserId ?? null, - sourceTrust: input.sourceTrust ?? null, + sourceTrust: resolvedSourceTrust ?? null, updatedAt: now, }) .where(eq(documents.id, existing.id)); @@ -481,7 +499,7 @@ export function documentService(db: Db) { lockedAt: existing.lockedAt, lockedByAgentId: existing.lockedByAgentId, lockedByUserId: existing.lockedByUserId, - sourceTrust: input.sourceTrust ?? null, + sourceTrust: resolvedSourceTrust ?? null, updatedAt: now, }, }; @@ -508,7 +526,7 @@ export function documentService(db: Db) { lockedAt: null, lockedByAgentId: null, lockedByUserId: null, - sourceTrust: input.sourceTrust ?? null, + sourceTrust: resolvedSourceTrust ?? null, createdAt: now, updatedAt: now, }) @@ -526,7 +544,7 @@ export function documentService(db: Db) { changeSummary: input.changeSummary ?? null, createdByAgentId: input.createdByAgentId ?? null, createdByUserId: input.createdByUserId ?? null, - createdByRunId: input.createdByRunId ?? null, + createdByRunId, createdAt: now, }) .returning(); @@ -671,17 +689,30 @@ export function documentService(db: Db) { revisionId: string; createdByAgentId?: string | null; createdByUserId?: string | null; + createdByRunId?: string | null; }) => { const key = normalizeDocumentKey(input.key); return db.transaction(async (tx) => { - const existing = await tx - .select(issueDocumentSelect) - .from(issueDocuments) - .innerJoin(documents, eq(issueDocuments.documentId, documents.id)) - .where(and(eq(issueDocuments.issueId, input.issueId), eq(issueDocuments.key, key))) - .then((rows) => rows[0] ?? null); + const [existing, issue] = await Promise.all([ + tx + .select(issueDocumentSelect) + .from(issueDocuments) + .innerJoin(documents, eq(issueDocuments.documentId, documents.id)) + .where(and(eq(issueDocuments.issueId, input.issueId), eq(issueDocuments.key, key))) + .then((rows) => rows[0] ?? null), + tx + .select({ + id: issues.id, + companyId: issues.companyId, + projectId: issues.projectId, + executionPolicy: issues.executionPolicy, + }) + .from(issues) + .where(eq(issues.id, input.issueId)) + .then((rows) => rows[0] ?? null), + ]); - if (!existing) throw notFound("Document not found"); + if (!existing || !issue) throw notFound("Document not found"); if (existing.lockedAt) { throw conflict("Document is locked", { key: existing.key, @@ -699,6 +730,8 @@ export function documentService(db: Db) { title: documentRevisions.title, format: documentRevisions.format, body: documentRevisions.body, + createdByAgentId: documentRevisions.createdByAgentId, + createdByRunId: documentRevisions.createdByRunId, }) .from(documentRevisions) .where(and(eq(documentRevisions.id, input.revisionId), eq(documentRevisions.documentId, existing.id))) @@ -715,6 +748,16 @@ export function documentService(db: Db) { }); } + const restoreTrust = await resolveDocumentRestoreSourceTrust({ + db: tx as unknown as Db, + issue, + restoringAgentId: input.createdByAgentId, + restoringUserId: input.createdByUserId, + restoringRunId: input.createdByRunId, + originalRevisionAgentId: revision.createdByAgentId, + originalRevisionRunId: revision.createdByRunId, + }); + await notifyIssueGraphRecovery(tx, { companyId: existing.companyId, issueId: existing.issueId }); const now = new Date(); const nextRevisionNumber = existing.latestRevisionNumber + 1; @@ -728,8 +771,9 @@ export function documentService(db: Db) { format: revision.format, body: revision.body, changeSummary: `Restored from revision ${revision.revisionNumber}`, - createdByAgentId: input.createdByAgentId ?? null, - createdByUserId: input.createdByUserId ?? null, + createdByAgentId: restoreTrust.revisionCreatedByAgentId, + createdByUserId: restoreTrust.revisionCreatedByUserId, + createdByRunId: restoreTrust.revisionCreatedByRunId, createdAt: now, }) .returning(); @@ -745,6 +789,7 @@ export function documentService(db: Db) { latestRevisionNumber: nextRevisionNumber, updatedByAgentId: input.createdByAgentId ?? null, updatedByUserId: input.createdByUserId ?? null, + sourceTrust: restoreTrust.sourceTrust, updatedAt: now, }) .where(eq(documents.id, existing.id)); @@ -767,6 +812,7 @@ export function documentService(db: Db) { latestRevisionNumber: nextRevisionNumber, updatedByAgentId: input.createdByAgentId ?? null, updatedByUserId: input.createdByUserId ?? null, + sourceTrust: restoreTrust.sourceTrust, updatedAt: now, }, }; diff --git a/server/src/services/issues.ts b/server/src/services/issues.ts index 7710deaf05e..16a934399ba 100644 --- a/server/src/services/issues.ts +++ b/server/src/services/issues.ts @@ -58,6 +58,7 @@ import { documentService } from "./documents.js"; import { emitArtifactCreatedAfterCommit, emitTaskCreatedAfterCommit, emitTaskStatusTransitionAfterCommit, emitChatStartedIfFirstOwnerTurn } from "./product-telemetry.js"; import { hasUnfinishedBlockers } from "./issue-dependency-wakeups.js"; import { parseTaskSearch, taskSearchCtes, taskSearchScore } from "./task-search.js"; +import { resolveActorSourceTrustForIssue } from "./source-trust.js"; import { createdFromIssueCondition } from "./issue-creation-origin.js"; import { loadRunBoundIssue } from "./issue-creation-source.js"; import { executionProjectionsForRuns } from "./execution-projection.js"; @@ -13998,13 +13999,23 @@ export function issueService(db: Db) { // The query below locks human comments on caller-owned transactions too, // sharing the fence with both question creation and Slack settlement. const issueQuery = dbOrTx - .select({ companyId: issues.companyId, conversationAgentId: issues.conversationAgentId }) + .select({ + companyId: issues.companyId, + projectId: issues.projectId, + executionPolicy: issues.executionPolicy, + conversationAgentId: issues.conversationAgentId, + }) .from(issues) .where(eq(issues.id, issueId)); // Caller-owned transactions (including chat and review comments) must // serialize with question creation before inserting the human comment. const issue = await (actor.userId || (actor.runId && dbOrTx !== db) ? issueQuery.for("update") : issueQuery) - .then((rows: Array<{ companyId: string; conversationAgentId: string | null }>) => rows[0] ?? null); + .then((rows: Array<{ + companyId: string; + projectId: string | null; + executionPolicy: unknown; + conversationAgentId: string | null; + }>) => rows[0] ?? null); if (!issue) throw notFound("Issue not found"); @@ -14298,6 +14309,26 @@ export function issueService(db: Db) { } const insertedNewComment = !comment; if (!comment) { + const resolvedSourceTrust = + options?.sourceTrust !== undefined + ? options.sourceTrust + : actor.agentId + ? await resolveActorSourceTrustForIssue({ + db: dbOrTx, + issue: { + id: issueId, + companyId: issue.companyId, + projectId: issue.projectId, + executionPolicy: issue.executionPolicy, + }, + actor: { + actorType: "agent", + actorId: actor.agentId, + agentId: actor.agentId, + runId: createdByRunId, + }, + }) + : null; [comment] = await measureRunPhase("response.write", () => insertIssueComment(dbOrTx, { companyId: issue.companyId, issueId, @@ -14312,7 +14343,7 @@ export function issueService(db: Db) { metadata, ...(options?.kvLabels !== undefined ? { kvLabels: options.kvLabels } : {}), ...(options?.schemaBlocks !== undefined ? { schemaBlocks: options.schemaBlocks } : {}), - sourceTrust: options?.sourceTrust ?? null, + sourceTrust: resolvedSourceTrust ?? null, createdAt: validCreatedAt ?? currentInsertTimestamp!, ...(currentInsertTimestamp ? { updatedAt: currentInsertTimestamp } diff --git a/server/src/services/native-runtime/paperclip-runner-tool-authority.ts b/server/src/services/native-runtime/paperclip-runner-tool-authority.ts index cc9194f67ad..14a356b897d 100644 --- a/server/src/services/native-runtime/paperclip-runner-tool-authority.ts +++ b/server/src/services/native-runtime/paperclip-runner-tool-authority.ts @@ -46,7 +46,7 @@ import { assertAssignableAgent } from "../agent-assignability.js"; import { approvalReadSqlCondition, canActorReadApproval, authorizationService, issueReadSqlCondition, type AuthorizationActor } from "../authorization.js"; import { resolveCoreTrustPreset } from "../trust-preset-resolver.js"; import { normalizeIssueExecutionPolicy, redactIssueMonitorExternalRef } from "../issue-execution-policy.js"; -import { buildLowTrustSourceTrust, isLowTrustQuarantined, LOW_TRUST_QUARANTINED_BODY, resolveActorSourceTrustForIssue, sanitizeQuarantinedCommentForHigherTrust } from "../source-trust.js"; +import { buildLowTrustSourceTrust, isLowTrustQuarantined, isPositivelyLowTrustReaderForIssue, LOW_TRUST_QUARANTINED_BODY, redactQuarantinedBodyForHigherTrust, resolveActorSourceTrustForIssue, sanitizeQuarantinedCommentForHigherTrust } from "../source-trust.js"; import { handoffPlanContext } from "./handoff-plan-context.js"; import { callCreateSkillTool, callUpdateSkillDetailsTool, callUpdateSkillTool } from "../skill-tools.js"; import { callProjectTool } from "../project-tools.js"; @@ -1112,8 +1112,7 @@ export class PaperclipRunnerToolAuthority { }; } case "get_task_history": { - const readerSourceTrust = await resolveActorSourceTrustForIssue({ db: this.db, issue: context.issue, - actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }); + const readerIsLowTrust = await this.#isLowTrustReader(context.issue); const limit = boundedLimit(input.limit); const comments = await this.db.select({ id: issueComments.id, @@ -1145,7 +1144,7 @@ export class PaperclipRunnerToolAuthority { // before reversing into chronological order. const historyBlocksBudget = createSchemaBlocksResponseBudget(); const projectedNewestFirst = comments.map(({ updatedAt: _updatedAt, ...comment }) => { - const redactQuarantined = !isLowTrustQuarantined(readerSourceTrust) && isLowTrustQuarantined(comment.sourceTrust); + const redactQuarantined = !readerIsLowTrust && isLowTrustQuarantined(comment.sourceTrust); const visible = redactQuarantined ? sanitizeQuarantinedCommentForHigherTrust(comment) : comment; const projectedBlocks = redactQuarantined ? { schemaBlocks: [] } @@ -1228,10 +1227,10 @@ export class PaperclipRunnerToolAuthority { // Honor the advertised limit (default 50, maximum 200), newest first. const revisions = await service.listIssueDocumentRevisions(this.binding.issueId, key, { limit: boundedLimit(input.limit, 50, 200) }); - if (!this.binding.museRuntime || revisions.length === 0) return boundedDocumentRead(call.tool, { revisions }); + if (revisions.length === 0) return boundedDocumentRead(call.tool, { revisions }); const document = await service.getIssueDocumentByKey(this.binding.issueId, key); return boundedDocumentRead(call.tool, - { revisions: await this.#projectMuseDocumentContent(context.issue, revisions, document ? [document] : []) }); + { revisions: await this.#projectDocumentContent(context.issue, revisions, document ? [document] : []) }); } case "write_document": return this.#writeDocument(input); case "list_agents": @@ -2115,8 +2114,8 @@ export class PaperclipRunnerToolAuthority { this.binding.companyId, { explicitBlocks: input.schemaBlocks, body }, ); - const sourceTrust = this.binding.museRuntime ? await resolveActorSourceTrustForIssue({ db: tx, issue: context.issue, - actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }) : undefined; + const sourceTrust = await resolveActorSourceTrustForIssue({ db: tx, issue: context.issue, + actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }); const comment = await issueService(tx).addComment( this.binding.issueId, body, @@ -2170,8 +2169,8 @@ export class PaperclipRunnerToolAuthority { if (recovering && !nativeToolAllowedInMode("write_document", context.issue.workMode)) { throw new Error("paperclip_runner_tool_mode_denied"); } - const sourceTrust = this.binding.museRuntime ? await resolveActorSourceTrustForIssue({ db: tx, issue: context.issue, - actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }) : undefined; + const sourceTrust = await resolveActorSourceTrustForIssue({ db: tx, issue: context.issue, + actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }); const write = await documentService(tx).upsertIssueDocument({ issueId: this.binding.issueId, key: requiredString(input.key), @@ -3121,74 +3120,141 @@ export class PaperclipRunnerToolAuthority { return result; } - async #visibleMuseDocuments(issue: typeof issues.$inferSelect, documents: NativeIssueDocument[]) { - if (!this.binding.museRuntime) return documents; - const visible = await this.#projectMuseDocumentContent(issue, documents.map(document => ({ - id: document.latestRevisionId, documentId: document.id, body: document.body ?? "", - })), documents); - return documents.map((document, index) => ({ ...document, body: visible[index]!.body })); + async #isLowTrustReader(issue: typeof issues.$inferSelect): Promise { + return isPositivelyLowTrustReaderForIssue({ + db: this.db, + issue, + actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId }, + }); } - async #projectMuseDocumentContent( + async #visibleMuseDocuments(issue: typeof issues.$inferSelect, documents: NativeIssueDocument[]) { + if (!this.binding.museRuntime) { + if (!documents.some(document => isLowTrustQuarantined(document.sourceTrust))) return documents; + if (await this.#isLowTrustReader(issue)) return documents; + return documents.map(document => + isLowTrustQuarantined(document.sourceTrust) + ? { ...redactQuarantinedBodyForHigherTrust(document), title: null } + : document); + } + const visible = await this.#projectDocumentContent(issue, documents.map(document => ({ + id: document.latestRevisionId, documentId: document.id, body: document.body ?? "", title: document.title, + })), documents); + return documents.map((document, index) => ({ ...document, body: visible[index]!.body, title: visible[index]!.title })); + } + + async #projectDocumentContent( readerIssue: typeof issues.$inferSelect, entries: T[], currentDocuments: NativeIssueDocument[], sourceIssueId = this.binding.issueId, ): Promise { - if (!this.binding.museRuntime || entries.length === 0) return entries; - const readerSourceTrust = await resolveActorSourceTrustForIssue({ db: this.db, issue: readerIssue, - actor: { actorType: "agent", actorId: this.binding.agentId, agentId: this.binding.agentId, runId: this.binding.runId } }); - if (isLowTrustQuarantined(readerSourceTrust)) return entries; + if (entries.length === 0) return entries; + if (await this.#isLowTrustReader(readerIssue)) return entries; const ids = entries.flatMap(entry => entry.id ? [entry.id] : []); - const provenance = ids.length === 0 ? [] : await this.db.select({ - id: documentRevisions.id, documentId: documentRevisions.documentId, - createdByAgentId: documentRevisions.createdByAgentId, createdByUserId: documentRevisions.createdByUserId, - createdByRunId: documentRevisions.createdByRunId, userId: authUsers.id, writerCompanyId: agents.companyId, - runId: heartbeatRuns.id, runCompanyId: heartbeatRuns.companyId, runAgentId: heartbeatRuns.agentId, - runIssueId: heartbeatRuns.nativeIssueId, runExecutionPolicy: sql`${heartbeatRuns.contextSnapshot}->'executionPolicy'`, - }).from(documentRevisions) - .leftJoin(authUsers, eq(authUsers.id, documentRevisions.createdByUserId)) - .leftJoin(agents, and(eq(agents.id, documentRevisions.createdByAgentId), eq(agents.companyId, this.binding.companyId))) - .leftJoin(heartbeatRuns, and(eq(heartbeatRuns.id, documentRevisions.createdByRunId), eq(heartbeatRuns.companyId, this.binding.companyId))) - .where(and(eq(documentRevisions.companyId, this.binding.companyId), inArray(documentRevisions.id, ids))); + const [provenance, sourceIssue] = await Promise.all([ + ids.length === 0 ? Promise.resolve([]) : this.db.select({ + id: documentRevisions.id, documentId: documentRevisions.documentId, + createdByAgentId: documentRevisions.createdByAgentId, createdByUserId: documentRevisions.createdByUserId, + createdByRunId: documentRevisions.createdByRunId, userId: authUsers.id, + writerCompanyId: agents.companyId, writerPermissions: agents.permissions, + runId: heartbeatRuns.id, runCompanyId: heartbeatRuns.companyId, runAgentId: heartbeatRuns.agentId, + runIssueId: heartbeatRuns.nativeIssueId, runExecutionPolicy: sql`${heartbeatRuns.contextSnapshot}->'executionPolicy'`, + }).from(documentRevisions) + .leftJoin(authUsers, eq(authUsers.id, documentRevisions.createdByUserId)) + .leftJoin(agents, and(eq(agents.id, documentRevisions.createdByAgentId), eq(agents.companyId, this.binding.companyId))) + .leftJoin(heartbeatRuns, and(eq(heartbeatRuns.id, documentRevisions.createdByRunId), eq(heartbeatRuns.companyId, this.binding.companyId))) + .where(and(eq(documentRevisions.companyId, this.binding.companyId), inArray(documentRevisions.id, ids))), + sourceIssueId === readerIssue.id + ? Promise.resolve({ companyId: readerIssue.companyId, projectId: readerIssue.projectId, executionPolicy: readerIssue.executionPolicy }) + : this.db.select({ + companyId: issues.companyId, projectId: issues.projectId, executionPolicy: issues.executionPolicy, + }).from(issues) + .where(and(eq(issues.id, sourceIssueId), eq(issues.companyId, this.binding.companyId))) + .then(rows => rows[0] ?? null), + ]); + const sourceProject = sourceIssue?.projectId + ? await this.db.select({ + companyId: projects.companyId, executionWorkspacePolicy: projects.executionWorkspacePolicy, + }).from(projects) + .where(and(eq(projects.id, sourceIssue.projectId), eq(projects.companyId, this.binding.companyId))) + .then(rows => rows[0] ?? null) + : null; const byRevision = new Map(provenance.map(row => [row.id, row])); const byDocument = new Map(currentDocuments.filter(document => document.companyId === this.binding.companyId && document.issueId === sourceIssueId).map(document => [document.id, document])); const withhold = (entry: T, body: string): T => ({ ...entry, body, + ...("title" in entry ? { title: null } : {}), ...("changeSummary" in entry ? { changeSummary: null } : {}) }); return entries.map(entry => { const document = byDocument.get(entry.documentId); const original = entry.id ? byRevision.get(entry.id) : undefined; - if (!document || !original || original.documentId !== document.id) return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); - const current = document.latestRevisionId === entry.id; - if (current && isLowTrustQuarantined(document.sourceTrust)) return withhold(entry, LOW_TRUST_QUARANTINED_BODY); - if (current && document.sourceTrust?.disposition === "promoted" + const current = Boolean(document && document.latestRevisionId === entry.id); + if (current && document && isLowTrustQuarantined(document.sourceTrust)) return withhold(entry, LOW_TRUST_QUARANTINED_BODY); + if (current && document && document.sourceTrust?.disposition === "promoted" && document.sourceTrust.promotedFrom?.artifactKind === "document" && document.sourceTrust.promotedFrom.artifactId === document.id) return entry; - if (original.createdByUserId && original.userId === original.createdByUserId - && !original.createdByAgentId && !original.createdByRunId) return entry; - if (!original.createdByAgentId || !original.createdByRunId || original.runId !== original.createdByRunId - || original.writerCompanyId !== this.binding.companyId || original.runCompanyId !== this.binding.companyId - || original.runAgentId !== original.createdByAgentId - || original.runIssueId !== sourceIssueId) return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); - const policy = original.runExecutionPolicy; - if (policy !== null && policy !== undefined && (typeof policy !== "object" || Array.isArray(policy))) { + if (this.binding.museRuntime) { + if (!document || !original || original.documentId !== document.id) return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); + if (original.createdByUserId && original.userId === original.createdByUserId + && !original.createdByAgentId && !original.createdByRunId) return entry; + if (!original.createdByAgentId || !original.createdByRunId || original.runId !== original.createdByRunId + || original.writerCompanyId !== this.binding.companyId || original.runCompanyId !== this.binding.companyId + || original.runAgentId !== original.createdByAgentId + || original.runIssueId !== sourceIssueId) return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); + const policy = original.runExecutionPolicy; + if (policy !== null && policy !== undefined && (typeof policy !== "object" || Array.isArray(policy))) { + return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); + } + const trust = resolveCoreTrustPreset({ + companyId: this.binding.companyId, + agent: original.writerCompanyId ? { companyId: original.writerCompanyId, permissions: original.writerPermissions } : null, + project: sourceProject, + issue: sourceIssue ? { companyId: sourceIssue.companyId, executionPolicy: sourceIssue.executionPolicy } : null, + run: { companyId: original.runCompanyId, executionPolicy: policy }, + }); + if (trust.kind === "low_trust_review") return withhold(entry, LOW_TRUST_QUARANTINED_BODY); + if (trust.kind === "standard" && ((current && document.sourceTrust === null) + || trust.sourcePresets.run === trust.preset)) return entry; return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); } - const trust = resolveCoreTrustPreset({ companyId: this.binding.companyId, - run: { companyId: original.runCompanyId, executionPolicy: policy } }); - if (trust.kind === "low_trust_review") return withhold(entry, LOW_TRUST_QUARANTINED_BODY); - if (trust.kind === "standard" && ((current && document.sourceTrust === null) - || trust.sourcePresets.run === trust.preset)) return entry; - return withhold(entry, UNKNOWN_DOCUMENT_REVISION_BODY); + if (!original) { + return document && isLowTrustQuarantined(document.sourceTrust) ? withhold(entry, LOW_TRUST_QUARANTINED_BODY) : entry; + } + if (original.createdByUserId && original.userId === original.createdByUserId + && !original.createdByAgentId && !original.createdByRunId) return entry; + if (original.createdByRunId && ( + original.runId !== original.createdByRunId + || original.runCompanyId !== this.binding.companyId + || (original.createdByAgentId && original.runAgentId !== original.createdByAgentId) + )) { + return withhold(entry, LOW_TRUST_QUARANTINED_BODY); + } + if (original.createdByAgentId || original.createdByRunId) { + const policy = original.runExecutionPolicy; + if (policy !== null && policy !== undefined && (typeof policy !== "object" || Array.isArray(policy))) { + return withhold(entry, LOW_TRUST_QUARANTINED_BODY); + } + const trust = resolveCoreTrustPreset({ + companyId: this.binding.companyId, + agent: original.writerCompanyId ? { companyId: original.writerCompanyId, permissions: original.writerPermissions } : null, + project: sourceProject, + issue: sourceIssue ? { companyId: sourceIssue.companyId, executionPolicy: sourceIssue.executionPolicy } : null, + run: original.runId && original.runCompanyId ? { companyId: original.runCompanyId, executionPolicy: policy } : null, + }); + if (trust.kind === "low_trust_review" || trust.kind === "denied") { + return withhold(entry, LOW_TRUST_QUARANTINED_BODY); + } + } + return entry; }); } async #sourcePlanApproval(context: { issue: typeof issues.$inferSelect; run: Pick }) { const plan = await handoffPlanContext(this.db, context.issue, this.#privacyActor(context.run)); - if (!plan || !this.binding.museRuntime) return plan; + if (!plan) return plan; const document = await documentService(this.db).getIssueDocumentByKey(plan.sourceIssueId, "plan"); - const [visible] = await this.#projectMuseDocumentContent(context.issue, [{ + const [visible] = await this.#projectDocumentContent(context.issue, [{ id: plan.revisionId, documentId: document?.id ?? "", body: plan.markdown, }], document ? [document] : [], plan.sourceIssueId); return { ...plan, markdown: visible!.body }; @@ -3231,9 +3297,8 @@ export class PaperclipRunnerToolAuthority { .limit(1); if (!revision) return null; const acceptedRevision = { ...revision, ...(approval?.approvedOptions ? { approvedOptions: approval.approvedOptions } : {}) }; - if (!this.binding.museRuntime) return acceptedRevision; const document = await documentService(this.db).getIssueDocumentByKey(this.binding.issueId, "plan"); - const [visible] = await this.#projectMuseDocumentContent(issue, [{ + const [visible] = await this.#projectDocumentContent(issue, [{ id: revision.revisionId, documentId: revision.documentId, body: revision.markdown, }], document ? [document] : []); return { ...acceptedRevision, markdown: visible!.body }; diff --git a/server/src/services/source-trust.ts b/server/src/services/source-trust.ts index 90091bed178..56f60637337 100644 --- a/server/src/services/source-trust.ts +++ b/server/src/services/source-trust.ts @@ -94,12 +94,19 @@ export function buildPromotedSourceTrust(input: { }; } -export async function resolveActorSourceTrustForIssue(input: { +export type ActorSourceTrustResolution = + | { kind: "standard"; sourceTrust: null } + | { kind: "low_trust_review"; sourceTrust: SourceTrustMetadata } + | { kind: "unverified_run"; sourceTrust: SourceTrustMetadata }; + +export async function resolveActorSourceTrustStateForIssue(input: { db: Db; issue: SourceTrustIssueContext; actor: SourceTrustActor; -}): Promise { - if (input.actor.actorType !== "agent" || !input.actor.agentId) return null; +}): Promise { + if (input.actor.actorType !== "agent" || !input.actor.agentId) { + return { kind: "standard", sourceTrust: null }; + } const [agent, project, run] = await Promise.all([ input.db @@ -134,12 +141,16 @@ export async function resolveActorSourceTrustForIssue(input: { ]); if (input.actor.runId && (!run || run.agentId !== input.actor.agentId)) { - // Fail closed: an unknown or mismatched run cannot prove higher trust, so tag the write as quarantined. - return buildLowTrustSourceTrust({ - issueId: input.issue.id, - runId: input.actor.runId, - agentId: input.actor.agentId, - }); + // Fail closed on writes: an unknown or mismatched run cannot prove higher trust, so tag the write as quarantined. + // Callers on read paths use `kind` via `isPositivelyLowTrustReaderForIssue` so unverifiable runs also fail closed. + return { + kind: "unverified_run", + sourceTrust: buildLowTrustSourceTrust({ + issueId: input.issue.id, + runId: input.actor.runId, + agentId: input.actor.agentId, + }), + }; } const runContext = readObject(run?.contextSnapshot); @@ -164,10 +175,33 @@ export async function resolveActorSourceTrustForIssue(input: { if (resolution.kind === "denied") { throw forbidden(resolution.detail); } - if (resolution.kind !== "low_trust_review") return null; - return buildLowTrustSourceTrust({ - issueId: input.issue.id, - runId: input.actor.runId, - agentId: input.actor.agentId, - }); + if (resolution.kind !== "low_trust_review") { + return { kind: "standard", sourceTrust: null }; + } + return { + kind: "low_trust_review", + sourceTrust: buildLowTrustSourceTrust({ + issueId: input.issue.id, + runId: input.actor.runId, + agentId: input.actor.agentId, + }), + }; +} + +export async function resolveActorSourceTrustForIssue(input: { + db: Db; + issue: SourceTrustIssueContext; + actor: SourceTrustActor; +}): Promise { + const resolved = await resolveActorSourceTrustStateForIssue(input); + return resolved.sourceTrust; +} + +export async function isPositivelyLowTrustReaderForIssue(input: { + db: Db; + issue: SourceTrustIssueContext; + actor: SourceTrustActor; +}): Promise { + const resolved = await resolveActorSourceTrustStateForIssue(input); + return resolved.kind === "low_trust_review"; } From 70d780107d3ed07a7c27e00f08cc97b714dab924 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Fri, 4 Dec 2026 10:10:42 -0600 Subject: [PATCH 021/119] fix(ui): stop re-sorting Recents sidebar items to the top on click (#23404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The sidebar includes a Recents list that mixes recent tasks, agent chats, and projects. > - Opening an existing task or project from Recents currently writes `Date.now()` as its timestamp and jumps that item to the top. > - That breaks spatial stability when a person clicks through items in Recents, because every click re-sorts the list. > - This pull request stops passive opens and clicks from changing an existing item's recency timestamp, seeds unseen items from their latest activity timestamp, and records explicit user activity when a person takes action on a task. > - The benefit is a predictable Recents list that orders items by recent activity without shifting on click. ## Linked Issues or Issue Description **What happened?** When a person clicked an existing task or project in the sidebar Recents list, opening that item stamped it with `Date.now()` and moved it to the top of Recents. Clicking through several recent items constantly re-sorted the sidebar. **Expected behavior** Recents sorts items with the most recent activity at the top, and clicking or passively opening an existing item keeps the list order unchanged. Only real activity (such as creating, editing, commenting, approving/rejecting, or responding to an interaction on a task, or server-side updates on chats and projects) moves an item to the top. **Steps to reproduce** 1. Open the Coordinator workspace with at least two tasks or projects in the sidebar Recents list. 2. Click an older item lower in Recents. 3. Observe that the clicked item jumps to the top of Recents even though no activity occurred. **Paperclip version or commit** Reproduced on `master` (`b63445c8f1`). **Deployment mode** Local dev (source checkout). Related PRs: #22219, #22024. ## What Changed - Updated `recordRecentTask` in `ui/src/lib/recent-tasks.ts` so passive opens never change an existing entry's `recordedAt`, and unseen passive opens seed chronologically from `lastActivityAt` or `updatedAt` (falling back below existing history when no valid timestamp exists). - Removed visit-time `Date.now()` bumping in `ui/src/pages/IssueDetail.tsx` and centralized explicit local activity updates (`recordLocalTaskActivity`) across task edits, comments, approvals (captured at mutation start), interaction responses, and isolated re-issues for both Streamlined and Coordinator modes. - Enabled immediate recent-task recording on task creation in `ui/src/components/NewIssueDialog.tsx` when Coordinator mode is enabled (previously gated only on Streamlined mode). - Extracted `recordProjectRecentVisit` and `buildCoordinatorRecents` in `ui/src/components/CoordinatorSidebar.tsx` so revisiting a project keeps its existing entry unchanged, unseen projects seed from `project.updatedAt`, real project updates advance its sort time via `Math.max`, and memo inputs remain referentially stable. - Updated `DESIGN.md` and `doc/PRODUCT.md` to document activity-based Recents ordering without click-driven re-sorting. - Added and updated unit and component tests in `ui/src/lib/recent-tasks.test.ts`, `ui/src/components/CoordinatorSidebar.recents.test.ts` (including a linear-scan read-budget check across 450 items), and `ui/src/pages/IssueDetail.mobile.test.tsx`. ## Verification Tested on rebased commit `79f028344b56ec41092ad458b956c3fd02be0fe0`: - `pnpm --filter @paperclipai/ui typecheck` — passed (0 errors). - `pnpm --filter @paperclipai/ui exec vitest run src/lib/recent-tasks.test.ts src/hooks/useRecentTasks.test.tsx src/hooks/useRecentTaskOpenWarmup.test.tsx src/components/CoordinatorSidebar.recents.test.ts src/pages/IssueDetail.mobile.test.tsx` — passed (5 files, 68 tests). - `pnpm check:token-gates` — passed (all 4 token gates clean). - Broad typecheck, build, and full test coverage will be verified by GitHub CI on this PR. ## Risks - Low risk. Changes are scoped to client-side Recents ordering, state recording, and documentation. No database migrations, API schema changes, or permission changes. - Users who relied on clicking an old task solely to pin it at the top of Recents can use the existing sidebar pin control or take action on the task. ## Model Used - Antigravity (Google DeepMind agentic assistant) with code inspection, file editing, shell execution, Vitest, TypeScript, and GitHub CLI tools. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip --- DESIGN.md | 8 +- doc/PRODUCT.md | 15 +- ui/src/components/CoordinatorSidebar.tsx | 46 +++-- ui/src/components/NewIssueDialog.tsx | 2 +- ui/src/lib/coordinator-recents.test.ts | 225 +++++++++++++++++++++++ ui/src/lib/coordinator-recents.ts | 79 ++++++++ ui/src/lib/recent-tasks.test.ts | 88 ++++++++- ui/src/lib/recent-tasks.ts | 45 ++++- ui/src/pages/IssueDetail.mobile.test.tsx | 194 ++++++++++++++++++- ui/src/pages/IssueDetail.tsx | 94 +++++++--- 10 files changed, 723 insertions(+), 73 deletions(-) create mode 100644 ui/src/lib/coordinator-recents.test.ts create mode 100644 ui/src/lib/coordinator-recents.ts diff --git a/DESIGN.md b/DESIGN.md index 66afaae09a0..265e8f2d96b 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -776,9 +776,11 @@ Recents appears only when it contains entries, without an empty state. Task entries require the viewer's own participation under the Mine inbox rule, regardless of inbox archive state. Automated provenance, account ownership and read-only visits do not establish participation. A qualifying task's title and -status stay current, but passive visits and background updates do not promote it -above newer user activity. A first passive visit places a qualifying candidate -below existing history. Readable subtasks remain contextual navigation under a +status stay current, but clicking or passively visiting an existing entry and +background updates do not promote it above newer user activity. A first passive +visit seeds an unseen qualifying entry from its latest activity timestamp (or +below existing history when unavailable) so newer items sort near the top +without re-sorting on click. Readable subtasks remain contextual navigation under a qualifying parent. ### Reuse collection behavior as well as appearance diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index 4b95c53eeb3..48e19b2cd95 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -120,13 +120,14 @@ The Tasks tab keeps the full relationship list and shows each task once. Project groups omit tasks already shown in the other sections and disappear when empty. Sidebar Recents and Classic Recent Tasks show tasks from the viewer’s own -recent activity as a flat list. A subtask has its own row and its own unread -marker. Tasks archived from the viewer’s inbox leave Recents. Canceled and -completed tasks remain eligible. Opening a recent task moves its row to the top -of Recents. Any task a person opens is eligible for their Recents, including -routine, channel, and agent-created tasks. When a person runs a routine manually, -the task that run creates goes to the top of their Recents at once, before they -open it. Neither of these adds the task to Mine. +recent activity as a flat list ordered by most recent activity. A subtask has +its own row and its own unread marker. Tasks archived from the viewer’s inbox +leave Recents. Canceled and completed tasks remain eligible. Clicking or opening +an existing item in Recents does not move it to the top; items re-sort only +when new activity occurs. Any task a person opens is eligible for their Recents, +including routine, channel, and agent-created tasks. When a person runs a +routine manually, the task that run creates goes to the top of their Recents at +once, before they open it. Neither of these adds the task to Mine. Standard Recents also shows recent chats and projects. The Coordinator sidebar pins **Plugins** above **More** by default. Users can diff --git a/ui/src/components/CoordinatorSidebar.tsx b/ui/src/components/CoordinatorSidebar.tsx index 0b7952b2532..249f2b0458c 100644 --- a/ui/src/components/CoordinatorSidebar.tsx +++ b/ui/src/components/CoordinatorSidebar.tsx @@ -1,7 +1,7 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { useQuery } from "@tanstack/react-query"; import { Inbox, Boxes, CircleCheck, Compass, Folder, History, LayoutDashboard, MessageCircle, MoreHorizontal, Network, Plus, Repeat, Search, Settings, SquarePen, Unplug, type LucideIcon } from "lucide-react"; -import type { Agent, IssueSummary, Project } from "@paperclipai/shared"; +import type { Agent, Issue, IssueSummary, Project } from "@paperclipai/shared"; import { useCoordinatorAttentionCount } from "@/hooks/useCoordinatorAttentionCount"; import { instanceSettingsApi } from "@/api/instanceSettings"; import { useAgentChatNavigation } from "@/hooks/useAgentChatNavigation"; @@ -12,6 +12,11 @@ import { projectPinKey, usePinnedNavigation } from "@/hooks/usePinnedNavigation" import { useDialogActions } from "@/context/DialogContext"; import { useSidebar } from "@/context/SidebarContext"; import { queryKeys } from "@/lib/queryKeys"; +import { + buildCoordinatorRecents, + recordProjectRecentVisit, + type CoordinatorProjectVisits, +} from "@/lib/coordinator-recents"; import type { RecentTaskEntry } from "@/lib/recent-tasks"; import { Link, useLocation } from "@/lib/router"; import { agentRouteRef, projectRouteRef } from "@/lib/utils"; @@ -33,6 +38,9 @@ import { companyProjectsQuery } from "@/lib/company-projects-query"; import { NavigationPinButton, type PinControls } from "./NavigationPinButton"; import { SidebarProjectTasks } from "./SidebarProjectTasks"; +const NO_AGENTS: readonly Agent[] = []; +const NO_CHATS: readonly Issue[] = []; +const NO_PROJECTS: readonly Project[] = []; const NO_RECENT_TASKS: never[] = []; const TASK_PIN_ID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i; const taskPinKey = (companyId: string, id: string) => `task:${companyId}:${id}`; @@ -156,29 +164,29 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) { const { openNewIssue } = useDialogActions(); const attentionCount = useCoordinatorAttentionCount(companyId); const { data: projects } = useQuery({ ...companyProjectsQuery(companyId!), enabled: !!companyId }); - const orderedPins = useMemo(() => buildPinnedNavigationItems(pinnedNavigation.pins, agents.data ?? [], destinations, - pinnedTasks, session.isSuccess ? projects : undefined), [pinnedNavigation.pins, agents.data, destinations, pinnedTasks, projects, session.isSuccess]); - // Only project IDs and visit times are kept in memory. Labels and task lists + const agentList = agents.data ?? NO_AGENTS; + const chatList = chats.data ?? NO_CHATS; + const projectList = projects ?? NO_PROJECTS; + const orderedPins = useMemo(() => buildPinnedNavigationItems(pinnedNavigation.pins, agentList, destinations, + pinnedTasks, session.isSuccess ? projectList : undefined), [pinnedNavigation.pins, agentList, destinations, pinnedTasks, projectList, session.isSuccess]); + // Only project IDs and activity timestamps are kept in memory. Labels and task lists // always come from the authorized API, scoped to the current person/company. const scope = `${companyId}:${userId}`; - const [projectVisits, setProjectVisits] = useState<{ scope: string; entries: Record }>({ scope, entries: {} }); + const [projectVisits, setProjectVisits] = useState({ scope, entries: {} }); useEffect(() => { const ref = location.pathname.match(/\/projects\/([^/]+)/)?.[1]; - const project = projects?.find(item => item.id === ref || projectRouteRef(item) === ref); + const project = projectList.find(item => item.id === ref || projectRouteRef(item) === ref); if (!project) return; - setProjectVisits(previous => ({ scope, entries: { ...(previous.scope === scope ? previous.entries : {}), [project.id]: Date.now() } })); - }, [location.pathname, projects, scope]); - const recents = useMemo(() => { - const roster = new Map((agents.data ?? []).map(agent => [agent.id, agent])); - const taskRows = recentTasks.map(task => ({ kind: "task" as const, id: task.id, time: task.recordedAt, task })); - const chatRows = (chats.data ?? []).flatMap(chat => { - const agent = chat.conversationAgentId ? roster.get(chat.conversationAgentId) : null; - return agent ? [{ kind: "chat" as const, id: chat.id, time: new Date(chat.updatedAt).getTime(), agent }] : []; - }); - const projectRows = (projects ?? []).flatMap(project => projectVisits.scope === scope && projectVisits.entries[project.id] - ? [{ kind: "project" as const, id: project.id, time: projectVisits.entries[project.id]!, project }] : []); - return [...taskRows, ...chatRows, ...projectRows].sort((a, b) => b.time - a.time); - }, [agents.data, chats.data, recentTasks, projects, projectVisits, scope]); + setProjectVisits(previous => recordProjectRecentVisit(previous, scope, project)); + }, [location.pathname, projectList, scope]); + const recents = useMemo(() => buildCoordinatorRecents({ + agents: agentList, + chats: chatList, + recentTasks, + projects: projectList, + projectVisits, + scope, + }), [agentList, chatList, recentTasks, projectList, projectVisits, scope]); const newTaskButton =