Skip to content

Commit 2c76e57

Browse files
committed
Introduce neo4j-management domain
1 parent dd35c1b commit 2c76e57

28 files changed

Lines changed: 725 additions & 307 deletions
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Plan: Introduce neo4j-management Domain
2+
3+
Create `domains/neo4j-management/` containing all scripts, configs, and tests for installing, configuring, starting, and stopping Neo4j. Move 15 files (10 shell scripts + 5 configuration templates) into the domain. Keep profiles in `scripts/profiles/` and jQAssistant YAML templates in `scripts/configuration/`. Update all references. Create a README with agent-friendly examples.
4+
5+
---
6+
7+
### Phase 1 — Create Domain Structure & Move Files
8+
9+
1. Create `domains/neo4j-management/` with a `configuration/` subdirectory
10+
2. Move **10 shell scripts** from `scripts/``domains/neo4j-management/`:
11+
- [setupNeo4j.sh](scripts/setupNeo4j.sh), [setupNeo4jInitialPassword.sh](scripts/setupNeo4jInitialPassword.sh), [configureNeo4j.sh](scripts/configureNeo4j.sh)
12+
- [startNeo4j.sh](scripts/startNeo4j.sh), [stopNeo4j.sh](scripts/stopNeo4j.sh)
13+
- [detectNeo4j.sh](scripts/detectNeo4j.sh), [detectNeo4jWindows.sh](scripts/detectNeo4jWindows.sh)
14+
- [waitForNeo4jHttpFunctions.sh](scripts/waitForNeo4jHttpFunctions.sh), [useNeo4jHighMemoryProfile.sh](scripts/useNeo4jHighMemoryProfile.sh)
15+
- [testConfigureNeo4j.sh](scripts/testConfigureNeo4j.sh)
16+
3a. Replace [scripts/startNeo4j.sh](scripts/startNeo4j.sh) and [scripts/stopNeo4j.sh](scripts/stopNeo4j.sh) with **minimal redirect stubs** for backward compatibility with existing projects that have forwarding scripts pointing to the old location. The stubs must not be referenced by any new code; they exist solely to avoid breaking old workspaces. Each stub contains only:
17+
```bash
18+
#!/usr/bin/env bash
19+
# Deprecated: moved to domains/neo4j-management/. This stub exists for backward compatibility only.
20+
source "$(dirname -- "${BASH_SOURCE[0]}")/../domains/neo4j-management/$(basename -- "${BASH_SOURCE[0]}")" "${@}"
21+
```
22+
3. Move **5 neo4j.conf templates** from `scripts/configuration/``domains/neo4j-management/configuration/`:
23+
- `template-neo4j.conf`, `template-neo4j-high-memory.conf`, `template-neo4j-low-memory.conf`, `template-neo4j-v4.conf`, `template-neo4j-v4-low-memory.conf`
24+
25+
### Phase 2 — Update Internal References (within moved scripts)
26+
27+
4. Add `NEO4J_MANAGEMENT_DIR` resolution to each moved script (same pattern as `DOMAIN_SCRIPT_DIR` in other domains), keeping a `SCRIPTS_DIR` fallback for shared utilities like `download.sh` and `operatingSystemFunctions.sh`
28+
5. Update `configureNeo4j.sh` — resolve config templates from `domains/neo4j-management/configuration/` instead of `scripts/configuration/`
29+
6. Update `setupNeo4j.sh` — source `configureNeo4j.sh` and `setupNeo4jInitialPassword.sh` from co-located directory
30+
7. Update the moved `startNeo4j.sh` and `stopNeo4j.sh` in the domain — source `waitForNeo4jHttpFunctions.sh` from the co-located directory
31+
8. Update `useNeo4jHighMemoryProfile.sh` — source `configureNeo4j.sh` from co-located directory
32+
9. Update `testConfigureNeo4j.sh` — source `configureNeo4j.sh` from co-located directory
33+
34+
### Phase 3 — Update External Callers
35+
36+
10. Update [scripts/analysis/analyze.sh](scripts/analysis/analyze.sh) — source `setupNeo4j.sh`, `startNeo4j.sh`, `stopNeo4j.sh` from `${DOMAINS_DIRECTORY}/neo4j-management/` (already resolves `DOMAINS_DIRECTORY`) *(critical path)*
37+
11. Update [init.sh](init.sh) — change forwarding script paths for `startNeo4j.sh` and `stopNeo4j.sh` from `./../../scripts/` to `./../../domains/neo4j-management/`. The redirect stubs in `scripts/` ensure old workspaces (where `init.sh` was already run before this change) still work without any manual migration.
38+
12. Check [scripts/resetAndScan.sh](scripts/resetAndScan.sh) — references `template-neo4j` for jQAssistant YAML path resolution; verify this is about jQAssistant templates (which stay) not neo4j.conf templates
39+
40+
### Phase 4 — Update Documentation
41+
42+
13. Update [COMMANDS.md](COMMANDS.md) — fix links to `setupNeo4j.sh`, `configureNeo4j.sh`, `stopNeo4j.sh`, `useNeo4jHighMemoryProfile.sh`, and configuration template references
43+
14. Update [README.md](README.md) — fix `useNeo4jHighMemoryProfile.sh` usage examples (lines ~304–307)
44+
15. Update [.github/prompts/plan-coding_agent_instructions.prompt.md](.github/prompts/plan-coding_agent_instructions.prompt.md) — fix `startNeo4j.sh` reference
45+
16. Update [scripts/SCRIPTS.md](scripts/SCRIPTS.md) — remove moved script entries (or regenerate via `generateScriptReference.sh`)
46+
17. Add [CHANGELOG.md](CHANGELOG.md) entry for the domain creation
47+
48+
### Phase 5 — Verify Renovate Patterns
49+
50+
18. Verify [renovate.json](renovate.json) — 5 regex managers use `^scripts/profiles/Neo4j-latest.*\\.sh$` and `^scripts/[^/]*\\.sh$`. Since profiles stay in `scripts/profiles/`, no changes needed unless moved scripts contain `NEO4J_VERSION:-` defaults (unlikely — those are in profiles). *Parallel with Phase 4.*
51+
52+
### Phase 6 — Create README.md
53+
54+
19. Create `domains/neo4j-management/README.md` with:
55+
- Purpose & scope (install, configure, start, stop Neo4j)
56+
- Prerequisites (Java, `jq`, `NEO4J_INITIAL_PASSWORD`)
57+
- Quick-start examples for setting up, starting, stopping Neo4j
58+
- Environment variables reference
59+
- Configuration templates explanation
60+
- Agent-friendly structured instructions for future AGENTS.md / skill usage
61+
62+
---
63+
64+
### Relevant Files
65+
66+
**Move (15 files):** 10 scripts from `scripts/` + 5 templates from `scripts/configuration/` (listed above)
67+
68+
**Create (1 file):** `domains/neo4j-management/README.md`
69+
70+
**Replace with redirect stubs (2 files):** `scripts/startNeo4j.sh`, `scripts/stopNeo4j.sh` — replaced in-place with minimal stubs that forward to the domain; not deleted
71+
72+
**Update (9–11 files):** [analyze.sh](scripts/analysis/analyze.sh), [init.sh](init.sh), [scripts/runTests.sh](scripts/runTests.sh), [COMMANDS.md](COMMANDS.md), [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [scripts/SCRIPTS.md](scripts/SCRIPTS.md), [.github/prompts/plan-coding_agent_instructions.prompt.md](.github/prompts/plan-coding_agent_instructions.prompt.md), possibly [scripts/resetAndScan.sh](scripts/resetAndScan.sh) and [renovate.json](renovate.json)
73+
74+
**Stay in place:** All 11 profile scripts, 5 jQAssistant YAML templates, all query function scripts, `scripts/startNeo4j.sh` (as stub), `scripts/stopNeo4j.sh` (as stub)
75+
76+
---
77+
78+
### Verification
79+
80+
1. Update [scripts/runTests.sh](scripts/runTests.sh) — it currently discovers tests with `find "${SCRIPTS_DIR}" -type f -name 'test*.sh'`, searching only the `scripts/` directory. Extend it to also search `domains/` so that `testConfigureNeo4j.sh` in its new location is picked up automatically (and any future domain-level tests are discovered too).
81+
2. Run `./scripts/runTests.sh` from the repository root — verify that `testConfigureNeo4j.sh` is discovered and executed from its new domain location, and that all other tests still pass.
82+
3. Run `shellcheck` on all moved scripts
83+
4. Grep for old paths (`scripts/setupNeo4j|scripts/configureNeo4j|scripts/detectNeo4j|scripts/waitForNeo4j|scripts/useNeo4jHighMemory|scripts/setupNeo4jInitialPassword|scripts/testConfigureNeo4j`) — no stale references should remain. `scripts/startNeo4j.sh` and `scripts/stopNeo4j.sh` are intentionally kept as redirect stubs, so references to them from *outside* this repository (e.g., old workspace forwarding scripts) are expected and acceptable.
84+
5. Verify `init.sh` forwarding scripts point to new locations
85+
6. Verify Renovate regex patterns still match profile files
86+
87+
---
88+
89+
### Decisions
90+
91+
- **Profiles stay in `scripts/profiles/`** — they also contain jQAssistant settings (separate concern)
92+
- **jQAssistant YAML templates stay in `scripts/configuration/`** — not neo4j-specific
93+
- **No COPIED_FILES.md** — files are moved, not copied (clean cut)
94+
- **testConfigureNeo4j.sh moves** into the domain
95+
- **init.sh paths updated directly** — forwarding scripts created by `init.sh` point to the domain going forward
96+
- **`scripts/startNeo4j.sh` and `scripts/stopNeo4j.sh` replaced with redirect stubs** — they forward to the domain implementation; not referenced by any pipeline code after the change, but kept so old project workspaces (already initialised before this change) continue to work without migration
97+
- **No domain entry-point scripts** (`*Csv.sh`, `*Python.sh`) — this domain is infrastructure, not report generation
98+
99+
---
100+
101+
### Pros and Cons: Moving Query Functions
102+
103+
The query execution infrastructure (`executeQueryFunctions.sh`, `executeQuery.sh`, `parseCsvFunctions.sh`, `projectionFunctions.sh`) was evaluated for inclusion:
104+
105+
**Pros of moving:**
106+
- Cohesive grouping — all Neo4j interaction in one place
107+
- Agent-friendly — a single domain to fully operate Neo4j
108+
- Cleaner `scripts/` directory
109+
110+
**Cons of moving:**
111+
- **30+ consumer files need path changes** — every report script, every domain script, `prepareAnalysis.sh`, `importGit.sh`
112+
- **Cross-domain coupling** — other domains would now depend on neo4j-management, breaking vertical-slice independence where each domain only depends on `scripts/`
113+
- **Mixing concerns** — management (lifecycle) and query execution (runtime API) are different layers
114+
- **No benefit to consumers** — the functions are already a stable, well-abstracted API
115+
116+
**Recommendation:** Don't move query functions now. Keep neo4j-management focused on lifecycle management. Query functions could become a separate `neo4j-query-api` domain later if desired.

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
This document describes the changes to the Code Graph Analysis Pipeline. The changes are grouped by version and date. The latest version is at the top.
44

5+
## (unreleased) Introduce neo4j-management domain
6+
7+
### ✨ Highlight
8+
9+
* Introduce `domains/neo4j-management/` as a vertical-slice domain that owns all Neo4j lifecycle management (install, configure, start, stop).
10+
11+
### 🚀 Features
12+
13+
* Move Neo4j management scripts from `scripts/` to `domains/neo4j-management/`:
14+
`setupNeo4j.sh`, `setupNeo4jInitialPassword.sh`, `configureNeo4j.sh`, `startNeo4j.sh`, `stopNeo4j.sh`,
15+
`detectNeo4j.sh`, `detectNeo4jWindows.sh`, `waitForNeo4jHttpFunctions.sh`, `useNeo4jHighMemoryProfile.sh`, `testConfigureNeo4j.sh`
16+
* Move Neo4j configuration templates from `scripts/configuration/` to `domains/neo4j-management/configuration/`:
17+
`template-neo4j.conf`, `template-neo4j-high-memory.conf`, `template-neo4j-low-memory.conf`, `template-neo4j-v4.conf`, `template-neo4j-v4-low-memory.conf`
18+
* Keep `scripts/startNeo4j.sh` and `scripts/stopNeo4j.sh` as **backward-compatible redirect stubs** so existing analysis workspaces continue to work without migration.
19+
* Extend `runTests.sh` to also discover and run test scripts in `domains/` subdirectories.
20+
521
## v3.5.0 Select analysis domain and npm dev dependency awareness
622

723
### ✨ Highlight

COMMANDS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,22 @@ If any of the script are not allowed to be executed use `chmod +x ./scripts/` fo
204204

205205
### Setup Neo4j Graph Database
206206

207-
Use [setupNeo4j.sh](./scripts/setupNeo4j.sh) to download [Neo4j](https://neo4j.com/download-center) and install the plugins [APOC](https://neo4j.com/labs/apoc/4.4) and [Graph Data Science](https://neo4j.com/product/graph-data-science).
207+
Use [setupNeo4j.sh](./domains/neo4j-management/setupNeo4j.sh) to download [Neo4j](https://neo4j.com/download-center) and install the plugins [APOC](https://neo4j.com/labs/apoc/4.4) and [Graph Data Science](https://neo4j.com/product/graph-data-science).
208208
This script requires the environment variable NEO4J_INITIAL_PASSWORD to be set. It sets the initial password with a temporary `NEO4J_HOME` environment variable to not interfere with a possibly globally installed Neo4j installation.
209209

210210
### Change Neo4j configuration template
211211

212-
Use [configureNeo4j.sh](./scripts/configureNeo4j.sh) to apply a different Neo4j configuration template from the [scripts/configuration](./scripts/configuration/) directory. This can be useful to optimize Neo4j for different workloads. Example:
212+
Use [configureNeo4j.sh](./domains/neo4j-management/configureNeo4j.sh) to apply a different Neo4j configuration template from the [domains/neo4j-management/configuration](./domains/neo4j-management/configuration/) directory. This can be useful to optimize Neo4j for different workloads. Example:
213213

214214
```shell
215-
NEO4J_CONFIG_TEMPLATE=template-neo4j-high-memory.conf ./scripts/configureNeo4j.sh
215+
NEO4J_CONFIG_TEMPLATE=template-neo4j-high-memory.conf ./domains/neo4j-management/configureNeo4j.sh
216216
```
217217

218218
**Hint:** In case you want to switch to the high memory profile as in the example, there is a simpler solution. Just run `useNeo4jHighMemoryProfile.sh` from the analysis workspace directory which will set the environment variable `NEO4J_CONFIG_TEMPLATE` and run `configureNeo4j.sh` for you.
219219

220220
### Start Neo4j Graph Database
221221

222-
Use [startNeo4j.sh](./scripts/startNeo4j.sh) to start the locally installed [Neo4j](https://neo4j.com/download-center) Graph database.
222+
Use [startNeo4j.sh](./domains/neo4j-management/startNeo4j.sh) to start the locally installed [Neo4j](https://neo4j.com/download-center) Graph database.
223223
It runs the script with a temporary `NEO4J_HOME` environment variable to not interfere with a possibly globally installed Neo4j installation.
224224

225225
**Hint:** Within the analysis workspace directory you can simply run `startNeo4j.sh` directly without the `../../` prefix since the script is also available in the analysis workspace.
@@ -380,7 +380,7 @@ execute_cypher ./cypher/Get_Graph_Data_Science_Library_Version.cypher a=1
380380

381381
## Stop Neo4j
382382

383-
Use [stopNeo4j.sh](./scripts/stopNeo4j.sh) to stop the locally running Neo4j Graph Database. It does nothing if the database is already stopped. It runs the script with a temporary `NEO4J_HOME` environment variable to not interfere with a possibly globally installed Neo4j installation.
383+
Use [stopNeo4j.sh](./domains/neo4j-management/stopNeo4j.sh) to stop the locally running Neo4j Graph Database. It does nothing if the database is already stopped. It runs the script with a temporary `NEO4J_HOME` environment variable to not interfere with a possibly globally installed Neo4j installation.
384384

385385
**Hint:** Within the analysis workspace directory you can run `stopNeo4j.sh` directly without the `../../` prefix since the script is also directly available in the analysis workspace.
386386

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ The [Code Structure Analysis Pipeline](./.github/workflows/internal-java-code-an
304304
👉 Simply run `useNeo4jHighMemoryProfile.sh` in your analysis working directory, or:
305305

306306
```shell
307-
./../../scripts/useNeo4jHighMemoryProfile.sh
307+
./../../domains/neo4j-management/useNeo4jHighMemoryProfile.sh
308308
```
309309

310310
## 🕸 Web References

domains/neo4j-management/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Neo4j Management Domain
2+
3+
Owns the full lifecycle of the local Neo4j Graph Database: download, install, configure, start, and stop.
4+
5+
## When to use
6+
7+
**Normally you don't need this.** [`analyze.sh`](./../../scripts/analysis/analyze.sh) handles setup, start, and stop automatically. Environment variables are set by the profile (`--profile`) — no manual configuration needed.
8+
9+
Use this domain directly only for on-demand tasks outside a full analysis run:
10+
11+
- **Start / stop** Neo4j manually (e.g. after a reboot, or to free resources)
12+
- **Reconfigure** without re-running the full analysis (e.g. increase memory)
13+
- **Check** whether and where Neo4j is installed and running
14+
15+
> ⚠️ **Stop Neo4j before switching projects.** If Neo4j keeps running across projects, data from different projects can end up in the same database instance.
16+
17+
## Scripts
18+
19+
### Entry points
20+
21+
| Script | Purpose |
22+
|--------|---------|
23+
| [startNeo4j.sh](./startNeo4j.sh) | Start Neo4j and wait until it is queryable |
24+
| [stopNeo4j.sh](./stopNeo4j.sh) | Stop Neo4j gracefully |
25+
| [configureNeo4j.sh](./configureNeo4j.sh) | Apply a configuration template from `configuration/` |
26+
| [useNeo4jHighMemoryProfile.sh](./useNeo4jHighMemoryProfile.sh) | Apply the high-memory configuration template |
27+
| [detectNeo4j.sh](./detectNeo4j.sh) | Detect whether Neo4j is installed in the tools directory |
28+
| [detectNeo4jWindows.sh](./detectNeo4jWindows.sh) | Windows-specific detection helper |
29+
| [setupNeo4j.sh](./setupNeo4j.sh) | Install Neo4j with APOC and Graph Data Science — **called by `analyze.sh` automatically** |
30+
31+
### Internal helpers _(not for direct use)_
32+
33+
| Script | Purpose |
34+
|--------|---------|
35+
| [setupNeo4jInitialPassword.sh](./setupNeo4jInitialPassword.sh) | Set the initial Neo4j password (sourced by `setupNeo4j.sh`) |
36+
| [waitForNeo4jHttpFunctions.sh](./waitForNeo4jHttpFunctions.sh) | HTTP polling functions (sourced by `startNeo4j.sh` / `stopNeo4j.sh`) |
37+
38+
### Tests
39+
40+
| Script | Purpose |
41+
|--------|---------|
42+
| [testConfigureNeo4j.sh](./testConfigureNeo4j.sh) | Integration tests for `configureNeo4j.sh` |
43+
44+
## Configuration templates
45+
46+
Stored under `configuration/`. Select a template via `NEO4J_CONFIG_TEMPLATE` (set automatically by the profile in normal runs).
47+
48+
| Template | Use case |
49+
|----------|---------|
50+
| [template-neo4j.conf](./configuration/template-neo4j.conf) | Default (Neo4j v5) |
51+
| [template-neo4j-high-memory.conf](./configuration/template-neo4j-high-memory.conf) | Increased heap and page-cache for large graphs |
52+
| [template-neo4j-low-memory.conf](./configuration/template-neo4j-low-memory.conf) | Reduced memory for constrained environments |
53+
| [template-neo4j-v4.conf](./configuration/template-neo4j-v4.conf) | Default (Neo4j v4) |
54+
| [template-neo4j-v4-low-memory.conf](./configuration/template-neo4j-v4-low-memory.conf) | Low-memory (Neo4j v4) |
55+
56+
## On-demand examples
57+
58+
Run from an analysis workspace (e.g. `temp/MyProject`) using the workspace forwarding scripts, or from the repo root using the full path.
59+
60+
```shell
61+
export NEO4J_INITIAL_PASSWORD=my-secret
62+
63+
./startNeo4j.sh # start (workspace shortcut)
64+
./stopNeo4j.sh # stop (always do this before switching projects)
65+
./useNeo4jHighMemoryProfile.sh # reconfigure with high-memory template
66+
67+
# From the repo root:
68+
./domains/neo4j-management/startNeo4j.sh
69+
./domains/neo4j-management/stopNeo4j.sh
70+
```
71+
72+
## Environment variables
73+
74+
All variables are set automatically by `analyze.sh` via the selected profile in normal runs. See [`scripts/ENVIRONMENT_VARIABLES.md`](./../../scripts/ENVIRONMENT_VARIABLES.md) for the full generated reference.
75+
76+
| Variable | Default | Description |
77+
|----------|---------|-------------|
78+
| `NEO4J_INITIAL_PASSWORD` | _(required)_ | Initial password for the local Neo4j instance |
79+
| `NEO4J_VERSION` | _(set in profile)_ | Neo4j version to download/use |
80+
| `NEO4J_EDITION` | `community` | `community` or `enterprise` |
81+
| `NEO4J_HTTP_PORT` | `7474` | HTTP port |
82+
| `NEO4J_BOLT_PORT` | `7687` | Bolt protocol port |
83+
| `NEO4J_CONFIG_TEMPLATE` | `template-neo4j.conf` | Configuration template filename |
84+
| `TOOLS_DIRECTORY` | `tools` | Directory where Neo4j is installed |
85+
| `NEO4J_MANAGEMENT_DIR` | _(auto-resolved)_ | Absolute path to this domain directory |
86+
| `SCRIPTS_DIR` | _(auto-resolved)_ | Absolute path to the shared `scripts/` directory |

scripts/configuration/template-neo4j-high-memory.conf renamed to domains/neo4j-management/configuration/template-neo4j-high-memory.conf

File renamed without changes.

scripts/configuration/template-neo4j-low-memory.conf renamed to domains/neo4j-management/configuration/template-neo4j-low-memory.conf

File renamed without changes.

scripts/configuration/template-neo4j-v4-low-memory.conf renamed to domains/neo4j-management/configuration/template-neo4j-v4-low-memory.conf

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)