惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
F
Full Disclosure
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
T
Threatpost
P
Privacy International News Feed
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
I
Intezer
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy & Cybersecurity Law Blog
A
Arctic Wolf
博客园 - 聂微东
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
H
Help Net Security
S
Schneier on Security
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Exploit Database - CXSecurity.com
T
Tor Project blog
月光博客
月光博客
NISL@THU
NISL@THU
A
About on SuperTechFans
Spread Privacy
Spread Privacy
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
G
Google Developers Blog
W
WeLiveSecurity
P
Palo Alto Networks Blog
The Last Watchdog
The Last Watchdog
K
Kaspersky official blog
博客园 - 司徒正美
L
LINUX DO - 热门话题
小众软件
小众软件

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders How to Switch AI Chatbots and Why You Might Want To GitHub - MattMessinger1/agentic_refund_guardrail: Safe refund policy layer for AI agents — Python + TypeScript. Same behavior, shared tests. Adam/papers/emergent_values_whitepaper.md at master · strangeadvancedmarketing/Adam Ask HN: How do you stop playing 20 questions with your AI coding tools How far can automation and AI support psychotherapy? - @theU GitHub - stagas/rtdiff: realtime git diff gui and AI-assisted commits A Mac Studio for Local AI — 6 Months Later A History of the Early Years of AI at the University of Edinburgh Why AI Coding Tools Still Feel Stuck on Localhost MSN AI Datacenters Are Becoming Strategic Targets twitter.com Penn Researchers Use AI to Surface Unreported GLP-1 Side Effects in Reddit Posts Show HN: MoodSense AI (ML and FastAPI and Gradio, Deployed on Hugging Face) Moodsense Ai - a Hugging Face Space by aman179102 AI models are terrible at betting on soccer—especially xAI Grok GitHub - xialeistudio/echoic GitHub - HimashaHerath/github-dev-wrapped: AI-powered weekly GitHub activity reports deployed to GitHub Pages GitHub - alejandrobalderas/claude-code-from-source: Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps AI and Tech brief: Ireland ascendant GitHub - Titovilal/context0: Context0 - Never Surrender Training for a Marathon with an AI Coach: What Worked and What Didn't Cyber Pulse: Agentic Intel - Apps on Google Play I Built an AI PR Reviewer That Catches Bugs by Not Looking for Bugs Gen Z workers are so fearful AI will take their job they’re intentionally sabotaging their company’s AI rollout | Fortune How AI Is Reimagining the Game of Golf–For Both Players and Courses GitHub - nattergabriel/reseed: A CLI tool for managing and distributing agent skills across projects Is SVG the final frontier? My AI workflow evolved from prompts to a near-autonomous workflow MLSharp Help - 3DGS Viewer & Generator I put my cognitive field based AI's runtime on GitHub Is Numble the first AI-proof game? A3: Kubernetes for autonomous AI agent fleets | Emergent Principles Deepali Vyas ("The Elite Recruiter") GitHub - msmarkgu/RelayFreeLLM: A restful API designed to route user prompts to various AI model providers. Unionized ProPublica staff are on strike over AI, layoffs, and wages Unleashing the Advantage of Quantum AI We're heading for an AI-fueled 'dementia crisis,' brain scientist warns The AI-Assisted Breach of Mexico's Government Infrastructure [pdf] GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. MSN GitHub - visionscaper/collabmem: Enabling long-term collaboration with Agentic AI - building up episodic and world model memory over time with in-context awareness We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs AI Code is Hollowing Out Open Source, and Maintainers are Looking the Other Way What leaked "SteamGPT" files could mean for the PC gaming platform's use of AI AI is the boss at this retail store. What could go wrong? GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce With Drones, Geophysics and ArtificiaI Intelligence, Researchers Prepare to Do Battle Against Land Mines A Single Operator, Two AI Platforms, Nine Government Agencies: The Full Technical Report 在 Steam 上购买 FriedrichAI: Offline AI 立省 10% GitHub - inevolin/resume-cli: Hit Claude usage limits? Resume any AI coding session elsewhere. Switch tools at zero friction. GitHub - atripati/ark: AI Runtime Kernel — a context operating system for AI agents. Eliminates tool bloat, loads only what’s needed, and gives LLMs their reasoning space back. How to Build a Secure AI PR Reviewer with Claude, GitHub Actions, and JavaScript This Startup Wants You to Pay Up to Talk With AI Versions of Human Experts Intel Arc Pro B70 Brings 32GB VRAM to Local AI for $949 WordPress 7.0: The Good, the AI, and the Still Missing AI on the couch: Anthropic gives Claude 20 hours of psychiatry IatroBench: Pre-Registered Evidence of Iatrogenic Harm from AI Safety Measures AI Agents Know About Supabase. They Don't Always Use It Right. The history and future of AI at Google, with Sundar Pichai Inside an AI‑enabled device code phishing campaign How Meta Used AI to Map Tribal Knowledge in Large-Scale Data Pipelines AI for Systems: Using LLMs to Optimize Database Query Execution Forecasting the Economic Effects of AI Introducing Tinker: Play with AI, bring your ideas to life AI sheds light on an ancient gaming mystery People really hate AI but not as much as Iran—or Democrats | Fortune What is an AI Product Engineer? Phoebe Gates wants her $185 million AI startup to succeed with 'no ties to my privilege or my last name': 'I have a chip on my shoulder' | Fortune
memgraph-ingester/README.md at main · ousatov-ua/memgraph-ingester
taubek · 2026-05-11 · via Hacker News - Newest: "AI"

Memgraph Ingester. Speed up your AI agent!

Build Maven Central License: MIT Visitors GitHub commits GitHub last commit

Ingests the structural model of a Java codebase into Memgraph as a queryable code + memory knowledge graph, combining source structure with persistent engineering context (decisions, rules, findings, etc.).

Optionally paired with the Memgraph MCP server, this enables you AI agent to reason over both code and accumulated project knowledge via graph queries instead of raw text search — improving accuracy, reducing cost, and speeding up analysis.

Having MCP configured is not required: mgconsole utility can be used to query the graph directly which also decreases tokens usage.

You can use the code in this repo as-is, or fork it and customize it to your needs. Memgraph is free too. Please submit any issues or pull requests.

What it does

Memgraph Ingester creates two project-scoped graphs for a Java codebase:

  • A Code graph under (:Project)-[:CONTAINS]->(:Code)
  • A Memory graph under (:Project)-[:HAS_MEMORY]->(:Memory)

Every code and memory node is scoped by a project property, so multiple Java codebases can share the same Memgraph instance without collisions.

The Code graph stores Java source structure in a queryable, persistent form. The ingester walks the source tree with JavaParser and symbol resolution, then writes packages, files, classes, interfaces, annotations, methods, fields, inheritance, and within-project call relationships.

The parser is configured for Java 25 syntax. It should handle most sources written for earlier Java versions too, but JavaParser is not a javac replacement and may still miss unsupported or edge-case constructs.

The Memory graph stores durable engineering context: decisions, ADRs, rules, findings, tasks, risks, questions, ideas, and domain notes. Memory items can refer to stable :CodeRef nodes, which are resolved back to the current code graph after ingestion. This lets agents query both structure (code) and knowledge (memory) without relying only on raw text search.

See doc/MEMORY.md for the Memory usage guide with prompt examples and Cypher recipes. See SCHEMA.md for the full graph model.

Requirements

  • Required: Java 25 JRE to run
  • Required: Memgraph instance (or Docker)
  • Optional: Java 25 SDK, Maven 3.9+ to build
  • Optional: mgconsole

Quick start

  • Download the latest jar (v6.0.7 the latest for now)
wget https://github.com/ousatov-ua/memgraph-ingester/releases/download/v6.0.7/memgraph-ingester.jar
  • Run Memgraph
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph-mage:3.9.0
  • Ingest the project:

Without classpath libs (weaker resolving):

cd /path/to/your/java/project
java -jar path/to/memgraph-ingester.jar \
  --source path/to/src \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code \
  --wipe-project-memories \
  --apply-schema

With classpath libs (better resolving). Example for Maven projects:

cd /path/to/your/java/project
CP=$(mvn -q dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=/dev/stdout 2>/dev/null)
java -jar path/to/memgraph-ingester.jar \
  --source path/to/src \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code \
  --wipe-project-memories \
  --apply-schema \
  --classpath "$CP"
  • Append knowledge for your agent
# GitHub Copilot
curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-github.sh \
  | bash -s -- my-project
# Claude
curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-claude.sh \
  | bash -s -- my-project
# Codex
curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-codex.sh \
  | bash -s -- my-project
# Gemini
curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-gemini.sh \
  | bash -s -- my-project
  • Enable MCP Memgraph for your AI agent (below you can find examples) OR put mgconsole in the path

Going further

Maven dependency (optional)

<dependency>
  <groupId>io.github.ousatov-ua</groupId>
  <artifactId>memgraph-ingester</artifactId>
  <version><!-- see latest on Maven Central --></version>
</dependency>

Start Memgraph

  • With Docker Compose:
cd memgraph-platform
docker-compose up -d
  • Just Docker
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph-mage:3.9.0

Bolt listens on localhost:7687.

Build the ingester

git clone https://github.com/ousatov-ua/memgraph-ingester.git
cd memgraph-ingester
mvn clean package -Pshade -DskipTests

Produces a shaded fat JAR at target/memgraph-ingester.jar.

Or use published shaded fat JAR in releases page.

Apply the schema (one-time per Memgraph instance)

cat src/main/resources/io/github/ousatov/tools/memgraph/cypher/create-schema.cypher | mgconsole --host localhost --port 7687

Creates uniqueness constraints and lookup indexes for both the code graph and the memory graph. Safe to re-run — existing constraints are reported and skipped.

You can also use the CLI. This command will apply the schema to the memgraph database first, then ingest the project:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --apply-schema

Next command will also wipe all data in the memgraph database first, then will apply the schema and ingest the project:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-all \
  --apply-schema

Ingest a project

This will wipe the Code graph for this project first:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code

This will wipe the Code and Memory graph for this project first:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code \
  --wipe-project-memories

Verify

MATCH (p:Project)-[:CONTAINS]->(c:Code)
RETURN p.name, c.sourceRoots, c.lastIngested;

You should see your project with a fresh lastIngested timestamp.

CLI options

Option Short Required Default Description
--source -s yes Root directory to scan (e.g. src/main/java)
--bolt -b yes Bolt URL, e.g. bolt://localhost:7687
--project -P yes Logical project name. Namespaces all nodes.
--user -u no Memgraph username (empty by default)
--pass -p no Memgraph password (empty by default)
--threads -t no 1 Parser threads (default 1). Each thread gets its own Bolt session.
--wipe-project-code no no false Delete this project's code graph before ingesting
--wipe-project-memories no no false Delete this project's memory graph before ingesting
--apply-schema no no false Apply schema before ingesting
--wipe-all no no false Wipe all data (schema will be dropped first)
--incremental no no false Skip files whose last-modified timestamp matches the stored value
--watch -w no false Watch for changes in the source directory and automatically re-ingest
--classpath no no Additional classpath entries (JARs) for symbol resolution, separated by the platform path separator. Improves CALLS edge and type resolution coverage.

--wipe-project-code only affects code nodes matching the given --project; other codebases in the same Memgraph instance are untouched, and the :Project anchor remains. --wipe-project-memories only affects memory nodes matching the given --project; the code graph and the :Project anchor remain.

Parallel ingestion

Large codebases ingest faster with multiple parser threads:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code \
  --threads 8

Each thread holds its own JavaParser and its own Bolt session. The Driver itself is shared.

Realistic speedup — don't expect linear scaling. JavaParser work is CPU-bound and parallelizes well, but Memgraph Community serializes writes internally, so the write path bottlenecks quickly:

Threads Typical speedup Bottleneck
1 1× (baseline) Sequential parse + write
4 ~2.5–3× Write serialization starts
8 ~3–4× Diminishing returns
16+ ~3–4× Writes fully saturated

4–8 threads is the sweet spot on most machines. Values higher than your CPU core count rarely help.

Determinism note: with --threads > 1, file processing order is non-deterministic. MERGE is idempotent, so results are identical, but log order will vary between runs.

Watch mode

For active development, use --watch (or -w) to monitor the source directory for changes. The ingester will automatically re-ingest modified .java files, update call edges, and refresh code references whenever a change is detected:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --watch

Watch mode uses Java's WatchService for efficient OS-level notifications and includes a small debounce delay to handle multiple rapid writes (e.g., from IDE saves). It recursively watches all subdirectories under the --source root.

Using with AI agents

This repo ships scripts designed to be dropped into any project that's been ingested. It tells AI agents how to scope queries to the right project, how the schema is shaped, when to reach for the graph vs. filesystem search, and how to use Memories for durable decisions and follow-up context.

Per-repo setup

CLAUDE

Use the bundled init-memgraph-claude.sh script, which fetches the template, substitutes the project name, and appends the result to the local CLAUDE.md

Run it from inside the repo you just ingested:

# Point at the script in your local checkout
/path/to/memgraph-ingester/script/init-memgraph-claude.sh my-project

Or fetch-and-run straight from GitHub:

curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-claude.sh \
  | bash -s -- my-project

Commit the updated CLAUDE.md. Claude Code reads it on every session start.

CODEX

Use the bundled init-memgraph-codex.sh script, which fetches the template, substitutes the project name, and appends the result to the local AGENTS.md

Run it from inside the repo you just ingested:

# Point at the script in your local checkout
/path/to/memgraph-ingester/script/init-memgraph-codex.sh my-project

Or fetch-and-run straight from GitHub:

curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-codex.sh \
  | bash -s -- my-project

Commit the updated AGENTS.md. Codex reads it on every session start.

GEMINI

Use the bundled init-memgraph-gemini.sh script, which fetches the template, substitutes the project name, and appends the result to the local AGENTS.md

Run it from inside the repo you just ingested:

# Point at the script in your local checkout
/path/to/memgraph-ingester/script/init-memgraph-gemini.sh my-project

Or fetch-and-run straight from GitHub:

curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-gemini.sh \
  | bash -s -- my-project

Commit the updated AGENTS.md. Gemini reads it on every session start.

GITHUB COPILOT

Use the bundled init-memgraph-github.sh script, which fetches the template, substitutes the project name, and appends the result to the local AGENTS.md

Run it from inside the repo you just ingested:

# Point at the script in your local checkout
/path/to/memgraph-ingester/script/init-memgraph-github.sh my-project

Or fetch-and-run straight from GitHub:

curl -s https://raw.githubusercontent.com/ousatov-ua/memgraph-ingester/refs/heads/main/script/init-memgraph-github.sh \
  | bash -s -- my-project

Commit the updated AGENTS.md. GitHub Copilot reads it on every session start.

MCP server setup

CLAUDE

Claude Code needs the Memgraph MCP server to actually run queries. Minimal project-scoped config in .claude.json for the target project:

{
  "mcpServers": {
    "memgraph": {
      "command": "uvx",
      "args": [
        "mcp-memgraph"
      ],
      "env": {
        "MEMGRAPH_URL": "bolt://localhost:7687",
        "MCP_READ_ONLY": "false"
      }
    }
  }
}

Please set MCP_READ_ONLY to "false" if you want to have Memories captured

Verify it's registered:

claude mcp list

CODEX

Codex needs the Memgraph MCP server to actually run queries. Minimal project-scoped config in ~/.codex/config.toml:

[mcp_servers.memgraph]

command = "uv"
args = [
    "run",
    "--with",
    "mcp-memgraph",
    "--python",
    "3.13",
    "mcp-memgraph"
]
[mcp_servers.memgraph.env]
MCP_TRANSPORT = "stdio"
MEMGRAPH_URL = "bolt://localhost:7687"
MEMGRAPH_USER = "memgraph"
MEMGRAPH_PASSWORD = ""
MEMGRAPH_DATABASE = "memgraph"
MCP_READ_ONLY = "false"

[mcp_servers.memgraph.tools.run_query]
approval_mode = "approve"

The Codex example is read-only. To let an agent create or update Memory nodes, use a writable MCP connection, for example, by setting MCP_READ_ONLY = "false" and keeping run_query approval enabled.

Verify it's registered:

codex mcp list

GEMINI

Codex needs the Memgraph MCP server to actually run queries. Minimal project-scoped config in ~/.gemini/settings.json:

{
  "mcpServers": {
    "mcp-memgraph": {
      "command": "uvx",
      "args": [
        "mcp-memgraph"
      ],
      "env": {
        "MEMGRAPH_URL": "bolt://localhost:7687",
        "MCP_READ_ONLY": "false"
      },
      "timeout": 5000,
      "trust": true
    }
  }
}

The example is read-only. To let an agent create or update Memory nodes, use a writable MCP connection, for example, by setting MCP_READ_ONLY = "false" and keeping run_query approval enabled.

Verify it's registered:

gemini mcp list

GITHUB COPILOT

GitHub Copilot needs the Memgraph MCP server to actually run queries. Minimal project-scoped config in ~/.copilot/mcp-config.json:

{
  "mcpServers": {
    "mcp-memgraph": {
      "type": "local",
      "command": "uvx",
      "args": [
        "mcp-memgraph"
      ],
      "env": {
        "MEMGRAPH_URL": "bolt://localhost:7687",
        "MCP_READ_ONLY": "false"
      },
      "tools": [
        "*"
      ]
    }
  }
}

Improved type resolution with --classpath

By default, the ingester resolves types against the JDK and the project source tree. To improve CALLS edge coverage, EXTENDS/IMPLEMENTS FQN resolution, and field/return type resolution for external library types, pass dependency JARs via --classpath:

# Use Maven to collect the classpath (compile + test scopes)
CP=$(mvn -q dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=/dev/stdout 2>/dev/null)
java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code \
  --classpath "$CP"

Tip: Use -DincludeScope=test to include test-scoped dependencies (JUnit, Testcontainers, etc.) — this ensures parameter types from those libraries resolve to FQNs in method signatures and field types. Without the matching JARs, external types fall back to simple names (e.g., Session instead of org.neo4j.driver.Session).

This lets JavaParser resolve method calls whose parameters use types from Neo4j Driver, Spring, JUnit 5, picocli, etc. — dramatically increasing the number of CALLS edges in the graph.

Re-ingesting after code changes

The graph goes stale as code changes. Re-run the ingester with --wipe-project-code to refresh:

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --wipe-project-code

For faster re-runs, use --incremental to skip files that haven't changed since the last ingestion (compared by filesystem lastModified timestamp):

java -jar target/memgraph-ingester.jar \
  --source /path/to/your/java/project/src/main/java \
  --bolt bolt://localhost:7687 \
  --project my-project \
  --incremental

Check freshness anytime:

MATCH (:Project {name: 'my-project'})-[:CONTAINS]->(c:Code)
RETURN c.sourceRoots, c.lastIngested;

Multiple projects in one Memgraph instance

Run the ingester once per codebase with different --project values. Each gets its own :Project -> :Code anchor chain; code nodes are composite-keyed by (key, project), so nothing collides.

java -jar target/memgraph-ingester.jar -s ~/code/repo-a/src/main/java -b bolt://localhost:7687 -P repo-a --wipe-project-code
java -jar target/memgraph-ingester.jar -s ~/code/repo-b/src/main/java -b bolt://localhost:7687 -P repo-b --wipe-project-code

List everything that's indexed:

MATCH (p:Project)-[:CONTAINS]->(c:Code)
RETURN p.name, c.sourceRoots, c.lastIngested
  ORDER BY c.lastIngested DESC;

What gets captured

Node label Identity
:Project name
:Code project
:Package (name, project)
:File (path, project)
:Class (fqn, project)
:Interface (fqn, project)
:Annotation (fqn, project)
:Method (signature, project)
:Field (fqn, project)
Relationship Meaning
(:Project)-[:CONTAINS]->(:Code) Code graph anchor
(:Code)-[:CONTAINS]->(:Package | :File) Top-level code membership
(:Package)-[:CONTAINS]->(:Class | :Interface | :Annotation) Package contents
(:File)-[:DEFINES]->(:Class | :Interface | :Annotation) Source location
(:Class)-[:EXTENDS]->(:Class) Class inheritance
(:Class)-[:IMPLEMENTS]->(:Interface) Interface implementation
(:Interface)-[:EXTENDS]->(:Interface) Interface inheritance
(:Class | :Interface)-[:DECLARES]->(:Method | :Field) Type members
(:Method)-[:CALLS]->(:Method) Call graph (best-effort)
(:*)-[:ANNOTATED_WITH]->(:Annotation) Annotation usage

Memory nodes are manually authored by agents or clients and share the same project namespace. Only the properties listed below are allowed — no extra properties may be added to any Memory node.

Label Key props All allowed properties
:Memory project project
:Decision id, project id, project, title, topic, status, rationale, consequences, createdAt, updatedAt
:ADR id, project id, project, number, title, status, context, decision, consequences, createdAt, updatedAt
:Rule id, project id, project, title, topic, severity, description, createdAt, updatedAt
:Context id, project id, project, title, topic, content, source, createdAt, updatedAt
:Finding id, project id, project, title, topic, type, summary, evidence, createdAt, updatedAt
:Task id, project id, project, title, status, priority, description, createdAt, updatedAt
:Risk id, project id, project, title, topic, severity, status, mitigation, createdAt, updatedAt
:Question id, project id, project, title, status, answer, createdAt, updatedAt
:Idea id, project id, project, title, topic, status, notes, createdAt, updatedAt
:CodeRef project, targetType, key project, targetType, key

Controlled values:

  • Decision status: proposed | accepted | rejected | superseded
  • ADR status: draft | accepted | rejected | superseded
  • Rule severity: hard | soft | recommendation
  • Finding type: bug | perf | constraint | security
  • Task status: todo | doing | done | blocked | cancelled
  • Risk severity: low | medium | high | critical
  • Risk status: open | mitigated | accepted | obsolete
  • Question status: open | answered | obsolete
Relationship Meaning
(:Project)-[:HAS_MEMORY]->(:Memory) Memory graph anchor
(:Memory)-[:HAS_DECISION | :HAS_ADR | :HAS_RULE | :HAS_CONTEXT]->(:*) Memory item ownership
(:Memory)-[:HAS_FINDING | :HAS_TASK | :HAS_RISK | :HAS_QUESTION]->(:*) Memory item ownership
(:Memory)-[:HAS_IDEA]->(:Idea) Memory item ownership
(:Decision | :ADR | :Rule | :Context | :Finding | :Task | :Risk | :Idea)-[:REFERS_TO]->(:CodeRef) Memory-to-code reference
(:CodeRef)-[:RESOLVES_TO]->(:Code | :Package | :File | :Class | :Interface | :Annotation | :Method | :Field) Current code node resolved after ingestion

CodeRef.targetType is one of Code, Package, File, Class, Interface, Annotation, Method, or Field. CodeRef.key uses the matching code identity: project name for Code, package name for Package, path for File, FQN for types/annotations/fields, and signature for Method. The ingester refreshes RESOLVES_TO edges after each run, so memory can survive code graph wipes and re-ingestion.

Caveats

  • CALLS is best-effort. JavaParser can't always resolve callees (complex generics, lambdas). Use --classpath with your project's dependency JARs to significantly improve resolution of external library types. Transitive call queries may still miss edges — a missing edge does not prove the call doesn't happen.
  • EXTENDS/IMPLEMENTS resolution. When the symbol solver cannot resolve a parent class or interface, the ingester infers the FQN from import statements and falls back to the source-level name. This means all inheritance edges are captured, but unresolvable external types may appear with a simple name (e.g. BeforeAllCallback) rather than a full FQN. Use --classpath to provide dependency JARs for full FQN resolution.
  • External types get tagged with your project. When a class extends or implements something from outside your source tree (e.g. RuntimeException, Spring interfaces), the ingester creates a :Class or :Interface node for it and scopes it to your project. These phantom nodes are marked with isExternal = true and have their name and packageName inferred from the FQN. Use WHERE NOT n.isExternal to filter them out. Project-internal nodes always have isExternal = false.
  • Same-class CALLS fallback. When full signature resolution fails for an unscoped (same-class) method call, the ingester falls back to name-based matching: it creates a CALLS edge if exactly one method with that name exists in the owning type. This avoids false positives from overloading while recovering many intra-class call edges that would otherwise be lost. The same fallback applies to same-class method references (Type::method).
  • Generated code is only indexed if you ingest it. Annotation processors, Lombok-generated members, and similar won't appear in the graph unless their generated source directory is passed to the ingester too:
java -jar memgraph-ingester.jar \
  --source target/generated-sources/annotations \
  --bolt bolt://localhost:7687 \
  --project work
  # no --wipe-project-code here!!!!

Project layout

.
├── src/main/java/io/github/ousatov/tools/memgraph/
│   ├── IngesterCli.java                    # CLI entry point (picocli Callable)
│   ├── IngestionOrchestrator.java          # Orchestrates sequential / parallel ingestion
│   ├── ParseService.java                   # JavaParser + symbol resolution
│   ├── GraphWriter.java                    # Cypher MERGE writes to Memgraph
│   ├── def/Const.java                      # Shared constants
│   ├── exception/ProcessingException.java  # Checked processing error
│   └── schema/Memgraph.java                # Schema loader (create / drop / wipe)
├── src/main/resources/io/github/ousatov/tools/memgraph/cypher/
│   ├── action/                             # Per-operation Cypher templates (upsert, wipe, resolve)
│   ├── create-schema.cypher                # Uniqueness constraints + indexes
│   ├── drop-schema.cypher                  # Schema teardown
│   └── wipe-all-data.cypher                # Full data wipe
├── src/test/java/                          # Unit + integration tests (JUnit 5, Testcontainers)
├── schema/
│   └── SCHEMA.md                           # Graph model reference (human-readable)
├── script/
│   ├── init-memgraph-claude.sh             # Appends Memgraph section to a repo's CLAUDE.md
│   ├── init-memgraph-codex.sh              # Appends Memgraph section to a repo's AGENTS.md (Codex)
│   ├── init-memgraph-gemini.sh             # Appends Memgraph section to a repo's AGENTS.md (Gemini)
│   └── init-memgraph-github.sh             # Appends Memgraph section to a repo's AGENTS.md (Copilot)
├── template/
│   ├── AI-memgraph-template.md             # Template for *.md injection
├── memgraph-platform/
│   └── docker-compose.yml                  # Memgraph + Lab (with UI)
├── pom.xml                                 # Maven build (shaded fat JAR, spotless-enforced)
└── README.md

License

MIT — see LICENSE.

Acknowledgements