# Changelog

All notable changes to MockMesh are documented here.
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

---

## [0.0.1] — 2026-03-22 (First Beta Release)

### Added

#### Core engine & plugin system
- `mockmesh.initialize()` — single call activates all interceptors; no return value capture required
- `mockmesh.engine()` — context-manager variant for scoped test or CI runs
- `mockmesh.shutdown()` — clean teardown with storage flush
- Singleton guard in `initialize()`: safe to call multiple times in same process
- `BasePlugin` ABC with `activate()` / `deactivate()` lifecycle hooks
- `PluginRegistry` — auto-discovers and loads all built-in interceptors
- `detect_available_providers()` — inspects installed packages at startup; only registers interceptors whose dependencies are present — no `providers=` argument needed
- `active_providers` property on `MockMeshEngine` reflects what was auto-detected

#### Standardized `_config` sections in all default JSON files
- Every built-in default JSON file (`aws.json`, `azure.json`, `gcp.json`, `sql.json`, `http.json`, `streaming.json`, `nosql.json`) now includes a `_config` section alongside `_meta`
- **`{_config.xxx}` placeholder syntax** — provider-specific values (account IDs, regions, project IDs) are defined once in `_config` and referenced via placeholders throughout response bodies
- `_resolve_config_placeholders()` — recursive resolver in `interceptors/loader.py` that walks dicts/lists/strings and replaces `{_config.xxx}` with top-level string values from `_config` at load time
- `_config` is preserved during JSON loading (not stripped like `_meta` and other `_`-prefixed keys)
- AWS `_config`: `account_id`, `region`, `mock_uuid`, `rds` (moved from top-level `rds_config`)
- Azure `_config`: `region`, `subscription_id`, `resource_group`, `vault_host`, `auth` (moved from top-level)
- GCP `_config`: `project_id`, `project_id_auth`, `project_number`, `auth` (moved from top-level)
- SQL `_config`: `connection` (moved from top-level)
- NoSQL `_config`: `default_database`
- Placeholder resolution does not affect RDS runtime templates (`{region}`, `{account}`, `{identifier}`) — these use a different pattern that does not match `{_config.xxx}`

#### Graceful failure handling and fallback system
- `FallbackConfig` dataclass (`core/fallback.py`) with three modes:
  - `"mock"` (default) — return a generic mock response on interceptor error
  - `"passthrough"` — call the real (unpatched) service on error
  - `"error"` — raise `InterceptError` with full context
- Per-provider fallback overrides via `fallback_config.provider_overrides`
- `on_intercept_error` callback: `(provider, operation, exception) -> optional_response`
- `safe_intercept()` wrapper — every interceptor's hot path now runs through this centralized error handler

#### Custom handler registration
- `mockmesh.register_handler(provider, operation, handler_fn)` — register a custom handler for any provider + operation pair
- `mockmesh.register_fallback(provider, fallback_fn)` — register a per-provider fallback function
- Both available as convenience functions on the module and as methods on `MockMeshEngine`

#### Error type hierarchy (`core/errors.py`)
- `MockMeshError` — base exception for all MockMesh errors
- `InterceptError(provider, operation, cause)` — raised when an interceptor fails
- `UnknownOperationError(provider, operation)` — raised for unrecognized operations

#### HTTP interceptor (`interceptors/http.py`)
- Patches `requests.adapters.HTTPAdapter.send` and `urllib.request.OpenerDirector.open` at transport level
- URL matching: exact, glob (`*`), `url_contains` substring; method filtering per rule
- Custom status codes and response headers per rule; rules evaluated top-to-bottom

#### AWS interceptor (`interceptors/aws/`)
- Transport-level patch of `botocore.endpoint.Endpoint.make_request` — no credentials needed
- 18 services, 290+ operations covered via built-in `aws.json` defaults
- Full storage-backed implementations for S3, DynamoDB, SQS, SSM, SecretsManager, ElastiCache
- **RDS / Aurora** (`interceptors/aws/rds.py`) — 47 operations across all major engines:
  - Engines: MySQL, PostgreSQL, MariaDB, Oracle EE/SE2, SQL Server (all editions), Aurora MySQL, Aurora PostgreSQL, Aurora Serverless v2
  - Resources: DB instances, Aurora clusters, snapshots, parameter groups, cluster parameter groups, subnet groups, option groups, RDS Proxy, event subscriptions

#### Azure interceptor (`interceptors/azure/`)
- `cloud_provider_for_url()` gate in `_mock_send` skips non-Azure URLs
- `MockAzureCredential` in `interceptors/azure/utils.py` — satisfies azure-mgmt-* auth pipeline without real credentials
- Full storage-backed: Blob, Cosmos DB, Service Bus, Key Vault
- ARM config-mock: SQL, Redis, AKS, ACI, ContainerApps
- Azure Event Hubs interceptor — mock `EventHubProducerClient` and `EventHubConsumerClient`
- Azure Storage Queue interceptor — mock `QueueClient` with send/receive/delete/peek/clear
- Azure Table Storage interceptor — mock `TableClient` and `TableServiceClient`
- Azure App Configuration interceptor — mock `AzureAppConfigurationClient`

#### GCP interceptor (`interceptors/gcp/`)
- URL dispatch architecture via `HttpInterceptor.register_url_dispatcher()` — avoids fragile ordering dependencies
- `cloud_provider_for_url()` replaces local `_GCP_URL_MARKERS`
- GCS, Pub/Sub, Secret Manager, Firestore — all storage-backed
- BigQuery, Spanner, GKE, Cloud Run — config-mock defaults

#### Direct SQL interceptor (`interceptors/sql.py`)
- Patches `connect()` on **psycopg2**, **psycopg3**, **pymysql**, **mysql-connector-python**, **aiomysql**, and **asyncpg**
- `MockConnection` / `MockCursor` implementing full DB-API 2.0 interface
- SQL parsing: `CREATE TABLE`, `DROP TABLE [IF EXISTS]`, `INSERT`, `UPDATE`, `DELETE`, `SELECT` with `WHERE`, `ORDER BY`, `LIMIT`, `COUNT(*)`
- Placeholder support: `%s`, `?`, `$N`

#### MongoDB interceptor (`interceptors/mongodb.py`)
- Patches `pymongo.MongoClient` with in-memory mock
- Full CRUD: `insert_one`, `insert_many`, `find`, `find_one`, `update_one`, `delete_one`, `delete_many`
- Query operators: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`, `$regex`, `$and`, `$or`
- Cursors with `sort`, `limit`, `skip`; aggregation with `$match` and `$project`

#### Redis interceptor (`interceptors/redis_cache.py`)
- Patches `redis.Redis` and `redis.StrictRedis` with in-memory mock
- Strings, hashes, lists, sets, key operations, pipelines, multiple databases

#### Kafka interceptor (`interceptors/kafka.py`)
- Replaces `confluent_kafka.Producer/Consumer` and `kafka.KafkaProducer/KafkaConsumer`
- Topic-based rule matching

#### RabbitMQ interceptor (`interceptors/rabbitmq.py`)
- Replaces `pika.BlockingConnection` with mock
- Queue/exchange-based rule matching

#### Local persistence layer (`storage/`)
- **Blob** (`storage/blob.py`): filesystem-backed S3 + Azure Blob + GCS with per-object metadata sidecars
- **NoSQL** (`storage/nosql.py`): JSON-file-backed key-value store
- **Cache** (`storage/cache.py`): ElastiCache cluster and replication group store
- **SQL** (`storage/sql.py`): SQLite-backed relational store
- **Storage segregation by provider**: Runtime storage directories organized by provider/category (`blob/aws/`, `nosql/azure/`, `nosql/mongodb/`, `cache/aws/`, `sql/standalone/`, etc.)
- `StorageManager` helpers for MongoDB (`mongo_insert`, `mongo_find`, etc.) and Redis (`redis_set`, `redis_get`, etc.)

#### Structured logging (`core/logger.py`)
- JSON rotating log file at `<workspace>/logs/mockmesh.log`
- Optional console output (`console_log=True`), human-readable (`json_console=False`)

#### Configuration system (`config/`)
- `ConfigLoader`: loads unified JSON configuration covering HTTP, AWS, Kafka, RabbitMQ rules
- `ConfigResolver` + `ResolutionTier` enum: single-pass tiered rule matching
- 4-tier resolution: user overrides → folder overrides → storage → built-in defaults

#### Shared SQL helpers (`interceptors/common_sql.py`)
- `ENGINE_PORTS`, `DEFAULT_ENGINE_VERSIONS` — single source of truth for both RDS and direct SQL
- `MockSQLExecutor` — routes SQL to per-verb handlers backed by the NoSQL store
- ARN and endpoint builder helpers shared with `aws/rds.py`

### Package
- `requests`, `boto3`, `botocore`, all `azure-*`, `confluent-kafka`, `kafka-python`, `pika`, `psycopg2-binary`, `pymysql`, `mysql-connector-python`, `pymongo`, `redis` in `dependencies`
- Optional extras: `http`, `aws`, `azure`, `gcp`, `kafka`, `rabbitmq`, `sql`, `mongodb`, `redis`, `dev`

---