Skip to content

Interface: BranchableScope<THandle, TReceipt, TSync> ​

Defined in: ports/branchable-scope.ts:17

Tier-3 runtime driver contract for branchable isolation scopes (capabilityTier: 'branchable').

Extends CheckpointableScope with Copy-on-Write child forking (forkChild), crash-recovery child reattachment (reattachChild), zero-pollution 3-way child commit (commitChild), dirty-safe child rebase (syncChild), and stacked prerequisite root sync (syncRoot).

Extends ​

Type Parameters ​

Type ParameterDefault typeDescription
THandleunknownRuntime scope handle type.
TReceipt extends Record<string, unknown>Record<string, unknown>Validated scope inspection receipt shape.
TSync extends Record<string, unknown>Record<string, unknown>Validated scope synchronization receipt shape.

Methods ​

acquireRoot() ​

ts
acquireRoot(runId): Promise<THandle>;

Defined in: ports/isolation-scope.ts:30

Provisions and initializes an isolated root scope handle for runId.

Executes any configured scope setup commands and pins the initial base state for the run.

Parameters ​

ParameterTypeDescription
runIdstringUnique identifier of the flow run.

Returns ​

Promise<THandle>

Newly acquired root scope handle.

Inherited from ​

CheckpointableScope.acquireRoot


commitChild() ​

ts
commitChild(child, parent): Promise<ReconcileResult<TReceipt>>;

Defined in: ports/branchable-scope.ts:63

Reconciles child into parent via a zero-pollution 3-way merge.

When parent has advanced and conflicts with child, leaves parent untouched, materializes the conflict state inside child, and returns status: 'conflict'.

Parameters ​

ParameterTypeDescription
childTHandleCompleted child scope handle.
parentTHandleTarget parent scope handle.

Returns ​

Promise<ReconcileResult<TReceipt>>

Clean or conflicted reconciliation result.


diffEffects() ​

ts
diffEffects(fromCheckpoint, handle): Promise<readonly ToolEffect[]>;

Defined in: ports/checkpointable-scope.ts:53

Synthesizes ToolEffect descriptors by deterministically diffing handle against fromCheckpoint.

Enables post-flight policy guard and quota tripwire verification for arbitrary subprocess tools.

Parameters ​

ParameterTypeDescription
fromCheckpointstringPre-tool checkpoint token captured before execution.
handleTHandleScope handle after tool execution.

Returns ​

Promise<readonly ToolEffect[]>

Synthesized tool effects for policy guard and tripwire evaluation.

Inherited from ​

CheckpointableScope.diffEffects


forkChild() ​

ts
forkChild(parent, forkId): Promise<THandle>;

Defined in: ports/branchable-scope.ts:37

Forks an isolated child scope handle cloned from parent.

Preserves uncommitted edits from parent inside the newly provisioned Copy-on-Write child handle.

Parameters ​

ParameterTypeDescription
parentTHandleParent scope handle to clone from.
forkIdstringUnique identifier of the child fork or speculative branch.

Returns ​

Promise<THandle>

Newly provisioned child scope handle.


getConflictLease()? ​

ts
getConflictLease?(handle): LeaseDelta | undefined;

Defined in: ports/branchable-scope.ts:101

Returns an optional temporary capability lease unlocking conflicted resources on handle.

Granted automatically when commitChild, syncChild, or syncRoot returns status: 'conflict'.

Parameters ​

ParameterTypeDescription
handleTHandleScope handle containing unresolved conflicts.

Returns ​

LeaseDelta | undefined

Temporary conflict resolution lease, or undefined if none.


inspect() ​

ts
inspect(handle): Promise<TReceipt>;

Defined in: ports/isolation-scope.ts:53

Captures a side-effect-free inspection receipt (TReceipt) for handle.

Validates the returned receipt against receiptSchema before exposing it to .inputFrom() or .evaluate().

Parameters ​

ParameterTypeDescription
handleTHandleActive scope handle to inspect.

Returns ​

Promise<TReceipt>

Validated inspection receipt.

Inherited from ​

CheckpointableScope.inspect


reattachChild() ​

ts
reattachChild(
   parent, 
   forkId, 
   checkpoint?
): Promise<THandle>;

Defined in: ports/branchable-scope.ts:50

Rebinds an existing child scope handle during process reboot crash recovery.

Restores the child worktree or isolated branch state and applies checkpoint when needed.

Parameters ​

ParameterTypeDescription
parentTHandleParent scope handle.
forkIdstringUnique identifier of the child fork.
checkpoint?stringOptional persisted childScopeCheckpoint fallback.

Returns ​

Promise<THandle>

Reattached child scope handle.


reattachRoot() ​

ts
reattachRoot(runId, checkpoint?): Promise<THandle>;

Defined in: ports/isolation-scope.ts:42

Rebinds an existing root scope handle during process reboot crash recovery.

Restores the handle from persistent disk or remote state and falls back to checkpoint when needed.

Parameters ​

ParameterTypeDescription
runIdstringUnique identifier of the recovering flow run.
checkpoint?stringOptional persisted baseScopeCheckpoint fallback.

Returns ​

Promise<THandle>

Reattached root scope handle.

Inherited from ​

CheckpointableScope.reattachRoot


release() ​

ts
release(handle): Promise<void>;

Defined in: ports/isolation-scope.ts:64

Releases and cleans up an ephemeral root or child scope handle.

Invoked inside finally blocks when a branch, tournament loser, or completed flow run terminates.

Parameters ​

ParameterTypeDescription
handleTHandleScope handle to release.

Returns ​

Promise<void>

Resolves once all resources for handle are released.

Inherited from ​

CheckpointableScope.release


restoreCheckpoint() ​

ts
restoreCheckpoint(handle, checkpoint): Promise<void>;

Defined in: ports/checkpointable-scope.ts:41

Restores handle to the exact state captured by checkpoint.

Discards any uncommitted mutations made since checkpoint was serialized without losing prior turns.

Parameters ​

ParameterTypeDescription
handleTHandleActive scope handle to roll back.
checkpointstringPreviously serialized checkpoint token.

Returns ​

Promise<void>

Resolves once handle matches checkpoint.

Inherited from ​

CheckpointableScope.restoreCheckpoint


serializeCheckpoint() ​

ts
serializeCheckpoint(handle): Promise<string>;

Defined in: ports/checkpointable-scope.ts:29

Captures the uncommitted state of handle into a serializable checkpoint token.

Used before post-flight-guarded subprocess tools and prior to child fork or step suspension.

Parameters ​

ParameterTypeDescription
handleTHandleActive scope handle to snapshot.

Returns ​

Promise<string>

Serialized checkpoint identifier or payload.

Inherited from ​

CheckpointableScope.serializeCheckpoint


syncChild() ​

ts
syncChild(parent, pausedChild): Promise<ReconcileResult<TSync>>;

Defined in: ports/branchable-scope.ts:75

Rebases/merges uncommitted changes in pausedChild onto an updated parent handle.

Preserves dirty working-tree edits in pausedChild across the 3-way rebase onto parent.

Parameters ​

ParameterTypeDescription
parentTHandleUpdated parent scope handle.
pausedChildTHandleSuspended child scope handle being resumed.

Returns ​

Promise<ReconcileResult<TSync>>

Clean or conflicted synchronization result.


syncRoot() ​

ts
syncRoot(rootHandle, prerequisiteReceipts): Promise<ReconcileResult<TSync>>;

Defined in: ports/branchable-scope.ts:87

Synchronizes rootHandle onto completed prerequisite run receipts.

Rebases or merges the task root scope onto the terminal commits of its prerequisite runs upon wakeup.

Parameters ​

ParameterTypeDescription
rootHandleTHandleTask root scope handle.
prerequisiteReceiptsreadonly TReceipt[]Terminal scope receipts of completed prerequisites.

Returns ​

Promise<ReconcileResult<TSync>>

Clean or conflicted synchronization result.

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
idreadonlystringUnique identifier of the isolation scope driver.CheckpointableScope.idports/isolation-scope.ts:17
receiptSchemareadonlyZodType<TReceipt>Zod schema validating receipts returned by inspect().CheckpointableScope.receiptSchemaports/isolation-scope.ts:19
supportsBranchingreadonlytrueLiteral capability marker confirming child branching support.-ports/branchable-scope.ts:23
supportsCheckpointsreadonlytrueLiteral capability marker confirming checkpoint support.CheckpointableScope.supportsCheckpointsports/checkpointable-scope.ts:18
syncSchemareadonlyZodType<TSync>Zod schema validating synchronization receipts returned by syncChild() and syncRoot().-ports/branchable-scope.ts:25

Released under the MIT License.