zeus1205/codeguardian-ai
0
๐ง OptiMaintainer
Production-grade OpenEnv environment for grading AI agents on open-source repository maintenance.
Built for the META HACKATHON โ grades agents across three tracks: Issue Triage, Security Audit, and Dependency Management.
Quick Start
# Install dependencies
pip install -r requirements.txt
# Start the server
uvicorn server.app:app --host 0.0.0.0 --port 8000
# Verify
curl http://localhost:8000/health
# โ {"status": "ok"}Docker
docker build -t optimaintainer .
docker run -p 8000:8000 optimaintainerAPI Endpoints
Action Space
Agents interact with the environment by sending POST /step with the following action types:
1. Triage (action_type: "triage")
Classify and route repository issues.
{
"action_type": "triage",
"scenario_id": "triage-001",
"payload": {
"category": "bug",
"severity": "high",
"assignee": "oncall:distributed",
"decision": "stop"
}
}2. Security Audit (action_type: "security")
Detect vulnerabilities in code snippets.
{
"action_type": "security",
"scenario_id": "security-001",
"payload": {
"findings": [
{
"cwe_id": "CWE-89",
"line_number": 2,
"fix_description": "Use parameterized queries with bound parameters"
}
]
}
}3. Dependency Update (action_type: "dependency")
Propose package version updates with migration analysis.
{
"action_type": "dependency",
"scenario_id": "dependency-001",
"payload": {
"updates": [
{
"package": "numpy",
"from_version": "1.24.4",
"to_version": "2.0.0",
"is_breaking": true,
"migration_notes": "The deprecated API functions have been removed. int64 is now the default dtype. numpy.distutils has been removed in favor of meson."
}
]
}
}Observation Space
Every /step call returns a structured Observation:
{
"scenario_id": "triage-001",
"action_type": "triage",
"total_score": 0.875,
"sub_scores": [
{"name": "category", "score": 1.0, "feedback": "Correct category: 'bug'"},
{"name": "severity", "score": 0.5, "feedback": "Severity one level off (expected medium, got high)"},
{"name": "routing", "score": 1.0, "feedback": "Exact assignee match: oncall:distributed"},
{"name": "decision", "score": 1.0, "feedback": "Correct decision: stop"}
],
"feedback": "[category] Correct | [severity] One level off | [routing] Exact | [decision] Correct",
"done": false
}Scoring Formulas
Triage (avg of Cat, Sev, Routing)
- Category: 1.0 exact, 0.0 wrong
- Severity: 1.0 exact, 0.5 adjacent, 0.0 otherwise (ordinal: low=0, medium=1, high=2, critical=3)
- Routing: 1.0 exact assignee, 0.5 correct domain, 0.0 wrong
- Decision: 1.0 correct, 0.0 wrong (logged as sub-score but not in total average)
Security (0.6 Base + 0.4 Quality)
- Match: CWE must match exactly and line within ยฑ2 range.
- Scoring: 0.6 base for match + 0.4 bonus for keyword overlap in fix description.
- Penalty: 0.7x multiplier applied if a CRITICAL or BLOCKER vulnerability is missed.
- False Positives: -0.05 deduction per reported finding that is not in ground truth (max -0.2).
Dependency Updater
- Version: 0.2 weight (exact version match)
- Breaking Recall: 0.4 weight (flagging breaking changes)
- Migration Quality: 0.4 weight (keyword overlap against reference)
- Zero-LLM Loop: Grading uses purely programmatic string/keyword logic.
Scenario Bank
15 scenarios (5 per track) stored in scenario_bank.json, covering real-world PyTorch/HuggingFace maintenance tasks:
Project Structure
Meta/
โโโ models.py # Pydantic schemas (Action, Observation)
โโโ scenario_bank.json # 15 test scenarios with reference answers
โโโ requirements.txt # Pinned dependencies (== only)
โโโ Dockerfile # python:3.11-slim, curl HEALTHCHECK
โโโ .dockerignore
โโโ server/
โ โโโ __init__.py
โ โโโ app.py # FastAPI: /reset, /step, /health
โ โโโ triage_grader.py # Issue classification grader
โ โโโ security_grader.py # Vulnerability detection grader
โ โโโ dependency_grader.py # Package update grader
โโโ test_audit.py # Comprehensive rubric compliance tests
โโโ validate.py # Quick validation script
โโโ README.mdRunning the Audit
# Start server
uvicorn server.app:app --host 0.0.0.0 --port 8000
# In another terminal
python test_audit.py
# โ ๐ 100% COMPLIANCE โ READY FOR SUBMISSION