Expand description
mushroomdb CLI library: hand-rolled arg parsing and the demo dataset builder.
The binary in main.rs stays thin — it dispatches on parse_args and
prints what the lib functions return.
Modules§
- doctor
mushroomdb doctor— verify an install end to end: the config entry, the store, the hooks, and a real stdio handshake with the configured MCP command.- export
- Export writer for
mushroomdb export. - import
mushroomdb import: bulk load of a nodes CSV and a relationships CSV.- ingest_
git mushroomdb ingest-git <db> <repo>: build and maintain a graph of a git repository. First run ingests the whole history; later runs apply only the commits after the recordedGitSynchead, so deletes and renames retract or move derived edges instead of leaving them stale.- install
mushroomdb install/uninstall— wire the /mushroom skill, the MCP server and the session hooks into an assistant.- recall
mushroomdb recall <db>: the body of theUserPromptSubmithook.- serve_
bolt serve’s Bolt listener settings: the--bolt-*flags, their environment variables, and the rules that turn them into a listener config or refuse the start.- structure
- Structure ingest: the working tree, read as graph.
Structs§
- CliError
- CLI-facing error. [
Display] is the message printed to stderr. - Demo
Outcome - Outcome of
run_demo. Counts are deterministic. - Shutdown
Plan - How a shutdown’s time is divided: the three phases, in order, and the most each may take. They sum to at most the timeout.
- TxFlags
- The HTTP transaction limits as given on
serve’s command line;Noneis “not given”, which leaves the environment variable (or the default) in force. Non-zero integers, notDurations, keepCommand::Servesmall.
Enums§
- Algo
Subcmd - Algorithm subcommand for
mushroomdb algo. - Command
- Parsed
mushroomdbinvocation. - Restore
Outcome - Re-exported where it has always been named:
cli::RestoreOutcome. Whatrestore_if_emptydid. - Schema
Listing - What
mushroomdb schema indexes|constraintslists. - ServeUi
- How
serveshould mount a UI. Precedence:--ui dir> embedded >--no-ui. - WalDisposition
- What a snapshot does with the WAL it folds in.
Constants§
- AUTOMATIC_
SNAPSHOT - What every snapshot mushroomdb takes on its own does with the WAL.
- AUTO_
SNAPSHOT_ RETENTION - How many WAL archives a snapshot mushroomdb takes on its own keeps.
None= all of them. Retention is configured, never defaulted: deleting history nobody asked to delete is not a default worth having. - DEFAULT_
RESTORE_ INTO - Where
restorewrites when--intois not given. - DEFAULT_
SHUTDOWN_ TIMEOUT_ SECS - Default for
serve --shutdown-timeout-secs: drain up to 25 s, snapshot in what is left of the budget (8 s with the default backup bounds), then flush the backup and release the lease within 22 s. - NO_
AUTO_ SNAPSHOT_ ENV - Set, to anything, in the environment of a
mushroomdb mcpthat must not snapshot the store it opens. - N_ORGS
- Deterministic demo: 10 Orgs, 20 Projects, 30 People.
- N_
PEOPLE - N_
PROJECTS - SAMPLE_
QUERY - Sample query printed by
mushroomdb demoand executed against the fresh store. - SHUTDOWN_
DRAIN_ SECS - The drain phase’s share at the default timeout, and its cap at any timeout.
- SNAPSHOT_
LOCK_ WAIT - How long a server-initiated snapshot waits for the store’s cross-process write lock before giving up.
- VERSION
- Build version, printed by
mushroomdb --version.
Functions§
- build_
index_ on run_build_indexagainst an already-open handle.- format_
backup - Format a
BackupReportfor display. - format_
demo - Render a
DemoOutcomethe waymushroomdb demoprints it. - format_
restore_ s3 - Format a
backup::RestoreS3Outcomefor display. - format_
stats - Pretty-print
Statsformushroomdb statsand the demo smoke test. - format_
suggest - Pretty-print a list of
RuleSuggestions formushroomdb suggest. - maybe_
run_ demo_ if_ empty - Run
run_demowhendiris missing or empty; otherwise leave it alone. - parse_
args - Parse argv after the binary name. Hand-rolled — no clap.
- read_
stats - Open
dirand return live stats. - resolve_
auto_ db - Where
--autolooks for a database, in order. - resolve_
statement - The statement a
queryorasofwas given:inlineas it came, or the text of--fileor of standard input. A file or pipe ends in a newline the editor orechoput there, which is not part of the statement, so trailing whitespace is dropped. - resolve_
tx_ limits - The HTTP transaction limits
serveruns with: each flag given wins over its environment variable, read throughenv; a limit given by neither keeps its default. - restore_
if_ empty mushroomdb::restore::restore_if_empty, in the CLI’s error type.- run_
algo - Run a graph algorithm and return a formatted string.
- run_
asof - Execute an as-of query at the given commit and print results.
- run_
backup - Create a consistent, verified backup of
db_dirtodest. - run_
brief - Body of
mushroomdb brief <db-dir>|--auto, theSessionStarthook. - run_
build_ index - Pump every outstanding vector-index build to completion, one slice per call, printing a line per slice.
- run_
demo - Build the deterministic demo dataset in an empty
dir. - run_
export - Export all data from
db_dirtodestinformat. - run_
import - Bulk-load CSV and JSONL files into
db_dir;mushroomdb import. - run_
migrate - Migrate the snapshot at
db_dirto the current format version. - run_
query - Run a Cypher read or write and print columns/rows like
run_asof. - run_
restore_ s3 mushroomdb restore --from s3://…: download, verify and install a restore point intointo(defaultDEFAULT_RESTORE_INTO) withbackup::restore_from_s3, and say what was restored.- run_
schema_ apply - Read
schema_file, opendb_dir, apply the schema, and return the diff as one line per entry:"created rule:x","updated view:y", etc. - run_
schema_ apply_ memory_ defaults mushroomdb schema apply <db> --memory-defaults- run_
schema_ apply_ memory_ identity mushroomdb schema apply <db> --memory-identity- run_
schema_ list mushroomdb schema indexes|constraints: the rowsSHOW INDEXES/SHOW CONSTRAINTSgive, as a table. The store opens read-only, so this writes nothing and never waits on a writer, a server included.- run_
snapshot - Open
dirand writesnapshot.bin, archiving the WAL by default. - run_
suggest - Profile the database at
dirand return all rule suggestions. - run_
verify - Validate the CRC32 integrity of every section in a V8 snapshot.
- run_why
- Body of
mushroomdb why <db> <a> <b>: every rule edge between two keys with the evidence that derived it, or an honest note that there is none. A key the store does not hold is an error (node key not found: <key>), not an empty answer. - shutdown_
plan - Divide
totalbetween the phases.backup_boundis the backup’s own shutdown bound (BackupConfig::shutdown_budget), zero without backup. - snapshot_
automatically - Take
AUTOMATIC_SNAPSHOTunder a held write lock, keepingAUTO_SNAPSHOT_RETENTIONarchives. - snapshot_
if_ wal_ grew - Take the automatic snapshot if the store’s WAL has grown past
SNAPSHOT_WAL_BYTES. - snapshot_
shared - Take the snapshot
servetakes — on a--snapshot-everytick, and once more on a graceful shutdown. - usage
- Usage text for no-args /
--help/-h. - validate_
ui_ dir --ui <dir>must be a directory that containsindex.html.- version_
string - The one line
--versionand theversionsubcommand print. - why_
for_ stdout why’s reply as it goes to stdout. A person at a terminal reads the framing line as a warning, sostyleddims it; the text stays, because an agent may be reading through a terminal too. Piped output is untouched.- worktree_
root - The root of the working tree
dirsits in: the nearest ancestor holding a.gitentry, orNoneoutside a checkout.