Skip to content
1 min read · 223 words

Function: approvePlan()

ts
function approvePlan(
  store: PlanStore,
  planId: string,
  record: ApprovalRecord,
): Promise<TransitionResult>;

Defined in: src/batteries/orchestration/approval.ts:145

Approves a frozen reviewable plan and moves it to executable.

The frozen content is rebuilt by folding the store's op log, the reachable authority set is recomputed, and it is asserted SET-EQUAL to record.authoritySet. Only then is the store's transition called, passing the recomputed digest as expectedDigest so the store refuses a stale commit, and the decision as the approval payload.

A set mismatch means the operator approved a different authority set than the plan actually carries, so the request is refused BEFORE the store is touched. The refusal is a TransitionResult-shaped failure returned rather than thrown: since TransitionResult has no free-form reason, the failure is reported as a digest_mismatch (an authority-set inequality is by definition a different content digest), carrying the actual digest and the assumed reviewable state so a caller that lost can read what happened.

Parameters

ParameterTypeDescription
storePlanStoreThe plan store holding the frozen plan.
planIdstringIdentity of the plan to approve.
recordApprovalRecordThe operator's decision, whose authoritySet must match the plan's recomputed reachable set exactly (order-insensitive).

Returns

Promise<TransitionResult>

The store's transition result, or a digest_mismatch-shaped refusal when the recomputed set does not match.