@markjaquith/agency 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -58
- package/cli-main.ts +0 -72
- package/fixtures/protocol/orchestration-recipes.json +9 -34
- package/package.json +1 -4
- package/schemas/agency-graph-v1.schema.json +2 -31
- package/src/cli-parser.test.ts +13 -132
- package/src/cli-parser.ts +10 -101
- package/src/cli.test.ts +12 -111
- package/src/commands/act.ts +2 -6
- package/src/commands/sync.ts +3 -3
- package/src/commands/validate.ts +3 -1
- package/src/commands/work.test.ts +70 -8
- package/src/commands/work.ts +15 -8
- package/src/graph-schema.ts +0 -2
- package/src/protocol.test.ts +0 -25
- package/src/protocol.ts +0 -11
- package/src/readiness.test.ts +2 -2
- package/src/services/ArchiveBulkService.test.ts +0 -88
- package/src/services/ArchiveService.ts +0 -32
- package/src/services/GraphMutationService.ts +0 -26
- package/src/services/GraphService.test.ts +1 -1
- package/src/services/IntegrationService.test.ts +4 -4
- package/src/services/LifecycleTransaction.ts +5 -1
- package/src/services/PhaseService.ts +1 -8
- package/src/services/ReadinessService.test.ts +0 -34
- package/src/services/ReadinessService.ts +1 -20
- package/src/services/ReviewService.test.ts +0 -64
- package/src/services/ReviewService.ts +0 -5
- package/src/services/SyncService.test.ts +75 -88
- package/src/services/SyncService.ts +52 -123
- package/src/services/TaskPhaseService.test.ts +13 -1
- package/src/services/TaskService.ts +1 -7
- package/src/services/WorkbaseService.ts +0 -3
- package/src/services/WorktreeService.test.ts +192 -1
- package/src/services/WorktreeService.ts +169 -34
- package/src/test-utils.ts +0 -2
- package/src/workbase/AGENTS.md +9 -15
- package/src/workbase/agent-command.test.ts +0 -3
- package/src/workbase/agent-command.ts +0 -6
- package/src/workbase/document-revision.ts +0 -4
- package/src/workbase/schemas.test.ts +12 -25
- package/src/workbase/schemas.ts +0 -16
- package/src/commands/claim.ts +0 -122
- package/src/services/ClaimService.test.ts +0 -415
- package/src/services/ClaimService.ts +0 -608
|
@@ -335,94 +335,6 @@ describe("ArchiveService bulk task archive", () => {
|
|
|
335
335
|
).toBe(true)
|
|
336
336
|
})
|
|
337
337
|
|
|
338
|
-
test("skips task- and phase-level active claims", async () => {
|
|
339
|
-
await createTask("claimed")
|
|
340
|
-
await dropTask("claimed")
|
|
341
|
-
const taskPath = join(root, "tasks/claimed/TASK.md")
|
|
342
|
-
await Bun.write(
|
|
343
|
-
taskPath,
|
|
344
|
-
(await Bun.file(taskPath).text()).replace(
|
|
345
|
-
"status: dropped\n",
|
|
346
|
-
`status: dropped
|
|
347
|
-
claim:
|
|
348
|
-
claimant: orchestrator
|
|
349
|
-
agent: opencode
|
|
350
|
-
sessionId: task-session
|
|
351
|
-
startedAt: 2026-08-07T00:00:00.000Z
|
|
352
|
-
targetRevision: ${"a".repeat(64)}
|
|
353
|
-
state: active
|
|
354
|
-
`,
|
|
355
|
-
),
|
|
356
|
-
)
|
|
357
|
-
await runTestEffect(
|
|
358
|
-
TaskService.pipe(
|
|
359
|
-
Effect.flatMap((service) =>
|
|
360
|
-
service.create(
|
|
361
|
-
{ id: "multi-claimed", ticketUrl: null, multiPhase: true },
|
|
362
|
-
root,
|
|
363
|
-
),
|
|
364
|
-
),
|
|
365
|
-
),
|
|
366
|
-
)
|
|
367
|
-
await runTestEffect(
|
|
368
|
-
PhaseService.pipe(
|
|
369
|
-
Effect.flatMap((service) =>
|
|
370
|
-
service.create(
|
|
371
|
-
{
|
|
372
|
-
taskId: "multi-claimed",
|
|
373
|
-
id: "phase",
|
|
374
|
-
repo: "agency",
|
|
375
|
-
branch: "task/multi-claimed",
|
|
376
|
-
base: "main",
|
|
377
|
-
},
|
|
378
|
-
root,
|
|
379
|
-
),
|
|
380
|
-
),
|
|
381
|
-
),
|
|
382
|
-
)
|
|
383
|
-
await runTestEffect(
|
|
384
|
-
PhaseService.pipe(
|
|
385
|
-
Effect.flatMap((service) =>
|
|
386
|
-
service.setStatus("multi-claimed", "phase", "dropped", root),
|
|
387
|
-
),
|
|
388
|
-
),
|
|
389
|
-
)
|
|
390
|
-
const phasePath = join(root, "tasks/multi-claimed/phases/phase/PHASE.md")
|
|
391
|
-
await Bun.write(
|
|
392
|
-
phasePath,
|
|
393
|
-
(await Bun.file(phasePath).text()).replace(
|
|
394
|
-
"status: dropped\n",
|
|
395
|
-
`status: dropped
|
|
396
|
-
claim:
|
|
397
|
-
claimant: orchestrator
|
|
398
|
-
agent: opencode
|
|
399
|
-
sessionId: phase-session
|
|
400
|
-
startedAt: 2026-08-07T00:00:00.000Z
|
|
401
|
-
targetRevision: ${"b".repeat(64)}
|
|
402
|
-
state: active
|
|
403
|
-
`,
|
|
404
|
-
),
|
|
405
|
-
)
|
|
406
|
-
|
|
407
|
-
const result = await archiveTasks(true)
|
|
408
|
-
|
|
409
|
-
expect(result.tasks).toMatchObject([
|
|
410
|
-
{
|
|
411
|
-
id: "claimed",
|
|
412
|
-
disposition: "skipped",
|
|
413
|
-
reason: { code: "active-claim", details: ["task:claimed"] },
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
id: "multi-claimed",
|
|
417
|
-
disposition: "skipped",
|
|
418
|
-
reason: {
|
|
419
|
-
code: "active-claim",
|
|
420
|
-
details: ["phase:multi-claimed/phase"],
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
])
|
|
424
|
-
})
|
|
425
|
-
|
|
426
338
|
test("rolls back the entire cohort when application fails", async () => {
|
|
427
339
|
await runTestEffect(
|
|
428
340
|
EpicService.pipe(
|
|
@@ -111,7 +111,6 @@ interface LifecycleOptions {
|
|
|
111
111
|
|
|
112
112
|
type TaskArchiveSkipCode =
|
|
113
113
|
| "non-terminal"
|
|
114
|
-
| "active-claim"
|
|
115
114
|
| "dirty-worktree"
|
|
116
115
|
| "checkout-preflight-failed"
|
|
117
116
|
| "retained-dependent"
|
|
@@ -169,7 +168,6 @@ interface TaskArchiveContext {
|
|
|
169
168
|
readonly executionUnits: readonly { taskId: string; phaseId?: string }[]
|
|
170
169
|
readonly terminal: boolean
|
|
171
170
|
readonly terminalDetails: readonly string[]
|
|
172
|
-
readonly activeClaims: readonly string[]
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
const loadTaskArchiveContext = (task: TaskRecord, root: string) =>
|
|
@@ -182,8 +180,6 @@ const loadTaskArchiveContext = (task: TaskRecord, root: string) =>
|
|
|
182
180
|
executionUnits: [{ taskId: task.id }],
|
|
183
181
|
terminal: isTerminalStatus(task.data.status),
|
|
184
182
|
terminalDetails: [`status=${task.data.status}`],
|
|
185
|
-
activeClaims:
|
|
186
|
-
task.data.claim?.state === "active" ? [`task:${task.id}`] : [],
|
|
187
183
|
} satisfies TaskArchiveContext
|
|
188
184
|
}
|
|
189
185
|
|
|
@@ -207,9 +203,6 @@ const loadTaskArchiveContext = (task: TaskRecord, root: string) =>
|
|
|
207
203
|
: phaseRecords.map(
|
|
208
204
|
(phase) => `phase:${phase.id}:status=${phase.data.status}`,
|
|
209
205
|
),
|
|
210
|
-
activeClaims: phaseRecords
|
|
211
|
-
.filter((phase) => phase.data.claim?.state === "active")
|
|
212
|
-
.map((phase) => `phase:${task.id}/${phase.id}`),
|
|
213
206
|
} satisfies TaskArchiveContext
|
|
214
207
|
})
|
|
215
208
|
|
|
@@ -217,9 +210,6 @@ const archiveEligibilityError = (context: TaskArchiveContext) => {
|
|
|
217
210
|
if (!context.terminal) {
|
|
218
211
|
return `Task '${context.task.id}' is not terminal (${context.terminalDetails.join(", ")}); only done or dropped tasks can be archived`
|
|
219
212
|
}
|
|
220
|
-
if (context.activeClaims.length > 0) {
|
|
221
|
-
return `Task '${context.task.id}' has active claims (${context.activeClaims.join(", ")}); release or finish them before archiving`
|
|
222
|
-
}
|
|
223
213
|
return undefined
|
|
224
214
|
}
|
|
225
215
|
|
|
@@ -735,11 +725,6 @@ export class ArchiveService extends Effect.Service<ArchiveService>()(
|
|
|
735
725
|
const executionUnits: { taskId: string; phaseId?: string }[] = []
|
|
736
726
|
const phaseRecords: PhaseRecord[] = []
|
|
737
727
|
for (const task of taskRecords) {
|
|
738
|
-
if ("claim" in task.data && task.data.claim?.state === "active") {
|
|
739
|
-
return yield* new ArchiveError({
|
|
740
|
-
message: `Task '${task.id}' has an active claim; release or finish it before archiving`,
|
|
741
|
-
})
|
|
742
|
-
}
|
|
743
728
|
if ("phases" in task.data) {
|
|
744
729
|
for (const phase of task.data.phases) {
|
|
745
730
|
const record = yield* (yield* PhaseService).show(
|
|
@@ -747,11 +732,6 @@ export class ArchiveService extends Effect.Service<ArchiveService>()(
|
|
|
747
732
|
phase.id,
|
|
748
733
|
root,
|
|
749
734
|
)
|
|
750
|
-
if (record.data.claim?.state === "active") {
|
|
751
|
-
return yield* new ArchiveError({
|
|
752
|
-
message: `Phase '${phase.id}' has an active claim; release or finish it before archiving`,
|
|
753
|
-
})
|
|
754
|
-
}
|
|
755
735
|
phaseRecords.push(record)
|
|
756
736
|
executionUnits.push({ taskId: task.id, phaseId: phase.id })
|
|
757
737
|
}
|
|
@@ -910,13 +890,6 @@ export class ArchiveService extends Effect.Service<ArchiveService>()(
|
|
|
910
890
|
})
|
|
911
891
|
continue
|
|
912
892
|
}
|
|
913
|
-
if (context.activeClaims.length > 0) {
|
|
914
|
-
skipped.set(task.id, {
|
|
915
|
-
code: "active-claim",
|
|
916
|
-
details: context.activeClaims,
|
|
917
|
-
})
|
|
918
|
-
continue
|
|
919
|
-
}
|
|
920
893
|
const destination = archivedTaskDirectory(root, task.id)
|
|
921
894
|
if (yield* fs.exists(destination)) {
|
|
922
895
|
skipped.set(task.id, {
|
|
@@ -1398,11 +1371,6 @@ export class ArchiveService extends Effect.Service<ArchiveService>()(
|
|
|
1398
1371
|
const declaration = task.data.phases.find(
|
|
1399
1372
|
(candidate) => candidate.id === id,
|
|
1400
1373
|
)!
|
|
1401
|
-
if (phase.data.claim?.state === "active") {
|
|
1402
|
-
return yield* new ArchiveError({
|
|
1403
|
-
message: `Phase '${id}' has an active claim; release or finish it before archiving`,
|
|
1404
|
-
})
|
|
1405
|
-
}
|
|
1406
1374
|
const dependent = task.data.phases.find((candidate) =>
|
|
1407
1375
|
candidate.dependsOn?.includes(id),
|
|
1408
1376
|
)
|
|
@@ -376,15 +376,6 @@ export class GraphMutationService extends Effect.Service<GraphMutationService>()
|
|
|
376
376
|
message: `Task '${id}' has multiple phases; update execution metadata on a phase instead`,
|
|
377
377
|
})
|
|
378
378
|
}
|
|
379
|
-
if (
|
|
380
|
-
executionChange &&
|
|
381
|
-
"claim" in record.data &&
|
|
382
|
-
record.data.claim?.state === "active"
|
|
383
|
-
) {
|
|
384
|
-
return yield* new GraphMutationError({
|
|
385
|
-
message: `Task '${id}' has an active claim; release or finish it before changing execution metadata`,
|
|
386
|
-
})
|
|
387
|
-
}
|
|
388
379
|
if (
|
|
389
380
|
updates.pr &&
|
|
390
381
|
"completion" in record.data &&
|
|
@@ -526,11 +517,6 @@ export class GraphMutationService extends Effect.Service<GraphMutationService>()
|
|
|
526
517
|
message: `Phase '${id}' has materialized code; remove its worktree with Agency before changing execution metadata`,
|
|
527
518
|
})
|
|
528
519
|
}
|
|
529
|
-
if (executionChange && record.data.claim?.state === "active") {
|
|
530
|
-
return yield* new GraphMutationError({
|
|
531
|
-
message: `Phase '${id}' has an active claim; release or finish it before changing execution metadata`,
|
|
532
|
-
})
|
|
533
|
-
}
|
|
534
520
|
if (updates.pr && record.data.completion) {
|
|
535
521
|
return yield* new GraphMutationError({
|
|
536
522
|
message:
|
|
@@ -842,10 +828,6 @@ export class GraphMutationService extends Effect.Service<GraphMutationService>()
|
|
|
842
828
|
return yield* new GraphMutationError({
|
|
843
829
|
message: `Task '${newId}' already exists`,
|
|
844
830
|
})
|
|
845
|
-
if ("claim" in task.data && task.data.claim?.state === "active")
|
|
846
|
-
return yield* new GraphMutationError({
|
|
847
|
-
message: `Task '${id}' has an active claim; release or finish it before renaming`,
|
|
848
|
-
})
|
|
849
831
|
if (yield* fs.isDirectory(join(from, "code")))
|
|
850
832
|
return yield* new GraphMutationError({
|
|
851
833
|
message: `Task '${id}' has a materialized worktree; remove it with Agency before renaming`,
|
|
@@ -859,10 +841,6 @@ export class GraphMutationService extends Effect.Service<GraphMutationService>()
|
|
|
859
841
|
root,
|
|
860
842
|
)
|
|
861
843
|
movedPhases.push(record)
|
|
862
|
-
if (record.data.claim?.state === "active")
|
|
863
|
-
return yield* new GraphMutationError({
|
|
864
|
-
message: `Phase '${phase.id}' has an active claim; release or finish it before renaming task '${id}'`,
|
|
865
|
-
})
|
|
866
844
|
if (yield* fs.isDirectory(join(dirname(record.path), "code")))
|
|
867
845
|
return yield* new GraphMutationError({
|
|
868
846
|
message: `Phase '${phase.id}' has a materialized worktree; remove it with Agency before renaming task '${id}'`,
|
|
@@ -952,10 +930,6 @@ export class GraphMutationService extends Effect.Service<GraphMutationService>()
|
|
|
952
930
|
})
|
|
953
931
|
}
|
|
954
932
|
const phase = yield* phases.show(taskId, id, root)
|
|
955
|
-
if (phase.data.claim?.state === "active")
|
|
956
|
-
return yield* new GraphMutationError({
|
|
957
|
-
message: `Phase '${id}' has an active claim; release or finish it before renaming`,
|
|
958
|
-
})
|
|
959
933
|
const from = dirname(phase.path)
|
|
960
934
|
const to = join(dirname(from), newId)
|
|
961
935
|
if (yield* fs.exists(to))
|
|
@@ -230,7 +230,7 @@ describe("GraphService", () => {
|
|
|
230
230
|
expect(calls).toBe(0)
|
|
231
231
|
})
|
|
232
232
|
|
|
233
|
-
test("never reports
|
|
233
|
+
test("never reports active or terminal execution units as ready", async () => {
|
|
234
234
|
const root = await createWorkbase()
|
|
235
235
|
roots.push(root)
|
|
236
236
|
const path = "tasks/ship/phases/implement/PHASE.md"
|
|
@@ -177,7 +177,7 @@ describe("IntegrationService", () => {
|
|
|
177
177
|
"agency task status <task> dropped --if-revision <revision> --json",
|
|
178
178
|
"Continue already materialized work",
|
|
179
179
|
"agency pr create <task> [phase]",
|
|
180
|
-
"agency
|
|
180
|
+
"agency task status <task> done --if-revision <revision> --no-pull-request",
|
|
181
181
|
"agency task create <slug> --multi-phase",
|
|
182
182
|
"agency task handoff <investigation-task> <new-task>",
|
|
183
183
|
"agency review refresh <task> --if-revision <revision> --json",
|
|
@@ -626,7 +626,7 @@ describe("IntegrationService", () => {
|
|
|
626
626
|
)
|
|
627
627
|
expect(body).toContain("Never invent entity IDs")
|
|
628
628
|
expect(body).toContain("Preserve parent backlinks")
|
|
629
|
-
expect(body).toContain("dirty-worktree,
|
|
629
|
+
expect(body).toContain("dirty-worktree, revision")
|
|
630
630
|
expect(body).toContain("`agency work` is the human launch flow")
|
|
631
631
|
expect(body).toContain("Agency worker launch target: <target>.")
|
|
632
632
|
expect(body).toContain("environment variables and a generated")
|
|
@@ -636,7 +636,7 @@ describe("IntegrationService", () => {
|
|
|
636
636
|
)
|
|
637
637
|
expect(body).toMatch(/If\s+the prompt\s+and context disagree/)
|
|
638
638
|
expect(body).toContain("marks execution work")
|
|
639
|
-
expect(body).toContain("
|
|
639
|
+
expect(body).toContain("marks execution work")
|
|
640
640
|
expect(body).toContain("formatting, type checks, build, dead-code checks")
|
|
641
641
|
expect(body).toContain("Review and commit the diff")
|
|
642
642
|
expect(body).toContain("Use `agency push`")
|
|
@@ -650,7 +650,7 @@ describe("IntegrationService", () => {
|
|
|
650
650
|
expect(body).toContain("marking it ready")
|
|
651
651
|
expect(body).toMatch(/completing\s+a refinement loop/)
|
|
652
652
|
expect(body).toContain("pausing or handing off")
|
|
653
|
-
expect(body).toContain("
|
|
653
|
+
expect(body).toContain("update status")
|
|
654
654
|
expect(body).toContain("`agency sync`")
|
|
655
655
|
expect(body).toContain("`--no-pull-request --summary <text>`")
|
|
656
656
|
expect(body).toContain("`TASK.md` or `PHASE.md`")
|
|
@@ -262,7 +262,11 @@ export const runLifecycleTransaction = ({
|
|
|
262
262
|
})
|
|
263
263
|
}
|
|
264
264
|
} catch (cause) {
|
|
265
|
-
if (
|
|
265
|
+
if (
|
|
266
|
+
cause instanceof LifecycleTransactionError ||
|
|
267
|
+
cause instanceof RevisionConflictError
|
|
268
|
+
)
|
|
269
|
+
throw cause
|
|
266
270
|
const rollbackErrors: unknown[] = []
|
|
267
271
|
for (const step of [...completed].reverse()) {
|
|
268
272
|
if (!step.rollback) continue
|
|
@@ -230,7 +230,6 @@ export class PhaseService extends Effect.Service<PhaseService>()(
|
|
|
230
230
|
base: taskData.base,
|
|
231
231
|
pr: taskData.pr,
|
|
232
232
|
status: taskData.status,
|
|
233
|
-
...(taskData.claim ? { claim: taskData.claim } : {}),
|
|
234
233
|
...(taskData.completion
|
|
235
234
|
? { completion: taskData.completion }
|
|
236
235
|
: {}),
|
|
@@ -515,16 +514,10 @@ export class PhaseService extends Effect.Service<PhaseService>()(
|
|
|
515
514
|
const validStatus = yield* decodeStatus(status)
|
|
516
515
|
if (validStatus === "delegated") {
|
|
517
516
|
return yield* new PhaseError({
|
|
518
|
-
message:
|
|
519
|
-
"Delegation requires explicit ownership; use 'agency claim'",
|
|
517
|
+
message: "Delegated status cannot be set directly",
|
|
520
518
|
})
|
|
521
519
|
}
|
|
522
520
|
const record = yield* service.show(taskId, id, startPath)
|
|
523
|
-
if (record.data.claim?.state === "active") {
|
|
524
|
-
return yield* new PhaseError({
|
|
525
|
-
message: `Phase '${id}' has an active claim; use agency release or agency finish`,
|
|
526
|
-
})
|
|
527
|
-
}
|
|
528
521
|
if (nonPrCompletion && validStatus !== "done") {
|
|
529
522
|
return yield* new PhaseError({
|
|
530
523
|
message: "Non-PR completion is valid only with a done status",
|
|
@@ -224,40 +224,6 @@ describe("ReadinessService", () => {
|
|
|
224
224
|
readiness.guardWorkTarget("execution-unit:phase/ship/implement", root),
|
|
225
225
|
)
|
|
226
226
|
|
|
227
|
-
await write(
|
|
228
|
-
root,
|
|
229
|
-
"tasks/ship/phases/implement/PHASE.md",
|
|
230
|
-
`---
|
|
231
|
-
repo: agency
|
|
232
|
-
branch: feat/implement
|
|
233
|
-
base: main
|
|
234
|
-
pr: null
|
|
235
|
-
status: working
|
|
236
|
-
claim:
|
|
237
|
-
claimant: orchestrator
|
|
238
|
-
agent: opencode
|
|
239
|
-
sessionId: session-1
|
|
240
|
-
startedAt: 2026-07-20T00:00:00.000Z
|
|
241
|
-
targetRevision: ${"a".repeat(64)}
|
|
242
|
-
state: active
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
# Execution
|
|
246
|
-
`,
|
|
247
|
-
)
|
|
248
|
-
expect(
|
|
249
|
-
await service((readiness) => readiness.getWorkTargetIds(root)),
|
|
250
|
-
).not.toContain("execution-unit:phase/ship/implement")
|
|
251
|
-
await expect(
|
|
252
|
-
service((readiness) =>
|
|
253
|
-
readiness.guardWorkTarget(
|
|
254
|
-
"execution-unit:phase/ship/implement",
|
|
255
|
-
root,
|
|
256
|
-
true,
|
|
257
|
-
),
|
|
258
|
-
),
|
|
259
|
-
).rejects.toThrow("active claim")
|
|
260
|
-
|
|
261
227
|
const blocked = await service((readiness) =>
|
|
262
228
|
Effect.either(readiness.guardWorkTarget("phase:ship/verify", root)),
|
|
263
229
|
)
|
|
@@ -46,22 +46,13 @@ const executionNodeId = (taskId: string, phaseId?: string) =>
|
|
|
46
46
|
? `execution-unit:phase/${taskId}/${phaseId}`
|
|
47
47
|
: `execution-unit:task/${taskId}`
|
|
48
48
|
|
|
49
|
-
const hasActiveClaim = (node: GraphNode) =>
|
|
50
|
-
node.kind !== "epic" &&
|
|
51
|
-
node.kind !== "repository" &&
|
|
52
|
-
"claim" in node.data &&
|
|
53
|
-
node.data.claim?.state === "active"
|
|
54
|
-
|
|
55
49
|
const isResumableWork = (node: GraphNode) =>
|
|
56
50
|
node.kind !== "repository" &&
|
|
57
51
|
node.status === "working" &&
|
|
58
|
-
!hasActiveClaim(node) &&
|
|
59
52
|
node.readiness.blockers.every((blocker) => blocker.kind !== "validation")
|
|
60
53
|
|
|
61
54
|
const isWorkTarget = (node: GraphNode) =>
|
|
62
|
-
node.kind !== "repository" &&
|
|
63
|
-
!hasActiveClaim(node) &&
|
|
64
|
-
(node.readiness.ready || isResumableWork(node))
|
|
55
|
+
node.kind !== "repository" && (node.readiness.ready || isResumableWork(node))
|
|
65
56
|
|
|
66
57
|
const itemFor = (
|
|
67
58
|
node: ExecutionNode,
|
|
@@ -200,16 +191,6 @@ export class ReadinessService extends Effect.Service<ReadinessService>()(
|
|
|
200
191
|
blockers: [],
|
|
201
192
|
})
|
|
202
193
|
}
|
|
203
|
-
if (hasActiveClaim(node)) {
|
|
204
|
-
return yield* new ExecutionGuardError({
|
|
205
|
-
message: `Cannot work on '${node.key}': it has an active claim. Use agency release or agency finish first.`,
|
|
206
|
-
action: "work",
|
|
207
|
-
target,
|
|
208
|
-
status: node.status!,
|
|
209
|
-
blockedBy: node.readiness!.blockedBy,
|
|
210
|
-
blockers: node.readiness!.blockers,
|
|
211
|
-
})
|
|
212
|
-
}
|
|
213
194
|
if (override) return
|
|
214
195
|
if (!node.readiness.ready && !isResumableWork(node)) {
|
|
215
196
|
const item = {
|
|
@@ -11,7 +11,6 @@ import { GraphService } from "./GraphService"
|
|
|
11
11
|
import { PullRequestService } from "./PullRequestService"
|
|
12
12
|
import { PhaseService } from "./PhaseService"
|
|
13
13
|
import { ArchiveService } from "./ArchiveService"
|
|
14
|
-
import { ClaimService } from "./ClaimService"
|
|
15
14
|
import { SyncService } from "./SyncService"
|
|
16
15
|
import { task as taskCommand } from "../commands/task"
|
|
17
16
|
|
|
@@ -183,69 +182,6 @@ describe("ReviewService", () => {
|
|
|
183
182
|
).rejects.toThrow("cannot be converted to phases")
|
|
184
183
|
})
|
|
185
184
|
|
|
186
|
-
test("participates in claim lifecycle", async () => {
|
|
187
|
-
const task = await createReview()
|
|
188
|
-
const claimed = await runTestEffect(
|
|
189
|
-
ClaimService.pipe(
|
|
190
|
-
Effect.flatMap((service) =>
|
|
191
|
-
service.claim(
|
|
192
|
-
{
|
|
193
|
-
taskId: "review",
|
|
194
|
-
claimant: "reviewer",
|
|
195
|
-
agent: "opencode",
|
|
196
|
-
sessionId: "session",
|
|
197
|
-
revision: task.revision,
|
|
198
|
-
},
|
|
199
|
-
root,
|
|
200
|
-
),
|
|
201
|
-
),
|
|
202
|
-
),
|
|
203
|
-
)
|
|
204
|
-
expect(claimed.data.status).toBe("working")
|
|
205
|
-
const released = await runTestEffect(
|
|
206
|
-
ClaimService.pipe(
|
|
207
|
-
Effect.flatMap((service) =>
|
|
208
|
-
service.release(
|
|
209
|
-
{
|
|
210
|
-
taskId: "review",
|
|
211
|
-
sessionId: "session",
|
|
212
|
-
revision: claimed.revision,
|
|
213
|
-
},
|
|
214
|
-
root,
|
|
215
|
-
),
|
|
216
|
-
),
|
|
217
|
-
),
|
|
218
|
-
)
|
|
219
|
-
expect(released.data.status).toBe("open")
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
test("rejects refresh while actively claimed", async () => {
|
|
223
|
-
const task = await createReview()
|
|
224
|
-
await runTestEffect(
|
|
225
|
-
ClaimService.pipe(
|
|
226
|
-
Effect.flatMap((service) =>
|
|
227
|
-
service.claim(
|
|
228
|
-
{
|
|
229
|
-
taskId: "review",
|
|
230
|
-
claimant: "reviewer",
|
|
231
|
-
agent: "opencode",
|
|
232
|
-
sessionId: "active",
|
|
233
|
-
revision: task.revision,
|
|
234
|
-
},
|
|
235
|
-
root,
|
|
236
|
-
),
|
|
237
|
-
),
|
|
238
|
-
),
|
|
239
|
-
)
|
|
240
|
-
await expect(
|
|
241
|
-
runTestEffect(
|
|
242
|
-
ReviewService.pipe(
|
|
243
|
-
Effect.flatMap((service) => service.refresh("review", root)),
|
|
244
|
-
),
|
|
245
|
-
),
|
|
246
|
-
).rejects.toThrow("active claim")
|
|
247
|
-
})
|
|
248
|
-
|
|
249
185
|
test("rolls back document and checkout when pin advancement fails", async () => {
|
|
250
186
|
const created = await createReview()
|
|
251
187
|
const workspace = await runTestEffect(
|
|
@@ -302,11 +302,6 @@ export class ReviewService extends Effect.Service<ReviewService>()(
|
|
|
302
302
|
})
|
|
303
303
|
}
|
|
304
304
|
const previousReview = task.data.review
|
|
305
|
-
if (task.data.claim?.state === "active") {
|
|
306
|
-
return yield* new ReviewError({
|
|
307
|
-
message: `Review task '${taskId}' has an active claim; release or finish it before refreshing`,
|
|
308
|
-
})
|
|
309
|
-
}
|
|
310
305
|
if (ifRevision && task.revision !== ifRevision) {
|
|
311
306
|
return yield* new RevisionConflictError({
|
|
312
307
|
path: task.path,
|