Skip to main content

Module parallel_proposal

Module parallel_proposal 

Source
Expand description

Bounded deterministic parallel proposal execution (spec 110-bounded-parallel-workflow-scheduling, P2, ADR-0042).

Extends the P1 sequential proposal executor in crate::proposal with a wave-based concurrent dispatcher over the same CanonicalProposal/ ResolvedProposalNode shapes. A traverse_contracts::ParallelSchedule (computed by traverse_contracts::compute_parallel_schedule) levelizes the already-validated acyclic graph into waves of node ids whose dependencies are satisfied by earlier waves; this module authorizes and executes that schedule.

FR-004a (spec 110): the first P2 implementation permits a wave with more than one member only when every member’s declared effect_class is pure_readenforce_pure_read_only_parallelism checks this before any dispatch. Once authorized, each wave runs on real OS threads via std::thread::scope, bounded to max_concurrent_nodes per batch; outcomes are folded back into the trace in the wave’s lexicographic order (not completion order), so the observable trace is deterministic regardless of real scheduling (FR-002).

Wall-clock and payload-size bounds (FR-001, FR-005) are checked between waves, before committing to the next one — Rust gives no safe way to preemptively interrupt an in-flight OS thread without unsafe, and FR-004a already restricts concurrent work to side-effect-free local reads, so a wave that is already dispatched is always allowed to finish; a budget that is already exhausted simply stops further waves from starting, reported as traverse_contracts::CanonicalProposal’s trace terminal state cancelled.

Structs§

ParallelAuthorizationError
ParallelAuthorizationFailure
ParallelExecutionLimits
Execution-time bounds that structural schedule validation cannot express (spec 110 FR-001: “time, memory” bounds). Checked between waves.

Enums§

ParallelAuthorizationErrorCode

Constants§

DEFAULT_MAX_WALL_TIME_MS
DEFAULT_MAX_WAVE_PAYLOAD_BYTES

Functions§

enforce_pure_read_only_parallelism
Enforces spec 110 FR-004a: the first P2 implementation permits parallel execution only for pure_read nodes. Any wave with more than one member is denied outright unless every member in it is pure_read.
execute_parallel_proposal
Executes an authorized ParallelSchedule wave by wave, dispatching each wave’s nodes concurrently (bounded to limits.max_concurrent_nodes batches) when the wave has more than one member, and folding results back in lexicographic order regardless of real completion order (spec 110 FR-002).