error-forge 1.2.0

Pragmatic Rust error-handling framework with stable error metadata, contextual diagnostics, optional async support, and synchronous recovery primitives (retry, circuit-breaker, backoff). Optional #[derive(ModError)], declarative define_errors!, and feature-gated logging / tracing / serde adapters.
Documentation
# Changelog

All notable changes to error-forge will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.2.0] - 2026-11-12

Minor release for `error-forge` and `error-forge-derive` (both `1.2.0`), with fixes from an independent review. No public item is removed or changes signature. Two documented behaviours change; see Changed. `error-forge-derive` has no code changes and is versioned with the main crate.

### Fixed

- **A circuit-breaker probe that never returns no longer locks the breaker.** A half-open probe that runs longer than the new `CircuitBreakerConfig::probe_timeout_ms` (default: the reset timeout) counts as failed: the circuit reopens and admits a new probe after the next reset timeout, and the hung probe's late result is ignored. Before, every call failed fast until a manual `reset()`.
- **The retry executor can jitter.** `RetryExecutor::with_backoff(impl Backoff)` takes any backoff (a configured `ExponentialBackoff` included), and `RetryExecutor::with_jitter` and `RetryPolicy::with_jitter` turn ±20% jitter on for the exponential schedule. Before, every executor used the same fixed 100, 200, 400 ms schedule, so retriers across a fleet woke in step.
- **Jitter no longer piles delays onto the cap.** A jittered delay is drawn from 80% to 120% of the calculated delay but never above the maximum, instead of being clamped onto it, which put about half of all delays at the cap on exactly the same instant.
- **Failure tracking stays linear.** The breaker keeps its failure times in a `VecDeque`, drops expired ones from the front, and keeps at most `failure_threshold` of them, instead of scanning a growing list under the lock on every failure.

### Security

- **`ForgeError::user_message` no longer carries the error's data.** It was documented as safe to show end users but defaulted to the full `Display` text, which carries file paths, endpoints (with any credentials in them), source errors and field values. The default is now the error's `caption()`. `AsyncForgeError::user_message` changes the same way, and `ContextError::user_message` leaves its context out. `Display`, `Debug` and `dev_message()` are unchanged and keep the detail for logs. Override `user_message` to show a message you have checked.
- **`Redacted<T>`**: a wrapper that prints as `[redacted]` in `Display`, `Debug` and `serde` output, so secrets held in an error stay out of error text and logs.
- **The `log` and `tracing` adapters escape control characters** in `dev_message`, so a newline in user input cannot start a forged log line.
- `#![forbid(unsafe_code)]` at the crate root (there was no unsafe code).

### Added

- `CircuitBreakerConfig::probe_timeout_ms` and `with_probe_timeout_ms`.
- `CircuitBreaker::is_probing`, which tells a running probe (calls fail fast) from a half-open circuit whose next call will be the probe.
- `RetryExecutor::with_backoff`, `RetryExecutor::with_jitter`, `RetryPolicy::with_jitter`.
- `Redacted<T>`.

### Changed

- `user_message()` defaults to the caption (see Security).
- A panic in a closure run by `CircuitBreaker::execute` in the closed state now counts as a failure, as an `Err` does. Before, only a panicking probe was recorded.
- The `jitter` feature no longer pulls in `rand`: jitter uses an in-crate generator and works with or without the feature. The feature now turns jitter on by default for the exponential `RetryExecutor` and `RetryPolicy`.

### Docs

- The circuit breaker documents that it counts failures, not a failure rate, and that closures need their own I/O timeouts.
- The hook docs say a panicking hook is caught only under `panic = "unwind"`, and that hooks must not panic or block.
- `docs/STABILITY.md` no longer says the crate panics in one place (it does not), and lists no jitter dependency. The stale `parking_lot` note in `Cargo.toml` is gone.


## [1.1.0] - 2026-11-09

Minor release for `error-forge` and `error-forge-derive` (both `1.1.0`). With default features, `error-forge` no longer brings any third-party crate into a dependent's build: `cargo tree -e normal` lists 8 third-party crates for `1.0.2` on Windows, Linux and macOS and none for `1.1.0`. No public item is removed, renamed or changed, and default features stay `[]`.

### Added

- `error-forge-derive` has a `derive` feature, on by default, that gates `#[derive(ModError)]` and the `syn`, `quote` and `proc-macro2` dependencies. Without it the crate has no dependencies.
- `error-forge` declares its `error-forge-derive` feature explicitly. Cargo created it implicitly while `error-forge-derive` was an optional dependency; it keeps its meaning (it compiles the derive macro, and `derive` implies it), so manifests that name it keep resolving.
- CI checks that the default `error-forge` dependency graph contains no third-party crate on any target.

### Changed

- `define_errors!` builds its constructor names (`fn [<Variant:lower>]`) with an internal identifier-pasting macro in `error-forge-derive` instead of the third-party `pastey` crate. Constructor names, spans and error messages for invalid names (a variant such as `Type` whose lowercase name is a keyword) are unchanged. The macro is reachable as `error_forge::__private::paste!`, which is not public API; the hidden `error_forge::__private::pastey` re-export is gone.
- `error-forge-derive` is now an always-on dependency of `error-forge`, with its default features off. The `derive` feature enables `error-forge-derive/derive` through the `error-forge-derive` feature.
- `CircuitBreaker` uses `std::sync::Mutex` instead of `parking_lot::Mutex`. Every acquisition goes through `PoisonError::into_inner`, so no method can panic on a poisoned lock, as before. `CircuitBreaker` is now `UnwindSafe` and `RefUnwindSafe`.
- `CircuitBreaker::execute` takes its lock once instead of twice for a successful call in the closed state; only the half-open probe takes it again. Against `1.0.2` (release build, no-op closure): uncontended `execute` is 17% faster on Windows and 20% faster on Linux (41.2 to 34.2 ns, 38.9 to 31.3 ns); eight threads sharing one breaker are 47% faster on Windows and 10% faster on Linux.
- A clean debug build of a crate that depends on `error-forge` with default features takes 0.78 s instead of 1.09 s on 32 jobs and 0.99 s instead of 2.67 s on one job (median of five, Windows, `CARGO_INCREMENTAL=0`).
- `docs/STABILITY.md` lists the new dependency set and narrows the dependency rules to what dependents can observe: adding a third-party dependency outside an opt-in feature is still a `2.0.0` change; removing one whose types are not in the public API is not. `docs/architecture.md`, `docs/COMPARISON.md`, `docs/migration.md`, `SECURITY.md` and the README describe the new dependencies.
- `error-forge-derive`'s `#[derive(ModError)]` implementation moved from `src/lib.rs` to `src/mod_error.rs`. No behaviour change.
- The lockfile takes `tokio` 1.53.3 (a dev-dependency, used by the tests only, #19) for RUSTSEC-2026-0386; nothing in either crate uses `AsyncFd`.

### Removed

- The `pastey` and `parking_lot` dependencies, and with them `lock_api`, `parking_lot_core`, `scopeguard`, `smallvec`, `cfg-if` and `windows-link` (Windows) or `libc` (Unix) from every dependent's build. None of their types appear in the public API.

## [1.0.2] - 2026-10-08

Patch release for `error-forge` and `error-forge-derive` (both `1.0.2`). Bug fixes, hygiene and build-time improvements; no public item added, removed or renamed (`cargo semver-checks` against `1.0.1`: 222 checks pass). Some inputs that compiled but silently produced wrong output are now compile errors; see **Changed**.

Patch release for `error-forge` and `error-forge-derive`. Bug fixes, documentation corrections and test/CI additions; no public item added, removed or renamed. A few fixes change output or reject input that used to be accepted silently; each is listed under Changed.

### Changed

- `define_errors!` passes a display string that has no field list through `format!`, as it already did for strings with one. `{{` and `}}` now print single braces, and a field named inline (`"Config error: {message}"`) is interpolated instead of printed literally. Strings without braces render as before. A string with a placeholder that names neither a field nor an item in scope (for example `"{}"` with no field list) used to print the braces and is now a compile error.
- `define_errors!` rejects unknown `#[kind]` tags at compile time. A misspelled tag (`retriable = true`, `staus = 503`) used to be ignored, leaving the default value in place.
- `#[derive(ModError)]` formats unit-variant display strings through `format!` like every other variant, so `"use {{x}} here"` displays as `use {x} here` instead of keeping the doubled braces. As for other variants, a `{name}` that resolves to nothing in scope is now a compile error.
- `#[derive(ModError)]` reports malformed attribute values as compile errors pointing at the value, instead of silently falling back to the default: a non-integer or out-of-range `#[error_http_status]` (`"404"`, `-1`, `70000`) or `#[error_exit_code]` (`99999999999`), a flag given something other than `true`/`false` (`#[error_retryable("yes")]`), and a string attribute given a non-string (`#[error_display(42)]`, a bare `#[error_prefix]`). A negative `#[error_exit_code(-2)]`, which was ignored, is now honoured.
- The `Display` impls generated by `#[derive(ModError)]` honour a width or precision given where the error is formatted: `format!("{:>10}", err)` pads the message and `{:.3}` truncates it. Without a width or precision the output is unchanged.
- `ForgeErrorRecovery::retry` honours `self.is_retryable()` as its documentation states: a non-retryable receiver runs the operation once and returns its result. It used to retry whenever the operation's own error was retryable, regardless of the receiver.
- `install_panic_hook` keeps the previously installed panic hook and calls it after printing the themed panic message, so crash reporters and logging hooks installed earlier keep working. When no custom hook was installed, the standard library's default message (and backtrace, if `RUST_BACKTRACE` is set) now follows the themed lines.
- `TracingAdapter` records the developer message in a field named `dev_message`. It used a field named `message`, which `tracing` reserves for the event message, so formatters printed two `message` values and JSON output carried a duplicate key.
- The error hook is no longer re-entered: an error created while the hook runs on the same thread (for example by a log sink that fails) does not call it again. A panic inside the hook is caught and discarded instead of unwinding through the `AppError` / `define_errors!` constructor or `ForgeError::register` call that fired it; the process panic hook still reports it.
- Dependency floors match what the code needs and are checked by a new CI job that builds with every direct dependency at its minimum version: `syn` `1.0.3`, `quote` `1.0.29` and `proc-macro2` `1.0.63` in `error-forge-derive`; `serde` `1.0.157`, `log` `0.4.4` and `tracing` `0.1.6` in `error-forge`. The previous floors (`syn 1.0`, `tracing 0.1`, `log 0.4`, ...) did not build.
- The `Display` impls generated by `#[derive(ModError)]` and `define_errors!` write straight to the formatter instead of building an intermediate `String`: about 19 ns instead of 49 ns for a two-field message, with no allocation.
- `CircuitBreaker` fails fast with one allocation instead of two: the circuit name is shared with `CircuitOpenError` instead of copied into it.
- `CodedError::is_retryable` and `CodedError::dev_message` read the registry entry in place instead of cloning it on every call.
- The colour detection in `ConsoleTheme` drops a Windows-only `WT_SESSION` check that returned the same answer as the default path. No behaviour change.
- CI runs the test suite on the `1.81` MSRV (with an MSRV-compatible resolution of the dev-dependencies), adds the minimal-versions build, and runs compile-pass / compile-fail tests for `define_errors!`, `group!` and `#[derive(ModError)]` through `trybuild` (new dev-dependency). `tests/thread_safety_test.rs` now exercises the hook, the error-code registry, collectors and the circuit breaker from several threads; it previously never shared anything between threads. Regression tests cover every fix in this release.

### Removed

- The `thiserror` dependency. Nothing in either crate used it and none of its types appear in the public API, so dependents cannot observe the removal; a clean default build is about 57% faster (3.0 s to 1.3 s in a local debug build). `docs/STABILITY.md` and `docs/COMPARISON.md` no longer list it.

### Fixed

- `define_errors!` no longer requires every field to implement `Display` and `Debug` when the variant has a custom display string. The default `"<caption>: <Variant> | field = value"` format is only generated for variants without one, and it chooses `Display` for a field named `source` and `Debug` for the others at expansion time, so fields such as `PathBuf`, `Vec<_>`, `Option<io::Error>` and `Option<Box<dyn Error + Send + Sync>>` work with a custom display. Output is unchanged for code that compiled before. The README's flagship example compiles again.
- `define_errors!` accepts doc comments and other attributes on variants, `#[error(...)]` after `#[kind(...)]`, and a missing trailing comma after the last variant. Malformed variants (missing `#[kind]`, two `#[error]` attributes, tuple variants) get a specific error message. Large enums in the 1.0.1 form still expand without recursion.
- `define_errors!` and `#[derive(ModError)]` refer to everything they generate through absolute paths (`::core::...`, `::std::...`, `$crate::...`), so user items named `Option`, `Some`, `None`, `Result`, `String`, `Box`, `std`, `core`, `fmt`, or local `format!` / `write!` / `stringify!` / `concat!` macros no longer break the expansion or change its output. `group!` already did; a test now covers all three.
- `#[derive(ModError)]`: `#[error_retryable(false)]`, `#[error_retryable = false]` and the same forms of `#[error_fatal]` evaluate to `false`. Any value used to mean `true`.
- `#[derive(ModError)]`: fields with raw identifiers (`r#type`) compile, and display strings may name them as `{type}` or `{r#type}`. Width and precision arguments taken from fields (`{value:>width$}`) keep working.
- `CircuitBreaker` credited the outcome of a slow call admitted while the circuit was closed to the half-open probe: if it finished during the probe, a failure reopened the circuit and a success closed it and let further callers through, breaking the single-probe guarantee. Only the probe now decides how the circuit leaves half-open; outcomes of calls admitted before the circuit tripped, or before `reset`, no longer count.
- `ErrorCollector::default()` no longer requires `E: Default`; the derived impl added that bound.
- The README circuit-breaker example used `CircuitBreaker::execute` as if it returned the closure's error type and did not compile. It now shows the boxed `RecoveryResult` and how to tell `CircuitOpenError` apart from the closure's error. README code blocks run as doctests so they keep compiling.
- `docs/STABILITY.md` no longer says `define_errors!` generates `ForgeError` impls; it generates inherent metadata methods.
- The `ForgeError::register` rustdoc no longer claims it registers the error with "the central error registry". It fires the error hook and stores nothing.
- The `ConsoleTheme::format_error` rustdoc no longer claims the method allocates exactly once.
- Documented limitations that need a breaking change to fix: enabling `async` anywhere in the dependency graph makes method calls such as `error.kind()` on `AppError` ambiguous where both `ForgeError` and `AsyncForgeError` are in scope (use `ForgeError::kind(&error)` or import one trait), and `ResultExt::context` collides with `anyhow::Context` (call `ResultExt::context(result, ...)` by path). The README, `docs/API.md` and the trait rustdocs show the workarounds. The README and `Cargo.toml` also state that the `console`, `backtrace`, `registry`, `collector` and `context` features gate nothing, and the derive docs state that attributes other than `error_prefix` are ignored on structs.

## [1.0.1] - 2026-10-08

Patch release for `error-forge` and `error-forge-derive` (both `1.0.1`). Bug fixes and documentation corrections only; no public item added, removed or renamed (`cargo semver-checks` against `1.0.0`: 222 checks pass).

### Changed

- `Cargo.lock` refreshed to the latest compatible releases (`serde 1.0.229`, `log 0.4.33`, `async-trait 0.1.91`, `rand 0.8.7`, `serde_json 1.0.151`, `tokio 1.53.0`, `quote 1.0.47`, `proc-macro2 1.0.107`). No `Cargo.toml` requirement changes; the lockfile is not part of the published crate.
- `AsyncForgeError` carries `#[allow(clippy::double_must_use)]` so the code `async_trait` generates for its default methods passes clippy 1.99 under `-D warnings`. No API or behaviour change.
- CI uses `actions/checkout@v7` (Node 24), installs a prebuilt `cargo-audit` instead of compiling it each run, runs clippy with `--all-targets` for default and all features, and runs the test suite with `--all-features` so the `async`, `log`, `tracing` and `jitter` paths are exercised.

### Fixed

- `CircuitBreaker::execute` no longer panics with "overflow when subtracting duration from instant" when `failure_window_ms` reaches back past the start of the monotonic clock (for example `u64::MAX`, or a window longer than the host's uptime). Such a window now keeps every recorded failure.
- `LinearBackoff::next_delay` saturates at `max_delay` instead of overflowing on large `attempt` or `increment` values. Debug builds used to panic and release builds returned a wrapped, far too short delay.
- `ExponentialBackoff::next_delay` clamps attempts above `i32::MAX` instead of wrapping to a negative exponent, which returned a zero delay where the cap was expected.
- `define_errors!` now works when invoked by path (`error_forge::define_errors! { ... }`) without importing the macro. Its internal helper arms recursed through the bare `define_errors!` name and failed with "cannot find macro `define_errors` in this scope"; they now go through `$crate::define_errors!`.
- The `group!` rustdoc, README, `docs/API.md` and `docs/migration.md` no longer claim that `define_errors!` implements `ForgeError`. It generates inherent metadata methods only; the docs now show the delegating `impl ForgeError` needed to wrap such an enum in `group!`, and the `group!` rustdoc carries it as a compiled example.
- `CircuitBreaker` now admits a single probe call once the reset timeout elapses, as `CircuitState::HalfOpen` documents. Concurrent calls fail fast with `CircuitOpenError` until the probe resolves; previously every caller was let through. A probe that panics reopens the circuit instead of leaving it stuck half-open.
- `CircuitBreaker::state` reports `CircuitState::HalfOpen` once the reset timeout of an open circuit has elapsed. It used to keep reporting `Open` until the next `execute` call. Reading the state does not change it.
- `ExponentialBackoff::next_delay` caps the first attempt at `max_delay` like every later attempt; it used to return the initial delay even when that was larger. With the `jitter` feature and `with_jitter(true)`, jitter now applies to the first attempt too, and a jittered delay never exceeds `max_delay` (it could previously land up to 20% above it).
- `ConsoleTheme` colour detection follows <https://no-color.org/>: `NO_COLOR` disables colour only when it is set to a non-empty value. An empty `NO_COLOR` used to disable colour as well, contrary to both the spec and the code comment. The `ConsoleTheme` rustdoc now counts two `const` preset constructors, not three.
- The `ErrorLogger::log_panic` rustdoc no longer implies the crate calls it when a panic hook is registered. It states that nothing calls it automatically and shows how to forward to it from your own panic hook.
- `error-forge-derive`: `#[derive(ModError)]` on a union now reports a `compile_error!` at the `union` keyword instead of panicking inside the proc macro.
- `error-forge-derive`: `#[derive(ModError)]` no longer generates code that fails to compile ("argument never used" / "named argument never used") for variants with fields that have no `#[error_display]`, or whose display string does not mention every field. Only the fields the string references are passed to `format!`. Strings that compiled before render the same output.
- `docs/API.md` examples compile and pass. The file had carried a stale second half since `0.9.7` (starting mid code block) that documented APIs which do not exist (`ErrorMetadata`, `register_url_format`, `with_success_threshold`, async `retry`), listed the removed `thread-safety` feature and `AppError::with_async_context`, and grouped `io::Error` directly. Those sections are replaced by working examples for hooks, logging, context, error codes, collection, backoff, retry, the circuit breaker, `ForgeErrorRecovery` and `AsyncForgeError`. Every `rust` block in the file now runs as a doctest under `cargo test --all-features`.
- The `[1.0.0]` CHANGELOG entry links its release notes to the v1.0.0 GitHub release. It pointed at `.dev/release/v1.0.0.md`, which is git-ignored and does not exist in the repository or the published crate.

## [1.0.0] - 2026-05-18

Stable API. The public surface is locked under SemVer for the entire `1.x` line — see [`docs/STABILITY.md`](docs/STABILITY.md) for the binding policy and [`docs/API-FREEZE-AUDIT.md`](docs/API-FREEZE-AUDIT.md) for the surface manifest. Three breaking corrections at the freeze boundary (`group!` macro, `parking_lot::Mutex` in `CircuitBreaker`, `AsyncForgeError::async_handle` default), several deprecations, `#[non_exhaustive]` annotations on public types likely to grow, and a substantial documentation expansion. See the full release notes in the [v1.0.0 GitHub release](https://github.com/jamesgober/error-forge/releases/tag/v1.0.0).

### Added

- **`docs/STABILITY.md`** — formal SemVer / panic-safety / determinism / deprecation / dependency / MSRV policy for the `1.x` line.
- **`docs/API-FREEZE-AUDIT.md`** — manifest of every public symbol in `1.0.0`, what trait impls it carries, what is `pub(crate)`, what is intentionally out of scope.
- **`docs/COMPARISON.md`** — honest side-by-side with `anyhow`, `thiserror`, `miette`, `snafu`, `eyre` including non-strengths.
- **`docs/architecture.md`** — design rationale (why `ForgeError` trait, why sync recovery, why `parking_lot`, etc.).
- **`docs/migration.md`** — upgrade guide from `0.9.x → 1.0.0` (and historical `0.6.x → 0.9.x → 1.0.0` summary).
- **`SECURITY.md`** — vulnerability disclosure policy with the `me@jamesgober.com` private reporting channel and triage timeline.
- **`CONTRIBUTING.md`** — contributor workflow, CI gates, code style, banned terms.
- **`RELEASING.md`** — codified release procedure with the derive-first publish order documented.
- **`CODEOWNERS`** — single-maintainer default.
- **`.dev/DIRECTIVES.md`** and **`.dev/ROADMAP.md`** — internal workflow rules and outstanding-work tracker (git-ignored).
- **`.github/dependabot.yml`** — weekly grouped updates for `cargo` and `github-actions` ecosystems with the `dtolnay/rust-toolchain` tag-format workaround.
- **`.github/PULL_REQUEST_TEMPLATE.md`** + `.github/ISSUE_TEMPLATE/{bug_report,feature_request}.md`.
- **`deny.toml`** — license allow-list, wildcard ban, `crates.io`-only sources.
- **`cargo deny` CI job** alongside `cargo audit`.
- **`new()` constructors on `ErrorContext` and `CircuitBreakerConfig`** so external callers (tests, custom wiring) can build these `#[non_exhaustive]` types without depending on the field list.
- **`CircuitBreakerConfig::with_failure_threshold` / `with_failure_window_ms` / `with_reset_timeout_ms`** builder methods for partial overrides.
- **`AppResult<T>`** — new type alias for `Result<T, AppError>` that does not shadow `std::result::Result` in glob imports.

### Changed

- **Breaking — `group!` macro rewritten.** The internal `@with_impl` arm had a macro-parse ambiguity in `0.9.x` that prevented top-level invocations of the documented form (covered by `ignore`d doctest in `0.9.x`). The rewrite eliminates the second repetition block entirely, and the generated `ForgeError` impl now delegates directly to each wrapped type's `ForgeError` methods instead of the silently-broken type-erased downcast pattern. **Every wrapped variant must now implement `ForgeError`** — wrap foreign types in `define_errors!` or `#[derive(ModError)]` enums first. Doctest is no longer `ignore`d and the parse-ambiguity is gone.
- **Breaking — `CircuitBreaker` now uses `parking_lot::Mutex` instead of `std::sync::Mutex`**. Removes the lock-poisoning hazard that `0.9.x` shipped — a panic inside an `execute(|| ...)` closure no longer poisons the breaker for the rest of the process. Adds `parking_lot` to the runtime deps (always-on).
- **Breaking — `AsyncForgeError::async_handle` gains a default no-op body.** Was a required method in `0.9.x` with a stub `Ok(())` impl on `AppError`; the stub is removed. Implementors override `async_handle` only if they want async behaviour.
- **Breaking — `AppError::with_async_context` removed.** The method took a `FnOnce()` and synchronously called it; nothing async about it. Use `ResultExt::with_context` or build `ContextError` directly.
- **Breaking — `#[non_exhaustive]` added to `ErrorLevel`, `ErrorContext`, `ErrorCodeInfo`, `CodedError`, `ContextError`, `CircuitBreakerConfig`, `CircuitState`.** External code can no longer struct-literal-construct these types, and exhaustive `match` statements need a wildcard arm. Migration guide in [`docs/migration.md`](docs/migration.md).
- **Breaking — `CodedError::new` no longer auto-registers the code** in the global registry. Pre-register codes at startup with `register_error_code` if you want documentation URLs or per-code retryability. Hot-path cost on `with_code(...)` is now one allocation and zero locking.
- **Breaking — hook callback widened to `Box<dyn Fn(ErrorContext<'_>) + Send + Sync + 'static>`.** Was a bare function pointer `fn(ErrorContext)` in `0.9.x`; the new shape accepts closures capturing thread-safe state.
- **Breaking — `pub use crate::macros::*;` narrowed.** The wildcard re-exported `ErrorContext`, `ErrorLevel`, `ErrorSource`, `register_error_hook`, `try_register_error_hook`, `call_error_hook`. `1.0` lists the first five explicitly and drops `call_error_hook` from the prelude path (still reachable via `error_forge::macros::call_error_hook`).
- **Performance — `CodedError::new` no longer takes a registry lock** (see Breaking note above).

### Deprecated

- **`error_forge::macros::register_error_hook`** (non-`try` variant). Silently discards the registration failure when a hook is already installed. Use `try_register_error_hook` instead, which returns `Err("Error hook already registered")` so callers can decide how to react.
- **`error_forge::Result<T>`** type alias. Shadows `std::result::Result` in `use error_forge::*` glob imports — a quiet footgun in caller code. Use `error_forge::AppResult<T>` instead.

Both deprecations stay callable through the entire `1.x` line; they are removed only in `2.0`.

### Security

- **`Cargo.lock` updated** to clear two RustSec advisories surfaced by `cargo-deny check`:
  - **GHSA-434x-w66g-qw3r / bytes 1.10.1** (integer overflow in `BytesMut::reserve`). Pulled patched `bytes 1.11.1` into the lockfile. Transitive via `tokio` (dev-only — does not affect consumers).
  - **RUSTSEC-2026-0097 / rand 0.8.5** (unsoundness in `rand::rng()` under a custom-logger + reseed scenario). Pulled patched `rand 0.8.6` into the lockfile. Only pulled in under the optional `jitter` feature; the unsoundness conditions do not apply to `error-forge`'s usage, but updating clears the advisory regardless.

### Compatibility

- MSRV stays at Rust `1.81`. No bump.
- The default feature set is `[]` (every optional feature is opt-in). Unchanged.
- New optional `jitter` feature gates the `rand` runtime dep that previously was always-on. Existing users who do not call `ExponentialBackoff::with_jitter(true)` save the `rand` transitive deps; users who do, add `features = ["jitter"]` to their `Cargo.toml`.

## [0.9.8] - 2026-05-18

Cleanup release. Drops the deprecated `atty` dependency, prunes a dead feature flag, tightens `ConsoleTheme` allocations, resolves three of the four ignored doctests, and rewrites the `Cargo.toml` description without banned terms. No public API changes. Sets `rust-version` in `Cargo.toml` for the first time and ships the corresponding MSRV-verification CI job.

### Added
- `rust-version = "1.81"` in `Cargo.toml`. MSRV is now declared explicitly and CI runs a dedicated MSRV-pin job verifying the crate builds against the exact `1.81.0` toolchain. The floor is driven by three independent constraints: `io::Error::other` (used by `AppError::filesystem` builders) is stable since 1.74; clippy's `incompatible_msrv` lint flags additional 1.81 items in the current source; and the committed `Cargo.lock` is format v4, which Cargo cannot parse on toolchains older than 1.78. `1.81` is the conservative floor that satisfies all three and matches `mod-events` in the workspace for consistency.
- `MSRV` badge in `README.md`.
- `cargo audit` CI job that runs the RustSec advisory database against every push. The job declares `permissions: { contents: read, checks: write }` so the `rustsec/audit-check` action can post findings as GitHub Check Runs without hitting `Resource not accessible by integration`.
- `#[doc(hidden)] pub mod __private` in `lib.rs` re-exporting `pastey` so that `define_errors!` expansions in downstream crates do not require the user to add the dep manually.
- `.dev/release/v0.9.8.md` release note describing the full cleanup scope.

### Changed
- **`Cargo.toml` description rewritten without banned terms** (`comprehensive`, `robust`). The new text reads: "Pragmatic Rust error-handling framework with stable error metadata, contextual diagnostics, optional async support, and synchronous recovery primitives (retry, circuit-breaker, backoff). Optional `#[derive(ModError)]`, declarative `define_errors!`, and feature-gated logging / tracing / serde adapters."
- **`ConsoleTheme` colour fields are now `&'static str`** instead of `String`. Saves 8 heap allocations per `ConsoleTheme::default()` / `with_colors()` / `plain()` construction. `with_colors()` and `plain()` are now `const fn`.
- **`print_error` caches its default `ConsoleTheme`** in a process-wide `OnceLock`. The terminal-capability check runs at most once regardless of how many errors are printed.
- **`ConsoleTheme::format_error` writes into a single `String` buffer** using `std::fmt::Write` instead of allocating an intermediate string per section. Allocations drop from ~6 to 1 per error formatted.
- **`terminal_supports_ansi()` decision is now cached in a `OnceLock`** on every platform (the Windows branch already did this; the Unix branch did the env-var checks on every call).
- README `MSRV` badge added; install snippet bumped from `0.9.7` to `0.9.8` and now documents the `1.70` MSRV. Per-feature install lines unchanged.
- `lib.rs` doctests for the crate-level Quick Start and Built-in Formatting blocks no longer carry the `ignore` annotation — they compile and run as part of `cargo test --all-features`.
- `recovery/mod.rs` module-level doctest now compiles and runs (the closure return type is declared so the retry policy can type-check the loop).
- `async_error.rs::AsyncForgeError` doctest is now gated behind a hidden `#[cfg(feature = "async")]` block and runs under `cargo test --all-features`.
- `group_macro.rs::group` doctest remains `ignore`d but now documents two known limitations explicitly (a macro-parse ambiguity in `@with_impl` and a broken `ForgeError` delegation pattern). Both are scheduled to be fixed in `1.0`.
- CHANGELOG `[0.6.3]` entry no longer carries the "Current release version" marker (`0.6.3` is well past current).

### Fixed
- **Replaced `atty` with `std::io::IsTerminal`.** `atty` is unmaintained and on the RustSec radar (RUSTSEC-2021-0145 — unaligned-read race). `std::io::IsTerminal` (stable since Rust 1.70) is the canonical replacement and lets `error-forge` drop the dependency entirely. Affects `console_theme::terminal_supports_ansi`; behaviour is unchanged from the user's perspective.
- **Replaced `paste` with `pastey`.** `paste 1.0.15` is unmaintained as of 2024-10-07 (RUSTSEC-2024-0436 — the author archived the repo). `pastey 0.2.2` is the published drop-in fork: identical `paste!` macro semantics, same `[<...>]` token-pasting and case-modifier syntax that `define_errors!` relies on. `cargo audit` now reports zero warnings on the committed `Cargo.lock`.
- **Audit CI job permissions.** Added `permissions: { contents: read, checks: write }` to the `audit` job so the `rustsec/audit-check` action's Check Run posting no longer fails with `Resource not accessible by integration`.

### Removed
- **`atty` dependency.** No longer needed after the `IsTerminal` migration.
- **`paste` dependency.** Replaced by `pastey`; see Fixed section.
- **`once_cell` dependency and the `thread-safety` feature flag** that gated it. `once_cell::sync::OnceCell` was never imported anywhere in the crate — every `OnceLock` usage was already `std::sync::OnceLock` (stable since `1.70`). The `thread-safety` feature was dead code; enabling it added a dep with no behaviour change.
- **`extern crate serde;`** from `lib.rs`. This Rust 2015 idiom is unnecessary in 2021 edition and provided no functional value.
- **Placeholder `it_works` test from `lib.rs`** (`assert_eq!(2 + 2, 4);`). The two remaining inline tests (`test_error_display`, `test_error_kind`) carry actual coverage; placeholder cruft is gone.

### Compatibility
- No public API changes from `0.9.7`. The `Cargo.toml` `version` bump, `rust-version` declaration, and dependency-table shrinkage are the only consumer-visible deltas. Existing source compiles unchanged.
- Removing the `thread-safety` feature is technically a breaking change for any consumer that lists it explicitly, but the feature gated zero behaviour, so no observable consequences.
- MSRV is now formally `1.81` (driven by `io::Error::other` + lockfile format v4 + clippy `incompatible_msrv` lint findings; see the `Added` section for the full rationale). A dedicated MSRV CI job verifies this on every push.

## [0.9.7] - 2026-03-24

### Added
- Added `try_register_error_hook(...)` so applications can detect duplicate hook registration explicitly.
- Added regression coverage for `define_errors!`, `#[derive(ModError)]`, coded-error overrides, and feature-gated behavior.

### Changed
- Rewrote the public README and API reference to match the real crate surface, supported attributes, and current recovery model.
- Updated crate-level and recovery module documentation examples to reflect the current API.
- Made `define_errors!` default `fatal` behavior consistent with `ForgeError` and `AppError` by defaulting to `false`.

### Fixed
- Fixed `CodedError::with_retryable(...)` and `CodedError::with_status(...)` so they now apply real per-instance overrides.
- Fixed `define_errors!` helper expansion bugs affecting tag parsing, display formatting, and source chaining.
- Fixed the derive macro so list-style attributes such as `#[error_display("...")]` and `#[error_http_status(...)]` are honored.
- Fixed strict lint failures so `cargo clippy --all-targets --all-features -- -D warnings` now passes cleanly.
- Removed stale documentation that described unsupported APIs or outdated examples.


## [0.9.6] - 2025-08-17

### Added
- Async error handling support via `AsyncForgeError` trait
- Integration with `async-trait` for async error handling in async contexts
- New async utilities like `from_async_result` and `async_handle` methods
- Retry logic with async support in examples
- Comprehensive error recovery module with:
  - Backoff strategies (Exponential, Linear, Fixed) with configurable parameters and jitter
  - Circuit breaker pattern to prevent cascading failures
  - Retry policy framework with custom predicates and backoff support
  - `ForgeErrorRecovery` extension trait for all `ForgeError` types

## [0.9.0] - 2025-08-17

### Added
- Cross-platform CI workflow for testing on Linux, macOS, and Windows
- Clippy checks in CI to ensure code quality
- Windows-specific terminal color detection
- Automatic color disabling for non-interactive terminals
- Thread-safe error hook system using `OnceLock` instead of `static mut`
- Structured context support with `ContextError` type
- Error wrapping with context via `context()` and `with_context()` methods
- Error registry with support for error codes and documentation URLs
- Non-fatal error collection system with `ErrorCollector`
- Optional logging integration with support for:
  - Custom logging implementations
  - Integration with the `log` crate (optional)
  - Integration with the `tracing` crate (optional)
- Improved error chaining with source tracking

### Changed
- Replaced unsafe global mutable state with thread-safe alternatives

### Fixed
- Fixed Clippy warnings:
  - Removed needless doctest main function
  - Fixed collapsible match pattern in derive macros
  - Fixed unused variables and imports
- Addressed deprecated `PanicInfo` usage, replaced with `PanicHookInfo`
- Fixed thread safety test reliability issues
- Fixed `CodedError` state tracking to properly update and report fatal flags
  - Removed collapsible match patterns in error-forge-derive crate
  - Removed unnecessary `fn main()` from doctest examples

## [0.6.3] - 2025-08-17

Historical maintenance release; superseded by `0.9.0`.

## [0.5.0] - 2025 (Prior release)

Initial public release with core functionality.

### Added
- `define_errors!` macro for declarative error definitions
- `ForgeError` trait for unified error handling
- `group!` macro for error composition
- `#[derive(ModError)]` for simplified error implementation
- Console formatting with ANSI color support
- Error hook system with severity levels
- Zero external dependencies design

[Unreleased]: https://github.com/jamesgober/error-forge/compare/v1.2.0...HEAD
[1.2.0]: https://github.com/jamesgober/error-forge/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/jamesgober/error-forge/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/jamesgober/error-forge/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/jamesgober/error-forge/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/jamesgober/error-forge/compare/v0.9.8...v1.0.0
[0.9.8]: https://github.com/jamesgober/error-forge/compare/v0.9.7...v0.9.8
[0.9.7]: https://github.com/jamesgober/error-forge/compare/0.9.6...v0.9.7
[0.9.6]: https://github.com/jamesgober/error-forge/compare/0.9.0...v0.9.6
[0.9.0]: https://github.com/jamesgober/error-forge/compare/0.6.3...v0.9.0
[0.6.3]: https://github.com/jamesgober/error-forge/compare/0.6.1...0.6.3