codex-workflow-v2 2.0.0-beta.14 → 2.0.0-beta.14.1

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.
Files changed (93) hide show
  1. package/README.md +3 -3
  2. package/dist/reviewer-runtime-build.json +24 -20
  3. package/dist/src/alpha6/adoption.d.ts +1 -1
  4. package/dist/src/alpha6/adoption.js +26 -8
  5. package/dist/src/alpha6/adoption.js.map +1 -1
  6. package/dist/src/alpha6/corrective-decision-boundary.js +9 -3
  7. package/dist/src/alpha6/corrective-decision-boundary.js.map +1 -1
  8. package/dist/src/alpha6/remediation.d.ts +2 -0
  9. package/dist/src/alpha6/remediation.js +68 -2
  10. package/dist/src/alpha6/remediation.js.map +1 -1
  11. package/dist/src/alpha7/autonomy.d.ts +9 -0
  12. package/dist/src/alpha7/autonomy.js +40 -1
  13. package/dist/src/alpha7/autonomy.js.map +1 -1
  14. package/dist/src/beta1/project-transaction.js +14 -4
  15. package/dist/src/beta1/project-transaction.js.map +1 -1
  16. package/dist/src/cli-actions.d.ts +3 -3
  17. package/dist/src/cli-actions.js +5 -0
  18. package/dist/src/cli-actions.js.map +1 -1
  19. package/dist/src/cli.js +31 -1
  20. package/dist/src/cli.js.map +1 -1
  21. package/dist/src/contracts.d.ts +19 -2
  22. package/dist/src/delegation.d.ts +5 -1
  23. package/dist/src/delegation.js +4 -0
  24. package/dist/src/delegation.js.map +1 -1
  25. package/dist/src/failed-checkpoint-update.d.ts +69 -0
  26. package/dist/src/failed-checkpoint-update.js +171 -0
  27. package/dist/src/failed-checkpoint-update.js.map +1 -0
  28. package/dist/src/lifecycle/corrective-replan-credential-core.d.ts +2 -0
  29. package/dist/src/lifecycle/corrective-replan-credential-core.js +45 -9
  30. package/dist/src/lifecycle/corrective-replan-credential-core.js.map +1 -1
  31. package/dist/src/lifecycle/corrective-replan.js +12 -8
  32. package/dist/src/lifecycle/corrective-replan.js.map +1 -1
  33. package/dist/src/lifecycle/semantic-registry.js +4 -2
  34. package/dist/src/lifecycle/semantic-registry.js.map +1 -1
  35. package/dist/src/observed-routes.js +5 -0
  36. package/dist/src/observed-routes.js.map +1 -1
  37. package/dist/src/state/corrective-replan-executor.js +1 -0
  38. package/dist/src/state/corrective-replan-executor.js.map +1 -1
  39. package/dist/src/state/corrective-replan-public.d.ts +9 -1
  40. package/dist/src/state/corrective-replan-public.js +49 -7
  41. package/dist/src/state/corrective-replan-public.js.map +1 -1
  42. package/dist/src/version.d.ts +1 -1
  43. package/dist/src/version.js +1 -1
  44. package/dist/src/version.js.map +1 -1
  45. package/dist/src/workflow-blocker-route.js +1 -1
  46. package/dist/src/workflow-blocker-route.js.map +1 -1
  47. package/dist/src/workflow.d.ts +40 -1
  48. package/dist/src/workflow.js +203 -33
  49. package/dist/src/workflow.js.map +1 -1
  50. package/docs/autonomy-guardrails.md +4 -4
  51. package/docs/development-flow.md +8 -6
  52. package/docs/project-memory.md +2 -2
  53. package/docs/release.md +7 -1
  54. package/docs/updating-existing-project.md +37 -0
  55. package/package.json +1 -1
  56. package/plugins/codex-workflow-gateway/.codex-plugin/plugin.json +1 -1
  57. package/plugins/codex-workflow-gateway/references/chat-dispatch.md +17 -5
  58. package/plugins/codex-workflow-gateway/references/protocol.md +39 -43
  59. package/plugins/codex-workflow-gateway/scripts/chat-dispatch.mjs +13 -3
  60. package/plugins/codex-workflow-gateway/scripts/chat-model-policy.mjs +18 -33
  61. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +15 -10
  62. package/references/state-machine.md +3 -1
  63. package/roles/delivery-coordinator.md +31 -11
  64. package/roles/scope-lead.md +1 -1
  65. package/roles/technical-planner.md +4 -1
  66. package/schemas/adoption-posture-event.schema.json +11 -0
  67. package/schemas/authorization-event.schema.json +1 -1
  68. package/schemas/corrective-decision-event.schema.json +23 -3
  69. package/schemas/corrective-replan-credentials.private.schema.json +8 -5
  70. package/schemas/corrective-replan-execution-event.private.schema.json +9 -0
  71. package/schemas/corrective-replan-public.schema.json +2 -1
  72. package/schemas/delegation-grant.schema.json +1 -1
  73. package/schemas/task.schema.json +18 -0
  74. package/schemas/transition-definition.schema.json +4 -0
  75. package/src/alpha6/adoption.ts +30 -7
  76. package/src/alpha6/corrective-decision-boundary.ts +9 -3
  77. package/src/alpha6/remediation.ts +69 -2
  78. package/src/alpha7/autonomy.ts +39 -1
  79. package/src/beta1/project-transaction.ts +13 -4
  80. package/src/cli-actions.ts +5 -0
  81. package/src/cli.ts +33 -0
  82. package/src/contracts.ts +19 -1
  83. package/src/delegation.ts +5 -1
  84. package/src/failed-checkpoint-update.ts +203 -0
  85. package/src/lifecycle/corrective-replan-credential-core.ts +39 -10
  86. package/src/lifecycle/corrective-replan.ts +12 -8
  87. package/src/lifecycle/semantic-registry.ts +4 -2
  88. package/src/observed-routes.ts +5 -0
  89. package/src/state/corrective-replan-executor.ts +1 -0
  90. package/src/state/corrective-replan-public.ts +50 -6
  91. package/src/version.ts +1 -1
  92. package/src/workflow-blocker-route.ts +1 -1
  93. package/src/workflow.ts +192 -22
@@ -1,3 +1,3 @@
1
1
  export const PACKAGE_NAME = 'codex-workflow-v2';
2
- export const PACKAGE_VERSION = '2.0.0-beta.14';
2
+ export const PACKAGE_VERSION = '2.0.0-beta.14.1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC"}
@@ -75,7 +75,7 @@ export function withWorkflowBlockerRoute(next, packageVersion) {
75
75
  projectName: 'codex-workflow-v2',
76
76
  chatType: 'workflow-blocker',
77
77
  title: patchVersion,
78
- modelRequest: { phase: 'implementation', complexity: 'complex', highRisk: false },
78
+ modelSelection: 'destination-default',
79
79
  requiredPacketFields: [
80
80
  'blockerId', 'packageVersion', 'sourceProject', 'sourceThreadId', 'source',
81
81
  'freshStatusHash', 'freshNextHash', 'repositoryState', 'expectedContinuation',
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-blocker-route.js","sourceRoot":"","sources":["../../src/workflow-blocker-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,MAAM,MAAM,GAAG,CAAC,KAAc,EAAe,EAAE,CAC7C,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;AAEnG,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,IAAI,GAAG,+BAA+B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAI,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACpD,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,MAAM;QAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACxE,MAAM,IAAI,SAAS,CAAC,wDAAwD,OAAO,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,aAAa,CAAC,IAAiB;IACtC,MAAM,KAAK,GAAG,C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B;gBAChC,QAAQ,EAAE,kBAAkB;gBAC5B,KAAK,EAAE,YAAY;gBACnB,cAAc,EAAE,qBAAqB;gBACrC,oBAAoB,EAAE;oBACpB,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ;oBAC1E,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,sBAAsB;iBAC9E;aACF;YACD,yBAAyB,EAAE;gBACzB,iDAAiD;gBACjD,6DAA6D;gBAC7D,yDAAyD;gBACzD,oFAAoF;aACrF;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,gCAAgC;gBACxC,cAAc,EAAE;oBACd,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,uBAAuB;oBACxE,mBAAmB,EAAE,kBAAkB;iBACxC;aACF;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,CAAC,UAAU,EAAE,yBAAyB,EAAE,uBAAuB,CAAC;gBACtE,WAAW,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,gBAAgB,CAAC;gBACzG,SAAS,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,CAAC;gBACzE,WAAW,EAAE,MAAM;aACpB;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type NavigationUpdateReceipt } from './navigation-update.js';
2
+ import { type FailedCheckpointUpdateReceipt } from './failed-checkpoint-update.js';
2
3
  import type { CheckExecutionOptions } from './checks/runner.js';
3
4
  import { type ChangeExplanationInput } from './change-explanation.js';
4
5
  import { type AdoptionPostureEvent, type AuditedRemediationEvidence, type ContextEnvelope, type CorrectivePlanAuditInput, type DependencyProvenanceRecoveryPreflight, type DelegationGrant, type DelegationGrantGate, type DelegationPolicyInput, type DiscoveryState, type MilestonePlanInput, type MilestoneProgressProjection, type MilestoneState, type KnowledgeSelection, type GraphBinding, type GraphKind, type GraphMode, type GraphRefreshEvidence, type GraphRefreshRequest, type HistoricalStepProvenanceRecoveryPreflight, type PlanRiskAuditEvent, type PublicWriterLease, type PublicWriterLeaseDiagnostic, type PublicWriterLeaseRepairResult, type ProjectKnowledgeMap, type ReviewInput, type TaskPlanInput, type TaskContextRefreshResult, type TaskState, type UpdatePreflightResult, type WriterCredentialResult, type WriterCredentialStatus, type WorkflowObservation, type WorkflowRole, type WorkspaceOwner } from './contracts.js';
@@ -125,6 +126,7 @@ export declare class WorkflowService {
125
126
  constructor(store?: FileStateStore, now?: () => Date, transactionHooks?: WorkflowTransactionHooks, checkOptions?: CheckExecutionOptions);
126
127
  inspectWriterLease(repository: string, entityId: string): PublicWriterLeaseDiagnostic | null;
127
128
  repairStaleWriterLease(repository: string, entityId: string): PublicWriterLeaseRepairResult | ReturnType<CoreTaskOperationLockManager['repairExpiredOrphan']>;
129
+ authorizeDelegatedCorrectiveReplan(repository: string, taskId: string, candidate: CorrectiveReplanPublicCandidate): CorrectiveReplanPublicCredential;
128
130
  prepareCorrectiveReplan(repository: string, taskId: string, candidate: CorrectiveReplanPublicCandidate): CorrectiveReplanHumanGateResult;
129
131
  confirmCorrectiveReplan(repository: string, taskId: string, candidate: CorrectiveReplanPublicCandidate, gate: CorrectiveReplanHumanGate, confirmationCode: string): CorrectiveReplanPublicCredential;
130
132
  executeCorrectiveReplan(repository: string, taskId: string, candidate: CorrectiveReplanPublicCandidate, credential: CorrectiveReplanPublicCredential): CorrectiveReplanExecutionResult;
@@ -171,6 +173,7 @@ export declare class WorkflowService {
171
173
  listDelegations(projectId: string): DelegationGrant[];
172
174
  prepareMilestoneAutonomy(repository: string, milestoneId: string, expectedRevision: number, principal: string, delegate: string, expiresAt: string): MilestoneAutonomyPreparation;
173
175
  grantMilestoneAutonomy(repository: string, milestoneId: string, expectedRevision: number, principal: string, delegate: string, expiresAt: string, confirmationCode: string): ActiveMilestoneAutonomy;
176
+ bindMilestoneAutonomy(repository: string, milestoneId: string, expectedRevision: number, actor: string, grantId: string): ActiveMilestoneAutonomy;
174
177
  evolveMilestonePlanAutonomously(repository: string, milestoneId: string, expectedRevision: number, plan: MilestonePlanInput, actor: string): MilestoneState;
175
178
  authorizeMilestone(repository: string, milestoneId: string, expectedRevision: number, actor: string, reason?: string, delegationGrantId?: string | null): MilestoneState;
176
179
  private assertMilestoneValidationReady;
@@ -272,11 +275,46 @@ export declare class WorkflowService {
272
275
  recoveredMilestoneIds: string[];
273
276
  };
274
277
  prepareAdoption(repository: string): AdoptionPreparation;
275
- applyAdoption(repository: string, actor: string, confirmationCode: string): AdoptionPostureEvent;
278
+ applyAdoption(repository: string, actor: string, confirmationCode: string, delegationGrantId?: string | null): AdoptionPostureEvent;
276
279
  updatePreflight(repository: string): UpdatePreflightResult & {
277
280
  adoption: AdoptionPreparation | null;
278
281
  };
279
282
  private navigationUpdateBoundary;
283
+ failedCheckpointUpdateSourcePreflight(repository: string, taskId: string, tarball: string): {
284
+ eligible: boolean;
285
+ blockers: string[];
286
+ receipt: FailedCheckpointUpdateReceipt;
287
+ } | {
288
+ eligible: boolean;
289
+ blockers: string[];
290
+ receipt: null;
291
+ };
292
+ failedCheckpointUpdateTransportPreflight(repository: string, taskId: string, tarball: string, receipt: FailedCheckpointUpdateReceipt): {
293
+ eligible: boolean;
294
+ blockers: string[];
295
+ proof: {
296
+ receipt: FailedCheckpointUpdateReceipt;
297
+ target: {
298
+ commitSha: string;
299
+ parentCommitSha: string;
300
+ packageVersion: string;
301
+ };
302
+ baseTransport: string;
303
+ targetHead: string;
304
+ binding: import("./failed-checkpoint-update.js").FailedCheckpointUpdateBinding;
305
+ };
306
+ action: string;
307
+ expectedRevision: number;
308
+ actor: string;
309
+ } | {
310
+ eligible: boolean;
311
+ blockers: string[];
312
+ proof: null;
313
+ action?: never;
314
+ expectedRevision?: never;
315
+ actor?: never;
316
+ };
317
+ recoverFailedCheckpointUpdate(repository: string, taskId: string, expectedRevision: number, tarball: string, receipt: FailedCheckpointUpdateReceipt, actor: string, reason: string): TaskState;
280
318
  navigationUpdateSourcePreflight(repository: string, taskId: string, tarball: string): {
281
319
  eligible: boolean;
282
320
  blockers: string[];
@@ -390,6 +428,7 @@ export declare class WorkflowService {
390
428
  private currentCorrectiveDerivedTaskAuthority;
391
429
  private nextForTaskWithDelegation;
392
430
  private taskPlanContract;
431
+ private registeredPlanningContextTransport;
393
432
  private taskContextChangeBlocker;
394
433
  private stopOverrideContextRebindDecisionId;
395
434
  private taskHasTerminalCorrectiveDecision;
@@ -1,5 +1,6 @@
1
1
  import { assessNavigationDirtyCarryover } from './alpha6/navigation-dirty-carryover.js';
2
2
  import { navigationUpdateSource, assertNavigationSourceInstalled, inspectNavigationTransport } from './navigation-update.js';
3
+ import { failedCheckpointUpdateSource, assertFailedCheckpointInstalled, inspectFailedCheckpointTransport, readFailedCheckpointDirtyTransport, FAILED_CHECKPOINT_SOURCE, FAILED_CHECKPOINT_TARGET } from './failed-checkpoint-update.js';
3
4
  import { verifyNavigationUpdateArtifact } from './navigation-update-artifact.js';
4
5
  import { taskSyncChecks, taskSyncChecksHash, assertNoPendingBaseSyncValidation, assessPendingBaseSyncValidation, assertPendingBaseSyncValidationReady } from './checks/task-sync.js';
5
6
  import { isVirginRegistrationRoot } from './domain/virgin-registration.js';
@@ -33,14 +34,14 @@ import { applyAdoptionPosture, assertAdoptionBaselinePreserved, buildAdoptionPre
33
34
  import { appendCurrentPlanRiskAudit, appendReboundPlanRiskAudit, buildCandidatePlanRiskAuditEvent, buildPlanRiskAuditEvent, readCurrentPlanRiskAudit, readCurrentPlanningObstructionAudit, readPlanRiskAuditEvents, validatePlanRiskAuditCandidate, } from './alpha6/plan-risk.js';
34
35
  import { hashCompletedSteps, hashExecutionAuthorization, preparePreExecutionReplanEvent, preExecutionReplanSidecar, readCurrentPreExecutionReplan, } from './alpha6/preexecution-replan.js';
35
36
  import { assessRootCauseReplanDirtyCarryover, matchesTerminalCorrectiveYield, } from './alpha6/root-cause-replan-carryover.js';
36
- import { appendCorrectiveDecisionEvent, appendPlanIntegrityRecoveryDecision, assertCorrectiveAuditorIndependence, assertGuardedRemediationAttemptAllowed, defaultCorrectiveAuditorActor, effectiveStepAllowedWrites, isKnowledgeReboundSupportDecision, findCurrentGuardedRemediationPosture, findFailedGuardedStepRequiringCorrectiveDecision, readGuardedRemediationPostureForStep, readCorrectiveDecisionEvents, readRemediationEvents, deriveRollingCauseDecision, deriveCurrentCauseDecisionForTask, prepareRemediationEvent, stopEscalateOverrideDecisionEventIds, } from './alpha6/remediation.js';
37
+ import { appendCorrectiveDecisionEvent, firstFailurePlanningObstructionEvidence, appendPlanIntegrityRecoveryDecision, assertCorrectiveAuditorIndependence, assertGuardedRemediationAttemptAllowed, defaultCorrectiveAuditorActor, effectiveStepAllowedWrites, isKnowledgeReboundSupportDecision, findCurrentGuardedRemediationPosture, findFailedGuardedStepRequiringCorrectiveDecision, readGuardedRemediationPostureForStep, readCorrectiveDecisionEvents, readRemediationEvents, deriveRollingCauseDecision, deriveCurrentCauseDecisionForTask, prepareRemediationEvent, stopEscalateOverrideDecisionEventIds, } from './alpha6/remediation.js';
37
38
  import { assessPlanIntegrityRecovery, defaultPlanIntegrityRecoveryActor, } from './alpha6/plan-integrity.js';
38
39
  import { mechanicalCauseBindings, normalizeMechanicalFailures, } from './alpha6/remediation-cause.js';
39
40
  import { assertMechanicalFeasibilityFresh, evaluateMechanicalFeasibility, hashMechanicalFeasibilityEvidence, } from './alpha6/mechanical-feasibility.js';
40
41
  import { assessMilestoneInitialAssembly, applyInitialMilestonePlanTransaction, applyMilestoneScopeChangeTransaction, assertMilestoneDependenciesDeclared, assertMilestoneTaskRunnable, assessMilestoneTaskDependencies, assertMilestoneMembershipIntegrity, assertMilestoneScopeChangeStatusAllowed, inspectMilestoneWithIntegrity, normalizeMilestonePlan, prepareMilestoneScopeChangeCandidate, prepareMilestoneScopeChangeBundle, readMilestoneScopeChangeEvents, readMilestoneForScopeChange, assessMilestoneScopeCompletion, readMilestoneWithIntegrity, } from './alpha6/milestone.js';
41
42
  import { applyProjectTransaction, recoverProjectTransactions, runRollbackProjectTransaction, } from './beta1/project-transaction.js';
42
43
  import { buildCurrentStrictStepReviewCycle, countUnverifiedStrictStepReviews, ensurePendingStrictStepReview, isStepReviewRequired, latestFailedStepReviewRouting, latestPassedVerifiedStepReviewEvent, recordStrictStepReview, verifiedHistoricalStepReviewCommits, verifiedHistoricalStepReviewBindings, } from './alpha6/review.js';
43
- import { applyMilestoneAutonomyContract, assertAutonomousPlanEvolution, prepareMilestoneAutonomyContract, readMilestoneAutonomyEvents, requireActiveMilestoneAutonomy, } from './alpha7/autonomy.js';
44
+ import { applyMilestoneAutonomyContract, bindMilestoneAutonomyToGrant, milestoneSemanticScopeHash, assertAutonomousPlanEvolution, prepareMilestoneAutonomyContract, readMilestoneAutonomyEvents, requireActiveMilestoneAutonomy, } from './alpha7/autonomy.js';
44
45
  import { appendCorrectiveDecisionRecovery, readValidatedCorrectiveDecisionRecoveryForNavigation, readValidatedStopOverrideContextRebindIfApplicable, requireCorrectiveDecisionRecoveryForRun, } from './alpha7/corrective-recovery.js';
45
46
  import { applyKnowledgeSelections, hashKnowledgeMap, inspectKnowledgeMap, normalizeRelativePath, reconcileKnowledgeMap, scanProjectKnowledge, selectKnowledgeSources, } from './memory.js';
46
47
  import { canonicalJsonStringify, prepareSidecarAppend, sha256Hex } from './alpha6/store-sidecars.js';
@@ -168,6 +169,9 @@ export class WorkflowService {
168
169
  repaired: true,
169
170
  };
170
171
  }
172
+ authorizeDelegatedCorrectiveReplan(repository, taskId, candidate) {
173
+ return this.correctiveReplanController(repository).authorizeDelegated({ taskId, candidate });
174
+ }
171
175
  prepareCorrectiveReplan(repository, taskId, candidate) {
172
176
  return this.correctiveReplanController(repository).prepare({ taskId, candidate });
173
177
  }
@@ -1382,6 +1386,20 @@ export class WorkflowService {
1382
1386
  locks.release(milestoneId, lease.token);
1383
1387
  }
1384
1388
  }
1389
+ bindMilestoneAutonomy(repository, milestoneId, expectedRevision, actor, grantId) {
1390
+ const { identity, locks } = this.#mutationContext(repository);
1391
+ const lease = locks.acquire(milestoneId, 'workflow-core:autonomy-binding');
1392
+ try {
1393
+ const milestone = this.readMilestoneCurrent(identity.projectId, milestoneId);
1394
+ assertExpectedRevision(milestone, expectedRevision);
1395
+ this.requireActiveKnowledgeMap(identity.repositoryRoot, identity.projectId);
1396
+ return bindMilestoneAutonomyToGrant({ store: this.store, projectId: identity.projectId,
1397
+ milestone, actor, grantId, now: this.now() });
1398
+ }
1399
+ finally {
1400
+ locks.release(milestoneId, lease.token);
1401
+ }
1402
+ }
1385
1403
  evolveMilestonePlanAutonomously(repository, milestoneId, expectedRevision, plan, actor) {
1386
1404
  const { identity, locks } = this.#mutationContext(repository);
1387
1405
  const authorityLease = locks.acquire(milestoneId, 'workflow-core:milestone-authority');
@@ -2033,7 +2051,7 @@ export class WorkflowService {
2033
2051
  const { identity } = this.#mutationContext(repository);
2034
2052
  const task = this.store.readTask(identity.projectId, taskId);
2035
2053
  assertExpectedRevision(task, expectedRevision);
2036
- const contextBlocker = this.taskContextChangeBlocker(task, 'rebind');
2054
+ const contextBlocker = this.taskContextChangeBlocker(task, 'rebind', identity.repositoryRoot);
2037
2055
  // Preserve Plan-corruption precedence over the active-Step rejection.
2038
2056
  if (contextBlocker && !contextBlocker.activeStep)
2039
2057
  throw contextBlocker.error;
@@ -2124,18 +2142,22 @@ export class WorkflowService {
2124
2142
  const currentMap = this.store.readKnowledgeMap(identity.projectId);
2125
2143
  assertExpectedRevision(task, expectedTaskRevision);
2126
2144
  assertExpectedRevision(currentMap, expectedKnowledgeMapRevision);
2127
- const contextBlocker = this.taskContextChangeBlocker(task, 'refresh');
2145
+ const contextBlocker = this.taskContextChangeBlocker(task, 'refresh', identity.repositoryRoot);
2128
2146
  if (contextBlocker)
2129
2147
  throw contextBlocker.error;
2130
2148
  const inspectedMap = inspectKnowledgeMap(currentMap, scanProjectKnowledge(identity.repositoryRoot, identity.projectId, this.now()));
2131
2149
  const transitions = [];
2132
- const planningRecovery = readFailedStepPlanningRecovery(this.store, task);
2133
- const currentPlanRiskAudit = planningRecovery?.current ?? readCurrentPlanRiskAudit(this.store, task);
2150
+ const retainedAudits = JSON.stringify(readPlanRiskAuditEvents(this.store, task));
2151
+ const retainedRemediation = JSON.stringify(readRemediationEvents(this.store, task));
2152
+ const transport = this.registeredPlanningContextTransport(task, identity.repositoryRoot);
2153
+ const planningRecovery = transport ? null : readFailedStepPlanningRecovery(this.store, task);
2154
+ const planningOnly = Boolean(planningRecovery || transport);
2155
+ const currentPlanRiskAudit = transport ? null : planningRecovery?.current ?? readCurrentPlanRiskAudit(this.store, task);
2134
2156
  const currentPlanArtifactHash = task.planHash
2135
2157
  ? this.store.hashArtifact(this.store.taskRoot(identity.projectId, task.id), 'plan.md')
2136
2158
  : null;
2137
2159
  const refreshAssessment = assessDelegatedKnowledgeRefresh(currentMap, inspectedMap, task, currentPlanArtifactHash);
2138
- if (planningRecovery && refreshAssessment.mode !== 'delegated-content-only') {
2160
+ if (planningOnly && refreshAssessment.mode !== 'delegated-content-only') {
2139
2161
  throw new WorkflowError('TRANSITION_BLOCKED', 'Stopped planning context refresh permits content-only Knowledge drift.');
2140
2162
  }
2141
2163
  // Validate every delegated transition before the first write so a narrow grant cannot
@@ -2185,14 +2207,14 @@ export class WorkflowService {
2185
2207
  }
2186
2208
  transitions.push('task knowledge-rebind');
2187
2209
  // A stopped Plan may regain its Knowledge binding, never execution authority.
2188
- if (!planningRecovery)
2210
+ if (!planningOnly)
2189
2211
  refreshedTask = this.authorizeTask(repository, taskId, refreshedTask.revision, actor, refreshAssessment.mode === 'delegated-plan-bounded-supporting-source'
2190
2212
  ? 'Delegated Plan-bounded supporting-source context refresh.'
2191
2213
  : 'Delegated content-only context refresh.', delegationGrantId);
2192
- if (!planningRecovery)
2214
+ if (!planningOnly)
2193
2215
  transitions.push('task execution authorize');
2194
2216
  return {
2195
- authority: planningRecovery ? 'planning-only' : 'execution',
2217
+ authority: planningOnly ? 'planning-only' : 'execution',
2196
2218
  mode: refreshAssessment.mode,
2197
2219
  transitions,
2198
2220
  addedSources: refreshAssessment.addedSources,
@@ -2202,10 +2224,21 @@ export class WorkflowService {
2202
2224
  },
2203
2225
  validate: (result) => {
2204
2226
  const currentTask = this.store.readTask(identity.projectId, task.id);
2205
- if (currentTask.revision !== result.task.revision || currentTask.status !== (planningRecovery ? 'awaiting_execution_authorization' : 'ready')) {
2227
+ if (currentTask.revision !== result.task.revision || currentTask.status !== (planningOnly ? 'awaiting_execution_authorization' : 'ready')) {
2206
2228
  throw new WorkflowError('STATE_CORRUPT', 'Context refresh transaction did not commit the expected Task posture.');
2207
2229
  }
2208
- if (planningRecovery) {
2230
+ if (transport) {
2231
+ if (!readFailedCheckpointDirtyTransport(this.store, identity.repositoryRoot, currentTask, transport.stepId, transport.sourceHead, transport.sourceDirtyHash)) {
2232
+ throw new WorkflowError('STATE_CORRUPT', 'Transport context proof disappeared.');
2233
+ }
2234
+ if (JSON.stringify(currentTask.steps) !== JSON.stringify(task.steps)
2235
+ || JSON.stringify(currentTask.authorizations) !== JSON.stringify(task.authorizations)
2236
+ || JSON.stringify(readPlanRiskAuditEvents(this.store, currentTask)) !== retainedAudits
2237
+ || JSON.stringify(readRemediationEvents(this.store, currentTask)) !== retainedRemediation) {
2238
+ throw new WorkflowError('STATE_CORRUPT', 'Transport context refresh changed retained evidence.');
2239
+ }
2240
+ }
2241
+ if (planningRecovery && !transport) {
2209
2242
  const rebound = readFailedStepPlanningRecovery(this.store, currentTask);
2210
2243
  if (!rebound || rebound.baseline.eventHash !== planningRecovery.baseline.eventHash
2211
2244
  || JSON.stringify(currentTask.steps) !== JSON.stringify(task.steps)
@@ -4031,7 +4064,7 @@ export class WorkflowService {
4031
4064
  const { identity } = this.#mutationContext(repository);
4032
4065
  return this.inspectAdoptionPreparation(identity, this.store.listTasks(identity.projectId), this.store.listMilestones(identity.projectId));
4033
4066
  }
4034
- applyAdoption(repository, actor, confirmationCode) {
4067
+ applyAdoption(repository, actor, confirmationCode, delegationGrantId = null) {
4035
4068
  const context = this.#mutationContext(repository);
4036
4069
  const tasks = context.store.listTasks(context.identity.projectId);
4037
4070
  const milestones = context.store.listMilestones(context.identity.projectId);
@@ -4046,7 +4079,7 @@ export class WorkflowService {
4046
4079
  sidecarInventory: this.collectAdoptionSidecarInventory(context.identity.projectId, tasks, milestones),
4047
4080
  blockers: this.computeAdoptionBoundaryBlockers(context.identity, tasks, context.locks.list()),
4048
4081
  now: this.now(),
4049
- }, actor, confirmationCode);
4082
+ }, actor, confirmationCode, delegationGrantId);
4050
4083
  }
4051
4084
  updatePreflight(repository) {
4052
4085
  const snapshot = this.observationSnapshot(repository);
@@ -4146,6 +4179,47 @@ export class WorkflowService {
4146
4179
  throw new WorkflowError('TRANSITION_BLOCKED', 'Navigation update supports one active base branch.');
4147
4180
  return { snapshot, task, root: snapshot.identity.repositoryRoot };
4148
4181
  }
4182
+ failedCheckpointUpdateSourcePreflight(repository, taskId, tarball) {
4183
+ try {
4184
+ const { task, root } = this.navigationUpdateBoundary(repository, taskId);
4185
+ assertFailedCheckpointInstalled(root, task, FAILED_CHECKPOINT_SOURCE);
4186
+ const receipt = failedCheckpointUpdateSource(root, this.store, task, verifyNavigationUpdateArtifact(tarball));
4187
+ return { eligible: true, blockers: [], receipt };
4188
+ }
4189
+ catch (error) {
4190
+ return { eligible: false, blockers: [error instanceof Error ? error.message : String(error)], receipt: null };
4191
+ }
4192
+ }
4193
+ failedCheckpointUpdateTransportPreflight(repository, taskId, tarball, receipt) {
4194
+ try {
4195
+ const { task, root } = this.navigationUpdateBoundary(repository, taskId);
4196
+ const proof = inspectFailedCheckpointTransport(root, this.store, task, receipt, verifyNavigationUpdateArtifact(tarball, path.join(root, 'node_modules/codex-workflow-v2')));
4197
+ return { eligible: true, blockers: [], proof,
4198
+ action: 'update failed-checkpoint-recover', expectedRevision: task.revision, actor: receipt.actor };
4199
+ }
4200
+ catch (error) {
4201
+ return { eligible: false, blockers: [error instanceof Error ? error.message : String(error)], proof: null };
4202
+ }
4203
+ }
4204
+ recoverFailedCheckpointUpdate(repository, taskId, expectedRevision, tarball, receipt, actor, reason) {
4205
+ this.#mutationContext(repository);
4206
+ const { task, root } = this.navigationUpdateBoundary(repository, taskId);
4207
+ assertExpectedRevision(task, expectedRevision);
4208
+ if (!actor.trim() || actor !== receipt?.actor || !reason.trim()) {
4209
+ throw new WorkflowError('INVALID_ARGUMENT', 'Failed-checkpoint update requires the original claimant and an explicit reason.');
4210
+ }
4211
+ const proof = inspectFailedCheckpointTransport(root, this.store, task, receipt, verifyNavigationUpdateArtifact(tarball, path.join(root, 'node_modules/codex-workflow-v2')));
4212
+ const updated = { ...task, status: 'awaiting_execution_authorization',
4213
+ systemCommits: [...task.systemCommits, proof.target.commitSha],
4214
+ dependencyProvenanceRecoveries: [...(task.dependencyProvenanceRecoveries ?? []), {
4215
+ ...proof.target, packageName: PACKAGE_NAME, files: ['package-lock.json', 'package.json'], actor,
4216
+ reason: `${reason.trim()} [failed-checkpoint-update ${receipt.artifact.sha256}]`,
4217
+ recordedAt: this.now().toISOString(), failedCheckpoint: proof.binding,
4218
+ }],
4219
+ };
4220
+ validateTaskHistory(root, updated);
4221
+ return this.store.writeTask(updated, expectedRevision);
4222
+ }
4149
4223
  navigationUpdateSourcePreflight(repository, taskId, tarball) {
4150
4224
  try {
4151
4225
  const { task, root } = this.navigationUpdateBoundary(repository, taskId);
@@ -4567,7 +4641,7 @@ export class WorkflowService {
4567
4641
  if (!allowAtomicTaskRefresh && current.status === 'active' && current.approval) {
4568
4642
  const milestonesById = new Map(this.listMilestonesCurrent(identity.projectId).map((milestone) => [milestone.id, milestone]));
4569
4643
  const inspected = inspectKnowledgeMap(current, scanned);
4570
- const refreshOwner = this.findDelegatedContextRefreshOwner(identity.projectId, this.store.listTasks(identity.projectId), milestonesById, current, inspected);
4644
+ const refreshOwner = this.findDelegatedContextRefreshOwner(identity.projectId, this.store.listTasks(identity.projectId), milestonesById, current, inspected, identity.repositoryRoot);
4571
4645
  if (refreshOwner) {
4572
4646
  throw new WorkflowError('TRANSITION_BLOCKED', 'Standalone Project Knowledge reconcile would strand an authorized Task context refresh.', {
4573
4647
  taskId: refreshOwner.task.id,
@@ -4720,7 +4794,18 @@ export class WorkflowService {
4720
4794
  currentEventType: status.adoption.currentPosture?.eventType ?? null,
4721
4795
  };
4722
4796
  if (status.adoption.status !== 'applied') {
4797
+ const adoptionApprovals = this.listDelegations(status.projectId).flatMap(grant => {
4798
+ try {
4799
+ return [assertDelegationCanAuthorize(grant, 'project.adopt', grant.delegate, { kind: 'project', id: status.projectId }, this.now())];
4800
+ }
4801
+ catch (error) {
4802
+ if (error instanceof WorkflowError && error.code === 'TRANSITION_BLOCKED')
4803
+ return [];
4804
+ throw error;
4805
+ }
4806
+ });
4723
4807
  return {
4808
+ ...(adoptionApprovals.length ? { delegatedApprovalOptions: adoptionApprovals } : {}),
4724
4809
  scope: 'project',
4725
4810
  projectId: status.projectId,
4726
4811
  status: status.adoption.status,
@@ -4729,7 +4814,7 @@ export class WorkflowService {
4729
4814
  observation: status.observation,
4730
4815
  navigation: status.adoption.safe
4731
4816
  ? {
4732
- kind: 'human-gate',
4817
+ kind: adoptionApprovals.length ? 'delegated' : 'human-gate',
4733
4818
  transitionId: null,
4734
4819
  cataloged: false,
4735
4820
  command: 'state adoption-apply',
@@ -4751,6 +4836,49 @@ export class WorkflowService {
4751
4836
  }
4752
4837
  const withAdoption = (value) => ({
4753
4838
  ...value,
4839
+ delegatedMilestoneAutonomyOptions: status.milestones.flatMap(milestone => {
4840
+ if (!['active', 'awaiting_execution_authorization'].includes(milestone.status) || !milestone.planHash)
4841
+ return [];
4842
+ const previousContract = readMilestoneAutonomyEvents(this.store, status.projectId, milestone.id).at(-1);
4843
+ if (previousContract) {
4844
+ if (previousContract.semanticScopeHash !== milestoneSemanticScopeHash(milestone))
4845
+ return [];
4846
+ try {
4847
+ const previousGrant = this.store.readDelegation(status.projectId, previousContract.delegationGrantId);
4848
+ if (previousGrant.status === 'active' && Date.parse(previousGrant.expiresAt) > this.now().getTime())
4849
+ return [];
4850
+ }
4851
+ catch (error) {
4852
+ if (!(error instanceof WorkflowError) || error.code !== 'NOT_FOUND')
4853
+ throw error;
4854
+ }
4855
+ }
4856
+ try {
4857
+ this.requireActiveKnowledgeMap(repository, status.projectId);
4858
+ }
4859
+ catch (error) {
4860
+ if (error instanceof WorkflowError)
4861
+ return [];
4862
+ throw error;
4863
+ }
4864
+ return this.listDelegations(status.projectId).flatMap(grant => {
4865
+ if (grant.scope.kind !== 'milestone' || grant.scope.id !== milestone.id
4866
+ || !['task.execution_authorize', 'task.final_accept', 'milestone.execution_authorize', 'milestone.final_accept']
4867
+ .every(transition => grant.transitions.some(value => value === transition)))
4868
+ return [];
4869
+ try {
4870
+ assertDelegationCanAuthorize(grant, 'milestone.execution_authorize', grant.delegate, milestone, this.now());
4871
+ return [{ action: 'milestone autonomy-bind', milestoneId: milestone.id,
4872
+ expectedRevision: milestone.revision, actor: grant.delegate, delegationGrantId: grant.id,
4873
+ issuesGrant: false, requiresExactHumanConfirmation: false }];
4874
+ }
4875
+ catch (error) {
4876
+ if (error instanceof WorkflowError && error.code === 'TRANSITION_BLOCKED')
4877
+ return [];
4878
+ throw error;
4879
+ }
4880
+ });
4881
+ }),
4754
4882
  ...(status.milestones.some((milestone) => milestone.status === 'active' && milestone.planHash)
4755
4883
  ? { activeMilestoneAutonomyOptions: status.milestones
4756
4884
  .filter((milestone) => milestone.status === 'active' && milestone.planHash)
@@ -4883,7 +5011,7 @@ export class WorkflowService {
4883
5011
  if (approved?.status === 'active' && approved.approval) {
4884
5012
  const inspected = inspectCurrentKnowledgeMap();
4885
5013
  if (inspected.status === 'stale')
4886
- prioritizedRefreshTask = this.findDelegatedContextRefreshOwner(status.projectId, status.tasks, milestonesById, approved, inspected)?.task ?? null;
5014
+ prioritizedRefreshTask = this.findDelegatedContextRefreshOwner(status.projectId, status.tasks, milestonesById, approved, inspected, repositoryRoot)?.task ?? null;
4887
5015
  }
4888
5016
  }
4889
5017
  const activeTask = requestedTask
@@ -4929,6 +5057,17 @@ export class WorkflowService {
4929
5057
  dependencyProvenanceRecovery: dependencyRecovery,
4930
5058
  });
4931
5059
  }
5060
+ if (PACKAGE_VERSION === FAILED_CHECKPOINT_TARGET && activeTask.status === 'awaiting_execution_authorization'
5061
+ && activeTask.workspaceOwner === 'external' && activeTask.steps.some(step => step.status === 'failed')) {
5062
+ const transport = inspectBoundedWorkflowDependencyCommit(repositoryRoot, headCommit(repositoryRoot));
5063
+ if (transport?.packageVersion === FAILED_CHECKPOINT_TARGET && !activeTask.systemCommits.includes(transport.commitSha)) {
5064
+ return withAdoption({ scope: 'task', id: activeTask.id, revision: activeTask.revision,
5065
+ action: 'update failed-checkpoint-transport-preflight',
5066
+ requiredInputs: ['--tarball <exact target artifact>', '--file <source receipt>'],
5067
+ reason: 'Verify the original failed-checkpoint receipt, native failure and retained product bytes before registering the dependency transport.',
5068
+ });
5069
+ }
5070
+ }
4932
5071
  const navigationSourceHead = activeTask.authorizations.filter(item => item.kind === 'execution' && item.decision === 'approved').at(-1)?.headCommit;
4933
5072
  if (activeTask.status === 'ready' && navigationSourceHead
4934
5073
  && activeTask.dependencyProvenanceRecoveries?.some(item => item.planIntegrity?.mode === 'navigation-fix-dirty-carryover')) {
@@ -5242,10 +5381,10 @@ export class WorkflowService {
5242
5381
  const contextRefreshOptions = action === 'project-memory reconcile'
5243
5382
  && (taskNext?.action !== 'task plan-set' || rollingRootCausePlanSet)
5244
5383
  && refreshAssessment?.eligible
5245
- ? this.delegatedContextRefreshOptions(status.projectId, activeTask, knowledgeMap, refreshAssessment.mode)
5384
+ ? this.delegatedContextRefreshOptions(status.projectId, activeTask, knowledgeMap, refreshAssessment.mode, repositoryRoot)
5246
5385
  : [];
5247
5386
  if (requestedTask && action === 'project-memory reconcile' && contextRefreshOptions.length === 0) {
5248
- const refreshOwner = this.findDelegatedContextRefreshOwner(status.projectId, status.tasks, milestonesById, storedKnowledgeMap, knowledgeMap);
5387
+ const refreshOwner = this.findDelegatedContextRefreshOwner(status.projectId, status.tasks, milestonesById, storedKnowledgeMap, knowledgeMap, repositoryRoot);
5249
5388
  if (refreshOwner && refreshOwner.task.id !== requestedTask.id) {
5250
5389
  throw new WorkflowError('TRANSITION_BLOCKED', `Task ${requestedTask.id} cannot be selected while Task ${refreshOwner.task.id} requires an atomic context refresh.`, {
5251
5390
  taskId: requestedTask.id,
@@ -5272,7 +5411,7 @@ export class WorkflowService {
5272
5411
  contextRefresh: {
5273
5412
  action: 'task context-refresh',
5274
5413
  mode: refreshAssessment.mode,
5275
- authority: readFailedStepPlanningRecovery(this.store, activeTask) ? 'planning-only' : 'execution',
5414
+ authority: (this.registeredPlanningContextTransport(activeTask, repositoryRoot) || readFailedStepPlanningRecovery(this.store, activeTask)) ? 'planning-only' : 'execution',
5276
5415
  addedSources: refreshAssessment.addedSources,
5277
5416
  options: contextRefreshOptions,
5278
5417
  },
@@ -5878,12 +6017,13 @@ export class WorkflowService {
5878
6017
  : {};
5879
6018
  const correctiveReplanOverlay = (posture) => {
5880
6019
  const evaluation = evaluateTaskCorrectiveReplanAvailability(task, posture);
6020
+ const replanDelegations = this.delegatedApprovalOptions(task.projectId, 'task.execution_authorize', task);
5881
6021
  const writerLease = inspectRawWriterLease(this.store.lockRoot(task.projectId), task.id, this.store.root);
5882
6022
  const command = handoffPosture.state === 'claimed'
5883
6023
  ? 'task corrective-yield'
5884
6024
  : writerLease
5885
6025
  ? 'doctor'
5886
- : 'task corrective-replan-prepare';
6026
+ : replanDelegations.length ? 'task corrective-replan-authorize' : 'task corrective-replan-prepare';
5887
6027
  if (evaluation.allowed && handoffPosture.state === 'none' && writerLease) {
5888
6028
  const navigation = correctiveReplanNavigation(evaluation);
5889
6029
  return {
@@ -5914,16 +6054,19 @@ export class WorkflowService {
5914
6054
  return evaluation.allowed
5915
6055
  ? {
5916
6056
  action: command,
6057
+ ...(replanDelegations.length ? { delegatedApprovalOptions: replanDelegations, correctiveReplanAuthority: { mode: 'delegated', candidateField: 'delegation', actorHash: 'sha256-utf8-grant-delegate', principalHash: 'sha256-utf8-grant-principal', grantTransition: 'task.execution_authorize' } } : {}),
5917
6058
  blockedAction: 'task plan-set',
5918
6059
  stepId: posture.stepId,
5919
- navigation: { ...correctiveReplanNavigation(evaluation), command },
6060
+ navigation: { ...correctiveReplanNavigation(evaluation), kind: replanDelegations.length ? 'executable' : 'human-gate', command },
5920
6061
  correctiveDecisionGate: {
5921
6062
  attemptCount: posture.attemptCount,
5922
6063
  decision: posture.correctiveDecision?.decision ?? null,
5923
6064
  decisionEventId: posture.correctiveDecision?.eventId ?? null,
5924
6065
  requiredAction: handoffPosture.state === 'claimed'
5925
6066
  ? 'Yield the exact C1 claim and writer lease before preparing replacement authority.'
5926
- : 'Prepare a state-bound candidate, confirm the Human gate, then execute its exact receipt.',
6067
+ : replanDelegations.length
6068
+ ? 'Prepare an independently validated same-scope candidate with the eligible grant and actor; authorize it without Human confirmation, then execute its exact delegated receipt.'
6069
+ : 'No eligible execution grant: request issuance/expansion of grant for delegate mode; the explicit Human preparation route remains available outside delegate mode.',
5927
6070
  },
5928
6071
  }
5929
6072
  : {
@@ -6461,12 +6604,14 @@ export class WorkflowService {
6461
6604
  // fix review. Advertise the existing append-only decision route without turning
6462
6605
  // every ordinary repair into a mandatory replan or rewriting that review.
6463
6606
  const correctiveDecisionOrdinal = failedStepRemediations.length + 1;
6607
+ const firstFailurePlanningObstruction = planningRecovery && failedStep
6608
+ ? firstFailurePlanningObstructionEvidence(this.store, task, failedStep.id) : null;
6464
6609
  const optionalCorrectiveDecision = (result.action === 'task run' || planningRecovery !== null)
6465
6610
  && (['needs_fix', 'ready'].includes(task.status) || planningRecovery !== null)
6466
6611
  && failedStep && task.planHash && planRiskAudit
6467
6612
  && planRiskAudit.reviewRequiredStepIds.includes(failedStep.id)
6468
6613
  && !task.steps.some(step => step.status === 'in_progress')
6469
- && failedStepRemediations.length >= 2
6614
+ && (failedStepRemediations.length >= 2 || firstFailurePlanningObstruction !== null)
6470
6615
  && handoffPosture.state !== 'pending'
6471
6616
  && !readCorrectiveDecisionEvents(this.store, task).some(event => event.stepId === failedStep.id && event.triggeringAttemptCount === correctiveDecisionOrdinal)
6472
6617
  && correctiveDecisionCheckoutEligible(this.store, repositoryRoot, task, failedStep.id)
@@ -6485,12 +6630,13 @@ export class WorkflowService {
6485
6630
  recommendedAuditor: defaultCorrectiveAuditorActor(task.id),
6486
6631
  auditorMustDifferFromLatestStrictReviewer: true,
6487
6632
  requiredActor: handoffPosture.state === 'claimed' ? handoffPosture.claimant : null,
6488
- decisions: planningRecovery ? ['replan-required', 'split-required', 'stop-escalate']
6489
- : ['continue-fix', 'replan-required', 'split-required', 'stop-escalate'],
6633
+ decisions: firstFailurePlanningObstruction ? ['replan-required']
6634
+ : planningRecovery ? ['replan-required', 'split-required', 'stop-escalate']
6635
+ : ['continue-fix', 'replan-required', 'split-required', 'stop-escalate'],
6490
6636
  authority: 'none',
6491
6637
  preservesOriginalReview: true,
6492
6638
  humanApprovalRequiredForDecision: false,
6493
- replanRequiresExistingHumanGate: true,
6639
+ replanRequiresBoundAuthorization: true,
6494
6640
  requiredAction: 'Only for newly assessed evidence: obtain an independent corrective audit, refresh next and existing writer authority, then record the decision. This option does not authorize Plan replacement or extra writes.',
6495
6641
  }
6496
6642
  : null;
@@ -6538,7 +6684,28 @@ export class WorkflowService {
6538
6684
  },
6539
6685
  };
6540
6686
  }
6541
- taskContextChangeBlocker(task, operation) {
6687
+ registeredPlanningContextTransport(task, repositoryRoot) {
6688
+ const failedTransport = repositoryRoot
6689
+ && task.status === 'awaiting_execution_authorization'
6690
+ && !task.steps.some(step => step.status === 'in_progress')
6691
+ && !readPlanRiskAuditEvents(this.store, task).some(event => event.planHash === task.planHash && event.decision !== 'stop-escalate')
6692
+ && readCorrectiveDecisionEvents(this.store, task).length === 0
6693
+ ? task.dependencyProvenanceRecoveries?.find(record => record.failedCheckpoint
6694
+ && task.steps.some(step => step.id === record.failedCheckpoint.stepId && step.status === 'failed'))
6695
+ : null;
6696
+ if (failedTransport?.failedCheckpoint && repositoryRoot) {
6697
+ const binding = failedTransport.failedCheckpoint;
6698
+ // Historical transports remain readable after later legitimate progress. Validate
6699
+ // their artifact first, but require current dirty bytes only for this exact checkpoint.
6700
+ readVerifiedPlanArtifact(this.store.taskRoot(task.projectId, task.id), binding.sourcePlanHash, task.planHash);
6701
+ if (binding.sourcePlanHash !== task.planHash)
6702
+ return null;
6703
+ if (readFailedCheckpointDirtyTransport(this.store, repositoryRoot, task, binding.stepId, binding.sourceHead, binding.sourceDirtyHash))
6704
+ return binding;
6705
+ }
6706
+ return null;
6707
+ }
6708
+ taskContextChangeBlocker(task, operation, repositoryRoot) {
6542
6709
  const blocked = (error) => ({ error, activeStep: false });
6543
6710
  if (readCurrentPreExecutionReplan(this.store, task)) {
6544
6711
  return blocked(new WorkflowError('TRANSITION_BLOCKED', `Task ${task.id} has a pending pre-execution replan; replace the implementation Plan before changing context.`, { taskId: task.id, requiredAction: 'task plan-set' }));
@@ -6549,6 +6716,8 @@ export class WorkflowService {
6549
6716
  requiredAction: 'Run task plan-set with the full unfinished remainder before requesting authorization.',
6550
6717
  }));
6551
6718
  }
6719
+ if (repositoryRoot && this.registeredPlanningContextTransport(task, repositoryRoot))
6720
+ return null;
6552
6721
  const posture = this.taskTerminalCorrectivePosture(task);
6553
6722
  if (posture) {
6554
6723
  return blocked(new WorkflowError('TRANSITION_BLOCKED', `Task ${task.id} has terminal corrective decision ${posture.posture}; Project Knowledge cannot rebind or refresh this Task.`, {
@@ -6636,10 +6805,11 @@ export class WorkflowService {
6636
6805
  policyHash: grant.policyHash,
6637
6806
  }));
6638
6807
  }
6639
- delegatedContextRefreshOptions(projectId, task, knowledgeMap, mode) {
6808
+ delegatedContextRefreshOptions(projectId, task, knowledgeMap, mode, repositoryRoot) {
6640
6809
  let planningRecovery;
6641
6810
  try {
6642
- planningRecovery = readFailedStepPlanningRecovery(this.store, task);
6811
+ planningRecovery = this.registeredPlanningContextTransport(task, repositoryRoot)
6812
+ ?? readFailedStepPlanningRecovery(this.store, task);
6643
6813
  if (!planningRecovery)
6644
6814
  readCurrentPlanRiskAudit(this.store, task);
6645
6815
  }
@@ -6676,7 +6846,7 @@ export class WorkflowService {
6676
6846
  policyHash: grant.policyHash,
6677
6847
  }));
6678
6848
  }
6679
- findDelegatedContextRefreshOwner(projectId, tasks, milestonesById, approved, inspected) {
6849
+ findDelegatedContextRefreshOwner(projectId, tasks, milestonesById, approved, inspected, repositoryRoot) {
6680
6850
  const tasksById = new Map(tasks.map((task) => [task.id, task]));
6681
6851
  for (const task of tasks) {
6682
6852
  if (!taskIsActionableFromRepositoryNext(task, milestonesById, tasksById)
@@ -6685,8 +6855,8 @@ export class WorkflowService {
6685
6855
  const assessment = assessDelegatedKnowledgeRefresh(approved, inspected, task, this.store.hashArtifact(this.store.taskRoot(projectId, task.id), 'plan.md'));
6686
6856
  if (!assessment.eligible)
6687
6857
  continue;
6688
- const options = this.delegatedContextRefreshOptions(projectId, task, inspected, assessment.mode);
6689
- if (options.length > 0 && this.taskContextChangeBlocker(task, 'refresh') === null)
6858
+ const options = this.delegatedContextRefreshOptions(projectId, task, inspected, assessment.mode, repositoryRoot);
6859
+ if (options.length > 0 && this.taskContextChangeBlocker(task, 'refresh', repositoryRoot) === null)
6690
6860
  return { task, assessment, options };
6691
6861
  }
6692
6862
  return null;