agentguard-governance 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. agentguard_governance-0.7.0/.env.example +21 -0
  2. agentguard_governance-0.7.0/.github/workflows/ci.yml +39 -0
  3. agentguard_governance-0.7.0/.github/workflows/publish.yml +33 -0
  4. agentguard_governance-0.7.0/.gitignore +20 -0
  5. agentguard_governance-0.7.0/.trace_sync +1 -0
  6. agentguard_governance-0.7.0/AI_CONTEXT.md +132 -0
  7. agentguard_governance-0.7.0/CLAUDE.md +94 -0
  8. agentguard_governance-0.7.0/LICENSE +21 -0
  9. agentguard_governance-0.7.0/PKG-INFO +745 -0
  10. agentguard_governance-0.7.0/README.md +705 -0
  11. agentguard_governance-0.7.0/agentguard/__init__.py +10 -0
  12. agentguard_governance-0.7.0/agentguard/ai_review.py +171 -0
  13. agentguard_governance-0.7.0/agentguard/checks/__init__.py +1 -0
  14. agentguard_governance-0.7.0/agentguard/checks/preflight.py +271 -0
  15. agentguard_governance-0.7.0/agentguard/checks/report.py +84 -0
  16. agentguard_governance-0.7.0/agentguard/checks/runtime.py +79 -0
  17. agentguard_governance-0.7.0/agentguard/cli.py +1161 -0
  18. agentguard_governance-0.7.0/agentguard/config/__init__.py +1 -0
  19. agentguard_governance-0.7.0/agentguard/config/loader.py +86 -0
  20. agentguard_governance-0.7.0/agentguard/enforcement/__init__.py +0 -0
  21. agentguard_governance-0.7.0/agentguard/enforcement/enforcer.py +205 -0
  22. agentguard_governance-0.7.0/agentguard/guided/__init__.py +0 -0
  23. agentguard_governance-0.7.0/agentguard/guided/concretizer.py +345 -0
  24. agentguard_governance-0.7.0/agentguard/guided/pinning.py +65 -0
  25. agentguard_governance-0.7.0/agentguard/guided/validator.py +82 -0
  26. agentguard_governance-0.7.0/agentguard/output/__init__.py +1 -0
  27. agentguard_governance-0.7.0/agentguard/output/renderer.py +212 -0
  28. agentguard_governance-0.7.0/agentguard/review/__init__.py +1 -0
  29. agentguard_governance-0.7.0/agentguard/review/reviewer.py +336 -0
  30. agentguard_governance-0.7.0/agentguard/templates/claude_md_block.md +22 -0
  31. agentguard_governance-0.7.0/agentguard/templates/governance.yaml +40 -0
  32. agentguard_governance-0.7.0/agentguard/web/__init__.py +0 -0
  33. agentguard_governance-0.7.0/agentguard/web/server.py +223 -0
  34. agentguard_governance-0.7.0/governance.yaml.example +78 -0
  35. agentguard_governance-0.7.0/pyproject.toml +59 -0
  36. agentguard_governance-0.7.0/tests/__init__.py +0 -0
  37. agentguard_governance-0.7.0/tests/test_ai_review.py +240 -0
  38. agentguard_governance-0.7.0/tests/test_cli.py +123 -0
  39. agentguard_governance-0.7.0/tests/test_config.py +132 -0
  40. agentguard_governance-0.7.0/tests/test_enforcer.py +346 -0
  41. agentguard_governance-0.7.0/tests/test_guided.py +1233 -0
  42. agentguard_governance-0.7.0/tests/test_pinning.py +85 -0
  43. agentguard_governance-0.7.0/tests/test_preflight.py +387 -0
  44. agentguard_governance-0.7.0/tests/test_renderer.py +54 -0
  45. agentguard_governance-0.7.0/tests/test_reviewer.py +382 -0
  46. agentguard_governance-0.7.0/tests/test_runtime.py +36 -0
  47. agentguard_governance-0.7.0/tests/test_validator.py +117 -0
  48. agentguard_governance-0.7.0/tests/test_verify.py +118 -0
  49. agentguard_governance-0.7.0/tests/test_web_server.py +143 -0
  50. agentguard_governance-0.7.0/web/index.html +12 -0
  51. agentguard_governance-0.7.0/web/package-lock.json +1746 -0
  52. agentguard_governance-0.7.0/web/package.json +21 -0
  53. agentguard_governance-0.7.0/web/src/App.jsx +240 -0
  54. agentguard_governance-0.7.0/web/src/components/CheckPanel.jsx +179 -0
  55. agentguard_governance-0.7.0/web/src/components/GovernanceView.jsx +160 -0
  56. agentguard_governance-0.7.0/web/src/components/InitPanel.jsx +114 -0
  57. agentguard_governance-0.7.0/web/src/components/ReviewPanel.jsx +84 -0
  58. agentguard_governance-0.7.0/web/src/components/StatusBadge.jsx +18 -0
  59. agentguard_governance-0.7.0/web/src/components/TerminalPanel.jsx +202 -0
  60. agentguard_governance-0.7.0/web/src/components/VerifyPanel.jsx +119 -0
  61. agentguard_governance-0.7.0/web/src/index.css +54 -0
  62. agentguard_governance-0.7.0/web/src/main.jsx +10 -0
  63. agentguard_governance-0.7.0/web/vite.config.js +14 -0
@@ -0,0 +1,21 @@
1
+ # AgentGuard AI Review Configuration
2
+ # Copy to .env and fill in your values
3
+ # NEVER commit .env to version control
4
+
5
+ # Provider: anthropic | openai | anysphere | openai-compatible
6
+ AGENTGUARD_AI_PROVIDER=anthropic
7
+
8
+ # API key for the selected provider
9
+ AGENTGUARD_AI_API_KEY=your-api-key-here
10
+
11
+ # Base URL (only for openai-compatible providers)
12
+ # AGENTGUARD_AI_BASE_URL=https://your-api-endpoint/v1
13
+
14
+ # Model override (optional — provider default used if not set)
15
+ # AGENTGUARD_AI_MODEL=claude-haiku-4-5-20251001
16
+
17
+ # Mission concretization uses a more capable model for schema reliability
18
+ # Anthropic: claude-sonnet-4-20250514 (instead of haiku)
19
+ # OpenAI: gpt-4o (instead of gpt-4o-mini)
20
+ # Override with AGENTGUARD_MISSION_MODEL=your-model if needed
21
+ # AGENTGUARD_MISSION_MODEL=claude-opus-4-20250514
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v6
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Lint with ruff
28
+ run: ruff check agentguard tests
29
+
30
+ - name: Run tests
31
+ run: pytest --tb=short
32
+
33
+ - name: Test web (with optional web deps)
34
+ run: |
35
+ pip install -e ".[web]"
36
+ pytest tests/test_web_server.py --tb=short
37
+
38
+ - name: Build package
39
+ run: pip install build hatchling && python -m build --no-isolation
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ environment: release
12
+ permissions:
13
+ id-token: write
14
+ contents: read
15
+
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v6
21
+ with:
22
+ python-version: '3.12'
23
+
24
+ - name: Install build dependencies
25
+ run: pip install build hatchling
26
+
27
+ - name: Build package
28
+ run: python -m build --no-isolation
29
+
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
32
+ with:
33
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.pyo
4
+ .Python
5
+ build/
6
+ dist/
7
+ *.egg-info/
8
+ .eggs/
9
+ .env
10
+ .venv
11
+ venv/
12
+ env/
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ *.log
16
+ report.md
17
+ agentguard-overrides.log
18
+ .DS_Store
19
+ web/node_modules/
20
+ web/dist/
@@ -0,0 +1 @@
1
+ c2f27bd
@@ -0,0 +1,132 @@
1
+ # AI_CONTEXT.md
2
+
3
+ > Keep this file current. Update after each significant session.
4
+
5
+ ---
6
+
7
+ ## Project
8
+
9
+ **Name:** AgentGuard
10
+ **Version:** 0.7.0
11
+ **Repo:** github.com/MyPatric69/agentguard
12
+ **Purpose:** Governance layer for autonomous AI agents — pre-flight
13
+ checks, runtime enforcement, concretization, and audit trail.
14
+
15
+ **Positioning:** Not an observability tool. The governance layer that
16
+ runs before, during, and after observability tools do.
17
+
18
+ **Taglines:**
19
+ - "Maximum instruction, minimum interpretation."
20
+ - "It doesn't eliminate the probability of failure. It reduces the impact."
21
+
22
+ ## Stack
23
+
24
+ - Python 3.11+
25
+ - Click (CLI), Rich (output), PyYAML (config), python-dotenv (env)
26
+ - Optional AI: Anthropic SDK, OpenAI SDK
27
+ - Optional Web: FastAPI + uvicorn, React 18 + Vite 5, xterm.js
28
+ - Build: hatchling, PyPI: agentguard-governance
29
+
30
+ ## Current State (v0.7.0)
31
+
32
+ ### CLI Commands (12 total)
33
+ - `agentguard check` — pre-flight: governance + prompt + harness checks
34
+ - `agentguard check --ai-review` — + AI scope quality score 1-10
35
+ - `agentguard init --interactive` — basic setup, no AI required
36
+ - `agentguard init --guided` — AI-concretized 5-step governance dialog
37
+ - `agentguard enforce` — PreToolUse hook, exit 0/2, deterministic
38
+ - `agentguard watch` — native Claude Code JSONL monitoring
39
+ - `agentguard report` — post-session Markdown governance report
40
+ - `agentguard review` — interactive governance update cycle
41
+ - `agentguard review --guided` — AI-assisted field update
42
+ - `agentguard verify` — prompt-pin drift detection
43
+ - `agentguard override` — documented exception with mandatory reason
44
+ - `agentguard web` — browser UI (requires pip install agentguard-governance[web])
45
+
46
+ ### Web UI (v0.7.0)
47
+ Six tabs: Pre-Flight Check, Governance, Verify Pins, Terminal,
48
+ Setup Governance, Review & Update.
49
+
50
+ Key features:
51
+ - Governance Score Ring on Check panel
52
+ - Color-coded scope sections (green/red/amber)
53
+ - xterm.js terminal with WebSocket PTY — runs interactive commands
54
+ - Quick Commands bar in terminal
55
+ - Run in Terminal buttons in Setup/Review panels
56
+ - Multi-project switcher (--path flag, dropdown when >1 project)
57
+ - Project name shown in header with check status
58
+
59
+ ### Key Technical Decisions
60
+ - Enforcement: deterministic, no LLM, never probabilistic
61
+ - Concretization: claude-sonnet / gpt-4o, temperature=0
62
+ - Mission concretization: higher-capability model (sonnet/gpt-4o)
63
+ - Scope review: provider default model (haiku/gpt-4o-mini)
64
+ - Validation: deterministic structural checks, no LLM
65
+ - Pinning: SHA-256 hashes of prompt+output in governance.yaml
66
+ - Version: single source of truth via importlib.metadata
67
+ - Terminal: PTY via Python stdlib pty + WebSocket + xterm.js
68
+ - Resize: binary protocol (0x01 prefix + cols/rows uint16)
69
+
70
+ ### governance.yaml Schema
71
+ - owner: string
72
+ - scope.authorized: list of {action, reason, added}
73
+ - scope.prohibited: list of {action, reason, severity, added}
74
+ - scope.requires_confirmation: list of {action, reason, added}
75
+ - scope.unresolved_ambiguities: list of {text, added, status}
76
+ - escalation: {contact, method, trigger}
77
+ - killswitch: string
78
+ - concretization_pins: list of {field, input_hash, prompt_hash,
79
+ output_hash, model, provider, temperature, date}
80
+ - governance_history: list of {date, action, tool, version,
81
+ changed_fields?}
82
+
83
+ ### Tests
84
+ - 217/217 passing
85
+ - CI: GitHub Actions, Python 3.11 + 3.12, green
86
+ - Web tests: TestClient (fastapi), PTY documented as manual-test-only
87
+
88
+ ## Open Items
89
+
90
+ ### Before PyPI
91
+ - Final documentation sync (this commit)
92
+
93
+ ### After PyPI
94
+ - Dev.to / LinkedIn article: "AgentGuard is live"
95
+ - v0.8.0: Intent-Aware Live Observer (drift detection via JSONL)
96
+ - Web-UI v0.8: inline governance editor
97
+ - Homebrew formula
98
+
99
+ ## Key Files
100
+
101
+ **Python backend:**
102
+ - `agentguard/web/server.py` — FastAPI + WebSocket PTY
103
+ - `agentguard/checks/preflight.py` — Layer 1
104
+ - `agentguard/enforcement/enforcer.py` — Layer 2
105
+ - `agentguard/checks/runtime.py` — Layer 3
106
+ - `agentguard/guided/concretizer.py` — AI concretization
107
+ - `agentguard/guided/validator.py` — structural validation
108
+ - `agentguard/guided/pinning.py` — SHA-256 pinning
109
+ - `agentguard/review/reviewer.py` — governance review
110
+ - `agentguard/ai_review.py` — scope quality review
111
+ - `agentguard/cli.py` — all commands
112
+ - `agentguard/output/renderer.py` — Rich output
113
+
114
+ **React frontend:**
115
+ - `web/src/App.jsx` — shell, sidebar, project switcher
116
+ - `web/src/components/CheckPanel.jsx` — score ring
117
+ - `web/src/components/GovernanceView.jsx` — scope cards
118
+ - `web/src/components/VerifyPanel.jsx` — pin cards
119
+ - `web/src/components/TerminalPanel.jsx` — xterm.js PTY
120
+ - `web/src/components/InitPanel.jsx` — setup panel
121
+ - `web/src/components/ReviewPanel.jsx` — review panel
122
+
123
+ ## Related
124
+
125
+ - Dev.to: https://dev.to/mypatric69/the-blind-spot-of-agentic-ai-systems-when-nobody-notices-the-agent-is-stuck-1hkb
126
+ - LinkedIn: https://www.linkedin.com/posts/patric-hayna-6b7b55134_the-blind-spot-of-agentic-ai-systems-when-activity-7467668285891821568-ZXtx
127
+
128
+ ---
129
+
130
+ ## Last updated
131
+
132
+ 2026-06-10 – Auto-synced 15 commit(s) to a166996
@@ -0,0 +1,94 @@
1
+ # AgentGuard — CLAUDE.md
2
+
3
+ ## Project Purpose
4
+ AgentGuard is a governance layer for autonomous AI agents. It provides pre-flight checks (Layer 1), runtime enforcement (Layer 2), runtime monitoring (Layer 3), and post-session reporting and audit (Layer 4). The goal is to make AI agents safer by ensuring governance prerequisites are in place before execution begins.
5
+
6
+ ## Architecture Overview (v0.7.0)
7
+
8
+ ```
9
+ agentguard/
10
+ ├── checks/
11
+ │ ├── preflight.py # Layer 1: governance + prompt + harness checks
12
+ │ ├── runtime.py # Layer 3: loop/stall/burn detection
13
+ │ └── report.py # Layer 4: post-session governance report
14
+ ├── enforcement/
15
+ │ └── enforcer.py # Layer 2: PreToolUse hook, exit 0/2
16
+ ├── guided/
17
+ │ ├── concretizer.py # AI concretization (sonnet/gpt-4o, temperature=0)
18
+ │ ├── validator.py # Deterministic structural validation
19
+ │ └── pinning.py # SHA-256 prompt/output pinning
20
+ ├── review/
21
+ │ └── reviewer.py # Governance review and update cycle
22
+ ├── web/
23
+ │ └── server.py # FastAPI bridge + WebSocket PTY terminal
24
+ ├── config/
25
+ │ └── loader.py # governance.yaml loading, list+string compat
26
+ ├── output/
27
+ │ └── renderer.py # Rich panels, severity colors
28
+ └── cli.py # All commands wired here
29
+
30
+ web/ # React/Vite frontend (built to web/dist/)
31
+ ├── src/
32
+ │ ├── App.jsx # Sidebar layout, project switcher
33
+ │ └── components/
34
+ │ ├── CheckPanel.jsx # Pre-flight check + score ring
35
+ │ ├── GovernanceView.jsx # Color-coded scope sections
36
+ │ ├── VerifyPanel.jsx # Pin verification cards
37
+ │ ├── TerminalPanel.jsx # xterm.js + WebSocket PTY
38
+ │ ├── InitPanel.jsx # Setup governance (Run in Terminal)
39
+ │ └── ReviewPanel.jsx # Review & update (Run in Terminal)
40
+ └── package.json
41
+ ```
42
+
43
+ ## Key Design Principles
44
+
45
+ - Enforcement layer: deterministic, no LLM, exit 0 or 2
46
+ - Concretization layer: LLM with temperature=0, human confirms
47
+ - Monitoring layer: LLM allowed, warnings only, never blocks
48
+ - Validation layer: deterministic, structural checks, no LLM
49
+
50
+ ## Scope
51
+ - Python CLI tool using Click and Rich
52
+ - No external network calls in core logic (API key optional for progress scoring)
53
+ - Target: developers and teams deploying autonomous AI agents
54
+
55
+ ## Code Quality Rules
56
+
57
+ **YAGNI** — Build only what is specified. No extra abstractions, no speculative features.
58
+ **KISS** — Prefer the simplest implementation that satisfies the requirement.
59
+ **DRY** — Extract shared logic when the same pattern appears 3+ times.
60
+ **Single Responsibility** — Each module does one thing. CLI wires them together.
61
+
62
+ - No debug logging (`print()` statements) in committed code
63
+ - No commented-out code
64
+ - No unused imports
65
+ - Tests must pass before commit (`pytest --tb=short`)
66
+ - One commit per logical change
67
+
68
+ ## Loop Detection
69
+ If the same approach fails 2+ times in a row:
70
+ 1. STOP immediately
71
+ 2. Do not retry the same strategy
72
+ 3. Propose a fundamentally different approach
73
+ 4. After 3 failed iterations: escalate or ask
74
+
75
+ ## Root Cause Analysis
76
+ - Confirm root cause before implementing any fix
77
+ - Do not patch symptoms
78
+ - If root cause is unclear, ask — do not guess
79
+
80
+ ## External APIs & Documentation
81
+ - Always fetch current documentation before diagnosing API issues
82
+ - Never rely on training-data memory for external API behavior
83
+ - If a newer API version or migration guide exists, flag it first
84
+
85
+ ## Testing
86
+ - All new behavior must have a corresponding test
87
+ - Tests live in `tests/` and mirror the module structure
88
+ - Use `tmp_path` pytest fixture for file system tests — never write to the real project root in tests
89
+
90
+ ## Version Management
91
+ - Version is defined ONLY in `pyproject.toml`
92
+ - `agentguard/__init__.py` reads version dynamically via importlib.metadata
93
+ - Never hardcode version in __init__.py
94
+ - On release: update pyproject.toml version only
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patric
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.