# API

## Current Endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/` | Service status |
| GET | `/healthz` | Liveness probe |
| GET | `/readyz` | Readiness probe (Redis + MongoDB) |
| GET | `/version` | Service version |
| GET | `/analysis-jobs/{job_id}` | Analysis job status (debug, in-memory) |
| GET | `/analysis/{analysis_id}` | Commit analysis result (Mongo-backed, in-memory fallback) |

## Future Endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/commits/{commit_sha}/analysis` | Commit analysis by SHA |
| GET | `/commits/{commit_sha}/impacted-symbols` | Impacted symbols by SHA |
| POST | `/admin/commits/{commit_sha}/analyze` | Trigger analysis |

## Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `HOST` | `0.0.0.0` | Bind host |
| `PORT` | `6003` | Bind port |
| `LOG_LEVEL` | `info` | Log level |
| `ENVIRONMENT` | `local` | Runtime environment |
| `REDIS_URL` | `redis://localhost:6379` | Redis Streams |
| `REDIS_STREAM_PREFIX` | (empty) | Optional stream prefix |
| `CONSUMER_GROUP` | `commit-intelligence-service` | Redis consumer group |
| `REDIS_STREAM_GROUP` | (same as `CONSUMER_GROUP`) | Stream consumer group override |
| `REDIS_STREAM_MAX_RETRIES` | `5` | DLQ threshold |
| `REDIS_STREAM_AUTOCLAIM_MS` | `60000` | `XAUTOCLAIM` min idle |
| `REDIS_STREAM_AUTOCLAIM_COUNT` | `10` | `XAUTOCLAIM` batch size |
| `REDIS_STREAM_BLOCK_MS` | `2000` | `XREADGROUP` block |
| `REDIS_STREAM_COUNT` | `10` | `XREADGROUP` count |
| `MONGO_URI` | `mongodb://localhost:27018/adpilot_commit_intel` | Primary MongoDB |
| `MONGODB_DATABASE` | `adpilot_commit_intel` | `commit_analyses` database |
| `DELTAS_MONGODB_DATABASE` | `adpilot_code_parser` | Cross-DB read of `graph_deltas` |
| `INDEXING_RUNS_DATABASE` | `adpilot_repo_sync` | Optional indexing run stage updates |
| `INDEXING_RUNS_ENABLED` | `true` | Gate cross-DB indexing run writes |
| `ARTIFACT_STORE_PATH` | `./data/artifacts` | Deprecated — filesystem reader tests only |
| `ANALYSIS_WORKERS` | `runtime.NumCPU()` | Bounded delta analysis concurrency |
| `SERVICE_VERSION` | `v0.1.0` | Emitted on `/version` |

Non-local environments require `REDIS_URL`, `MONGO_URI`, and `MONGODB_DATABASE`.

See `env.example` for a copy-paste template.
