Skip to content

About

Open-source, local-first graph investigation workbench: Cypher + SQL, path exploration, evidence, and a JSON CLI for AI agents

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

KhonsuGraph

A local-first desktop workbench for HawDB graphs: open a graph, query it in Cypher or PostgreSQL SQL, see nodes and relationships on a canvas, bring data in through plugins, and build .dash dashboards an AI agent can write and a person can review. Built on HawDB; not an official HawDB product.

Layout

Path What
app/ The desktop app: GPUI with gpui-kit (DuckLocal's shell) and gpui-graph for the canvas
crates/khonsu-core HawDB access, writer lock, results, schema, plugin host, merge writer, settings
crates/khonsu-dash .dash dashboards: parse, validate, filters, check, comments, presence, the window link
crates/khonsu-cli khonsu, the windowless JSON CLI for agents and scripts; the app runs it when called as khonsu or with a subcommand
crates/khonsu-plugin-protocol The data-source plugin protocol (JSON lines over stdio); see docs/plugins.md to write a plugin in any language
plugins/csv The built-in CSV plugin
khonsugraph-marketplace A separate repository: the official plugins installed by name (marketplace) rather than bundled, such as sql (PostgreSQL, MySQL, SQLite), ducklocal (Parquet, CSV, DuckDB), aws (an AWS account through the aws CLI) and neo4j (a Neo4j database, such as one Cartography fills), with the CI that builds and releases them
skills/khonsugraph The agent skill: how to query, author dashboards and review them with a person
examples/ Five user-story dashboards on public datasets, the scripts that build their graphs, an AWS exposure dashboard, a blast-radius investigation template and a Python plugin

Build

cargo build --workspace            # app, CLI and the CSV plugin
cargo test --workspace

Tests create their graphs in scratch/tests (set in .cargo/config.toml), not the system temp directory, because of the Windows drive-root limit below.

Release builds

Script Makes
scripts/bundle.sh An unsigned KhonsuGraph.app to try on a Mac
scripts/package-macos.sh The signed, notarized .dmg (Developer ID and an App Store Connect key required)
scripts/package-windows.ps1 A zip of the Windows build (not code-signed)

One executable is both the app and the khonsu CLI: with no arguments it opens the window; called as khonsu, or with a subcommand or a flag (khonsugraph query …, khonsugraph --help), it runs the command and exits. So cargo run -p khonsugraph -- query … works from a checkout. Every package holds it and the built-in CSV plugin under plugins/csv/ beside it, which is where it looks for built-in plugins; the Windows zip adds a khonsu.exe copy, since Windows finds a command by file name. The robot button in the title bar (Command line & AI) puts khonsu on your PATH and adds the agent skill to Claude Code. Pushing a v* tag runs .github/workflows/release.yml, which builds the packages and publishes a GitHub release.

Graph analysis

khonsu graph analyze adds what HawDB's Cypher lacks, after networkx: summary, degree, pagerank, betweenness, closeness, components (weak or --strong), communities (Louvain), clustering, kcore and shortest path, over the whole graph, --label/--type, or a --cypher subgraph. Results match networkx on the same graph; on the audit story (5,881 accounts, 35,592 ratings) the summary, components, clustering, cores, diameter and PageRank equal networkx's exactly.

khonsu graph analyze summary --db graphs/audit
khonsu graph analyze pagerank --db graphs/audit --type TRUSTS --top 10
khonsu graph analyze communities --db graphs/investigation

Two more ask what networkx does not, once one record is known to matter: similar --node ID lists the nodes of the same label whose relationships look most like that node's, and outliers lists the nodes least like the rest of their label. Both compare what a node does: its relationships counted by direction, type and the label at the other end. Every candidate is scored, the same graph gives the same answer, and each row carries the counts behind its distance.

khonsu graph analyze similar --db graphs/audit --node 407  # accounts rated the way #472 is
khonsu graph analyze outliers --db graphs/audit --top 10  # accounts unlike the rest

Investigations

khonsu graph explore follows relationships from a node within caps, khonsu evidence says what supports a record, khonsu investigate saves a line of inquiry and reopens it against the graph as it is now, and khonsu graph snapshot says what changed between two points. See saved investigations, snapshots and what the gates test. What is kept in the graph and what in files follows two rules; see what goes in a graph. khonsu graph ontology says what a graph's labels mean, whether a graph can answer a question, and how two concepts connect in it; see ontology.

A template asks a question the same way each time, read-only and within caps, and a report keeps the answer so a reviewer can check it and run it again:

khonsu investigate template run examples/sre/blast-radius.template.json --db graphs/infra \
  -p service=infra/svc-db --report db.report.json
khonsu investigate report export db.report.json --markdown db.md
khonsu investigate report replay db.report.json

Every finding names the records behind it, the caps that applied and what was missing. See templates and reports.

HawDB 0.34.0 notes

KhonsuGraph pins HawDB to 0.34.0. See the 0.34 upgrade validation for compatibility checks and their scope, and the 0.27, 0.24, 0.22, 0.19, 0.15, 0.12 and 0.11 validation for earlier database compatibility checks.

  • Graphs written before HawDB 0.31, by every KhonsuGraph build up to v0.3.0, cannot be read and report old_format: 0.31 changed the storage format (persistent format version 2) and reads no older graph. khonsu graph rebuild makes them again from their data sources; anything written by hand rather than synced is not carried over.

  • One process per graph directory, readers included. While the app has a graph open, khonsu query (writes too, with --write), schema, graph explain, dash check and plugin sync run through the app, which refreshes what it shows after a write.

  • On Windows, a graph can go anywhere in your user folder. Elsewhere, opening one for writing flushes every directory up to the drive root, which needs write access to the root itself. Ordinary users cannot write to C:\, so a path like C:\graphs fails; use your user folder or a drive whose root you can write to (for example D:\graphs). Graphs anywhere can still be opened read-only.

  • OPTIONAL MATCH, scalar IN expressions and json_value() on JSON text are supported. Relationship properties can now be updated with SET; the importer retains its existing delete/recreate strategy.

  • Cypher sum(), list functions (size, head, range, indexing, slices) and list comprehensions work since 0.21–0.22; shortestPath, temporal types and toString-style conversions by 0.24. Dates and times come back as ISO 8601 strings. labels(), path variables outside shortestPath and string concatenation still fail, and SQL still refuses WHERE true. So an unpicked dashboard filter is true in Cypher, and in SQL ("col" IS NULL OR "col" IS NOT NULL) on the column a pick compares: true for every row either way, as DuckLocal's TRUE.

  • HawDB's LOAD CSV stays off, so a query or a dashboard cannot read files from disk; CSV files come in through a data source.

  • SQL numbers are exact decimals since 0.25 (SELECT 1.5, DECIMAL columns and their sum); they come back as JSON numbers, or as exact text when a double would lose digits. SQL syntax errors give a line and column again, worked out from the byte span the new parser reports.

  • KhonsuGraph explicitly limits reads to 100,000 result rows, preserving its previous behavior after HawDB removed the default row limit in 0.10. The result display limit is separate and does not lower execution cost.

  • Vector values returned by SQL and Cypher are exposed as JSON number arrays, including vector properties inside graph elements.

  • A full CSV import of the audit story (5,881 nodes, 35,592 relationships) took 47 seconds on 0.15.0 with debug builds on Windows 11; the same import took about 13 minutes on 0.8.

License

Apache-2.0.

About

Open-source, local-first graph investigation workbench: Cypher + SQL, path exploration, evidence, and a JSON CLI for AI agents

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages