guard-cli 0.1.0rc1__tar.gz → 0.1.2__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 (58) hide show
  1. guard_cli-0.1.2/LICENSE +21 -0
  2. {guard_cli-0.1.0rc1/guard_cli.egg-info → guard_cli-0.1.2}/PKG-INFO +142 -85
  3. guard_cli-0.1.0rc1/PKG-INFO → guard_cli-0.1.2/README.md +128 -96
  4. guard_cli-0.1.2/guard_cli/__init__.py +7 -0
  5. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/agent_integration.py +12 -9
  6. guard_cli-0.1.2/guard_cli/api.py +457 -0
  7. guard_cli-0.1.2/guard_cli/backend.py +534 -0
  8. guard_cli-0.1.2/guard_cli/cli.py +343 -0
  9. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/db.py +72 -6
  10. guard_cli-0.1.2/guard_cli/doctor_cmd.py +535 -0
  11. guard_cli-0.1.2/guard_cli/events.py +77 -0
  12. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/feedback.py +2 -1
  13. guard_cli-0.1.2/guard_cli/hook.py +682 -0
  14. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/ingest/coverage.py +28 -4
  15. guard_cli-0.1.2/guard_cli/init_cmd.py +451 -0
  16. guard_cli-0.1.2/guard_cli/integrations/__init__.py +1 -0
  17. guard_cli-0.1.2/guard_cli/integrations/antigravity.py +258 -0
  18. guard_cli-0.1.2/guard_cli/integrations/claude.py +234 -0
  19. guard_cli-0.1.2/guard_cli/state.py +203 -0
  20. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/thin_slice.py +26 -5
  21. guard_cli-0.1.2/guard_cli.egg-info/PKG-INFO +267 -0
  22. guard_cli-0.1.2/guard_cli.egg-info/SOURCES.txt +48 -0
  23. guard_cli-0.1.2/guard_cli.egg-info/entry_points.txt +3 -0
  24. guard_cli-0.1.2/guard_cli.egg-info/requires.txt +16 -0
  25. guard_cli-0.1.2/guard_cli.egg-info/top_level.txt +1 -0
  26. guard_cli-0.1.2/pyproject.toml +46 -0
  27. guard_cli-0.1.2/tests/test_antigravity_integration.py +143 -0
  28. guard_cli-0.1.2/tests/test_antigravity_pre_recording_fixes.py +345 -0
  29. guard_cli-0.1.2/tests/test_api_and_hook.py +423 -0
  30. guard_cli-0.1.2/tests/test_backend.py +134 -0
  31. guard_cli-0.1.2/tests/test_commit_bypass.py +72 -0
  32. guard_cli-0.1.2/tests/test_commit_bypass_fresh_session.py +177 -0
  33. guard_cli-0.1.2/tests/test_doctor_cmd.py +157 -0
  34. guard_cli-0.1.2/tests/test_embedded_platform.py +63 -0
  35. guard_cli-0.1.2/tests/test_event_reasons.py +123 -0
  36. guard_cli-0.1.2/tests/test_fingerprint_invalidation.py +121 -0
  37. guard_cli-0.1.2/tests/test_hook_timeout.py +91 -0
  38. guard_cli-0.1.2/tests/test_init_cmd.py +107 -0
  39. guard_cli-0.1.2/tests/test_integration_init_doctor.py +171 -0
  40. guard_cli-0.1.0rc1/README.md +0 -198
  41. guard_cli-0.1.0rc1/guard/__init__.py +0 -2
  42. guard_cli-0.1.0rc1/guard/cli.py +0 -194
  43. guard_cli-0.1.0rc1/guard_cli.egg-info/SOURCES.txt +0 -24
  44. guard_cli-0.1.0rc1/guard_cli.egg-info/entry_points.txt +0 -2
  45. guard_cli-0.1.0rc1/guard_cli.egg-info/requires.txt +0 -6
  46. guard_cli-0.1.0rc1/guard_cli.egg-info/top_level.txt +0 -1
  47. guard_cli-0.1.0rc1/pyproject.toml +0 -30
  48. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/decision.py +0 -0
  49. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/ingest/__init__.py +0 -0
  50. {guard_cli-0.1.0rc1/guard → guard_cli-0.1.2/guard_cli}/ingest/static.py +0 -0
  51. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/guard_cli.egg-info/dependency_links.txt +0 -0
  52. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/setup.cfg +0 -0
  53. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_coverage.py +0 -0
  54. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_db.py +0 -0
  55. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_decision.py +0 -0
  56. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_feedback.py +0 -0
  57. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_static.py +0 -0
  58. {guard_cli-0.1.0rc1 → guard_cli-0.1.2}/tests/test_thin_slice.py +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Guard Contributors
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.
@@ -1,37 +1,67 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: guard-cli
3
- Version: 0.1.0rc1
3
+ Version: 0.1.2
4
4
  Summary: Graph-powered safety layer for AI coding agents built on FalkorDB
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/thisisvaishnav/guard
7
+ Project-URL: Repository, https://github.com/thisisvaishnav/guard
8
+ Project-URL: Bug Tracker, https://github.com/thisisvaishnav/guard/issues
9
+ Project-URL: Changelog, https://github.com/thisisvaishnav/guard/blob/main/CHANGELOG.md
5
10
  Requires-Python: >=3.10
6
11
  Description-Content-Type: text/markdown
12
+ License-File: LICENSE
7
13
  Requires-Dist: falkordb>=1.0.0
14
+ Requires-Dist: rich>=12.0.0
15
+ Requires-Dist: coverage>=7.0.0
16
+ Provides-Extra: embedded
17
+ Requires-Dist: falkordblite>=0.10.0; python_version >= "3.12" and extra == "embedded"
18
+ Provides-Extra: mcp
8
19
  Provides-Extra: dev
9
20
  Requires-Dist: pytest>=8.0.0; extra == "dev"
10
21
  Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
11
22
  Requires-Dist: coverage>=7.0.0; extra == "dev"
23
+ Requires-Dist: rich>=12.0.0; extra == "dev"
24
+ Dynamic: license-file
12
25
 
13
26
  # Guard: Graph-Powered Safety Layer for AI Coding Agents
14
27
 
28
+ [![PyPI version](https://img.shields.io/pypi/v/guard-cli.svg)](https://pypi.org/project/guard-cli/)
29
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
30
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
31
+ [![FalkorDB](https://img.shields.io/badge/Graph-FalkorDB-red.svg)](https://falkordb.com/)
32
+
15
33
  > **A high-velocity, graph-native regression prevention engine built on FalkorDB.**
16
34
  > Guard selects the exact minimal subset of tests to run after an AI coding agent modifies code, measures a multi-factor **Trust Score**, and deterministically triggers hard fallbacks to full test suites when graph confidence drops.
17
35
 
18
36
  ---
19
37
 
20
- ## 1. Problem Statement & Motivation
38
+ ## Quickstart
21
39
 
22
- When AI coding agents (Claude Code, Cursor, Codex, OpenCode) modify complex codebases, running the entire test suite on every step slows iteration cycles to a crawl. Conversely, naive heuristics used by developers or agents to speed things up introduce catastrophic silent escapes:
40
+ ### 1. Install Guard
41
+ ```bash
42
+ uv tool install guard-cli
43
+ # Or with embedded FalkorDB support on Python 3.12+:
44
+ # uv tool install "guard-cli[embedded]"
45
+ ```
23
46
 
24
- - **Same-File Heuristic (`same-file`)**: Only runs tests in the matching test file (e.g., changes in `src/flask/helpers.py` $\to$ run `tests/test_helpers.py`). In real production architectures, foundational helpers, middleware, and lifecycle hooks are heavily exercised across disparate modules (`test_basic.py`, `test_blueprints.py`, `test_templating.py`). On the held-out benchmark, **`same-file` suffered a 17.6% Escape Rate** (3 missed failures).
25
- - **Agent Guessing (`naive-guess`)**: LLMs predicting test paths based on file names or semantic similarity produce identical blind spots and hallucinate coverage.
26
- - **Run-All Suite (`run-all`)**: 100% safe, but destroys developer velocity and agent autonomy on non-trivial suites.
47
+ ### 2. Initialize in your Repository
48
+ ```bash
49
+ cd /path/to/your/repo
50
+ guard init
51
+ ```
52
+ `guard init` auto-detects your Python environment, sets up FalkorDB (server, docker, or embedded), ingests static call graphs & dynamic test coverage, and configures agent integrations (Claude Code Stop hook, AGENTS.md, .gitignore).
27
53
 
28
- **Guard's Core Thesis**: Code relationships and test executions form a graph topology. By indexing static AST relationships and per-test dynamic coverage contexts inside **FalkorDB**, Guard computes exact dependency subgraphs, measures empirical test confidence, dynamically widens around ambiguous dynamic dispatch, and enforces hard overrides when evidence is absent.
54
+ ### 3. Check System Health
55
+ ```bash
56
+ guard doctor
57
+ ```
58
+ Verifies backend connectivity, graph integrity, git freshness, and integration settings.
29
59
 
30
60
  ---
31
61
 
32
- ## 2. Verified Benchmark Results (Held-Out Evaluation)
62
+ ## Verified Benchmark Results (Held-Out Evaluation)
33
63
 
34
- Guard was evaluated against **`pallets/flask`** (494 tests) across 24 held-out mutants under a frozen protocol (`evals/split.json`, `PLAN.md`).
64
+ Evaluated against **`pallets/flask`** (494 tests) across 24 held-out mutants under a frozen protocol (`evals/split.json`, `PLAN.md`).
35
65
 
36
66
  All metrics are evaluated and reported as **Paired Metrics** (Escape Rate $\leftrightarrow$ Fallback Rate $\leftrightarrow$ Savings Ratio):
37
67
 
@@ -44,16 +74,28 @@ All metrics are evaluated and reported as **Paired Metrics** (Escape Rate $\left
44
74
  | *Ablation 1: `guard-no-confidence`* | 0.0% (0/17) | 77.1% | 20.8% (5/24) | 17 | None |
45
75
  | *Ablation 2: `guard-no-widening`* | 0.0% (0/17) | 73.3% | 25.0% (6/24) | 17 | None |
46
76
 
47
- > **Key Result**: Guard achieved a **0.0% Escape Rate** while delivering **67.3% Test-Time Savings** compared to `run-all`, completely eliminating the 17.6% escape rate of `same-file`.
77
+ > **Key Result**: Guard achieved a **0.0% Escape Rate** while delivering **67.3% Test-Time Savings** compared to `run-all`, completely eliminating the 17.6% escape rate of naive heuristics.
48
78
 
49
79
  ### Case Study: Root Cause of `m08` Escape Under `same-file`
50
- - **Mutant `m08`** inverted an `if not` statement in `src/flask/helpers.py:45`.
51
- - `same-file` and `naive-guess` selected `tests/test_helpers.py` (30 tests) $\to$ **0 failures reported (Escape)**.
52
- - `guard` traversed FalkorDB `COVERED_BY` edges and detected dependent execution paths in `tests/test_basic.py`, `tests/test_blueprints.py`, and `tests/test_templating.py` (26 tests) $\to$ **Caught failure immediately (0.0% escape)**.
80
+ - **Mutant `m08`** inverted an `if not` condition in `src/flask/helpers.py:45`.
81
+ - `same-file` and `naive-guess` selected only `tests/test_helpers.py` (30 tests) $\to$ **0 failures reported (Escape)**.
82
+ - `guard` traversed FalkorDB `COVERED_BY` edges and detected dependent execution paths in `tests/test_basic.py`, `tests/test_blueprints.py`, and `tests/test_templating.py` (26 tests) $\to$ **Caught failure in 0.13s (0.0% escape)**.
53
83
 
54
84
  ---
55
85
 
56
- ## 3. Architecture & System Design
86
+ ## Problem Statement & Motivation
87
+
88
+ When AI coding agents (Claude Code, Cursor, Codex, OpenCode) modify complex codebases, running the entire test suite on every step slows iteration cycles to a crawl. Conversely, naive heuristics introduce catastrophic silent escapes:
89
+
90
+ - **Same-File Heuristic (`same-file`)**: Only runs tests in the matching test file (e.g., changes in `src/flask/helpers.py` $\to$ run `tests/test_helpers.py`). Foundational helpers, middleware, and lifecycle hooks are heavily exercised across disparate modules (`test_basic.py`, `test_blueprints.py`, `test_templating.py`). On the held-out benchmark, **`same-file` suffered a 17.6% Escape Rate** (3 missed failures).
91
+ - **Agent Guessing (`naive-guess`)**: LLMs predicting test paths based on file names or semantic similarity produce identical blind spots and hallucinate coverage.
92
+ - **Run-All Suite (`run-all`)**: 100% safe, but destroys developer velocity and agent autonomy on non-trivial suites.
93
+
94
+ **Guard's Core Thesis**: Code relationships and test executions form a graph topology. By indexing static AST relationships and per-test dynamic coverage contexts inside **FalkorDB**, Guard computes exact dependency subgraphs, measures empirical test confidence, dynamically widens around ambiguous dynamic dispatch, and enforces hard overrides when evidence is absent.
95
+
96
+ ---
97
+
98
+ ## Architecture & System Design
57
99
 
58
100
  Guard operates as a deterministic, graph-native verification pipeline connecting static code structure, dynamic coverage telemetry, and autonomous agent loops:
59
101
 
@@ -62,10 +104,37 @@ Guard operates as a deterministic, graph-native verification pipeline connecting
62
104
  3. **Decision Engine (`guard.decision`)**: Pre-emptively checks hard safety overrides (uncovered functions, dynamic dispatch, touched tests), computes the multi-factor Trust Score, and routes execution to the appropriate policy level.
63
105
  4. **Self-Healing Feedback Loop (`guard.feedback`)**: Injects high-confidence `miss_repair` edges whenever a missed failure is detected, continuously hardening the graph against future escapes.
64
106
 
107
+ ```
108
+ +-----------------------+
109
+ | AI Agent Git Diff |
110
+ +-----------+-----------+
111
+ |
112
+ v
113
+ +-----------------------+
114
+ | AST Diff Analyzer | -> Identifies modified functions & test files
115
+ +-----------+-----------+
116
+ |
117
+ v
118
+ +-----------------------+
119
+ | FalkorDB Graph Engine| -> Queries COVERED_BY edges, call paths,
120
+ +-----------+-----------+ and dynamic dispatch topology
121
+ |
122
+ v
123
+ +-----------------------+
124
+ | Decision Engine | -> Evaluates hard overrides & Trust Score
125
+ +-----------+-----------+
126
+ |
127
+ +---------+---------+
128
+ | |
129
+ Trust >= 0.8 Trust < 0.8 / Override
130
+ | |
131
+ v v
132
+ +-----------------+ +-----------------+
133
+ | Targeted Subset | | Full Test Suite |
134
+ +-----------------+ +-----------------+
135
+ ```
65
136
 
66
- ### 3.1. FalkorDB Graph Schema
67
-
68
- The graph layer leverages FalkorDB for low-latency Cypher queries and multi-hop graph traversals:
137
+ ### FalkorDB Graph Schema
69
138
 
70
139
  #### Nodes
71
140
  - `(:File {path})`: Source files and test files in the repository.
@@ -83,17 +152,17 @@ The graph layer leverages FalkorDB for low-latency Cypher queries and multi-hop
83
152
 
84
153
  ---
85
154
 
86
- ## 4. Decision Engine & Trust Model
155
+ ## Decision Engine & Trust Model
87
156
 
88
157
  Guard evaluates code changes using a strict two-stage process: **Hard Safety Overrides** followed by the **Empirical Trust Score Policy**.
89
158
 
90
- ### 4.1. Hard Safety Overrides (Pre-Emptive Gating)
159
+ ### 1. Hard Safety Overrides (Pre-Emptive Gating)
91
160
  Before computing continuous scores, Guard enforces three non-bypassable guardrails:
92
- 1. **Test Files Touched**: If any test file is modified or added, Guard forces `run-all` with a safety warning (modifying assertions could invalidate test isolation).
161
+ 1. **Test Files Touched**: If any test file is modified or added, Guard forces `run-all` with a safety warning.
93
162
  2. **Missing Evidence (`no_evidence`)**: If any modified function lacks dynamic coverage evidence in FalkorDB, Guard automatically falls back to `run-all` (never guess when unmapped).
94
163
  3. **Dynamic Dispatch Flagged**: If AST analysis flags dynamic dispatch (`getattr`, `setattr`, `eval`, `**kwargs` dispatch), Guard automatically triggers **Dynamic Widening**, expanding the candidate test set to include all module tests.
95
164
 
96
- ### 4.2. Trust Score Formula
165
+ ### 2. Trust Score Formula
97
166
  When no hard overrides force `run-all`, Guard computes the composite trust metric:
98
167
 
99
168
  $$\text{Trust} = 0.5 \cdot \text{EvidenceRatio} + 0.3 \cdot \text{Freshness} + 0.2 \cdot (1 - \text{UncertainRatio})$$
@@ -102,109 +171,97 @@ $$\text{Trust} = 0.5 \cdot \text{EvidenceRatio} + 0.3 \cdot \text{Freshness} + 0
102
171
  - $\text{Freshness}$: Proportion of evidence edges whose `last_verified_sha` matches the current commit SHA.
103
172
  - $\text{UncertainRatio}$: Proportion of modified functions flagged with dynamic dispatch patterns.
104
173
 
105
- ### 4.3. Three-Level Execution Policy
174
+ ### 3. Three-Level Execution Policy
106
175
  - **$\text{Trust} \ge 0.8$ (`subset`)**: Execute only the directly covering tests mapped via high-confidence `COVERED_BY` edges.
107
176
  - **$0.5 \le \text{Trust} < 0.8$ (`medium`)**: Execute the covering subset plus all tests associated with the modified modules.
108
177
  - **$\text{Trust} < 0.5$ (`run-all`)**: Enforce full test suite fallback.
109
178
 
110
179
  ---
111
180
 
112
- ## 5. Self-Healing Feedback Loop
181
+ ## Claude Code & Agent Integration
113
182
 
114
- When an unexpected regression or missed test failure occurs:
115
- 1. The failure event is captured via `guard feedback --function <func_id> --test <test_id>`.
116
- 2. Guard writes a synthetic repair edge `(:Function)-[:COVERED_BY {source: 'miss_repair', confidence: 1.0}]->(:Test)`.
117
- 3. The `no_evidence` flag on the function is cleared.
118
- 4. Future decisions for this function or its callers automatically select the repaired test, preventing recurring escapes.
183
+ > **Experimental**: Both the Claude Code Stop hook and the Antigravity integration are
184
+ > labeled **experimental**. The Antigravity `hooks.json` schema was verified against
185
+ > [Antigravity's official hook documentation](https://antigravity.google/docs/hooks), but
186
+ > both integrations have only been validated with simulated stdin/stdout input. A real
187
+ > live session (Claude Code, Antigravity) has not yet confirmed end-to-end behavior.
119
188
 
120
- ---
189
+ Guard integrates into autonomous coding workflows:
121
190
 
122
- ## 6. Installation & Quickstart
191
+ - **Claude Code Stop Hook**: Installed via `guard hook install` into `.claude/settings.local.json`. Whenever Claude attempts to conclude a task, the Stop hook evaluates the diff. If tests fail, it blocks completion (Exit 2) and injects a concise $\le$ 30 line failure report.
192
+ - **Idle-Turn Optimization**: Caches working-tree SHA-256 fingerprints and skips unchanged turns and non-Python diffs.
193
+ - **Loop Guard**: Caps consecutive failures at 3 attempts, handing control back to the user before burning tokens.
194
+ - **Audit Log**: Appends all hook executions, test results, and decisions to `.guard/events.jsonl`.
123
195
 
124
- ### Prerequisites
125
- - Python 3.10+
126
- - Docker & Docker Compose (for FalkorDB)
196
+ ---
127
197
 
128
- ### 1. Start FalkorDB
129
- ```bash
130
- docker compose up -d
131
- # FalkorDB is live on localhost:6379
132
- # Web UI is accessible on http://localhost:3000
133
- ```
198
+ ## CLI Reference
134
199
 
135
- ### 2. Install Guard
200
+ ### `guard init`
201
+ Initializes Guard in a repository, detects backends, and configures integrations:
136
202
  ```bash
137
- pip install -e .
138
- # Or install with dev dependencies:
139
- pip install -e ".[dev]"
203
+ guard init [--backend server|docker|embedded] [--skip-coverage]
140
204
  ```
141
205
 
142
- ### 3. Ingest Target Repository
206
+ #### Backends & Platform Support
207
+
208
+ Guard supports three FalkorDB backend topologies:
209
+ 1. **Server (`--backend server`)**: Connects to an existing FalkorDB instance (default: `localhost:6379`). Works across all platforms.
210
+ 2. **Docker (`--backend docker`)**: Automatically launches and manages a dedicated `guard-falkordb` container on port 6390. Works on any platform with Docker installed.
211
+ 3. **Embedded (`--backend embedded`)**: Zero-configuration, in-process FalkorDBLite instance.
212
+ - **Supported OS & Platform Requirements**:
213
+ - **Python**: 3.12 or newer
214
+ - **Linux**: `glibc` 2.39 or newer (e.g., Ubuntu 24.04+, Fedora 40+)
215
+ - **macOS**: macOS 15 (Sequoia) or newer
216
+ - **Platform Fallback**: On unsupported platforms (such as Linux with glibc < 2.39 or macOS < 15), Guard prints a clear message:
217
+ ```text
218
+ no embedded build for this platform, use Docker or a server
219
+ ```
220
+ and guides you to use `--backend docker` or `--backend server` instead of failing with a build error.
221
+
222
+ ### `guard doctor`
223
+ Verifies system health, backend reachability, graph counts, and settings:
143
224
  ```bash
144
- # 1. Ingest static AST topology into FalkorDB
145
- guard ingest-static /path/to/target/repo --include-tests
146
-
147
- # 2. Ingest per-test coverage contexts (runs pytest with --cov-context=test)
148
- guard ingest-coverage /path/to/target/repo --runs 3
149
-
150
- # 3. View database statistics
151
- guard stats
225
+ guard doctor [--fix]
152
226
  ```
153
227
 
154
- ---
155
-
156
- ## 7. CLI Reference
157
-
158
228
  ### `guard run`
159
229
  Executes agent pre-completion test verification on the current working tree diff:
160
230
  ```bash
161
- guard run --repo /path/to/target/repo
231
+ guard run [--repo /path/to/repo]
162
232
  ```
163
- *Exits with code 0 on success, or code 1 if tests fail or trust is breached, blocking autonomous agents from committing broken code.*
164
233
 
165
234
  ### `guard check`
166
- Computes the test selection decision without executing tests (outputs JSON or human-readable format):
235
+ Computes the test selection decision without executing tests (outputs JSON schema v1.0 or text):
167
236
  ```bash
168
- guard check --repo /path/to/target/repo --json
237
+ guard check [--repo /path/to/repo] [--json]
169
238
  ```
170
239
 
171
- ### `guard callers`
172
- Traverses multi-hop static call graph in FalkorDB up to $N$ hops:
240
+ ### `guard hook`
241
+ Manages Claude Code and agent hook configurations (experimental — see note above):
173
242
  ```bash
174
- guard callers "src/flask/app.py::Flask.dispatch_request" --hops 4 --min-confidence 0.6
175
- ```
176
-
177
- ### `guard covering-tests`
178
- Queries all tests covering a specific function ordered by edge confidence:
179
- ```bash
180
- guard covering-tests "src/flask/helpers.py::url_for"
243
+ guard hook install [--shared] [--antigravity]
244
+ guard hook status
245
+ guard hook uninstall [--antigravity]
181
246
  ```
182
247
 
183
248
  ### `guard feedback`
184
- Repairs the graph after a missed failure:
249
+ Repairs the graph after an unexpected failure:
185
250
  ```bash
186
251
  guard feedback --function "src/flask/helpers.py::url_for" --test "tests/test_helpers.py::test_url_for"
187
252
  ```
188
253
 
189
254
  ---
190
255
 
191
- ## 8. Architectural Trade-offs & Limits
192
-
193
- ### What Graph-Native Architecture Enables
194
- - **Deterministic Traceability**: Every skipped test has an explicit, queryable reason (`guard check --json` outputs edge justifications for all known tests).
195
- - **Cross-Module Awareness**: Identifies deep, non-obvious test linkages across package boundaries that escape keyword search or lexical matching.
196
- - **Fail-Safe Convergence**: Combines static structure with empirical dynamic execution contexts so that gaps trigger defensive full runs rather than silent failures.
256
+ ## Documentation & Visualizations
197
257
 
198
- ### Known Limits and Edge Cases
199
- 1. **Dynamic Python Metaprogramming**: Heavy dynamic dispatch (`getattr(module, var)()`, custom metaclasses, dynamic decorators) cannot be completely resolved via static AST. *Mitigation*: Guard detects dynamic syntax patterns and triggers dynamic widening or full fallbacks.
200
- 2. **Initial Ingestion Cost**: Generating fine-grained per-test coverage contexts requires an initial baseline run (`pytest --cov-context=test`), which can incur a 1.5x–2.0x slowdown during graph ingestion.
201
- 3. **Ecosystem Scope**: Currently tuned for Python repositories using `pytest`.
258
+ Additional architectural diagrams, interactive visualizations, and test reports are available in the [`docs/`](docs/) directory:
259
+ - [Interactive 3D Flow Architecture](docs/project_flow_3d.html)
260
+ - [Safety Layer Overview](docs/falkordb-safety-layer.html)
261
+ - [Verification Reports](reports/)
202
262
 
203
263
  ---
204
264
 
205
- ## 9. Verification & Quality Invariants
265
+ ## License
206
266
 
207
- Guard development adheres to strict engineering rules (`PLAN.md` R1–R9):
208
- - **Frozen Benchmarks**: Acceptance claims and split files are immutable and verified through independent verifier runs (`reports/verify_t*.md`).
209
- - **Zero Flake Tolerance**: Flaky tests are detected during ingest runs and excluded from dynamic evidence edges.
210
- - **Complete Test Coverage**: Pure decision logic, parsers, and graph writers are covered with unit and integration tests under `tests/`.
267
+ MIT License. See [LICENSE](LICENSE) for details.