@@ -6,10 +6,11 @@ import {
66} from "../effect_program.ts" ;
77import { VISION_MATERIAL_CLOSEOUT_HINT , visionAuthoringContract } from "../goals/vision_checkpoint.ts" ;
88import { parseExactGoalRef } from "../goals/goal_instance_identity.ts" ;
9- import { requireBoolean , requireJsonObject , requireNonEmptyString , requireStringArray } from "../runtime_decode.ts" ;
9+ import { requireBoolean , requireJsonObject , requireNonEmptyString , requireStringArray , requireStringLiteral } from "../runtime_decode.ts" ;
1010import { MATERIAL_DELIVERY_OUTCOMES } from "../work_items/delivery_outcome.ts" ;
1111import { DELIVERY_BOUNDARIES } from "../turn_driver/delivery_continuity.ts" ;
1212import { PROGRESS_RESULT_CLASSES } from "../work_items/replan_history.ts" ;
13+ import { HANDOFF_MODES } from "../coordination/handoff_mode_vocabulary.ts" ;
1314
1415export function turnScopedCliSettlementPlan ( params : JsonObject ) : SettlementPlan {
1516 const identity = settlementIdentity (
@@ -54,15 +55,28 @@ export function turnScopedCliSettlementPlan(params: JsonObject): SettlementPlan
5455 const inFlight = params . delivery_boundary === "in_flight_continuation" ;
5556 const autonomousReplan = ( params . autonomous_replan === undefined ? false
5657 : requireBoolean ( params . autonomous_replan , "autonomous_replan" ) ) || identity . binding_kind === "autonomous_replan" ;
58+ const mode = params . handoff_mode == null ? null
59+ : requireStringLiteral ( params . handoff_mode , HANDOFF_MODES , "handoff_mode" ) ;
60+ const managedClaim = identity . binding_kind === "todo" && mode === "hard_lease" ;
61+ const proofSupplied = params . completion_proof_supplied === undefined ? false
62+ : requireBoolean ( params . completion_proof_supplied , "completion_proof_supplied" ) ;
63+ const completionProof = managedClaim && ! proofSupplied
64+ ? " --claim-operation-id '<original claim_operation_id>'" : "" ;
5765 const validation : SettlementStep = {
5866 kind : "validation" , owner : "agent" , idempotency_key_ref : "$.identity.effect_id" ,
5967 expected_receipt : "validation_receipt" ,
6068 precondition : "delivery result is independently validated" ,
6169 } ;
6270 if ( identity . binding_kind === "todo" ) {
63- validation . command_template = requireNonEmptyString ( commands . todo_completion , "todo_completion" ) ;
71+ validation . command_template = requireNonEmptyString ( commands . todo_completion , "todo_completion" ) + completionProof ;
6472 validation . command_condition = "todo_deliverable_complete" ;
65- validation . precondition = "validate the original Todo deliverable; when complete, run ordinary Todo completion " +
73+ const claimHint = managedClaim ? "Before task execution, prepare it with ordinary Todo claim: `" +
74+ requireNonEmptyString ( commands . todo_claim , "todo_claim" ) +
75+ "`. Reuse an already accepted current claim or explicit lease proof; keep the original " +
76+ "claim_operation_id for managed progress/completion retries. claimed_by alone is not an execution lease. " +
77+ "An expired, released or replaced execution requires normal ownership recovery; " +
78+ "this plan neither acquires nor renews execution. " : "" ;
79+ validation . precondition = claimHint + "validate the original Todo deliverable; when complete, run ordinary Todo completion " +
6680 "with its original declaration and current lease before writeback/spend. Use --evidence for " +
6781 "an artifact pointer; --result-file requires approved Goal acceptance criteria bound to this Todo, " +
6882 "not merely a Todo validator. No invented successor " +
@@ -108,7 +122,7 @@ export function turnScopedCliSettlementPlan(params: JsonObject): SettlementPlan
108122 precondition : "the selected Todo is final with no runnable successor and matching " +
109123 "writeback and quota spend receipts exist" ,
110124 idempotency_key_ref : "$.identity.effect_id" , expected_receipt : "terminal_closeout_receipt" ,
111- command_template : requireNonEmptyString ( commands . terminal_closeout , "terminal_closeout" ) ,
125+ command_template : requireNonEmptyString ( commands . terminal_closeout , "terminal_closeout" ) + completionProof ,
112126 conditional : true ,
113127 } ) ;
114128 return {
0 commit comments