# Project audit command

Run from the repository root with the virtual environment activated:

```powershell
python manage.py help audit_project
python manage.py audit_project
python manage.py audit_project --quick
python manage.py audit_project --full
```

Default is quick. The two flags are mutually exclusive. Exit 0 means the checks
passed; required-check or test failures return nonzero. Independent checks continue
after failures. No shell-specific orchestration or `shell=True` is used.

Both modes run Django system checks, dry-run `makemigrations --check`, unapplied/
conflicting migration inspection, `git diff --check`, and Git-tracked `.env` detection.
The command does not apply migrations to the normal database or alter Git.

Quick runs these existing smoke tests (19 tests at implementation time):

- `tests.test_foundation`
- `apps.access.test_security_audit.AuthenticationSecurityTests`
- `apps.access.test_security_audit.FinalAuthorizationAuditTests`

Full uses the standard Django test command with no labels and `interactive=False`,
equivalent to `python manage.py test --noinput`. It includes the smoke tests once,
has no short timeout, and does not require a fixed test count.

Tests use Django's database creation/migration/teardown with a unique temporary
PostgreSQL test name to avoid colliding with other test processes. The command
supports the project's existing single-database configuration and rejects mirrors
or disabled test migrations. Configuration is restored afterward. Interrupted runs
may leave their isolated test database for operator review; no automatic cleanup of
other databases is performed. Operational business data is never modified.

Implementation is one command in the existing reporting app, plus eight mocked
tooling tests. No business logic, existing tests, or historical migrations change.
There is no phase registry, report generation, or additional audit framework.

Passing `audit_project` does not replace architectural or business-semantic review
for newly introduced requirements.

Verification on 2026-09-30: help passed; eight tooling tests passed; quick mode
passed all checks and all 19 smoke tests (44.898s test execution, 139.520s overall
including fresh database setup and teardown). Full mode was not run for this
simplified implementation, as requested. The earlier broader implementation's
unfinished full run was stopped and its isolated test database removed.
