Configuration Options for the Graph Module in Hivemind
The graph module exposes three primary configuration levers: ignoreDirs (an array of directory basenames to skip), respectGitignore (a boolean controlling .gitignore integration), and memoryPath (an environment variable defining where snapshots are persisted). These settings are loaded from ~/.deeplake/graph-ignore.json and process.env, allowing precise control over indexing scope and storage location.
The activeloopai/hivemind repository implements a code-graph analysis system that crawls repository structure and persists graph snapshots to disk. Understanding the configuration options for the graph module is essential for excluding build artifacts, respecting existing ignore rules, and relocating data storage to suit distributed or containerized environments.
Core Configuration Options
Ignore Directories (ignoreDirs)
The ignoreDirs option defines directory basenames that the graph builder will unconditionally skip during filesystem traversal. According to src/graph/ignore-config.ts, this configuration is backed by the DEFAULT_IGNORE_DIRS constant—an array of approximately 40 common build-output and version-control directories. When the builder encounters any directory name present in this list, it excludes the entire subtree from node and edge generation.
Gitignore Respect (respectGitignore)
The respectGitignore boolean determines whether the builder honors the repository’s own .gitignore patterns. When set to true (the default), the system executes git ls-files --exclude-standard to filter out ignored paths before they enter the graph index. This prevents generated files, dependencies, and secrets from being parsed and stored.
Storage Location via memoryPath
While not exclusive to the graph module, the memoryPath configuration dictates where snapshots are serialized. Defined in src/config.ts, this value defaults to ~/.deeplake/memory but can be overridden via the HIVEMIND_MEMORY_PATH environment variable. The graph module appends /graphs/<repo-key>/ to this base path, where repo-key is a SHA-1 hash of the remote URL computed at runtime.
Where Configuration Lives in the Source Code
Configuration is distributed across two primary entry points in the codebase:
src/graph/ignore-config.ts– ExportsloadGraphIgnore(), which reads or creates~/.deeplake/graph-ignore.json. This file validates against theGraphIgnoreConfiginterface and supplies theDEFAULT_IGNORE_DIRSfallback.src/config.ts– ExportsloadConfig(), which resolvesmemoryPathfromprocess.env.HIVEMIND_MEMORY_PATHor falls back to the default DeepLake directory.src/graph/snapshot.js(imported assnapshot.tsin source) – ContainsrepoDir(), which constructs the final graph storage path by combiningmemoryPathwith the repository key.
Practical Configuration Examples
Customize Ignore Patterns
import { loadGraphIgnore, DEFAULT_IGNORE_DIRS } from "./src/graph/ignore-config.js";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
// Load existing configuration or bootstrap defaults
const config = loadGraphIgnore();
// Add project-specific directories to the exclusion list
config.ignoreDirs.push("generated-contracts", "wasm-target");
// Persist to ~/.deeplake/graph-ignore.json
const configPath = join(homedir(), ".deeplake", "graph-ignore.json");
writeFileSync(configPath, JSON.stringify(config, null, 2));
console.log("Active ignore list:", config.ignoreDirs);
Disable Gitignore Respect for CI
import { spawnGraphPullWorker } from "./src/graph/spawn-pull-worker.js";
// Override environment before spawning the pull worker
process.env.HIVEMIND_RESPECT_GITIGNORE = "false";
await spawnGraphPullWorker({ cwd: process.cwd() });
// The graph will now index files normally excluded by .gitignore
Relocate Graph Storage
import { loadConfig } from "./src/config.js";
import { repoDir } from "./src/graph/snapshot.js";
// Override base storage path via environment variable
process.env.HIVEMIND_MEMORY_PATH = "/mnt/fast-storage/hivemind";
const config = loadConfig();
const graphPath = repoDir(config.memoryPath);
console.log("Graph snapshots stored at:", graphPath);
// Output: /mnt/fast-storage/hivemind/graphs/<repo-key>/
Summary
- The graph module is configured via
ignoreDirs(array of skipped directory names),respectGitignore(boolean for.gitignoreintegration), andmemoryPath(base storage location). - Settings persist in
~/.deeplake/graph-ignore.jsonfor ignore rules and environment variables for storage paths. - The
loadGraphIgnore()andloadConfig()functions provide the programmatic entry points for reading and modifying these values at runtime.
Frequently Asked Questions
Where does Hivemind store graph configuration files?
The primary configuration file graph-ignore.json lives in the ~/.deeplake/ directory and is created automatically the first time loadGraphIgnore() is invoked. Global settings like memoryPath are resolved via the HIVEMIND_MEMORY_PATH environment variable rather than static configuration files.
Can I configure the graph module to ignore specific file extensions?
No, the current implementation in src/graph/ignore-config.ts only supports directory name matching via ignoreDirs. File extension filtering is not exposed in the configuration schema; you must rely on respectGitignore set to true and add extension patterns to your repository’s .gitignore file.
How do I move the graph snapshot storage to a different disk?
Set the HIVEMIND_MEMORY_PATH environment variable to an absolute path on the target disk before running any graph commands. The repoDir() function in src/graph/snapshot.js appends graphs/<repo-key> to this base path, allowing you to relocate the entire snapshot database to external or network-attached storage.
What happens if I delete the graph-ignore.json file?
If the file is missing, loadGraphIgnore() recreates it with default values, including the DEFAULT_IGNORE_DIRS list and respectGitignore: true. Deletion effectively resets your configuration to factory defaults, though existing snapshots in the memory path remain untouched.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →