Skip to main content

fork

Function fork 

Source
pub async fn fork(
    __arg0: State<AppState>,
    __arg1: Path<String>,
    body: Bytes,
) -> Result<Response, ApiError>
Expand description

POST /v1/runs/{id}/fork: fork a graph run from a node boundary into a NEW run, refusing (or recording an acknowledgement for) the writes the re-walked segment would re-fire.

The origin is never touched: this reads its log, plans the fork purely (salvor_engine::plan_fork), and — on success — writes the child’s prefix under a fresh id and drives it onward from the fork node, exactly as a recovered graph run continues. The refusals, each typed and precise:

  • 404 unknown_run — no such origin.
  • 409 not_a_graph_run — the origin is an ordinary agent run.
  • 409 invalid_fork_node — the origin never entered the named node.
  • 404 unknown_graph — the origin’s graph is no longer in the registry (graphs do not survive a restart); resubmit the identical document, then fork.
  • 409 origin_needs_reconciliation — the origin is parked at a dangling write; resolve it first.
  • 409 write_replay_hazard — the re-walked segment holds Effect::Write intents not covered by acknowledge_writes; details.writes lists exactly the ones still needing acknowledgement.

dry_run: true returns the preview (the hazard list and the would-be prefix summary) and creates nothing; the structural refusals above still apply, so a dry run reports a fork that could never proceed rather than pretending it could.