codex-workflow-v2 2.0.0-beta.12.1 → 2.0.0-beta.12.2

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.
@@ -20,7 +20,7 @@ import { assessMilestoneInitialAssembly, applyInitialMilestonePlanTransaction, a
20
20
  import { applyProjectTransaction, recoverProjectTransactions, runRollbackProjectTransaction, } from './beta1/project-transaction.js';
21
21
  import { buildCurrentStrictStepReviewCycle, countUnverifiedStrictStepReviews, ensurePendingStrictStepReview, isStepReviewRequired, latestFailedStepReviewRouting, latestPassedVerifiedStepReviewEvent, recordStrictStepReview, verifiedHistoricalStepReviewCommits, } from './alpha6/review.js';
22
22
  import { applyMilestoneAutonomyContract, assertAutonomousPlanEvolution, prepareMilestoneAutonomyContract, readMilestoneAutonomyEvents, requireActiveMilestoneAutonomy, } from './alpha7/autonomy.js';
23
- import { appendCorrectiveDecisionRecovery, readValidatedCorrectiveDecisionRecoveryForNavigation, requireCorrectiveDecisionRecoveryForRun, } from './alpha7/corrective-recovery.js';
23
+ import { appendCorrectiveDecisionRecovery, readValidatedCorrectiveDecisionRecoveryForNavigation, readValidatedStopOverrideContextRebindIfApplicable, requireCorrectiveDecisionRecoveryForRun, } from './alpha7/corrective-recovery.js';
24
24
  import { applyKnowledgeSelections, hashKnowledgeMap, inspectKnowledgeMap, normalizeRelativePath, reconcileKnowledgeMap, scanProjectKnowledge, selectKnowledgeSources, } from './memory.js';
25
25
  import { canonicalJsonStringify, sha256Hex } from './alpha6/store-sidecars.js';
26
26
  import { ensureDirectory } from './fs-utils.js';
@@ -1827,7 +1827,10 @@ export class WorkflowService {
1827
1827
  const recovery = staleDecision?.decision === 'continue-fix'
1828
1828
  ? requireCorrectiveDecisionRecoveryForRun(this.store, task, stepId, actor, writerToken)
1829
1829
  : null;
1830
- const gate = assertGuardedRemediationAttemptAllowed(this.store, task, stepId, planRiskAudit, recovery?.correctiveDecisionEventId ?? null);
1830
+ const stopOverrideContextRebind = staleDecision?.decision === 'stop-escalate'
1831
+ ? readValidatedStopOverrideContextRebindIfApplicable(this.store, task, stepId)
1832
+ : null;
1833
+ const gate = assertGuardedRemediationAttemptAllowed(this.store, task, stepId, planRiskAudit, recovery?.correctiveDecisionEventId ?? null, stopOverrideContextRebind?.stopDecision.eventId ?? null);
1831
1834
  resumesCorrectiveReplan = gate.posture === 'replan-ready';
1832
1835
  }
1833
1836
  const knowledgeMap = this.assertTaskKnowledgeBinding(context.identity.repositoryRoot, task);
@@ -2065,7 +2068,7 @@ export class WorkflowService {
2065
2068
  checksHash: sha256Hex(canonicalJsonStringify(checks)),
2066
2069
  reviewEventHash: null,
2067
2070
  reviewerAttestationHash: null,
2068
- }, planRiskAudit, this.now());
2071
+ }, planRiskAudit, this.now(), this.stopOverrideContextRebindDecisionId(task, stepId));
2069
2072
  }
2070
2073
  const steps = task.steps.map((candidate) => candidate.id === stepId ? { ...candidate, status: 'failed' } : candidate);
2071
2074
  return this.store.writeTask({ ...task, status: 'needs_fix', steps, blockReason: `${stepId} checks failed.` }, expectedRevision);
@@ -2185,7 +2188,7 @@ export class WorkflowService {
2185
2188
  checksHash: currentCycle.reviewRecordedEvent.checksHash,
2186
2189
  reviewEventHash: currentCycle.reviewRecordedEvent.eventHash,
2187
2190
  reviewerAttestationHash: currentCycle.reviewerAttestationEvent.eventHash,
2188
- }, planRiskAudit, this.now());
2191
+ }, planRiskAudit, this.now(), this.stopOverrideContextRebindDecisionId(task, stepId));
2189
2192
  }
2190
2193
  return this.store.writeTask(applyStrictStepReviewResolution(task, stepId, currentCycle.resolution), expectedRevision);
2191
2194
  }
@@ -2213,7 +2216,7 @@ export class WorkflowService {
2213
2216
  checksHash: reviewRecordedEvent.checksHash,
2214
2217
  reviewEventHash: reviewRecordedEvent.eventHash,
2215
2218
  reviewerAttestationHash: reviewerAttestationEvent.eventHash,
2216
- }, planRiskAudit, this.now());
2219
+ }, planRiskAudit, this.now(), this.stopOverrideContextRebindDecisionId(task, stepId));
2217
2220
  }
2218
2221
  return this.store.writeTask(applyStrictStepReviewResolution(task, stepId, recorded.resolution, launch.review.summary), expectedRevision);
2219
2222
  }
@@ -2285,7 +2288,7 @@ export class WorkflowService {
2285
2288
  checksHash: recorded.reviewRecordedEvent.checksHash,
2286
2289
  reviewEventHash: recorded.reviewRecordedEvent.eventHash,
2287
2290
  reviewerAttestationHash: recorded.reviewerAttestationEvent.eventHash,
2288
- }, readCurrentPlanRiskAudit(this.store, task), this.now());
2291
+ }, readCurrentPlanRiskAudit(this.store, task), this.now(), this.stopOverrideContextRebindDecisionId(task, stepId));
2289
2292
  }
2290
2293
  const saved = this.store.writeTask(applyStrictStepReviewResolution(task, stepId, recorded.resolution, review.summary), expectedRevision);
2291
2294
  return {
@@ -3956,6 +3959,39 @@ export class WorkflowService {
3956
3959
  case 'decision-required':
3957
3960
  if (guardedCorrectivePosture.correctiveDecision
3958
3961
  && guardedCorrectivePosture.correctiveDecision.planHash !== task.planHash) {
3962
+ if (guardedCorrectivePosture.correctiveDecision.decision === 'stop-escalate') {
3963
+ try {
3964
+ const assessment = readValidatedStopOverrideContextRebindIfApplicable(this.store, task, guardedCorrectivePosture.stepId);
3965
+ if (!assessment) {
3966
+ throw new WorkflowError('TRANSITION_BLOCKED', 'Stale stop decision has no validated stop-override context-rebind continuation.');
3967
+ }
3968
+ guardedCorrectiveOverlay = {
3969
+ action: 'task run',
3970
+ stepId: guardedCorrectivePosture.stepId,
3971
+ stopOverrideContextRebind: {
3972
+ state: 'validated',
3973
+ overrideEventId: assessment.override.eventId,
3974
+ stopDecisionEventId: assessment.stopDecision.eventId,
3975
+ sourcePlanHash: assessment.override.planHash,
3976
+ reboundPlanHash: task.planHash,
3977
+ semanticPlanHash: assessment.semanticPlanHash,
3978
+ appendOnly: true,
3979
+ },
3980
+ };
3981
+ }
3982
+ catch (error) {
3983
+ guardedCorrectiveOverlay = {
3984
+ action: 'doctor',
3985
+ stepId: guardedCorrectivePosture.stepId,
3986
+ blockedAction: 'task run',
3987
+ stopOverrideContextRebind: {
3988
+ state: 'blocked',
3989
+ reason: error instanceof Error ? error.message : String(error),
3990
+ },
3991
+ };
3992
+ }
3993
+ break;
3994
+ }
3959
3995
  try {
3960
3996
  const navigation = readValidatedCorrectiveDecisionRecoveryForNavigation(this.store, task, guardedCorrectivePosture.stepId);
3961
3997
  guardedCorrectiveOverlay = navigation.recovery
@@ -4234,6 +4270,9 @@ export class WorkflowService {
4234
4270
  : 'Escalate outside this Task; stop-escalate cannot be resumed or rebound.',
4235
4271
  });
4236
4272
  }
4273
+ stopOverrideContextRebindDecisionId(task, stepId) {
4274
+ return readValidatedStopOverrideContextRebindIfApplicable(this.store, task, stepId)?.stopDecision.eventId ?? null;
4275
+ }
4237
4276
  taskHasTerminalCorrectiveDecision(task) {
4238
4277
  return this.taskTerminalCorrectivePosture(task) !== null;
4239
4278
  }