Skip to content

Commit aef66bc

Browse files
committed
Docs: Synchronize all documentation and environment examples for Unified Enforcer
1 parent 517baf4 commit aef66bc

4 files changed

Lines changed: 73 additions & 39 deletions

File tree

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ GROQ_API_KEY=""
1212

1313
# Infrastructure
1414
REDIS_URL="redis://localhost:6380"
15-
DB_PATH="commitguard.db"
15+
DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/commitguard"
16+
# DB_PATH="commitguard.db" # Legacy SQLite support
17+
1618

1719
# Integrations
1820
# SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."

DOCUMENTATION.md

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,58 @@
11
# CommitGuard AI: Comprehensive Documentation 📚
22

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.
44

55
---
66

7-
## 🏗️ Architecture Overview
7+
## 🏗️ Architecture Overview: The Unified Enforcer
88

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.
1518

1619
---
1720

1821
## 🚦 Core Workflows
1922

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.
3634

3735
---
3836

39-
## 💬 Slack Integration Guide
37+
## 💬 Integration Guide
4038

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.
4944

5045
---
5146

5247
## 🧪 Testing and Quality
5348
CommitGuard AI enforces a **90% coverage threshold**.
5449
- **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.
5752

5853
---
5954

6055
## 🚀 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`.

docs/guides/gitops.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# GitOps Accountability Guide 🛠️
2+
3+
In the engineering world, commitments aren't just made in Slack; they are made in **Source Code**.
4+
5+
## 🔴 The Problem
6+
Technical debt often accumulates because of "soft promises" made in code comments or commit messages:
7+
- *"TODO: Refactor this DB connector."*
8+
- *"I'll fix this auth bug in the next PR."*
9+
- *"Temporary hack, will clean up tonight."*
10+
11+
These promises "vanish" because no project management tool monitors them.
12+
13+
## 🟢 The Solution: CommitGuard GitOps
14+
CommitGuard monitors your repository at the source level.
15+
16+
### 1. Extraction from Commits
17+
If a commit message contains a promise (Who/What/When), the **CommitmentExtractor** identifying it as a formal obligation.
18+
```bash
19+
POST /ingest/git
20+
{
21+
"author_email": "dev@company.com",
22+
"message": "Fixing CSS. I promise to refactor the login logic by Friday."
23+
}
24+
```
25+
26+
### 2. Fulfillment Analysis (Slippage)
27+
The **SlippageAnalyst** looks at the subsequent PR.
28+
* **The Check**: Did the promised refactor actually happen?
29+
* **The Result**: If the code doesn't match the promise, the agent flags **"Shadow Debt"** and alerts the team.
30+
31+
### 3. Truth Gap Detection
32+
When you provide a check-in via Slack, CommitGuard cross-references it with your recent Git activity.
33+
* **User**: *"I'm almost done refactoring."*
34+
* **Git**: *0 lines changed in 48 hours.*
35+
* **Agent**: *"I noticed no code changes. Is there a blocker I can help with?"* (Tone: Supportive but firm).

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ nav:
5757
- Usage Guides:
5858
- Quick Start: guides/quickstart.md
5959
- Slack Integration: guides/slack.md
60+
- GitOps Accountability: guides/gitops.md
61+
6062
- API Reference:
6163
- Endpoint Specs: reference/api.md
6264

0 commit comments

Comments
 (0)