Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions demo4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Release Manifest — Fraud Intelligence Sprint (Sprint 4)

## Code Repository

**Project Code Repository:** https://github.com/dcsil/PyGuard-Agentic-Agent

> **Note:** There is no deployed app URL for this release. PyGuard runs as a local Python service and is accessed exclusively through the Slack workspace. All interaction happens via Slack DM or channel @mention with the PyGuard Agent app.

## What This Release Validates

This release demonstrates the **pivot from personal assistant to autonomous fraud intelligence** for SMEs. PyGuard is no longer a general-purpose task executor — it is a specialized fraud analyst that sits on top of an existing detection model, transforms raw flagged transaction data into contextualized intelligence, and delivers a professional executive report directly in Slack.

**Primary interaction:** From a single message sent via Slack DM, PyGuard ingests a pre-scored fraud dataset (2,189 transactions, 23 fields), detects all 7 fraud pattern types, generates a structured PDF report with 5 embedded data visualizations, and uploads it to Slack — end-to-end, requiring zero analyst expertise from the user.

**Key architectural change:** A dedicated fraud intelligence subsystem (`fraud_system/`) is added as a parallel domain alongside the existing personal assistant pipeline. The MemoryAgent's intent classifier now routes `fraud_analysis` queries to a specialized `FraudOrchestratorAgent` with 5 fraud-specific subagents, while leaving all personal assistant capabilities untouched. A full PDF generation engine (matplotlib + LaTeX + tectonic) produces professional, branded reports delivered via `files_upload_v2`.

---

## Repository Index (Artifacts for This Sprint)

### 1) Feature Lock Justification

- **File:** `PyGuard/feature-lock-justification.md`
- Contains: Product Review CUJ executed against the same persona, goal, and metrics as the Sprint 3 baseline. Baseline vs. current build comparison with quantified improvement ratios (96.3% time reduction, 95.5% step reduction, 133–250% increase in patterns detected). Alpha feature completeness matrix covering all 15 implemented features. Alpha release criteria validation across feature completeness, internal stability, test repeatability, error handling, security, operations, and reliability. Go/No-Go decision with feature freeze list and beta remediation plan for 7 known gaps.

### 2) Alpha Validation Evidence

- **File:** `PyGuard/alpha-validation-evidence.md`
- Contains: Evidence package for all seven alpha release criteria. Automated test results for FraudDataService (8 queries, all assertions verified against exact dataset values), database CRUD (8 operations), PDF generation (547KB output confirmed), orchestrator helper logic, LaTeX escape safety, verification logic determinism, and Slack config parsing. Live session logs from 3 independent runs demonstrating consistent behavior (same intent confidence 0.98–0.99, same complexity classification, same pipeline routing). Error scenario coverage table (7 scenarios, all handled without crash). Reliability evidence including WAL mode, automatic WebSocket reconnection, and fail-open degradation patterns.

### 3) Pivot Contract

- **File:** `PyGuard/pivot-contract.md`
- Contains: Pre-sprint hypothesis (quantified value claim for PDF delivery over raw Slack text), kill metric (80% of n≥5 runs producing verified PDFs with 5 charts and 6 sections, no placeholders), trigger date (March 24, 2026), and two strategic fallback options defining what we would test if the hypothesis is violated (pure Python PDF library vs. Slack Block Kit with image attachments).

### 4) Build Trap Post-Mortem

- **File:** `PyGuard/build-trap-postmortem.md`
- Contains: Retrospective on whether the PDF report feature delivered hypothesized value and whether building was necessary to validate the hypothesis. Separation of capability validation (genuinely required building) from demand validation (could have been partially validated without code). Two named premature assumptions: format preference and visualization necessity. Changes committed to the next pivot contract. Reasoning behind the two deprioritized features (DataAnalystAgent, WhatsApp client).

---

## Sprint 4 System Topology (Runtime View)

```
Slack User (DM or Channel @mention)
↕ Slack Socket Mode (persistent WebSocket — no public URL required)
SlackService (slack/service.py — Python, runs as FastAPI lifespan task)
↕ calls process_chat_message()
FastAPI Backend (main.py — single Python process)
MemoryAgent (intent classifier: fraud_analysis | action_only | rule_only | user_management | both)
↓ ↓
FraudOrchestratorAgent OrchestratorAgent (personal assistant — unchanged)
├── FraudDataAnalystAgent ├── CalendarAgent (Google Calendar via Composio)
│ (8 SQL query tools ├── EmailAgent (Gmail via Composio)
│ → SQLite fraud_transactions)├── ResearchAgent (OpenAI WebSearchTool)
├── FraudPatternAgent └── ReportWriterAgent (Google Docs via Composio)
├── FraudReportAgent
│ (generate_pdf_report tool)
│ ↓
│ FraudReportGenerator
│ ├── matplotlib (5 charts → PNG)
│ ├── LaTeX template assembly
│ └── tectonic compile → PDF
├── FraudAlertAgent
└── FraudVerificationAgent
SlackService._send_reply() → chat_postMessage → Slack User (text summary)
SlackService._upload_pdf() → files_upload_v2 → Slack User (PDF attachment)
```

---

## New Modules (Sprint 4)

| Module | Purpose |
|--------|---------|
| `backend/fraud_system/fraud_data_service.py` | Loads fraud CSV into SQLite; 8 SQL query methods |
| `backend/fraud_system/fraud_orchestrator.py` | Coordinates fraud subagents; extracts PDF path from output |
| `backend/fraud_system/report_generator.py` | matplotlib chart generation + LaTeX assembly + tectonic compilation |
| `backend/fraud_system/subagents/fraud_data_analyst.py` | 8 `@function_tool` wrappers around FraudDataService |
| `backend/fraud_system/subagents/fraud_pattern_agent.py` | Pattern interpretation with domain knowledge for all 7 pattern types |
| `backend/fraud_system/subagents/fraud_report_agent.py` | PDF report generation via `generate_pdf_report` function tool |
| `backend/fraud_system/subagents/fraud_alert_agent.py` | Severity evaluation (CRITICAL/HIGH/MEDIUM/LOW) + alert formatting |
| `backend/fraud_system/subagents/fraud_verification_agent.py` | QA: data accuracy, completeness, actionability, no fabrication |

## Modified Modules (Sprint 4)

| Module | Change |
|--------|--------|
| `backend/agent_system/memory_agent.py` | Added `fraud_analysis` as 5th intent type with fraud keyword detection |
| `backend/api/chat_handler.py` | Fraud routing: `type=fraud_analysis` → `FraudOrchestratorAgent`; `pdf_path` propagation |
| `backend/api/schemas.py` | Added `pdf_path: Optional[str]` and `fraud_analysis: Optional[Dict]` to `ChatResponse` |
| `backend/slack/service.py` | Added `_upload_pdf()` via `files_upload_v2`; fixed subtype filter; added error handling |
| `backend/database/local_db.py` | Added `fraud_alerts` table; 3 new CRUD methods |
| `backend/config/agent_config.py` | Added 5 fraud agent profiles + `FRAUD` orchestrator profile |
| `backend/main.py` | Added `logging.basicConfig` for structured console output |
| `backend/agent_system/orchestrator_agent.py` | Removed broken `DataAnalystAgent` import; cleaned instructions |
| `backend/requirements.txt` | Added `matplotlib` |
Loading