PBI-50: SPRINT_IMPLEMENTATION single-session sprint runner (Scrum4Me-side) (#139)
* PBI-50 F1: SPRINT_BATCH execution-strategy + cross-repo blocker + branch-resume Schema-migratie + Scrum4Me-side wiring voor de nieuwe SPRINT_IMPLEMENTATION-flow: - prisma: PrStrategy ADD VALUE 'SPRINT_BATCH'; ClaudeJobKind ADD VALUE 'SPRINT_IMPLEMENTATION'; nieuwe enum SprintTaskExecutionStatus; ClaudeJob.lease_until + status_lease_until index; SprintRun.previous_run_id (self-relation SprintRunChain) voor branch-hergebruik bij resume; nieuwe sprint_task_executions tabel met frozen plan_snapshot + verify_required_snapshot per task in scope. - actions/sprint-runs.ts startSprintRunCore: nieuwe blocker-type 'task_cross_repo' voor SPRINT_BATCH (pre-flight rejecteert sprints met cross-repo task_url). Bij SPRINT_BATCH: één SPRINT_IMPLEMENTATION ClaudeJob (geen per-task loop). - actions/sprint-runs.ts resumePausedSprintRunAction: SPRINT_BATCH-pad met remaining-execution-check; bij onafgemaakt werk → nieuwe SprintRun met previous_run_id + run.branch hergebruikt + nieuwe SPRINT_IMPLEMENTATION-job. Oude SprintRun → CANCELLED. Bestaande PBI-49 P0 scope-DONE pad ongewijzigd. - actions/products.ts updatePrStrategyAction: accepteert SPRINT_BATCH. - components/products/pr-strategy-select.tsx: drie opties met helptekst, gebruikt @prisma/client PrStrategy ipv lokaal type. - components/sprint/sprint-run-controls.tsx: BLOCKER_LABELS + blockerHref voor task_cross_repo. Migratie applied op Neon. Type-check + 532 tests groen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * PBI-50 F5: cross-repo blocker test voor SPRINT_BATCH - task_cross_repo blocker fires bij task.repo_url ≠ product.repo_url - happy path: tasks zonder repo_url-override of met match → één SPRINT_IMPLEMENTATION-job (niet per-task). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * PBI-50 F5: docs/architecture/sprint-execution-modes.md Vergelijking PER_TASK vs SPRINT_BATCH met trade-offs, datamodel- toevoegingen (SprintTaskExecution, lease_until, SprintRunChain) en MCP-tools-matrix per modus. Toegevoegd aan breadcrumb in docs/architecture.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6dcc91383
commit
07749ad9fb
10 changed files with 490 additions and 69 deletions
|
|
@ -0,0 +1,68 @@
|
|||
-- PBI-50: SPRINT_IMPLEMENTATION single-session sprint runner
|
||||
-- Adds:
|
||||
-- - PrStrategy.SPRINT_BATCH (third option)
|
||||
-- - ClaudeJobKind.SPRINT_IMPLEMENTATION (fifth kind)
|
||||
-- - SprintTaskExecutionStatus enum
|
||||
-- - ClaudeJob.lease_until (for heartbeat-driven stale detection)
|
||||
-- - SprintRun.previous_run_id (for branch reuse on resume)
|
||||
-- - sprint_task_executions table (frozen scope-snapshot per claim)
|
||||
|
||||
-- AlterEnum: PrStrategy ADD VALUE (Postgres requires this outside transaction;
|
||||
-- Prisma migrate handles it)
|
||||
ALTER TYPE "PrStrategy" ADD VALUE 'SPRINT_BATCH';
|
||||
|
||||
-- AlterEnum: ClaudeJobKind ADD VALUE
|
||||
ALTER TYPE "ClaudeJobKind" ADD VALUE 'SPRINT_IMPLEMENTATION';
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "SprintTaskExecutionStatus" AS ENUM ('PENDING', 'RUNNING', 'DONE', 'FAILED', 'SKIPPED');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "claude_jobs" ADD COLUMN "lease_until" TIMESTAMP(3);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "sprint_runs" ADD COLUMN "previous_run_id" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "sprint_task_executions" (
|
||||
"id" TEXT NOT NULL,
|
||||
"sprint_job_id" TEXT NOT NULL,
|
||||
"task_id" TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL,
|
||||
"plan_snapshot" TEXT NOT NULL,
|
||||
"verify_required_snapshot" "VerifyRequired" NOT NULL,
|
||||
"verify_only_snapshot" BOOLEAN NOT NULL DEFAULT false,
|
||||
"base_sha" TEXT,
|
||||
"head_sha" TEXT,
|
||||
"status" "SprintTaskExecutionStatus" NOT NULL DEFAULT 'PENDING',
|
||||
"verify_result" "VerifyResult",
|
||||
"verify_summary" TEXT,
|
||||
"skip_reason" TEXT,
|
||||
"started_at" TIMESTAMP(3),
|
||||
"finished_at" TIMESTAMP(3),
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "sprint_task_executions_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "sprint_task_executions_sprint_job_id_order_idx" ON "sprint_task_executions"("sprint_job_id", "order");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "sprint_task_executions_sprint_job_id_task_id_key" ON "sprint_task_executions"("sprint_job_id", "task_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "claude_jobs_status_lease_until_idx" ON "claude_jobs"("status", "lease_until");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "sprint_runs_previous_run_id_key" ON "sprint_runs"("previous_run_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "sprint_runs" ADD CONSTRAINT "sprint_runs_previous_run_id_fkey" FOREIGN KEY ("previous_run_id") REFERENCES "sprint_runs"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "sprint_task_executions" ADD CONSTRAINT "sprint_task_executions_sprint_job_id_fkey" FOREIGN KEY ("sprint_job_id") REFERENCES "claude_jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "sprint_task_executions" ADD CONSTRAINT "sprint_task_executions_task_id_fkey" FOREIGN KEY ("task_id") REFERENCES "tasks"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -92,6 +92,7 @@ enum SprintRunStatus {
|
|||
enum PrStrategy {
|
||||
SPRINT
|
||||
STORY
|
||||
SPRINT_BATCH
|
||||
}
|
||||
|
||||
enum IdeaStatus {
|
||||
|
|
@ -110,6 +111,15 @@ enum ClaudeJobKind {
|
|||
IDEA_GRILL
|
||||
IDEA_MAKE_PLAN
|
||||
PLAN_CHAT
|
||||
SPRINT_IMPLEMENTATION
|
||||
}
|
||||
|
||||
enum SprintTaskExecutionStatus {
|
||||
PENDING
|
||||
RUNNING
|
||||
DONE
|
||||
FAILED
|
||||
SKIPPED
|
||||
}
|
||||
|
||||
enum IdeaLogType {
|
||||
|
|
@ -304,24 +314,27 @@ model Sprint {
|
|||
}
|
||||
|
||||
model SprintRun {
|
||||
id String @id @default(cuid())
|
||||
sprint Sprint @relation(fields: [sprint_id], references: [id], onDelete: Cascade)
|
||||
sprint_id String
|
||||
started_by User @relation("SprintRunStartedBy", fields: [started_by_id], references: [id])
|
||||
started_by_id String
|
||||
status SprintRunStatus @default(QUEUED)
|
||||
pr_strategy PrStrategy
|
||||
branch String?
|
||||
pr_url String?
|
||||
started_at DateTime?
|
||||
finished_at DateTime?
|
||||
failure_reason String?
|
||||
failed_task Task? @relation("SprintRunFailedTask", fields: [failed_task_id], references: [id], onDelete: SetNull)
|
||||
failed_task_id String?
|
||||
pause_context Json?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
jobs ClaudeJob[]
|
||||
id String @id @default(cuid())
|
||||
sprint Sprint @relation(fields: [sprint_id], references: [id], onDelete: Cascade)
|
||||
sprint_id String
|
||||
started_by User @relation("SprintRunStartedBy", fields: [started_by_id], references: [id])
|
||||
started_by_id String
|
||||
status SprintRunStatus @default(QUEUED)
|
||||
pr_strategy PrStrategy
|
||||
branch String?
|
||||
pr_url String?
|
||||
started_at DateTime?
|
||||
finished_at DateTime?
|
||||
failure_reason String?
|
||||
failed_task Task? @relation("SprintRunFailedTask", fields: [failed_task_id], references: [id], onDelete: SetNull)
|
||||
failed_task_id String?
|
||||
pause_context Json?
|
||||
previous_run_id String? @unique
|
||||
previous_run SprintRun? @relation("SprintRunChain", fields: [previous_run_id], references: [id], onDelete: SetNull)
|
||||
next_run SprintRun? @relation("SprintRunChain")
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
jobs ClaudeJob[]
|
||||
|
||||
@@index([sprint_id, status])
|
||||
@@index([started_by_id, status])
|
||||
|
|
@ -329,32 +342,33 @@ model SprintRun {
|
|||
}
|
||||
|
||||
model Task {
|
||||
id String @id @default(cuid())
|
||||
story Story @relation(fields: [story_id], references: [id], onDelete: Cascade)
|
||||
story_id String
|
||||
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||
product_id String
|
||||
sprint Sprint? @relation(fields: [sprint_id], references: [id])
|
||||
sprint_id String?
|
||||
code String @db.VarChar(30)
|
||||
title String
|
||||
description String?
|
||||
implementation_plan String?
|
||||
priority Int
|
||||
sort_order Float
|
||||
status TaskStatus @default(TO_DO)
|
||||
verify_only Boolean @default(false)
|
||||
verify_required VerifyRequired @default(ALIGNED_OR_PARTIAL)
|
||||
id String @id @default(cuid())
|
||||
story Story @relation(fields: [story_id], references: [id], onDelete: Cascade)
|
||||
story_id String
|
||||
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||
product_id String
|
||||
sprint Sprint? @relation(fields: [sprint_id], references: [id])
|
||||
sprint_id String?
|
||||
code String @db.VarChar(30)
|
||||
title String
|
||||
description String?
|
||||
implementation_plan String?
|
||||
priority Int
|
||||
sort_order Float
|
||||
status TaskStatus @default(TO_DO)
|
||||
verify_only Boolean @default(false)
|
||||
verify_required VerifyRequired @default(ALIGNED_OR_PARTIAL)
|
||||
// Override product.repo_url for branch/worktree/push purposes. Set when
|
||||
// a task targets a different repo than its parent product (e.g. an
|
||||
// MCP-server task tracked under the main product's PBI). Falls back to
|
||||
// product.repo_url when null.
|
||||
repo_url String?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
claude_questions ClaudeQuestion[]
|
||||
claude_jobs ClaudeJob[]
|
||||
sprint_run_failures SprintRun[] @relation("SprintRunFailedTask")
|
||||
repo_url String?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
claude_questions ClaudeQuestion[]
|
||||
claude_jobs ClaudeJob[]
|
||||
sprint_run_failures SprintRun[] @relation("SprintRunFailedTask")
|
||||
sprint_task_executions SprintTaskExecution[]
|
||||
|
||||
@@unique([product_id, code])
|
||||
@@index([story_id, priority, sort_order])
|
||||
|
|
@ -364,20 +378,20 @@ model Task {
|
|||
}
|
||||
|
||||
model ClaudeJob {
|
||||
id String @id @default(cuid())
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
id String @id @default(cuid())
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
user_id String
|
||||
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||
product_id String
|
||||
task Task? @relation(fields: [task_id], references: [id], onDelete: Cascade)
|
||||
task Task? @relation(fields: [task_id], references: [id], onDelete: Cascade)
|
||||
task_id String?
|
||||
idea Idea? @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||
idea Idea? @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||
idea_id String?
|
||||
sprint_run SprintRun? @relation(fields: [sprint_run_id], references: [id], onDelete: SetNull)
|
||||
sprint_run SprintRun? @relation(fields: [sprint_run_id], references: [id], onDelete: SetNull)
|
||||
sprint_run_id String?
|
||||
kind ClaudeJobKind @default(TASK_IMPLEMENTATION)
|
||||
status ClaudeJobStatus @default(QUEUED)
|
||||
claimed_by_token ApiToken? @relation(fields: [claimed_by_token_id], references: [id], onDelete: SetNull)
|
||||
kind ClaudeJobKind @default(TASK_IMPLEMENTATION)
|
||||
status ClaudeJobStatus @default(QUEUED)
|
||||
claimed_by_token ApiToken? @relation(fields: [claimed_by_token_id], references: [id], onDelete: SetNull)
|
||||
claimed_by_token_id String?
|
||||
claimed_at DateTime?
|
||||
started_at DateTime?
|
||||
|
|
@ -396,9 +410,11 @@ model ClaudeJob {
|
|||
pr_url String?
|
||||
summary String?
|
||||
error String?
|
||||
retry_count Int @default(0)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
retry_count Int @default(0)
|
||||
lease_until DateTime?
|
||||
task_executions SprintTaskExecution[] @relation("SprintJobExecutions")
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@index([user_id, status])
|
||||
@@index([task_id, status])
|
||||
|
|
@ -406,9 +422,41 @@ model ClaudeJob {
|
|||
@@index([sprint_run_id, status])
|
||||
@@index([status, claimed_at])
|
||||
@@index([status, finished_at])
|
||||
@@index([status, lease_until])
|
||||
@@map("claude_jobs")
|
||||
}
|
||||
|
||||
// PBI-50: frozen scope-snapshot per SPRINT_IMPLEMENTATION-claim. Bij claim
|
||||
// wordt voor elke TO_DO-task in scope één PENDING-record gemaakt met
|
||||
// implementation_plan + verify_required gesnapshot. Worker en gate werken
|
||||
// uitsluitend op deze rows; latere wijzigingen aan Task hebben geen
|
||||
// invloed op de lopende batch.
|
||||
model SprintTaskExecution {
|
||||
id String @id @default(cuid())
|
||||
sprint_job ClaudeJob @relation("SprintJobExecutions", fields: [sprint_job_id], references: [id], onDelete: Cascade)
|
||||
sprint_job_id String
|
||||
task Task @relation(fields: [task_id], references: [id], onDelete: Cascade)
|
||||
task_id String
|
||||
order Int
|
||||
plan_snapshot String @db.Text
|
||||
verify_required_snapshot VerifyRequired
|
||||
verify_only_snapshot Boolean @default(false)
|
||||
base_sha String?
|
||||
head_sha String?
|
||||
status SprintTaskExecutionStatus @default(PENDING)
|
||||
verify_result VerifyResult?
|
||||
verify_summary String? @db.Text
|
||||
skip_reason String? @db.Text
|
||||
started_at DateTime?
|
||||
finished_at DateTime?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@unique([sprint_job_id, task_id])
|
||||
@@index([sprint_job_id, order])
|
||||
@@map("sprint_task_executions")
|
||||
}
|
||||
|
||||
model ModelPrice {
|
||||
id String @id @default(cuid())
|
||||
model_id String @unique
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue