@pennixrv/trellis 0.7.2-beta.31 → 0.7.2-beta.33
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/dist/commands/teamwork/artifact.d.ts +7 -1
- package/dist/commands/teamwork/artifact.d.ts.map +1 -1
- package/dist/commands/teamwork/artifact.js +9 -3
- package/dist/commands/teamwork/artifact.js.map +1 -1
- package/dist/commands/teamwork/batch.d.ts.map +1 -1
- package/dist/commands/teamwork/batch.js +63 -18
- package/dist/commands/teamwork/batch.js.map +1 -1
- package/dist/commands/teamwork/context-loader.d.ts.map +1 -1
- package/dist/commands/teamwork/context-loader.js +4 -1
- package/dist/commands/teamwork/context-loader.js.map +1 -1
- package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
- package/dist/commands/teamwork/coordinator.js +152 -13
- package/dist/commands/teamwork/coordinator.js.map +1 -1
- package/dist/commands/teamwork/plan.d.ts.map +1 -1
- package/dist/commands/teamwork/plan.js +9 -1
- package/dist/commands/teamwork/plan.js.map +1 -1
- package/dist/commands/teamwork/text-body.d.ts.map +1 -1
- package/dist/commands/teamwork/text-body.js +4 -2
- package/dist/commands/teamwork/text-body.js.map +1 -1
- package/dist/migrations/manifests/0.7.2-beta.32.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.33.json +9 -0
- package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/workflow.md +2 -2
- package/dist/templates/trellis/scripts/common/worktree_delegation.py +3 -2
- package/dist/templates/trellis/scripts/common/worktree_delegation_contract.py +12 -2
- package/dist/templates/trellis/scripts/common/worktree_delegation_messages.py +3 -2
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
import { isTaskPhaseId, parseTaskWorkflowState, } from "@pennixrv/trellis-core/task";
|
|
6
|
-
import { assertCoordinationTransition, readTeamworkEvents, readCoordinationState, recordCoordinationEvent, } from "@pennixrv/trellis-core/teamwork";
|
|
6
|
+
import { assertCoordinationTransition, readTeamworkEvents, readCoordinationState, recordCoordinationEvent, resolveTeamworkBatchSession, } from "@pennixrv/trellis-core/teamwork";
|
|
7
7
|
import { TeammateReportReadError, readTeammateReport, writeTeammateQueueFact, writeTeammateClaim, writeTeammateDisposition, validateTeamworkPlan, } from "./artifact.js";
|
|
8
8
|
import { assertTeammateAdapterContract, assertTeammateHostCapability, } from "./teammate-adapters.js";
|
|
9
9
|
import { effectiveTeammateCapacity, resolveTeammateRuntimeConfig, } from "./teammate-config.js";
|
|
@@ -165,12 +165,19 @@ function reconciliationReceipt(plan, projection, capacity) {
|
|
|
165
165
|
}
|
|
166
166
|
async function recordRecoveryReconciliation(input) {
|
|
167
167
|
const { plan, cwd, by, existingState, projection, capacity, reason } = input;
|
|
168
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
169
|
+
sessionId: plan.sessionId,
|
|
170
|
+
batchId: plan.batchId,
|
|
171
|
+
planHash: plan.planHash,
|
|
172
|
+
cwd,
|
|
173
|
+
});
|
|
168
174
|
if (existingState !== "RECONCILIATION_REQUIRED" &&
|
|
169
175
|
existingState !== "AWAITING_REVIEW" &&
|
|
170
176
|
existingState !== "ALL_ACCEPTED" &&
|
|
171
177
|
existingState !== "SETTLED_WITH_FAILURE") {
|
|
172
178
|
await appendTransition({
|
|
173
179
|
sessionId: plan.sessionId,
|
|
180
|
+
projectKey,
|
|
174
181
|
cwd,
|
|
175
182
|
by,
|
|
176
183
|
batchId: plan.batchId,
|
|
@@ -185,6 +192,7 @@ async function recordRecoveryReconciliation(input) {
|
|
|
185
192
|
const receipt = reconciliationReceipt(plan, projection, capacity);
|
|
186
193
|
await appendAction({
|
|
187
194
|
sessionId: plan.sessionId,
|
|
195
|
+
projectKey,
|
|
188
196
|
cwd,
|
|
189
197
|
by,
|
|
190
198
|
batchId: plan.batchId,
|
|
@@ -194,6 +202,7 @@ async function recordRecoveryReconciliation(input) {
|
|
|
194
202
|
});
|
|
195
203
|
await appendAction({
|
|
196
204
|
sessionId: plan.sessionId,
|
|
205
|
+
projectKey,
|
|
197
206
|
cwd,
|
|
198
207
|
by,
|
|
199
208
|
batchId: plan.batchId,
|
|
@@ -205,8 +214,15 @@ async function recordRecoveryReconciliation(input) {
|
|
|
205
214
|
return receipt;
|
|
206
215
|
}
|
|
207
216
|
async function recoverExistingBatch(input) {
|
|
217
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
218
|
+
sessionId: input.plan.sessionId,
|
|
219
|
+
batchId: input.plan.batchId,
|
|
220
|
+
planHash: input.plan.planHash,
|
|
221
|
+
cwd: input.cwd,
|
|
222
|
+
});
|
|
208
223
|
const projection = await readCoordinationState({
|
|
209
224
|
sessionId: input.plan.sessionId,
|
|
225
|
+
projectKey,
|
|
210
226
|
cwd: input.cwd,
|
|
211
227
|
});
|
|
212
228
|
const existing = projection.batches.find((batch) => batch.batchId === input.plan.batchId);
|
|
@@ -217,6 +233,7 @@ async function recoverExistingBatch(input) {
|
|
|
217
233
|
}
|
|
218
234
|
const events = await readTeamworkEvents({
|
|
219
235
|
sessionId: input.plan.sessionId,
|
|
236
|
+
projectKey,
|
|
220
237
|
cwd: input.cwd,
|
|
221
238
|
});
|
|
222
239
|
if (existing.state === "AWAITING_REVIEW" ||
|
|
@@ -251,6 +268,7 @@ async function recoverExistingBatch(input) {
|
|
|
251
268
|
if (receipts.length === 0) {
|
|
252
269
|
await appendAction({
|
|
253
270
|
sessionId: input.plan.sessionId,
|
|
271
|
+
projectKey,
|
|
254
272
|
cwd: input.cwd,
|
|
255
273
|
by: input.by,
|
|
256
274
|
batchId: input.plan.batchId,
|
|
@@ -278,6 +296,7 @@ async function appendTransition(input) {
|
|
|
278
296
|
transitionState(input.states, input.id, input.state, input.entity);
|
|
279
297
|
await recordCoordinationEvent({
|
|
280
298
|
sessionId: input.sessionId,
|
|
299
|
+
projectKey: input.projectKey,
|
|
281
300
|
...(input.cwd ? { cwd: input.cwd } : {}),
|
|
282
301
|
by: input.by,
|
|
283
302
|
batchId: input.batchId,
|
|
@@ -301,6 +320,7 @@ async function appendTransition(input) {
|
|
|
301
320
|
async function appendAction(input) {
|
|
302
321
|
await recordCoordinationEvent({
|
|
303
322
|
sessionId: input.sessionId,
|
|
323
|
+
projectKey: input.projectKey,
|
|
304
324
|
...(input.cwd ? { cwd: input.cwd } : {}),
|
|
305
325
|
by: input.by,
|
|
306
326
|
batchId: input.batchId,
|
|
@@ -343,6 +363,12 @@ export async function runTeamworkCoordinator(input) {
|
|
|
343
363
|
});
|
|
344
364
|
assertTeamworkPlanCurrent(plan, input.taskRoot);
|
|
345
365
|
const cwd = input.cwd ?? input.taskRoot;
|
|
366
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
367
|
+
sessionId: plan.sessionId,
|
|
368
|
+
batchId: plan.batchId,
|
|
369
|
+
planHash: plan.planHash,
|
|
370
|
+
cwd,
|
|
371
|
+
});
|
|
346
372
|
const frozenLaunches = new Map();
|
|
347
373
|
for (const assignment of plan.assignments) {
|
|
348
374
|
assertTeammateAdapterContract(assignment.provider);
|
|
@@ -360,6 +386,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
360
386
|
const by = input.by ?? "main";
|
|
361
387
|
const existing = await readCoordinationState({
|
|
362
388
|
sessionId: plan.sessionId,
|
|
389
|
+
projectKey,
|
|
363
390
|
cwd,
|
|
364
391
|
});
|
|
365
392
|
const settled = existing.batches.find((batch) => batch.batchId === plan.batchId);
|
|
@@ -436,6 +463,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
436
463
|
}
|
|
437
464
|
await appendTransition({
|
|
438
465
|
sessionId: plan.sessionId,
|
|
466
|
+
projectKey,
|
|
439
467
|
by,
|
|
440
468
|
batchId: plan.batchId,
|
|
441
469
|
entity: "batch",
|
|
@@ -455,6 +483,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
455
483
|
});
|
|
456
484
|
await appendTransition({
|
|
457
485
|
sessionId: plan.sessionId,
|
|
486
|
+
projectKey,
|
|
458
487
|
by,
|
|
459
488
|
batchId: plan.batchId,
|
|
460
489
|
entity: "batch",
|
|
@@ -466,6 +495,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
466
495
|
for (const assignment of plan.assignments) {
|
|
467
496
|
await appendTransition({
|
|
468
497
|
sessionId: plan.sessionId,
|
|
498
|
+
projectKey,
|
|
469
499
|
by,
|
|
470
500
|
batchId: plan.batchId,
|
|
471
501
|
entity: "assignment",
|
|
@@ -477,6 +507,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
477
507
|
});
|
|
478
508
|
await appendAction({
|
|
479
509
|
sessionId: plan.sessionId,
|
|
510
|
+
projectKey,
|
|
480
511
|
by,
|
|
481
512
|
batchId: plan.batchId,
|
|
482
513
|
entity: "assignment",
|
|
@@ -487,6 +518,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
487
518
|
}
|
|
488
519
|
await appendTransition({
|
|
489
520
|
sessionId: plan.sessionId,
|
|
521
|
+
projectKey,
|
|
490
522
|
by,
|
|
491
523
|
batchId: plan.batchId,
|
|
492
524
|
entity: "batch",
|
|
@@ -504,6 +536,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
504
536
|
async function reconcile(reason) {
|
|
505
537
|
await appendAction({
|
|
506
538
|
sessionId: plan.sessionId,
|
|
539
|
+
projectKey,
|
|
507
540
|
by,
|
|
508
541
|
batchId: plan.batchId,
|
|
509
542
|
entity: "batch",
|
|
@@ -513,6 +546,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
513
546
|
if (batchStates.get(plan.batchId) !== "RECONCILIATION_REQUIRED") {
|
|
514
547
|
await appendTransition({
|
|
515
548
|
sessionId: plan.sessionId,
|
|
549
|
+
projectKey,
|
|
516
550
|
by,
|
|
517
551
|
batchId: plan.batchId,
|
|
518
552
|
entity: "batch",
|
|
@@ -534,6 +568,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
534
568
|
};
|
|
535
569
|
await appendAction({
|
|
536
570
|
sessionId: plan.sessionId,
|
|
571
|
+
projectKey,
|
|
537
572
|
by,
|
|
538
573
|
batchId: plan.batchId,
|
|
539
574
|
entity: "batch",
|
|
@@ -551,6 +586,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
551
586
|
continue;
|
|
552
587
|
await appendTransition({
|
|
553
588
|
sessionId: plan.sessionId,
|
|
589
|
+
projectKey,
|
|
554
590
|
by,
|
|
555
591
|
batchId: plan.batchId,
|
|
556
592
|
entity: "assignment",
|
|
@@ -592,6 +628,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
592
628
|
input.runtime.prepare?.(context);
|
|
593
629
|
await appendTransition({
|
|
594
630
|
sessionId: plan.sessionId,
|
|
631
|
+
projectKey,
|
|
595
632
|
by,
|
|
596
633
|
batchId: plan.batchId,
|
|
597
634
|
entity: "assignment",
|
|
@@ -607,6 +644,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
607
644
|
});
|
|
608
645
|
await appendTransition({
|
|
609
646
|
sessionId: plan.sessionId,
|
|
647
|
+
projectKey,
|
|
610
648
|
by,
|
|
611
649
|
batchId: plan.batchId,
|
|
612
650
|
entity: "attempt",
|
|
@@ -620,6 +658,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
620
658
|
});
|
|
621
659
|
await appendTransition({
|
|
622
660
|
sessionId: plan.sessionId,
|
|
661
|
+
projectKey,
|
|
623
662
|
by,
|
|
624
663
|
batchId: plan.batchId,
|
|
625
664
|
entity: "teammate",
|
|
@@ -648,6 +687,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
648
687
|
});
|
|
649
688
|
await appendAction({
|
|
650
689
|
sessionId: plan.sessionId,
|
|
690
|
+
projectKey,
|
|
651
691
|
by,
|
|
652
692
|
batchId: plan.batchId,
|
|
653
693
|
entity: "attempt",
|
|
@@ -659,6 +699,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
659
699
|
});
|
|
660
700
|
await appendAction({
|
|
661
701
|
sessionId: plan.sessionId,
|
|
702
|
+
projectKey,
|
|
662
703
|
by,
|
|
663
704
|
batchId: plan.batchId,
|
|
664
705
|
entity: "attempt",
|
|
@@ -672,6 +713,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
672
713
|
context.providerSessionId = launchReceipt.providerSessionId;
|
|
673
714
|
await appendTransition({
|
|
674
715
|
sessionId: plan.sessionId,
|
|
716
|
+
projectKey,
|
|
675
717
|
by,
|
|
676
718
|
batchId: plan.batchId,
|
|
677
719
|
entity: "attempt",
|
|
@@ -688,6 +730,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
688
730
|
});
|
|
689
731
|
await appendTransition({
|
|
690
732
|
sessionId: plan.sessionId,
|
|
733
|
+
projectKey,
|
|
691
734
|
by,
|
|
692
735
|
batchId: plan.batchId,
|
|
693
736
|
entity: "teammate",
|
|
@@ -702,6 +745,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
702
745
|
});
|
|
703
746
|
await appendTransition({
|
|
704
747
|
sessionId: plan.sessionId,
|
|
748
|
+
projectKey,
|
|
705
749
|
by,
|
|
706
750
|
batchId: plan.batchId,
|
|
707
751
|
entity: "assignment",
|
|
@@ -746,6 +790,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
746
790
|
return;
|
|
747
791
|
await appendAction({
|
|
748
792
|
sessionId: plan.sessionId,
|
|
793
|
+
projectKey,
|
|
749
794
|
by,
|
|
750
795
|
batchId: plan.batchId,
|
|
751
796
|
entity: "attempt",
|
|
@@ -773,6 +818,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
773
818
|
const transitionKey = `continuation:${current.continuations}`;
|
|
774
819
|
await appendTransition({
|
|
775
820
|
sessionId: plan.sessionId,
|
|
821
|
+
projectKey,
|
|
776
822
|
by,
|
|
777
823
|
batchId: plan.batchId,
|
|
778
824
|
entity: "attempt",
|
|
@@ -790,6 +836,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
790
836
|
});
|
|
791
837
|
await appendTransition({
|
|
792
838
|
sessionId: plan.sessionId,
|
|
839
|
+
projectKey,
|
|
793
840
|
by,
|
|
794
841
|
batchId: plan.batchId,
|
|
795
842
|
entity: "teammate",
|
|
@@ -805,6 +852,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
805
852
|
});
|
|
806
853
|
await appendTransition({
|
|
807
854
|
sessionId: plan.sessionId,
|
|
855
|
+
projectKey,
|
|
808
856
|
by,
|
|
809
857
|
batchId: plan.batchId,
|
|
810
858
|
entity: "assignment",
|
|
@@ -826,6 +874,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
826
874
|
if (batchStates.get(plan.batchId) === "RUNNING") {
|
|
827
875
|
await appendTransition({
|
|
828
876
|
sessionId: plan.sessionId,
|
|
877
|
+
projectKey,
|
|
829
878
|
by,
|
|
830
879
|
batchId: plan.batchId,
|
|
831
880
|
entity: "batch",
|
|
@@ -903,6 +952,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
903
952
|
const { assignment, context, retryCount } = activeWork;
|
|
904
953
|
await appendTransition({
|
|
905
954
|
sessionId: plan.sessionId,
|
|
955
|
+
projectKey,
|
|
906
956
|
by,
|
|
907
957
|
batchId: plan.batchId,
|
|
908
958
|
entity: "attempt",
|
|
@@ -920,6 +970,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
920
970
|
});
|
|
921
971
|
await appendTransition({
|
|
922
972
|
sessionId: plan.sessionId,
|
|
973
|
+
projectKey,
|
|
923
974
|
by,
|
|
924
975
|
batchId: plan.batchId,
|
|
925
976
|
entity: "teammate",
|
|
@@ -955,6 +1006,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
955
1006
|
});
|
|
956
1007
|
await appendTransition({
|
|
957
1008
|
sessionId: plan.sessionId,
|
|
1009
|
+
projectKey,
|
|
958
1010
|
by,
|
|
959
1011
|
batchId: plan.batchId,
|
|
960
1012
|
entity: "attempt",
|
|
@@ -969,6 +1021,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
969
1021
|
});
|
|
970
1022
|
await appendTransition({
|
|
971
1023
|
sessionId: plan.sessionId,
|
|
1024
|
+
projectKey,
|
|
972
1025
|
by,
|
|
973
1026
|
batchId: plan.batchId,
|
|
974
1027
|
entity: "assignment",
|
|
@@ -993,6 +1046,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
993
1046
|
}
|
|
994
1047
|
await appendTransition({
|
|
995
1048
|
sessionId: plan.sessionId,
|
|
1049
|
+
projectKey,
|
|
996
1050
|
by,
|
|
997
1051
|
batchId: plan.batchId,
|
|
998
1052
|
entity: "assignment",
|
|
@@ -1011,6 +1065,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1011
1065
|
const { assignment, context, retryCount } = activeWork;
|
|
1012
1066
|
await recordCoordinationEvent({
|
|
1013
1067
|
sessionId: plan.sessionId,
|
|
1068
|
+
projectKey,
|
|
1014
1069
|
by,
|
|
1015
1070
|
batchId: plan.batchId,
|
|
1016
1071
|
entity: "attempt",
|
|
@@ -1062,6 +1117,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1062
1117
|
}
|
|
1063
1118
|
await appendTransition({
|
|
1064
1119
|
sessionId: plan.sessionId,
|
|
1120
|
+
projectKey,
|
|
1065
1121
|
by,
|
|
1066
1122
|
batchId: plan.batchId,
|
|
1067
1123
|
entity: "teammate",
|
|
@@ -1077,6 +1133,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1077
1133
|
});
|
|
1078
1134
|
await appendTransition({
|
|
1079
1135
|
sessionId: plan.sessionId,
|
|
1136
|
+
projectKey,
|
|
1080
1137
|
by,
|
|
1081
1138
|
batchId: plan.batchId,
|
|
1082
1139
|
entity: "attempt",
|
|
@@ -1094,6 +1151,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1094
1151
|
});
|
|
1095
1152
|
await appendTransition({
|
|
1096
1153
|
sessionId: plan.sessionId,
|
|
1154
|
+
projectKey,
|
|
1097
1155
|
by,
|
|
1098
1156
|
batchId: plan.batchId,
|
|
1099
1157
|
entity: "assignment",
|
|
@@ -1107,6 +1165,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1107
1165
|
});
|
|
1108
1166
|
await appendTransition({
|
|
1109
1167
|
sessionId: plan.sessionId,
|
|
1168
|
+
projectKey,
|
|
1110
1169
|
by,
|
|
1111
1170
|
batchId: plan.batchId,
|
|
1112
1171
|
entity: "assignment",
|
|
@@ -1123,6 +1182,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1123
1182
|
async function settle() {
|
|
1124
1183
|
await appendTransition({
|
|
1125
1184
|
sessionId: plan.sessionId,
|
|
1185
|
+
projectKey,
|
|
1126
1186
|
by,
|
|
1127
1187
|
batchId: plan.batchId,
|
|
1128
1188
|
entity: "batch",
|
|
@@ -1134,6 +1194,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1134
1194
|
const status = pendingReview ? "AWAITING_REVIEW" : "SETTLED_WITH_FAILURE";
|
|
1135
1195
|
await appendTransition({
|
|
1136
1196
|
sessionId: plan.sessionId,
|
|
1197
|
+
projectKey,
|
|
1137
1198
|
by,
|
|
1138
1199
|
batchId: plan.batchId,
|
|
1139
1200
|
entity: "batch",
|
|
@@ -1141,9 +1202,14 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1141
1202
|
state: status,
|
|
1142
1203
|
states: batchStates,
|
|
1143
1204
|
});
|
|
1144
|
-
const receipt = terminalReceiptFromProjection(plan, await readCoordinationState({
|
|
1205
|
+
const receipt = terminalReceiptFromProjection(plan, await readCoordinationState({
|
|
1206
|
+
sessionId: plan.sessionId,
|
|
1207
|
+
projectKey,
|
|
1208
|
+
cwd,
|
|
1209
|
+
}));
|
|
1145
1210
|
await appendAction({
|
|
1146
1211
|
sessionId: plan.sessionId,
|
|
1212
|
+
projectKey,
|
|
1147
1213
|
by,
|
|
1148
1214
|
batchId: plan.batchId,
|
|
1149
1215
|
entity: "batch",
|
|
@@ -1192,6 +1258,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1192
1258
|
pending.shift();
|
|
1193
1259
|
await appendTransition({
|
|
1194
1260
|
sessionId: plan.sessionId,
|
|
1261
|
+
projectKey,
|
|
1195
1262
|
by,
|
|
1196
1263
|
batchId: plan.batchId,
|
|
1197
1264
|
entity: "assignment",
|
|
@@ -1280,6 +1347,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1280
1347
|
const transitionKey = `continuation:${current.continuations}`;
|
|
1281
1348
|
await appendTransition({
|
|
1282
1349
|
sessionId: plan.sessionId,
|
|
1350
|
+
projectKey,
|
|
1283
1351
|
by,
|
|
1284
1352
|
batchId: plan.batchId,
|
|
1285
1353
|
entity: "attempt",
|
|
@@ -1297,6 +1365,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1297
1365
|
});
|
|
1298
1366
|
await appendTransition({
|
|
1299
1367
|
sessionId: plan.sessionId,
|
|
1368
|
+
projectKey,
|
|
1300
1369
|
by,
|
|
1301
1370
|
batchId: plan.batchId,
|
|
1302
1371
|
entity: "teammate",
|
|
@@ -1312,6 +1381,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1312
1381
|
});
|
|
1313
1382
|
await appendTransition({
|
|
1314
1383
|
sessionId: plan.sessionId,
|
|
1384
|
+
projectKey,
|
|
1315
1385
|
by,
|
|
1316
1386
|
batchId: plan.batchId,
|
|
1317
1387
|
entity: "assignment",
|
|
@@ -1329,6 +1399,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1329
1399
|
});
|
|
1330
1400
|
await appendTransition({
|
|
1331
1401
|
sessionId: plan.sessionId,
|
|
1402
|
+
projectKey,
|
|
1332
1403
|
by,
|
|
1333
1404
|
batchId: plan.batchId,
|
|
1334
1405
|
entity: "attempt",
|
|
@@ -1346,6 +1417,7 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1346
1417
|
});
|
|
1347
1418
|
await appendTransition({
|
|
1348
1419
|
sessionId: plan.sessionId,
|
|
1420
|
+
projectKey,
|
|
1349
1421
|
by,
|
|
1350
1422
|
batchId: plan.batchId,
|
|
1351
1423
|
entity: "teammate",
|
|
@@ -1407,13 +1479,21 @@ export async function runTeamworkCoordinator(input) {
|
|
|
1407
1479
|
return settle();
|
|
1408
1480
|
}
|
|
1409
1481
|
export async function assertTeamworkReceiptDurable(plan, receipt, cwd) {
|
|
1482
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
1483
|
+
sessionId: plan.sessionId,
|
|
1484
|
+
batchId: plan.batchId,
|
|
1485
|
+
planHash: plan.planHash,
|
|
1486
|
+
cwd,
|
|
1487
|
+
});
|
|
1410
1488
|
const [state, events] = await Promise.all([
|
|
1411
1489
|
readCoordinationState({
|
|
1412
1490
|
sessionId: plan.sessionId,
|
|
1491
|
+
projectKey,
|
|
1413
1492
|
...(cwd ? { cwd } : {}),
|
|
1414
1493
|
}),
|
|
1415
1494
|
readTeamworkEvents({
|
|
1416
1495
|
sessionId: plan.sessionId,
|
|
1496
|
+
projectKey,
|
|
1417
1497
|
...(cwd ? { cwd } : {}),
|
|
1418
1498
|
}),
|
|
1419
1499
|
]);
|
|
@@ -1432,14 +1512,25 @@ export async function assertTeamworkReceiptDurable(plan, receipt, cwd) {
|
|
|
1432
1512
|
/** Retire uncertain work only from associated terminal or process-birth evidence. */
|
|
1433
1513
|
export async function reconcileTeamworkBatch(input) {
|
|
1434
1514
|
const { plan, cwd } = input;
|
|
1515
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
1516
|
+
sessionId: plan.sessionId,
|
|
1517
|
+
batchId: plan.batchId,
|
|
1518
|
+
planHash: plan.planHash,
|
|
1519
|
+
cwd,
|
|
1520
|
+
});
|
|
1435
1521
|
const projection = await readCoordinationState({
|
|
1436
1522
|
sessionId: plan.sessionId,
|
|
1523
|
+
projectKey,
|
|
1437
1524
|
cwd,
|
|
1438
1525
|
});
|
|
1439
1526
|
const batch = projection.batches.find((entry) => entry.batchId === plan.batchId);
|
|
1440
1527
|
if (batch?.planHash !== plan.planHash)
|
|
1441
1528
|
throw new Error("Batch does not match the frozen plan");
|
|
1442
|
-
const events = await readTeamworkEvents({
|
|
1529
|
+
const events = await readTeamworkEvents({
|
|
1530
|
+
sessionId: plan.sessionId,
|
|
1531
|
+
projectKey,
|
|
1532
|
+
cwd,
|
|
1533
|
+
});
|
|
1443
1534
|
const resolving = events.some((event) => event.kind === "coordination" &&
|
|
1444
1535
|
event.batchId === plan.batchId &&
|
|
1445
1536
|
event.action === "reconciliation_resolved");
|
|
@@ -1539,6 +1630,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1539
1630
|
for (const attempt of attempts) {
|
|
1540
1631
|
await recordCoordinationEvent({
|
|
1541
1632
|
sessionId: plan.sessionId,
|
|
1633
|
+
projectKey,
|
|
1542
1634
|
cwd,
|
|
1543
1635
|
by,
|
|
1544
1636
|
batchId: plan.batchId,
|
|
@@ -1553,6 +1645,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1553
1645
|
if (!["FINAL_FAILED", "REPORT_SUBMITTED"].includes(attempt.state))
|
|
1554
1646
|
await appendTransition({
|
|
1555
1647
|
sessionId: plan.sessionId,
|
|
1648
|
+
projectKey,
|
|
1556
1649
|
cwd,
|
|
1557
1650
|
by,
|
|
1558
1651
|
batchId: plan.batchId,
|
|
@@ -1572,6 +1665,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1572
1665
|
if (teammate && !["FAILED", "REPORT_SUBMITTED"].includes(teammate.state))
|
|
1573
1666
|
await appendTransition({
|
|
1574
1667
|
sessionId: plan.sessionId,
|
|
1668
|
+
projectKey,
|
|
1575
1669
|
cwd,
|
|
1576
1670
|
by,
|
|
1577
1671
|
batchId: plan.batchId,
|
|
@@ -1589,6 +1683,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1589
1683
|
if (!["ACCEPTED", "FINAL_FAILED"].includes(assignment.state))
|
|
1590
1684
|
await appendTransition({
|
|
1591
1685
|
sessionId: plan.sessionId,
|
|
1686
|
+
projectKey,
|
|
1592
1687
|
cwd,
|
|
1593
1688
|
by,
|
|
1594
1689
|
batchId: plan.batchId,
|
|
@@ -1607,6 +1702,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1607
1702
|
for (const lease of projection.leases.filter((entry) => entry.batchId === plan.batchId))
|
|
1608
1703
|
await recordCoordinationEvent({
|
|
1609
1704
|
sessionId: plan.sessionId,
|
|
1705
|
+
projectKey,
|
|
1610
1706
|
cwd,
|
|
1611
1707
|
by,
|
|
1612
1708
|
batchId: plan.batchId,
|
|
@@ -1625,6 +1721,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1625
1721
|
]);
|
|
1626
1722
|
await recordCoordinationEvent({
|
|
1627
1723
|
sessionId: plan.sessionId,
|
|
1724
|
+
projectKey,
|
|
1628
1725
|
cwd,
|
|
1629
1726
|
by,
|
|
1630
1727
|
batchId: plan.batchId,
|
|
@@ -1642,6 +1739,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1642
1739
|
if (batch.state !== "SETTLING")
|
|
1643
1740
|
await appendTransition({
|
|
1644
1741
|
sessionId: plan.sessionId,
|
|
1742
|
+
projectKey,
|
|
1645
1743
|
cwd,
|
|
1646
1744
|
by,
|
|
1647
1745
|
batchId: plan.batchId,
|
|
@@ -1653,6 +1751,7 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1653
1751
|
});
|
|
1654
1752
|
await appendTransition({
|
|
1655
1753
|
sessionId: plan.sessionId,
|
|
1754
|
+
projectKey,
|
|
1656
1755
|
cwd,
|
|
1657
1756
|
by,
|
|
1658
1757
|
batchId: plan.batchId,
|
|
@@ -1662,9 +1761,10 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1662
1761
|
states,
|
|
1663
1762
|
transitionKey: "reconcile",
|
|
1664
1763
|
});
|
|
1665
|
-
const receipt = terminalReceiptFromProjection(plan, await readCoordinationState({ sessionId: plan.sessionId, cwd }));
|
|
1764
|
+
const receipt = terminalReceiptFromProjection(plan, await readCoordinationState({ sessionId: plan.sessionId, projectKey, cwd }));
|
|
1666
1765
|
await appendAction({
|
|
1667
1766
|
sessionId: plan.sessionId,
|
|
1767
|
+
projectKey,
|
|
1668
1768
|
cwd,
|
|
1669
1769
|
by,
|
|
1670
1770
|
batchId: plan.batchId,
|
|
@@ -1678,7 +1778,17 @@ export async function reconcileTeamworkBatch(input) {
|
|
|
1678
1778
|
}
|
|
1679
1779
|
/** Read settled facts without admitting work or consulting current resource policy. */
|
|
1680
1780
|
export async function readSettledTeamworkReceipt(plan, cwd) {
|
|
1681
|
-
const
|
|
1781
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
1782
|
+
sessionId: plan.sessionId,
|
|
1783
|
+
batchId: plan.batchId,
|
|
1784
|
+
planHash: plan.planHash,
|
|
1785
|
+
cwd,
|
|
1786
|
+
});
|
|
1787
|
+
const state = await readCoordinationState({
|
|
1788
|
+
sessionId: plan.sessionId,
|
|
1789
|
+
projectKey,
|
|
1790
|
+
cwd,
|
|
1791
|
+
});
|
|
1682
1792
|
const batch = state.batches.find((entry) => entry.batchId === plan.batchId);
|
|
1683
1793
|
if (!batch ||
|
|
1684
1794
|
!["AWAITING_REVIEW", "ALL_ACCEPTED", "SETTLED_WITH_FAILURE"].includes(batch.state))
|
|
@@ -1690,6 +1800,12 @@ export async function readSettledTeamworkReceipt(plan, cwd) {
|
|
|
1690
1800
|
/** Main-agent review starts only after the CLI has drained the entire batch. */
|
|
1691
1801
|
export async function reviewTeamworkReport(input) {
|
|
1692
1802
|
const { plan, taskRoot, cwd } = input;
|
|
1803
|
+
const { project: projectKey } = await resolveTeamworkBatchSession({
|
|
1804
|
+
sessionId: plan.sessionId,
|
|
1805
|
+
batchId: plan.batchId,
|
|
1806
|
+
planHash: plan.planHash,
|
|
1807
|
+
cwd,
|
|
1808
|
+
});
|
|
1693
1809
|
if (!input.reason.trim())
|
|
1694
1810
|
throw new Error("Review requires an explicit reason");
|
|
1695
1811
|
const assignment = plan.assignments.find((item) => item.assignmentId === input.assignmentId);
|
|
@@ -1699,6 +1815,7 @@ export async function reviewTeamworkReport(input) {
|
|
|
1699
1815
|
assertTeamworkPlanCurrent(plan, taskRoot);
|
|
1700
1816
|
const projection = await readCoordinationState({
|
|
1701
1817
|
sessionId: plan.sessionId,
|
|
1818
|
+
projectKey,
|
|
1702
1819
|
cwd,
|
|
1703
1820
|
});
|
|
1704
1821
|
const batch = projection.batches.find((item) => item.batchId === plan.batchId);
|
|
@@ -1710,7 +1827,26 @@ export async function reviewTeamworkReport(input) {
|
|
|
1710
1827
|
item.assignmentId === assignment.assignmentId);
|
|
1711
1828
|
if (!work?.attemptId || !work.teammateId)
|
|
1712
1829
|
throw new Error("Review has no matching report attempt");
|
|
1713
|
-
|
|
1830
|
+
if (work.state !== "AWAITING_REVIEW") {
|
|
1831
|
+
const events = await readTeamworkEvents({
|
|
1832
|
+
sessionId: plan.sessionId,
|
|
1833
|
+
projectKey,
|
|
1834
|
+
});
|
|
1835
|
+
const reviewed = events
|
|
1836
|
+
.filter((event) => event.kind === "coordination" &&
|
|
1837
|
+
event.entity === "assignment" &&
|
|
1838
|
+
event.action === "state_transition" &&
|
|
1839
|
+
event.batchId === plan.batchId &&
|
|
1840
|
+
event.assignmentId === assignment.assignmentId &&
|
|
1841
|
+
event.attemptId === work.attemptId &&
|
|
1842
|
+
event.teammateId === work.teammateId &&
|
|
1843
|
+
event.state === work.state)
|
|
1844
|
+
.at(-1);
|
|
1845
|
+
if (reviewed?.kind !== "coordination" ||
|
|
1846
|
+
reviewed.payload?.reportSha256 !== input.reportSha256)
|
|
1847
|
+
throw new Error("Review digest does not match the original disposition");
|
|
1848
|
+
}
|
|
1849
|
+
const report = readTeammateReport({
|
|
1714
1850
|
taskRoot,
|
|
1715
1851
|
briefPath: assignment.briefPath,
|
|
1716
1852
|
attemptId: work.attemptId,
|
|
@@ -1725,14 +1861,12 @@ export async function reviewTeamworkReport(input) {
|
|
|
1725
1861
|
inputRevision: plan.inputRevision,
|
|
1726
1862
|
},
|
|
1727
1863
|
sourceDigest: assignment.sourceDigest,
|
|
1864
|
+
reportSha256: input.reportSha256,
|
|
1728
1865
|
});
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
.
|
|
1732
|
-
|
|
1733
|
-
.digest("hex");
|
|
1734
|
-
if (reportSha256 !== input.reportSha256)
|
|
1735
|
-
throw new Error("Review report digest does not match the inspected report");
|
|
1866
|
+
const reportSha256 = report.artifact.sha256;
|
|
1867
|
+
if (assignment.execution.launch.reportVersion === 2 &&
|
|
1868
|
+
report.schemaVersion !== 2)
|
|
1869
|
+
throw new Error("Report does not match the frozen result contract");
|
|
1736
1870
|
const state = input.decision === "accepted" ? "ACCEPTED" : "FINAL_FAILED";
|
|
1737
1871
|
if (work.state !== "AWAITING_REVIEW" && work.state !== state)
|
|
1738
1872
|
throw new Error("Report already has a different final disposition");
|
|
@@ -1763,6 +1897,7 @@ export async function reviewTeamworkReport(input) {
|
|
|
1763
1897
|
if (work.state === "AWAITING_REVIEW")
|
|
1764
1898
|
await appendTransition({
|
|
1765
1899
|
sessionId: plan.sessionId,
|
|
1900
|
+
projectKey,
|
|
1766
1901
|
cwd,
|
|
1767
1902
|
by,
|
|
1768
1903
|
batchId: plan.batchId,
|
|
@@ -1783,6 +1918,7 @@ export async function reviewTeamworkReport(input) {
|
|
|
1783
1918
|
});
|
|
1784
1919
|
let updated = await readCoordinationState({
|
|
1785
1920
|
sessionId: plan.sessionId,
|
|
1921
|
+
projectKey,
|
|
1786
1922
|
cwd,
|
|
1787
1923
|
});
|
|
1788
1924
|
const remaining = updated.assignments.filter((item) => item.batchId === plan.batchId);
|
|
@@ -1790,6 +1926,7 @@ export async function reviewTeamworkReport(input) {
|
|
|
1790
1926
|
!remaining.some((item) => item.state === "AWAITING_REVIEW")) {
|
|
1791
1927
|
await appendTransition({
|
|
1792
1928
|
sessionId: plan.sessionId,
|
|
1929
|
+
projectKey,
|
|
1793
1930
|
cwd,
|
|
1794
1931
|
by,
|
|
1795
1932
|
batchId: plan.batchId,
|
|
@@ -1802,12 +1939,14 @@ export async function reviewTeamworkReport(input) {
|
|
|
1802
1939
|
});
|
|
1803
1940
|
updated = await readCoordinationState({
|
|
1804
1941
|
sessionId: plan.sessionId,
|
|
1942
|
+
projectKey,
|
|
1805
1943
|
cwd,
|
|
1806
1944
|
});
|
|
1807
1945
|
}
|
|
1808
1946
|
const receipt = terminalReceiptFromProjection(plan, updated);
|
|
1809
1947
|
await appendAction({
|
|
1810
1948
|
sessionId: plan.sessionId,
|
|
1949
|
+
projectKey,
|
|
1811
1950
|
cwd,
|
|
1812
1951
|
by,
|
|
1813
1952
|
batchId: plan.batchId,
|