Pranoy Mukherjee commited on
Commit
8325dd1
·
1 Parent(s): 3bc3287

HF Space prep

Browse files
HF_SPACES_DEPLOY.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Spaces Deployment Checklist
2
+
3
+ ## Local Preflight
4
+
5
+ Run these from the repo root:
6
+
7
+ ```bash
8
+ pip install -r requirements.txt
9
+ pytest
10
+ python app.py
11
+ ```
12
+
13
+ Open:
14
+
15
+ ```text
16
+ http://127.0.0.1:7860
17
+ ```
18
+
19
+ Test a small repo first:
20
+
21
+ ```text
22
+ https://github.com/pallets/itsdangerous
23
+ ```
24
+
25
+ ## Create The Space
26
+
27
+ 1. Go to Hugging Face Spaces.
28
+ 2. Create a new Space.
29
+ 3. Choose SDK: `Gradio`.
30
+ 4. Choose hardware: CPU basic for the mock MVP.
31
+ 5. Use the AMD hackathon organization if the event requires it.
32
+
33
+ ## Required Files
34
+
35
+ These must be at the repo root:
36
+
37
+ ```text
38
+ app.py
39
+ requirements.txt
40
+ README.md
41
+ ```
42
+
43
+ The README includes the Space metadata:
44
+
45
+ ```yaml
46
+ sdk: gradio
47
+ sdk_version: 6.14.0
48
+ app_file: app.py
49
+ ```
50
+
51
+ ## Environment Variables
52
+
53
+ For the public mock demo:
54
+
55
+ ```text
56
+ LLM_PROVIDER=mock
57
+ ```
58
+
59
+ For a later AMD/vLLM deployment:
60
+
61
+ ```text
62
+ LLM_PROVIDER=vllm
63
+ LLM_BASE_URL=http://YOUR_VLLM_ENDPOINT/v1
64
+ LLM_API_KEY=not-needed-if-your-endpoint-does-not-require-one
65
+ LLM_MODEL=Qwen/Qwen2.5-Coder-32B-Instruct
66
+ ```
67
+
68
+ ## First Hosted Smoke Test
69
+
70
+ In the deployed Space, test:
71
+
72
+ ```text
73
+ https://github.com/pallets/itsdangerous
74
+ ```
75
+
76
+ Then test:
77
+
78
+ ```text
79
+ https://github.com/psf/requests
80
+ ```
81
+
82
+ Expected behavior:
83
+
84
+ - Crawler maps files.
85
+ - Chunker creates chunks.
86
+ - Security, Performance, Quality, and Docs agents run.
87
+ - Synthesizer returns a report.
88
+ - Report shows a prioritized subset while preserving total finding counts.
89
+
90
+ ## If The Space Fails
91
+
92
+ Check the Space logs first. Common issues:
93
+
94
+ - Dependency install failure: verify `requirements.txt`.
95
+ - App import failure: verify root `app.py`.
96
+ - GitHub clone failure: verify Space has outbound internet access.
97
+ - Large repo timeout: test `pallets/itsdangerous` before larger repos.
README.md CHANGED
@@ -1,6 +1,19 @@
 
 
 
 
 
 
 
 
 
1
  # SwarmAudit
2
 
3
- AI-powered multi-agent code auditing for GitHub repositories. Paste a public GitHub URL and get a structured audit report with severity, file references, and suggested fixes.
 
 
 
 
4
 
5
  ## MVP
6
 
@@ -10,6 +23,45 @@ SwarmAudit currently runs with a mock-first LLM interface so the demo is not blo
10
  GitHub URL -> Crawler -> Chunker -> [Security Agent + Performance Agent + Quality Agent + Docs Agent] -> Synthesizer -> Report
11
  ```
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ## Quick Start
14
 
15
  ```bash
@@ -36,6 +88,14 @@ Health check:
36
  curl http://127.0.0.1:8000/health
37
  ```
38
 
 
 
 
 
 
 
 
 
39
  Run the Gradio demo:
40
 
41
  ```bash
@@ -61,6 +121,15 @@ LLM_PROVIDER=mock
61
 
62
  Later, set `LLM_PROVIDER=vllm` and point `LLM_BASE_URL` at an OpenAI-compatible vLLM endpoint running Qwen2.5-Coder.
63
 
 
 
 
 
 
 
 
 
 
64
  ## Report Schema
65
 
66
  Each finding includes:
@@ -87,6 +156,25 @@ Reports preserve full finding totals while displaying a prioritized subset for r
87
 
88
  SwarmAudit is ready to launch as a Gradio Space with the root `app.py` entrypoint. Keep `LLM_PROVIDER=mock` for a reliable public demo, then switch to `LLM_PROVIDER=vllm` when an AMD MI300X-hosted Qwen2.5-Coder endpoint is available.
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ## Tests
91
 
92
  ```bash
 
1
+ ---
2
+ title: SwarmAudit
3
+ sdk: gradio
4
+ sdk_version: 6.14.0
5
+ app_file: app.py
6
+ pinned: false
7
+ license: mit
8
+ ---
9
+
10
  # SwarmAudit
11
 
12
+ Paste any public GitHub URL. Get a structured multi-agent code audit in minutes.
13
+
14
+ SwarmAudit is an AI-agent code review system for the AMD Developer Hackathon. It clones a public repository, filters and chunks source files, runs specialized review agents, and returns a severity-ranked report with file references and suggested fixes.
15
+
16
+ The local MVP runs in mock-first mode, so the demo works without waiting for ROCm, vLLM, or MI300X infrastructure. The inference layer is designed to switch to a vLLM-compatible Qwen2.5-Coder endpoint later.
17
 
18
  ## MVP
19
 
 
23
  GitHub URL -> Crawler -> Chunker -> [Security Agent + Performance Agent + Quality Agent + Docs Agent] -> Synthesizer -> Report
24
  ```
25
 
26
+ ## Demo Status
27
+
28
+ Working locally:
29
+
30
+ - Gradio UI with live agent progress
31
+ - FastAPI `/health` and `/audit` endpoints
32
+ - GitHub clone and repo scan on public repos
33
+ - Four analysis agents plus synthesizer
34
+ - Prioritized report display with full raw finding totals preserved
35
+ - Hugging Face Spaces-style `app.py` entrypoint
36
+
37
+ Smoke-tested repos:
38
+
39
+ - `https://github.com/psf/requests`
40
+ - `https://github.com/pallets/itsdangerous`
41
+
42
+ Example output is available in [`examples/requests_report_excerpt.md`](examples/requests_report_excerpt.md).
43
+
44
+ ## Architecture
45
+
46
+ ```mermaid
47
+ flowchart LR
48
+ U[User enters GitHub URL] --> API[FastAPI / Gradio]
49
+ API --> C[Crawler Agent]
50
+ C --> F[File Filter]
51
+ F --> K[Chunker]
52
+ K --> S[Security Agent]
53
+ K --> P[Performance Agent]
54
+ K --> Q[Quality Agent]
55
+ K --> D[Docs Agent]
56
+ S --> Y[Synthesizer Agent]
57
+ P --> Y
58
+ Q --> Y
59
+ D --> Y
60
+ Y --> R[Structured Audit Report]
61
+ ```
62
+
63
+ The graph is intentionally modular: each agent returns strict Pydantic findings, and the synthesizer merges, deduplicates, prioritizes, and formats the final report.
64
+
65
  ## Quick Start
66
 
67
  ```bash
 
88
  curl http://127.0.0.1:8000/health
89
  ```
90
 
91
+ Audit endpoint:
92
+
93
+ ```bash
94
+ curl -X POST http://127.0.0.1:8000/audit \
95
+ -H "Content-Type: application/json" \
96
+ -d '{"repo_url":"https://github.com/psf/requests"}'
97
+ ```
98
+
99
  Run the Gradio demo:
100
 
101
  ```bash
 
121
 
122
  Later, set `LLM_PROVIDER=vllm` and point `LLM_BASE_URL` at an OpenAI-compatible vLLM endpoint running Qwen2.5-Coder.
123
 
124
+ Key safety limits:
125
+
126
+ ```text
127
+ MAX_FILES=200
128
+ MAX_FILE_SIZE_KB=250
129
+ MAX_CHARS_PER_CHUNK=12000
130
+ CLONE_BASE_DIR=.swarm_audit_tmp
131
+ ```
132
+
133
  ## Report Schema
134
 
135
  Each finding includes:
 
156
 
157
  SwarmAudit is ready to launch as a Gradio Space with the root `app.py` entrypoint. Keep `LLM_PROVIDER=mock` for a reliable public demo, then switch to `LLM_PROVIDER=vllm` when an AMD MI300X-hosted Qwen2.5-Coder endpoint is available.
158
 
159
+ See [`HF_SPACES_DEPLOY.md`](HF_SPACES_DEPLOY.md) for the deployment checklist.
160
+
161
+ Recommended Space settings:
162
+
163
+ - SDK: Gradio
164
+ - App file: `app.py`
165
+ - Python: 3.11 or newer
166
+ - Default env: `LLM_PROVIDER=mock`
167
+
168
+ ## AMD MI300X Roadmap
169
+
170
+ The current code path is intentionally mock-first. The next inference phase is:
171
+
172
+ 1. Start a Qwen2.5-Coder vLLM server on AMD Developer Cloud.
173
+ 2. Expose an OpenAI-compatible `/v1/chat/completions` endpoint.
174
+ 3. Set `LLM_PROVIDER=vllm`, `LLM_BASE_URL`, and `LLM_MODEL`.
175
+ 4. Add LLM enrichment to agent findings while keeping static rules as deterministic guardrails.
176
+ 5. Add a benchmark tab with MI300X latency and throughput numbers.
177
+
178
  ## Tests
179
 
180
  ```bash
examples/requests_report_excerpt.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SwarmAudit Example Report Excerpt
2
+
3
+ Repository: `https://github.com/psf/requests`
4
+
5
+ This excerpt comes from a local smoke test using the mock-first MVP pipeline.
6
+
7
+ ## Summary
8
+
9
+ - Files scanned: `41`
10
+ - Files skipped: `122`
11
+ - Total findings: `217`
12
+ - Findings displayed: `34`
13
+ - Hidden lower-priority findings: `183`
14
+
15
+ ## Severity Summary
16
+
17
+ - CRITICAL: `0`
18
+ - HIGH: `4`
19
+ - MEDIUM: `121`
20
+ - LOW: `92`
21
+
22
+ ## Agent Summary
23
+
24
+ - Security Agent: `4`
25
+ - Performance Agent: `115`
26
+ - Quality Agent: `48`
27
+ - Docs Agent: `50`
28
+
29
+ ## Example Finding
30
+
31
+ ### [HIGH] TLS certificate verification disabled
32
+
33
+ - File: `tests/test_requests.py:2908-2908`
34
+ - Agent: `Security Agent`
35
+
36
+ Disabling TLS verification can allow man-in-the-middle attacks.
37
+
38
+ **Why it matters:** Attackers often search repos for exposed credentials and unsafe execution paths.
39
+
40
+ **Suggested fix:**
41
+
42
+ ```text
43
+ Remove verify=False and use a trusted CA bundle if needed.
44
+ ```
45
+
46
+ ## Display Policy
47
+
48
+ SwarmAudit preserves full finding totals but displays a prioritized subset for readability. High-severity findings are shown first, repeated low-severity findings are summarized, and report warnings explain when lower-priority findings are hidden from the demo view.
requirements.txt CHANGED
@@ -1,11 +1,11 @@
1
- fastapi
2
- uvicorn[standard]
3
- gradio
4
- gitpython
5
- pydantic
6
- pydantic-settings
7
- langgraph
8
- langchain-core
9
- httpx
10
- python-dotenv
11
- pytest
 
1
+ fastapi==0.128.0
2
+ uvicorn[standard]==0.40.0
3
+ gradio==6.14.0
4
+ gitpython==3.1.49
5
+ pydantic==2.12.5
6
+ pydantic-settings==2.14.0
7
+ langgraph==1.1.10
8
+ langchain-core==1.3.2
9
+ httpx==0.28.1
10
+ python-dotenv==1.2.1
11
+ pytest==9.0.3