# Changelog

All notable changes to this project 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).

## [0.2.0] - 2026-03-14

### Changed

- Hardened blockchain adapter contracts across `mock`, `ethereum`, and `hyperledger` backends with normalized return schemas for submit/verify/status operations.
- Switched blockchain configuration to canonical `IMGSEC_*` environment variables only.
- Upgraded CLI blockchain verification behavior with normalized status output and explicit exit codes:
  - `0` passed
  - `2` partial/failed verification
  - `1` runtime/configuration error or disabled backend
- Split blockchain dependency extras:
  - `ethereum`
  - `hyperledger`
  - `blockchain-all`

### Added

- Fail-open blockchain anchor error recording in audit logs via `blockchain_anchor_error` with sanitized fields:
  - `backend`
  - `error_code`
  - `message`
  - `retryable`
  - `timestamp`
- Frequency validation for `IMGSEC_BLOCKCHAIN_FREQUENCY` with secure default fallback.
- Integration tests for mock, Ethereum, and Hyperledger adapter flows.
- CI jobs that gate blockchain backend integration checks and upload backend-specific test artifacts.

### Fixed

- Mock blockchain storage race/corruption risk by adding file locking and atomic write semantics.
- Local test runner reliability (`run_tests.sh`) by using `python3`, strict shell mode, and repo-relative policy paths.

### Migration Notes

- Legacy blockchain environment names are no longer supported:
  - `BLOCKCHAIN_BACKEND` -> `IMGSEC_BLOCKCHAIN_BACKEND`
  - `ETHEREUM_RPC_URL` -> `IMGSEC_ETHEREUM_RPC_URL`
  - `ETHEREUM_PRIVATE_KEY` -> `IMGSEC_ETHEREUM_PRIVATE_KEY`
  - `ETHEREUM_CONTRACT_ADDRESS` -> `IMGSEC_ETHEREUM_CONTRACT_ADDRESS`
- For package extras, replace `pymedsec[blockchain]` with `pymedsec[blockchain-all]` (or backend-specific extras).

## [0.1.0] - 2025-09-07

### Added

#### Core Features

- **Medical Image Security**: Complete HIPAA/GDPR/GxP-ready medical image sanitization and encryption library
- **Envelope Encryption**: AES-256-GCM with KMS-managed key wrapping for secure data protection
- **PHI Sanitization**: Comprehensive DICOM and EXIF metadata cleaning to remove sensitive information
- **Audit Logging**: Tamper-evident logs with HMAC signatures and rolling anchor hashes
- **Blockchain Anchoring**: Optional blockchain audit anchoring for enhanced tamper-evident compliance

#### KMS Integration

- **AWS KMS**: Production-ready AWS Key Management Service integration
- **HashiCorp Vault**: Enterprise secret management with Vault backend
- **Mock KMS**: Development and testing KMS adapter for local development

#### Blockchain Support

- **Ethereum Integration**: Full Ethereum blockchain support via web3.py
- **Mock Blockchain**: Local simulation for testing and development
- **Hyperledger Framework**: Placeholder for future Hyperledger Fabric support

#### Format Support

- **DICOM**: Complete DICOM metadata extraction, sanitization, and UID regeneration
- **PNG**: EXIF metadata handling and removal
- **JPEG**: EXIF, IPTC, and XMP metadata processing
- **TIFF**: Technical and EXIF metadata management

#### CLI Interface

- **pymedsec CLI**: Complete command-line interface for all operations
- **Sanitization Commands**: File sanitization with format-specific options
- **Encryption/Decryption**: Secure data encryption and memory-only decryption
- **Verification Tools**: Integrity verification and blockchain anchor validation
- **Audit Commands**: Audit log management and blockchain verification

#### Developer Experience

- **Python 3.8+**: Compatible with Python 3.8 through 3.12
- **No Type Annotations**: Clean codebase without type hints for broad compatibility
- **Comprehensive Testing**: Full test suite with pytest and coverage reporting
- **Documentation**: Complete technical documentation and compliance guides

#### Compliance Features

- **HIPAA Readiness**: Aligned with HIPAA Security Rule requirements
- **GDPR Compliance**: Privacy-by-design with data minimization
- **GxP Validation**: Good practice validation for regulated environments
- **Audit Trails**: Complete audit logging for compliance verification

### Security Features

- **Memory-Only Processing**: Secure ML training workflows with automatic memory cleanup
- **PHI Protection**: No PHI transmitted to external systems (blockchain, KMS)
- **Cryptographic Integrity**: SHA-256 digest verification and tamper detection
- **Key Management**: Secure key wrapping and rotation support

### Documentation

- **Architecture Guide**: Complete system architecture documentation
- **Compliance Guides**: HIPAA, GDPR, and GxP alignment documentation
- **Blockchain Guide**: Detailed blockchain audit anchoring documentation
- **API Documentation**: Complete Python API documentation
- **CLI Documentation**: Full command-line interface documentation

### Infrastructure

- **PyPI Ready**: Complete packaging configuration for PyPI publication
- **Build System**: Modern setuptools build configuration
- **Development Tools**: Black formatting, flake8 linting, pytest testing
- **CI/CD Ready**: GitHub Actions workflow examples

### Examples

- **Demo Scripts**: Working demonstration scripts for all features
- **Integration Examples**: Real-world usage examples and patterns
- **Policy Templates**: Sample YAML policy configurations

## [Unreleased]

### Planned Features

- **Hyperledger Fabric**: Complete Hyperledger Fabric blockchain integration
- **Additional KMS**: Azure Key Vault and Google Cloud KMS support
- **Enhanced OCR**: Advanced OCR-based redaction capabilities
- **Performance Optimization**: Multi-threading and async processing
- **Cloud Integration**: Direct cloud storage integration
- **ML Pipeline**: Enhanced ML training pipeline integration

---

### Note on Versioning

This project follows semantic versioning:

- **MAJOR**: Incompatible API changes
- **MINOR**: Backwards-compatible functionality additions
- **PATCH**: Backwards-compatible bug fixes

### Security Updates

Security-related changes are highlighted in release notes and detailed in the security documentation.

### Breaking Changes

Any breaking changes will be clearly documented in the release notes with migration guides.
