Expand description
RCH_*_INJECT_* test-injection env-var registry (br-62u24.13 — MVP).
This module is the single source of truth for the names of every debug/test injection environment variable consumed by RCH binaries. The bead spec for 62u24.13 calls out the foundation problem:
In the cross-agent code-review work (commits
68fcb7c+ d6d086e and the 21 sibling beads in epics2s99h,62u24,zcecy), every e2e test script and many unit tests reference debug-only env-var hooks andrch debug *subcommands that don’t exist in the codebase yet. Without a foundational bead defining the contract for these primitives, each task-bead implementer will arbitrarily reinvent its own conventions — resulting in inconsistent naming, duplicate functionality, missing#[cfg(debug_assertions)]gates, and accidental release-build leakage.
By defining the canonical names HERE as pub const NAME_OF_VAR: &str = "RCH_..." items, downstream tests can write
std::env::var(injection::RCH_DOCTOR_INJECT) instead of
std::env::var("RCH_DOCTOR_INJECT") — a typo in the latter is a
silent no-op, but the former is a compile error.
§Discipline (the contract this module enforces)
- All injection env-var names are
pub const NAME: &stritems here. Adding a new injection point requires adding the const, not coining a new name at the consumer site. - All names match the regex
RCH_[A-Z][A-Z0-9_]*_INJECT(_[A-Z0-9_]+)?. TheRCH_prefix is owned by us; the_INJECTsegment is the discriminator that lets release-build audits grep for “did any injection name leak into the binary?”. ALL_INJECTION_VARSenumerates every defined const. The unit tests at the bottom of this module assert (a) no duplicate values, (b) every value matches the naming regex, (c) the slice length equals the number ofpub constitems in this file. Adding a new const without updatingALL_INJECTION_VARSis a test failure.- Release-build gate is the consumer’s responsibility. This
module exports names, not behavior. Each call site that reads
one of these env vars must gate the read with
#[cfg(debug_assertions)](or document an explicit reason if a release-build read is intentional). This module’s name-only surface is itself safe to compile in release.
§Scope of this MVP delivery
Lands the registry surface (names + enumeration + naming validator)
that every other bead can immediately consume. The companion
deliverables from 62u24.13 — rch debug subcommand convention,
request_id propagation, tracing-capture test helper, the
#[cfg(debug_assertions)] gate audit — are filed as follow-up
scope. Each is independently substantial; the registry is the
minimum that unblocks the rest.
Constants§
- ALL_
INJECTION_ VARS - Every injection env-var name registered in this module. Consumed
by release-build leak audits, fuzzers, and the
rch debug(TBD) subcommand’s introspection surface. - RCH_
DEBUG_ INJECT_ PANIC - Trigger an intentional panic at a designated code path (value
1). Used by the hook fail-open regression suite to confirm that classifier panics are caught and the hook still exits 0 (the project’s #1 invariant per AGENTS.md). - RCH_
DEBUG_ INJECT_ TIMING_ SAVE_ FAIL - Force the timing-cache save path to fail (value
1) so tests can confirm the hook’s fail-open behavior under disk-error conditions. - RCH_
DOCTOR_ INJECT - Inject a synthetic reliability-doctor diagnostic at the named code
path. Value is a free-form discriminator (e.g.,
disk_pressure_warn,topology_circuit_open) interpreted by the consumer; an empty/unset value disables the injection. - RCH_
DOCTOR_ INJECT_ SLOW_ PROBE - Inject artificial latency into a specific reliability probe. Value
format:
<probe_name>=<delay_ms>(e.g.,helpers=10000). Used to exercise the per-probe timeout path (bd-62u24.8 parallelism). - RCH_
DOCTOR_ INJECT_ STATUS_ CIRCUIT - Inject a specific status-circuit state for a synthetic worker
(e.g.,
open_forced). Used by reliability-doctor tests that need to exercise the partial-outage code path without spinning up a real fleet. - RCH_
FIX_ INJECT_ POST_ FAIL - Force the fix executor’s post-validation step to fail even when
remediation succeeded, so tests can exercise the
FailedPostValidationoutcome branch. - RCH_
FIX_ INJECT_ UNSAFE - Inject a remediation step whose
dry_run_safe == falseso the--fixexecutor exercises theSkippedNotSafeoutcome path without a real unsafe remediation in the registry. - RCH_
QC_ INJECT_ STALL - Inject a synthetic stall on a specific worker’s quick-check probe.
Value is the worker ID (e.g.,
w1). - RCH_
QC_ INJECT_ STALL_ ALL - Force every worker’s quick-check probe to stall (value
1). Used by integration tests that need the “everything timing out” branch of the status surface.
Functions§
- is_
injection_ var - Returns
trueifnameis one of the registered RCH injection env-var names. Used by audit tools that scan process environments for stray injection settings and by the (TBD)rch debug list-injectionsintrospection surface. - is_
well_ formed_ injection_ name - Returns
trueifnameis shape-compatible with the project’s injection naming policy: starts withRCH_, contains_INJECTsomewhere after the prefix, and consists only of ASCII uppercase / digits / underscores. Used by the unit tests below to enforce the naming regex without pulling in theregexcrate (this is aconst-friendly check on a small alphabet).