Skip to content

Commit cbbecd4

Browse files
committed
feat: add checkpoint context types and fix state machine transitions
Add structured CheckpointContext with failureKind and touchSet violation metadata to replace error-string parsing. Add completed->failed and failed->running to VALID_JOB_TRANSITIONS to support touchSet violation detection and agent relaunch flows. Closes #61
1 parent 6f07762 commit cbbecd4

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/lib/plan-types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ export type PlanStatus =
1010

1111
export type CheckpointType = 'pre_merge' | 'on_error' | 'pre_pr';
1212

13+
export type FailureKind = 'touchset' | 'merge_conflict' | 'test_failure' | 'job_failed';
14+
15+
export interface CheckpointContext {
16+
jobName: string;
17+
failureKind: FailureKind;
18+
touchSetViolations?: string[];
19+
touchSetPatterns?: string[];
20+
}
21+
1322
export type JobStatus =
1423
| 'queued'
1524
| 'waiting_deps'
@@ -39,6 +48,7 @@ export interface PlanSpec {
3948
completedAt?: string;
4049
prUrl?: string;
4150
checkpoint?: CheckpointType | null;
51+
checkpointContext?: CheckpointContext | null;
4252
}
4353

4454
export interface JobSpec {
@@ -76,8 +86,8 @@ export const VALID_JOB_TRANSITIONS: Record<JobStatus, JobStatus[]> = {
7686
queued: ['waiting_deps', 'running', 'stopped', 'canceled'],
7787
waiting_deps: ['running', 'stopped', 'canceled'],
7888
running: ['completed', 'failed', 'stopped', 'canceled'],
79-
completed: ['ready_to_merge', 'stopped', 'canceled'],
80-
failed: ['ready_to_merge', 'stopped', 'canceled'],
89+
completed: ['ready_to_merge', 'failed', 'stopped', 'canceled'],
90+
failed: ['ready_to_merge', 'running', 'stopped', 'canceled'],
8191
ready_to_merge: ['merging', 'needs_rebase', 'stopped', 'canceled'],
8292
merging: ['merged', 'conflict', 'stopped', 'canceled'],
8393
merged: ['needs_rebase'],

src/lib/schemas.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export const JobSpecSchema = z.object({
7272
mode: z.enum(['vanilla', 'plan', 'ralph', 'ulw']).optional(),
7373
});
7474

75+
export const FailureKindSchema = z.enum(['touchset', 'merge_conflict', 'test_failure', 'job_failed']);
76+
77+
export const CheckpointContextSchema = z.object({
78+
jobName: z.string(),
79+
failureKind: FailureKindSchema,
80+
touchSetViolations: z.array(z.string()).optional(),
81+
touchSetPatterns: z.array(z.string()).optional(),
82+
});
83+
7584
export const PlanSpecSchema = z.object({
7685
id: z.string(),
7786
name: z.string(),
@@ -86,6 +95,7 @@ export const PlanSpecSchema = z.object({
8695
completedAt: z.string().optional(),
8796
prUrl: z.string().optional(),
8897
checkpoint: CheckpointTypeSchema.nullable().optional(),
98+
checkpointContext: CheckpointContextSchema.nullable().optional(),
8999
ghAuthenticated: z.boolean().optional(),
90100
});
91101

0 commit comments

Comments
 (0)