"Git Blame for AI-Generated Code"
A comprehensive system to track, validate, and audit AI-generated code for compliance with HIPAA, GDPR, PCI-DSS, and other regulatory frameworks.
The Challenge:
- AI-generated code lacks traceability and audit trails
- No way to verify compliance with regulatory requirements
- Unknown security and quality of AI outputs
- No gates to prevent non-compliant code in production
- When auditors ask "Who generated this code?", there's no answer
Real-World Impact:
- Healthcare apps with HIPAA violations
- Financial systems with PCI-DSS gaps
- Privacy breaches from GDPR non-compliance
- Legal liability for AI-generated bugs
- Failed compliance audits
A multi-stage provenance tracking system with progressive enforcement:
Generate β Capture silently (no friction)
Commit β Warn and log (escapable)
CI/CD β Hard gate (absolute)
β
Automatic Capture - Transparent provenance tracking during code generation
β
Comprehensive Metadata - Model, prompt, compliance flags, risk assessment
β
Git-Integrated Storage - Version-controlled with your code
β
Multi-Stage Enforcement - Progressive validation from dev to production
β
Compliance-Ready - Built for HIPAA, GDPR, PCI-DSS audits
β
Developer-Friendly - Zero friction, clear value proposition
graph TB
A[Bob AI Assistant] -->|Generates Code| B[Provenance Capture]
B -->|Embeds Metadata| C[Git Attributes Store]
C -->|Developer Commits| D[Pre-commit Hook]
D -->|Validation| E{Compliant?}
E -->|Yes| F[Commit Allowed]
E -->|No| G[Warning Logged]
F --> H[CI/CD Pipeline]
G --> H
H -->|Hard Validation| I{Valid?}
I -->|Yes| J[Deploy]
I -->|No| K[Block]
L[Audit Dashboard] -->|Queries| C
- Provenance Capture Layer - Intercepts AI code generation
- Git Attributes Storage - Version-controlled metadata
- Validation Engine - Multi-stage compliance checks
- Audit Dashboard - Compliance reporting and analytics
- CLI Tools - Query and manage provenance data
Each AI-generated code block captures:
{
"provenance_id": "uuid-v4",
"model_info": {
"name": "gpt-4",
"version": "2024-05",
"provider": "openai"
},
"generation": {
"timestamp": "2026-05-02T00:00:00Z",
"prompt_hash": "sha256-hash",
"confidence_score": 0.95
},
"code_info": {
"file_path": "src/auth/login.ts",
"function_name": "authenticateUser",
"line_range": [45, 78],
"lines_count": 34,
"language": "typescript"
},
"compliance": {
"flags": ["HIPAA", "PCI-DSS"],
"human_review_required": true,
"policy_version": "v2.1.0",
"risk_level": "high"
},
"validation": {
"signature": "cryptographic-signature",
"chain_hash": "previous-hash"
}
}# Install VS Code extension
code --install-extension code-provenance
# Install CLI tool
npm install -g @code-provenance/cli
# Initialize in your project
cd your-project
provenance-cli init# Generate code with Bob (provenance captured automatically)
# No manual steps required!
# Query provenance
provenance-cli query --file src/auth.ts --line 45
# Validate repository
provenance-cli validate --strict
# Generate compliance report
provenance-cli report --format pdf --compliance HIPAA- Hover over code to see provenance info
- Status bar shows AI code percentage
- Command palette for audit operations
- Inline markers for critical code
Setup:
- Healthcare application handling patient data
- Developer uses Bob to generate authentication code
- Code must comply with HIPAA
Workflow:
// Developer asks Bob: "Create a secure authentication function"
// Bob generates code (provenance captured automatically)
export async function authenticateUser(credentials: Credentials) {
// @ai-provenance: prov-12345
const hashedPassword = await bcrypt.hash(credentials.password, 10);
const user = await db.users.findOne({ email: credentials.email });
if (!user || !(await bcrypt.compare(credentials.password, user.password))) {
throw new UnauthorizedError();
}
return generateToken(user);
// @ai-provenance-end: prov-12345
}Commit Attempt:
$ git commit -m "Add authentication"
π Checking AI code provenance...
β οΈ Warning: 1 function requires HIPAA review
- src/auth.ts:45-78 (authenticateUser)
Continue with commit? [y/N] y
π Logging provenance warning...CI/CD Pipeline:
$ git push origin main
π Validating AI code provenance...
β Deployment blocked: HIPAA review required
- src/auth.ts:45-78 (authenticateUser)
Please complete human review before deployment.After Review:
$ provenance-cli mark-reviewed --file src/auth.ts --line 45 --reviewer john@company.com
β
Code marked as reviewed
$ git push origin main
π Validating AI code provenance...
β
All checks passed
π Deploying to production...- Cryptographic signatures on all metadata
- Chain hashing links provenance entries
- Immutable audit log of all operations
- Access controls for sensitive data
| Regulation | Requirement | Our Solution |
|---|---|---|
| HIPAA | Audit trail of PHI access | Track all code touching patient data |
| GDPR | Data processing records | Metadata shows AI processing |
| PCI-DSS | Change tracking | Git integration provides history |
| SOX | Code review evidence | Human review flags |
| ISO 27001 | Security controls | Risk assessment in metadata |
- One-way hashing of prompts (SHA-256)
- Data minimization - only essential metadata
- Encryption at rest for sensitive fields
- Access logging for audit trail
- GDPR compliance - right to erasure
- β Protect yourself from AI liability
- β Quick lookup of code origins
- β Personal AI usage analytics
- β Resume-worthy compliance experience
- β Complete audit trail for AI code
- β Automated compliance reporting
- β Risk assessment and tracking
- β Faster audit completion
- β Reduce compliance risk
- β Pass regulatory audits
- β Demonstrate due diligence
- β Competitive advantage
- β Clear provenance trail
- β Tamper-proof evidence
- β Standardized reporting
- β Easy verification
# Clone repository
git clone https://github.com/your-org/code-provenance.git
cd code-provenance
# Install dependencies
npm install
# Run tests
npm test
# Build extension
npm run build
# Run in development mode
npm run devMIT License - see LICENSE for details
Star this repo if you believe AI code needs provenance tracking!
Join the discussion to help shape the future of this project!
Contribute to make this an industry standard!
Built with β€οΈ for the AI Code Compliance Hackathon
"Every line of AI code deserves a story"