@mstar-harness/cli 3.10.1 → 3.10.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/dist/mstar-harness.js +498 -32
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -2886,7 +2886,7 @@ function validatePlanProgress(value, what = "coordination.progress") {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
return violations;
|
|
2888
2888
|
}
|
|
2889
|
-
function validatePlanHandoff(value, what = "coordination.handoff") {
|
|
2889
|
+
function validatePlanHandoff(value, what = "coordination.handoff", route = "integration") {
|
|
2890
2890
|
if (!isPlainObject2(value))
|
|
2891
2891
|
return [invalid("coordination.row.handoff-shape", `${what} must be an object`)];
|
|
2892
2892
|
const allowed = [
|
|
@@ -3026,7 +3026,25 @@ function validatePlanHandoff(value, what = "coordination.handoff") {
|
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
3028
3028
|
if ((value.state === "integrating" || value.state === "merged" || value.state === "completed") && value.integration === undefined) {
|
|
3029
|
-
|
|
3029
|
+
if (route === "standalone-development" && value.state === "completed") {
|
|
3030
|
+
if (value.completed_at === undefined) {
|
|
3031
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.state completed requires completed_at for a standalone handoff`));
|
|
3032
|
+
}
|
|
3033
|
+
if (!isNonEmptyString(value.accepted_at)) {
|
|
3034
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.accepted_at is required for a standalone completed handoff`));
|
|
3035
|
+
}
|
|
3036
|
+
if (!isNonEmptyString(value.accepted_by)) {
|
|
3037
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.accepted_by is required for a standalone completed handoff`));
|
|
3038
|
+
}
|
|
3039
|
+
if (value.qc === undefined) {
|
|
3040
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.qc is required for a standalone completed handoff`));
|
|
3041
|
+
}
|
|
3042
|
+
if (value.qa === undefined) {
|
|
3043
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.qa is required for a standalone completed handoff`));
|
|
3044
|
+
}
|
|
3045
|
+
} else {
|
|
3046
|
+
violations.push(invalid("coordination.row.handoff-field", `${what}.state ${String(value.state)} requires integration`));
|
|
3047
|
+
}
|
|
3030
3048
|
}
|
|
3031
3049
|
return violations;
|
|
3032
3050
|
}
|
|
@@ -3062,7 +3080,7 @@ function validatePreparedCoordination(value, what = "coordination.prepared") {
|
|
|
3062
3080
|
}
|
|
3063
3081
|
return violations;
|
|
3064
3082
|
}
|
|
3065
|
-
function validateRowCoordination(value, what = "coordination") {
|
|
3083
|
+
function validateRowCoordination(value, what = "coordination", route = "integration") {
|
|
3066
3084
|
if (!isPlainObject2(value))
|
|
3067
3085
|
return [invalid("coordination.row.shape", `${what} must be an object`)];
|
|
3068
3086
|
const allowed = ["revision", "prepared", "session", "progress", "handoff"];
|
|
@@ -3081,7 +3099,7 @@ function validateRowCoordination(value, what = "coordination") {
|
|
|
3081
3099
|
if (value.progress !== undefined)
|
|
3082
3100
|
violations.push(...validatePlanProgress(value.progress, `${what}.progress`));
|
|
3083
3101
|
if (value.handoff !== undefined)
|
|
3084
|
-
violations.push(...validatePlanHandoff(value.handoff, `${what}.handoff
|
|
3102
|
+
violations.push(...validatePlanHandoff(value.handoff, `${what}.handoff`, route));
|
|
3085
3103
|
if (value.handoff !== undefined && value.session === undefined) {
|
|
3086
3104
|
violations.push(invalid("coordination.row.handoff-field", `${what}.handoff requires a bound plan session`));
|
|
3087
3105
|
}
|
|
@@ -3503,6 +3521,45 @@ var WORKFLOW_TERMINAL_STATUSES = ["completed", "failed", "stopped"];
|
|
|
3503
3521
|
var WORKFLOW_LIFECYCLE_TYPES = ["plan", "iteration"];
|
|
3504
3522
|
var WORKFLOW_DELIVERY_KINDS = ["development", "verification/report-only"];
|
|
3505
3523
|
var WORKFLOW_COMPOUND_OUTCOMES = ["created", "updated", "skipped"];
|
|
3524
|
+
function isStandaloneDevelopmentWorkflow(snapshot) {
|
|
3525
|
+
return snapshot.type === "plan" && snapshot.delivery_kind === "development" && Array.isArray(snapshot.plans) && snapshot.plans.length === 1;
|
|
3526
|
+
}
|
|
3527
|
+
function rowValidationRoute(snapshot, row) {
|
|
3528
|
+
if (isStandaloneDevelopmentWorkflow(snapshot) && snapshot.plans[0]?.id === row.id) {
|
|
3529
|
+
return "standalone-development";
|
|
3530
|
+
}
|
|
3531
|
+
return "integration";
|
|
3532
|
+
}
|
|
3533
|
+
function validateStandaloneCompletedCoherence(snapshot, row) {
|
|
3534
|
+
const violations = [];
|
|
3535
|
+
if (!isStandaloneDevelopmentWorkflow(snapshot) || row.id !== snapshot.plans[0]?.id)
|
|
3536
|
+
return violations;
|
|
3537
|
+
const coordination = row.coordination;
|
|
3538
|
+
if (!isPlainObject2(coordination) || !isPlainObject2(coordination.handoff))
|
|
3539
|
+
return violations;
|
|
3540
|
+
const handoff = coordination.handoff;
|
|
3541
|
+
if (handoff.state !== "completed" || handoff.integration !== undefined)
|
|
3542
|
+
return violations;
|
|
3543
|
+
if (row.status !== "Done") {
|
|
3544
|
+
violations.push(violation3("high", "coordination.row.handoff-field", `standalone completed handoff requires row ${String(row.id)} to be Done`));
|
|
3545
|
+
}
|
|
3546
|
+
if (row.execution_lease !== undefined) {
|
|
3547
|
+
violations.push(violation3("high", "coordination.row.handoff-field", `standalone completed handoff requires no execution lease on row ${String(row.id)}`));
|
|
3548
|
+
}
|
|
3549
|
+
if (snapshot.integration_merge_lease !== undefined) {
|
|
3550
|
+
violations.push(violation3("high", "coordination.row.handoff-field", "standalone completed handoff requires no integration_merge_lease on the snapshot"));
|
|
3551
|
+
}
|
|
3552
|
+
const source = snapshot.branch?.source;
|
|
3553
|
+
const target = snapshot.branch?.target;
|
|
3554
|
+
if (!isNonEmptyString(source) || !isNonEmptyString(target)) {
|
|
3555
|
+
violations.push(violation3("high", "coordination.row.handoff-field", "standalone completed handoff requires nonblank branch.source and branch.target"));
|
|
3556
|
+
} else {
|
|
3557
|
+
if (handoff.source_branch !== source) {
|
|
3558
|
+
violations.push(violation3("high", "coordination.row.handoff-field", `standalone completed handoff source_branch ${String(handoff.source_branch)} must equal branch.source ${source}`));
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
return violations;
|
|
3562
|
+
}
|
|
3506
3563
|
function stableJson(value) {
|
|
3507
3564
|
if (Array.isArray(value))
|
|
3508
3565
|
return `[${value.map(stableJson).join(",")}]`;
|
|
@@ -3622,13 +3679,17 @@ function validateWorkflowSnapshot(doc) {
|
|
|
3622
3679
|
} else if (!Array.isArray(doc.plans)) {
|
|
3623
3680
|
violations.push(violation3("high", "workflow.snapshot.invalid-plans", "plans must be an array of legacy plan rows"));
|
|
3624
3681
|
} else {
|
|
3682
|
+
const snapshotDoc = doc;
|
|
3625
3683
|
for (const row of doc.plans) {
|
|
3626
3684
|
violations.push(...validatePlanRow(row).violations);
|
|
3627
3685
|
if (isPlainObject2(row) && row.execution_lease !== undefined) {
|
|
3628
3686
|
violations.push(...validateExecutionLease(row.execution_lease).violations);
|
|
3629
3687
|
}
|
|
3630
3688
|
if (isPlainObject2(row) && row.coordination !== undefined) {
|
|
3631
|
-
|
|
3689
|
+
const planRow = row;
|
|
3690
|
+
const route = rowValidationRoute(snapshotDoc, planRow);
|
|
3691
|
+
violations.push(...validateRowCoordination(row.coordination, `plans[${String(row.id)}].coordination`, route));
|
|
3692
|
+
violations.push(...validateStandaloneCompletedCoherence(snapshotDoc, planRow));
|
|
3632
3693
|
}
|
|
3633
3694
|
}
|
|
3634
3695
|
}
|
|
@@ -3984,6 +4045,15 @@ async function recordWorkflowDelivery(workflowId, dir, opts) {
|
|
|
3984
4045
|
if (stableJson(snapshot.delivery ?? null) === stableJson(merged)) {
|
|
3985
4046
|
return { snapshot, written: false };
|
|
3986
4047
|
}
|
|
4048
|
+
const tailMembers = members.filter((member) => member === "compound" || member === "pr" || member === "merge");
|
|
4049
|
+
if (tailMembers.length > 0) {
|
|
4050
|
+
const notDone = snapshot.plans.filter((row) => row.status !== "Done");
|
|
4051
|
+
if (notDone.length > 0) {
|
|
4052
|
+
const rowDetail = notDone.map((row) => `${row.id} (${JSON.stringify(row.status)})`).join(", ");
|
|
4053
|
+
const detail = violation3("high", "PHASE6_PLAN_ROW_NOT_DONE", `owned plan row(s) ${rowDetail} are not Done - every plan row must be Done before the delivery tail (${tailMembers.join(", ")}) is recorded (mstar-artifacts/references/plan-workflow-lifecycle-contract.md section 3: row Done -> compound disposition -> PR identity -> verified-merge record)`, `Bring every owned plan row to Done, then record delivery evidence with 'mstar workflow evidence --workflow ${workflowId} --file <payload.json>'`);
|
|
4054
|
+
throw new Error(`refusing to record delivery evidence: ${detail.code}: ${detail.message}${detail.fix !== undefined ? ` (fix: ${detail.fix})` : ""}`);
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
3987
4057
|
const next = { ...snapshot, delivery: merged, updated_at: at };
|
|
3988
4058
|
await validateAndPutWorkflowSnapshot(store, next, snapshotPath);
|
|
3989
4059
|
return { snapshot: next, written: true };
|
|
@@ -12351,7 +12421,7 @@ function validatePlanProgress2(value, what = "coordination.progress") {
|
|
|
12351
12421
|
}
|
|
12352
12422
|
return violations;
|
|
12353
12423
|
}
|
|
12354
|
-
function validatePlanHandoff2(value, what = "coordination.handoff") {
|
|
12424
|
+
function validatePlanHandoff2(value, what = "coordination.handoff", route = "integration") {
|
|
12355
12425
|
if (!isPlainObject22(value))
|
|
12356
12426
|
return [invalid2("coordination.row.handoff-shape", `${what} must be an object`)];
|
|
12357
12427
|
const allowed = [
|
|
@@ -12491,7 +12561,25 @@ function validatePlanHandoff2(value, what = "coordination.handoff") {
|
|
|
12491
12561
|
}
|
|
12492
12562
|
}
|
|
12493
12563
|
if ((value.state === "integrating" || value.state === "merged" || value.state === "completed") && value.integration === undefined) {
|
|
12494
|
-
|
|
12564
|
+
if (route === "standalone-development" && value.state === "completed") {
|
|
12565
|
+
if (value.completed_at === undefined) {
|
|
12566
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.state completed requires completed_at for a standalone handoff`));
|
|
12567
|
+
}
|
|
12568
|
+
if (!isNonEmptyString2(value.accepted_at)) {
|
|
12569
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.accepted_at is required for a standalone completed handoff`));
|
|
12570
|
+
}
|
|
12571
|
+
if (!isNonEmptyString2(value.accepted_by)) {
|
|
12572
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.accepted_by is required for a standalone completed handoff`));
|
|
12573
|
+
}
|
|
12574
|
+
if (value.qc === undefined) {
|
|
12575
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.qc is required for a standalone completed handoff`));
|
|
12576
|
+
}
|
|
12577
|
+
if (value.qa === undefined) {
|
|
12578
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.qa is required for a standalone completed handoff`));
|
|
12579
|
+
}
|
|
12580
|
+
} else {
|
|
12581
|
+
violations.push(invalid2("coordination.row.handoff-field", `${what}.state ${String(value.state)} requires integration`));
|
|
12582
|
+
}
|
|
12495
12583
|
}
|
|
12496
12584
|
return violations;
|
|
12497
12585
|
}
|
|
@@ -12527,7 +12615,7 @@ function validatePreparedCoordination2(value, what = "coordination.prepared") {
|
|
|
12527
12615
|
}
|
|
12528
12616
|
return violations;
|
|
12529
12617
|
}
|
|
12530
|
-
function validateRowCoordination2(value, what = "coordination") {
|
|
12618
|
+
function validateRowCoordination2(value, what = "coordination", route = "integration") {
|
|
12531
12619
|
if (!isPlainObject22(value))
|
|
12532
12620
|
return [invalid2("coordination.row.shape", `${what} must be an object`)];
|
|
12533
12621
|
const allowed = ["revision", "prepared", "session", "progress", "handoff"];
|
|
@@ -12546,7 +12634,7 @@ function validateRowCoordination2(value, what = "coordination") {
|
|
|
12546
12634
|
if (value.progress !== undefined)
|
|
12547
12635
|
violations.push(...validatePlanProgress2(value.progress, `${what}.progress`));
|
|
12548
12636
|
if (value.handoff !== undefined)
|
|
12549
|
-
violations.push(...validatePlanHandoff2(value.handoff, `${what}.handoff
|
|
12637
|
+
violations.push(...validatePlanHandoff2(value.handoff, `${what}.handoff`, route));
|
|
12550
12638
|
if (value.handoff !== undefined && value.session === undefined) {
|
|
12551
12639
|
violations.push(invalid2("coordination.row.handoff-field", `${what}.handoff requires a bound plan session`));
|
|
12552
12640
|
}
|
|
@@ -12737,6 +12825,45 @@ var WORKFLOW_TERMINAL_STATUSES2 = ["completed", "failed", "stopped"];
|
|
|
12737
12825
|
var WORKFLOW_LIFECYCLE_TYPES2 = ["plan", "iteration"];
|
|
12738
12826
|
var WORKFLOW_DELIVERY_KINDS2 = ["development", "verification/report-only"];
|
|
12739
12827
|
var WORKFLOW_COMPOUND_OUTCOMES2 = ["created", "updated", "skipped"];
|
|
12828
|
+
function isStandaloneDevelopmentWorkflow2(snapshot) {
|
|
12829
|
+
return snapshot.type === "plan" && snapshot.delivery_kind === "development" && Array.isArray(snapshot.plans) && snapshot.plans.length === 1;
|
|
12830
|
+
}
|
|
12831
|
+
function rowValidationRoute2(snapshot, row) {
|
|
12832
|
+
if (isStandaloneDevelopmentWorkflow2(snapshot) && snapshot.plans[0]?.id === row.id) {
|
|
12833
|
+
return "standalone-development";
|
|
12834
|
+
}
|
|
12835
|
+
return "integration";
|
|
12836
|
+
}
|
|
12837
|
+
function validateStandaloneCompletedCoherence2(snapshot, row) {
|
|
12838
|
+
const violations = [];
|
|
12839
|
+
if (!isStandaloneDevelopmentWorkflow2(snapshot) || row.id !== snapshot.plans[0]?.id)
|
|
12840
|
+
return violations;
|
|
12841
|
+
const coordination = row.coordination;
|
|
12842
|
+
if (!isPlainObject22(coordination) || !isPlainObject22(coordination.handoff))
|
|
12843
|
+
return violations;
|
|
12844
|
+
const handoff = coordination.handoff;
|
|
12845
|
+
if (handoff.state !== "completed" || handoff.integration !== undefined)
|
|
12846
|
+
return violations;
|
|
12847
|
+
if (row.status !== "Done") {
|
|
12848
|
+
violations.push(violation32("high", "coordination.row.handoff-field", `standalone completed handoff requires row ${String(row.id)} to be Done`));
|
|
12849
|
+
}
|
|
12850
|
+
if (row.execution_lease !== undefined) {
|
|
12851
|
+
violations.push(violation32("high", "coordination.row.handoff-field", `standalone completed handoff requires no execution lease on row ${String(row.id)}`));
|
|
12852
|
+
}
|
|
12853
|
+
if (snapshot.integration_merge_lease !== undefined) {
|
|
12854
|
+
violations.push(violation32("high", "coordination.row.handoff-field", "standalone completed handoff requires no integration_merge_lease on the snapshot"));
|
|
12855
|
+
}
|
|
12856
|
+
const source = snapshot.branch?.source;
|
|
12857
|
+
const target = snapshot.branch?.target;
|
|
12858
|
+
if (!isNonEmptyString2(source) || !isNonEmptyString2(target)) {
|
|
12859
|
+
violations.push(violation32("high", "coordination.row.handoff-field", "standalone completed handoff requires nonblank branch.source and branch.target"));
|
|
12860
|
+
} else {
|
|
12861
|
+
if (handoff.source_branch !== source) {
|
|
12862
|
+
violations.push(violation32("high", "coordination.row.handoff-field", `standalone completed handoff source_branch ${String(handoff.source_branch)} must equal branch.source ${source}`));
|
|
12863
|
+
}
|
|
12864
|
+
}
|
|
12865
|
+
return violations;
|
|
12866
|
+
}
|
|
12740
12867
|
function stableJson2(value) {
|
|
12741
12868
|
if (Array.isArray(value))
|
|
12742
12869
|
return `[${value.map(stableJson2).join(",")}]`;
|
|
@@ -12856,13 +12983,17 @@ function validateWorkflowSnapshot2(doc) {
|
|
|
12856
12983
|
} else if (!Array.isArray(doc.plans)) {
|
|
12857
12984
|
violations.push(violation32("high", "workflow.snapshot.invalid-plans", "plans must be an array of legacy plan rows"));
|
|
12858
12985
|
} else {
|
|
12986
|
+
const snapshotDoc = doc;
|
|
12859
12987
|
for (const row of doc.plans) {
|
|
12860
12988
|
violations.push(...validatePlanRow2(row).violations);
|
|
12861
12989
|
if (isPlainObject22(row) && row.execution_lease !== undefined) {
|
|
12862
12990
|
violations.push(...validateExecutionLease2(row.execution_lease).violations);
|
|
12863
12991
|
}
|
|
12864
12992
|
if (isPlainObject22(row) && row.coordination !== undefined) {
|
|
12865
|
-
|
|
12993
|
+
const planRow = row;
|
|
12994
|
+
const route = rowValidationRoute2(snapshotDoc, planRow);
|
|
12995
|
+
violations.push(...validateRowCoordination2(row.coordination, `plans[${String(row.id)}].coordination`, route));
|
|
12996
|
+
violations.push(...validateStandaloneCompletedCoherence2(snapshotDoc, planRow));
|
|
12866
12997
|
}
|
|
12867
12998
|
}
|
|
12868
12999
|
}
|
|
@@ -15978,6 +16109,7 @@ var IMPLEMENTED_OPERATIONS = {
|
|
|
15978
16109
|
"integration-start": true,
|
|
15979
16110
|
"integration-accept": true,
|
|
15980
16111
|
complete: true,
|
|
16112
|
+
"repair-delivery-source": true,
|
|
15981
16113
|
reconcile: true
|
|
15982
16114
|
};
|
|
15983
16115
|
function nowIso() {
|
|
@@ -16537,7 +16669,11 @@ function allowedOperations(role, sessionId, snapshot, row) {
|
|
|
16537
16669
|
out.push("accept", "return");
|
|
16538
16670
|
break;
|
|
16539
16671
|
case "accepted":
|
|
16540
|
-
|
|
16672
|
+
if (isStandaloneDevelopmentWorkflow2(snapshot)) {
|
|
16673
|
+
out.push("return", "complete", "repair-delivery-source");
|
|
16674
|
+
} else {
|
|
16675
|
+
out.push("return", "integration-start");
|
|
16676
|
+
}
|
|
16541
16677
|
break;
|
|
16542
16678
|
case "integrating":
|
|
16543
16679
|
out.push("integration-accept", "complete", "reconcile");
|
|
@@ -17312,6 +17448,13 @@ async function mutatePlanCoordination(request) {
|
|
|
17312
17448
|
expectedRevision
|
|
17313
17449
|
});
|
|
17314
17450
|
}
|
|
17451
|
+
case "repair-delivery-source": {
|
|
17452
|
+
assertExactKeys2(operation, ["kind", "handoffId"], "repair-delivery-source operation");
|
|
17453
|
+
return mutateRepairDeliverySource(await coordinatorScope(session, request.planId, kind), session, sessionAbs, {
|
|
17454
|
+
handoffId: namedHandoffId(operation),
|
|
17455
|
+
expectedRevision
|
|
17456
|
+
});
|
|
17457
|
+
}
|
|
17315
17458
|
case "reconcile": {
|
|
17316
17459
|
assertExactKeys2(operation, ["kind", "handoffId"], "reconcile operation");
|
|
17317
17460
|
return mutateReconcile(await coordinatorScope(session, request.planId, kind), session, sessionAbs, {
|
|
@@ -17342,6 +17485,7 @@ var COORDINATOR_OPERATIONS = [
|
|
|
17342
17485
|
"integration-start",
|
|
17343
17486
|
"integration-accept",
|
|
17344
17487
|
"complete",
|
|
17488
|
+
"repair-delivery-source",
|
|
17345
17489
|
"reconcile"
|
|
17346
17490
|
];
|
|
17347
17491
|
function assertSessionRole(session, kind) {
|
|
@@ -17982,6 +18126,313 @@ async function mutateIntegrationAccept(scope, session, sessionPath, request) {
|
|
|
17982
18126
|
view: buildView(scope.harnessRoot, scope.workflowId, scope.projectId, scope, result.snapshot, result.row, session, sessionPath)
|
|
17983
18127
|
};
|
|
17984
18128
|
}
|
|
18129
|
+
function validateRowCoordinationInContext(context, coordination, what) {
|
|
18130
|
+
assertViolationFree(validateRowCoordination2(coordination, what, rowValidationRoute2(context.snapshot, context.row)), what);
|
|
18131
|
+
}
|
|
18132
|
+
function standaloneDeliveryAnchors(snapshot, planId) {
|
|
18133
|
+
const source = snapshot.branch?.source;
|
|
18134
|
+
const target = snapshot.branch?.target;
|
|
18135
|
+
if (!isNonEmptyString2(source) || !isNonEmptyString2(target)) {
|
|
18136
|
+
throw new CoordinationError2("coordination.invalid-transition", `plan ${planId} has no delivery anchors \u2014 the snapshot must name branch.source and branch.target`, { plan_id: planId });
|
|
18137
|
+
}
|
|
18138
|
+
return { source, target };
|
|
18139
|
+
}
|
|
18140
|
+
function assertStandaloneRoute(snapshot, planId, what) {
|
|
18141
|
+
if (!isStandaloneDevelopmentWorkflow2(snapshot)) {
|
|
18142
|
+
throw new CoordinationError2("coordination.invalid-transition", `${what} requires a standalone development workflow for plan ${planId}`, { plan_id: planId });
|
|
18143
|
+
}
|
|
18144
|
+
}
|
|
18145
|
+
function assertNoIntegrationContamination(context, planId, handoff, what, code = "coordination.invalid-transition") {
|
|
18146
|
+
if (handoff.integration !== undefined) {
|
|
18147
|
+
throw new CoordinationError2(code, `${what} refuses plan ${planId} because the handoff already carries an integration record`, { plan_id: planId });
|
|
18148
|
+
}
|
|
18149
|
+
if (context.snapshot.integration_worktree_path !== undefined) {
|
|
18150
|
+
throw new CoordinationError2(code, `${what} refuses plan ${planId} because the snapshot names integration_worktree_path`, { plan_id: planId });
|
|
18151
|
+
}
|
|
18152
|
+
if (isNonEmptyString2(context.snapshot.branch?.integration)) {
|
|
18153
|
+
throw new CoordinationError2(code, `${what} refuses plan ${planId} because the snapshot names branch.integration`, { plan_id: planId, integration: context.snapshot.branch?.integration });
|
|
18154
|
+
}
|
|
18155
|
+
if (context.snapshot.integration_merge_lease !== undefined) {
|
|
18156
|
+
throw new CoordinationError2(code, `${what} refuses plan ${planId} because the snapshot carries an integration merge lease`, { plan_id: planId });
|
|
18157
|
+
}
|
|
18158
|
+
}
|
|
18159
|
+
function assertAcceptedReviewDecision(handoff, planId, what) {
|
|
18160
|
+
if (handoff.qc.decision !== "Approve" && handoff.qc.decision !== "Approve with residuals") {
|
|
18161
|
+
throw new CoordinationError2("coordination.invalid-transition", `${what} requires an accepted QC decision for plan ${planId} \u2014 got ${handoff.qc.decision}`, { plan_id: planId, decision: handoff.qc.decision });
|
|
18162
|
+
}
|
|
18163
|
+
if (handoff.qa.decision !== "pass") {
|
|
18164
|
+
throw new CoordinationError2("coordination.invalid-transition", `${what} requires QA decision pass for plan ${planId} \u2014 got ${handoff.qa.decision}`, { plan_id: planId, decision: handoff.qa.decision });
|
|
18165
|
+
}
|
|
18166
|
+
}
|
|
18167
|
+
function assertStandaloneBranchIdentity(context, scope, handoff, anchors, what, requireLease = true) {
|
|
18168
|
+
const worktree = canonicalTarget2(scope.worktreePath);
|
|
18169
|
+
if (handoff.source_branch !== anchors.source) {
|
|
18170
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires handoff.source_branch ${handoff.source_branch} to equal the registered delivery source ${anchors.source}`, { plan_id: scope.planId, expected: anchors.source, actual: handoff.source_branch });
|
|
18171
|
+
}
|
|
18172
|
+
if (requireLease) {
|
|
18173
|
+
const lease = requireExecutionLease(context.row, scope.planId, what);
|
|
18174
|
+
if (scope.workingBranch !== anchors.source) {
|
|
18175
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires the prepared working branch ${scope.workingBranch} to equal the registered delivery source ${anchors.source}`, { plan_id: scope.planId, expected: anchors.source, actual: scope.workingBranch });
|
|
18176
|
+
}
|
|
18177
|
+
if (lease.working_branch !== anchors.source) {
|
|
18178
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires the execution lease working branch ${lease.working_branch} to equal the registered delivery source ${anchors.source}`, { plan_id: scope.planId, expected: anchors.source, actual: lease.working_branch });
|
|
18179
|
+
}
|
|
18180
|
+
if (canonicalTarget2(lease.worktree_path) !== worktree) {
|
|
18181
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires the execution lease worktree ${lease.worktree_path} to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: lease.worktree_path });
|
|
18182
|
+
}
|
|
18183
|
+
}
|
|
18184
|
+
if (canonicalTarget2(handoff.worktree_path) !== worktree) {
|
|
18185
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires the handoff worktree ${handoff.worktree_path} to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: handoff.worktree_path });
|
|
18186
|
+
}
|
|
18187
|
+
const metadata = context.row.metadata;
|
|
18188
|
+
if (isPlainObject22(metadata) && metadata.working_branch !== undefined && metadata.working_branch !== anchors.source) {
|
|
18189
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires row metadata.working_branch to equal the registered delivery source ${anchors.source}`, { plan_id: scope.planId, expected: anchors.source, actual: metadata.working_branch });
|
|
18190
|
+
}
|
|
18191
|
+
if (isPlainObject22(metadata) && metadata.worktree_path !== undefined && canonicalTarget2(String(metadata.worktree_path)) !== worktree) {
|
|
18192
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires row metadata.worktree_path to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: metadata.worktree_path });
|
|
18193
|
+
}
|
|
18194
|
+
}
|
|
18195
|
+
function assertStandaloneSourceGitProof(scope, handoff, sourceBranch, what) {
|
|
18196
|
+
assertFeatureCheckout(scope, handoff.source_sha, what);
|
|
18197
|
+
const branch = gitRead(scope.worktreePath, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
18198
|
+
if (branch !== sourceBranch) {
|
|
18199
|
+
throw gitProof(`${what} requires the plan worktree ${scope.worktreePath} to be on ${sourceBranch} \u2014 got ${branch || "a detached HEAD"}`, { plan_id: scope.planId, expected: sourceBranch, actual: branch });
|
|
18200
|
+
}
|
|
18201
|
+
const refTip = gitRead(scope.worktreePath, ["rev-parse", `refs/heads/${sourceBranch}`]);
|
|
18202
|
+
if (refTip !== handoff.source_sha) {
|
|
18203
|
+
throw gitProof(`${what} requires refs/heads/${sourceBranch} to resolve to the pinned source ${handoff.source_sha} \u2014 got ${refTip || "missing"}`, { plan_id: scope.planId, expected: handoff.source_sha, actual: refTip });
|
|
18204
|
+
}
|
|
18205
|
+
if (handoff.review_head !== handoff.source_sha) {
|
|
18206
|
+
throw gitProof(`${what} requires review_head to be the pinned source ${handoff.source_sha} \u2014 got ${handoff.review_head}`, { plan_id: scope.planId, source_sha: handoff.source_sha, review_head: handoff.review_head });
|
|
18207
|
+
}
|
|
18208
|
+
if (!gitObjectExists(scope.worktreePath, handoff.review_base)) {
|
|
18209
|
+
throw gitProof(`${what} review base ${handoff.review_base} is not a commit of ${scope.worktreePath}`, {
|
|
18210
|
+
plan_id: scope.planId,
|
|
18211
|
+
review_base: handoff.review_base
|
|
18212
|
+
});
|
|
18213
|
+
}
|
|
18214
|
+
if (!gitIsAncestor(scope.worktreePath, handoff.review_base, handoff.review_head)) {
|
|
18215
|
+
throw gitProof(`${what} review range ${handoff.review_base}..${handoff.review_head} is not an ancestry`, { plan_id: scope.planId, review_base: handoff.review_base, review_head: handoff.review_head });
|
|
18216
|
+
}
|
|
18217
|
+
}
|
|
18218
|
+
async function assertStandaloneCompletionPrecheck(context, scope, session, handoff) {
|
|
18219
|
+
assertStandaloneRoute(context.snapshot, scope.planId, "complete");
|
|
18220
|
+
if (context.snapshot.status !== "running") {
|
|
18221
|
+
throw new CoordinationError2("coordination.invalid-transition", `complete requires workflow ${context.snapshot.id} to still be running \u2014 got ${context.snapshot.status}`, { workflow_id: context.snapshot.id, status: context.snapshot.status });
|
|
18222
|
+
}
|
|
18223
|
+
if (handoff.state !== "accepted") {
|
|
18224
|
+
throw new CoordinationError2("coordination.invalid-transition", `plan ${scope.planId} handoff is ${handoff.state} \u2014 standalone complete requires an accepted handoff`, { plan_id: scope.planId, state: handoff.state });
|
|
18225
|
+
}
|
|
18226
|
+
if (rowStatusOf(context.row) !== "InReview") {
|
|
18227
|
+
throw new CoordinationError2("coordination.invalid-transition", `complete requires ${scope.planId} to still be InReview`, { plan_id: scope.planId, status: context.row.status });
|
|
18228
|
+
}
|
|
18229
|
+
const prepared = context.coordination?.prepared;
|
|
18230
|
+
if (prepared === undefined) {
|
|
18231
|
+
throw new CoordinationError2("coordination.not-prepared", `plan ${scope.planId} is not prepared in this workflow`, { plan_id: scope.planId });
|
|
18232
|
+
}
|
|
18233
|
+
assertNoIntegrationContamination(context, scope.planId, handoff, "complete");
|
|
18234
|
+
assertEvidenceDigests(handoff);
|
|
18235
|
+
assertAcceptedReviewDecision(handoff, scope.planId, "complete");
|
|
18236
|
+
if (handoff.qa.gate !== prepared.qa_gate) {
|
|
18237
|
+
throw new CoordinationError2("coordination.assignment-stale", `complete qa.gate ${handoff.qa.gate} is not the Assignment's QA gate ${prepared.qa_gate}`, { plan_id: scope.planId, expected: prepared.qa_gate, actual: handoff.qa.gate });
|
|
18238
|
+
}
|
|
18239
|
+
await assertFindingsClosed(scope, prepared, "complete");
|
|
18240
|
+
assertExecutionHolder(context.row, session.session_id, scope.planId, "complete");
|
|
18241
|
+
const anchors = standaloneDeliveryAnchors(context.snapshot, scope.planId);
|
|
18242
|
+
assertStandaloneBranchIdentity(context, scope, handoff, anchors, "complete");
|
|
18243
|
+
assertStandaloneSourceGitProof(scope, handoff, anchors.source, "complete");
|
|
18244
|
+
}
|
|
18245
|
+
function requireAcceptedHandoffForRepair(context, planId, namedHandoffId2) {
|
|
18246
|
+
const handoff = context.coordination?.handoff;
|
|
18247
|
+
if (handoff === undefined || handoff.id !== namedHandoffId2 || handoff.state !== "accepted" || rowStatusOf(context.row) !== "InReview") {
|
|
18248
|
+
throw new CoordinationError2("coordination.delivery-source-repair.no-accepted-handoff", `repair-delivery-source requires plan ${planId} to carry the named accepted handoff while InReview`, { plan_id: planId, handoff_id: namedHandoffId2, state: handoff?.state, status: context.row.status });
|
|
18249
|
+
}
|
|
18250
|
+
return handoff;
|
|
18251
|
+
}
|
|
18252
|
+
function assertRepairNotTerminal(snapshot) {
|
|
18253
|
+
if (WORKFLOW_TERMINAL_STATUSES2.includes(snapshot.status)) {
|
|
18254
|
+
throw new CoordinationError2("coordination.delivery-source-repair.terminal", `repair-delivery-source refuses workflow ${snapshot.id} in terminal status ${snapshot.status}`, { workflow_id: snapshot.id, status: snapshot.status });
|
|
18255
|
+
}
|
|
18256
|
+
}
|
|
18257
|
+
function assertLegacyRepairShape(snapshot, planId, handoff) {
|
|
18258
|
+
const source = snapshot.branch?.source;
|
|
18259
|
+
const target = snapshot.branch?.target;
|
|
18260
|
+
if (!isNonEmptyString2(source) || !isNonEmptyString2(target)) {
|
|
18261
|
+
throw new CoordinationError2("coordination.delivery-source-repair.not-legacy-shape", `repair-delivery-source requires nonblank delivery anchors on plan ${planId}`, { plan_id: planId });
|
|
18262
|
+
}
|
|
18263
|
+
const candidateSource = handoff.source_branch;
|
|
18264
|
+
if (!isNonEmptyString2(candidateSource)) {
|
|
18265
|
+
throw new CoordinationError2("coordination.delivery-source-repair.not-legacy-shape", `repair-delivery-source requires the accepted handoff to name a nonblank source branch for plan ${planId}`, { plan_id: planId });
|
|
18266
|
+
}
|
|
18267
|
+
if (source === candidateSource) {
|
|
18268
|
+
throw new CoordinationError2("coordination.delivery-source-repair.already-aligned", `repair-delivery-source refuses plan ${planId} because branch.source already equals the accepted handoff source ${candidateSource}`, { plan_id: planId, source, candidate: candidateSource });
|
|
18269
|
+
}
|
|
18270
|
+
if (source !== target) {
|
|
18271
|
+
throw new CoordinationError2("coordination.delivery-source-repair.not-legacy-shape", `repair-delivery-source requires the legacy shape branch.source === branch.target for plan ${planId} \u2014 got source ${source} and target ${target}`, { plan_id: planId, source, target });
|
|
18272
|
+
}
|
|
18273
|
+
return { target, candidateSource };
|
|
18274
|
+
}
|
|
18275
|
+
function assertRepairBranchIdentity(context, scope, handoff, candidateSource, what) {
|
|
18276
|
+
const worktree = canonicalTarget2(scope.worktreePath);
|
|
18277
|
+
if (handoff.source_branch !== candidateSource) {
|
|
18278
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires handoff.source_branch ${handoff.source_branch} to equal the candidate delivery source ${candidateSource}`, { plan_id: scope.planId, expected: candidateSource, actual: handoff.source_branch });
|
|
18279
|
+
}
|
|
18280
|
+
const lease = requireExecutionLease(context.row, scope.planId, what);
|
|
18281
|
+
if (scope.workingBranch !== candidateSource) {
|
|
18282
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires the prepared working branch ${scope.workingBranch} to equal the candidate delivery source ${candidateSource}`, { plan_id: scope.planId, expected: candidateSource, actual: scope.workingBranch });
|
|
18283
|
+
}
|
|
18284
|
+
if (lease.working_branch !== candidateSource) {
|
|
18285
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires the execution lease working branch ${lease.working_branch} to equal the candidate delivery source ${candidateSource}`, { plan_id: scope.planId, expected: candidateSource, actual: lease.working_branch });
|
|
18286
|
+
}
|
|
18287
|
+
if (canonicalTarget2(lease.worktree_path) !== worktree) {
|
|
18288
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires the execution lease worktree ${lease.worktree_path} to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: lease.worktree_path });
|
|
18289
|
+
}
|
|
18290
|
+
if (canonicalTarget2(handoff.worktree_path) !== worktree) {
|
|
18291
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires the handoff worktree ${handoff.worktree_path} to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: handoff.worktree_path });
|
|
18292
|
+
}
|
|
18293
|
+
const metadata = context.row.metadata;
|
|
18294
|
+
if (isPlainObject22(metadata) && metadata.working_branch !== undefined && metadata.working_branch !== candidateSource) {
|
|
18295
|
+
throw new CoordinationError2("coordination.scope-mismatch", `${what} requires row metadata.working_branch to equal the candidate delivery source ${candidateSource}`, { plan_id: scope.planId, expected: candidateSource, actual: metadata.working_branch });
|
|
18296
|
+
}
|
|
18297
|
+
if (isPlainObject22(metadata) && metadata.worktree_path !== undefined && canonicalTarget2(String(metadata.worktree_path)) !== worktree) {
|
|
18298
|
+
throw new CoordinationError2("coordination.path-mismatch", `${what} requires row metadata.worktree_path to equal the prepared scope ${worktree}`, { plan_id: scope.planId, expected: worktree, actual: metadata.worktree_path });
|
|
18299
|
+
}
|
|
18300
|
+
}
|
|
18301
|
+
function assertDeliveryPrCompatible(snapshot, candidateSource, registeredTarget, planId) {
|
|
18302
|
+
const pr = snapshot.delivery?.pr;
|
|
18303
|
+
if (pr === undefined)
|
|
18304
|
+
return;
|
|
18305
|
+
if (pr.head !== candidateSource || pr.target !== registeredTarget) {
|
|
18306
|
+
throw new CoordinationError2("coordination.delivery-source-repair.pr-conflict", `repair-delivery-source refuses plan ${planId} because stored PR identity head ${JSON.stringify(pr.head)} target ${JSON.stringify(pr.target)} conflicts with candidate source ${candidateSource} and registered target ${registeredTarget}`, { plan_id: planId, pr_head: pr.head, pr_target: pr.target, candidate: candidateSource, target: registeredTarget });
|
|
18307
|
+
}
|
|
18308
|
+
}
|
|
18309
|
+
function assertRepairDeliverySourceAdmission(context, scope) {
|
|
18310
|
+
if (!isStandaloneDevelopmentWorkflow2(context.snapshot)) {
|
|
18311
|
+
throw new CoordinationError2("coordination.delivery-source-repair.unsupported-workflow", `repair-delivery-source requires a single-row standalone development workflow for plan ${scope.planId}`, { plan_id: scope.planId, workflow_id: context.snapshot.id });
|
|
18312
|
+
}
|
|
18313
|
+
assertRepairNotTerminal(context.snapshot);
|
|
18314
|
+
if (context.snapshot.status === "paused") {
|
|
18315
|
+
throw new CoordinationError2("coordination.invalid-transition", `repair-delivery-source refuses paused workflow ${context.snapshot.id}`, { workflow_id: context.snapshot.id, status: context.snapshot.status });
|
|
18316
|
+
}
|
|
18317
|
+
if (context.snapshot.status !== "running") {
|
|
18318
|
+
throw new CoordinationError2("coordination.invalid-transition", `repair-delivery-source requires workflow ${context.snapshot.id} to still be running \u2014 got ${context.snapshot.status}`, { workflow_id: context.snapshot.id, status: context.snapshot.status });
|
|
18319
|
+
}
|
|
18320
|
+
}
|
|
18321
|
+
async function assertRepairDeliverySourcePrecheck(context, scope, session, handoff) {
|
|
18322
|
+
assertNoIntegrationContamination(context, scope.planId, handoff, "repair-delivery-source", "coordination.delivery-source-repair.not-legacy-shape");
|
|
18323
|
+
const prepared = context.coordination?.prepared;
|
|
18324
|
+
if (prepared === undefined) {
|
|
18325
|
+
throw new CoordinationError2("coordination.not-prepared", `plan ${scope.planId} is not prepared in this workflow`, { plan_id: scope.planId });
|
|
18326
|
+
}
|
|
18327
|
+
assertEvidenceDigests(handoff);
|
|
18328
|
+
assertAcceptedReviewDecision(handoff, scope.planId, "repair-delivery-source");
|
|
18329
|
+
if (handoff.qa.gate !== prepared.qa_gate) {
|
|
18330
|
+
throw new CoordinationError2("coordination.assignment-stale", `repair-delivery-source qa.gate ${handoff.qa.gate} is not the Assignment's QA gate ${prepared.qa_gate}`, { plan_id: scope.planId, expected: prepared.qa_gate, actual: handoff.qa.gate });
|
|
18331
|
+
}
|
|
18332
|
+
await assertFindingsClosed(scope, prepared, "repair-delivery-source");
|
|
18333
|
+
assertExecutionHolder(context.row, session.session_id, scope.planId, "repair-delivery-source");
|
|
18334
|
+
const { target, candidateSource } = assertLegacyRepairShape(context.snapshot, scope.planId, handoff);
|
|
18335
|
+
assertRepairBranchIdentity(context, scope, handoff, candidateSource, "repair-delivery-source");
|
|
18336
|
+
assertDeliveryPrCompatible(context.snapshot, candidateSource, target, scope.planId);
|
|
18337
|
+
assertStandaloneSourceGitProof(scope, handoff, candidateSource, "repair-delivery-source");
|
|
18338
|
+
}
|
|
18339
|
+
function repairDeliverySourceRow(context, scope, candidateSource) {
|
|
18340
|
+
const nextCoordination = {
|
|
18341
|
+
...context.coordination ?? { revision: 0 },
|
|
18342
|
+
revision: context.revision + 1
|
|
18343
|
+
};
|
|
18344
|
+
validateRowCoordinationInContext(context, nextCoordination, `plan ${scope.planId} coordination`);
|
|
18345
|
+
const currentBranch = context.snapshot.branch ?? {};
|
|
18346
|
+
return {
|
|
18347
|
+
row: { ...context.row, coordination: nextCoordination },
|
|
18348
|
+
coordination: nextCoordination,
|
|
18349
|
+
topLevel: {
|
|
18350
|
+
branch: { ...currentBranch, source: candidateSource }
|
|
18351
|
+
}
|
|
18352
|
+
};
|
|
18353
|
+
}
|
|
18354
|
+
async function mutateRepairDeliverySource(scope, session, sessionPath, request) {
|
|
18355
|
+
const result = await withRowCommit(scope, {
|
|
18356
|
+
expectedRevision: request.expectedRevision,
|
|
18357
|
+
precheck: async (context) => {
|
|
18358
|
+
assertCoordinatorBinding(session, sessionPath, context.snapshot);
|
|
18359
|
+
assertRepairDeliverySourceAdmission(context, scope);
|
|
18360
|
+
const handoff = requireAcceptedHandoffForRepair(context, scope.planId, request.handoffId);
|
|
18361
|
+
await assertRepairDeliverySourcePrecheck(context, scope, session, handoff);
|
|
18362
|
+
},
|
|
18363
|
+
mutate: (context) => {
|
|
18364
|
+
const handoff = requireAcceptedHandoffForRepair(context, scope.planId, request.handoffId);
|
|
18365
|
+
const { candidateSource } = assertLegacyRepairShape(context.snapshot, scope.planId, handoff);
|
|
18366
|
+
return repairDeliverySourceRow(context, scope, candidateSource);
|
|
18367
|
+
}
|
|
18368
|
+
});
|
|
18369
|
+
return {
|
|
18370
|
+
ok: true,
|
|
18371
|
+
operation: "repair-delivery-source",
|
|
18372
|
+
session,
|
|
18373
|
+
session_file: sessionPath,
|
|
18374
|
+
outcome: "delivery-source-repaired",
|
|
18375
|
+
view: buildView(scope.harnessRoot, scope.workflowId, scope.projectId, scope, result.snapshot, result.row, session, sessionPath)
|
|
18376
|
+
};
|
|
18377
|
+
}
|
|
18378
|
+
function completeStandaloneRow(context, scope, handoff) {
|
|
18379
|
+
const metadata = isPlainObject22(context.row.metadata) ? { ...context.row.metadata } : {};
|
|
18380
|
+
metadata.working_branch = handoff.source_branch;
|
|
18381
|
+
metadata.worktree_path = handoff.worktree_path;
|
|
18382
|
+
const nextCoordination = {
|
|
18383
|
+
...context.coordination ?? { revision: 0 },
|
|
18384
|
+
revision: context.revision + 1,
|
|
18385
|
+
handoff: { ...handoff, state: "completed", completed_at: nowIso() }
|
|
18386
|
+
};
|
|
18387
|
+
validateRowCoordinationInContext(context, nextCoordination, `plan ${scope.planId} coordination`);
|
|
18388
|
+
const nextRow = { ...context.row, status: "Done", metadata, coordination: nextCoordination };
|
|
18389
|
+
delete nextRow.execution_lease;
|
|
18390
|
+
return { row: nextRow, coordination: nextCoordination };
|
|
18391
|
+
}
|
|
18392
|
+
function assertStandaloneCompletedReplay(context, scope, handoff) {
|
|
18393
|
+
assertStandaloneRoute(context.snapshot, scope.planId, "reconcile");
|
|
18394
|
+
if (rowStatusOf(context.row) !== "Done") {
|
|
18395
|
+
throw new CoordinationError2("coordination.invalid-transition", `reconcile requires ${scope.planId} to be Done for a standalone completed replay`, { plan_id: scope.planId, status: context.row.status });
|
|
18396
|
+
}
|
|
18397
|
+
if (context.row.execution_lease !== undefined) {
|
|
18398
|
+
throw new CoordinationError2("coordination.invalid-transition", `reconcile requires no execution lease on ${scope.planId} for a standalone completed replay`, { plan_id: scope.planId });
|
|
18399
|
+
}
|
|
18400
|
+
if (context.snapshot.integration_merge_lease !== undefined) {
|
|
18401
|
+
throw new CoordinationError2("coordination.invalid-transition", `reconcile requires no integration merge lease for a standalone completed replay of ${scope.planId}`, { plan_id: scope.planId });
|
|
18402
|
+
}
|
|
18403
|
+
assertNoIntegrationContamination(context, scope.planId, handoff, "reconcile");
|
|
18404
|
+
const storedHandoffViolations = validatePlanHandoff2(handoff, `plan ${scope.planId} coordination.handoff`, "standalone-development");
|
|
18405
|
+
const storedHandoffFailure = storedHandoffViolations.find((entry) => !entry.ok);
|
|
18406
|
+
if (storedHandoffFailure !== undefined) {
|
|
18407
|
+
throw new CoordinationError2(storedHandoffFailure.code, storedHandoffFailure.message, { plan_id: scope.planId });
|
|
18408
|
+
}
|
|
18409
|
+
const anchors = standaloneDeliveryAnchors(context.snapshot, scope.planId);
|
|
18410
|
+
assertStandaloneBranchIdentity(context, scope, handoff, anchors, "reconcile", false);
|
|
18411
|
+
const repository = proofRepository([handoff.worktree_path, scope.worktreePath, scope.harnessRoot]);
|
|
18412
|
+
if (repository !== undefined && !gitObjectExists(repository, handoff.source_sha)) {
|
|
18413
|
+
throw gitProof(`reconcile cannot re-verify the pinned standalone source ${handoff.source_sha} for plan ${scope.planId}`, { plan_id: scope.planId, source_sha: handoff.source_sha });
|
|
18414
|
+
}
|
|
18415
|
+
}
|
|
18416
|
+
async function assertIterationCompletionPrecheck(context, scope, session, handoff) {
|
|
18417
|
+
if (handoff.state !== "merged") {
|
|
18418
|
+
throw new CoordinationError2("coordination.invalid-transition", `plan ${scope.planId} handoff is ${handoff.state} \u2014 complete requires a merged attempt`, { plan_id: scope.planId, state: handoff.state });
|
|
18419
|
+
}
|
|
18420
|
+
if (rowStatusOf(context.row) !== "InReview") {
|
|
18421
|
+
throw new CoordinationError2("coordination.invalid-transition", `complete requires ${scope.planId} to still be InReview`, { plan_id: scope.planId, status: context.row.status });
|
|
18422
|
+
}
|
|
18423
|
+
const prepared = context.coordination?.prepared;
|
|
18424
|
+
if (prepared === undefined) {
|
|
18425
|
+
throw new CoordinationError2("coordination.not-prepared", `plan ${scope.planId} is not prepared in this workflow`, { plan_id: scope.planId });
|
|
18426
|
+
}
|
|
18427
|
+
assertEvidenceDigests(handoff);
|
|
18428
|
+
await assertFindingsClosed(scope, prepared, "complete");
|
|
18429
|
+
assertExecutionHolder(context.row, session.session_id, scope.planId, "complete");
|
|
18430
|
+
assertMergeLease(context.snapshot, session, scope.planId, handoff);
|
|
18431
|
+
const integration = requireIntegration(handoff, scope.planId);
|
|
18432
|
+
const anchors = integrationAnchors(context.snapshot, scope.planId);
|
|
18433
|
+
const checkout = assertIntegrationCheckout(anchors, scope.planId);
|
|
18434
|
+
assertRecordedResult(anchors.worktreePath, scope.planId, integration, handoff.source_sha, checkout.head);
|
|
18435
|
+
}
|
|
17985
18436
|
function completeRow(context, scope, handoff, resultSha) {
|
|
17986
18437
|
const integration = requireIntegration(handoff, scope.planId);
|
|
17987
18438
|
const completed = { ...integration, result_sha: resultSha, verified_at: nowIso() };
|
|
@@ -18000,33 +18451,27 @@ function completeRow(context, scope, handoff, resultSha) {
|
|
|
18000
18451
|
dropTopLevel: release === undefined ? [] : ["integration_merge_lease"]
|
|
18001
18452
|
};
|
|
18002
18453
|
}
|
|
18454
|
+
var completeStandaloneMutateGapForTest;
|
|
18003
18455
|
async function mutateComplete(scope, session, sessionPath, request) {
|
|
18004
18456
|
const result = await withRowCommit(scope, {
|
|
18005
18457
|
expectedRevision: request.expectedRevision,
|
|
18006
18458
|
precheck: async (context) => {
|
|
18007
18459
|
assertCoordinatorBinding(session, sessionPath, context.snapshot);
|
|
18008
18460
|
const handoff = requireHandoff(context, scope.planId, request.handoffId);
|
|
18009
|
-
if (
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
if (rowStatusOf(context.row) !== "InReview") {
|
|
18013
|
-
throw new CoordinationError2("coordination.invalid-transition", `complete requires ${scope.planId} to still be InReview`, { plan_id: scope.planId, status: context.row.status });
|
|
18014
|
-
}
|
|
18015
|
-
const prepared = context.coordination?.prepared;
|
|
18016
|
-
if (prepared === undefined) {
|
|
18017
|
-
throw new CoordinationError2("coordination.not-prepared", `plan ${scope.planId} is not prepared in this workflow`, { plan_id: scope.planId });
|
|
18461
|
+
if (isStandaloneDevelopmentWorkflow2(context.snapshot)) {
|
|
18462
|
+
await assertStandaloneCompletionPrecheck(context, scope, session, handoff);
|
|
18463
|
+
return;
|
|
18018
18464
|
}
|
|
18019
|
-
|
|
18020
|
-
await assertFindingsClosed(scope, prepared, "complete");
|
|
18021
|
-
assertExecutionHolder(context.row, session.session_id, scope.planId, "complete");
|
|
18022
|
-
assertMergeLease(context.snapshot, session, scope.planId, handoff);
|
|
18023
|
-
const integration = requireIntegration(handoff, scope.planId);
|
|
18024
|
-
const anchors = integrationAnchors(context.snapshot, scope.planId);
|
|
18025
|
-
const checkout = assertIntegrationCheckout(anchors, scope.planId);
|
|
18026
|
-
assertRecordedResult(anchors.worktreePath, scope.planId, integration, handoff.source_sha, checkout.head);
|
|
18465
|
+
await assertIterationCompletionPrecheck(context, scope, session, handoff);
|
|
18027
18466
|
},
|
|
18028
18467
|
mutate: (context) => {
|
|
18029
18468
|
const handoff = requireHandoff(context, scope.planId, request.handoffId);
|
|
18469
|
+
if (isStandaloneDevelopmentWorkflow2(context.snapshot)) {
|
|
18470
|
+
completeStandaloneMutateGapForTest?.();
|
|
18471
|
+
const anchors = standaloneDeliveryAnchors(context.snapshot, scope.planId);
|
|
18472
|
+
assertStandaloneSourceGitProof(scope, handoff, anchors.source, "complete");
|
|
18473
|
+
return completeStandaloneRow(context, scope, handoff);
|
|
18474
|
+
}
|
|
18030
18475
|
const integration = requireIntegration(handoff, scope.planId);
|
|
18031
18476
|
const resultSha = assertRecordedResult(integration.worktree_path, scope.planId, integration, handoff.source_sha, undefined);
|
|
18032
18477
|
return completeRow(context, scope, handoff, resultSha);
|
|
@@ -18050,6 +18495,10 @@ async function classifyReconcile(context, scope, session, handoff, expectedHando
|
|
|
18050
18495
|
});
|
|
18051
18496
|
}
|
|
18052
18497
|
if (handoff.state === "completed") {
|
|
18498
|
+
if (isStandaloneDevelopmentWorkflow2(context.snapshot)) {
|
|
18499
|
+
assertStandaloneCompletedReplay(context, scope, handoff);
|
|
18500
|
+
return { outcome: "already-completed", apply: () => null };
|
|
18501
|
+
}
|
|
18053
18502
|
const integration = requireIntegration(handoff, planId);
|
|
18054
18503
|
const repository = proofRepository([integration.worktree_path, handoff.worktree_path, session.harness_root]);
|
|
18055
18504
|
if (repository === undefined) {
|
|
@@ -20196,6 +20645,7 @@ var PLAN_VERBS = {
|
|
|
20196
20645
|
"integration-start": true,
|
|
20197
20646
|
"integration-accept": true,
|
|
20198
20647
|
complete: true,
|
|
20648
|
+
"repair-delivery-source": true,
|
|
20199
20649
|
reconcile: true
|
|
20200
20650
|
};
|
|
20201
20651
|
var WORKFLOW_VERBS = {
|
|
@@ -20548,10 +20998,26 @@ function registerPlanCommands(program2) {
|
|
|
20548
20998
|
for (const [kind, description] of [
|
|
20549
20999
|
["accept", "Accept a submitted handoff: execution ownership transfers to the coordinator, no merge yet"],
|
|
20550
21000
|
["return", "Return a submitted/accepted handoff to the plan owner and restore its execution holder"],
|
|
20551
|
-
[
|
|
20552
|
-
|
|
20553
|
-
|
|
20554
|
-
|
|
21001
|
+
[
|
|
21002
|
+
"integration-start",
|
|
21003
|
+
"Iteration route only: record the integration attempt and pin its base before any Git merge (Git stays the operator's action)"
|
|
21004
|
+
],
|
|
21005
|
+
[
|
|
21006
|
+
"integration-accept",
|
|
21007
|
+
"Iteration route only: verify the pinned Git result of the started integration attempt (never runs a merge)"
|
|
21008
|
+
],
|
|
21009
|
+
[
|
|
21010
|
+
"complete",
|
|
21011
|
+
"Record row Done after verified Git proof \u2014 iteration route releases both leases after a merged handoff; standalone development completes from the accepted handoff without integration and releases only the row lease (workflow stays running)"
|
|
21012
|
+
],
|
|
21013
|
+
[
|
|
21014
|
+
"repair-delivery-source",
|
|
21015
|
+
"Legacy-only: replace a wrong registered delivery source (source === target) from the accepted handoff pin \u2014 never Done, delivery evidence, or a user-supplied branch; not a normal lifecycle step"
|
|
21016
|
+
],
|
|
21017
|
+
[
|
|
21018
|
+
"reconcile",
|
|
21019
|
+
"Crash recovery: iteration route observes the merge checkout and finishes or abandons the attempt; standalone development only replays an already-completed row as a no-write already-completed"
|
|
21020
|
+
]
|
|
20555
21021
|
]) {
|
|
20556
21022
|
const command = plan.command(kind).description(`${description} (coordinator session)`).option("--session <path>", "Absolute coordinator session JSON envelope path").option("--plan <id>", "Plan id").option("--handoff <id>", "Handoff id this call acts on (must be the row's live handoff; `plan show --json` reports it)");
|
|
20557
21023
|
if (kind === "return")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mstar-harness/cli",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.3",
|
|
4
4
|
"description": "Morning Star harness CLI — installer bootstrap + mstar workflow verbs (path/status/lease/sdd/iteration/dispatch/worktree/lint/design-md/audit/compound/host/skill).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|