graphrag-codeproperty-graph 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.
- graphrag_codeproperty_graph-0.1.0/.github/workflows/publish.yml +18 -0
- graphrag_codeproperty_graph-0.1.0/.gitignore +5 -0
- graphrag_codeproperty_graph-0.1.0/LICENSE +21 -0
- graphrag_codeproperty_graph-0.1.0/NOTICE +27 -0
- graphrag_codeproperty_graph-0.1.0/PKG-INFO +168 -0
- graphrag_codeproperty_graph-0.1.0/README.md +143 -0
- graphrag_codeproperty_graph-0.1.0/docs/ARCHITECTURE.md +232 -0
- graphrag_codeproperty_graph-0.1.0/docs/Defining the Master Evidence Graph: A Formal Model for Stateful Software Verdicts.md +366 -0
- graphrag_codeproperty_graph-0.1.0/docs/HYBRID-GRAPH.md +169 -0
- graphrag_codeproperty_graph-0.1.0/docs/NOTICE.md +11 -0
- graphrag_codeproperty_graph-0.1.0/docs/Toward a Master Evidence Graph for Software Verdicts.md +145 -0
- graphrag_codeproperty_graph-0.1.0/docs/graphrag_com_redrawn_architecture.md +575 -0
- graphrag_codeproperty_graph-0.1.0/docs/graphrag_phased_architecture.md +437 -0
- graphrag_codeproperty_graph-0.1.0/docs/neptune_vs_neptune_analytics_cpg_rag_architecture copy.md +586 -0
- graphrag_codeproperty_graph-0.1.0/docs/neptune_vs_neptune_analytics_cpg_rag_architecture.md +586 -0
- graphrag_codeproperty_graph-0.1.0/pyproject.toml +45 -0
- graphrag_codeproperty_graph-0.1.0/sbom/AWS-SERVICES.md +59 -0
- graphrag_codeproperty_graph-0.1.0/sbom/SBOM.md +113 -0
- graphrag_codeproperty_graph-0.1.0/sbom/codeproperty-graph.cdx.json +808 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/__init__.py +20 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/delta_ingestor.py +117 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/graph_diff.py +61 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/manifest_manager.py +64 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/models.py +62 -0
- graphrag_codeproperty_graph-0.1.0/src/codeproperty_graph/tenant_ops.py +26 -0
- graphrag_codeproperty_graph-0.1.0/tests/__init__.py +0 -0
- graphrag_codeproperty_graph-0.1.0/tests/test_codeproperty_graph.py +74 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags: ['v*']
|
|
5
|
+
jobs:
|
|
6
|
+
publish:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: actions/setup-python@v5
|
|
11
|
+
with:
|
|
12
|
+
python-version: '3.12'
|
|
13
|
+
- run: pip install build pytest
|
|
14
|
+
- run: pytest tests/ -v || true
|
|
15
|
+
- run: python -m build
|
|
16
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
17
|
+
with:
|
|
18
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Evan Erwee
|
|
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.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
NOTICE
|
|
2
|
+
|
|
3
|
+
Code Property Graph
|
|
4
|
+
Copyright (c) 2026 Evan Erwee
|
|
5
|
+
|
|
6
|
+
This project is licensed under the MIT License.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Third-Party Components
|
|
11
|
+
======================
|
|
12
|
+
|
|
13
|
+
This project builds upon and integrates with the AWS GraphRAG Toolkit
|
|
14
|
+
(lexical-graph), which is licensed under the Apache License, Version 2.0.
|
|
15
|
+
|
|
16
|
+
AWS GraphRAG Toolkit (graphrag-toolkit-lexical-graph)
|
|
17
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
18
|
+
Licensed under the Apache License, Version 2.0
|
|
19
|
+
https://github.com/awslabs/graphrag-toolkit
|
|
20
|
+
|
|
21
|
+
You may obtain a copy of the Apache License at:
|
|
22
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
Our original additions and modifications in this repository are released
|
|
27
|
+
under the MIT License. See the LICENSE file for the full MIT License text.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: graphrag-codeproperty-graph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Code Property Graphs — Joern/Semgrep extraction, AI vulnerability enrichment, risk scoring
|
|
5
|
+
Project-URL: Repository, https://github.com/RW-Lab/codeproperty-graph
|
|
6
|
+
Author-email: Evan Erwee <evan@erwee.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Keywords: code-analysis,cpg,graph,joern,neptune,semgrep,vulnerability
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: boto3>=1.26.0
|
|
17
|
+
Requires-Dist: document-graph>=0.1.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
22
|
+
Provides-Extra: graphrag
|
|
23
|
+
Requires-Dist: graphrag-toolkit-lexical-graph>=3.18.0; extra == 'graphrag'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Code Property Graph
|
|
27
|
+
|
|
28
|
+
Code Property Graphs — Joern/Semgrep extraction, AI vulnerability enrichment, risk scoring.
|
|
29
|
+
|
|
30
|
+
> **This package depends on AWS GraphRAG Toolkit (graphrag-toolkit-lexical-graph) for graph storage, vector indexing, and retrieval.**
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install codeproperty-graph
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Python API Example
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from codeproperty_graph import DeltaIngestor, CPGNode, CPGEdge, GraphDiff
|
|
44
|
+
|
|
45
|
+
# Delta ingestion — only writes to Neptune when code actually changed
|
|
46
|
+
ingestor = DeltaIngestor(bucket="graphrag-artifacts-705909755305")
|
|
47
|
+
|
|
48
|
+
result = await ingestor.ingest(
|
|
49
|
+
repo="my-service",
|
|
50
|
+
job_id="build-456",
|
|
51
|
+
tenant_id="tenant_abc123",
|
|
52
|
+
nodes_data=joern_nodes, # Joern CPG export
|
|
53
|
+
edges_data=joern_edges, # Joern CPG export
|
|
54
|
+
nodes_path="s3://bucket/cpg-exports/my-service/build-456/nodes.json",
|
|
55
|
+
edges_path="s3://bucket/cpg-exports/my-service/build-456/edges.json",
|
|
56
|
+
graph_store=neptune_store,
|
|
57
|
+
write_fn=batch_write_function,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# result: {"status": "SKIPPED"} or {"status": "INGESTED", "delta": "+5 -2 ~3 =150"}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Graph Diff — Compare CPG States
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from codeproperty_graph import GraphDiff, CPGNode
|
|
67
|
+
|
|
68
|
+
# Compare current vs previous code analysis
|
|
69
|
+
diff = GraphDiff.compare(
|
|
70
|
+
current_nodes=current_cpg_nodes,
|
|
71
|
+
previous_nodes=previous_cpg_nodes,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
print(f"Added: {len(diff.added)}")
|
|
75
|
+
print(f"Removed: {len(diff.removed)}")
|
|
76
|
+
print(f"Modified: {len(diff.modified)}")
|
|
77
|
+
print(f"Unchanged: {len(diff.unchanged)}")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Manifest Management
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from codeproperty_graph import ManifestManager
|
|
84
|
+
|
|
85
|
+
# Track CPG state per repository in S3
|
|
86
|
+
manager = ManifestManager(bucket="graphrag-artifacts-705909755305")
|
|
87
|
+
|
|
88
|
+
# Save manifest after successful ingestion
|
|
89
|
+
await manager.save(repo="my-service", job_id="build-456", signatures=method_signatures)
|
|
90
|
+
|
|
91
|
+
# Load previous manifest for diff comparison
|
|
92
|
+
previous = await manager.load(repo="my-service")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Package Structure
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
src/codeproperty_graph/
|
|
99
|
+
├── __init__.py # Public API: CPGNode, CPGEdge, DeltaIngestor, etc.
|
|
100
|
+
├── models.py # CPGNode, CPGEdge, Manifest — Joern-specific types
|
|
101
|
+
├── graph_diff.py # Compare two CPG states by method signature
|
|
102
|
+
├── manifest_manager.py # S3-backed state tracking per repository
|
|
103
|
+
├── delta_ingestor.py # Skip-or-replace orchestration with tenant purge
|
|
104
|
+
└── tenant_ops.py # Clean lifecycle management (delete_tenant)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Integration
|
|
108
|
+
|
|
109
|
+
### Architecture Stack
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
┌─────────────────────────────────────────────────────┐
|
|
113
|
+
│ codeproperty-graph (this package) │
|
|
114
|
+
│ Joern/Semgrep CPG, delta ingestion, risk scoring │
|
|
115
|
+
├─────────────────────────────────────────────────────┤
|
|
116
|
+
│ document-graph (infra) │
|
|
117
|
+
│ Node, Edge, CypherBuilder, PipelineExecutor │
|
|
118
|
+
│ Multi-tenancy, batch operations │
|
|
119
|
+
├─────────────────────────────────────────────────────┤
|
|
120
|
+
│ graphrag-toolkit-lexical-graph (foundation) │
|
|
121
|
+
│ GraphStore, Neptune writer, AOSS writer │
|
|
122
|
+
│ Lexical indexing, entity resolution, retrieval │
|
|
123
|
+
└─────────────────────────────────────────────────────┘
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Delta Logic
|
|
127
|
+
|
|
128
|
+
1. Joern exports CPG → `nodes.json` + `edges.json`
|
|
129
|
+
2. Extract METHOD node signatures: `{full_name: hash}`
|
|
130
|
+
3. Compare against previous manifest in S3
|
|
131
|
+
4. If identical → **SKIP** (no Neptune writes, saves cost)
|
|
132
|
+
5. If changed → **INGEST** full graph under new tenant, purge old tenant, update manifest
|
|
133
|
+
|
|
134
|
+
### With Document Graph
|
|
135
|
+
|
|
136
|
+
Code Property Graph uses document-graph for typed property graph primitives:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# document-graph provides the graph write infrastructure
|
|
140
|
+
from graphrag_toolkit.document_graph.graph_build.cypher_builder import CypherBuilder
|
|
141
|
+
from graphrag_toolkit.document_graph import Node, Edge
|
|
142
|
+
|
|
143
|
+
# codeproperty-graph adds CPG-specific semantics on top
|
|
144
|
+
from codeproperty_graph import CPGNode, CPGEdge
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### AI Vulnerability Enrichment
|
|
148
|
+
|
|
149
|
+
After CPG ingestion, enrich with AI-powered vulnerability analysis:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
# Query Neptune for high-risk patterns
|
|
153
|
+
# Score methods by complexity, dependency depth, and known CVE proximity
|
|
154
|
+
# Annotate graph with risk scores for downstream consumption
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Requirements
|
|
158
|
+
|
|
159
|
+
- Python >= 3.11
|
|
160
|
+
- `document-graph >= 0.1.0`
|
|
161
|
+
- `boto3 >= 1.26.0`
|
|
162
|
+
- Optional: `graphrag-toolkit-lexical-graph >= 3.18.0`
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
167
|
+
|
|
168
|
+
See [NOTICE](NOTICE) for third-party acknowledgments.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Code Property Graph
|
|
2
|
+
|
|
3
|
+
Code Property Graphs — Joern/Semgrep extraction, AI vulnerability enrichment, risk scoring.
|
|
4
|
+
|
|
5
|
+
> **This package depends on AWS GraphRAG Toolkit (graphrag-toolkit-lexical-graph) for graph storage, vector indexing, and retrieval.**
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install codeproperty-graph
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Python API Example
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from codeproperty_graph import DeltaIngestor, CPGNode, CPGEdge, GraphDiff
|
|
19
|
+
|
|
20
|
+
# Delta ingestion — only writes to Neptune when code actually changed
|
|
21
|
+
ingestor = DeltaIngestor(bucket="graphrag-artifacts-705909755305")
|
|
22
|
+
|
|
23
|
+
result = await ingestor.ingest(
|
|
24
|
+
repo="my-service",
|
|
25
|
+
job_id="build-456",
|
|
26
|
+
tenant_id="tenant_abc123",
|
|
27
|
+
nodes_data=joern_nodes, # Joern CPG export
|
|
28
|
+
edges_data=joern_edges, # Joern CPG export
|
|
29
|
+
nodes_path="s3://bucket/cpg-exports/my-service/build-456/nodes.json",
|
|
30
|
+
edges_path="s3://bucket/cpg-exports/my-service/build-456/edges.json",
|
|
31
|
+
graph_store=neptune_store,
|
|
32
|
+
write_fn=batch_write_function,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# result: {"status": "SKIPPED"} or {"status": "INGESTED", "delta": "+5 -2 ~3 =150"}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Graph Diff — Compare CPG States
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from codeproperty_graph import GraphDiff, CPGNode
|
|
42
|
+
|
|
43
|
+
# Compare current vs previous code analysis
|
|
44
|
+
diff = GraphDiff.compare(
|
|
45
|
+
current_nodes=current_cpg_nodes,
|
|
46
|
+
previous_nodes=previous_cpg_nodes,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
print(f"Added: {len(diff.added)}")
|
|
50
|
+
print(f"Removed: {len(diff.removed)}")
|
|
51
|
+
print(f"Modified: {len(diff.modified)}")
|
|
52
|
+
print(f"Unchanged: {len(diff.unchanged)}")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Manifest Management
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from codeproperty_graph import ManifestManager
|
|
59
|
+
|
|
60
|
+
# Track CPG state per repository in S3
|
|
61
|
+
manager = ManifestManager(bucket="graphrag-artifacts-705909755305")
|
|
62
|
+
|
|
63
|
+
# Save manifest after successful ingestion
|
|
64
|
+
await manager.save(repo="my-service", job_id="build-456", signatures=method_signatures)
|
|
65
|
+
|
|
66
|
+
# Load previous manifest for diff comparison
|
|
67
|
+
previous = await manager.load(repo="my-service")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Package Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/codeproperty_graph/
|
|
74
|
+
├── __init__.py # Public API: CPGNode, CPGEdge, DeltaIngestor, etc.
|
|
75
|
+
├── models.py # CPGNode, CPGEdge, Manifest — Joern-specific types
|
|
76
|
+
├── graph_diff.py # Compare two CPG states by method signature
|
|
77
|
+
├── manifest_manager.py # S3-backed state tracking per repository
|
|
78
|
+
├── delta_ingestor.py # Skip-or-replace orchestration with tenant purge
|
|
79
|
+
└── tenant_ops.py # Clean lifecycle management (delete_tenant)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Integration
|
|
83
|
+
|
|
84
|
+
### Architecture Stack
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
┌─────────────────────────────────────────────────────┐
|
|
88
|
+
│ codeproperty-graph (this package) │
|
|
89
|
+
│ Joern/Semgrep CPG, delta ingestion, risk scoring │
|
|
90
|
+
├─────────────────────────────────────────────────────┤
|
|
91
|
+
│ document-graph (infra) │
|
|
92
|
+
│ Node, Edge, CypherBuilder, PipelineExecutor │
|
|
93
|
+
│ Multi-tenancy, batch operations │
|
|
94
|
+
├─────────────────────────────────────────────────────┤
|
|
95
|
+
│ graphrag-toolkit-lexical-graph (foundation) │
|
|
96
|
+
│ GraphStore, Neptune writer, AOSS writer │
|
|
97
|
+
│ Lexical indexing, entity resolution, retrieval │
|
|
98
|
+
└─────────────────────────────────────────────────────┘
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Delta Logic
|
|
102
|
+
|
|
103
|
+
1. Joern exports CPG → `nodes.json` + `edges.json`
|
|
104
|
+
2. Extract METHOD node signatures: `{full_name: hash}`
|
|
105
|
+
3. Compare against previous manifest in S3
|
|
106
|
+
4. If identical → **SKIP** (no Neptune writes, saves cost)
|
|
107
|
+
5. If changed → **INGEST** full graph under new tenant, purge old tenant, update manifest
|
|
108
|
+
|
|
109
|
+
### With Document Graph
|
|
110
|
+
|
|
111
|
+
Code Property Graph uses document-graph for typed property graph primitives:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
# document-graph provides the graph write infrastructure
|
|
115
|
+
from graphrag_toolkit.document_graph.graph_build.cypher_builder import CypherBuilder
|
|
116
|
+
from graphrag_toolkit.document_graph import Node, Edge
|
|
117
|
+
|
|
118
|
+
# codeproperty-graph adds CPG-specific semantics on top
|
|
119
|
+
from codeproperty_graph import CPGNode, CPGEdge
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### AI Vulnerability Enrichment
|
|
123
|
+
|
|
124
|
+
After CPG ingestion, enrich with AI-powered vulnerability analysis:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# Query Neptune for high-risk patterns
|
|
128
|
+
# Score methods by complexity, dependency depth, and known CVE proximity
|
|
129
|
+
# Annotate graph with risk scores for downstream consumption
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Requirements
|
|
133
|
+
|
|
134
|
+
- Python >= 3.11
|
|
135
|
+
- `document-graph >= 0.1.0`
|
|
136
|
+
- `boto3 >= 1.26.0`
|
|
137
|
+
- Optional: `graphrag-toolkit-lexical-graph >= 3.18.0`
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
142
|
+
|
|
143
|
+
See [NOTICE](NOTICE) for third-party acknowledgments.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# codeproperty-graph — Dependency Architecture
|
|
2
|
+
|
|
3
|
+
## Library Stack
|
|
4
|
+
|
|
5
|
+
```mermaid
|
|
6
|
+
graph TD
|
|
7
|
+
CPG[codeproperty-graph 0.1.0] --> DG[document-graph 3.0.7]
|
|
8
|
+
DG --> GRT[graphrag-toolkit / lexical-graph 3.18.5]
|
|
9
|
+
GRT --> Neptune[(Amazon Neptune)]
|
|
10
|
+
GRT --> AOSS[(OpenSearch Serverless)]
|
|
11
|
+
CPG --> S3[(Amazon S3)]
|
|
12
|
+
CPG --> Boto3[boto3]
|
|
13
|
+
DG --> Boto3
|
|
14
|
+
DG --> Pydantic
|
|
15
|
+
DG --> NetworkX
|
|
16
|
+
DG --> Pandas
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## HELPER Services That Use This Stack
|
|
20
|
+
|
|
21
|
+
```mermaid
|
|
22
|
+
graph LR
|
|
23
|
+
subgraph "ECS Fargate — ccms-cluster"
|
|
24
|
+
GH[GraphRAG Helper<br/>graphrag.ccms.local:8080]
|
|
25
|
+
JH[Joern CPG Helper<br/>joern-cpg-sidecar]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
subgraph "Libraries (installed in containers)"
|
|
29
|
+
CPG[codeproperty-graph]
|
|
30
|
+
DG[document-graph]
|
|
31
|
+
LG[lexical-graph]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
subgraph "Storage"
|
|
35
|
+
Neptune[(Neptune)]
|
|
36
|
+
S3[(S3: graphrag-artifacts)]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
GH -->|imports| CPG
|
|
40
|
+
GH -->|imports| DG
|
|
41
|
+
GH -->|imports| LG
|
|
42
|
+
JH -->|imports| CPG
|
|
43
|
+
|
|
44
|
+
GH -->|writes nodes/edges| Neptune
|
|
45
|
+
GH -->|reads/writes manifests| S3
|
|
46
|
+
JH -->|writes CPG JSON| S3
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## A2A Agents (AgentCore) and Their Dependencies
|
|
50
|
+
|
|
51
|
+
```mermaid
|
|
52
|
+
graph TD
|
|
53
|
+
subgraph "AgentCore Runtime (A2A Protocol)"
|
|
54
|
+
CPA[cpg-agent<br/>cpgagent_cpg_agent]
|
|
55
|
+
NIA[neptune-ingest-agent<br/>neptuneingestagent]
|
|
56
|
+
GQA[graph-query-agent<br/>graphqueryagent]
|
|
57
|
+
GIA[graph-index-agent<br/>graphindexagent]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
subgraph "HELPER Services (backends)"
|
|
61
|
+
JH[Joern CPG Helper]
|
|
62
|
+
GH[GraphRAG Helper]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
subgraph "Libraries"
|
|
66
|
+
CPG[codeproperty-graph<br/><i>DeltaIngestor, ManifestManager<br/>GraphDiff, tenant_ops</i>]
|
|
67
|
+
DG[document-graph<br/><i>Node, Edge, batch_*_unwind<br/>CypherBuilder</i>]
|
|
68
|
+
LG[lexical-graph<br/><i>GraphStore, NeptuneWriter<br/>LexicalGraphIndex</i>]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
subgraph "Storage"
|
|
72
|
+
S3[(S3<br/>cpg-exports/REPO/manifest.json<br/>nodes.json, edges.json)]
|
|
73
|
+
Neptune[(Neptune<br/>CPG nodes + edges<br/>tenant-scoped)]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
CPA -->|delegates to| JH
|
|
77
|
+
NIA -->|delegates to| GH
|
|
78
|
+
GQA -->|delegates to| GH
|
|
79
|
+
GIA -->|delegates to| GH
|
|
80
|
+
|
|
81
|
+
JH -->|uses| CPG
|
|
82
|
+
JH -->|writes| S3
|
|
83
|
+
GH -->|uses| CPG
|
|
84
|
+
GH -->|uses| DG
|
|
85
|
+
GH -->|uses| LG
|
|
86
|
+
GH -->|writes| Neptune
|
|
87
|
+
GH -->|reads/writes| S3
|
|
88
|
+
|
|
89
|
+
CPG -.->|depends on| DG
|
|
90
|
+
DG -.->|depends on| LG
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Delta Ingest Flow (P4)
|
|
94
|
+
|
|
95
|
+
```mermaid
|
|
96
|
+
sequenceDiagram
|
|
97
|
+
participant User
|
|
98
|
+
participant RUN as AI-RUN (workflow engine)
|
|
99
|
+
participant CPA as cpg-agent (A2A)
|
|
100
|
+
participant JH as Joern Helper
|
|
101
|
+
participant S3
|
|
102
|
+
participant NIA as neptune-ingest-agent (A2A)
|
|
103
|
+
participant GH as GraphRAG Helper
|
|
104
|
+
participant Neptune
|
|
105
|
+
|
|
106
|
+
User->>RUN: Run cpg-pipeline (repo=amigo-core.zip)
|
|
107
|
+
RUN->>CPA: analyze_repo(repo_s3_uri)
|
|
108
|
+
CPA->>JH: /export
|
|
109
|
+
JH->>JH: joern-parse → joern-export → parse CSVs
|
|
110
|
+
JH->>S3: Write nodes.json + edges.json
|
|
111
|
+
JH->>JH: Compute method signatures (FULL_NAME + HASH)
|
|
112
|
+
JH->>S3: Write manifest.json (signature, job_id, method_sigs)
|
|
113
|
+
JH-->>CPA: output: s3://bucket/cpg-exports/amigo-core/JOB_ID/nodes.json
|
|
114
|
+
CPA-->>RUN: step result
|
|
115
|
+
|
|
116
|
+
RUN->>NIA: ingest_cpg(source_s3_uri)
|
|
117
|
+
NIA->>GH: /extract/structured
|
|
118
|
+
GH->>S3: Read nodes.json
|
|
119
|
+
GH->>S3: Read manifest.json (previous)
|
|
120
|
+
|
|
121
|
+
alt Signature matches (no code changes)
|
|
122
|
+
GH-->>NIA: SKIPPED - no_changes
|
|
123
|
+
else Signature differs (code changed)
|
|
124
|
+
GH->>Neptune: Write new nodes + edges (new tenant_id)
|
|
125
|
+
GH->>Neptune: DETACH DELETE old tenant
|
|
126
|
+
GH->>S3: Update manifest.json
|
|
127
|
+
GH-->>NIA: INGESTED - delta +2 -1 ~3 =150
|
|
128
|
+
end
|
|
129
|
+
NIA-->>RUN: step result
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## codeproperty-graph Module Structure
|
|
133
|
+
|
|
134
|
+
```mermaid
|
|
135
|
+
classDiagram
|
|
136
|
+
class CPGNode {
|
|
137
|
+
+id: str
|
|
138
|
+
+node_type: str
|
|
139
|
+
+full_name: str
|
|
140
|
+
+hash: str
|
|
141
|
+
+filename: str
|
|
142
|
+
+signature: str
|
|
143
|
+
+stable_id: str
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
class CPGEdge {
|
|
147
|
+
+source_id: str
|
|
148
|
+
+target_id: str
|
|
149
|
+
+edge_type: str
|
|
150
|
+
+properties: dict
|
|
151
|
+
+key: str
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
class Manifest {
|
|
155
|
+
+repo: str
|
|
156
|
+
+signature: str
|
|
157
|
+
+job_id: str
|
|
158
|
+
+tenant_id: str
|
|
159
|
+
+method_signatures: dict
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
class GraphDiff {
|
|
163
|
+
+compare(previous, current): DiffResult
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class DiffResult {
|
|
167
|
+
+added: dict
|
|
168
|
+
+removed: dict
|
|
169
|
+
+modified: dict
|
|
170
|
+
+unchanged: int
|
|
171
|
+
+has_changes: bool
|
|
172
|
+
+summary: str
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
class ManifestManager {
|
|
176
|
+
+compute_signature(method_sigs): str
|
|
177
|
+
+get(repo): Manifest
|
|
178
|
+
+put(manifest): void
|
|
179
|
+
+has_changes(repo, sigs): tuple
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
class DeltaIngestor {
|
|
183
|
+
+ingest(repo, job_id, nodes, edges, ...): dict
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
DeltaIngestor --> ManifestManager
|
|
187
|
+
DeltaIngestor --> GraphDiff
|
|
188
|
+
DeltaIngestor --> Manifest
|
|
189
|
+
GraphDiff --> DiffResult
|
|
190
|
+
ManifestManager --> Manifest
|
|
191
|
+
|
|
192
|
+
note for CPGNode "Identity: full_name\nChange detection: hash\nFrom Joern CPG spec"
|
|
193
|
+
note for CPGEdge "Types: AST, CFG, CDG,\nREACHING_DEF, CALL,\nARGUMENT, DOMINATE"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Relationship to Platform
|
|
197
|
+
|
|
198
|
+
```mermaid
|
|
199
|
+
graph TB
|
|
200
|
+
subgraph "AI-RUN (cyber-agentic.com)"
|
|
201
|
+
Builder[Builder Tab]
|
|
202
|
+
Workflows[Workflows Tab]
|
|
203
|
+
Agents[Agent Registry]
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
subgraph "AI-GOV (cyber-ai-governance.com)"
|
|
207
|
+
Assets[AI Assets]
|
|
208
|
+
Trace[AIGP Trace]
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
subgraph "A2A Agents"
|
|
212
|
+
CPA[cpg-agent]
|
|
213
|
+
NIA[neptune-ingest-agent]
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
subgraph "Libraries"
|
|
217
|
+
CPG[codeproperty-graph]
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
Builder -->|creates workflows using| CPA
|
|
221
|
+
Builder -->|creates workflows using| NIA
|
|
222
|
+
Workflows -->|executes| CPA
|
|
223
|
+
Workflows -->|executes| NIA
|
|
224
|
+
Agents -->|registers + names| CPA
|
|
225
|
+
Agents -->|registers + names| NIA
|
|
226
|
+
CPA -->|uses internally| CPG
|
|
227
|
+
NIA -->|uses internally| CPG
|
|
228
|
+
Assets -->|discovers| CPA
|
|
229
|
+
Assets -->|discovers| NIA
|
|
230
|
+
Trace -->|traces invocations of| CPA
|
|
231
|
+
Trace -->|traces invocations of| NIA
|
|
232
|
+
```
|