phrour-repograph 0.1.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 (37) hide show
  1. phrour_repograph-0.1.0/LICENSE +15 -0
  2. phrour_repograph-0.1.0/PKG-INFO +279 -0
  3. phrour_repograph-0.1.0/README.md +264 -0
  4. phrour_repograph-0.1.0/pyproject.toml +31 -0
  5. phrour_repograph-0.1.0/setup.cfg +4 -0
  6. phrour_repograph-0.1.0/src/phrour_repograph/__init__.py +3 -0
  7. phrour_repograph-0.1.0/src/phrour_repograph/cli.py +542 -0
  8. phrour_repograph-0.1.0/src/phrour_repograph/graph.py +623 -0
  9. phrour_repograph-0.1.0/src/phrour_repograph/impact.py +206 -0
  10. phrour_repograph-0.1.0/src/phrour_repograph/index.py +265 -0
  11. phrour_repograph-0.1.0/src/phrour_repograph/indexers/__init__.py +22 -0
  12. phrour_repograph-0.1.0/src/phrour_repograph/indexers/docs.py +146 -0
  13. phrour_repograph-0.1.0/src/phrour_repograph/indexers/infra.py +1363 -0
  14. phrour_repograph-0.1.0/src/phrour_repograph/indexers/python_indexer.py +163 -0
  15. phrour_repograph-0.1.0/src/phrour_repograph/indexers/rules.py +344 -0
  16. phrour_repograph-0.1.0/src/phrour_repograph/mcp.py +484 -0
  17. phrour_repograph-0.1.0/src/phrour_repograph/model.py +147 -0
  18. phrour_repograph-0.1.0/src/phrour_repograph/modulemap.py +25 -0
  19. phrour_repograph-0.1.0/src/phrour_repograph/recipes.py +100 -0
  20. phrour_repograph-0.1.0/src/phrour_repograph/report.py +199 -0
  21. phrour_repograph-0.1.0/src/phrour_repograph/select_tests.py +74 -0
  22. phrour_repograph-0.1.0/src/phrour_repograph.egg-info/PKG-INFO +279 -0
  23. phrour_repograph-0.1.0/src/phrour_repograph.egg-info/SOURCES.txt +35 -0
  24. phrour_repograph-0.1.0/src/phrour_repograph.egg-info/dependency_links.txt +1 -0
  25. phrour_repograph-0.1.0/src/phrour_repograph.egg-info/entry_points.txt +2 -0
  26. phrour_repograph-0.1.0/src/phrour_repograph.egg-info/top_level.txt +1 -0
  27. phrour_repograph-0.1.0/tests/test_cli.py +251 -0
  28. phrour_repograph-0.1.0/tests/test_confidence.py +126 -0
  29. phrour_repograph-0.1.0/tests/test_determinism.py +71 -0
  30. phrour_repograph-0.1.0/tests/test_graph.py +166 -0
  31. phrour_repograph-0.1.0/tests/test_iac.py +213 -0
  32. phrour_repograph-0.1.0/tests/test_impact.py +235 -0
  33. phrour_repograph-0.1.0/tests/test_indexers.py +454 -0
  34. phrour_repograph-0.1.0/tests/test_mcp.py +219 -0
  35. phrour_repograph-0.1.0/tests/test_mcp2026.py +132 -0
  36. phrour_repograph-0.1.0/tests/test_recipes.py +163 -0
  37. phrour_repograph-0.1.0/tests/test_store.py +220 -0
@@ -0,0 +1,15 @@
1
+ Copyright 2026 Soteria Solutions LLC. All rights reserved.
2
+
3
+ No part of this software may be copied, reproduced, modified, distributed,
4
+ published, sublicensed, or sold without prior written permission from
5
+ Soteria Solutions LLC. This includes source code and compiled forms.
6
+
7
+ You may install and run this software for evaluation and for your own
8
+ internal, non-commercial use, and you may redistribute unmodified packages
9
+ for installation purposes only.
10
+
11
+ Contributions may be submitted under a contributor licence agreement; see
12
+ CONTRIBUTING.md. Nothing in this notice grants any patent rights.
13
+
14
+ THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, TO THE
15
+ MAXIMUM EXTENT PERMITTED BY LAW.
@@ -0,0 +1,279 @@
1
+ Metadata-Version: 2.4
2
+ Name: phrour-repograph
3
+ Version: 0.1.0
4
+ Summary: Persistent cybersecurity code and infrastructure graph with deterministic queries
5
+ Author: Phrourios Security
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Homepage, https://phrourios.com
8
+ Project-URL: Source, https://github.com/Phrourios/phrour-repograph
9
+ Project-URL: Issues, https://github.com/Phrourios/phrour-repograph/issues
10
+ Project-URL: Changelog, https://github.com/Phrourios/phrour-repograph/blob/HEAD/CHANGELOG.md
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ <!-- phrourios:header:start -->
17
+ <p align="center"><img src="assets/banner.svg" alt="PhrourRepograph banner" width="100%"></p>
18
+
19
+ <p align="center">
20
+ <img alt="License: Proprietary" src="https://img.shields.io/badge/license-Proprietary-6F7C80">
21
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-3776AB">
22
+ <img alt="SEF 1.0" src="https://img.shields.io/badge/SEF-1.0-4FD6CF">
23
+ <img alt="Status: 0.1.0 release candidate" src="https://img.shields.io/badge/status-0.1.0--rc-6F7C80">
24
+ </p>
25
+ <!-- phrourios:header:end -->
26
+
27
+
28
+
29
+ # PhrourRepograph
30
+
31
+ A persistent cybersecurity graph of code and infrastructure, with deterministic queries.
32
+ PhrourRepograph indexes a repository into SQLite once, then answers three questions from the same
33
+ graph: what does this change reach, which tests cover it, and which security-relevant node sits
34
+ in the path.
35
+
36
+ Status: 0.1.0 release candidate. The Python, infrastructure, detection rule and document
37
+ indexers, the graph store, change impact, test selection, CLI and the dual-era MCP server work.
38
+ PyPI publication and the MCP registry listing are pending.
39
+
40
+ <!-- phrourios:getting-started:start -->
41
+ <!-- phrourios:glance:start -->
42
+ ## At a glance
43
+
44
+ | | |
45
+ | --- | --- |
46
+ | Input | A repository tree |
47
+ | Output | SQLite graph and deterministic query results |
48
+ | Engine | `phrour-repograph` 0.1.0 |
49
+ | License | All rights reserved (Soteria Solutions LLC) |
50
+ <!-- phrourios:glance:end -->
51
+
52
+ ## Getting started
53
+
54
+ Requires Python 3.11 or later. The project has no runtime dependencies.
55
+
56
+ ```bash
57
+ # from a checkout (development)
58
+ python3 -m pip install -e .
59
+
60
+ # from PyPI, once 0.1.0 is published
61
+ uvx phrour-repograph --help
62
+ pipx install phrour-repograph
63
+ python3 -m pip install --user phrour-repograph
64
+
65
+ phrour-repograph --version
66
+ phrour-repograph --help
67
+ ```
68
+
69
+ <!-- phrourios:getting-started:end -->
70
+
71
+ ## Research question
72
+
73
+ Can one persistent graph, built from syntax and configuration without executing anything,
74
+ tell a security reviewer where a code or infrastructure change lands, and do it with answers
75
+ that stay the same from run to run and from agent to agent?
76
+
77
+ ## What works
78
+
79
+ - Repository indexing into SQLite. The walk skips VCS, virtualenv and build directories, files
80
+ larger than 1 MiB, and private key or `.env` names. Unchanged files are skipped by SHA-256.
81
+ - The Python indexer: modules, classes, functions, test functions, imports, local calls, and
82
+ inferred attribute references. Each test node gets a `tests` edge to the modules it imports.
83
+ - The rules indexer: Sigma and YARA files become `rule` nodes. A MITRE tag becomes a `technique`
84
+ node with a `detects` edge. A rule body is never compiled or run.
85
+ - The docs indexer: every Markdown file becomes a `doc` node. A link or a path that names a file
86
+ in the repo becomes a `documents` edge; a link to another `.md` file becomes `references`.
87
+ - The infrastructure indexer: Dockerfile, compose, Kubernetes YAML and Terraform become
88
+ `container`, `image`, `service`, `host`, `network`, `port` and `dependency` nodes. Environment
89
+ variable names are recorded; their values are not.
90
+ - Graph queries: `query`, `trace`, `paths`, `stats`, `export`, and the `lens` view of security
91
+ kinds (`rule`, `control`, `vulnerability`, `identity`, `service`, plus entrypoint functions).
92
+ - Change impact: `impact` maps changed files to changed nodes, walks outward up to a depth, and
93
+ labels every reached node with depth and the key path that reached it. Inferred edges are
94
+ flagged.
95
+ - Query recipes: `detections` names the rules that detect a technique, `tests-for` names the tests
96
+ that reach a file or symbol, and `uncovered` names the modules that no test imports. Each answer
97
+ comes from stored edges, with the key chain that supports it.
98
+ - Test selection: `select-tests` walks forward from each test node to the changed keys and
99
+ returns the tests, each with the key chain that justifies it.
100
+ - SEF 1.0 output: `impact --record FILE` writes one evidence record with the indexed file set
101
+ hash, findings, evidence and limitations. See `../security-evidence-schema`.
102
+ - MCP server: newline-delimited JSON-RPC 2.0 over stdio, negotiating protocol `2024-11-05`,
103
+ `2025-03-26` or `2025-06-18`, with five read-only tools. See below.
104
+ - Workspace indexing: `index --workspace` indexes the root repository and every child git
105
+ repository as separate names, and never folds a nested repository into its parent.
106
+ - Measured on 2026-11-28 on the development workstation: 12 repositories, 318 files, 1384 nodes and 2602 edges in
107
+ 0.28 s.
108
+
109
+ ## What does not work yet
110
+
111
+ - YAML and Terraform are read with a line parser for the documented subset, not a full grammar.
112
+ A manifest the parser does not recognize is recorded as a file only.
113
+ - Call resolution is partial. Cross-module calls are not resolved; attribute access through an
114
+ import becomes an inferred `references` edge at confidence 0.6. Test selection therefore works
115
+ at module granularity: a test that imports a module selects every changed file and symbol in it.
116
+ - `uncovered` is an import-level bound, not line coverage. A test that reaches a module through a
117
+ fixture, a subprocess or `importlib` is not counted.
118
+ - No runtime data. There is no execution, no taint tracking, no dynamic dispatch and no network
119
+ map.
120
+ - No incremental watch mode. Re-indexing parses every changed file again.
121
+ - No remote transport for MCP and no authentication. The server is a local stdio process.
122
+
123
+ ## Install and run
124
+
125
+ ```bash
126
+ python3 -m venv .venv
127
+ . .venv/bin/activate
128
+ python3 -m pip install -e . pytest
129
+ python3 -m pytest -q
130
+ ```
131
+
132
+ Then, from a repository you want in the graph:
133
+
134
+ ```bash
135
+ phrour-repograph --db .phrour-repograph/graph.db init
136
+ phrour-repograph --db .phrour-repograph/graph.db index .
137
+ phrour-repograph --db .phrour-repograph/graph.db index /home/me/work --workspace
138
+ phrour-repograph --db .phrour-repograph/graph.db stats --json
139
+ phrour-repograph --db .phrour-repograph/graph.db query --kind function --name parse --json
140
+ phrour-repograph --db .phrour-repograph/graph.db search "credential rotation" --json
141
+ phrour-repograph --db .phrour-repograph/graph.db trace 'module:repo:pkg.auth' --depth 2 --json
142
+ phrour-repograph --db .phrour-repograph/graph.db impact . --since HEAD~1 --json
143
+ phrour-repograph --db .phrour-repograph/graph.db impact . --files src/auth.py --json --record impact.sef.json
144
+ phrour-repograph --db .phrour-repograph/graph.db select-tests . --files src/auth.py --json
145
+ phrour-repograph --db .phrour-repograph/graph.db detections T1071.001 --json
146
+ phrour-repograph --db .phrour-repograph/graph.db tests-for file:myrepo:src/auth.py --json
147
+ phrour-repograph --db .phrour-repograph/graph.db uncovered --limit 20
148
+ phrour-repograph --db .phrour-repograph/graph.db lens --json
149
+ ```
150
+
151
+ Every command that prints a result takes `--json`. Exit codes: `0` success, `1` a finding the
152
+ caller asked for (no path found, a security node in the impact, an empty lens), `2` a usage
153
+ error. `impact` indexes the target repository before it analyses; the other commands read the
154
+ existing database.
155
+
156
+ <!-- mcp-name: io.github.Phrourios/phrour-repograph -->
157
+
158
+ ## MCP server
159
+
160
+ <!-- mcp-name: io.github.Phrourios/phrour-repograph -->
161
+
162
+ `phrour-repograph --db PATH mcp` or `python -m phrour-repograph.mcp --db PATH` speaks MCP on stdin and
163
+ stdout. Logs never go to stdout. `server.json` next to this README is the registry listing.
164
+
165
+ The server is dual-era, per the `2026-07-28` protocol revision:
166
+
167
+ - Modern clients send every request stateless with
168
+ `_meta["io.modelcontextprotocol/protocolVersion"]`. `server/discover` answers first and names
169
+ the supported versions; a version the server lacks answers `-32022` with that list. Results
170
+ carry `resultType`, list results carry `ttlMs` and `cacheScope`.
171
+ - Legacy clients (revision `2025-11-25`) may send `initialize` first, or call the read-only
172
+ tools directly; plain requests are served statelessly. `ping` works only in this era.
173
+ - Revisions `2024-11-05`, `2025-03-26` and `2025-06-18` are refused with the supported list.
174
+
175
+ Methods: `server/discover`, `tools/list`, `tools/call`, plus legacy `initialize`, `ping` and
176
+ notifications. Unknown methods return `-32601`.
177
+
178
+ Tools:
179
+
180
+ | Tool | Arguments | Answer |
181
+ | --- | --- | --- |
182
+ | `query_graph` | `kind`, `name`, `path`, `repo`, `limit` | matching nodes |
183
+ | `get_node` | `key` | one node or null |
184
+ | `trace_dependencies` | `key`, `depth`, `direction` | reached nodes with the edge that reached each |
185
+ | `analyze_change` | `root`, `since`, `files` | changed nodes, impacted nodes, tests, unknowns |
186
+ | `select_tests` | `root`, `since`, `files` | tests plus the files a runner needs |
187
+
188
+ Each tool result is one `content[0]` item of type `text` that holds a JSON string, mirrored as
189
+ `structuredContent`. The tools are read-only: they never index, write or execute. Every tool
190
+ carries `annotations` (`readOnlyHint` true, `openWorldHint` false).
191
+
192
+ Client configuration (Claude Desktop, OpenClaw, any stdio client):
193
+
194
+ ```json
195
+ {
196
+ "mcpServers": {
197
+ "phrour-repograph": {
198
+ "command": "phrour-repograph",
199
+ "args": ["--db", "/path/to/repo/.phrour-repograph/graph.db", "mcp"]
200
+ }
201
+ }
202
+ }
203
+ ```
204
+
205
+ ## Ontology in one paragraph
206
+
207
+ Nodes are things: `repository`, `file`, `module`, `class`, `function`, `test`, `doc`, `policy`,
208
+ `service`, `container`, `image`, `host`, `network`, `port`, `rule`, `technique`, `dependency`,
209
+ `vulnerability`, `control`, `identity`, `device`, `firmware`. Edges are directed and carry a
210
+ provenance of `observed` or `inferred` plus a confidence: `contains`, `defines`, `imports`,
211
+ `calls`, `references`, `tests`, `exposes`, `depends_on`, `detects`, `documents`, `affects`,
212
+ `owns`. The full list with one line each is in `docs/ontology.md`.
213
+
214
+ ## Edge confidence tiers
215
+
216
+ Every edge carries a provenance and a confidence. The tiers are fixed:
217
+
218
+ | Tier | Confidence | Meaning | Examples |
219
+ | --- | --- | --- | --- |
220
+ | observed | 1.0 | the relationship is written literally in a source file | `import`, `defines`, a Markdown link, `FROM ubuntu:22.04`, `depends_on` in Compose |
221
+ | heuristic | 0.7 - 0.9 | a parser heuristic or naming convention inferred it | a Terraform reference found by block scan (0.7), "a test file imports a module, so it tests it" (0.8) |
222
+ | weak | 0.4 - 0.6 | a text mention or a guess-shaped link; review before trusting | a bare file path named in prose (0.5), `COPY --from` of a non-stage name (0.6) |
223
+
224
+ `--min-confidence` (CLI and MCP) drops edges below the threshold before walking, so a review
225
+ prompt built only from observed links is one flag away.
226
+
227
+ ## Boundary with ExploitGraph
228
+
229
+ PhrourRepograph owns the code and infrastructure graph, change impact and test selection. ExploitGraph
230
+ owns reachability and exploitability of vulnerabilities. PhrourRepograph may carry a `vulnerability`
231
+ node and an `affects` edge because the ontology is shared, but it does not decide whether a flaw
232
+ is exploitable. If a feature could sit in both, fix the row in `../docs/boundaries.md` first.
233
+
234
+ ## No LLM in the query path
235
+
236
+ Every answer comes from a SQL query, a graph walk or `git diff`. There is no model, no embedding
237
+ and no ranking that changes between runs. An agent may read the JSON, but the JSON is the same
238
+ for every reader.
239
+
240
+ ## Limits
241
+
242
+ - A clean impact result is not proof of safety. It means the graph saw no path, and the graph is
243
+ static and partial.
244
+ - A file that was not indexed (unsupported language, secret-like name, over 1 MiB) cannot appear
245
+ in any answer.
246
+ - Depth bounds the walk. A dependency beyond the requested depth is invisible.
247
+ - Results depend on the git ref you diff against.
248
+
249
+
250
+
251
+
252
+
253
+ <!-- phrourios:standards:start -->
254
+ ## Standards and references
255
+
256
+ - [tree-sitter](https://tree-sitter.github.io/tree-sitter/), Incremental parsing for source code.
257
+ - [SQLite](https://sqlite.org/), The embedded database used for the graph store.
258
+ - [Model Context Protocol](https://modelcontextprotocol.io/), The agent interface exposed by the MCP server.
259
+ <!-- phrourios:standards:end -->
260
+
261
+ <!-- phrourios:footer:start -->
262
+ ## Part of Phrourios Security
263
+
264
+ Phrourios Security builds security operations you can prove. This project is part of the
265
+ [Phrourios portfolio](https://github.com/Phrourios). Every result carries evidence, limits and a reproduction command.
266
+ <!-- phrourios:footer:end -->
267
+
268
+ ## License
269
+
270
+ All rights reserved, Soteria Solutions LLC. See `LICENSE`. Install, run and
271
+ unmodified package redistribution for installation are allowed; anything else needs
272
+ written permission. Decided 2026-12-03 (D-063), consistent with the Phrourios core
273
+ projects rule of 2026-11-30.
274
+
275
+ ## Contact
276
+
277
+ - Project contact: [contact@phrourios.com](mailto:contact@phrourios.com).
278
+ - Security issues: see [SECURITY.md](SECURITY.md), or email
279
+ [security@phrourios.com](mailto:security@phrourios.com). Do not open a public issue.
@@ -0,0 +1,264 @@
1
+ <!-- phrourios:header:start -->
2
+ <p align="center"><img src="assets/banner.svg" alt="PhrourRepograph banner" width="100%"></p>
3
+
4
+ <p align="center">
5
+ <img alt="License: Proprietary" src="https://img.shields.io/badge/license-Proprietary-6F7C80">
6
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-3776AB">
7
+ <img alt="SEF 1.0" src="https://img.shields.io/badge/SEF-1.0-4FD6CF">
8
+ <img alt="Status: 0.1.0 release candidate" src="https://img.shields.io/badge/status-0.1.0--rc-6F7C80">
9
+ </p>
10
+ <!-- phrourios:header:end -->
11
+
12
+
13
+
14
+ # PhrourRepograph
15
+
16
+ A persistent cybersecurity graph of code and infrastructure, with deterministic queries.
17
+ PhrourRepograph indexes a repository into SQLite once, then answers three questions from the same
18
+ graph: what does this change reach, which tests cover it, and which security-relevant node sits
19
+ in the path.
20
+
21
+ Status: 0.1.0 release candidate. The Python, infrastructure, detection rule and document
22
+ indexers, the graph store, change impact, test selection, CLI and the dual-era MCP server work.
23
+ PyPI publication and the MCP registry listing are pending.
24
+
25
+ <!-- phrourios:getting-started:start -->
26
+ <!-- phrourios:glance:start -->
27
+ ## At a glance
28
+
29
+ | | |
30
+ | --- | --- |
31
+ | Input | A repository tree |
32
+ | Output | SQLite graph and deterministic query results |
33
+ | Engine | `phrour-repograph` 0.1.0 |
34
+ | License | All rights reserved (Soteria Solutions LLC) |
35
+ <!-- phrourios:glance:end -->
36
+
37
+ ## Getting started
38
+
39
+ Requires Python 3.11 or later. The project has no runtime dependencies.
40
+
41
+ ```bash
42
+ # from a checkout (development)
43
+ python3 -m pip install -e .
44
+
45
+ # from PyPI, once 0.1.0 is published
46
+ uvx phrour-repograph --help
47
+ pipx install phrour-repograph
48
+ python3 -m pip install --user phrour-repograph
49
+
50
+ phrour-repograph --version
51
+ phrour-repograph --help
52
+ ```
53
+
54
+ <!-- phrourios:getting-started:end -->
55
+
56
+ ## Research question
57
+
58
+ Can one persistent graph, built from syntax and configuration without executing anything,
59
+ tell a security reviewer where a code or infrastructure change lands, and do it with answers
60
+ that stay the same from run to run and from agent to agent?
61
+
62
+ ## What works
63
+
64
+ - Repository indexing into SQLite. The walk skips VCS, virtualenv and build directories, files
65
+ larger than 1 MiB, and private key or `.env` names. Unchanged files are skipped by SHA-256.
66
+ - The Python indexer: modules, classes, functions, test functions, imports, local calls, and
67
+ inferred attribute references. Each test node gets a `tests` edge to the modules it imports.
68
+ - The rules indexer: Sigma and YARA files become `rule` nodes. A MITRE tag becomes a `technique`
69
+ node with a `detects` edge. A rule body is never compiled or run.
70
+ - The docs indexer: every Markdown file becomes a `doc` node. A link or a path that names a file
71
+ in the repo becomes a `documents` edge; a link to another `.md` file becomes `references`.
72
+ - The infrastructure indexer: Dockerfile, compose, Kubernetes YAML and Terraform become
73
+ `container`, `image`, `service`, `host`, `network`, `port` and `dependency` nodes. Environment
74
+ variable names are recorded; their values are not.
75
+ - Graph queries: `query`, `trace`, `paths`, `stats`, `export`, and the `lens` view of security
76
+ kinds (`rule`, `control`, `vulnerability`, `identity`, `service`, plus entrypoint functions).
77
+ - Change impact: `impact` maps changed files to changed nodes, walks outward up to a depth, and
78
+ labels every reached node with depth and the key path that reached it. Inferred edges are
79
+ flagged.
80
+ - Query recipes: `detections` names the rules that detect a technique, `tests-for` names the tests
81
+ that reach a file or symbol, and `uncovered` names the modules that no test imports. Each answer
82
+ comes from stored edges, with the key chain that supports it.
83
+ - Test selection: `select-tests` walks forward from each test node to the changed keys and
84
+ returns the tests, each with the key chain that justifies it.
85
+ - SEF 1.0 output: `impact --record FILE` writes one evidence record with the indexed file set
86
+ hash, findings, evidence and limitations. See `../security-evidence-schema`.
87
+ - MCP server: newline-delimited JSON-RPC 2.0 over stdio, negotiating protocol `2024-11-05`,
88
+ `2025-03-26` or `2025-06-18`, with five read-only tools. See below.
89
+ - Workspace indexing: `index --workspace` indexes the root repository and every child git
90
+ repository as separate names, and never folds a nested repository into its parent.
91
+ - Measured on 2026-11-28 on the development workstation: 12 repositories, 318 files, 1384 nodes and 2602 edges in
92
+ 0.28 s.
93
+
94
+ ## What does not work yet
95
+
96
+ - YAML and Terraform are read with a line parser for the documented subset, not a full grammar.
97
+ A manifest the parser does not recognize is recorded as a file only.
98
+ - Call resolution is partial. Cross-module calls are not resolved; attribute access through an
99
+ import becomes an inferred `references` edge at confidence 0.6. Test selection therefore works
100
+ at module granularity: a test that imports a module selects every changed file and symbol in it.
101
+ - `uncovered` is an import-level bound, not line coverage. A test that reaches a module through a
102
+ fixture, a subprocess or `importlib` is not counted.
103
+ - No runtime data. There is no execution, no taint tracking, no dynamic dispatch and no network
104
+ map.
105
+ - No incremental watch mode. Re-indexing parses every changed file again.
106
+ - No remote transport for MCP and no authentication. The server is a local stdio process.
107
+
108
+ ## Install and run
109
+
110
+ ```bash
111
+ python3 -m venv .venv
112
+ . .venv/bin/activate
113
+ python3 -m pip install -e . pytest
114
+ python3 -m pytest -q
115
+ ```
116
+
117
+ Then, from a repository you want in the graph:
118
+
119
+ ```bash
120
+ phrour-repograph --db .phrour-repograph/graph.db init
121
+ phrour-repograph --db .phrour-repograph/graph.db index .
122
+ phrour-repograph --db .phrour-repograph/graph.db index /home/me/work --workspace
123
+ phrour-repograph --db .phrour-repograph/graph.db stats --json
124
+ phrour-repograph --db .phrour-repograph/graph.db query --kind function --name parse --json
125
+ phrour-repograph --db .phrour-repograph/graph.db search "credential rotation" --json
126
+ phrour-repograph --db .phrour-repograph/graph.db trace 'module:repo:pkg.auth' --depth 2 --json
127
+ phrour-repograph --db .phrour-repograph/graph.db impact . --since HEAD~1 --json
128
+ phrour-repograph --db .phrour-repograph/graph.db impact . --files src/auth.py --json --record impact.sef.json
129
+ phrour-repograph --db .phrour-repograph/graph.db select-tests . --files src/auth.py --json
130
+ phrour-repograph --db .phrour-repograph/graph.db detections T1071.001 --json
131
+ phrour-repograph --db .phrour-repograph/graph.db tests-for file:myrepo:src/auth.py --json
132
+ phrour-repograph --db .phrour-repograph/graph.db uncovered --limit 20
133
+ phrour-repograph --db .phrour-repograph/graph.db lens --json
134
+ ```
135
+
136
+ Every command that prints a result takes `--json`. Exit codes: `0` success, `1` a finding the
137
+ caller asked for (no path found, a security node in the impact, an empty lens), `2` a usage
138
+ error. `impact` indexes the target repository before it analyses; the other commands read the
139
+ existing database.
140
+
141
+ <!-- mcp-name: io.github.Phrourios/phrour-repograph -->
142
+
143
+ ## MCP server
144
+
145
+ <!-- mcp-name: io.github.Phrourios/phrour-repograph -->
146
+
147
+ `phrour-repograph --db PATH mcp` or `python -m phrour-repograph.mcp --db PATH` speaks MCP on stdin and
148
+ stdout. Logs never go to stdout. `server.json` next to this README is the registry listing.
149
+
150
+ The server is dual-era, per the `2026-07-28` protocol revision:
151
+
152
+ - Modern clients send every request stateless with
153
+ `_meta["io.modelcontextprotocol/protocolVersion"]`. `server/discover` answers first and names
154
+ the supported versions; a version the server lacks answers `-32022` with that list. Results
155
+ carry `resultType`, list results carry `ttlMs` and `cacheScope`.
156
+ - Legacy clients (revision `2025-11-25`) may send `initialize` first, or call the read-only
157
+ tools directly; plain requests are served statelessly. `ping` works only in this era.
158
+ - Revisions `2024-11-05`, `2025-03-26` and `2025-06-18` are refused with the supported list.
159
+
160
+ Methods: `server/discover`, `tools/list`, `tools/call`, plus legacy `initialize`, `ping` and
161
+ notifications. Unknown methods return `-32601`.
162
+
163
+ Tools:
164
+
165
+ | Tool | Arguments | Answer |
166
+ | --- | --- | --- |
167
+ | `query_graph` | `kind`, `name`, `path`, `repo`, `limit` | matching nodes |
168
+ | `get_node` | `key` | one node or null |
169
+ | `trace_dependencies` | `key`, `depth`, `direction` | reached nodes with the edge that reached each |
170
+ | `analyze_change` | `root`, `since`, `files` | changed nodes, impacted nodes, tests, unknowns |
171
+ | `select_tests` | `root`, `since`, `files` | tests plus the files a runner needs |
172
+
173
+ Each tool result is one `content[0]` item of type `text` that holds a JSON string, mirrored as
174
+ `structuredContent`. The tools are read-only: they never index, write or execute. Every tool
175
+ carries `annotations` (`readOnlyHint` true, `openWorldHint` false).
176
+
177
+ Client configuration (Claude Desktop, OpenClaw, any stdio client):
178
+
179
+ ```json
180
+ {
181
+ "mcpServers": {
182
+ "phrour-repograph": {
183
+ "command": "phrour-repograph",
184
+ "args": ["--db", "/path/to/repo/.phrour-repograph/graph.db", "mcp"]
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ## Ontology in one paragraph
191
+
192
+ Nodes are things: `repository`, `file`, `module`, `class`, `function`, `test`, `doc`, `policy`,
193
+ `service`, `container`, `image`, `host`, `network`, `port`, `rule`, `technique`, `dependency`,
194
+ `vulnerability`, `control`, `identity`, `device`, `firmware`. Edges are directed and carry a
195
+ provenance of `observed` or `inferred` plus a confidence: `contains`, `defines`, `imports`,
196
+ `calls`, `references`, `tests`, `exposes`, `depends_on`, `detects`, `documents`, `affects`,
197
+ `owns`. The full list with one line each is in `docs/ontology.md`.
198
+
199
+ ## Edge confidence tiers
200
+
201
+ Every edge carries a provenance and a confidence. The tiers are fixed:
202
+
203
+ | Tier | Confidence | Meaning | Examples |
204
+ | --- | --- | --- | --- |
205
+ | observed | 1.0 | the relationship is written literally in a source file | `import`, `defines`, a Markdown link, `FROM ubuntu:22.04`, `depends_on` in Compose |
206
+ | heuristic | 0.7 - 0.9 | a parser heuristic or naming convention inferred it | a Terraform reference found by block scan (0.7), "a test file imports a module, so it tests it" (0.8) |
207
+ | weak | 0.4 - 0.6 | a text mention or a guess-shaped link; review before trusting | a bare file path named in prose (0.5), `COPY --from` of a non-stage name (0.6) |
208
+
209
+ `--min-confidence` (CLI and MCP) drops edges below the threshold before walking, so a review
210
+ prompt built only from observed links is one flag away.
211
+
212
+ ## Boundary with ExploitGraph
213
+
214
+ PhrourRepograph owns the code and infrastructure graph, change impact and test selection. ExploitGraph
215
+ owns reachability and exploitability of vulnerabilities. PhrourRepograph may carry a `vulnerability`
216
+ node and an `affects` edge because the ontology is shared, but it does not decide whether a flaw
217
+ is exploitable. If a feature could sit in both, fix the row in `../docs/boundaries.md` first.
218
+
219
+ ## No LLM in the query path
220
+
221
+ Every answer comes from a SQL query, a graph walk or `git diff`. There is no model, no embedding
222
+ and no ranking that changes between runs. An agent may read the JSON, but the JSON is the same
223
+ for every reader.
224
+
225
+ ## Limits
226
+
227
+ - A clean impact result is not proof of safety. It means the graph saw no path, and the graph is
228
+ static and partial.
229
+ - A file that was not indexed (unsupported language, secret-like name, over 1 MiB) cannot appear
230
+ in any answer.
231
+ - Depth bounds the walk. A dependency beyond the requested depth is invisible.
232
+ - Results depend on the git ref you diff against.
233
+
234
+
235
+
236
+
237
+
238
+ <!-- phrourios:standards:start -->
239
+ ## Standards and references
240
+
241
+ - [tree-sitter](https://tree-sitter.github.io/tree-sitter/), Incremental parsing for source code.
242
+ - [SQLite](https://sqlite.org/), The embedded database used for the graph store.
243
+ - [Model Context Protocol](https://modelcontextprotocol.io/), The agent interface exposed by the MCP server.
244
+ <!-- phrourios:standards:end -->
245
+
246
+ <!-- phrourios:footer:start -->
247
+ ## Part of Phrourios Security
248
+
249
+ Phrourios Security builds security operations you can prove. This project is part of the
250
+ [Phrourios portfolio](https://github.com/Phrourios). Every result carries evidence, limits and a reproduction command.
251
+ <!-- phrourios:footer:end -->
252
+
253
+ ## License
254
+
255
+ All rights reserved, Soteria Solutions LLC. See `LICENSE`. Install, run and
256
+ unmodified package redistribution for installation are allowed; anything else needs
257
+ written permission. Decided 2026-12-03 (D-063), consistent with the Phrourios core
258
+ projects rule of 2026-11-30.
259
+
260
+ ## Contact
261
+
262
+ - Project contact: [contact@phrourios.com](mailto:contact@phrourios.com).
263
+ - Security issues: see [SECURITY.md](SECURITY.md), or email
264
+ [security@phrourios.com](mailto:security@phrourios.com). Do not open a public issue.
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "phrour-repograph"
7
+ version = "0.1.0"
8
+ description = "Persistent cybersecurity code and infrastructure graph with deterministic queries"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "LicenseRef-Proprietary"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Phrourios Security" }]
14
+ dependencies = []
15
+
16
+ [project.scripts]
17
+ phrour-repograph = "phrour_repograph.cli:main"
18
+
19
+ [project.urls]
20
+ Homepage = "https://phrourios.com"
21
+ Source = "https://github.com/Phrourios/phrour-repograph"
22
+ Issues = "https://github.com/Phrourios/phrour-repograph/issues"
23
+ Changelog = "https://github.com/Phrourios/phrour-repograph/blob/HEAD/CHANGELOG.md"
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
27
+
28
+ [tool.pytest.ini_options]
29
+ pythonpath = ["src"]
30
+ testpaths = ["tests"]
31
+ addopts = "-q"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """PhrourRepograph: a cybersecurity-native code and infrastructure graph."""
2
+
3
+ __version__ = "0.1.0"