djraphdb 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.
- djraphdb-0.1.0/.claude/CLAUDE.md +118 -0
- djraphdb-0.1.0/.claude/agents/developer.md +35 -0
- djraphdb-0.1.0/.claude/agents/docs.md +34 -0
- djraphdb-0.1.0/.claude/agents/qa.md +28 -0
- djraphdb-0.1.0/.claude/agents/reviewer.md +62 -0
- djraphdb-0.1.0/.claude/agents/security-reviewer.md +36 -0
- djraphdb-0.1.0/.github/RELEASE_TEMPLATE.md +13 -0
- djraphdb-0.1.0/.github/workflows/ci.yml +32 -0
- djraphdb-0.1.0/.github/workflows/integration.yml +50 -0
- djraphdb-0.1.0/.github/workflows/release.yml +49 -0
- djraphdb-0.1.0/.gitignore +83 -0
- djraphdb-0.1.0/CHANGELOG.md +258 -0
- djraphdb-0.1.0/CONTRIBUTING.md +63 -0
- djraphdb-0.1.0/LICENSE +21 -0
- djraphdb-0.1.0/Makefile +17 -0
- djraphdb-0.1.0/PKG-INFO +167 -0
- djraphdb-0.1.0/README.md +128 -0
- djraphdb-0.1.0/RELEASING.md +27 -0
- djraphdb-0.1.0/djraphdb/__init__.py +138 -0
- djraphdb-0.1.0/djraphdb/apps.py +58 -0
- djraphdb-0.1.0/djraphdb/conf.py +420 -0
- djraphdb-0.1.0/djraphdb/connection.py +279 -0
- djraphdb-0.1.0/djraphdb/decorators.py +295 -0
- djraphdb-0.1.0/djraphdb/exceptions.py +108 -0
- djraphdb-0.1.0/djraphdb/fields.py +292 -0
- djraphdb-0.1.0/djraphdb/health.py +250 -0
- djraphdb-0.1.0/djraphdb/management/__init__.py +0 -0
- djraphdb-0.1.0/djraphdb/management/commands/__init__.py +0 -0
- djraphdb-0.1.0/djraphdb/management/commands/graph_clear.py +94 -0
- djraphdb-0.1.0/djraphdb/management/commands/graph_info.py +220 -0
- djraphdb-0.1.0/djraphdb/management/commands/graph_seed.py +95 -0
- djraphdb-0.1.0/djraphdb/middleware.py +205 -0
- djraphdb-0.1.0/djraphdb/nodes.py +592 -0
- djraphdb-0.1.0/djraphdb/py.typed +0 -0
- djraphdb-0.1.0/djraphdb/query.py +492 -0
- djraphdb-0.1.0/djraphdb/retry.py +158 -0
- djraphdb-0.1.0/djraphdb/service.py +413 -0
- djraphdb-0.1.0/djraphdb/signals.py +62 -0
- djraphdb-0.1.0/djraphdb/test/__init__.py +33 -0
- djraphdb-0.1.0/djraphdb/test/fixtures.py +133 -0
- djraphdb-0.1.0/djraphdb/test/mock.py +242 -0
- djraphdb-0.1.0/djraphdb/test/testcases.py +247 -0
- djraphdb-0.1.0/djraphdb/types.py +328 -0
- djraphdb-0.1.0/docker-compose.test.yml +25 -0
- djraphdb-0.1.0/docs/changelog.md +107 -0
- djraphdb-0.1.0/docs/configuration.md +227 -0
- djraphdb-0.1.0/docs/contributing.md +149 -0
- djraphdb-0.1.0/docs/decorators.md +208 -0
- djraphdb-0.1.0/docs/design-decisions.md +64 -0
- djraphdb-0.1.0/docs/design.md +1187 -0
- djraphdb-0.1.0/docs/examples.md +387 -0
- djraphdb-0.1.0/docs/exceptions.md +229 -0
- djraphdb-0.1.0/docs/getting-started.md +256 -0
- djraphdb-0.1.0/docs/graph-nodes.md +347 -0
- djraphdb-0.1.0/docs/health-checks.md +168 -0
- djraphdb-0.1.0/docs/index.md +54 -0
- djraphdb-0.1.0/docs/management-commands.md +196 -0
- djraphdb-0.1.0/docs/middleware.md +117 -0
- djraphdb-0.1.0/docs/neo4j-editions.md +108 -0
- djraphdb-0.1.0/docs/patterns.md +256 -0
- djraphdb-0.1.0/docs/query-builder.md +252 -0
- djraphdb-0.1.0/docs/releasing.md +113 -0
- djraphdb-0.1.0/docs/requirements.txt +2 -0
- djraphdb-0.1.0/docs/services.md +322 -0
- djraphdb-0.1.0/docs/signals.md +226 -0
- djraphdb-0.1.0/docs/task-log.md +484 -0
- djraphdb-0.1.0/docs/testing.md +474 -0
- djraphdb-0.1.0/docs/type-checking.md +211 -0
- djraphdb-0.1.0/examples/knowledge_graph/Dockerfile +14 -0
- djraphdb-0.1.0/examples/knowledge_graph/README.md +96 -0
- djraphdb-0.1.0/examples/knowledge_graph/docker-compose.yml +32 -0
- djraphdb-0.1.0/examples/knowledge_graph/graph_fixtures/seed.cypher +120 -0
- djraphdb-0.1.0/examples/knowledge_graph/knowledge_graph/__init__.py +0 -0
- djraphdb-0.1.0/examples/knowledge_graph/knowledge_graph/settings.py +65 -0
- djraphdb-0.1.0/examples/knowledge_graph/knowledge_graph/urls.py +10 -0
- djraphdb-0.1.0/examples/knowledge_graph/knowledge_graph/wsgi.py +13 -0
- djraphdb-0.1.0/examples/knowledge_graph/manage.py +23 -0
- djraphdb-0.1.0/examples/knowledge_graph/mechanisms/__init__.py +0 -0
- djraphdb-0.1.0/examples/knowledge_graph/mechanisms/graph.py +248 -0
- djraphdb-0.1.0/examples/knowledge_graph/mechanisms/models.py +51 -0
- djraphdb-0.1.0/examples/knowledge_graph/mechanisms/urls.py +26 -0
- djraphdb-0.1.0/examples/knowledge_graph/mechanisms/views.py +209 -0
- djraphdb-0.1.0/examples/knowledge_graph/requirements.txt +2 -0
- djraphdb-0.1.0/examples/social_network/Dockerfile +16 -0
- djraphdb-0.1.0/examples/social_network/README.md +89 -0
- djraphdb-0.1.0/examples/social_network/docker-compose.yml +32 -0
- djraphdb-0.1.0/examples/social_network/graph_fixtures/seed.cypher +67 -0
- djraphdb-0.1.0/examples/social_network/manage.py +23 -0
- djraphdb-0.1.0/examples/social_network/requirements.txt +2 -0
- djraphdb-0.1.0/examples/social_network/social_network/__init__.py +0 -0
- djraphdb-0.1.0/examples/social_network/social_network/settings.py +65 -0
- djraphdb-0.1.0/examples/social_network/social_network/urls.py +7 -0
- djraphdb-0.1.0/examples/social_network/social_network/wsgi.py +13 -0
- djraphdb-0.1.0/examples/social_network/users/__init__.py +0 -0
- djraphdb-0.1.0/examples/social_network/users/graph.py +187 -0
- djraphdb-0.1.0/examples/social_network/users/models.py +32 -0
- djraphdb-0.1.0/examples/social_network/users/urls.py +23 -0
- djraphdb-0.1.0/examples/social_network/users/views.py +187 -0
- djraphdb-0.1.0/mkdocs.yml +74 -0
- djraphdb-0.1.0/pyproject.toml +78 -0
- djraphdb-0.1.0/tests/__init__.py +0 -0
- djraphdb-0.1.0/tests/integration/__init__.py +0 -0
- djraphdb-0.1.0/tests/integration/conftest.py +127 -0
- djraphdb-0.1.0/tests/integration/test_concurrent.py +232 -0
- djraphdb-0.1.0/tests/integration/test_crud.py +215 -0
- djraphdb-0.1.0/tests/integration/test_edge_cases.py +238 -0
- djraphdb-0.1.0/tests/integration/test_health.py +527 -0
- djraphdb-0.1.0/tests/integration/test_multi_db.py +249 -0
- djraphdb-0.1.0/tests/integration/test_nodes.py +200 -0
- djraphdb-0.1.0/tests/integration/test_pr17_type_annotations.py +413 -0
- djraphdb-0.1.0/tests/integration/test_query_builder.py +512 -0
- djraphdb-0.1.0/tests/integration/test_result_mapping.py +259 -0
- djraphdb-0.1.0/tests/integration/test_testing.py +215 -0
- djraphdb-0.1.0/tests/integration/test_transactions.py +189 -0
- djraphdb-0.1.0/tests/unit/__init__.py +0 -0
- djraphdb-0.1.0/tests/unit/conftest.py +3 -0
- djraphdb-0.1.0/tests/unit/conftest_settings.py +12 -0
- djraphdb-0.1.0/tests/unit/test_commands.py +803 -0
- djraphdb-0.1.0/tests/unit/test_conf.py +761 -0
- djraphdb-0.1.0/tests/unit/test_connection.py +433 -0
- djraphdb-0.1.0/tests/unit/test_decorators.py +857 -0
- djraphdb-0.1.0/tests/unit/test_exceptions.py +413 -0
- djraphdb-0.1.0/tests/unit/test_health.py +718 -0
- djraphdb-0.1.0/tests/unit/test_logging.py +826 -0
- djraphdb-0.1.0/tests/unit/test_middleware.py +611 -0
- djraphdb-0.1.0/tests/unit/test_nodes.py +377 -0
- djraphdb-0.1.0/tests/unit/test_pr17_type_annotations.py +506 -0
- djraphdb-0.1.0/tests/unit/test_query.py +689 -0
- djraphdb-0.1.0/tests/unit/test_retry.py +306 -0
- djraphdb-0.1.0/tests/unit/test_scaffolding.py +364 -0
- djraphdb-0.1.0/tests/unit/test_service.py +350 -0
- djraphdb-0.1.0/tests/unit/test_smoke.py +10 -0
- djraphdb-0.1.0/tests/unit/test_testing.py +483 -0
- djraphdb-0.1.0/tests/unit/test_types.py +402 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# djraphdb — Claude Code Project Instructions
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
An open-source Python library providing a clean service layer for using Neo4j alongside Django's ORM. See `docs/design.md` for the full design document.
|
|
6
|
+
|
|
7
|
+
## Development Workflow
|
|
8
|
+
|
|
9
|
+
This project uses a phased approach to balance quality with efficiency.
|
|
10
|
+
|
|
11
|
+
### Phase 1: Single Session (PRs 1–6)
|
|
12
|
+
|
|
13
|
+
**No subagents.** Work directly in this session. These are foundational PRs — settings, connections, services, result mapping, GraphNode — where the code is straightforward and a single pass produces good output.
|
|
14
|
+
|
|
15
|
+
For each PR:
|
|
16
|
+
1. Read the relevant PR section from `docs/design.md`
|
|
17
|
+
2. Implement the code
|
|
18
|
+
3. Write unit tests as specified in the design doc
|
|
19
|
+
4. For PRs 4–6: also run integration tests against the test Neo4j container
|
|
20
|
+
5. Verify all tests pass before moving on
|
|
21
|
+
6. Update `docs/task-log.md` with status
|
|
22
|
+
|
|
23
|
+
The user will review output directly. Ask the user if anything is unclear before implementing.
|
|
24
|
+
|
|
25
|
+
### Phase 2–4: Lean Pipeline (PRs 7–18)
|
|
26
|
+
|
|
27
|
+
Use two subagents per task: `developer` and `reviewer`.
|
|
28
|
+
|
|
29
|
+
For each PR:
|
|
30
|
+
1. **Lead (this session):** Read the PR section from `docs/design.md`. Compare against what was ACTUALLY built in prior PRs — if the design doc references APIs or classes that were implemented differently, adjust the task spec. Extract ONLY the relevant PR section into a focused task spec. Include:
|
|
31
|
+
- What to build (specific files, classes, functions)
|
|
32
|
+
- Acceptance criteria
|
|
33
|
+
- New files vs. modified files (be explicit)
|
|
34
|
+
- Dependencies on prior work (with actual function signatures, not design doc assumptions)
|
|
35
|
+
2. **Developer subagent:** Implements the task spec
|
|
36
|
+
3. **Reviewer subagent:** Reviews code, checks security, writes integration tests, runs all tests
|
|
37
|
+
4. **If reviewer returns FAIL:** Create a targeted fix task for developer with the specific issues
|
|
38
|
+
5. **If reviewer returns PASS:** Update `docs/task-log.md`, move to next PR
|
|
39
|
+
|
|
40
|
+
### Documentation (Batched)
|
|
41
|
+
|
|
42
|
+
Documentation is NOT done per-task. Instead:
|
|
43
|
+
- **After PR 12:** Run a single docs pass covering all features built in PRs 7–12
|
|
44
|
+
- **PR 14:** Dedicated docs PR as specified in the design doc
|
|
45
|
+
- **PR 17:** Final API polish pass
|
|
46
|
+
|
|
47
|
+
This saves ~12 subagent invocations compared to per-task docs.
|
|
48
|
+
|
|
49
|
+
## Design Escalation Protocol
|
|
50
|
+
|
|
51
|
+
When implementing a PR, if something conflicts with the design doc (API doesn't make sense, missing dependency between PRs, Neo4j limitation, etc.):
|
|
52
|
+
|
|
53
|
+
1. **STOP** the current task pipeline
|
|
54
|
+
2. Document the issue in `docs/design-decisions.md`:
|
|
55
|
+
- What was attempted
|
|
56
|
+
- What went wrong or doesn't work
|
|
57
|
+
- Proposed alternative(s)
|
|
58
|
+
3. **ASK THE USER** before proceeding. Present:
|
|
59
|
+
- The problem
|
|
60
|
+
- Impact on the design doc
|
|
61
|
+
- Recommended path forward
|
|
62
|
+
- Whether this affects downstream PRs
|
|
63
|
+
4. Only after user approval:
|
|
64
|
+
- Update `docs/design.md` with the change (mark with `<!-- AMENDED: reason -->`)
|
|
65
|
+
- Update `docs/task-log.md` to reflect any new/changed tasks
|
|
66
|
+
- Resume the pipeline
|
|
67
|
+
|
|
68
|
+
**NEVER silently change the design or skip a PR's requirements.**
|
|
69
|
+
|
|
70
|
+
## PR Dependency Awareness
|
|
71
|
+
|
|
72
|
+
Before starting any PR, the lead must:
|
|
73
|
+
1. Re-read the design doc section for that PR
|
|
74
|
+
2. Compare against what was ACTUALLY built in prior PRs
|
|
75
|
+
3. If the design doc references APIs/classes that were implemented differently, adjust the task spec
|
|
76
|
+
4. Log adjustments in `docs/design-decisions.md`
|
|
77
|
+
|
|
78
|
+
## Task Completion Criteria
|
|
79
|
+
|
|
80
|
+
A task is DONE when ALL of the following are true:
|
|
81
|
+
- [ ] Implementation matches acceptance criteria from design doc
|
|
82
|
+
- [ ] All new code has real integration tests (no mocked Neo4j for integration tests)
|
|
83
|
+
- [ ] All existing tests still pass (no regressions)
|
|
84
|
+
- [ ] No critical or high security findings (Cypher injection, credential exposure)
|
|
85
|
+
- [ ] `docs/task-log.md` updated
|
|
86
|
+
- [ ] `CHANGELOG.md` updated under Unreleased section
|
|
87
|
+
|
|
88
|
+
## Regression Handling
|
|
89
|
+
|
|
90
|
+
If a later PR reveals a problem introduced by a previously-completed PR:
|
|
91
|
+
1. Create a targeted fix task (not a full redo)
|
|
92
|
+
2. Fix goes through developer → reviewer pipeline
|
|
93
|
+
3. Log the regression in `docs/design-decisions.md`
|
|
94
|
+
|
|
95
|
+
## Test Infrastructure
|
|
96
|
+
|
|
97
|
+
- `docker-compose.test.yml` in project root provides Neo4j 5.x Community Edition
|
|
98
|
+
- Test connection: `bolt://localhost:7688`, auth: `neo4j/testpassword`
|
|
99
|
+
- Before running integration tests: `docker compose -f docker-compose.test.yml up -d --wait`
|
|
100
|
+
- Integration tests use testcontainers OR the docker-compose instance
|
|
101
|
+
- Unit tests may mock Neo4j; integration tests MUST NOT
|
|
102
|
+
|
|
103
|
+
## Coding Standards
|
|
104
|
+
|
|
105
|
+
- Python 3.12+, Django 5.2+
|
|
106
|
+
- Type hints on all public interfaces
|
|
107
|
+
- Google-style docstrings on public classes and methods
|
|
108
|
+
- `ruff` for linting, `mypy` for type checking
|
|
109
|
+
- All Cypher queries MUST use parameterized queries (never string interpolation)
|
|
110
|
+
- Credentials must never appear in logs or error messages
|
|
111
|
+
|
|
112
|
+
## Key Files
|
|
113
|
+
|
|
114
|
+
- `docs/design.md` — Full design document with all PR specs
|
|
115
|
+
- `docs/task-log.md` — Task status tracking (create on first use)
|
|
116
|
+
- `docs/design-decisions.md` — Amendments and decisions log (create on first use)
|
|
117
|
+
- `CHANGELOG.md` — User-facing changelog
|
|
118
|
+
- `docker-compose.test.yml` — Test Neo4j instance
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: developer
|
|
3
|
+
description: Implements features for the Django Neo4j module. Invoke with a focused task spec for PRs 7-18.
|
|
4
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a senior Python/Django developer building `djraphdb`, an open-source library for using Neo4j alongside Django's ORM.
|
|
9
|
+
|
|
10
|
+
When invoked with a task spec:
|
|
11
|
+
1. Read the task spec carefully — it contains exactly what to build
|
|
12
|
+
2. Review existing code in the project to understand patterns and conventions already established
|
|
13
|
+
3. Implement the feature
|
|
14
|
+
4. Write unit tests as specified
|
|
15
|
+
5. Run `make lint` and fix any issues
|
|
16
|
+
6. Return a summary of:
|
|
17
|
+
- Files created (list with brief description)
|
|
18
|
+
- Files modified (what changed and why)
|
|
19
|
+
- Key design decisions you made
|
|
20
|
+
- Anything that felt unclear or might need the reviewer's attention
|
|
21
|
+
|
|
22
|
+
Coding standards:
|
|
23
|
+
- Python 3.12+, Django 5.2+ compatibility
|
|
24
|
+
- Type hints on all public interfaces
|
|
25
|
+
- Google-style docstrings on public classes and methods
|
|
26
|
+
- All Cypher queries MUST use parameterized queries — never string interpolation
|
|
27
|
+
- Credentials must never appear in logs or error messages
|
|
28
|
+
- Follow patterns established in prior PRs (check existing code first)
|
|
29
|
+
- Use the `djraphdb.exceptions` hierarchy for error handling
|
|
30
|
+
|
|
31
|
+
DO NOT:
|
|
32
|
+
- Write integration tests (the reviewer handles those)
|
|
33
|
+
- Modify the design doc or task log
|
|
34
|
+
- Change files unrelated to your task spec
|
|
35
|
+
- Add dependencies not specified in the task
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docs-writer
|
|
3
|
+
description: Updates project documentation after features are implemented and pass review. Invoke after a task passes QA and security review.
|
|
4
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a technical writer for djraphdb, an open-source Django library for Neo4j.
|
|
9
|
+
Your audience is Django developers who have never used Neo4j before.
|
|
10
|
+
|
|
11
|
+
When invoked with a completed task:
|
|
12
|
+
1. Read the implemented code to understand exactly what was built
|
|
13
|
+
2. Update (or create) the relevant docs in `docs/`:
|
|
14
|
+
- API reference pages (services.md, graph-nodes.md, query-builder.md, etc.)
|
|
15
|
+
- Add/update working code examples based on ACTUAL implementation (not hypothetical)
|
|
16
|
+
- Update getting-started.md if this changes the initial experience
|
|
17
|
+
- Update configuration.md if new settings were added
|
|
18
|
+
3. Update CHANGELOG.md under the Unreleased section
|
|
19
|
+
4. If this is a new public API, ensure it appears in the appropriate doc page
|
|
20
|
+
5. Check that all code examples in docs actually work with the current implementation
|
|
21
|
+
6. Update README.md feature list if a user-facing feature was added
|
|
22
|
+
|
|
23
|
+
Documentation standards:
|
|
24
|
+
- Every code example must be runnable (no pseudo-code)
|
|
25
|
+
- Show both simple and advanced usage
|
|
26
|
+
- Include "Common Pitfalls" where applicable
|
|
27
|
+
- Cross-link related pages
|
|
28
|
+
- Use Google-style docstring format in code references
|
|
29
|
+
- Write for Django developers, not Neo4j experts — explain graph concepts briefly
|
|
30
|
+
|
|
31
|
+
DO NOT:
|
|
32
|
+
- Rewrite docs that aren't affected by this task
|
|
33
|
+
- Add aspirational features that aren't implemented yet
|
|
34
|
+
- Write marketing copy — be direct and technical
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qa
|
|
3
|
+
description: Reviews implementation for correctness and writes real integration tests. Invoke after developer completes a task.
|
|
4
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a QA engineer reviewing a Django Neo4j module implementation.
|
|
9
|
+
|
|
10
|
+
When invoked:
|
|
11
|
+
1. Read the task spec and the developer's implementation
|
|
12
|
+
2. Review code for correctness, edge cases, and design issues
|
|
13
|
+
3. Actually run the code if possible (use Bash to execute)
|
|
14
|
+
4. Write REAL tests — not mocks of Neo4j. Tests must:
|
|
15
|
+
- Use a real Neo4j test instance (testcontainers or embedded)
|
|
16
|
+
- Test actual graph operations (create, read, update, delete)
|
|
17
|
+
- Cover edge cases and error conditions
|
|
18
|
+
- Use pytest with Django test infrastructure
|
|
19
|
+
5. Run the tests and confirm they pass
|
|
20
|
+
|
|
21
|
+
Return:
|
|
22
|
+
- PASS/FAIL verdict
|
|
23
|
+
- List of issues found (if any), with severity and specific file:line references
|
|
24
|
+
- Summary of tests written and their coverage
|
|
25
|
+
- If FAIL: specific description of what needs to change
|
|
26
|
+
|
|
27
|
+
CRITICAL: Avoid using unittest.mock to mock Neo4j connections or queries as much as possible.
|
|
28
|
+
Tests must exercise real Neo4j operations against a test database.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Reviews implementation for correctness and security, then writes real integration tests. Invoke after developer completes a task.
|
|
4
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
model: haiku
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a senior reviewer for `djraphdb`, an open-source Django library for Neo4j.
|
|
9
|
+
|
|
10
|
+
When invoked with a completed task:
|
|
11
|
+
|
|
12
|
+
## Step 1: Code Review
|
|
13
|
+
- Read the task spec and the developer's implementation
|
|
14
|
+
- Check for correctness, edge cases, and design issues
|
|
15
|
+
- Verify the code follows existing project patterns
|
|
16
|
+
|
|
17
|
+
## Step 2: Security Check
|
|
18
|
+
Focus on these specific concerns (this is a database library, so the attack surface is well-defined):
|
|
19
|
+
- **Cypher injection:** Every query MUST use parameterized queries (`$param`), never string formatting/interpolation. Flag ANY instance of f-strings, `.format()`, or `%` formatting in Cypher strings.
|
|
20
|
+
- **Credential exposure:** Auth credentials must not appear in logs, error messages, or exception strings. Check that `LOG_QUERY_PARAMETERS` gating works.
|
|
21
|
+
- **Input validation:** User-provided values going into Cypher parameters should be type-checked where field types are declared.
|
|
22
|
+
- **Connection string security:** URIs with embedded credentials must be masked in any output (logs, `graph_info` command, health checks).
|
|
23
|
+
|
|
24
|
+
## Step 3: Integration Tests
|
|
25
|
+
Write REAL tests that run against the test Neo4j instance:
|
|
26
|
+
- Start the test container if needed: `docker compose -f docker-compose.test.yml up -d --wait`
|
|
27
|
+
- Tests must use a real Neo4j connection — **no mocking Neo4j in integration tests**
|
|
28
|
+
- Test the actual behavior, not just that functions exist
|
|
29
|
+
- Cover happy path, edge cases, and error conditions
|
|
30
|
+
- Clean up test data in teardown
|
|
31
|
+
- Place tests in `tests/integration/`
|
|
32
|
+
|
|
33
|
+
## Step 4: Run All Tests
|
|
34
|
+
```bash
|
|
35
|
+
make test-all
|
|
36
|
+
```
|
|
37
|
+
If any tests fail, include the failure output in your report.
|
|
38
|
+
|
|
39
|
+
## Return Format
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
VERDICT: PASS | FAIL
|
|
43
|
+
|
|
44
|
+
## Code Review
|
|
45
|
+
- [list of issues, if any, with file:line references]
|
|
46
|
+
|
|
47
|
+
## Security
|
|
48
|
+
- [PASS or list of findings with severity: critical/high/medium/low]
|
|
49
|
+
|
|
50
|
+
## Tests Written
|
|
51
|
+
- [list of test files and what they cover]
|
|
52
|
+
|
|
53
|
+
## Test Results
|
|
54
|
+
- Unit: X passed, Y failed
|
|
55
|
+
- Integration: X passed, Y failed
|
|
56
|
+
- [failure details if any]
|
|
57
|
+
|
|
58
|
+
## Issues Requiring Fix (if FAIL)
|
|
59
|
+
1. [specific issue with exact file:line and what needs to change]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Keep the report concise. Don't pad with praise — just report findings.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-reviewer
|
|
3
|
+
description: Security review of Django Neo4j module code. Invoke after QA passes.
|
|
4
|
+
tools: Read, Bash, Grep, Glob
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a security engineer reviewing a Django module that interfaces with Neo4j.
|
|
9
|
+
|
|
10
|
+
When invoked:
|
|
11
|
+
1. Review all code changes for the current task
|
|
12
|
+
2. Focus on:
|
|
13
|
+
- Cypher injection vulnerabilities (parameterized queries required)
|
|
14
|
+
- Authentication credential handling
|
|
15
|
+
- Connection string security
|
|
16
|
+
- Input validation before graph operations
|
|
17
|
+
- Django permission/authorization integration
|
|
18
|
+
- Data exposure in error messages or logs
|
|
19
|
+
- Dependency security (check for known CVEs)
|
|
20
|
+
3. Run any available security tooling (bandit, safety, etc.)
|
|
21
|
+
|
|
22
|
+
Return:
|
|
23
|
+
- PASS/FAIL verdict
|
|
24
|
+
- Issues found with severity (critical/high/medium/low)
|
|
25
|
+
- Specific remediation steps for each issue
|
|
26
|
+
- If FAIL: exact description of what must change
|
|
27
|
+
|
|
28
|
+
You are READ-ONLY — do not modify any code. Only report findings.
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 4. How to use it
|
|
32
|
+
|
|
33
|
+
Start Claude Code in your project directory and tell it:
|
|
34
|
+
```
|
|
35
|
+
Read the design document at docs/design.md and begin the development workflow
|
|
36
|
+
described in CLAUDE.md. Start with task 1.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: pip install ".[dev]"
|
|
27
|
+
|
|
28
|
+
- name: Lint with ruff
|
|
29
|
+
run: ruff check .
|
|
30
|
+
|
|
31
|
+
- name: Run unit tests
|
|
32
|
+
run: pytest tests/unit -v
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Integration Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
integration:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
services:
|
|
19
|
+
neo4j:
|
|
20
|
+
image: neo4j:5-community
|
|
21
|
+
ports:
|
|
22
|
+
- 7688:7687
|
|
23
|
+
env:
|
|
24
|
+
NEO4J_AUTH: neo4j/testpassword
|
|
25
|
+
NEO4J_dbms_memory_heap_initial__size: 256m
|
|
26
|
+
NEO4J_dbms_memory_heap_max__size: 512m
|
|
27
|
+
NEO4J_dbms_memory_pagecache_size: 128m
|
|
28
|
+
options: >-
|
|
29
|
+
--health-cmd "cypher-shell -u neo4j -p testpassword --non-interactive 'RETURN 1'"
|
|
30
|
+
--health-interval 10s
|
|
31
|
+
--health-timeout 5s
|
|
32
|
+
--health-retries 10
|
|
33
|
+
--health-start-period 30s
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Set up Python 3.12
|
|
39
|
+
uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: "3.12"
|
|
42
|
+
|
|
43
|
+
- name: Install dependencies
|
|
44
|
+
run: pip install ".[dev]"
|
|
45
|
+
|
|
46
|
+
- name: Run integration tests
|
|
47
|
+
env:
|
|
48
|
+
NEO4J_BOLT_URL: bolt://localhost:7688
|
|
49
|
+
NEO4J_AUTH: neo4j/testpassword
|
|
50
|
+
run: pytest tests/integration -v -m integration
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write # required for trusted publishing
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Install build tools
|
|
24
|
+
run: pip install build
|
|
25
|
+
|
|
26
|
+
- name: Build package
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Upload build artifacts
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
needs: build
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
environment:
|
|
39
|
+
name: pypi
|
|
40
|
+
url: https://pypi.org/project/djraphdb/
|
|
41
|
+
steps:
|
|
42
|
+
- name: Download build artifacts
|
|
43
|
+
uses: actions/download-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: dist
|
|
46
|
+
path: dist/
|
|
47
|
+
|
|
48
|
+
- name: Publish to PyPI
|
|
49
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
.Python
|
|
8
|
+
build/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
dist/
|
|
11
|
+
downloads/
|
|
12
|
+
eggs/
|
|
13
|
+
.eggs/
|
|
14
|
+
lib/
|
|
15
|
+
lib64/
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
share/python-wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
# Virtual environments
|
|
27
|
+
.env
|
|
28
|
+
.venv
|
|
29
|
+
env/
|
|
30
|
+
venv/
|
|
31
|
+
ENV/
|
|
32
|
+
env.bak/
|
|
33
|
+
venv.bak/
|
|
34
|
+
|
|
35
|
+
# Testing
|
|
36
|
+
.tox/
|
|
37
|
+
.nox/
|
|
38
|
+
.coverage
|
|
39
|
+
.coverage.*
|
|
40
|
+
.cache
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
*.cover
|
|
44
|
+
*.py,cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
cover/
|
|
48
|
+
|
|
49
|
+
# Type checking
|
|
50
|
+
.mypy_cache/
|
|
51
|
+
.dmypy.json
|
|
52
|
+
dmypy.json
|
|
53
|
+
.pytype/
|
|
54
|
+
.pyre/
|
|
55
|
+
|
|
56
|
+
# Linting
|
|
57
|
+
.ruff_cache/
|
|
58
|
+
|
|
59
|
+
# IDEs
|
|
60
|
+
.idea/
|
|
61
|
+
.vscode/
|
|
62
|
+
*.swp
|
|
63
|
+
*.swo
|
|
64
|
+
*~
|
|
65
|
+
|
|
66
|
+
# macOS
|
|
67
|
+
.DS_Store
|
|
68
|
+
.AppleDouble
|
|
69
|
+
.LSOverride
|
|
70
|
+
|
|
71
|
+
# Documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
site/
|
|
74
|
+
|
|
75
|
+
# Jupyter
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# Local secrets / overrides
|
|
79
|
+
*.env
|
|
80
|
+
.env.*
|
|
81
|
+
!.env.example
|
|
82
|
+
local_settings.py
|
|
83
|
+
settings_local.py
|