Skip to main content

Module context

Module context 

Source
Expand description

Context enrichment utilities for DualContextError.

This module provides builder patterns and causality tracking for error contexts that complement the core DualContextError type from models.rs.

§Architecture Integration

Unlike the deprecated monolithic ErrorContext, this module works with the dual-context system rather than replacing it:

  • ContextBuilder: Fluent API for constructing rich error contexts
  • ContextMetadata: FUTURE: Structured metadata (not yet integrated with DualContextError)
  • ContextChain: Causality tracking for error chains

§Security Properties

All context data adheres to the same security model as DualContextError:

  • Sensitive fields are zeroized on drop
  • Public/internal separation is maintained
  • No implicit conversions between trust boundaries

§Example

use palisade_errors::{ContextBuilder, DualContextError, OperationCategory};

let err = ContextBuilder::new()
    .public_lie("Operation failed")
    .internal_diagnostic("Actual error: database connection timeout")
    .category(OperationCategory::IO)
    .build();

§Future Work: Metadata Integration

ContextMetadata is provided as a foundation for future enhancement but is not yet integrated with DualContextError. When metadata support is added to the core error type, this module will provide the builder interface for it.

Until then, metadata is architecturally orphaned and should not be used in production code paths.

Structs§

ContextBuilder
Fluent builder for constructing DualContextError.
ContextChain
Error chain for tracking causality across system boundaries.

Enums§

ContextBuilderError
Error type for context builder failures.