Expand description
§diagprint
diagprint is a Rust diagnostics lifecycle framework for carrying
structured diagnostics through creation, enrichment, rendering, editor and
CI integration, guarded remediation, verification, export, and telemetry.
The crate deliberately separates diagnostic data from presentation and mutation:
Diagnosticdescribes what happened.CapturedDiagnosticpairs a diagnostic with its immutable source snapshot.Suggestiondescribes a possible resolution.Fixervalidates and applies guarded structured edits.FixPlancoordinates transactional multi-file remediation.InteropDiagnosticis the dependency-free interoperability boundary.SourceCachesupplies virtual and cached source text to renderers.DocumentationResolverresolves documentation without guessing package versions.DiagnosticMetadatalets typed errors supply semantic metadata.CompilerImporterconsumes structured rustc diagnostics.CargoWorkspacemodels Cargo package/dependency metadata.CargoStreamImporterconsumes Cargo build-message streams.
Calling a renderer never modifies source files.
§Canonical identity
diagprint.canonical/v1 defines stable, schema-versioned identity for
diagnostics and reports without depending on JSON field ordering or volatile
runtime metadata. DiagnosticFingerprint identifies a logical diagnostic,
DiagnosticDigest identifies meaningful diagnostic content, and
ReportDigest identifies report content independently of insertion order.
DiagnosticDelta uses those identities to classify diagnostics across
reports as new, resolved, persisting, or changed while preserving duplicate
diagnostic instances.
DeltaPolicy evaluates those semantic differences for baseline-aware CI
without making existing diagnostic debt appear newly introduced.
Canonical v1 is immutable: incompatible identity changes require a new canonicalization version rather than silently changing existing digests.
§Diagnostic forensics
DiagnosticCaseFile turns a verified DiagnosticHistory into a
privacy-light forensic explanation for one logical diagnostic fingerprint.
Case-file v1 reports first/last observation, current lifecycle state, contiguous active episodes, reappearances, canonical-content changes, severity increases, supporting run/report/digest evidence, and the current history-chain head.
The forensic layer is deliberately evidence-based. It does not guess root cause, source-control blame, or authorship.
DiagnosticHistory::case_file requires an exact canonical fingerprint.
The diagprint why CLI additionally accepts a unique fingerprint prefix.
§Git provenance
GitProvenanceRecord can bind one immutable diagnostic-history run to an
exact Git commit and tree without changing history-v2 semantics.
GitProvenanceBinding::CapturedClean means diagprint observed a clean
worktree around the scan. GitProvenanceBinding::UserAsserted is an
explicit after-the-fact association and therefore carries weaker evidence.
Git provenance establishes repository context and temporal association. It does not establish that a commit caused a diagnostic transition.
§Diagnostic intelligence
Structured suggestions can carry explanations, documentation links,
structured edits, advisory follow-up commands, and an Applicability
classification.
Automatic editing requires Applicability::MachineApplicable, valid
non-overlapping UTF-8 edit ranges, and verification of expected source
contents.
Suggested shell commands are informational only and are never executed by
Fixer or FixPlan.
§Transactional remediation
FixPlan supports deterministic preconditions, multi-file preparation,
rollback-on-error writes, post-apply verification, verification rollback,
and optional backups.
Verification is declarative and does not execute shell commands.
§Virtual and cached source text
SourceCache stores named source text independently from diagnostics.
SourceProvider lets parsers, bridges, and other integrations populate
that cache without coupling the renderer to a specific ecosystem.
SourceSnapshot captures an immutable point-in-time source view so old
diagnostics can render against the exact text they were created from.
SourceRevision identifies successive versions of one named source and
allows snapshots to detect whether a diagnostic-time buffer is still current.
Terminal rendering can prefer cached source and fall back to filesystem
reads when no cached source exists.
This supports editor buffers, generated files, parser inputs, compiler virtual files, and other source text which may never exist on disk.
Source contents are not serialized into Diagnostic JSON output.
§Generic interoperability
InteropDiagnostic is a dependency-free, owned diagnostic protocol for
compilers, linters, parsers, language tools, and third-party adapters.
It preserves:
- severity;
- diagnostic code;
- message and help;
- notes;
- primary and secondary source labels;
- cause chains;
- documentation links;
- related diagnostics.
Custom producers can implement InteropDiagnosticSource and gain direct
conversion through InteropDiagnosticSourceExt.
Automatic edits and executable commands are deliberately excluded from the generic protocol. Remediation requires stronger ecosystem-specific safety guarantees.
§Cargo intelligence
CargoWorkspace consumes cargo metadata --format-version=1 output and
preserves package identity, versions, workspace membership, targets,
features, and resolved dependency context.
CargoStreamImporter consumes Cargo --message-format=json output and
recognizes compiler diagnostics, compiler artifacts, build-script results,
and build completion.
Unknown future Cargo message kinds are retained as CargoMessage::Unknown
rather than rejected.
§Documentation intelligence
DocumentationResolver can build package/version catalogs from
Cargo.lock or CargoWorkspace.
Ambiguous package versions remain ambiguous rather than being guessed.
§Ecosystem interoperability
The miette feature consumes miette’s structured diagnostic protocol,
including source labels, causes, and related diagnostics.
The codespan-reporting feature resolves codespan’s file IDs and byte
ranges into InteropDiagnostic before conversion to diagprint.
The ariadne feature provides a structured bridge which can emit both an
Ariadne report and a diagprint InteropDiagnostic from the same source
metadata without parsing rendered terminal output.
The annotate-snippets feature provides the same dual-output model for
annotate-snippets reports while validating its byte-oriented source spans.
The anyhow feature preserves Anyhow context/source chains.
The tracing feature turns significant tracing events into structured
diagnostics.
External adapters never need to parse another library’s pretty terminal rendering.
§Compiler diagnostics
CompilerImporter consumes structured rustc JSON diagnostics directly.
It preserves compiler severity, Rust error codes, source spans, notes,
help, structured replacements, and applicability.
Filesystem hydration is disabled by default.
§Typed errors
Application error enums and structs can implement DiagnosticMetadata
to provide stable diagnostic codes, severity, help, notes, and structured
suggestions.
§Terminal documentation
The optional terminal-docs feature can fetch documentation and display it
directly in a terminal with sanitized remote content and syntax-highlighted
examples.
§Themes
Theme, Style, and SeverityTheme control terminal presentation.
The optional cybercore feature maps the Cybercore semantic palette into
diagprint rather than copying Cybercore color values.
§Feature flags
artifact-store— append-only artifact generations with filesystem locking.derive— deriveDiagnosticMetadatafrom typed errors.anyhow— Anyhow context-chain integration.ariadne— structured Ariadne/diagprint bridge.annotate-snippets— structured annotate-snippets/diagprint bridge.miette— miette diagnostic-protocol integration.codespan-reporting— codespan-reporting diagnostic integration.tracing— structured tracing-event integration.compression— gzip and Zstandard report compression.html— HTML diagnostic and report rendering.cybercore— Cybercore theme-schema integration.terminal-docs— terminal documentation retrieval and syntax highlighting.
Generic interoperability, typed errors, compiler/Cargo ingestion,
documentation resolution, and FixPlan are core features.
All optional features are disabled by default.
Re-exports§
pub use interop::DiagnosticTree;pub use interop::InteropDiagnostic;pub use interop::InteropDiagnosticSource;pub use interop::InteropDiagnosticSourceExt;pub use interop::InteropLabel;pub use render::GithubActionsDeltaRenderer;pub use render::ReportRenderer;pub use render::SeverityTheme;pub use render::Style;pub use render::Theme;
Modules§
- interop
- Dependency-free diagnostic interoperability protocol.
- project_
scan - render
Structs§
- Artifact
Digest - SHA-256 identity of exact exported artifact bytes.
- Artifact
Writer - Persists verified artifacts as create-only transactional directories.
- Capsule
Manifest Entry - One exact payload recorded by the capsule manifest.
- Capsule
Policy Descriptor - Privacy-safe capsule-policy description stored in the manifest.
- Capsule
Provenance - Deterministic producer/project provenance.
- Capsule
Source Entry - One exported source in a capsule source index.
- Capsule
Source Index - Index describing an explicitly exported source snapshot.
- Captured
Diagnostic - A diagnostic paired with the immutable source snapshot it was produced against.
- Cargo
Artifact - Cargo
Build Finished - Cargo
Build Script - Cargo
Build Summary - Aggregate intelligence for one Cargo build stream.
- Cargo
Compiler Diagnostic - Cargo
Dependency - Cargo
Dependency Kind - Cargo
Package - Cargo
Package Identity - Cargo
Profile - Cargo
Stream Importer - Cargo
Target - Cargo
Unknown Message - Cargo
Workspace - Cause
- Compiler
Importer - Delta
Artifact - Portable, privacy-aware representation of a semantic diagnostic delta.
- Delta
Artifact Counts - Serializable delta summary.
- Delta
Artifact Entry - One portable semantic delta entry.
- Delta
Artifact Evaluation - Portable CI policy and evaluation result attached to a delta artifact.
- Delta
Artifact Fingerprint Policy - Serializable fingerprint policy recorded in a delta artifact.
- Delta
Artifact Policy - Serializable form of
DeltaPolicy. - Delta
Artifact Violation - One machine-readable failed CI rule.
- Delta
Counts - Counts diagnostic instances by delta classification.
- Delta
Evaluation - Result of evaluating a
DiagnosticDeltaagainst aDeltaPolicy. - Delta
Policy - Baseline-aware policy for evaluating a
DiagnosticDelta. - Delta
Violation - One failed
DeltaRuleand the number of matching diagnostic instances. - Diagnostic
- Diagnostic
Attribute - Named structured value attached to a diagnostic.
- Diagnostic
Capsule - In-memory diagnostic capsule.
- Diagnostic
Capsule Manifest - Manifest for one diagnostic capsule.
- Diagnostic
Capsule Policy - Controls privacy-sensitive capsule contents.
- Diagnostic
Capsule Verification - Successful capsule verification.
- Diagnostic
Case File - Privacy-light forensic summary for one logical diagnostic fingerprint.
- Diagnostic
Case Run - Evidence for one history run in which the diagnostic was actually present.
- Diagnostic
Clean Window - One contiguous history interval where the fingerprint is absent.
- Diagnostic
Delta - Semantic comparison between a baseline and candidate diagnostic report.
- Diagnostic
Digest - Deterministic digest of one diagnostic’s meaningful content under diagprint.canonical/v1.
- Diagnostic
Episode - One contiguous period during which a logical diagnostic was present.
- Diagnostic
Fingerprint - Stable semantic identity for one logical diagnostic under diagprint.canonical/v1.
- Diagnostic
History - Append-only tamper-evident diagnostic history.
- Diagnostic
History Run - One immutable persisted diagnostic state.
- Diagnostic
History Transition - Semantic transition between two persisted history runs.
- Diagnostic
Lineage - Cross-run history for one logical diagnostic fingerprint.
- Diagnostic
Lineage Step - One transition in the history of a single logical diagnostic fingerprint.
- Diagnostic
Relationship - Diagnostic
Relationship Graph - Diagnostic
Relationship Graph Builder - Diagnostic
Relationship Node - Diagnostic
Relationship Snapshot - Diagnostic
Remediation Assessment - Diagnostic
Remediation Replay - Diagnostic
Remediation Replay Step - Diagnostic
Report - An owned collection of structured diagnostics.
- Diagnostic
Timeline - Complete run-by-run forensic lifecycle for one logical fingerprint.
- Diagnostic
Timeline Run - One complete run in a diagnostic forensic timeline.
- Documentation
Link - Documentation
Resolver - Resolves documentation without silently guessing package versions.
- Export
Diagnostic - External, privacy-conscious representation of a diagnostic.
- Export
Documentation Link - Sanitized documentation link.
- Export
Label - Privacy-conscious source label.
- Export
Policy - Shared privacy policy for external diagnostic serialization.
- Export
Policy Descriptor - Privacy-safe description of the export boundary.
- Export
Receipt - Receipt for one exact exported artifact.
- Export
Source Location - Privacy-conscious source location.
- Export
Suggestion - Metadata-only representation of a remediation suggestion.
- Exported
Artifact - Exact artifact payload plus its export receipt.
- File
Check Failure - Fingerprint
Policy - Controls which stable semantic fields participate in a diagnostic fingerprint.
- FixCheck
- FixPlan
- A transactional remediation plan composed of explicit filesystem edits, preconditions, and deterministic post-apply verification checks.
- FixPlan
Check - FixPlan
Descriptor - Deterministic, serializable description of one
FixPlan. - FixPlan
Preview - FixPlan
Report - FixPreview
- FixReport
- Fixer
- GitProvenance
Record - Immutable Git provenance for exactly one diagnostic-history run.
- History
Delta Counts - Counts semantic diagnostic transitions between two history runs.
- History
Observation - One privacy-light canonical observation of a diagnostic.
- History
Severity Counts - Severity counts retained for one historical run.
- Json
Lines Sink - Newline-delimited JSON sink suitable for logs and stream processing.
- Label
- Persisted
Artifact - Result of one committed artifact transaction.
- Persisted
Diagnostic Capsule - Result of one committed capsule transaction.
- Receipt
Evaluation - Lightweight CI result retained in an export receipt.
- Remediation
Effect - Semantic diagnostic effect observed after remediation and rescanning.
- Remediation
Evidence Effect - Remediation
Evidence Record - Privacy-light evidence binding one exact successful remediation receipt to one exact adjacent transition in a verified diagnostic history.
- Remediation
Outcome - Result of the successful filesystem remediation transaction.
- Remediation
Plan Receipt - Privacy-safe identity and summary of the exact fix plan used.
- Remediation
Receipt - Evidence tying one exact remediation plan to before/after diagnostic state.
- Report
Digest - Order-independent deterministic digest of a diagnostic report under diagprint.canonical/v1.
- Reporter
- Reporter
Builder - Rollback
Failure - Rotation
Policy - Rotation
State - Sensitive
- A value which must be explicitly exposed before its contents are rendered.
- Severity
Counts - Counts diagnostics by severity.
- Sink
Error - Source
Cache - Thread-safe shared cache of named source texts.
- Source
Entry - One immutable source revision.
- Source
Location - Source
Revision - Monotonic revision of one named source.
- Source
Snapshot - Immutable point-in-time view of a
SourceCache. - Suggested
Command - Suggestion
- Text
Range - Writer
Sink - Sink which renders diagnostics into an arbitrary synchronous writer.
Enums§
- Applicability
- Artifact
Encoding - External encoding used to produce an exact artifact byte stream.
- Artifact
Verification Error - Failure while checking artifact bytes against an export receipt.
- Artifact
Write Error - Failure while transactionally persisting an exported artifact.
- Canonicalization
Error - Failure while projecting diagnostic data into a portable canonical form.
- Canonicalization
Version - Version of diagprint’s canonical identity encoding.
- Capsule
Entry Kind - Logical role of one capsule payload.
- Cargo
Import Error - Cargo
Message - Compiler
Import Error - Compression
- Delta
Kind - Classification of one diagnostic instance between a baseline and candidate report.
- Delta
Rule - One CI/evaluation rule applied to a
DiagnosticDelta. - Diagnostic
Capsule Error - Capsule construction, persistence, or verification failure.
- Diagnostic
Case Status - Current lifecycle state of one logical diagnostic.
- Diagnostic
Change - One classified diagnostic instance in a
DiagnosticDelta. - Diagnostic
Clean Window Kind - Classification for one contiguous run window where the diagnostic is absent.
- Diagnostic
History Error - Diagnostic-history persistence or integrity failure.
- Diagnostic
Relationship Direction - Direction used when traversing a diagnostic relationship graph.
- Diagnostic
Relationship Error - Diagnostic
Relationship Evidence - Diagnostic
Relationship Evidence Filter - Controls whether inferred-correlation edges participate in graph traversal.
- Diagnostic
Relationship Kind - Diagnostic
Remediation State - Diagnostic
Timeline Event - Notable lifecycle event occurring at one timeline run.
- Diagnostic
Timeline Phase - Presence state of one logical diagnostic in one retained history run.
- Diagnostic
Value - Typed value attached to a structured diagnostic attribute.
- Digest
Algorithm - Hash algorithm used by canonical v1 identity values.
- Documentation
Error - Edit
- Export
Attributes - Policy for arbitrary structured diagnostic attributes.
- Export
Path - Policy for source paths in an external diagnostic export.
- Export
Remediation - Policy for remediation information in an external diagnostic export.
- Export
Text - Policy for free-form text in an external diagnostic export.
- Export
Url - Policy for documentation URLs in an external diagnostic export.
- File
Check - A deterministic filesystem condition used as either a precondition or a post-apply verification step.
- Fingerprint
Source - Source identity included in derived diagnostic fingerprints.
- FixError
- FixPlan
Error - GitProvenance
Binding - Evidence strength for a Git/history binding.
- GitProvenance
Error - Label
Kind - Redaction
Policy - Explicit policy for presenting a
Sensitivevalue. - Remediation
Evidence Error - Remediation
Receipt Error - Failure while constructing a remediation receipt.
- Remediation
Replay Error - Remediation
Status - Successful remediation state.
- Report
Status - Result of evaluating a diagnostic report against a failure threshold.
- Rotation
Cadence - Severity
- Sink
Error Kind
Constants§
- CANONICAL_
V1_ NAMESPACE - Stable canonicalization namespace used by diagprint’s first identity schema.
- CAPSULE_
PROVENANCE_ V1_ SCHEMA - Stable schema for capsule provenance metadata.
- CAPSULE_
SOURCE_ INDEX_ V1_ SCHEMA - Stable schema for an exported source snapshot index.
- DELTA_
V1_ MEDIA_ TYPE - Media type used by
diagprint.delta/v1JSON artifacts. - DELTA_
V1_ SCHEMA - Stable schema identifier for portable diagnostic delta artifacts.
- DIAGNOSTIC_
CAPSULE_ V1_ SCHEMA - Stable schema identifier for a diagnostic capsule manifest.
- DIAGNOSTIC_
CASE_ FILE_ V1_ SCHEMA - Stable schema for privacy-light diagnostic forensic case files.
- DIAGNOSTIC_
HISTORY_ HEAD_ V1_ SCHEMA - Mutable head record for one append-only history directory.
- DIAGNOSTIC_
HISTORY_ RUN_ V1_ SCHEMA - Original unchained diagnostic-history schema.
- DIAGNOSTIC_
HISTORY_ RUN_ V2_ SCHEMA - Tamper-evident hash-chained diagnostic-history schema.
- DIAGNOSTIC_
LINEAGE_ V1_ SCHEMA - Stable schema for exported diagnostic-lineage summaries.
- DIAGNOSTIC_
RELATIONSHIP_ GRAPH_ V1_ SCHEMA - DIAGNOSTIC_
RELATIONSHIP_ SNAPSHOT_ V1_ SCHEMA - DIAGNOSTIC_
REMEDIATION_ REPLAY_ V1_ SCHEMA - DIAGNOSTIC_
TIMELINE_ V1_ SCHEMA - Stable schema for run-by-run diagnostic forensic timelines.
- FIX_
PLAN_ DESCRIPTOR_ V1_ SCHEMA - Stable schema identifier for deterministic fix-plan descriptors.
- GIT_
PROVENANCE_ V1_ SCHEMA - Stable schema for Git provenance bound to one immutable diagnostic-history run.
- IDENTITY_
ATTRIBUTE - Reserved structured attribute understood by canonical fingerprinting.
- RECEIPT_
V1_ SCHEMA - Stable schema identifier for export receipts.
- REDACTED
- Default representation for protected values.
- REMEDIATION_
EVIDENCE_ V1_ SCHEMA - REMEDIATION_
RECEIPT_ V1_ SCHEMA - Stable schema identifier for remediation receipts.
Traits§
- Diagnostic
Error Ext - Convenience conversion methods for typed errors carrying
DiagnosticMetadata. - Diagnostic
Metadata - Optional diagnostic metadata implemented by typed application errors.
- Diagnostic
Sink - Synchronous destination for structured diagnostics.
- Result
Diagnostic Ext - Converts typed
Resulterrors into native diagprint diagnostics. - Source
Provider - A type which can supply named source text to a
SourceCache.
Functions§
- is_
sensitive_ key - Returns whether an attribute/key name commonly represents sensitive data.
- sanitize_
path - Reduces a filesystem path or source name to its final component.
- sanitize_
url - Removes URL user information, query parameters, and fragments.
Type Aliases§
- Captured
Diagnostic Result - Result type whose error is a boxed captured diagnostic.
- Diagnostic
Result - Result type whose error is a boxed structured diagnostic.
- Result
- Sink
Result