Skip to content

Remediation

darkstar edited this page Oct 3, 2026 · 2 revisions

Remediation

Remediation is a separate flow from diagnosis:

Diagnostic → Suggestion → Fixer / FixPlan → RemediationReceipt

💡 Suggestions

use diagprint::{Applicability, Edit, Suggestion, TextRange};

let suggestion = Suggestion::new("Replace deprecated value")
    .applicability(Applicability::MachineApplicable)
    .edit(Edit::replace("config.toml", TextRange::new(10, 13), "old", "new"));
pub enum Applicability { MachineApplicable, MaybeIncorrect, HasPlaceholders, Manual }

Only guarded, MachineApplicable structured edits are eligible for automatic application.

🔧 Fixer

use diagprint::Fixer;

let check  = Fixer::new().check(&diagnostic)?;                      // validate, write nothing
let report = Fixer::new().backups(true).apply(&diagnostic)?;        // apply validated fixes
Fixer::new().backups(true).apply_interactive(&diagnostic)?;         // ask first

Before any write it validates applicability, expected source contents, edit ranges, UTF-8 boundaries, overlapping edits, duplicate insertion points and filesystem state. Stale edits are rejected, never guessed.

🧰 FixPlan: transactional multi-file fixes

  1. validate every affected file
  2. prepare all resulting contents
  3. create recovery state
  4. perform the writes
  5. roll back observed failures
  6. optionally run post-fix verification
  7. roll back if verification fails

Warning

Portable crash-atomic multi-file writes are not claimed.

✅ Verification and suggested commands

Fix plans can declare structured, declarative verification. diagprint never runs arbitrary shell commands during application or verification. Suggestions can carry advisory commands, which are never executed automatically:

use diagprint::SuggestedCommand;

let command = SuggestedCommand::new("cargo check")
    .explanation("Verify the project after applying the edit");

🔁 Remediation evidence replay

A successful guarded remediation receipt can be bound to an exact transition in tamper-evident history, then replayed later without reapplying anything:

diagprint replay .diagprint/history <FINGERPRINT>
diagprint replay .diagprint/history <FINGERPRINT> --format json
diagprint history remediation-verify .diagprint/history

Replay separates observed lifecycle evidence from causal claims: remediation causation, recurrence root cause and Git causation stay NOT ESTABLISHED. Spec: docs/forensics-remediation-replay-v1.md, receipts: docs/receipt-v1.md.

← 🌉 Ecosystem Interop  ·  🔬 Diagnostic Forensics →

🩺 diagprint

⚡ Start

🧱 Build

📤 Ship

🔧 Fix

🔬 Investigate

🛠️ Project


🌐 Site · 📖 docs.rs · 📦 crates.io

Clone this wiki locally