pub fn qualified_error_ctx(
verb: &str,
kind: &str,
ns: &str,
name: &str,
) -> StringExpand description
Substrate-primitive composer for the workspace-canonical
<verb> <Kind> <ns>/<name> diagnostic-body head every
per-Kind error_ctx peer wraps
around a wire-verb failure against a namespaced K8s resource
(through crate::kube_error::KubeResultExt::kube_ctx_with on
the reconciler-boundary consumers or through
anyhow::Context::with_context on the export-worker
consumers).
Owns the fixed 4-slot shape at ONE substrate site, routing the
<ns>/<name> join through the workspace-wide
qualified_process_ref composer so a future normalization of
the qualified-ref shape (case-fold, unicode collation, IDN) lands
at ONE site and every per-Kind diagnostic body picks it up
mechanically.
Pre-lift the 4-slot shape recurred at TWO peer per-Kind
composers in this crate past the ★★ PRIME-DIRECTIVE ≥ 2
duplication threshold, each restating the SAME
format!("{verb} <Kind> {}", qualified_process_ref(ns, name))
incantation with only the fixed <Kind> literal differing:
crate::configmap::error_ctx— the ConfigMap-axis per-Kind composer (<Kind> = "ConfigMap"), routing the closed-loop probe’s receipt-CM writer + the export-worker’s SSA-side ConfigMap writer through ONE substrate slug.crate::process_api::error_ctx— the tatara-CRD Process-axis per-Kind composer (<Kind> = "Process"), routing the reconciler-boundary ProcessPhase evaluator + the export-worker’s ProcessSnapshotSource reader through ONE substrate slug.
Both peers walked the SAME 4-slot shape — take a verb, a fixed
&'static str per-Kind literal ("ConfigMap" / "Process"),
and the target resource’s namespace + name — and produced the
SAME "<verb> <Kind> <ns>/<name>" diagnostic head. Post-lift
each per-Kind composer reads
crate::qualified_error_ctx(<verb>, "<Kind>", ns, name) as a
one-line delegate, and the shared 4-slot shape lives at ONE
substrate owner here. A future third + fourth per-Kind composer
(a crate::secret::error_ctx for the K8s Secret axis, a
crate::job::error_ctx for the batch/v1::Job axis a future
ConditionKind::JobAttested companion reader might open, a
crate::helm_release::error_ctx for the FluxCD HelmRelease
axis the P2 reconciler already emits) inherits the 4-slot shape
through THIS composer, pinning only its own &'static str Kind
literal.
§Naming — qualified_error_ctx, not error_ctx
The bare error_ctx name is already taken at each per-Kind
composer’s module (crate::configmap::error_ctx,
crate::process_api::error_ctx, crate::list::error_ctx),
each closing its own per-Kind or per-verb axis. This composer’s
qualified_error_ctx name is deliberately distinct so a caller
with any of the per-Kind modules in scope cannot resolve to the
wrong composer by accident (which would silently drop the
per-Kind literal at the callsite). The qualified_ prefix names
the routing invariant: the <ns>/<name> join at the composer’s
tail rides through qualified_process_ref, the SAME workspace-
wide substrate every per-Kind peer already routes through.
§4-slot shape, not 3
The kind slot is required — the pre-lift per-Kind composers
hard-coded their Kind literal as a &'static str at each
format! chain, and post-lift the composer keeps that Kind
literal at the caller so the K8s-canonical TitleCase spelling
stays visible in the callsite’s grep footprint. A future
caller with a dynamically-composed Kind slot (a CRD-family
walker that renders errors for every ProcessTable /
EphemeralPool / EphemeralAllocation variant at one call)
still reaches through this same 4-slot signature — the &str
bound on kind accepts both &'static str literals (the
per-Kind peer shape) and runtime-composed &str slices (the
dynamic-Kind walker shape).
§#[must_use]
The returned String is consumed by [crate::kube_error:: KubeResultExt::kube_ctx_with], by
anyhow::Context::with_context’s owned-String-returning
closure form, or by the sibling [crate::err_ctx::ErrCtxExt:: err_ctx_with] owned-string escape hatch. Dropping the return
silently drops the diagnostic head entirely, which is never the
intended semantic at any pre-lift or post-lift consumer.
Theory anchor: THEORY.md §VI.1 (generation over composition —
the 4-slot <verb> <Kind> <ns>/<name> shape recurred at 2 peer
per-Kind composers past the ★★ PRIME-DIRECTIVE ≥ 2 duplication
trigger, and is lifted onto the ONE workspace-wide substrate
owner here). THEORY.md §II.1 invariant 5 (composition preserves
proofs — a regression that reordered the head slots, dropped
the fixed <Kind> word, or routed the <ns>/<name> join
through a bare inline format! — bypassing
qualified_process_ref — surfaces at
[qualified_error_ctx_tests] rather than as silent drift across
every per-Kind diagnostic body and every future per-Kind peer
that opens on this composer).