|
1 | 1 | # CommitGuard AI: Comprehensive Documentation 📚 |
2 | 2 |
|
3 | | -Welcome to the internal mechanics of CommitGuard AI. This document provides a deep dive into how to use the platform, how the agentic reasoning works, and how to scale the system. |
| 3 | +Welcome to the internal mechanics of CommitGuard AI. This document provides a deep dive into the **Unified Enforcer** architecture—the bridge between chat-based behavioral analysis and GitOps technical accountability. |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
7 | | -## 🏗️ Architecture Overview |
| 7 | +## 🏗️ Architecture Overview: The Unified Enforcer |
8 | 8 |
|
9 | | -CommitGuard AI is built on a **Decoupled Event-Driven Architecture**: |
10 | | -1. **FastAPI Entrypoint**: Receives natural language or structured data. |
11 | | -2. **Redis Broker**: Handshakes the data to background workers via ARQ. |
12 | | -3. **The Brain (Agents)**: A suite of specialized LLM agents that analyze sentiment, risk, and burnout. |
13 | | -4. **Persistence Layer**: PostgreSQL (via SQLModel) stores historical reliability and Slack identity mapping. |
14 | | -5. **Intervention Layer**: Outbound Slack Webhooks perform directed @mentions. |
| 9 | +CommitGuard AI is built on a **High-Fidelity Event-Driven Architecture**: |
| 10 | +1. **FastAPI Entrypoint**: Multi-source ingestion (Slack threads + Git Webhooks). |
| 11 | +2. **Redis Broker**: Handshakes the data to background workers via **ARQ**. |
| 12 | +3. **The Intelligence (Brain)**: |
| 13 | + - `ExcuseDetector`: Analyzing the "Human Layer" (Sentiment). |
| 14 | + - `SlippageAnalyst`: Analyzing the "Code Layer" (Promise-vs-Reality). |
| 15 | + - `TruthGapDetector`: Correlating the two for 360-degree accountability. |
| 16 | +4. **Persistence Layer**: PostgreSQL (via SQLModel) stores unified identities and historical scores. |
| 17 | +5. **Intervention Layer**: Outbound Slack Webhooks with precision @mentions. |
15 | 18 |
|
16 | 19 | --- |
17 | 20 |
|
18 | 21 | ## 🚦 Core Workflows |
19 | 22 |
|
20 | | -### 1. The "Commitment Ingestion" Flow |
21 | | -When a user makes a vague promise in a public channel: |
22 | | -- **Action**: Call `POST /ingest/raw`. |
23 | | -- **Mechanics**: The `CommitmentExtractor` agent parses the text. It identifies the **Who** (Owner), **What** (Task), and **When** (Deadline). |
24 | | -- **Result**: A structured record is ready for tracking. |
25 | | - |
26 | | -### 2. The "Accountability Loop" |
27 | | -This is the heartbeat of the platform. |
28 | | -- **Action**: Call `POST /evaluate`. |
29 | | -- **Step 1: Excuse Analysis**: The agent determines if a delay is "Legitimate," "Deflection," or a "Burnout Signal." |
30 | | -- **Step 2: Risk Scoring**: A score (0-1) is generated based on the check-in sentiment and historical reliability. |
31 | | -- **Step 3: Burnout Detection**: The agent looks for linguistic markers of fatigue or loss of copability. |
32 | | -- **Step 4: Adaptation**: The `ToneAdapter` selects a communication style: |
33 | | - - `Supportive`: For high-performers showing burnout signs. |
34 | | - - `Firm`: For repeat deflectors. |
35 | | -- **Step 5: Intervention**: A background job is scheduled. If the risk remains high, a **Slack Alert** is sent. |
| 23 | +### 1. Ingestion: Behavioral vs. GitOps |
| 24 | +- **Behavioral**: Call `POST /ingest/raw`. Extracts who/what/when from chat. |
| 25 | +- **GitOps**: Call `POST /ingest/git`. Extracts commitments from commit messages and PR descriptions. |
| 26 | +- **Identity Fusion**: Use `POST /users/config/git` and `/slack` to link emails and Slack IDs to a single human owner. |
| 27 | + |
| 28 | +### 2. The "Unified Accountability Loop" |
| 29 | +1. **Evaluation**: Triggered via `POST /evaluate`. |
| 30 | +2. **Slippage Check**: The agent cross-references the check-in sentiment against recent technical evidence. |
| 31 | +3. **Truth Gap Analysis**: If a user claims 90% progress but Git shows 0 changes, the `TruthGapDetector` flags a discrepancy. |
| 32 | +4. **Tone Selection**: `ToneAdapter` scales pressure (Supportive for fatigue, Confrontational for deflection). |
| 33 | +5. **Intervention**: If risk is High/Critical, an autonomous Slack follow-up is triggered. |
36 | 34 |
|
37 | 35 | --- |
38 | 36 |
|
39 | | -## 💬 Slack Integration Guide |
| 37 | +## 💬 Integration Guide |
40 | 38 |
|
41 | | -### Setting up @Mentions |
42 | | -To make the agent mention specific people: |
43 | | -1. Find the user's **Slack Member ID** (Click profile -> More -> Copy member ID). |
44 | | -2. Call the mapping endpoint: |
45 | | - ```bash |
46 | | - POST /users/config/slack?user_id=internal_id&slack_id=U12345678 |
47 | | - ``` |
48 | | -3. From now on, any alert for `internal_id` will ping `@User` in Slack. |
| 39 | +### Setting up @Mentions & Git Mapping |
| 40 | +To unify a developer's identity: |
| 41 | +1. **Slack**: Find Member ID (e.g., `U12345`). Map with `POST /users/config/slack`. |
| 42 | +2. **Git**: Map their dev email with `POST /users/config/git`. |
| 43 | +3. **Result**: CommitGuard now knows that `dev@company.com` on GitHub is the same person as `@John` on Slack. |
49 | 44 |
|
50 | 45 | --- |
51 | 46 |
|
52 | 47 | ## 🧪 Testing and Quality |
53 | 48 | CommitGuard AI enforces a **90% coverage threshold**. |
54 | 49 | - **Unit Tests**: Test individual agent logic in `src/agents/`. |
55 | | -- **Integration Tests**: Verify the loop from API to Database. |
56 | | -- **Mock Mode**: Set `LLM_PROVIDER="mock"` in `.env` to run tests without hitting your API credits. |
| 50 | +- **Performance Tests**: Verify the correlation logic in `tests/test_performance.py`. |
| 51 | +- **Mock Mode**: Set `LLM_PROVIDER="mock"` to run full-suite tests without hitting API credits. |
57 | 52 |
|
58 | 53 | --- |
59 | 54 |
|
60 | 55 | ## 🚀 Scaling for Production |
61 | | -- **Database**: The system is pre-configured for **PostgreSQL**. Simply update your `DATABASE_URL`. |
62 | | -- **Concurrency**: Scale your background processing by spinning up multiple `worker` containers in `docker-compose.yml`. |
63 | | -- **Observability**: Monitor system health at `:8000/metrics` via the integrated Prometheus exporter. |
| 56 | +- **Database**: Pre-configured for **PostgreSQL**. Update your `DATABASE_URL` in `.env`. |
| 57 | +- **Concurrency**: Scale by increasing `worker` replicas in `docker-compose.yml`. |
| 58 | +- **Observability**: Live metrics at `:8000/metrics`. |
0 commit comments