M4: agent-run job queue + worker drain (Increment 1)
SharedKernel: IWorkerModule seam (RegisterWorker runs in the worker host only).
Bootstrap: AddTeamUpWorkerServices; the worker host now wires it.
Assembler module (schema "assembler", InitialAssembler migration):
- Job (Pending→Processing→Done/Failed) + AgentRun (Queued→Running→Completed/Failed) entities.
- JobQueue: enqueue + ClaimNextAsync using `FOR UPDATE SKIP LOCKED` in a transaction.
- AgentRunExecutor (Increment-1 placeholder — real assemble/model/parse lands in Increment 2).
- JobProcessor BackgroundService drains the queue on the worker host (web off the model path).
- POST /api/assembler/runs enqueues a run; GET /api/assembler/runs/{id} reads it.
Verified: build green; ArchitectureTests 8/8 (Assembler references only SharedKernel);
IntegrationTests 28/28 incl. enqueue→claim(SKIP LOCKED)→process→Completed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TeamUp.Modules.Assembler.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialAssembler : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "assembler");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "agent_runs",
|
||||
schema: "assembler",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
SeatId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
WorkItemId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
AgentId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||
Prompt = table.Column<string>(type: "text", nullable: true),
|
||||
Output = table.Column<string>(type: "text", nullable: true),
|
||||
ActionType = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
|
||||
ActionRisk = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
||||
ResultJson = table.Column<string>(type: "text", nullable: true),
|
||||
Trace = table.Column<string>(type: "text", nullable: true),
|
||||
Error = table.Column<string>(type: "text", nullable: true),
|
||||
LatencyMs = table.Column<long>(type: "bigint", nullable: true),
|
||||
CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
CompletedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_agent_runs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "jobs",
|
||||
schema: "assembler",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Type = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: false),
|
||||
Payload = table.Column<string>(type: "text", nullable: false),
|
||||
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||
Attempts = table.Column<int>(type: "integer", nullable: false),
|
||||
LockedBy = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: true),
|
||||
LockedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Error = table.Column<string>(type: "text", nullable: true),
|
||||
CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
CompletedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_jobs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_agent_runs_SeatId",
|
||||
schema: "assembler",
|
||||
table: "agent_runs",
|
||||
column: "SeatId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_agent_runs_WorkItemId",
|
||||
schema: "assembler",
|
||||
table: "agent_runs",
|
||||
column: "WorkItemId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_jobs_Status_CreatedAtUtc",
|
||||
schema: "assembler",
|
||||
table: "jobs",
|
||||
columns: new[] { "Status", "CreatedAtUtc" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "agent_runs",
|
||||
schema: "assembler");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "jobs",
|
||||
schema: "assembler");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user