commit ed0fc2554206b600d7965d5461d916f7c2c2c668
parent 1848b9a7977ff20e7da1fabb601773b01adbcfb4
Author: triesap <tyson@radroots.org>
Date: Mon, 12 Oct 2026 06:36:48 +0000
service_host: redact retained causes in ordinary error Debug
- Preserve host categories while keeping dependency causes out of Debug and Display
- Retain explicit trusted source inspection and original-cause downcasting
- Add synthetic privacy and non-renderable cause regressions for ordinary and pretty Debug
- Verify Rust 1.99.0 format, all-target check, 167 tests, Clippy and architecture closure
Diffstat:
3 files changed, 107 insertions(+), 6 deletions(-)
diff --git a/contracts/architecture/deviations.toml b/contracts/architecture/deviations.toml
@@ -2,6 +2,34 @@ schema_version = 1
architecture_id = "radroots.crates.release.v1"
[[deviation]]
+id = "RCRV1-DEV-029"
+date = "2026-10-12"
+status = "closed"
+approval = "The user approved the full successor refactor and local verified checkpoints; publication and supported consumer qualification remain separate."
+affected_steps = ["010", "040", "070", "130"]
+spec_anchors = ["contracts/crates/release_v1/radroots_crates_release_v1.toml#repository_policy"]
+source_evidence = [
+ "HostError derives ordinary Debug over its retained dependency-owned cause, while Display and safe_error use fixed host-owned projections.",
+ "The service-host package requires ordinary Debug to exclude private input and dependency diagnostics; its current error test checks Display with a fieldless cause only.",
+ "The upstream integration branch has the same error implementation; no newer correction is available there. Enclosing admin and lifecycle errors already redact retained causes separately.",
+]
+replacement_action = "Reproduce ordinary and pretty Debug with synthetic sensitive and non-renderable causes. If reproduced, redact retained causes in HostError Debug while preserving typed categories, fixed public errors, explicitly trusted source inspection, public API shapes and effect ownership."
+verification = [
+ "Validate this standalone deviation before changing production formatting, then record failing diagnostic regressions against unchanged production source.",
+ "Prove ordinary and pretty Debug do not render the dependency cause, while trusted source downcasting and safe Display remain available; cover sourced and unsourced host errors.",
+ "Run exact Rust 1.99.0 scoped formatting, all-target check, full service-host package tests and warnings-as-errors Clippy; review the exact owner diff before a local commit.",
+]
+unresolved_risk = "The contained ordinary Debug correction is locally verified. Supported consumer adoption and full host/platform qualification remain separate; no deployed disclosure is claimed."
+normative_architecture_change = false
+adr_required = false
+closure_evidence = [
+ "Both diagnostic regressions failed against unchanged production formatting: ordinary Debug exposed synthetic private input and invoked the retained dependency's Debug formatter.",
+ "Ordinary and pretty Debug now retain the host category and source presence without rendering the dependency; safe Display, explicitly trusted source inspection and original-cause downcasting remain available.",
+ "Exact Rust 1.99.0 scoped formatting, all-feature/all-target check, all-feature package tests including 167 passing tests/doctests and zero ignored, and warnings-as-errors all-target Clippy passed on local macOS arm64.",
+ "Only private host diagnostic formatting, its inline regressions, package guidance and this deviation changed. Public API shapes, features, dependencies, transports, lifecycle and effect ownership are unchanged.",
+]
+
+[[deviation]]
id = "RCRV1-DEV-028"
date = "2026-10-12"
status = "closed"
diff --git a/crates/service_host/README.md b/crates/service_host/README.md
@@ -93,7 +93,9 @@ deadlines, task names, metric snapshots, reason collections, and shutdown
phases have explicit bounds. Safe Display and ordinary Debug projections
exclude raw paths, SQL, credentials, payloads, and provider or relay errors.
Where a host error retains an original cause for trusted inspection, that cause
-is not rendered by its safe projection.
+is not rendered by its safe projection or ordinary/pretty `Debug`. `HostError`
+formatting does not invoke the retained cause's formatters; explicit trusted
+`source()` inspection and downcasting retain the original cause.
Reason-code iterators and wire arrays stop at the first item beyond their fixed
maximum. Administration payloads are traversed directly from the bounded input
diff --git a/crates/service_host/src/error.rs b/crates/service_host/src/error.rs
@@ -134,8 +134,7 @@ impl fmt::Display for SafeHostError {
}
}
-/// A typed host failure whose public display never includes its internal cause.
-#[derive(Debug)]
+/// A typed host failure whose Display and Debug never render its internal cause.
pub struct HostError {
kind: HostErrorKind,
source: Option<Box<dyn Error + Send + Sync + 'static>>,
@@ -169,6 +168,16 @@ impl HostError {
}
}
+impl fmt::Debug for HostError {
+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+ formatter
+ .debug_struct("HostError")
+ .field("kind", &self.kind)
+ .field("source", &self.source.as_ref().map(|_| "<redacted>"))
+ .finish()
+ }
+}
+
impl fmt::Display for HostError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.safe_error().fmt(formatter)
@@ -188,11 +197,11 @@ mod tests {
use super::*;
#[derive(Debug)]
- struct SensitiveCause;
+ struct SensitiveCause(&'static str);
impl fmt::Display for SensitiveCause {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
- formatter.write_str("secret upstream detail")
+ formatter.write_str(self.0)
}
}
@@ -200,7 +209,10 @@ mod tests {
#[test]
fn display_is_safe_while_source_is_preserved() {
- let error = HostError::with_source(HostErrorKind::ConfigDocument, SensitiveCause);
+ let error = HostError::with_source(
+ HostErrorKind::ConfigDocument,
+ SensitiveCause("secret upstream detail"),
+ );
assert_eq!(
error.to_string(),
@@ -214,6 +226,65 @@ mod tests {
}
#[test]
+ fn ordinary_debug_preserves_category_and_redacts_trusted_cause() {
+ let marker = "synthetic private diagnostic input";
+ let error = HostError::with_source(HostErrorKind::ConfigDocument, SensitiveCause(marker));
+
+ for rendered in [
+ format!("{error:?}"),
+ format!("{error:#?}"),
+ error.to_string(),
+ ] {
+ assert!(!rendered.contains(marker));
+ }
+ assert!(format!("{error:?}").contains("ConfigDocument"));
+ assert_eq!(error.kind(), HostErrorKind::ConfigDocument);
+ assert_eq!(
+ error
+ .source()
+ .unwrap()
+ .downcast_ref::<SensitiveCause>()
+ .unwrap()
+ .0,
+ marker
+ );
+ assert_eq!(error.source().unwrap().to_string(), marker);
+
+ let unsourced = HostError::new(HostErrorKind::TaskFailure);
+ assert!(unsourced.source().is_none());
+ assert!(format!("{unsourced:?}").contains("TaskFailure"));
+ assert!(format!("{unsourced:#?}").contains("TaskFailure"));
+ }
+
+ #[test]
+ fn ordinary_debug_does_not_format_retained_dependency_cause() {
+ struct ExplicitInspectionCause;
+
+ impl fmt::Debug for ExplicitInspectionCause {
+ fn fmt(&self, _formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+ panic!("dependency Debug requires explicit trusted inspection")
+ }
+ }
+
+ impl fmt::Display for ExplicitInspectionCause {
+ fn fmt(&self, _formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+ panic!("dependency Display requires explicit trusted inspection")
+ }
+ }
+
+ impl Error for ExplicitInspectionCause {}
+
+ let error = HostError::with_source(HostErrorKind::TaskFailure, ExplicitInspectionCause);
+ assert!(format!("{error:?}").contains("TaskFailure"));
+ assert!(format!("{error:#?}").contains("TaskFailure"));
+ assert_eq!(
+ error.to_string(),
+ HostErrorKind::TaskFailure.safe_error().to_string()
+ );
+ assert!(error.source().unwrap().is::<ExplicitInspectionCause>());
+ }
+
+ #[test]
fn safe_codes_have_stable_serialization_helpers() {
let expected = [
(HostErrorKind::ConfigDocument, "host_config_document"),