Skip to main content

Module fork

Module fork 

Source
Expand description

Fork planning: the pure computation behind fork-from-node.

A fork is a NEW run whose log opens with the origin’s prefix — every event below the Event::NodeEntered the fork restarts from — rewritten under the fork’s own run id, with the seq-0 Event::GraphRunStarted carrying a ForkOrigin as the durable record of that descent. The origin is never touched: plan_fork only reads it. Everything in this module is pure — no store, no clock, no randomness — so the server and the CLI share one honest story for where the fork boundary sits, which writes the re-walked segment would re-fire, and what bytes the child’s prefix holds.

The boundary is the position k of the Event::NodeEntered for the requested node. The prefix is every event with seq < k; the child restarts by re-walking from that node. A node the origin never entered is refused (ForkError::NodeNeverEntered) rather than guessed at — a fork must land on a real node boundary the run actually reached, so the prefix is always a faithful sub-log the child replays byte for byte before continuing live.

§Refuse-then-record lives one layer up

This module surfaces the write hazard set (ForkPlan::hazards): the Effect::Write tool intents in the segment the fork will re-walk. Deciding whether the operator acknowledged them, and recording that acknowledgement into ForkOrigin::acknowledged_writes, is the caller’s policy (the server’s 409 write_replay_hazard, the CLI’s --acknowledge-writes). This module computes the set and copies the acknowledgement into the child; it does not judge it.

Structs§

ForkPlan
A planned fork of an origin run: the boundary, the prefix to copy, and the write hazard set in the segment the fork will re-walk.
WriteHazard
A recorded Effect::Write tool intent that a fork’s re-walked segment would re-execute: the evidence the refuse-then-record policy shows the operator.

Enums§

ForkError
Why a fork cannot be planned at all, independent of write acknowledgement.

Functions§

plan_fork
Plans a fork of origin_log restarting from from_node.