Skip to main content

A local-first staging VCS for AI agents - quarantine commits before merging to production Git

Project description

SAV - Shadow VCS v0.1

License: MIT Python 3.11+ Tests

A local-first "staging VCS" that lets AI agents (and humans) commit code safely—before it ever touches your production Git repository.


What is Shadow VCS?

Shadow VCS (SAV) is a next-generation version control system for the age of AI-assisted coding. It acts as a secure quarantine for code changes—especially those generated by AI agents—so you can review, test, and enforce policy before anything merges to your real Git repo.

Why?
AI can write code, but it can also make mistakes, introduce security risks, or bypass your best practices. Shadow VCS gives you a buffer zone—like a spam filter for code—between autonomous agents and your trusted codebase.


Key Features

  • Staging Isolation: All changes land in .sav/commits/*—never in your main repo until approved.
  • Audit-Grade Provenance: Every commit is fingerprinted and logged in a tamper-resistant SQLite database. Full traceability: who/what/when/why for every change, even before it hits Git.
  • Policy-Driven Quarantine: YAML rules let you auto-approve safe changes, block dangerous ones, and require human review for anything risky.
  • Security by Default: Detects secrets, large binaries, and suspicious patterns before they hit production.
  • Human-in-the-Loop: You decide what gets merged—AI agents can't sneak code past you.
  • Compliance & Forensics: Prove to auditors that risky changes were reviewed and approved by a human. Every action is logged for compliance and incident response.
  • AI Agent Safety: Designed for AI/LLM workflows: keep agent output isolated until a human approves.
  • Not Just Another Git Wrapper: SAV is a staging VCS, not a Git plugin. It's a new layer of control before Git.

How It Works

graph TD
    A[AI Agent] --> B[Shadow VCS]
    B --> C[.sav/commits/*]
    B --> D[Policy Engine]
    D --> E{Risk Assessment}
    E -->|Low Risk| F[Auto-Approve]
    E -->|High Risk| G[Human Review]
    F --> H[Production Git]
    G --> H
    B --> I[Audit Trail]

Quick Start

1. Install

Requirements:

  • Python 3.11+
  • Git (for production workflows)

From source:

git clone https://github.com/AKIFQ/sav.git
cd sav
pip install -e .

(PyPI coming soon!)

2. Initialize a Shadow VCS Repo

mkdir my-project
cd my-project
sav init

Creates .sav/ with:

  • commits/ (quarantined changes)
  • fingerprints/ (risk data)
  • index.sqlite (audit log)
  • constraints.yaml (policy rules)

3. Make Your First Commit

echo 'print("Hello Shadow VCS!")' > hello.py
sav commit -m "Add hello script" hello.py

Sample output:

Created commit a1b2c3d4 (auto-approved by policy)
  Files: 1
  Lines: +1 -0
  Risk score: 0.0

4. Review & Approve

sav status --all
sav review a1b2c3d4
sav approve a1b2c3d4

Or reject with a reason:

sav reject a1b2c3d4 -r "Security concern"

Full Usage & Commands

Command Description
sav init Initialize Shadow VCS repository
sav commit -m "msg" <files> Create new commit
sav status [--all] Show commit status
sav review <commit-id> Review commit details
sav approve <commit-id> Approve and apply commit
sav reject <commit-id> Reject commit
sav policy test Test policy rules

Configuration

Policy & Risk Assessment

Customize .sav/constraints.yaml:

rules:
  - match: "*.md"
    auto_approve: true
  - match: "*"
    condition: "risk_score < 0.3 and lines_added < 50"
    auto_approve: true
  - match: "*"
    condition: "risk_score > 0.7"
    require_role: "admin"
  - match: "*"
    auto_approve: false
  • Supported conditions: risk_score, lines_added, lines_deleted
  • Test your rules:
sav policy test \
  --rule '{"match": "*.py", "condition": "risk_score < 0.5"}' \
  --context '{"risk_score": 0.2, "lines_added": 10, "lines_deleted": 0}'

How risk is calculated:

  • Large changes = higher risk
  • Many files = higher risk
  • Sensitive patterns (e.g. *.key, config, secret) = high risk
  • Large binaries (>500KB) = high risk
  • Heavy deletions = higher risk

Environment Variables

  • SAV_REPO_PATH — Set default repository path
  • SAV_LOG_LEVEL — Set logging level (default: INFO)

Directory Structure

.sav/
├── commits/
│   └── <commit-uuid>/
│       ├── files/
│       ├── meta.json
│       └── diff.patch
├── fingerprints/
│   └── <fingerprint-uuid>.json
├── index.sqlite
└── constraints.yaml

Security & Compliance

  • Audit-Grade Logging: All actions and approvals are logged in index.sqlite for full traceability.
  • Provenance: Every commit is fingerprinted and risk-assessed.
  • Policy Enforcement: Block, quarantine, or require review for risky changes.
  • Sandboxed Evaluation: Policy expressions use restricted Python eval().
  • File Isolation: Commits stored separately until approved.
  • Forensics: Reconstruct who/what/when/why for any change—ideal for regulated industries, incident response, and supply chain security.

🤖 AI & Automation Use Cases

  • AI Agent Safety: Keep LLM/AI-generated code isolated until a human approves.
  • Contractor/External Code: Quarantine and review code from untrusted sources.
  • Compliance Automation: Prove to auditors that all risky changes were reviewed and approved.
  • Preview: v0.2+ will support direct LangChain and custom agent integration.
from sav.integrations.langchain import ShadowVCSWrapper
agent = ShadowVCSWrapper(your_langchain_agent)
result = agent.run("Refactor the authentication module")

Development & Contributing

  • Setup:
    git clone https://github.com/AKIFQ/sav.git
    cd sav
    python -m venv venv
    source venv/bin/activate  # or `venv\Scripts\activate` on Windows
    pip install -e .
    pip install pytest
    
  • Run tests:
    pytest tests/ -v
    
  • Pre-commit:
    python scripts/prepush.py
    
  • Contribute:
    1. Fork the repo
    2. Create a feature branch
    3. Commit your changes
    4. Push and open a Pull Request
  • Code style: PEP 8, add tests, update docs for new features

License

MIT License - see LICENSE

Shadow VCS – Because AI agents need training wheels too!


If you like this project, please ⭐️ the repo and share your feedback!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

savai-0.1.0.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

savai-0.1.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file savai-0.1.0.tar.gz.

File metadata

  • Download URL: savai-0.1.0.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for savai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4271b5ca4df1457d89a9dcb7d90e6f7458170040843a57811343b0a9315733da
MD5 a4abd1da9dbf95d8f4301cf7a17ae141
BLAKE2b-256 9076e7b76b7479239b496751703caea8635c75912c1b7212b4b99ef7f1feba06

See more details on using hashes here.

File details

Details for the file savai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: savai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for savai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4aa9acecd82007257d67bec3bd7bd329ec1fca5597ee418c19a6a9227dafc3f
MD5 bd360e2efd8a4ab16ad354099d31ebd5
BLAKE2b-256 44d0da474a3f048fce359b5199f477ea2a7e8f1d0e28e97a05033c0379a275c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page