Skip to main content

join_pid_segment

Function join_pid_segment 

Source
pub fn join_pid_segment(head: &str, tail: impl Display) -> String
Expand description

Compose the canonical <head><PID_PATH_SEPARATOR><tail> hierarchical PID-path segment join.

Owns the fixed 2-slot format!("{head}.{tail}") shape as ONE substrate site, routing the separator through PID_PATH_SEPARATOR so a future normalization of the separator (see the const’s doc for the catalog) reaches every hierarchical- PID producer through this ONE primitive.

Pre-lift the 2-slot join was hand-authored at THREE production sites past the ★★ PRIME-DIRECTIVE ≥ 2 duplication threshold, split across two crates:

  • format_process_address on the (identity.name, pid_path) pair — the root address composer.
  • [crate::pid::allocate_pid] on the Some(parent) arm’s (parent, next_sequence) pair — the child PID allocator.
  • [crate::pid::allocate_pid] on the None arm’s (identity.name, next_sequence) pair — the root PID allocator.

Post-lift each callsite reads join_pid_segment(<head>, <tail>) and the composed byte shape matches the pre-lift format! chain verbatim. The tail parameter accepts any std::fmt::Display-able value so the u32 next_sequence slot on [crate::pid::allocate_pid] flows through the primitive without a pre-format .to_string() round- trip, matching the sibling [crate::boundary::Satisfaction::labeled_diagnostic] composer’s tail: impl Display convention.

Extension: future hierarchical-PID producers (P3 kenshi-runner’s per-suite Job PID allocator, any future placement rule that names a fresh child under an existing parent) land as ONE new callsite through this composer instead of another hand-authored format!( "{head}.{tail}") restatement.

Theory grounding: THEORY.md §VI.1 (generation over composition — the shape recurred at three sites past the PRIME-DIRECTIVE ≥ 2 duplication trigger, and is lifted to ONE owner here). THEORY.md §II.1 invariant 5 (composition preserves proofs — the three callsites now compose structurally through ONE primitive; a regression that drifted the separator at ONE site surfaces at [tests::join_pid_segment_*] rather than as silent operator- facing skew across the hierarchical-PID address space).