diff --git a/server/src/__tests__/issues-service.test.ts b/server/src/__tests__/issues-service.test.ts
index 200168c70b0..0d4fd35b825 100644
--- a/server/src/__tests__/issues-service.test.ts
+++ b/server/src/__tests__/issues-service.test.ts
@@ -2999,6 +2999,110 @@ describeEmbeddedPostgres("issueService blockers and dependency wake readiness",
});
});
+ it("keeps the workspace-finalize barrier for legacy operations without heartbeatRunId", async () => {
+ const companyId = randomUUID();
+ const assigneeAgentId = randomUUID();
+ const projectId = randomUUID();
+ const projectWorkspaceId = randomUUID();
+ const executionWorkspaceId = randomUUID();
+
+ await db.insert(companies).values({
+ id: companyId,
+ name: "Paperclip",
+ issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
+ requireBoardApprovalForNewAgents: false,
+ });
+ await db.insert(agents).values({
+ id: assigneeAgentId,
+ companyId,
+ name: "QA",
+ role: "qa",
+ status: "active",
+ adapterType: "claude_local",
+ adapterConfig: {},
+ runtimeConfig: {},
+ permissions: {},
+ });
+ await db.insert(projects).values({
+ id: projectId,
+ companyId,
+ name: "Shared workspace project",
+ status: "in_progress",
+ });
+ await db.insert(projectWorkspaces).values({
+ id: projectWorkspaceId,
+ companyId,
+ projectId,
+ name: "Shared workspace",
+ sourceType: "local_path",
+ visibility: "default",
+ isPrimary: true,
+ });
+ await db.insert(executionWorkspaces).values({
+ id: executionWorkspaceId,
+ companyId,
+ projectId,
+ projectWorkspaceId,
+ mode: "isolated_workspace",
+ strategyType: "git_worktree",
+ name: "Shared exec workspace",
+ status: "active",
+ providerType: "git_worktree",
+ });
+
+ const blockerId = randomUUID();
+ const dependentId = randomUUID();
+ await db.insert(issues).values([
+ {
+ id: blockerId,
+ companyId,
+ projectId,
+ title: "Legacy predecessor",
+ status: "done",
+ priority: "medium",
+ executionWorkspaceId,
+ },
+ {
+ id: dependentId,
+ companyId,
+ projectId,
+ title: "Dependent",
+ status: "blocked",
+ priority: "medium",
+ assigneeAgentId,
+ },
+ ]);
+ await svc.update(dependentId, { blockedByIssueIds: [blockerId] });
+
+ await db.insert(workspaceOperations).values({
+ companyId,
+ executionWorkspaceId,
+ phase: "worktree_prepare",
+ status: "succeeded",
+ startedAt: new Date("2026-05-23T22:00:00.000Z"),
+ });
+
+ await expect(svc.getDependencyReadiness(dependentId)).resolves.toMatchObject({
+ isDependencyReady: false,
+ pendingFinalizeBlockerIssueIds: [blockerId],
+ unresolvedBlockerIssueIds: [blockerId],
+ });
+
+ await db.insert(workspaceOperations).values({
+ companyId,
+ executionWorkspaceId,
+ phase: "workspace_finalize",
+ status: "succeeded",
+ startedAt: new Date("2026-05-23T22:10:00.000Z"),
+ });
+
+ await expect(svc.getDependencyReadiness(dependentId)).resolves.toMatchObject({
+ isDependencyReady: true,
+ pendingFinalizeBlockerIssueIds: [],
+ unresolvedBlockerIssueIds: [],
+ });
+ });
+
it("keeps a reused-workspace blocker ready when a later sibling operation is unfinalized", async () => {
const companyId = randomUUID();
const assigneeAgentId = randomUUID();
diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts
index 55c76ee42a7..0c7320c8d5b 100644
--- a/server/src/services/heartbeat.ts
+++ b/server/src/services/heartbeat.ts
@@ -10612,7 +10612,7 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
if (outcome.kind === "deferred" || outcome.kind === "duplicate") return null;
if (outcome.kind === "existing") return outcome.run;
if (outcome.kind === "skipped") {
- if ("dependencyGate" in outcome && outcome.dependencyGate && reason === BLOCKER_RELEASE_WAKE_REASON) {
+ if ("dependencyGate" in outcome && outcome.dependencyGate && reason === BLOCKER_RELEASE_WAKE_REASON && issueId) {
await requeueBlockerReleaseWakeIfDependencyGateCleared({
companyId: agent.companyId,
agentId,
diff --git a/server/src/services/issues.ts b/server/src/services/issues.ts
index a0034a60a94..78ec84becce 100644
--- a/server/src/services/issues.ts
+++ b/server/src/services/issues.ts
@@ -696,6 +696,8 @@ async function listPendingFinalizeBlockerIssueIds(
);
const latestByBlockerIssueId = new Map
Some ancestor blockers are still covered by active work — see the "Ultimately waiting on" row below.