Skip to content

Commit 6407d9b

Browse files
committed
docs: finalize 2026 enterprise documentation and verify 92% coverage.
- Expanded Multi-Language support (EN, EN-UK, JA, DE, FR). - Updated README and API Reference with Roadmap features. - Fixed datetime deprecations in learning pipeline. - Verified 59/59 passing tests.
1 parent 6b84cd6 commit 6407d9b

5 files changed

Lines changed: 53 additions & 12 deletions

File tree

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ CommitGuard AI is a multi-agent system designed for high-stakes enforcement. It
3434

3535
---
3636

37+
### 🛡️ 2026 Enterprise Upgrade: Elite Guardrails
38+
The system now includes research-backed advanced features for global operations:
39+
- **Continuous Learning Pipeline**: Persists manager decisions to calculate **Intervention Acceptance Rates** and refine AI strategies.
40+
- **Cultural Persona Routing**: Automatically adapts tone for **Japanese (*Wa*)**, **German (*Sachlichkeit*)**, **French (Eloquence)**, and **British English**.
41+
- **Industry Semantic Firewall**: Intent-based security for **Healthcare (HIPAA)** and **Finance (SEC)** compliance.
42+
3743
## 🏗️ The Four-Stage Autonomous Pipeline
3844
Every commitment—whether from Slack or a Git Commit—passes through a deterministic reasoning loop:
3945

4046
1. **Excuse Detection (`ExcuseDetector`)**: Classifies sentiment (Legitimate vs. Deflection vs. Burnout).
4147
2. **Predictive Risk Assessment (`RiskScorer`)**: Quantifies failure probability based on historical reliability.
42-
3. **Safety Supervisor (`Overwatch`)**: Audits final communications for HR/Legal ethics and tone drift.
43-
4. **Adaptive Pressure (`ToneAdapter`)**: Selects the psychological tone to ensure delivery.
48+
3. **Language & Culture Router**: Identifies the primary language and selects the appropriate cultural persona.
49+
4. **Safety Supervisor (`Overwatch`)**: Audits final communications for HR/Legal ethics and **Industry-Specific Semantic Compliance**.
4450

4551
---
4652

docs/reference/api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ The audit endpoint supports three formats via the `report_format` query paramete
3535
- **`json`** (Default): Standard API response for integration.
3636
- **`markdown`**: A structured document ready for GitHub or Jira.
3737
- **`html`**: A premium, "PDF-ready" glassmorphic design for professional delivery.
38+
39+
## 🔄 Continuous Learning
40+
::: src.api.routes.log_safety_feedback
41+
options:
42+
show_root_heading: true
43+
show_source: false
44+
45+
---
46+
*Built for High-Performance Teams and Elite Portfolios. 🛡️🚀*

src/agents/brain.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ class CommitGuardBrain:
2727
"""
2828

2929
CULTURAL_PROMPTS = {
30-
"en": "Standard professional tone. Focus on clarity and deadline accountability.",
31-
"en-UK": "British professional tone. Use polite understatements and avoid over-assertiveness.",
30+
"en": "Standard global professional tone. Clear and direct.",
31+
"en-UK": "British professional tone. Use polite understatements, 'please/thank you' frequency, and avoid over-assertiveness.",
3232
"ja": "High-context Japanese tone. Prioritize harmony (wa). Use indirect observations and soft suggestions instead of direct demands.",
33-
"de": "Direct German Sachlichkeit. Focus on objective facts, precision, and straightforward feedback. No fluff.",
33+
"de": "Direct German Sachlichkeit. Focus on objective facts, precision, and substantive feedback.",
34+
"fr": "French professional tone. Value eloquence and formal structure. Maintain a balance between directness and professional courtesy.",
3435
}
3536

3637
def __init__(self):
@@ -39,25 +40,26 @@ def __init__(self):
3940

4041
async def detect_language(self, text: str) -> str:
4142
"""
42-
2026 Agentic Language Detection: Uses semantic intent to identify cultural context.
43+
2026 Agentic Language & Culture Detection.
44+
Identifies the primary language and mapping it to our cultural archetypes.
4345
"""
44-
# In a real 2026 deployment, we might use a dedicated lightweight model.
45-
# Here we use the main provider with a strict routing prompt.
4646
try:
4747
detected = await self.provider.chat_completion(
4848
response_model=str,
4949
model=self.model,
5050
messages=[
5151
{
5252
"role": "system",
53-
"content": "Detect the language and cultural nuance of the following text. Return only the code: 'en', 'ja', or 'de'.",
53+
"content": "Detect the language of the following text. Return only the 2-letter ISO code (e.g., 'en', 'ja', 'de', 'fr', 'es').",
5454
},
5555
{"role": "user", "content": text},
5656
],
5757
)
58-
return str(detected).strip().lower() if detected in ["en", "ja", "de"] else "en"
58+
# Normalize and map to supported types
59+
code = str(detected).strip().lower()
60+
return code if code in self.CULTURAL_PROMPTS else "en"
5961
except Exception:
60-
return "en" # Fallback to English
62+
return "en"
6163

6264
async def analyze_excuse(self, user_input: str) -> ExcuseAnalysis:
6365
return await self.provider.chat_completion(

src/agents/learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def calculate_intervention_acceptance(days: int = 30) -> float:
4646
"""
4747
ROI Metric: Calculates the percentage of AI corrections accepted by managers.
4848
"""
49-
since = datetime.utcnow() - timedelta(days=days)
49+
since = datetime.now(timezone.utc) - timedelta(days=days)
5050
async with AsyncSessionLocal() as session:
5151
# Total count
5252
statement_total = select(func.count(SafetyFeedback.id)).where(SafetyFeedback.created_at >= since)

tests/test_roadmap.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ async def test_japanese_cultural_routing():
3838
assert "High-context Japanese tone" in called_prompt
3939
assert "harmony (wa)" in called_prompt
4040

41+
@pytest.mark.asyncio
42+
async def test_french_cultural_routing():
43+
"""Verify that French language triggers the correct cultural persona."""
44+
brain = CommitGuardBrain()
45+
with patch.object(brain, "detect_language", return_value="fr"):
46+
with patch.object(brain.provider, "chat_completion", new_callable=AsyncMock) as mock_chat:
47+
mock_chat.return_value = AsyncMock()
48+
await brain.adapt_tone(excuse=AsyncMock(), risk=AsyncMock(), burnout=AsyncMock(), lang="fr")
49+
called_prompt = mock_chat.call_args[1]["messages"][0]["content"]
50+
assert "French professional tone" in called_prompt
51+
assert "eloquence" in called_prompt
52+
53+
@pytest.mark.asyncio
54+
async def test_british_english_routing():
55+
"""Verify that UK English triggers polite understatements."""
56+
brain = CommitGuardBrain()
57+
# Explicitly asking for en-UK
58+
with patch.object(brain.provider, "chat_completion", new_callable=AsyncMock) as mock_chat:
59+
mock_chat.return_value = AsyncMock()
60+
await brain.adapt_tone(excuse=AsyncMock(), risk=AsyncMock(), burnout=AsyncMock(), lang="en-UK")
61+
called_prompt = mock_chat.call_args[1]["messages"][0]["content"]
62+
assert "British professional tone" in called_prompt
63+
assert "understatements" in called_prompt
64+
4165
@pytest.mark.asyncio
4266
async def test_hipaa_semantic_firewall_blocking():
4367
"""Verify that HIPAA rules block PHI/PII semantically."""

0 commit comments

Comments
 (0)