Commit 88ecec5
committed
fix(serve): invoke GraphBootstrapper directly instead of via dead ApplicationReadyEvent listener
GraphBootstrapper's H2->Neo4j fallback was registered for
@eventlistener(ApplicationReadyEvent.class), but that event never
fires during a normal serve run because ServeCommand.call() blocks
in Thread.join() as a CommandLineRunner. Consequence: if someone
shipped a bundle with only the H2 analysis cache (no enriched Neo4j
graph) and ran `code-iq serve`, Neo4j would stay empty forever and
graph-traversal queries would return nothing. Not observed in our
pipeline today only because `enrich` always runs before `serve`.
Fix:
- Drop @eventlistener from bootstrapNeo4jFromCache() and its
associated imports (ApplicationReadyEvent, @eventlistener).
- ServeCommand.call() now calls graphBootstrapper.bootstrapNeo4jFromCache()
explicitly before the Neo4j status report, so the advertised
node/edge counts reflect post-bootstrap state. Injection is
Optional since the bean only exists in the "serving" profile
(matches the existing @Profile + @ConditionalOnBean guards).
- Class javadoc updated to document the new invocation model and
the reason the event-listener path did not work.
The method is idempotent (guards on count>0 and on missing H2 file),
so moving the invocation is safe even in scenarios where Neo4j is
already populated by `enrich`.
Tests: existing GraphBootstrapperTest still passes unchanged (it calls
the method directly).
Integration verification:
# full pipeline to populate both H2 + Neo4j
./scripts/baseline/run-pipeline.sh spring-petclinic
# wipe ONLY Neo4j; keep H2
rm -rf .seeds/spring-petclinic/.code-iq/graph
# re-run serve
java -jar target/code-iq-*-cli.jar serve .seeds/spring-petclinic --port 18080 &
# wait for /actuator/health=200, then:
curl http://127.0.0.1:18080/api/stats
Before this fix: Neo4j empty, stats=0.
After this fix: log shows "Bootstrapped Neo4j with 634 nodes and
604 edges from H2 cache", /api/stats returns 677
nodes / 604 edges / 65 files.1 parent 3beafd9 commit 88ecec5
2 files changed
Lines changed: 21 additions & 4 deletions
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | | - | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
0 commit comments