mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
Implement issue execution lock with deferred wake promotion
Add per-issue execution lock (executionRunId, executionAgentNameKey, executionLockedAt) to prevent concurrent runs on the same issue. Same-name wakes are coalesced into the active run; different-name wakes are deferred and promoted when the lock holder finishes. Includes checkout/release run ownership enforcement, agent run ID propagation from JWT claims, wakeup deduplication across assignee and mention wakes, and claimQueuedRun extraction for reuse. Adds two DB migrations for checkoutRunId and execution lock columns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4e18cfa818
commit
49e15f056d
13 changed files with 9050 additions and 180 deletions
2
packages/db/src/migrations/0012_perpetual_ser_duncan.sql
Normal file
2
packages/db/src/migrations/0012_perpetual_ser_duncan.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "issues" ADD COLUMN "checkout_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD CONSTRAINT "issues_checkout_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("checkout_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;
|
||||
4
packages/db/src/migrations/0013_dashing_wasp.sql
Normal file
4
packages/db/src/migrations/0013_dashing_wasp.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE "issues" ADD COLUMN "execution_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD COLUMN "execution_agent_name_key" text;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD COLUMN "execution_locked_at" timestamp with time zone;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD CONSTRAINT "issues_execution_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("execution_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;
|
||||
4087
packages/db/src/migrations/meta/0012_snapshot.json
Normal file
4087
packages/db/src/migrations/meta/0012_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
4118
packages/db/src/migrations/meta/0013_snapshot.json
Normal file
4118
packages/db/src/migrations/meta/0013_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -85,6 +85,20 @@
|
|||
"when": 1771616419708,
|
||||
"tag": "0011_windy_corsair",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "7",
|
||||
"when": 1771619674673,
|
||||
"tag": "0012_perpetual_ser_duncan",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 13,
|
||||
"version": "7",
|
||||
"when": 1771623691139,
|
||||
"tag": "0013_dashing_wasp",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ import { agents } from "./agents.js";
|
|||
import { projects } from "./projects.js";
|
||||
import { goals } from "./goals.js";
|
||||
import { companies } from "./companies.js";
|
||||
import { heartbeatRuns } from "./heartbeat_runs.js";
|
||||
|
||||
export const issues = pgTable(
|
||||
"issues",
|
||||
|
|
@ -26,6 +27,10 @@ export const issues = pgTable(
|
|||
status: text("status").notNull().default("backlog"),
|
||||
priority: text("priority").notNull().default("medium"),
|
||||
assigneeAgentId: uuid("assignee_agent_id").references(() => agents.id),
|
||||
checkoutRunId: uuid("checkout_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
|
||||
executionRunId: uuid("execution_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
|
||||
executionAgentNameKey: text("execution_agent_name_key"),
|
||||
executionLockedAt: timestamp("execution_locked_at", { withTimezone: true }),
|
||||
createdByAgentId: uuid("created_by_agent_id").references(() => agents.id),
|
||||
createdByUserId: text("created_by_user_id"),
|
||||
issueNumber: integer("issue_number"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue