# Public API — `mgf-django`

> **Master-HEAD banner:** tracks the public surface of the CURRENT main/release.
> Verify your pinned version via `mgf.django.__version__` (mirrors
> `pyproject.toml::project.version`). Machine-readable companion:
> [`PUBLIC_API.json`](PUBLIC_API.json), generated from `__all__` + pinned in CI.

The public surface is exactly `mgf.django.__all__`. Modules under a leading
underscore (`_apps`, `_middleware`, `_logging`, `_settings`, `_throttle`, `_errors`)
are private.

- **Stability tiers:** every public name is `experimental` (the 0.x window).

## `mgf.django`

| Name | Tier | Description |
|---|---|---|
| `MgfCommonConfig` | experimental | Django `AppConfig` that runs `mgf.common.bootstrap()` once at app-registry build. |
| `MgfRequestIdMiddleware` | experimental | Sync middleware that sets/propagates a sanitised request-id contextvar. |
| `MgfContextMiddleware` | experimental | Sync middleware binding the mgf-common request context; audit-logs+re-raises on error. |
| `ThrottleMiddleware` | experimental | Token-bucket rate-limit middleware (429 on exceed). |
| `TokenBucket` | experimental | The in-process token bucket; `try_consume(key) -> (allowed, retry_after)`. |
| `JsonFormatter` | experimental | No-arg structured-log formatter for Django's `LOGGING` config. |
| `DjangoSettingsBridge` | experimental | Read-only `BaseAppSettings` view over `django.conf.settings`. |
| `SENSITIVE_PATHS_DEFAULT` | experimental | Default redaction path set for the JsonFormatter. |

## Exceptions (AP-07)

`mgf.django._errors` defines `ThrottleConfigError` and `DjangoSettingTypeError`,
both subclassing `mgf.common.exceptions.ConfigError` (→ `AppError`) and carrying
machine-readable fields (`.field`/`.value`, `.received_type`).
