mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - When a task is created in a project without explicit workspace overrides, Paperclip derives `projectWorkspaceId`, `executionWorkspaceSettings`, and a project-derived `workspaceSelection` (`source: "project"`). > - Moving that unbound task to a different project via `issues.update` left the old project's `projectWorkspaceId` and `workspaceSelection` behind. > - Subsequent runs kept resolving back to the old project's workspace and storage owner, causing repeated workspace validation or storage-incompatibility failures even after the user moved the task to a compatible project. > - This pull request re-derives project-derived workspace bindings when an unbound task moves projects, and reconciles already-moved unbound tasks with stale `source: "project"` bindings at run admission while preserving explicit workspace selections and bound execution workspaces. > - The benefit is that moving an unbound task to a compatible project immediately lets it run on the new project's workspace without hidden stale-workspace failures. ## Linked Issues or Issue Description Related: #17552, #22849. **What happened?** When a task was created in a project, `issues.create` automatically set `projectWorkspaceId` and `workspaceSelection` with `source: "project"`. If the task failed before binding an execution workspace (`executionWorkspaceId === null`) and the user moved the task to a different project (for example from a Core-storage project to a plugin-storage project), `issues.update` updated `projectId` but left `projectWorkspaceId` and `workspaceSelection` pointing to the old project's workspace. Every subsequent run still resolved the old project's workspace and storage policy and failed. **Expected behavior** - Moving an unbound task whose workspace binding is project-derived (`source: "project"`, or a legacy `projectWorkspaceId` belonging to the previous project with no `workspaceSelection`) re-derives `projectWorkspaceId`, `workspaceSelection`, and `executionWorkspaceSettings` from the new project (or clears them when moving to no project or a sourceless project). - Explicit workspace selections (`source !== "project"`), bound execution workspaces (`executionWorkspaceId != null`), pending workspace selections, and tasks with an active running run or pending workspace recovery keep their current workspace binding. - Tasks already moved on an older release with a stale `source: "project"` binding pointing to a different project are reconciled at run admission before workspace preparation. **Steps to reproduce** 1. Create a Core-storage project A with a Git workspace and a plugin-storage project B with a Git workspace. 2. Create an isolated task in project A (so `issues.create` sets `workspaceSelection.source = "project"`). 3. Move the task to project B via `issueService.update(id, { projectId: projectB.id })`. 4. Before this fix, `projectWorkspaceId` and `workspaceSelection.selection.projectWorkspaceId` still point to project A's workspace. **Paperclip version or commit** Reproduced against `origin/master` at `2d764bebc6ed`. **Deployment mode** Self-hosted / Cloud server. Verified locally on macOS arm64 with embedded PostgreSQL. ## What Changed - `server/src/services/project-move-workspace-reconciliation.ts`: add focused helpers (`isProjectDerivedWorkspaceBindingStale`, `deriveProjectDefaultWorkspaceBinding`, `hasActiveTaskWorkspaceRunHolder`) shared between issue updates and run admission. - `server/src/services/execution-workspaces.ts`: add `reconcileProjectWorkspaceForProjectMove` (used by `issues.update`) and `reconcileStaleProjectWorkspaceAtAdmission` (used at run admission for already-moved tasks with stale `source: "project"` bindings). Keeping the shared reconciliation helpers in a sibling module avoids growing `execution-workspaces.ts` and `issues.ts` unnecessarily. - `server/src/services/issues.ts`: invoke `reconcileProjectWorkspaceForProjectMove` inside `issues.update` after `changesPrivacy` when `projectId` changes and no explicit workspace fields were supplied. - `server/src/services/heartbeat.ts`: invoke `reconcileStaleProjectWorkspaceAtAdmission` alongside `releaseAncestorWorkspaceBindingAtAdmission` at run admission, marking `workspaceSelectionChanged = true` when reconciled. - `server/src/__tests__/issue-project-move-workspace.test.ts`: add red-green database regressions for moving to another project, moving to a sourceless/null project, preserving explicit selections, preserving bound `executionWorkspaceId`, deferring mid-run moves, and reconciling already-moved tasks at admission. - `server/src/__tests__/agent-project-access.test.ts`: use `source: "explicit"` for the explicitly-retained-source denial test and add a companion test verifying `source: "project"` re-derives on project move. ## Verification - **Red (before production edits)**: - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-project-move-workspace.test.ts` failed on `re-derives a project-derived workspace when moving an unbound task to another project` and `clears a project-derived workspace when moving to no project or a sourceless project` because `projectWorkspaceId` and `workspaceSelection` stayed pinned to the old project. - **Green (after production edits)**: - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-project-move-workspace.test.ts src/__tests__/agent-project-access.test.ts` — 20/20 passed. - `pnpm --filter @paperclipai/server typecheck` — passed. - `pnpm --filter @paperclipai/server build` — passed. - `pnpm --filter @paperclipai/server exec vitest run src/services/heartbeat/workspace-preparation.test.ts -t "names incompatible Core project storage|rejects Core Git worktree preparation"` — 2/2 passed. - `pnpm --filter @paperclipai/server exec vitest run src/services/task-interruption-presentation.test.ts` — 82/82 passed. - `pnpm verify --explain` selected 1978/2333 files due to touching central server services; required GitHub Actions CI supplies the broad suite coverage. - Live deployment and recovery of previously affected tasks on hosted instances are outside this PR's scope. ## Risks - Low risk. Reconciliation is gated to unbound tasks (`executionWorkspaceId == null`, `workspacePendingSelection == null`) with no active run holder or pending workspace recovery, and never alters explicit (`source !== "project"`) workspace selections or bound files. - Moving a task to a project whose trust boundary currently denies the assigned agent will not fail the move; execution access remains enforced at run admission. ## Model Used - Google Gemini (Antigravity agentic coding assistant) with tool use, shell execution, and local test verification. Exact deployment model ID and context window are not exposed to the 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 - [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
504 lines
16 KiB
TypeScript
504 lines
16 KiB
TypeScript
import { randomUUID } from "node:crypto";
|
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import { eq } from "drizzle-orm";
|
|
import {
|
|
agents,
|
|
companies,
|
|
companyMemberships,
|
|
createDb,
|
|
executionWorkspaces,
|
|
heartbeatRuns,
|
|
instanceSettings,
|
|
issues,
|
|
plugins,
|
|
projects,
|
|
projectWorkspaces,
|
|
type Db,
|
|
} from "@paperclipai/db";
|
|
import { startEmbeddedPostgresTestDatabase, type EmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js";
|
|
import { createPluginWorkspaceFixture } from "./helpers/plugin-workspaces.js";
|
|
import { issueService } from "../services/issues.js";
|
|
import { executionWorkspaceService } from "../services/execution-workspaces.js";
|
|
import { assertTaskWorkspaceExecutionAccess } from "../services/task-workspace-access.js";
|
|
|
|
describe("project move workspace reconciliation", () => {
|
|
let pg: EmbeddedPostgresTestDatabase;
|
|
let db: Db;
|
|
|
|
beforeAll(async () => {
|
|
pg = await startEmbeddedPostgresTestDatabase("paperclip-issue-project-move-");
|
|
db = createDb(pg.connectionString);
|
|
}, 60_000);
|
|
|
|
afterAll(async () => {
|
|
await pg?.cleanup();
|
|
}, 30_000);
|
|
|
|
async function seedTwoProjects() {
|
|
const companyId = randomUUID();
|
|
const agentId = randomUUID();
|
|
await db.insert(companies).values({
|
|
id: companyId,
|
|
name: "Move Co",
|
|
issuePrefix: `M${companyId.slice(0, 5).toUpperCase()}`,
|
|
status: "active",
|
|
});
|
|
await db.insert(instanceSettings).values({
|
|
id: randomUUID(),
|
|
singletonKey: "default",
|
|
experimental: { enableIsolatedWorkspaces: true },
|
|
}).onConflictDoUpdate({
|
|
target: instanceSettings.singletonKey,
|
|
set: { experimental: { enableIsolatedWorkspaces: true }, updatedAt: new Date() },
|
|
});
|
|
await db.insert(agents).values({
|
|
id: agentId,
|
|
companyId,
|
|
name: "Winston",
|
|
adapterType: "paperclip_runner",
|
|
status: "idle",
|
|
});
|
|
|
|
const storage = await createPluginWorkspaceFixture(db, companyId);
|
|
const [storagePlugin] = await db.select().from(plugins).where(eq(plugins.id, storage.pluginId));
|
|
await db.update(plugins).set({
|
|
manifestJson: {
|
|
...storagePlugin!.manifestJson,
|
|
workspaceProvider: {
|
|
...storagePlugin!.manifestJson.workspaceProvider!,
|
|
defaultForProjects: { mode: "isolated_workspace", strategy: "git_worktree" },
|
|
},
|
|
},
|
|
}).where(eq(plugins.id, storage.pluginId));
|
|
|
|
const [coreProject] = await db.insert(projects).values({
|
|
companyId,
|
|
name: "Paperclip (Deprecated)",
|
|
executionWorkspacePolicy: {
|
|
enabled: true,
|
|
defaultMode: "isolated_workspace",
|
|
workspaceStrategy: { type: "git_worktree" },
|
|
},
|
|
}).returning();
|
|
const [coreWorkspace] = await db.insert(projectWorkspaces).values({
|
|
companyId,
|
|
projectId: coreProject!.id,
|
|
name: "paperclipai/paperclip (core)",
|
|
sourceType: "git_repo",
|
|
repoUrl: "https://github.com/paperclipai/paperclip",
|
|
isPrimary: true,
|
|
}).returning();
|
|
|
|
const [pluginProject] = await db.insert(projects).values({
|
|
companyId,
|
|
name: "Paperclip",
|
|
executionWorkspacePolicy: {
|
|
enabled: true,
|
|
storageProviderPluginId: storage.pluginId,
|
|
},
|
|
}).returning();
|
|
const [pluginWorkspace] = await db.insert(projectWorkspaces).values({
|
|
companyId,
|
|
projectId: pluginProject!.id,
|
|
name: "paperclipai/paperclip (plugin)",
|
|
sourceType: "git_repo",
|
|
repoUrl: "https://github.com/paperclipai/paperclip",
|
|
isPrimary: true,
|
|
}).returning();
|
|
|
|
const [emptyProject] = await db.insert(projects).values({
|
|
companyId,
|
|
name: "Notes Only",
|
|
}).returning();
|
|
|
|
return {
|
|
companyId,
|
|
agentId,
|
|
coreProject: coreProject!,
|
|
coreWorkspace: coreWorkspace!,
|
|
pluginProject: pluginProject!,
|
|
pluginWorkspace: pluginWorkspace!,
|
|
emptyProject: emptyProject!,
|
|
};
|
|
}
|
|
|
|
it("re-derives a project-derived workspace when moving an unbound task to another project", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Investigate duplicate routines",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
});
|
|
expect(created.projectWorkspaceId).toBe(f.coreWorkspace.id);
|
|
expect(created.workspaceSelection).toMatchObject({
|
|
version: 1,
|
|
source: "project",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
});
|
|
|
|
const moved = await svc.update(created.id, { projectId: f.pluginProject.id });
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
workspaceBindingRevision: created.workspaceBindingRevision + 1,
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "project",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("clears a project-derived workspace when moving to no project or a sourceless project", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Move to sourceless",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
});
|
|
|
|
const movedToEmpty = await svc.update(created.id, { projectId: f.emptyProject.id });
|
|
expect(movedToEmpty).toMatchObject({
|
|
projectId: f.emptyProject.id,
|
|
projectWorkspaceId: null,
|
|
workspaceSelection: null,
|
|
});
|
|
|
|
const created2 = await svc.create(f.companyId, {
|
|
title: "Move to projectless",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
});
|
|
const movedToNull = await svc.update(created2.id, { projectId: null });
|
|
expect(movedToNull).toMatchObject({
|
|
projectId: null,
|
|
projectWorkspaceId: null,
|
|
workspaceSelection: null,
|
|
executionWorkspaceSettings: null,
|
|
});
|
|
});
|
|
|
|
it("preserves an explicit workspace selection when moving a task to another project", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Explicit workspace task",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
workspaceSelection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
workspaceSelectionSource: "explicit",
|
|
});
|
|
|
|
const moved = await svc.update(created.id, { projectId: f.pluginProject.id });
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "explicit",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("preserves a bound execution workspace when moving a task to another project", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Task with bound files",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
});
|
|
const [boundWs] = await db.insert(executionWorkspaces).values({
|
|
companyId: f.companyId,
|
|
projectId: f.coreProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
sourceIssueId: created.id,
|
|
name: "Bound worktree",
|
|
cwd: "/tmp/bound-worktree",
|
|
mode: "isolated_workspace",
|
|
strategyType: "git_worktree",
|
|
}).returning();
|
|
await db.update(issues).set({ executionWorkspaceId: boundWs!.id }).where(eq(issues.id, created.id));
|
|
|
|
const moved = await svc.update(created.id, { projectId: f.pluginProject.id });
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
executionWorkspaceId: boundWs!.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
});
|
|
});
|
|
|
|
it("does not mutate workspace binding mid-run when moving a task with an active running run linked only by issueId", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Task with active run",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "in_progress",
|
|
});
|
|
const runId = randomUUID();
|
|
await db.insert(heartbeatRuns).values({
|
|
id: runId,
|
|
companyId: f.companyId,
|
|
agentId: f.agentId,
|
|
issueId: created.id,
|
|
status: "running",
|
|
contextSnapshot: {},
|
|
});
|
|
|
|
const moved = await svc.update(created.id, { projectId: f.pluginProject.id });
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
});
|
|
});
|
|
|
|
it("re-derives a legacy projectWorkspaceId with no workspaceSelection when moving to another project", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const issueId = randomUUID();
|
|
await db.insert(issues).values({
|
|
id: issueId,
|
|
companyId: f.companyId,
|
|
title: "Legacy unbound task",
|
|
status: "todo",
|
|
projectId: f.coreProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
workspaceSelection: null,
|
|
assigneeAgentId: f.agentId,
|
|
});
|
|
|
|
const moved = await svc.update(issueId, { projectId: f.pluginProject.id });
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
workspaceBindingRevision: 1,
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "project",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("honors an explicit projectWorkspaceId passed alongside a project move", async () => {
|
|
const f = await seedTwoProjects();
|
|
const svc = issueService(db);
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Move with explicit source",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: f.agentId,
|
|
status: "todo",
|
|
});
|
|
|
|
const moved = await svc.update(created.id, {
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
});
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
});
|
|
});
|
|
|
|
it("allows moving an unbound task to a trust-denied project with workspaceSelectionActor while keeping execution access denied", async () => {
|
|
const f = await seedTwoProjects();
|
|
const restrictedAgentId = randomUUID();
|
|
await db.insert(agents).values({
|
|
id: restrictedAgentId,
|
|
companyId: f.companyId,
|
|
name: "Restricted Reviewer",
|
|
adapterType: "process",
|
|
status: "idle",
|
|
permissions: {
|
|
trustPreset: "low_trust_review",
|
|
authorizationPolicy: {
|
|
trustBoundary: {
|
|
mode: "low_trust_review",
|
|
companyId: f.companyId,
|
|
projectIds: [f.coreProject.id],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
await db.insert(companyMemberships).values({
|
|
companyId: f.companyId,
|
|
principalType: "agent",
|
|
principalId: restrictedAgentId,
|
|
membershipRole: "member",
|
|
status: "active",
|
|
});
|
|
const svc = issueService(db);
|
|
const board = { type: "board" as const, source: "local_implicit" as const };
|
|
await db.update(projects).set({
|
|
executionWorkspacePolicy: {
|
|
enabled: true,
|
|
storageProviderPluginId: (f.pluginProject.executionWorkspacePolicy as Record<string, unknown>).storageProviderPluginId,
|
|
trustPreset: "low_trust_review",
|
|
authorizationPolicy: {
|
|
trustBoundary: {
|
|
mode: "low_trust_review",
|
|
companyId: f.companyId,
|
|
projectIds: [f.pluginProject.id],
|
|
},
|
|
},
|
|
} as Record<string, unknown>,
|
|
}).where(eq(projects.id, f.pluginProject.id));
|
|
const created = await svc.create(f.companyId, {
|
|
title: "Task moving to denied project",
|
|
projectId: f.coreProject.id,
|
|
assigneeAgentId: restrictedAgentId,
|
|
status: "todo",
|
|
workspaceSelectionActor: board,
|
|
});
|
|
|
|
const moved = await svc.update(created.id, {
|
|
projectId: f.pluginProject.id,
|
|
workspaceSelectionActor: board,
|
|
});
|
|
expect(moved).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
workspaceSelection: null,
|
|
workspaceBindingRevision: created.workspaceBindingRevision + 1,
|
|
});
|
|
|
|
const agentActor = {
|
|
type: "agent" as const,
|
|
source: "agent_key" as const,
|
|
agentId: restrictedAgentId,
|
|
companyId: f.companyId,
|
|
};
|
|
await expect(
|
|
assertTaskWorkspaceExecutionAccess(db, agentActor, f.companyId, { issueId: created.id }),
|
|
).rejects.toMatchObject({ status: 403 });
|
|
});
|
|
|
|
it("reconciles an already-moved task with a stale project-derived workspace at admission", async () => {
|
|
const f = await seedTwoProjects();
|
|
const issueId = randomUUID();
|
|
const runId = randomUUID();
|
|
await db.insert(issues).values({
|
|
id: issueId,
|
|
companyId: f.companyId,
|
|
title: "Already moved before fix",
|
|
status: "todo",
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
assigneeAgentId: f.agentId,
|
|
executionWorkspaceSettings: { mode: "isolated_workspace" },
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "project",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
await db.insert(heartbeatRuns).values({
|
|
id: runId,
|
|
companyId: f.companyId,
|
|
agentId: f.agentId,
|
|
issueId,
|
|
status: "running",
|
|
contextSnapshot: { issueId },
|
|
});
|
|
|
|
const wsSvc = executionWorkspaceService(db);
|
|
const reconciled = await wsSvc.reconcileStaleProjectWorkspaceAtAdmission({
|
|
companyId: f.companyId,
|
|
issueId,
|
|
runId,
|
|
});
|
|
expect(reconciled).toBe(true);
|
|
|
|
const [after] = await db.select().from(issues).where(eq(issues.id, issueId));
|
|
expect(after).toMatchObject({
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
workspaceBindingRevision: 1,
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "project",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.pluginWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
|
|
// Re-running admission reconciliation once consistent is a no-op.
|
|
expect(await wsSvc.reconcileStaleProjectWorkspaceAtAdmission({
|
|
companyId: f.companyId,
|
|
issueId,
|
|
runId,
|
|
})).toBe(false);
|
|
});
|
|
|
|
it("does not reconcile an explicit cross-project workspace selection at admission", async () => {
|
|
const f = await seedTwoProjects();
|
|
const issueId = randomUUID();
|
|
const runId = randomUUID();
|
|
await db.insert(issues).values({
|
|
id: issueId,
|
|
companyId: f.companyId,
|
|
title: "Explicit cross-project selection",
|
|
status: "todo",
|
|
projectId: f.pluginProject.id,
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
assigneeAgentId: f.agentId,
|
|
workspaceSelection: {
|
|
version: 1,
|
|
source: "explicit",
|
|
selection: {
|
|
kind: "configured_source",
|
|
projectWorkspaceId: f.coreWorkspace.id,
|
|
mode: "managed_isolated",
|
|
},
|
|
},
|
|
});
|
|
|
|
const wsSvc = executionWorkspaceService(db);
|
|
expect(await wsSvc.reconcileStaleProjectWorkspaceAtAdmission({
|
|
companyId: f.companyId,
|
|
issueId,
|
|
runId,
|
|
})).toBe(false);
|
|
|
|
const [after] = await db.select().from(issues).where(eq(issues.id, issueId));
|
|
expect(after?.projectWorkspaceId).toBe(f.coreWorkspace.id);
|
|
});
|
|
});
|