# Changelog

All notable changes to this project will be documented in this file.

## [0.4.2] - 2026-03-31

### Added
- **Agentic Tool Guards** (`ToolCallGuard`): A declarative firewall for agent tool executions, preventing infinite loops and dangerous downstream actions.
- **Session Tracker** (`SessionTracker`): In-memory TTL tracking for `max_calls_per_session` rate-limiting to prevent rogue agents from draining budgets or blowing up downstream APIs.
- **Frictionless Adapters**: 
  - `@wrap_tool`: Universal decorator for tracking pure Python tool execution.
  - `wrap_langchain_tools`: Dynamically secures existing LangChain `BaseTool` lists.
- **`ToolCallViolation` Exception**: Child of `FinGuardViolation` explicitly typed for tool interception, allowing the agent orchestration loop to safely self-correct instead of crashing.

## [0.4.1] - 2026-03-31

### Added
- **Langfuse Backend** (`LangfuseBackend`): Native hierarchical session tracing and visual safety scoring using the Langfuse API. 
- **OpenTelemetry Backend** (`OTELBackend`): Native APM integration emitting standard W3C traces (single `finguard.guard` span with per-scanner span events) and metrics (`finguard.latency.ms`). 
- **Agent Backtracking Exceptions**: Framework now raises `FinGuardViolation` (carrying the full `GuardTrace`) instead of a generic string exception when a policy is blocked, allowing orchestrators to programmatically self-correct.
- **Observability Extras**: Exposes enterprise backend dependencies cleanly via `pip install finguard[observability]`, keeping the core module lightweight. Added `pip install finguard[all]`.

## [0.4.0] - 2026-03-30

### Added
- **GuardTrace** — Immutable forensic record per invocation. Every `GuardResult` now carries a `trace` field with `trace_id`, `policy_id`, `risk_tier`, input fingerprint, per-scanner breakdown, block stage, and latency.
- **ScannerTrace** — Per-scanner execution record capturing name, stage, trigger status, confidence score, violations, latency, and skip/bypass reason.
- **AuditLogger** — Multi-backend fan-out logger. Assembles `GuardTrace` from pipeline data and dispatches to configured backends.
- **Audit Backends** — `memory` (default, circular buffer), `file` (NDJSON, SIEM-compatible, strftime rotation), `console` (pretty-print for debugging).
- **In-process query API** — `guard.traces`, `guard.get_trace(id)`, `guard.violations` for incident review without leaving the process.
- **Extended `AuditConfig`** — `redact_input`, `include_metadata_keys` allowlist, `file_path` with daily rotation, `emit_traces` kill-switch.
- **Canonical scanner name registry** — Stable, human-readable scanner names in all traces regardless of class changes.

### Changed
- `pipeline.py` — Input and Output pipelines now return `List[ScannerTrace]` as a fourth/fifth element (backwards-compatible).
- `schema.py` — `GuardResult` gains an optional `trace: GuardTrace | None` field.
- `config.py` — `AuditConfig.backend` default changed from `'json'` to `'memory'`.

## [0.3.1] - 2026-03-28

### Added
- **Environment Health Check**: New `check_runtime_health()` utility to verify ONNX availability at startup. FinGuard now warns users loudly with fix instructions if `onnxruntime` or `optimum` are missing.
- **Model Pre-fetching**: New `finguard-download` CLI command and `FinGuard.download_models()` method to pre-cache all ONNX models, eliminating first-run latency.

### Fixed
- **Silent Latency Regression**: Fixed a bug where scanners would silently fall back to slow PyTorch inference without notifying the user.
- **Environment Stability**: Pinned `numpy < 2.0.0` and `torch >= 2.2.0` to resolve critical initialization crashes and `rms_norm` attribute errors in fresh environments.
- **Pipeline Redaction**: Corrected the output pipeline to properly recognize and persist PII redactions from the native `FinGuardPIIEngine`.

## [0.3.0] - 2026-03-28

## [0.2.0] - 2026-03-27

### Added
- **Native ONNX Acceleration**: Forced ONNX Runtime by default for all scanners, achieving a 3.4x performance gain on CPU.
- **Sub-150ms Latency**: Reduced baseline scanning overhead from ~400ms to ~117ms natively.
- **`FinGuard` Schema Refactor**: Extracted data models into `finguard/schema.py` to resolve circular dependencies and improve maintainability.

### Changed
- **Unified API**: Simplified `FinGuard` constructor by removing `device` auto-detection logic. The framework is now "Fast-by-default" on all platforms.
- **Dependency Stabilization**: Capped Python version to `<3.13` and optimized the core `onnxruntime` and `optimum` stack.
- **Refined Logging**: Suppressed noisy external library logs (transformers, hf_hub) and streamlined hardware status reports.

### Removed
- Experimental GPU/CUDA auto-detection (transitioned to universal high-speed CPU-ONNX architecture for stability).

### Fixed
- Initialization bug where `llm-guard` would force CUDA providers even if ORT-GPU was missing.
- Circular import between `core.py` and `pipeline.py`.
