# ahto ahto is a code intelligence engine that runs on your machine. Point it at a repository and it copies the whole history to your disk as tables you can query with SQL, parses the code into symbols, imports and calls, and matches its packages against security advisories. One local port serves all of it to you, your programs and your coding agents. **Every commit, queryable.** `No account` · `No hosted service` · `Nothing uploaded` · `Parquet on your disk` · `DuckDB inside` **[Try the live demo](https://demo.ahto.dev)**: the histories of Linux, Go, Rust, PHP and Node in 34 tables, with the web app, the SQL workbench and the [API explorer](https://demo.ahto.dev/docs/api). More at [ahto.dev](https://ahto.dev). Status: open source and in active development. Commands, tables and settings can still change between releases. (From /docs) --- # Getting started This page takes you from nothing to a first answer by installing ahto, crawling a repository, asking it a question in SQL and opening the web app. ## Install One line installs the newest release; see `scripts/get.sh --help` for the options: ```sh curl -fsSL https://ahto.dev/install.sh | sh ``` To build it from source instead, use a checkout: ```sh mise install # the pinned tools, then builds ahto into ~/.local/bin (https://mise.jdx.dev) ahto doctor # checks Git, the lake directory and DuckDB ``` You need Git 2.42.0 or newer on your `PATH` and a C compiler: ahto uses cgo for DuckDB and the tree-sitter grammars. `ahto doctor` says what is missing or too old. The build writes one binary, `dist/ahto`, with DuckDB and the parsers inside, and copies it to `~/.local/bin/ahto` so `ahto` runs from any directory. Set `AHTO_BIN_DIR` to install it somewhere else; it never uses sudo, and it says so when the directory is not on your `PATH`. `mise run install:global` builds and installs it again after a change; `mise run build` only writes `dist/ahto`. ## First crawl ```sh ahto crawl https://github.com/golang/example ``` ```text REPOSITORY STATUS REFS COMMITS TREES BLOBS TAGS SNAPSHOT RUN github.com/golang/example published 1 76 225 220 0 480ac9e41e15 01a22cb2-f2a6-7747-a1c5-2cbc7b04caaa ``` `RUN` is the id of this crawl. That took about 2 seconds. Run the same command again and the status is `unchanged`, with 0 new objects. A crawl that is stopped halfway leaves the lake as it was before the crawl. After it publishes, a crawl also derives the read models and parses the new source files ([parsing](/docs/parsing)), so the symbols and the call graph are there when it ends. ## Choosing what to crawl By default ahto crawls the default branch. Flags choose more: ```sh ahto crawl --all-branches # every branch ahto crawl --branch 'release-*' # branches matching a glob ahto crawl --tag 'go1.23.*' # tags matching a glob ahto crawl --depth 1 # only the newest commit; a later full crawl fills in the rest ahto crawl --dry-run # list the refs it would crawl, fetch nothing ahto crawl --no-parse # leave the parse stage out of this crawl ahto crawl ~/src/my-project # a local repository ``` `ahto crawl --help` lists every flag. Several URLs in one command are crawled one after another. For a repository that needs a login, see [private repositories](/docs/private-repositories). ## A first question ```sh ahto query sql "select author_name, count(*) as commits from commits group by 1 order by 2 desc limit 10" ahto files # the files on the default branch ahto history README.md # the commits that changed a file, newest first ``` [Querying](/docs/querying) has the tables, the macros and the output formats. ## The gateway and the web app ```sh ahto serve # then open http://127.0.0.1:8080 ahto serve --no-ui # the gateway alone mise run dev:all # for work on ui/app: the gateway, then the web app on http://127.0.0.1:8081 ``` `serve` runs the gateway on one port, on 127.0.0.1 only, with no sign-in (unless the node is an authority member; see [when sign-in applies](/docs/identity#when-it-applies)): MCP for coding agents, and REST, gRPC, JSON-RPC, GraphQL and more for programs. [The gateway](/docs/gateway) explains each surface. To give a coding agent the lake as MCP tools, point it at `http://127.0.0.1:8080/mcp` while `serve` runs. An agent opened in this repository finds it already (see [Agents in this repository](/docs/gateway#agents-in-this-repository)); `mise run mcp:add` registers it in Claude Code for every other folder. The web app (code browser, 3D city, SQL workbench, security pages and these docs) is built into the released binary, so `ahto serve` answers it at `http://127.0.0.1:8080`, with every API also below `/api` for it ([the web app](/docs/gateway#the-web-app)). The gateway's own paths (`/mcp`, `/healthz`, `/openapi.json`, the `/v1` routes) stay at the root. `--no-ui` leaves the web app out. A binary built in the checkout embeds the web app when `ui/app/dist` holds a build (`mise run ui:setup` once, then `mise run ui:build`, then `mise install`). To work on the web app itself, `mise run dev:all` starts the gateway and the web app's dev server, and stops both on Ctrl-C. A public demo with Linux, Go, Rust, PHP and Node runs at . (From /docs/getting-started) --- # Quick start One line installs the newest release on Linux and macOS (amd64 and arm64). It checks the binary against the release's `SHA256SUMS`, puts it in `~/.local/bin` and never uses sudo. Add `-s -- --claude` after `sh` to register ahto in Claude Code as well: ```sh curl -fsSL https://ahto.dev/install.sh | sh ``` Then crawl a repository, ask it a question and start the gateway: ```sh ahto crawl https://github.com/golang/example ahto query sql "select author_name, count(*) as commits from commits group by 1 order by 2 desc limit 10" ahto serve # then open http://127.0.0.1:8080: the web app, with the API also below /api ``` `ahto upgrade` later replaces the binary with the newest release, with the same checksum check. To build from source you need Git 2.42.0 or newer, a C compiler (ahto uses cgo for DuckDB and the parsers) and [mise](https://mise.jdx.dev): In the checkout, `mise install` is the only setup step: it installs the pinned tools, builds ahto and puts it in `~/.local/bin`. [Getting started](/docs/getting-started) walks through each step, and [Development](/docs/development) covers building and testing. (From /docs/quick-start) --- # What you get Everything below runs on your own disk and answers on one local port. - **The whole history as tables.** Every commit, tree, blob, tag and ref, written as Parquet and read with the DuckDB engine inside the binary. A second crawl adds only what is new ([querying](/docs/querying), [the lake](/docs/lake)). - **Code that is understood, not only stored.** Source files are parsed into symbols, imports, calls and syntax trees, once per distinct file ([parsing](/docs/parsing)). - **Risk at any commit.** Advisories from OSV, CISA KEV and EPSS sit next to your code and meet its pinned packages; a scan adds the secrets, dangerous calls and sensitive files ([security](/docs/security)). - **A web app to look around.** A code browser, a 3D city of the repository, a canvas, a SQL workbench, the security pages and these docs, built into the binary ([the web app](/docs/gateway#the-web-app)). - **One port for people and agents.** MCP for coding agents, and REST, gRPC, JSON-RPC, GraphQL, WebSocket and MQTT for programs ([the gateway](/docs/gateway)). - **Agents that run from the gateway.** Claude, Codex and others can run on your machine through the REST API; off by default ([agents](/docs/agents)). - **Tools around your code.** `ahto check` skips CI checks whose inputs did not change, `ahto task` keeps your work as a tree, and `ahto serve` takes OpenTelemetry traces and crashes and maps them to commits ([checks](/docs/checks), [how to](/docs/how-to), [debugger](/docs/debugger)). - **Closed networks of your own machines.** Nodes find and admit each other by key, with a signed membership log, and people sign in with a device key or a passkey. Lake data does not move between peers yet ([networking](/docs/networking), [identity](/docs/identity)). (From /docs/what-you-get) --- # How to Short recipes for the things people do with ahto, each with the commands to copy and what you should see. Each recipe was run against a build of this repository. A recipe that only points to another page says so and was not repeated here. ## Ask a question about a repository ```sh ahto crawl ~/src/my-project ahto query sql "select author_name, count(*) as commits from commits group by 1 order by 2 desc limit 3" ``` ```text author_name commits Nevio Vesic 293 Nevio Vesić 98 dependabot[bot] 6 ``` (Names are from one repository's history; yours will differ.) The crawl prints a table whose last column, `RUN`, is the id of this crawl. More in [getting started](/docs/getting-started) and [querying](/docs/querying). ## Let an agent read your repositories Run `ahto serve`, then point your agent's MCP settings at `http://127.0.0.1:8080/mcp`. How the gateway serves its tools is in [the gateway](/docs/gateway#mcp). Not run for this page. ## Keep track of work with the task tree A task tree lives on your machine. Add a project, two tasks under it, and list what can start: ```sh ahto task add "Ship the docs" ahto task add "Write networking page" --parent --hours 2 --state ready ahto task add "Review it" --parent --hours 1 ahto task tree ahto task ready ``` ```text ID STATE HOURS DUE DONE TITLE 01M8PB3VSRJF2BDPAG9ZAXRWYK backlog - - 0/2 Ship the docs 01M8PB4DK1DCCADECGDCARB636 ready 2 - - Write networking page 01M8PB4DNX0QVKJKE6Z994Z9EP backlog 1 - - Review it ``` `task ready` then lists only "Write networking page", the one in state `ready` with all its dependencies done. Every command is in [commands](/docs/commands) and the rules (guards, states) in [the gateway](/docs/gateway#the-task-service). While `ahto serve` runs it holds the task file; the same commands reach it through the gateway with `--gateway host:port`. ## Skip CI checks whose inputs did not change Put the checks in `ci/checks.json`, then run `ahto check run` twice. The second run says `cached`. See [checks](/docs/checks). ## Speed up a second Go build ```sh export GOCACHEPROG="ahto cas gocacheprog --dir $HOME/.cache/ahto-cas" go build ./... ``` See [checks](/docs/checks#a-go-build-cache) for the measured hits and misses. ## Collect traces from your program Start `ahto serve` and point your program's OpenTelemetry exporter at `http://127.0.0.1:4318`. Read the traces with `GET /v1/debug/traces`. See [debugger](/docs/debugger). ## Connect two machines in a closed network Make each machine's key, make a CA, admit both, and start `ahto serve` on each. The steps, with the output of every command, are in [networking](/docs/networking#set-up-a-network). What the network carries today is membership and sign-in; it does not yet carry your lake. ## Let a teammate sign in Needs a members network whose node is in the authority group. See [identity](/docs/identity). ## Crawl a private repository See [private repositories](/docs/private-repositories). ## Change a setting See [configuration](/docs/configuration). A running gateway saves settings from the UI or with `POST /v1/settings`; the keys that apply at once are marked there. (From /docs/how-to) --- # Querying Every table of the lake is a view in DuckDB, so any question about a repository is a SQL query. This page lists the query commands, the macros that save the common joins, the commands that answer without SQL and the tables. ## The query commands ```sh ahto query tables # every table with its files, rows and bytes ahto query schema commits # the columns of a table, with what each one means ahto query sql "describe commits" # the columns of a table, as DuckDB sees them ahto query sql "select author_name, count(*) as commits from commits group by 1 order by 2 desc limit 10" ahto query sql -o csv "select commit_oid, message from commits" > commits.csv ahto query file report.sql # run every statement of a file, print the last result ahto query explain "select ..." # the plan of a query, with rows and time per step ahto query export --format parquet --out authors.parquet "select ..." # json, csv, parquet or arrow ``` `ahto query schema` with no table prints every table and column with its description. ## Macros Four macros save the joins most questions need: | Macro | Gives | Columns | |---|---|---| | `files_at(tree_oid)` | the files under a root tree, as `git ls-tree -r` | `path`, `mode`, `kind`, `oid` | | `head_tree(repo_id)` | the root tree of the default branch in the last crawl (one value) | | | `head_files(repo_id)` | `files_at(head_tree(repo_id))` | `path`, `mode`, `kind`, `oid` | | `commits_of(repo_id)` | the commits a repository reaches | the columns of `commits` | `kind` is `file`, `exec`, `symlink`, `gitlink` or `other`; `oid` is the blob, or the commit of a gitlink; `path` is NULL when it is not valid UTF-8. For example: ```sh ahto query sql "select path from head_files((select repo_id from repositories limit 1)) where path like '%.go' order by path" ``` SQL sent to the gateway (the SQL workbench, functions, Arrow) refuses `files_at` and `WITH RECURSIVE`: DuckDB does not hold a recursive walk to the memory limit, and one old Linux tree took more than 5 GB in 5 seconds. Use `head_files`, or the files API at a commit, which walks one level per query. The local `ahto query` commands still run them. ## Without SQL ```sh ahto files # the files on the default branch: path, mode, object id, language ahto files --at v1.2.0 cmd/ # under cmd/ at a tag, branch or full commit or tree id ahto history README.md # the commits that changed a file or directory, newest first ahto inspect HEAD # one commit, tree, blob or tag, like git cat-file -p ahto inspect --ast HEAD:main.go # the syntax tree of a source file ``` `history` follows first parents, like `git log --first-parent --no-renames -- `. `files` and `history` pick the only repository in the lake, or take `--repo`. Every command prints a table by default; `-o json`, `-o jsonl` and `-o csv` give machine output. ## Functions `ahto function list` shows the functions over the lake: built-ins such as `hot_files`, `lone_maintainer`, `largest_functions`, `todo_comments`, `top_imports` and `security_fix_commits`, and the WebAssembly functions in the lake's `functions` folder. `ahto function call [key=value...]` runs one and prints its rows: ```sh ahto function list --category quality ahto function call hot_files path=src/ limit=20 ``` A wasm function is a folder with a `function.yaml` and its module; `examples/functions` has one that counts TODO and FIXME per blob. `ahto function new ` writes a new one that builds without an ahto checkout, and `ahto function test ` runs it once without adding it, keeping a run or filling the cache (`run` is another name for `call`): ```sh ahto function new line_count && cd line_count && go mod tidy && go test ./... GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o line_count.wasm . ahto function test . --rows 'SELECT DISTINCT blob_oid FROM file_versions LIMIT 10' ``` Over the gateway the same try is `function_test`, and `function_add` also takes a module by URL (`fetch`: the manifest, an https `module_url` and its `module_sha256`), so a remote client does not send the module in base64. The design is in the functions design document. ## The tables | Table | One row per | |---|---| | `repositories`, `remotes` | repository, and each URL it was crawled from | | `crawl_runs`, `snapshots` | crawl, and each distinct state of a repository's refs | | `refs`, `ref_updates` | ref in a snapshot, and each time a ref moved | | `commits`, `commit_parents` | commit (author, committer, dates, message), and each parent link | | `repo_commits` | commit a repository reaches | | `tags` | annotated tag | | `trees`, `tree_entries` | directory, and each file or directory in it | | `blobs` | file content (size and line count; the bytes stay in the mirror) | | `blob_contents` | text of a file that is valid UTF-8, has no NUL byte and is at most 1 MiB | | `changes` | file a commit added, changed or deleted, against its first parent | | `file_versions` | file at a version: language and vendor, generated, test and docs flags | | `submodules`, `languages` | submodule in `.gitmodules`, and each known language | | `tree_files` | file under the root tree of a crawled ref tip (a read model) | | `path_changes` | row of `changes`, sorted by path, with its author, subject and blob facts (a read model) | The read models are derived from the tables above, so the code browser reads one table for a tree or a history. A crawl brings them up to date after it publishes, and `ahto storage derive` does the same on its own. The parsing tables (symbols, imports, calls and the syntax trees) are in [parsing](/docs/parsing), and the advisory tables in [security](/docs/security). (From /docs/querying) --- # Parsing ahto parses the source files of the lake into tables of declarations, imports, calls, comments and syntax trees, once per distinct blob. A crawl does it after it publishes, so the code browser, the workbench and SQL can ask what a function calls, who imports a package or where a name is used. ## Languages ahto parses Go with Go's own `go/parser` and every other language with a tree-sitter grammar. The [languages table](/docs/languages) lists them with their extensions. The grammars are vendored under `third_party/treesitter` and compiled into `ahto` with cgo. A build without cgo parses Go only. The Noir grammar is GPL-3.0, so the binaries ahto ships leave it out; build with `-tags noir` to parse `.nr` files. ## The tables | Table | One row per | |---|---| | `parse_status` | source blob: parsed, parsed with syntax errors, or skipped (too large or generated), with its language and parser | | `symbols` | declaration: function, method, type, struct, interface, variable, constant or field, with its signature, body hash and doc | | `imports` | import of a file, with its alias | | `symbol_refs` | identifier that uses a name, resolved to its declaration in the same file when it can be | | `calls` | call, with its callee, how it resolved and the declaration it is inside | | `comments` | comment, with the declaration it documents and whether it is a directive | | `syntax_nodes` | node of the raw syntax tree; the `syntax_tree` view gives each node its index, parent and offsets | `ahto query schema ` gives every column with what it means. The full design, and what is still to come (cross-file symbol resolution), is in the source intelligence design document. ## When files are parsed A crawl parses the new source blobs after it derives the read models, and `ahto parse [--repo]` does the same on its own. `crawl --no-parse` leaves the parse stage out for one crawl, and `lake.parse.enabled: false` for every crawl; `ahto parse` catches up later. A blob is parsed once, and parsed again only in two cases: - **Automatically, when ahto's extraction changes.** Each `parse_status` row records the extraction version that wrote it (the last word of `parser`, such as `v1`). When a newer ahto extracts more or differently, the next crawl or `ahto parse` parses every blob an older version parsed and drops its old rows, in the same publish. Nothing has to be dropped by hand. - **On purpose, with `ahto parse --rebuild`.** It parses every source blob again, whatever version parsed it, and replaces its rows. Use it after a crash or an interrupted run you do not trust, on a lake whose parsing tables look wrong, after changing `lake.parse.max_bytes` or `skip_generated`, or to write the tables anew. It takes `--repo` (only the blobs of those repositories), `--no-syntax-nodes` and `--lock-timeout` like the rest of `ahto parse`. Either way the new rows and the dropped ones are published together, so a blob never counts twice. `ahto parse` reports how many blobs it parsed again as `reparsed`. ## Syntax trees `ahto inspect --ast :` prints the syntax tree of one file, and the `GetSyntax` rpc of the [source service](/docs/gateway#the-source-service) returns it, for any language ahto parses. `syntax_nodes` is by far the largest parsing table, and it is on by default (`lake.parse.syntax_nodes`). For the whole history of golang/go (191,272 distinct Go blobs, 6.90 GB of source) it is 1.04 billion rows and 3.1 GB on disk, out of 4.84 GB for all the parsing tables, and it adds 18 to 28 s to a parse that takes 30 s without it (Apple M4 Pro, 14 cores, measured 2026-11-23). `--no-syntax-nodes` on `crawl` or `parse` leaves it out for one run; `inspect --ast` and `GetSyntax` then parse the file again when asked. `ahto storage status` shows its size. (From /docs/parsing) --- # Languages ahto parses these languages into symbols, imports, calls, comments and syntax trees. Go uses Go's own `go/parser`; every other language uses a tree-sitter grammar compiled into the binary. | Language | Extensions | |---|---| | Go | `.go` | | Rust | `.rs` | | C, C++ | `.c` `.h`, `.cc` `.cpp` `.cxx` `.hh` `.hpp` and more | | JavaScript, TypeScript, TSX | `.js` `.mjs` `.cjs` `.jsx`, `.ts` `.mts` `.cts`, `.tsx` | | Python, Java, PHP | `.py` `.pyi`, `.java`, `.php` | | Solidity, Cairo, FunC, Circom, Tact, Move, Sway | `.sol`, `.cairo`, `.fc` `.func`, `.circom`, `.tact`, `.move`, `.sw` | | Noir | `.nr`, only in a build with `-tags noir` | A build without cgo parses Go only. [Parsing](/docs/parsing) lists the parsing tables and says when files are parsed again. (From /docs/languages) --- # The lake The lake is a directory on your disk with plain Parquet files, the bare Git mirrors they were read from and a manifest of which files make up each table. Nothing is uploaded. ## Where it is By default the lake is `~/.local/share/ahto/lake`. Use another with `--lake ` or `AHTO_LAKE_DIR`, or set `lake.dir` in the config. A crawl writes each repository into one lake: the location that names the repository, else the location with the longest organization that holds it, else `lake.dir`. `--lake` given on the command line sends the whole crawl to that lake instead. Each location is a whole lake of its own; read it with `--lake `. ```yaml lake: dir: ~/.local/share/ahto/lake locations: # other lakes for some repositories; the rest go to dir - dir: /Volumes/Disk0/ahto/lake repos: [github.com/torvalds/linux] # these repositories orgs: [github.com/rust-lang] # and every repository under these ``` ## Looking after it ```sh ahto storage status # size of the tables, the mirrors and the index ahto repo list # the repositories in the lake ahto repo show # its remotes, refs and last crawls ahto repo rm # remove it (its shared objects stay until a later gc) ahto storage gc # delete what removed repositories left behind ahto storage compact [table] # merge small files; with no table, those with more than --min-files files ahto storage derive # bring the read models (tree_files, path_changes) up to date ahto storage verify # check every file, row count and id index of the lake ``` Every crawl and sync compacts on its own the tables that have more than 64 files of under 1 MB each on average, such as crawl_runs, which gets a file on every sync. Run `ahto storage compact` for the big tables. ## Reading it with other tools The tables are plain Parquet files under `data/`, so DuckDB, Python or any other Parquet reader can read them too. `ahto query tables` lists them with their files, rows and bytes. ## One writer at a time Only one crawl, parse or sync writes to a lake at a time: a second one exits with code 75, or first waits as long as `--lock-timeout` (`lake.lock_timeout`) says. Readers never wait. A write that is stopped halfway leaves the lake as it was, since the manifest names the new files only once they are all on disk. ## Keeping it in sync `ahto serve` syncs each repository it serves every `lake.sync_interval` (5 minutes by default; 0 turns it off). A crawl of a repository with nothing new reports `unchanged` and writes nothing. (From /docs/lake) --- # Commands Every command of the `ahto` CLI on one page, in the groups `ahto --help` shows. `ahto --help` shows the options of each. ## Lake | Command | What it does | |---|---| | `crawl` | fetch repositories and add them to the lake, then derive the read models and parse the new source files ([getting started](/docs/getting-started#choosing-what-to-crawl)) | | `login` | show, check or keep the login for an https remote ([private repositories](/docs/private-repositories)) | | `repo list`, `repo show`, `repo rm` | the repositories in the lake | | `storage status`, `storage compact`, `storage gc`, `storage derive`, `storage verify` | the lake on disk and its read models ([the lake](/docs/lake)) | | `parse` | parse the source files a crawl has not parsed yet; `--rebuild` parses them all again ([parsing](/docs/parsing)) | ## Query | Command | What it does | |---|---| | `query sql`, `query file`, `query explain`, `query export` | SQL over the lake, a file of SQL, a query plan, and export to JSON, CSV, Parquet or Arrow ([querying](/docs/querying)) | | `query tables`, `query schema` | the tables with their files, rows and bytes, and their columns with what each means | | `files`, `history` | the files at a ref, and the commits that changed a path | | `inspect` | one commit, tree, blob or tag; `--ast :` the syntax tree of a source file | | `security sync`, `security sources` | download the OSV, CISA KEV and EPSS feeds into the lake, and how the last sync went ([security](/docs/security)) | | `security search`, `security show` | search the advisories, and one advisory with the lake commits it names | | `security posture`, `security deps`, `security findings` | a repository's grade, its pinned packages, and what puts it at risk at a commit | | `function list`, `function call` | the built-in and WebAssembly functions over the lake, and running one ([querying](/docs/querying#functions)) | | `function new`, `function test` | start a new function in a folder, and compile and call it once without adding it | | `task list`, `task tree`, `task get`, `task rollup` | the node's [task tree](/docs/gateway#the-task-service): the roots or a task's children, a subtree with roll-ups, one task with its path and links, and a roll-up | | `task add`, `task update`, `task move`, `task state`, `task link` | add a task, change the fields given as flags, move it under a parent or among its siblings, set its state (with `--evidence`, `--pr`, `--reason` or `--force-reason`), and add or `--remove` a link | | `task ready`, `task plan`, `task chain`, `task late` | the tasks to start next, the open tasks fitted into days at `--hours-per-day` from `--start`, the longest chain of dependencies by hours, and what is late | | `task export`, `task import` | the whole task log in the `ahto.task.v1` format to a file or stdout, and adding the ops another node's export has that this one lacks | ## Serve | Command | What it does | |---|---| | `serve` | run the [gateway](/docs/gateway): MCP, REST, gRPC, JSON-RPC, GraphQL, WebSocket, MQTT and OpenAPI on one port, with the lake as the [source service](/docs/gateway#the-source-service); `serve --stdio` serves the [MCP tools](/docs/gateway#mcp) over stdin and stdout instead, for a client that starts ahto itself. On a port it also answers the built-in [web app](/docs/gateway#the-web-app) at `/`, with the API also below `/api`; `--no-ui` leaves it out. It also takes OpenTelemetry on `127.0.0.1:4318` for the [debugger](/docs/debugger); `--otlp-listen off` turns that off | | `mcp-tools` | print the MCP tools the gateway would offer | | `ui` | print a one-time code that signs the web UI in as this node's owner, when the node is an authority member ([identity](/docs/identity)) | | `migrate` | schema migrations of the configured databases ([adapters](/docs/adapters#migrations)) | | `p2p init`, `p2p id`, `p2p ca`, `p2p admit`, `p2p revoke`, `p2p network`, `p2p publish`, `p2p psk` | the peer-to-peer node: its key and peer ID, the network's CA, and who is a member ([networking](/docs/networking)) | | `p2p guardian list`, `set`, `rehearse`, `sign`, `cancel` | the guardians that sign a network's recovery ([identity](/docs/identity#recovery)) | ## Setup | Command | What it does | |---|---| | `doctor` | check Git, the lake and DuckDB | | `version` | the versions of ahto, Go, Git, DuckDB and the lake schema | | `upgrade` (`update`) | replace this binary with the newest release, checked against its `SHA256SUMS`; `--check` only looks, `--version v0.1.2` picks one | | `config` | print the settings in effect ([configuration](/docs/configuration)) | ## Tools | Command | What it does | |---|---| | `check run`, `check plan`, `check key`, `check mtime` | run a repository's checks and skip the ones whose inputs did not change since they last passed ([checks](/docs/checks)) | | `cas gocacheprog` | a content-addressed store, served to `go build` as its `GOCACHEPROG` build cache ([checks](/docs/checks#a-go-build-cache)) | ## Global flags | Flag | What it does | |---|---| | `--lake ` | the lake to use (`AHTO_LAKE_DIR`) | | `--config ` | a YAML config, or a directory of them; repeat to layer (`AHTO_CONFIG`) | | `--env ` | `development`, `test`, `staging` or `production` (`AHTO_ENV`) | | `--profile ` | write Go profiles (cpu, heap, mutex and more) to this directory; `report` prints a table of spans, `trace` adds an execution trace (large, and slow for cgo-heavy commands such as parse) | | `--log-level`, `--log-format` | how much to log, and as console text or JSON | | `--pprof-listen ` | serve Go's pprof on this loopback address while the command runs | (From /docs/commands) --- # Agents The agents service lets the gateway run a coding agent such as Claude or Codex on your machine, and streams what it does back. It is off by default and has no command of its own: you reach it through the gateway's REST API, its MCP tools and the web UI. This page says how to turn it on, which agents exist and where it stops. ## Turn it on Set `agents.enabled` in the config (or `AHTO_AGENTS_ENABLED=true`) and restart `ahto serve`: ```yaml agents: enabled: true default: claude # the agent a call uses when it names none ``` The agent's own program must be installed and signed in on this machine; ahto starts it and does not sign it in. `claude` and `codex` are on and use your subscription sign-in by default; the others are off until you set them. | Agent | Default | How ahto reaches it | |---|---|---| | `claude` | on, `read_only` | the `claude` program, with your sign-in | | `codex` | on, `read_only` | the `codex` program, with your sign-in | | `grok` | off | an HTTP API (`base_url`, `model` `grok-4`), needs `api_key` | | `mistral` | off | an HTTP API (model `devstral-medium-latest`), needs `api_key` | | `ollama` | off | a model on this machine (`http://127.0.0.1:11434/v1`, model `qwen2.5-coder:7b`), needs no key | Every agent takes the same keys, and a key that does nothing for an agent is refused at start: `enabled`, `auth` (`subscription`, `api_key` or `none`), `model`, `binary`, `base_url`, `api_key`, `sandbox` and `timeout` (10 minutes when unset). `sandbox` is `read_only` or `workspace_write`: the second lets the agent change files. `agents.mcp.servers` lists MCP servers, each a `command` (spoken to over stdio) or a `url`, with an `env` map. ## Use it | Call | What it does | |---|---| | `GET /v1/agents` | the agents, whether each is enabled, and whether it is ready | | `POST /v1/agents/{name}/ask` | one question, one answer | | `POST /v1/agents/{name}/runs` | a run that streams its steps as they happen | `ready` means the agent can run now: its program is installed and signed in, or its API answers. An agent that talks to a chat API (`grok`, `mistral`, `ollama`) calls the MCP servers named under `agents.mcp.servers`; `claude` and `codex` use their own tools. ## Where it stops - Agents run on the owner's machine only. The gateway refuses a call when it is in public mode, and when `protocol.allow_remote` is set, because there is no sign-in for the caller yet. - No `ahto agents` command exists. - The proxy that keeps the agent's credentials out of its hands (RFC 0022) is in use when `claude` or `codex` run with `auth: api_key`. Two building blocks have code and tests but no command or API yet: a workspace an agent works in and hands back as a patch (RFC 0023), and a table of runs (RFC 0024). Do not rely on them. The design is RFC 0016. Not to be confused with [agents in this repository](/docs/gateway#agents-in-this-repository): that is how an outside agent, such as Claude Code, reaches ahto. This page is the reverse: ahto running an agent. (From /docs/agents) --- # Checks and the build cache `ahto check` runs your repository's checks and skips the ones whose inputs have not changed since they last passed. Two things live on this page: the check runner, which CI uses, and a build cache for Go that stores its files in ahto's content-addressed store. Both are built and work on one machine. ## Run checks A check is a command and the git paths it reads. List them in `ci/checks.json` at the repository's root: ```json {"checks": [{"name": "hello", "run": "echo hello from check", "inputs": ["src"]}]} ``` ```sh ahto check plan # which checks would run ahto check run # run the ones with no stored pass ahto check run # again: nothing changed, so nothing runs ``` ```text hello runs 1 of 1 checks would run; caches needed: none ``` ```text hello | hello from check hello | pass in 19ms ahto check: 0 cached, 1 passed, 0 failed in 207ms ``` ```text hello | cached: passed at 2026-11-30T13:41:12Z in a571ca3f4226 (0.0s) ahto check: 1 cached, 0 passed, 0 failed in 34ms ``` Change a file under `src`, commit it, and `ahto check run` runs the check again. How a check is kept: - Its key is a hash of the check itself, the platform and the contents of the tracked files its `inputs` match, so the key changes exactly when an input does. - Only a pass is stored, in `.cache/ahto-check` in the repository root (`-cache DIR` moves it). A failure is never stored. - A check whose inputs hold changes that are not committed runs and is not stored, so a stored pass always describes committed files. - `ahto check key NAME` prints a check's key and whether it is stored. | Field of a check | Meaning | |---|---| | `name`, `run` | what it is called, and the shell command (`sh -c`, in the repository root) | | `inputs` | git pathspecs it reads; `@name` stands for a group from the file's `groups` | | `salt` | `daily` (a new pass each UTC day, for checks against data that changes on its own) or `commit` (a new pass for each commit, for checks that read history) | | `after` | checks that start first when both run, because they share a cache | | `needs` | the caches the check uses; `plan` reports them for CI | Flags go before the names: `-f FILE` for another checks file, `-cache DIR`, `-j N` for how many run at once (default the number of CPUs). In CI, `ahto check plan` with `GITHUB_OUTPUT` set writes the misses and the caches they need there, so a job can skip setting up what nothing uses. `ahto check mtime` sets each tracked file's time to its last commit, so Go's test cache keeps its results on a fresh clone (not exercised for this page). This repository's own checks are in `ci/checks.json` and are what `mise run check` and the CI workflow run. ## A Go build cache `ahto cas gocacheprog` serves Go's build cache from the store, so a second build of the same code fetches its results instead of compiling them: ```sh export GOCACHEPROG="ahto cas gocacheprog --dir $HOME/.cache/ahto-cas" go build ./... ``` Measured on a tiny module on one machine: the first build had 0 hits and 57 misses; a second build with `go build -a` (which ignores Go's own cache) had 28 hits and 1 miss. `--stats FILE` writes these counters as JSON when it ends. `--max-bytes` (default 20 GiB, a starting value that was not measured) removes the least recently used blobs above it. Logs go to stderr, since stdout carries Go's protocol. The store is on one machine. Fetching a blob from a peer is not built and the design (RFC 0013) is still proposed. (From /docs/checks) --- # Debugger The debugger takes traces, logs and crash reports from your own programs and ties each one to the commit and file it came from. It is the first part of a larger plan: what is built is the receiving end and the lookup. Probes that reach into a running program are not built. ## What is built `ahto serve` listens for OpenTelemetry over OTLP/HTTP on `127.0.0.1:4318`, the port exporters use by default, so a program that already exports traces needs no change: ```sh OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 ./your-program ``` ahto keeps what it receives in its own DuckDB file, beside the lake and not in it, for 7 days. It maps a build to a commit of the lake using the revision Go stamps in the binary (or the `service.version` the program reports: a tag, a branch or a commit), and a stack frame to the file and line in that commit. | Call | What it returns | |---|---| | `GET /v1/debug/targets` | the services that sent something | | `GET /v1/debug/traces`, `/traces/{trace_id}` | find traces, read one | | `GET /v1/debug/logs` | logs | | `POST /v1/debug/crashes` | send a crash report | | `GET /v1/debug/crashes`, `/crashes/{id}` | list crash reports, read one with its code mapped | ## Try it without a program With `ahto serve` running, send one span by hand and read it back: ```sh curl -s -X POST http://127.0.0.1:4318/v1/traces -H 'Content-Type: application/json' -d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"demo"}}]},"scopeSpans":[{"spans":[{"traceId":"5b8efff798038103d269b633813fc60c","spanId":"eee19b7ec3c1b174","name":"GET /hello","kind":2,"startTimeUnixNano":"1700000000000000000","endTimeUnixNano":"1700000000050000000"}]}]}]}' curl -s http://127.0.0.1:8080/v1/debug/traces ``` ```text {} {"traces":[{"trace_id":"5b8efff798038103d269b633813fc60c","service":"demo","root":"GET /hello","start":"2023-11-14T22:13:20Z","duration_us":"50000","spans":1,"error":false,"error_message":"","version":""}],"next_page_token":""} ``` ## Settings | Setting | Default | What it does | |---|---|---| | `--otlp-listen` (`AHTO_OTLP_LISTEN`) | `127.0.0.1:4318` | where `ahto serve` takes OTLP; `off` turns it off | | `debug.path` | `debug/debug.duckdb` in ahto's data folder | the store; one process opens it, `ahto serve` | | `debug.retention_days` | `7` | days kept, 1 to 90, counted from when ahto received the data | The listener is on loopback only and is never started in public mode or with `protocol.allow_remote`. ## Not built yet Probes (breakpoints and snapshots in a running program) are planned. The design is RFC 0021. (From /docs/debugger) --- # The API `ahto serve` puts every rpc on one port, `127.0.0.1:8080` by default, on every surface at once: MCP at `/mcp`, REST at `/v1/...`, JSON-RPC at `/rpc`, GraphQL at `/graphql`, WebSocket at `/ws`, MQTT over WebSocket at `/mqtt`, gRPC on any path, and Arrow streams at `/arrow/v1/`. `/openapi.json` describes the REST routes, and `/llms.txt` is a short guide for agents, built from the live catalog. ```sh curl 127.0.0.1:8080/v1/source/repositories # the repositories in the lake curl 127.0.0.1:8080/llms.txt # one line per call ``` A gateway that listens on loopback asks for no sign-in unless the node is an authority member. [The gateway](/docs/gateway) covers each surface and the source service. The API explorer, at `/docs/api` in the web app, sends real requests and runs on the [live demo](https://demo.ahto.dev/docs/api). (From /docs/the-api) --- # The gateway `ahto serve` is a local gateway that serves the lake and your gRPC services on one port, as MCP tools, REST routes and more. Point it at one or more gRPC backends and it serves every rpc on one port as an MCP tool, a REST route, a JSON-RPC method, a GraphQL field, a WebSocket call, an MQTT topic and a gRPC method, with an OpenAPI document for the routes. There is no sign-in unless the node is in its network's authority group (`p2p.networks[].authority.member`, RFC 0014): then calls need a session ([when sign-in applies](/docs/identity#when-it-applies)), and `ahto ui` prints a one-time code that signs the browser in. See also [security](/docs/security#how-ahto-keeps-itself-safe). With no configuration there are eight backends, all inside the process, and 87 rpcs (`/readyz` lists them). `base` has six rpcs (`Ping`, `GetInfo`, `ListServices`, `CheckUpdate`, `WatchStatus` and `Watch`; see `proto/ahto/base/v1/base.proto`), enough to try every surface. Turning [sign-in](/docs/identity) on adds a ninth backend, the identity service (`cli/settings.go`). The debugger's rpcs (`debug.*`) have no sign-in, so a public gateway, or one that allows remote callers (`protocol.allow_remote`), denies them: they leave the catalog and `GetInfo` lists them in `denied_rpcs`. `source` reads the lake: see [The source service](#the-source-service). The catalog is the same on every surface, so `/llms.txt` always lists what your build has. ## Surfaces Every surface serves the same catalog of rpcs, on the same port. | Surface | Path | What it is | |---|---|---| | `mcp` | `/mcp` | One MCP tool per rpc, named `_` (streamable HTTP) | | `mcp_sse` | `/sse` | The same tools over HTTP with server-sent events, for older MCP clients | | `rest` | `/` | The `google.api.http` routes; a server stream is server-sent events | | `jsonrpc` | `/rpc` | JSON-RPC 2.0; `rpc.discover` answers an OpenRPC document | | `openapi` | `/openapi.json` | The OpenAPI 3.1 document of the REST routes | | `ws` | `/ws` | WebSocket with JSON frames; many calls on one connection | | `graphql` | `/graphql` | GraphQL over POST | | `mqtt` | `/mqtt` | MQTT 3.1.1 and 5 over WebSocket; request and reply topics | | `llms` | `/llms.txt` | A short Markdown guide for agents: the surfaces, examples, one line per call | | `llms-full` | `/llms-full.txt` | The same with each call's comment and fields; `?backend=` keeps one backend | | `agent` | `/agent` | The same guide as an HTML page with no JavaScript | | `grpc` | any path | gRPC on the same port (HTTP/2, plaintext or TLS) | Two more paths: `/healthz` says the process is up, and `/readyz` lists the backends. ### The web app The released binary has the web app (`ui/app`) built in, and `ahto serve` answers it on the same port: open `http://127.0.0.1:8080`. Every path above is then also below `/api`, which is where the web app calls: `/api/mcp`, `/api/v1/base/ping`, `/api/llms.txt`. A request below `/api` is served without it and with `/api` in `X-Forwarded-Prefix`, after any prefix a proxy in front sent, so the pages for agents name the right paths. The gateway's own paths win at the root: `/mcp`, `/healthz`, `/llms.txt`, `/openapi.json` and the REST routes (`/v1/...`) answer as they do without the web app, and a mistyped `/v1` path is still a JSON 404. Any other `GET` or `HEAD` gets the web app's file, or its `index.html` for a client that takes HTML. Files under `/assets/` are cached for a year (their names change with each build); the rest is checked on every load. gRPC is unchanged. `ahto serve --no-ui` leaves the web app out, and so does `serve --stdio`. A binary built without `ui/app/dist` (`scripts/build.sh` embeds it when it is there) serves the gateway alone. ### Pages for agents `/llms.txt`, `/llms-full.txt` and `/agent` are built on each request from the live catalog, so a denied rpc is on none of them and a moved surface shows its new path. Behind a proxy that mounts the gateway under a path, send that path in `X-Forwarded-Prefix` (for example `/api`): these pages put it in front of every path, and `/openapi.json` names it in `servers`. A prefix that is not one to four plain path segments is ignored. ```sh curl 127.0.0.1:8080/llms.txt curl '127.0.0.1:8080/llms-full.txt?backend=base' ``` Each surface can be turned off or moved to another path in the configuration. ## Calling an rpc An rpc has three names, and every surface and every allow or deny list takes any of them: | Form | Example | Note | |---|---|---| | Canonical | `base.BaseService.Ping` | `..`, always unique | | Short | `base.Ping` | `.`, when it is unique | | Tool | `base_ping` | The MCP tool name and the GraphQL field name | ### REST ```sh curl 127.0.0.1:8080/v1/base/ping curl -N 127.0.0.1:8080/v1/base/watch -d '{"count":3}' # a stream: server-sent events curl 127.0.0.1:8080/openapi.json ``` Fields of nested messages are query parameters with dots: `?filter.page.size=5`. When two routes match one path, the one with more literal segments is served: `GET /v1/tasks/tree` is `GetTree`, not `GetTask` with the id `tree`. A tie goes to the rpc listed first. ### JSON-RPC ```sh curl 127.0.0.1:8080/rpc -d '{"jsonrpc":"2.0","id":1,"method":"base.Ping","params":{"message":"hi"}}' curl 127.0.0.1:8080/rpc -d '{"jsonrpc":"2.0","id":1,"method":"rpc.discover"}' ``` - `params` is the request message as an object. - One call or a batch of up to 50. A call with no `id` is a notification and gets no answer. - A server stream answers as `{items, truncated, reason}`. - Errors: -32700 not JSON, -32600 not a call, -32601 unknown method, -32602 bad params, -32000 the call failed (the problem is in `data`). ### GraphQL ```sh curl 127.0.0.1:8080/graphql -H 'content-type: application/json' \ -d '{"query":"{ base_ping(message: \"hi\") { message } }"}' ``` - An rpc whose route is a GET is a query; every other rpc is a mutation. - The arguments are the fields of the request message. - A server stream answers as `{items, truncated, reason}`. There are no subscriptions. - A failure is a GraphQL error with the problem code in `extensions.code`. - POST only; a GET is answered with 405. ### WebSocket Connect to `ws://127.0.0.1:8080/ws` and send JSON text frames. ```json {"type":"call","id":"1","rpc":"base.Watch","body":{"count":3}} ``` The gateway answers each call with zero or more `data` frames, then one `end` or one `error`: ```json {"type":"data","id":"1","body":{"sequence":1}} {"type":"end","id":"1"} ``` `{"type":"cancel","id":"1"}` stops a call. The `id` is yours to choose. One connection holds up to 64 open calls, and a stream is sent in full as it comes. ### MQTT Connect an MQTT client to `ws://127.0.0.1:8080/mqtt` and publish the request message as JSON to `rpc/`, for example `rpc/base.Ping`. | Case | Where the answer goes | User property `status` | |---|---|---| | The request has a response topic (MQTT 5) | that topic | `ok`, or `data` then `end`, or `error` | | Unary, no response topic | `rpc//reply` | `ok` | | Stream, no response topic | `rpc//reply`, then `rpc//end` | `data`, then `end` | | Failure, no response topic | `rpc//error` | `error` | The correlation data of the request is echoed. A client may subscribe to anything and may publish only to `rpc/`. A request is never handed to other subscribers: this is a request and reply surface, not a message bus. ### gRPC A gRPC client calls the gateway's port as if it were the backend: ```sh grpcurl -plaintext -proto proto/ahto/base/v1/base.proto -import-path proto \ -d '{"message":"hi"}' 127.0.0.1:8080 ahto.base.v1.BaseService/Ping ``` The gateway does not serve gRPC reflection and does not forward request metadata. A method that is unknown or denied answers `Unimplemented`. ### MCP ```sh mise run mcp:add # register the gateway in Claude Code as "ahto" for every folder mise run mcp:tools # print the tool table as JSON, serve nothing ``` Each rpc is one tool. Its description is the comment of the rpc in the proto file, and its input schema is built from the request message. A server stream is collected into one answer, up to the limits in `protocol.streams` or `protocol.mcp`. A tool's hints (read only, destructive, idempotent) follow from the rpc: one served by `GET` or marked `NO_SIDE_EFFECTS` reads, one marked `IDEMPOTENT` is idempotent, and a write destroys unless its name starts with `Add` or `Sync`. An rpc can set them itself with the option `(ahto.base.v1.tool)` from `proto/ahto/base/v1/options.proto`, as the task service does for `UpdateTask` (a write that destroys nothing) and `Import` (idempotent). By default `tools/list` is brief: each tool has its title, the first sentence of its description and the names and types of its fields, and a `describe_tools` tool gives any tool in full (schema and description). The full list of every tool is about 60 KB, which every session would read before its first call. `/mcp?tools=full` lists them in full; `protocol.mcp.brief: false` makes full the default, and then `/mcp?tools=brief` gives the brief list. stdio follows `protocol.mcp.brief`. Every tool can be called either way. Two resources let a client attach context by URI. `ahto://schema` is the schema of every lake table (what `source_get_schema` answers), and the template `ahto://{repo}/{commit}/{+path}` is the text of one file: `repo` is the repository id, `commit` an id, branch or tag, or `HEAD` or `-` for the default branch head. Each is read through its tool, so it is listed only while `protocol.mcp` lists that tool. A file over `source_get_file`'s caps answers its first part, and `_meta` says `truncated` and `next_start_line` for `source_get_file` to read on; a binary file has no text and `_meta` says `binary` and `raw_url`. Tool answers are JSON text with no `outputSchema`: each fits `max_bytes` or says `_truncated`, and the input schema and description say the fields. The server's `instructions` say which tool to call when: `source_list_repositories` first, since the other tools take its repository id; `source_run_query` after `source_get_schema` for counts and rankings; `function_call` with `explain_symbol` for one symbol; `source_get_file` with lines to read code. Three prompts start common tasks, and most clients show them as slash commands: | Prompt | Arguments | What it asks the agent to do | |---|---|---| | `ahto_start` | none | list the repositories, with the order of calls above | | `ahto_explain` | `symbol` (required), `repo` | explain a symbol: `explain_symbol`, then its definition with `source_get_file` | | `ahto_review` | `commit` (default the head), `repo` | review a commit: `source_get_commit`, the `impact` function, `source_get_review` | There is one MCP server with one tool table, reachable three ways: | Transport | How | For | |---|---|---| | Streamable HTTP | `/mcp` on the gateway's port | most clients; each request stands alone | | HTTP with server-sent events | `GET /sse` opens the stream, which names the URL to POST to | clients that only speak the older (2024-11-05) transport | | stdio | `ahto serve --stdio` | clients that start the server themselves | The two HTTP transports pass the same local-only check as every other surface, and either can be turned off or moved under `protocol.surfaces`. A session that stays open (stdio or SSE) is told with `notifications/tools/list_changed` when a backend that was down comes up and its tools appear. With `--stdio`, ahto reads one JSON-RPC message per line from stdin and writes its answers to stdout, and nothing else; logs go to stderr. It binds no port and does not start the peer-to-peer node. The client is the process that started it, so it has the rights of a loopback client even when `protocol.allow_remote` is set. It exits when stdin closes. A client config that starts it: ```json { "mcpServers": { "ahto": { "command": "ahto", "args": ["serve", "--stdio"] } } } ``` Add `"--config", "/path/to/ahto.yaml"` before `"serve"` to use a config file other than the default one. ### Agents in this repository An agent opened in this repository knows ahto and reaches the gateway with nothing set up on the machine (ADR 0012, RFC 0019). The files are committed: | File | Read by | What it holds | |---|---|---| | `AGENTS.md` | Codex, Cursor, Copilot, Gemini, Zed, opencode, Amp, Junie and most others | what ahto is, which tool when, how to test and commit | | `CLAUDE.md` | Claude Code | `@AGENTS.md`, so both read one text | | `.mcp.json` | Claude Code, VS Code Copilot, Grok | the server `ahto` at `${AHTO_MCP_URL:-http://127.0.0.1:8080/mcp}` | | `.claude/settings.json` | Claude Code | turns `ahto` on and allows its read-only tools with no prompt | | `.claude/skills/ahto-mcp/` | Claude Code, Cursor, Cline, opencode, Amp, Goose | the skill: the order of calls, cut answers, what not to call | | `.agents/skills/ahto-mcp` | Codex, Gemini, Zed, Amp, Goose | a link to the same skill | Claude Code asks once whether to trust the folder; after that the server and the read-only tools work. The tools that change state (adding, removing or syncing a repository, adding a function, changing settings, running an agent) still ask each time. Set `AHTO_MCP_URL` when the gateway runs on another port. Personal settings go in `.claude/settings.local.json`, which git ignores, as it ignores every other file in `.claude/`. ## The source service `ahto serve` also serves the lake (`--lake` or `lake.dir`) as `ahto.source.v1.SourceService` (`proto/ahto/source/v1/source.proto`), for a code browser and for agents. It holds one DuckDB engine, opened read-only and locked down, checks the lake's manifest every second and swaps to a new engine when a crawl or `storage gc` publishes; calls in flight finish on the old engine. With no lake the calls answer `Unavailable` until one appears. | Rpc | REST | Takes | Cached | |---|---|---|---| | `ListRepositories` | `GET /v1/source/repositories` | | no | | `Resolve` | `GET /v1/source/resolve` | `repo`, `rev` (branch, tag, `HEAD` or id; empty is the default branch), `path` | no | | `GetTree` | `GET /v1/source/tree` | `repo`, `commit`, `path` | yes | | `GetFile` | `GET /v1/source/file` | `repo`, `commit`, `path` | yes | | `GetSyntax` | `GET /v1/source/syntax` | `repo`, `commit`, `path` (a file in any language ahto parses; another file is `FailedPrecondition`) | yes, by blob as well | | `ListHistory` | `GET /v1/source/history` | `repo`, `commit`, `path`, `page_token`, `limit` (default 50, at most 1,000) | yes | | `GetCommit` | `GET /v1/source/commit` | `repo`, `commit` | yes | | `FindFiles` | `GET /v1/source/files/find` | `repo`, `commit`, `text` (a part of the path, any case; empty is every file), `limit` (default 50, at most 1,000) | yes | | `GetActivity` | `GET /v1/source/activity` | `repo`, `commit`, `path` (empty is the whole repository), `bucket` (`day`, `week`, `month` or `year`; empty is `month`) | yes | | `ListFileStats` | `GET /v1/source/files/stats` | `repo`, `commit`, `path` (a folder or a file; empty is every file), `limit` (default 50, at most 1,000) | yes | | `ListAuthors` | `GET /v1/source/authors` | `repo`, `commit`, `path` (empty is the whole repository) | yes | | `GetUpkeep` | `GET /v1/source/upkeep` | `repo`, `commit`, `path`, `as_of` (RFC 3339; empty is now) | no | | `GetBlame` | `GET /v1/source/blame` | `repo`, `commit`, `path` (a file) | yes | | `RunQuery` | `POST /v1/source/query` | `sql` (one `SELECT` or `WITH`), `limit` (rows, default 1,000, at most 100,000), `timeout` (default 10 s, at most 60 s) | no | | `WatchSnapshots` | `GET /v1/source/snapshots/watch` | | no; a stream of published snapshots | `repo` is the repository's id or name. `commit` must be a full commit id: resolve a branch or tag with `Resolve` first. An answer named by a commit id never changes, so the REST answers of the cached rpcs carry `Cache-Control: public, max-age=31536000, immutable` and an `ETag`, and a request with that `If-None-Match` gets `304`. Errors carry no cache headers. ```sh curl '127.0.0.1:8080/v1/source/resolve?repo=github.com/golang/example&rev=master&path=hello' curl '127.0.0.1:8080/v1/source/tree?repo=github.com/golang/example&commit=&path=hello' ``` `GetSyntax` is the syntax tree of a source file in any [parsed language](/docs/parsing#languages) (`go/parser` for Go, tree-sitter for the rest), one node per syntax node in preorder: its kind, its parent's index (`-1` for the root), depth, byte offsets and name. It reads `syntax_nodes` when the parse stage stored the blob's nodes (`stored` is true), else parses the file now; the two answers are the same node for node. A file with syntax errors still has a tree, with `status` `syntax_error` and the first error. The bytes of a file are not in `GetFile`; its `raw_url` points at the raw surface: ```sh curl '127.0.0.1:8080/raw/v1//blob/?path=hello/hello.go' curl -H 'Range: bytes=0-99' '127.0.0.1:8080/raw/v1//blob/' # 206 ``` `/raw` takes `GET` and `HEAD`, answers ranges, and sends the immutable headers with the blob id as the `ETag`. `path` only picks the content type. Images, audio, video, PDF, Wasm, zip and gzip go out as their type; every other blob is `text/plain` when it is UTF-8, else `application/octet-stream`, so HTML and SVG in a repository never run as a page on the gateway's origin (`nosniff` and a `sandbox` content security policy as well). Each repository has one held `git cat-file` process, so its blobs are read one at a time. `FindFiles` gives the first `limit` files and `total`, the count of every match. `GetActivity` counts, per bucket of author time in UTC (`hour`, `day`, `week` from Monday, `month` or `year`), the first-parent commits from `commit` that change `path` and their distinct author emails, as `git log --first-parent --no-renames -- ` lists them. Both take a commit id so their answers never change. `GetActivity` and `ListHistory` take an optional window of author time, `since` and `until` (RFC 3339 timestamps, half-open: `since` counts, `until` does not), so a zoomed chart asks only for what it shows: ```sh curl '127.0.0.1:8080/v1/source/activity?commit=&bucket=hour&since=2026-11-01T00:00:00Z&until=2026-11-08T00:00:00Z' ``` The Arrow surface streams the full answer of either one as an Arrow IPC stream (`application/vnd.apache.arrow.stream`), with no JSON to parse and no page limit: ```sh curl -o files.arrow '127.0.0.1:8080/arrow/v1//files?commit=&text=_test.go' curl -o activity.arrow '127.0.0.1:8080/arrow/v1//activity?commit=&path=src&bucket=week' ``` `files` has the columns `path`, `kind`, `mode` and `oid`; `activity` has `start` (the bucket's first second, Unix seconds), `commits` and `authors`, and takes `since` and `until` as RFC 3339 or Unix seconds. The `` is escaped as in `/raw`. The surface takes `GET` and `HEAD` and sends the same immutable headers and `ETag` as the cached rpcs. It runs the same named query as the rpc, so both give the same rows. A binary built without `-tags=duckdb_arrow` answers `501`; `scripts/build.sh` and the mise tasks build with the tag. ### The workbench rpcs The developer workbench boards of the web app read five more rpcs: - `ListFileStats` lists the files of `commit` under `path`, by path, each with its kind, size, lines, language, and the first-parent commits that change it (`commits`, distinct `authors`, `last_commit` and `last_time`), the first `limit` of them and `total`. It is the data of the code city. - `ListAuthors` lists the authors of the first-parent commits from `commit` that change `path`, by email: name, email, commits, and the author time of their first and last change, the most commits first. - `GetUpkeep` says whether `path` is still kept up, from the same authors: the last change, the whole calendar months since then (`months_idle`), the authors whose last change is in the twelve months before `as_of`, and how many authors changed it in all. Its answer moves with `as_of`, so it carries no cache headers. - `GetBlame` runs `git blame --porcelain` on the repository's mirror: `hunks` (a run of lines one commit last changed: `commit`, the `path` and `original_line` there, `line` and `lines` in the file) and `commits` (author, email, author time, subject, whether it is the `boundary`, and the `previous` commit and path). It follows renames, as git does. - `RunQuery` runs one read-only `SELECT` or `WITH` over the lake's views and gives `columns`, `rows` as JSON values (a time in RFC 3339, bytes in base64, an integer beyond 2^53 as a string) and `truncated` when more rows were there. Anything else (several statements, a write, a file read such as `read_text`) is `InvalidArgument`; a query past its timeout is `DeadlineExceeded`. It is never cached, and neither the service nor the gateway logs the SQL. ```sh curl '127.0.0.1:8080/v1/source/files/stats?repo=&commit=&path=src' curl '127.0.0.1:8080/v1/source/upkeep?repo=&commit=&path=src&as_of=2026-11-23T00:00:00Z' curl -X POST 127.0.0.1:8080/v1/source/query -d '{"sql":"SELECT count(*) FROM commits","limit":10,"timeout":"5s"}' ``` The Arrow surface has two more routes. `stats` is the full `ListFileStats` (columns `path`, `kind`, `size`, `lines`, `language`, `commits`, `authors`, `last_commit`, `last_time`), with the immutable headers. `query` is `RunQuery` as Arrow: the SQL as `sql` in a `GET`, or as the body of a `POST` (at most 1 MiB), with `limit` and `timeout` (such as `5s`) as query parameters; it answers `Cache-Control: no-store` and no `ETag`. ```sh curl -o city.arrow '127.0.0.1:8080/arrow/v1//stats?commit=' curl -o rows.arrow --data-binary 'SELECT * FROM commits' '127.0.0.1:8080/arrow/v1//query?limit=50000' ``` ## The task service The task service (`proto/ahto/task/v1/task.proto`, backend `task`) keeps the node's task tree: projects at the root, epics under them, and tasks to any depth. The design is in RFC 0020 and ADR 0014. The tree lives in one DuckDB file, `tasks.path` (by default `tasks/tasks.duckdb` in ahto's data folder). `ahto serve` opens it and holds it while it runs. In the gateway of any other command, or when another process holds the file, every task rpc answers `UNAVAILABLE` and says why. [`ahto task`](commands.md#query) opens the file itself while no process holds it, and calls this gateway's gRPC when `ahto serve` does. In public mode every task rpc answers `PERMISSION_DENIED`: the tree is the owner's own. | Rpc | REST | What it does | |---|---|---| | `ListTasks` | `GET /v1/tasks` | tasks by parent, depth, state, label, repository or assignee, paged | | `GetTask` | `GET /v1/tasks/{id}` | one task with its path from the root, its links and its rollup | | `GetTree` | `GET /v1/tasks/tree` | a subtree in rank order, to a depth, with each node's rollup | | `AddTask` | `POST /v1/tasks` | a task under a parent, or a project; after or before a sibling | | `UpdateTask` | `PATCH /v1/tasks/{id}` | the fields in `update_mask` | | `MoveTask` | `POST /v1/tasks/{id}/move` | to another parent or place among siblings | | `SetState` | `POST /v1/tasks/{id}/state` | the state, with evidence, a pull request or a reason | | `AddLink`, `RemoveLink` | `POST /v1/tasks/{from_id}/links`, `.../links/remove` | `depends_on`, `relates`, `duplicates` | | `AddComment` | `POST /v1/tasks/{task_id}/comments` | a comment, kept in the history | | `RemoveTask` | `DELETE /v1/tasks/{id}` | a tombstone on the task and its subtree | | `ListHistory` | `GET /v1/tasks/history` | the ops of a task or a subtree, newest first, paged | | `ListNext` | `GET /v1/tasks/next` | ready tasks whose dependencies are done, by due day then rank | | `PlanTasks` | `GET /v1/tasks/plan` | the open tasks under a root fitted into days, and what does not fit, paged by day | | `GetChain` | `GET /v1/tasks/chain` | the longest chain of open tasks by hours, each waiting on the one before | | `ListLate` | `GET /v1/tasks/late` | open tasks past their due day, or planned to end after it, paged | | `WatchTasks` | `GET /v1/tasks/watch` | a stream of new ops | | `Export`, `Import` | `GET /v1/tasks/export`, `POST /v1/tasks/import` | the whole op log in the `ahto.task.v1` format | States are `backlog`, `ready`, `doing`, `review`, `done` and `dropped`. A rollup counts the subtree below a task, not the task itself: total, done, dropped, hours and the latest due day. **Guards.** A write that breaks a rule answers `FAILED_PRECONDITION` with a `Refusal` detail naming the guard: `dependencies_done` (doing while a dependency is open), `open_children` (done while a child is open), `evidence` (done with no evidence and no pull request) and `reason` (dropped, or leaving done, without one). These four are skipped by a `force_reason`, which the op keeps with the guards it skipped. `move_cycle`, `dependency_cycle`, `missing` and `state` keep the tree whole and cannot be forced. Over REST a refusal is HTTP 400. **Versions.** Every task has a `version`. Pass it as `expected_version` on a write: when the task changed since, the write answers `ABORTED` with a `Conflict` detail that holds the task as it is now. Without `expected_version` the write is blind. Links and comments do not change the version. **Planning.** `PlanTasks` fits the open tasks under `root_id` (every open task without one) into days from `start_on` (today without it), `hours_per_day` hours a day (8 without it, at most 24). A task waits on its open `depends_on` tasks and its open children; of the tasks whose waits are over, the one due soonest goes first, undated ones last. A dependency of a task is as urgent as the task. A task's hours may split across days; a task without hours takes no time, and a parent without hours of its own takes no day and ends with its last child. Every day is a working day. What does not fit is a `Miss` with a reason: `overdue` (due before the plan starts), `after_due` (the plan ends it after its due day), `dependency_cycle` or `beyond_horizon` (it would end more than 3,660 days out). The misses come on the first page. `GetChain` answers the chain with the most hours (fewer tasks between equals) and the ids of any dependency loop; `ListLate` answers the `overdue` and `after_due` misses. **History.** Every write is an op in an append-only log: its `op_id` is the SHA-256 of its fields, and with p2p on and its key there, `sig` is the node's ed25519 signature. `Import` refuses an export with a changed op, adds only the ops the store lacks, and works the tree out again, so importing twice adds nothing. ```sh curl -X POST 127.0.0.1:8080/v1/tasks -d '{"title":"ahto","state":"STATE_READY"}' curl -X POST 127.0.0.1:8080/v1/tasks -d '{"parent_id":"","title":"write the docs","state":"STATE_READY","due_on":"2026-12-15"}' curl '127.0.0.1:8080/v1/tasks/tree?id=&depth=2' curl 127.0.0.1:8080/v1/tasks/next curl '127.0.0.1:8080/v1/tasks/plan?root_id=&hours_per_day=6&start_on=2026-12-01' curl '127.0.0.1:8080/v1/tasks/chain?root_id=' curl '127.0.0.1:8080/v1/tasks/late?root_id=' curl -X POST 127.0.0.1:8080/v1/tasks//state -d '{"state":"STATE_DONE","pr":""}' curl -o tasks.json 127.0.0.1:8080/v1/tasks/export curl -X POST 127.0.0.1:8080/v1/tasks/import --data-binary @tasks.json # on another node ``` ## Configuration The settings layers are described in [configuration](/docs/configuration). The gateway's section: ```yaml protocol: listen: 127.0.0.1:8080 allow_remote: false # true: accept a non-loopback address and remote callers origins: [] # web origins passkeys are used from besides loopback ones, # e.g. https://ahto.example.com (scheme://host[:port]) tls: # both set: every surface over TLS; both empty: plaintext cert_file: "" key_file: "" services: # the gRPC backends orders: address: 127.0.0.1:50051 descriptors: reflection # default; or "embedded", or a path to a descriptor set timeout: 30s rpcs: # every surface; a denied rpc does not exist anywhere allow: ["base.*", "orders.*"] deny: ["orders.OrderService.Purge"] streams: # how much of a stream MCP, JSON-RPC and GraphQL collect max_items: 100 timeout: 10s surfaces: # turn one off, or move it openapi: {enabled: false} mqtt: {enabled: false} grpc: {enabled: false} rest: {path: /api/} mcp: deny: ["orders_delete_*"] # MCP only, on top of protocol.rpcs max_stream_items: 20 # overrides protocol.streams for MCP tools: orders_get_order: {title: Get an order, read_only: true} ``` Keep the TLS key outside the repository; the config holds only its path. ## Extend the gateway from Go The repository root holds no `main` package, so the module can be imported. A program extends the gateway through `protocol.Options`: ```go g, err := protocol.New(ctx, settings, protocol.Options{ // A gRPC service served from inside the process, with no port. Local: []protocol.Local{{Name: "orders", Desc: &ordersv1.OrderService_ServiceDesc, Impl: &orders.Service{}}}, // A surface of your own. A built-in name replaces that surface. Surfaces: []protocol.Surface{protocol.NewSurface("hello", "/hello", func(g *protocol.Gateway) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { rpc, _ := g.Lookup("orders.ListOrders") req, _ := protocol.Decode(rpc, nil) out, _ := g.Call(r.Context(), "hello", rpc, req) _, _ = w.Write(out) }) })}, }) ``` A service with its own settings embeds the base `config.Config` in its struct and loads it with `config.Load`, so it gets the same layers. (From /docs/gateway) --- # Security ahto keeps the public vulnerability feeds in the lake next to your code, so it can say which advisories touch a repository at a commit. It also says which of them are exploited in the wild and what else in the code puts it at risk, and this page says how ahto keeps itself safe. ## The advisory feeds ```sh ahto security sync # the default feeds ahto security sync all # every feed ahto knows ahto security sync osv:RubyGems # one feed; an OSV feed may be named by its ecosystem ahto security sync --offline # rebuild the tables from the copies of the last sync ahto security sources # the feeds of the last sync and how each went ``` | Feed | What it holds | Synced by default | |---|---|---| | `osv:Go`, `osv:crates.io`, `osv:PyPI`, `osv:Maven`, `osv:npm`, `osv:Linux` | [OSV](https://osv.dev) advisories for those ecosystems | yes | | `kev` | CISA's [Known Exploited Vulnerabilities](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) catalog | yes | | `epss` | FIRST's [EPSS](https://www.first.org/epss/) score: how likely a CVE is to be exploited in the next 30 days | yes | | `osv:GIT`, `osv:RubyGems`, `osv:Packagist`, `osv:NuGet`, `osv:Hex`, `osv:Pub`, `osv:Debian`, `osv:Alpine` | OSV advisories for those | with `all` or by name | A sync downloads the feeds and replaces the advisory tables in one lake run, so a query never sees half a sync. It keeps a copy of each download, and `--offline` reads only those. ## Asking about a repository ```sh ahto security posture # grade, findings by severity, packages and manifests ahto security deps --vulnerable # the pinned packages that have a finding ahto security findings --severity high # what puts it at risk, riskiest first ahto security findings --kev --fixable # exploited in the wild, with a known fix ahto security search --ecosystem Go --kev # search the advisories themselves ahto security show CVE-2024-1086 # one advisory, with the lake commits it names ``` `posture`, `deps` and `findings` take `--repo` (optional when the lake holds one repository) and `--at` (`HEAD`, a ref, or a commit or tag id). `deps` reads the manifests and lockfiles at that commit. `findings` has five kinds, chosen with `--kind`: | Kind | What it is | |---|---| | `vulnerable_dependency` | a pinned package version an advisory covers | | `vulnerable_commit` | a commit an advisory names as bringing in or fixing a flaw | | `secret` | a value in the code that looks like a key or a token; shown as a fingerprint, never as the value | | `dangerous_call` | a call such as a shell or `eval` with a variable, TLS checks turned off or a broken hash (rules after gosec, bandit, flawfinder and eslint-plugin-security) | | `sensitive_file` | a file such as a private key or a credentials file | `--stream` prints each finding as it is found. Every command takes `-o json`, `jsonl` or `csv`. ## The advisory tables | Table | One row per | |---|---| | `advisories` | advisory: id and aliases, summary, severity, CVSS score, packages, CWEs, dates | | `advisory_events` | event of an affected range: introduced, fixed, last affected or limit, as a version or a commit | | `advisory_versions` | version an advisory lists as affected | | `advisory_refs` | link of an advisory: the fix, the report, the article | | `kev` | CVE in the KEV catalog: vendor, product, date added, due date, ransomware use | | `epss` | CVE with its chance of being exploited in the next 30 days, and its percentile | | `advisory_sources` | feed of the last sync: when, how many records, and ok, unchanged or failed | The functions `known_exploited_fixes` and `security_fix_commits` join them with the history: the commits that fix a KEV CVE, and the commits whose message says they fix a flaw (`ahto function call security_fix_commits`). The security service of the gateway serves the same answers to the web app and to agents. The design is in the security service design document. ## How ahto keeps itself safe - ahto runs `git` with a cleaned environment: no hooks, and no global or system Git config. Mirrors are bare, so nothing is checked out and nothing in a repository runs. - A remote URL is never written to a log or the lake with its password or token in it, and a token reaches `git` only through the environment of that one process ([private repositories](/docs/private-repositories#how-a-token-is-kept-safe)). - Email addresses are hidden from the gateway's query answers. - The gateway listens only on 127.0.0.1 unless you set `protocol.allow_remote`. Do not set it on a network you do not trust; for a gateway other people reach, set `public: true` as well ([configuration](/docs/configuration#public-mode)). Passkeys then work only from the web origins listed in `protocol.origins`, besides loopback ones: a passkey is for the host its origin names, and that host is one you choose, never one a request names. - The gateway has no authentication unless the node is in its network's authority group (`p2p.networks[].authority.member`). Then every call, loopback too, needs a session, a remote call also needs the group's lease, and `ahto ui` prints a one-time code, good once for five minutes from this machine, that signs the first browser in. A gateway with `protocol.allow_remote` mints no code. To report a vulnerability in ahto itself, see `SECURITY.md` at the root of the source. (From /docs/security) --- # Sign-in, people and recovery On a members network, people sign in to the gateway with a device key or a passkey, and every call is checked against a signed membership log. This page covers the part of [networking](/docs/networking) that is about people: who may sign in, how to bring someone in, and how a network is recovered. It is built and has tests; the commands and calls below come from the code and its protocol file, and the sign-in flow was not run end to end for this page. The design is RFC 0014. ## When it applies Sign-in is on only when all of these hold: - the network is a members network (it has a `ca`); - this node is a member of the network's authority group (`authority.member: true`); - the caller is not on this machine, or `protocol.allow_remote` is set. A gateway on `127.0.0.1` with no `allow_remote` never asks for a sign-in; that is how the [getting started](/docs/getting-started) setup works. Passwords and accounts at another provider are not offered: identity is key-based only. ## The authority group The people, credentials and grants live in a membership log, version 2. A small group of nodes (3 or 5 is the design) agrees on each new entry with Raft, so the network keeps working while one of them is down, and nobody can rewrite the log alone. Each member of the group says so in its config, with the peer IDs of the first voters, the same list on each: ```yaml p2p: enabled: true networks: - id: acme ca: ed25519:... authority: member: true voters: ["12D3KooW...", "12D3KooW...", "12D3KooW..."] # dir: acme.authority # Raft's files and the sessions, in p2p.dir ``` `voters` is read once, when the group starts in an empty folder. If it is left out, the group is this node alone. A network at log version 1 (the `p2p admit` log in [networking](/docs/networking)) keeps working as it is; v2 is what `authority.member` turns on. ## Sign in `ahto ui` is the first sign-in. On the machine that runs the node, it signs a challenge with the node's own key and prints a one-time code, good for five minutes, from this machine only: ```sh ahto ui ``` Open the web UI and enter the code; you are the network's owner. A newer code replaces the last. A gateway with `protocol.allow_remote` set mints none, so on one of those, sign in with a device key or a passkey you added earlier. How long a session lasts depends on the network's session profile, part of its policy (`GET /v1/identity/policy`): - **personal** (the default): each call keeps the session alive, and it ends after 30 days without use. The policy can set a different idle limit. - **enterprise**: after an hour without use, the session refuses calls until the same device key or passkey signs in again (`POST /v1/identity/signin`). That keeps the session. Either way it ends 24 hours after sign-in. ## Bring someone in An admin creates an invite; the person accepts it with their own device key or a passkey and becomes a member. The calls are on the gateway's REST API under `/v1/identity`: | Call | What it does | |---|---| | `POST /v1/identity/invites`, `GET /v1/identity/invites` | make an invite, list invites | | `POST /v1/identity/invites/accept` | the invited person accepts | | `GET /v1/identity/persons`, `/persons/{id}` | list people (admins see everyone, others see themselves) | | `POST /v1/identity/roles/grant`, `/roles/revoke` | give or take the role `admin` or `member`, network-wide or on a resource pattern | | `POST /v1/identity/revoke` | sign out a person, a credential or a workload | | `POST /v1/identity/credentials`, `GET` the same | add a device key or passkey, list them | | `POST /v1/identity/workloads`, `GET` the same | admit a machine (a build server, a service) | | `GET`, `POST /v1/identity/policy` | the network's session policy | | `GET /v1/identity/session`, `/sessions`; `POST /sessions/revoke`, `/signout` | your sessions | | `GET /v1/identity/authority` | whether the group has a leader and is reachable | The network keeps at least one admin: the last one cannot be taken away. Every call is checked against the log and is denied unless a rule allows it. The full request and response shapes are in `proto/ahto/identity/v1/identity.proto`. ## Audit Every entry of the log is an audit event: who, what, when. Admins read them with `GET /v1/identity/audit`, or stream them with `/v1/identity/audit/export`. To have a log shipper pick them up, set a folder; the node writes one file per UTC day there, one JSON object a line, and removes files older than `retention` (default one year, at least 24 hours): ```yaml audit: dir: audit # in p2p.dir unless absolute retention: 8760h ``` ## Recovery If the authority group is lost, the network is recovered by guardians: keys held by people you trust, of which a threshold must sign. Nothing here changes the network until enough of them sign. ```sh ahto p2p guardian list # guardians, threshold, last rehearsal, open requests ahto p2p guardian set ... # ask for a new guardian set; each new key signs it too ahto p2p guardian rehearse # practice a recovery with a throwaway key; changes nothing ahto p2p guardian sign # sign an open request with this node's key ahto p2p guardian cancel # cancel an open request ``` A key is 64 hex digits of an Ed25519 key or a peer ID. A request stays open for 7 days. A guardian who cannot reach a gateway can give `sign --payload --print` and send the signature on. Rehearse the recovery once after you set the guardians, and again when they change. ## Not built yet - Sign-in on a network that is not a members network. - Sign-in through a provider, and passwords: not planned. (From /docs/identity) --- # Private repositories ahto crawls a private repository with the login you already use for Git. It never prompts, never prints a token and keeps one only when you ask it to. ## ssh An ssh remote (`git@github.com:org/repo.git`) uses your ssh keys and agent, as `git` does. `lake.git.ssh_command` sets the ssh command when the default is not right. ## https An https remote that asks for a login gets one from the first of these that has it: 1. the URL itself (`https://user:token@host/org/repo`; better kept out of shell history); 2. `lake.git.credentials` in the config, for a host and an optional path; 3. the `GH_TOKEN` and `GITHUB_TOKEN` variables (github.com, `GITHUB_SERVER_URL`, `*.ghe.com`), `GH_ENTERPRISE_TOKEN` and `GITHUB_ENTERPRISE_TOKEN` (`GH_HOST`), `GITLAB_TOKEN` (gitlab.com or `GITLAB_HOST`) and `CI_JOB_TOKEN` (the GitLab CI server); 4. your git credential helpers (macOS keychain, Git Credential Manager, libsecret, `store`, `gh auth setup-git`), asked with `git credential fill` and prompts off; 5. `gh auth token` and `glab config get token` for that host. Sources 3 to 5 are read from your machine; `lake.git.local_logins: false` turns them off, for a server that should use only its config. A login the remote refuses moves on to the next source. ahto never prompts and never writes to a helper on its own. ## ahto login ```sh ahto login github.com # what each source holds (never the token) ahto login https://git.example.com/org/repo # also check the remote takes it ahto login --with-token git.example.com < token.txt # keep a token in your credential helper ``` ## Logins in the config For a server or CI, name the token in the config. The password is a secret: `env`, `file` or `command` (the first line it prints, for a vault or a password manager): ```yaml lake: git: credentials: - host: git.example.com path: /platform # optional: only repositories under this path password: {env: GIT_TOKEN} - host: bitbucket.org username: x-token-auth # the default user name is x-access-token password: {command: [op, read, "op://ci/bitbucket/token"]} ``` GitHub, GitHub Enterprise, GitLab (and self-managed), Gitea, Forgejo and Azure DevOps take a token as the password with any user name; Bitbucket wants `x-token-auth` or your account name. A token needs read access to the repository's contents; an organisation with SAML SSO also wants the token authorized for it. ## How a token is kept safe - A login reaches `git` through an inline credential helper that answers only for that remote's host, so a redirect to another host never gets the token. - The token is passed in the environment of that one `git` process, never on its command line, and is never logged or printed, also not by `ahto login`. - A remote URL is never written to a log or the lake with its password or token in it. - ahto keeps a token only when you run `ahto login --with-token`, and then in your own credential helper. (From /docs/private-repositories) --- # Configuration ahto needs no config file; this page says where settings come from, how the web app saves them, what public mode changes and what each key does. ## Where settings come from Settings come from five places; a later one wins: 1. the defaults of the environment (`development`, `test`, `staging`, `production`; `--env`); 2. YAML files (`--config`, repeatable; a directory is read as `base.yaml`, `.yaml`, `local.yaml`); 3. the saved settings file (`AHTO_SETTINGS_FILE`, else `~/.config/ahto/settings.yaml`), which the settings page writes; 4. `AHTO_*` variables (`log.level` is `AHTO_LOG_LEVEL`); 5. flags. `ahto config` prints the result as YAML. ## Saving settings from the web app `GET /v1/settings` lists every setting with its value, default and source. `POST /v1/settings` with `{"values": {"log.level": "debug"}}` saves to the saved file. All the values are checked first, and one bad value saves nothing. `log.level` and `log.format` apply at once; every other key applies after a restart. A key that a variable or a flag sets is locked, and so are `env`, `public`, `protocol.allow_remote`, secrets and maps. A public gateway refuses every save (the design). ## Public mode `public: true` (`AHTO_PUBLIC=true`) is for a gateway other people reach. A query DuckDB refuses then says only its kind (`the query does not parse (parser error)`), not DuckDB's message and where it points, and the settings cannot be saved. It is off by default, so on your own machine an error says what is wrong and at which character. `GET /v1/base/info` reports it as `public`. Email addresses are hidden from query answers in both modes. ## The lake [The lake](/docs/lake) explains `dir` and `locations`; [private repositories](/docs/private-repositories) explains `git.credentials`. ```yaml lake: dir: ~/.local/share/ahto/lake locations: [] # other lakes for some repositories; the rest go to dir lock_timeout: 0s # wait this long for another writer; 0 fails at once sync_interval: 5m # the server syncs a repository with no interval of its own this often; 0 is off git: binary: git timeout: 1h # per git command fsck: true # check every fetched object allow_http: false # plain http:// remotes allow_local: true # local paths and file:// remotes ssh_command: "" # the ssh command for ssh remotes; empty is git's own local_logins: true # tokens from your environment, credential helpers, gh and glab credentials: [] # logins for https remotes limits: blob_scan_bytes: 16777216 # larger blobs are recorded, not scanned (scanned=false) max_refs: 100000 # a remote that advertises more fails the crawl max_path_bytes: 4096 # a longer path is flagged max_tree_entries: 1000000 # a larger tree fails the crawl query_memory: 50% # DuckDB's memory limit, as bytes or a share of RAM; empty is DuckDB's own parquet: compression: zstd # none, snappy, gzip, zstd or lz4 row_group_rows: 122880 # the most rows in one row group max_file_rows: 10000000 # a run starts a new file of a table after this many rows content: scope: baseline # which files fill blob_contents: those in the baseline commit's tree, all or none max_bytes: 1048576 # larger files are left out parse: enabled: true # parse the new source files after each crawl; --no-parse skips it once syntax_nodes: true # store every syntax node in syntax_nodes; about 3.1 GB for golang/go max_bytes: 4194304 # larger source files are skipped; at most 1 GiB skip_generated: true # skip generated source files derive: tag_trees: false # also write tree_files for tags the crawl did not select, when their commit is in the lake ``` `query_memory` is 50% and not DuckDB's 80% because a crawl and the gateway each open an engine, and at 80% a large derive could run the machine out of memory. ## Tasks [The task service](/docs/gateway#the-task-service) keeps the node's task tree in one DuckDB file. `ahto serve` opens it and holds it while it runs; `ahto task` opens it while no process holds it, and calls the gateway at `protocol.listen` when one does. ```yaml tasks: path: ~/.local/share/ahto/tasks/tasks.duckdb # the default is tasks/tasks.duckdb in ahto's data folder ``` ## Agents and the debugger ```yaml agents: enabled: false # off until set; see agents.md for each agent's keys default: claude debug: path: ~/.local/share/ahto/debug/debug.duckdb # the default is debug/debug.duckdb in ahto's data folder retention_days: 7 # 1 to 90 ``` [Agents](/docs/agents) are off by default and refuse a public or remote gateway. The [debugger](/docs/debugger) takes OTLP on `127.0.0.1:4318` (`--otlp-listen`, `AHTO_OTLP_LISTEN`) and keeps what it gets for `retention_days`. ## The gateway, adapters and peers - `protocol`: the gateway's address, TLS, backends, allowed rpcs, streams, surfaces and MCP tools, in [the gateway](/docs/gateway#configuration). - `adapters`: the PostgreSQL, ClickHouse, DuckDB and Parquet connections, in [adapters](/docs/adapters). - `p2p`: the peer-to-peer node, off by default (`enabled: false`). It listens on port 4100 over QUIC and TCP, and its networks and members are set with `ahto p2p`. Every key is in [networking](/docs/networking#settings), and the sign-in keys in [identity](/docs/identity). The design is in the peer-to-peer design document. `dht` (default on) runs each network's private DHT, so a member that knows only the bootstrap nodes finds and connects to the other live members; `dht: false` starts none, and the node then reaches only the peers whose addresses it is given. A network's `authority` (`member`, `voters`, `dir`) makes the node a voter of the network's authority group and turns sign-in on for its gateway (RFC 0014). Its `audit` (`dir`, `retention`) copies the network's audit events and the node's to one `.jsonl` a UTC day in `dir` (in `p2p.dir` unless absolute) for a SIEM shipper, and removes those files and the node's journal files once their day is older than `retention` (default `8760h`, at least `24h`), never the newest. The membership log is never trimmed. (From /docs/configuration) --- # Networking and peers ahto nodes can form a closed peer-to-peer network, one per organization, where only nodes the organization signed in may connect. This page says what that gives you today, how to set a network up, and what is not built yet. The peer-to-peer node is off by default, and `ahto serve` without it opens no port besides the gateway's. ## What it does today A network is a set of ahto nodes that know each other by key. Each node has a key; its peer ID (`12D3KooW...`) is the public half. Built on libp2p, the node: - lets in only the peers it is told about: those in its own peer list, or those in the organization's signed membership log (below); - finds the other members with a private DHT that only the network's own members answer, so a new node that knows one bootstrap address finds the rest; - trades the membership log with the peers it reaches, so an admit or a revoke made on one machine reaches every node; - closes the connections of a peer the moment its revoke arrives; - can ask the network's authority group to sign people in (see [identity](/docs/identity)). A network never merges with another one: two organizations are two networks with two keys. ### Not built yet ahto does not yet move lake data, repositories or build-cache blobs between peers. The network carries membership and sign-in, not your code. These parts of the design are planned, and nothing here depends on them: - sharing lake snapshots and files between peers (RFC 0008, "Lake over P2P"); - fetching a build-cache blob from a peer: the store exists on one machine only (RFC 0013; see [checks](/docs/checks#a-go-build-cache)); - links between two organizations' networks; - `ahto p2p status` and a peer-to-peer service on the gateway. Today the `node up` line in the log is the only report of the node, and there is no command that lists the peers connected right now. ## Set up a network Two admission modes exist. A **list** network lets in the peers you name on each node. A **members** network lets in whoever the organization's CA has signed into a membership log; it is the one to use beyond two or three nodes. The steps below make a members network of a server and a laptop. Each command was run against a build of this repository. **1. Name the network on each node.** Put this in the config file of every node (`--config`) and give each its own `dir`; the default is `~/.local/share/ahto/p2p`: ```yaml p2p: enabled: true networks: - id: acme ``` **2. Make each node's key.** This prints the peer ID. Run it on every node: ```sh ahto --config ahto.yaml p2p init ``` ```text network: acme peer id: 12D3KooWCA7VfKm4oSECWgD5MGrjXMe65XXuZ1Aob76g4b1ts3aR key: /home/you/.local/share/ahto/p2p/acme.key ... ``` **3. Make the CA, once, on the machine that will admit members.** Keep its key (`acme.ca.key`) on that machine or offline; it signs every member. ```sh ahto --config ahto.yaml p2p ca init ``` ```text network: acme ca: ed25519:4cEDhM12KuTNTD0Hi81HC3G21cklJ88sxj8HmD6KkaE= ... Put the ca line in every node's config to let in the members of this log: ``` **4. Admit each node, the bootstrap node first.** Use the peer IDs from step 2: ```sh ahto --config ahto.yaml p2p admit 12D3KooWCA7V... --name server --role bootstrap ahto --config ahto.yaml p2p admit 12D3KooWQeoc... --name laptop ``` ```text entry 2: admit 12D3KooWQeoc9DxL5mM3yamNkEhTB9tmazW1tv1XY6Grddr1xSFj (laptop), roles member, expires never ``` `--role` is `member`, `bootstrap`, `relay` or `client` (repeat it for several), and `--expires` ends a membership: `720h`, `30d`, `2027-01-31` or an RFC 3339 time. **5. Point every node at the CA and the bootstrap node.** Add the `ca:` line step 3 printed to every node. Every node but the bootstrap one also names where to dial it, an address ending in `/p2p/`: ```yaml p2p: enabled: true networks: - id: acme ca: ed25519:4cEDhM12KuTNTD0Hi81HC3G21cklJ88sxj8HmD6KkaE= bootstrap: ["/ip4/203.0.113.10/udp/4100/quic-v1/p2p/12D3KooWCA7VfKm4oSECWgD5MGrjXMe65XXuZ1Aob76g4b1ts3aR"] ``` The bootstrap node must be reachable: open UDP and TCP port 4100 to it. **6. Start the nodes, the bootstrap node first.** ```sh ahto --config ahto.yaml serve ``` ```text INF p2p: node up dht=true listen=["/p2p-circuit","/ip4/0.0.0.0/udp/4100/quic-v1","/ip4/0.0.0.0/tcp/4100"] mode=server network=acme peer=12D3KooW... peer_list=0 INF p2p: membership log updated entries=5 head=159336200a5d network=acme ``` The second line is the laptop taking the log from the server. Check it on any node: ```sh ahto --config ahto.yaml p2p network ``` ```text network: acme ca: ed25519:4cEDhM12KuTNTD0Hi81HC3G21cklJ88sxj8HmD6KkaE= entries: 5, head 159336200a5dda0c3230acacdf5c45e211b9506bef502339a4fdbe8e67df701e NAME PEER ROLES EXPIRES STATE laptop 12D3KooWQeoc9DxL5mM3yamNkEhTB9tmazW1tv1XY6Grddr1xSFj member never live server 12D3KooWCA7VfKm4oSECWgD5MGrjXMe65XXuZ1Aob76g4b1ts3aR bootstrap never live ``` If a node logs `bootstrap did not answer ... this node is not on its list`, its peer ID is not admitted yet, or was revoked: run `ahto p2p network` on the CA machine and look at its STATE. ### Add and remove members later On the CA machine, `admit` a new peer, or change a peer's name, roles or expiry by admitting it again, and `revoke` one that must go: ```sh ahto p2p admit 12D3KooWNew... --name build-server --expires 90d ahto p2p revoke 12D3KooWQeoc... ahto p2p publish # hand the log to the bootstrap peers; or --to ``` `publish` needs a `bootstrap` list, or `--to`; without one it says so. A node that reads its log from a file takes in a change on `SIGHUP`. A revoked peer's connections close as the entry arrives; the log keeps the revoke, since it is never trimmed. ### A list network, with no CA For two machines you control, skip the CA. Each node lists the peers allowed to connect: ```yaml p2p: enabled: true networks: - id: acme bootstrap: ["/ip4/203.0.113.10/tcp/4100/p2p/12D3KooWCA7V..."] peers: - {id: 12D3KooWCA7V..., name: server} ``` A peer with `enabled: false` is refused and its connections closed, also when it is a bootstrap node or a member. `SIGHUP` reloads the list. A list network logs nothing when a peer connects, so a wrong list shows only as a node that finds nobody. ### A pre-shared key `ahto p2p psk` writes a key file. Only nodes that hold it can start a handshake, which hides the node from anyone who scans for it. Copy it to every node by a safe route and set `psk_file`: ```sh ahto --config ahto.yaml p2p psk # writes .psk in p2p.dir; --out sets the file ``` A pre-shared key works over TCP only. A network with one listens on TCP alone, and its bootstrap addresses must be `/tcp/` ones. ## Settings Everything is under `p2p` and is off until `enabled: true`. `ahto config` prints the result. | Key | Default | What it does | |---|---|---| | `enabled` | `false` | start the node with `ahto serve` (`AHTO_P2P_ENABLED`) | | `mode` | `server` | `server` listens and answers; `client` only dials out | | `dir` | `~/.local/share/ahto/p2p` | the keys, membership logs and pre-shared keys | | `listen` | QUIC and TCP on port 4100 | addresses a server listens on | | `announce` | none | addresses to tell others about, in place of the ones the node finds | | `dht` | `true` | the network's private DHT; `false` and a node reaches only peers it has addresses for | | `nat.port_map`, `nat.autonat`, `nat.hole_punching` | `true` | ask the router for a port, ask peers whether an address is reachable, connect through NAT | | `nat.relay_service` | `false` | relay for other members; set it on a bootstrap node | | `limits.max_peers`, `limits.max_conns_per_ip` | `200`, `8` | how many connections the node keeps | | `networks[].id` | | the network's name; its protocols start with `/ahto/` | | `networks[].ca` | | the CA's public key; with it the network is a members network | | `networks[].admission` | `list`, or `members` with a `ca` | who is let in | | `networks[].key_file`, `psk_file` | `.key`, none | the node's key and the pre-shared key, in `dir` unless absolute | | `networks[].bootstrap` | none | addresses dialed first | | `networks[].peers` | none | the node's own list: who may connect, or who is disabled | | `networks[].authority` | off | the node's part in the sign-in group; see [identity](/docs/identity) | | `networks[].audit` | off | a daily copy of audit events for a log shipper; see [identity](/docs/identity#audit) | `networks` is a list, so it comes from a YAML file, not from an environment variable. The first build takes one network. The NAT keys are set but only the DHT and the admission rules are proved by the design's tests; a node behind NAT across the internet is not yet reported by any command. ## All the commands | Command | What it does | |---|---| | `p2p init` | make this node's key for a network and print its peer ID | | `p2p id` | print this node's peer ID | | `p2p ca init` | make the CA key and the log's first entry; `--wait` waits for recovery to be ready | | `p2p admit ` | sign a peer in, or change it (`--name`, `--role`, `--expires`) | | `p2p revoke ` | sign a peer out | | `p2p network` | print the CA, its fingerprint and the members | | `p2p publish` | hand the log to the bootstrap peers, or `--to` | | `p2p psk` | make a pre-shared key file | | `p2p guardian list`, `set`, `rehearse`, `sign`, `cancel` | the guardians that sign the network's recovery ([identity](/docs/identity#recovery)) | Each takes `--network ` when the config holds more than one. `admit`, `revoke` and `ca init` take `--ca-key` for a CA key kept somewhere else than `.ca.key` in `p2p.dir`. The design is in RFC 0008. (From /docs/networking) --- # Storage adapters `src/adapters/` holds the storage adapters a service built on ahto can use. The `ahto` command opens the ones in its `adapters` config section only for `ahto migrate` ([Migrations](#migrations)). | Kind | Package | What it opens | Library | |---|---|---|---| | `postgres` | `src/adapters/postgres` | a PostgreSQL server | pgx v5 | | `clickhouse` | `src/adapters/clickhouse` | a ClickHouse server, native or HTTP protocol | clickhouse-go v2 | | `duckdb` | `src/adapters/duckdb` | a DuckDB file, or a database in memory (needs cgo) | duckdb-go v2 | | `parquet` | `src/adapters/parquet` | a directory of Parquet files | parquet-go | The three databases give a `*sql.DB` with the same pool settings. The Parquet store has typed `parquet.Write` and `parquet.Read`, and DuckDB can query the files it writes with `read_parquet`. `duckdb.DB` adds what DuckDB has beyond `database/sql`: ```go db, err := duckdb.Open(ctx, cfg.DuckDB) n, err := db.Append(ctx, "", "events", rows) // bulk insert through the appender n, err = db.ExportParquet(ctx, "SELECT * FROM events", "out/events.parquet", duckdb.ParquetOptions{Compression: "zstd"}) // or PartitionBy for a Hive directory n, err = db.ImportParquet(ctx, "", "events_copy", "out/*.parquet") err = db.Attach(ctx, duckdb.Attachment{Name: "other", Path: "other.duckdb", ReadOnly: true}) ``` Also `Appender` (row by row, with `Flush`), `Detach`, `LoadExtension`, `CreateSecret`, `Extensions`, `Databases`, `Version` and `Checkpoint`. Functions written in Go are given at open, so the `init` statements can use them, or registered later with `db.Register`; DuckDB keeps them for the whole database, so every connection of the pool sees them: ```go double := duckdb.Scalar1("double", func(ctx context.Context, x int64) (int64, error) { return 2 * x, nil }) // Scalar0 to Scalar3; Volatile, NullsIn db, err := duckdb.OpenWith(ctx, cfg.DuckDB, duckdb.Options{Functions: []duckdb.Function{double}}) err = db.Register(ctx, duckdb.Table("numbers", duckdb.TableSpec{ Columns: []duckdb.Column{{Name: "n", Type: driver.TYPE_BIGINT}}, Args: []duckdb.Column{{Type: driver.TYPE_BIGINT}}, Rows: rows, // returns an iter.Seq2[[]any, error] })) info, err := db.Profile(ctx, "SELECT sum(n) FROM numbers(1000)") // the tree of operators ``` `ScalarRaw` and `TableRaw` take the driver's own function types, and `Options.ReplacementScan` (or `db.ReplacementScan`) maps an unknown table name to a table function. With `-tags=duckdb_arrow` the DuckDB adapter also speaks Arrow: `db.QueryArrow` returns an `array.RecordReader`, `db.ImportArrow` writes one into a table, and `db.Arrow` gives the driver's Arrow interface on one connection. `src/adapters/arrow` (pure Go, no tag) writes and reads the Arrow IPC stream (`arrow.WriteIPC`, `arrow.ReadIPC`). Without the tag the Arrow methods return `duckdb.ErrArrowNotBuilt`. Since 2026-11-23 the tag is the default: `scripts/build.sh` and every mise task build with it (`GOFLAGS` in `mise.toml`), and `mise run vet:plain`, `lint:plain` and `test:plain` check the build without it, so a plain `go build ./...` keeps working. A service uses them in one of two ways. With a fixed field per store: ```go type Settings struct { config.Config `yaml:",inline"` Postgres postgres.Settings `yaml:"postgres"` } db, err := postgres.Open(ctx, cfg.Postgres) ``` Or with a named set, so the config decides how many there are and of which kind: ```yaml adapters: main: kind: postgres host: 127.0.0.1 port: 5432 database: ahto user: ahto password: {env: AHTO_POSTGRES_PASSWORD} # or {file: /run/secrets/pg} sslmode: disable pool: {max_open: 20, max_idle: 5} events: kind: clickhouse addresses: ["127.0.0.1:9000"] protocol: native # or http database: ahto user: ahto password: {env: AHTO_CLICKHOUSE_PASSWORD} compression: lz4 local: kind: duckdb path: data/ahto.duckdb # empty: in memory threads: 4 memory_limit: 2GB temp_directory: data/tmp options: {preserve_insertion_order: "false"} # any other DuckDB option extensions: # loaded at open, in order - {name: httpfs, install: true} # install downloads it once secrets: # made at open, kept in memory only - name: lake type: s3 params: {region: eu-central-1, scope: "s3://my-bucket"} secret_params: key_id: {env: LAKE_KEY_ID} secret: {env: LAKE_SECRET} attach: # other databases, read as name.schema.table - {name: archive, path: data/archive.duckdb, read_only: true} init: # run on every new connection - USE archive lake: kind: parquet dir: data/lake compression: zstd ``` - A later config layer merges into an entry by name and key, so `production.yaml` can change only `host`. A different `kind` under the same name replaces the entry. - An unknown key or an unknown kind fails the load. - A password is never written in the config: it names an environment variable or a file. - Entries of the `adapters` section have no `AHTO_*` variables of their own; use a layer file. - A new kind is one call, `adapters.Register("mykind", open)`, from your own package. Its settings type has `SetDefaults()` and `Validate()`. ## Migrations Schema migrations are SQL files in `migrations//`, embedded in the binary and run by [goose](https://github.com/pressly/goose) v3. Each file has a `-- +goose Up` and a `-- +goose Down` part and a sequential name, `00001_schema_info.sql`. A kind with no directory (Parquet) has nothing to migrate: `up` and `status` return without an error. ```yaml adapters: main: kind: postgres # ... migrations: auto: true # run up when the adapter opens (default false) table: ahto_schema_migrations # the record table (the default) ``` ```sh ahto migrate status [adapter ...] # every migration of each adapter, applied or pending ahto migrate up [adapter ...] # apply what is pending; all adapters when none is named ahto migrate down # roll back the latest one of one adapter ahto migrate create # write migrations//0000N_.sql in the source tree ``` From Go, `set.Migrator(name)` gives the same `Up`, `Down`, `Status` and `Version`, and `adapters.NewMigrator` works on a database opened with a typed field. - Two runners never apply one migration twice. PostgreSQL takes a session advisory lock (`pg_try_advisory_lock`, the id from the table name). ClickHouse and DuckDB lock inside the process only, so run their migrations from one deploy step, not from every replica. - ClickHouse runs each file without a transaction, since it has none; write its statements with `IF [NOT] EXISTS` so a file that stopped halfway can run again. `migrate create clickhouse` adds `-- +goose NO TRANSACTION` for you. - An adapter with `auto: true` runs `up` whenever it opens, also when `ahto migrate status` or `down` opens it. - A new file needs a rebuild: the binary carries the migrations it was built with. A new kind adds its directory to the `go:embed` line in `migrations/migrations.go`. ## Local servers `compose.yaml` starts PostgreSQL 19.0 and ClickHouse 26.9 for work on this machine, both on 127.0.0.1 only. DuckDB and Parquet are files and need no server. ```sh mise run compose:up # makes .env with random passwords when missing, waits until healthy mise run test:adapters # the adapter tests against both servers mise run compose:down # stop; compose:reset also deletes the data ``` Ports and passwords are in `.env` (not in git; `.env.example` lists the keys). (From /docs/adapters) --- # Development This page says how to build and test ahto, how to run its web app, and where each part of the code lives. ```sh mise tasks # list every task mise run build # dist/ahto, one binary mise run install:global # dist/ahto, then ~/.local/bin/ahto (mise install runs it too) mise run test # tests with the race detector mise run check # format, tidy, protos, vet, lint, tests, vulnerabilities, secrets mise run ci # check, then the build; the same thing the CI workflow runs mise run proto # regenerate src/pb/ from proto/ mise run bench # benchmarks with allocation counts mise run compose:up # local PostgreSQL and ClickHouse (see adapters.md) mise run test:adapters # adapter tests against them mise run release # dist/ahto-- for linux and darwin, with SHA256SUMS ``` The engine uses cgo (`CGO_ENABLED=1`) for DuckDB and the tree-sitter grammars, so the build needs a C compiler. A target that is not this machine needs a C cross-compiler in `CC`, for example `CC="zig cc -target x86_64-linux-gnu" scripts/build.sh linux/amd64`; without one the script stops with that hint. The `ahto` front binary uses the standard library only and builds without cgo. ## Install from a release `scripts/get.sh` installs a release for this user: it picks the binary for this machine, checks it against `SHA256SUMS`, puts it in `~/.local/bin` without sudo, then runs `ahto version` and `ahto doctor`. `--claude` also registers the gateway in Claude Code, as `mise run mcp:add` does. `--dry-run` says every step and changes nothing. On a terminal it draws a progress bar for the download and colours its steps (`NO_COLOR=1` turns colour off); piped into a log it writes the same steps as plain lines. ```sh sh scripts/get.sh --dry-run --claude # see what it would do sh scripts/get.sh # the newest GitHub release sh scripts/get.sh --version v0.1.0 # that release sh scripts/get.sh --from dist # the release `mise run release` wrote to dist/ sh scripts/get.sh --help # every option ``` The script runs the same when it is downloaded and piped to `sh -s -- `; each release carries it as `get.sh`. `scripts/install.sh` (`mise run install:global`) uses its install step for `dist/ahto`. ## Releases Pushing a tag `v*` runs `.github/workflows/release.yml`. It builds ahto for linux and darwin on amd64 and arm64, each on its own runner (cgo needs a native build), checks that each binary reports the tag, and publishes a GitHub release with the binaries, `SHA256SUMS`, `get.sh` and a build provenance attestation per binary. Linux builds on Ubuntu 22.04, so they need glibc 2.35 or newer; musl systems such as Alpine are not supported yet. ```sh git tag v0.1.0 && git push origin v0.1.0 ``` Protos live in `proto/` (buf). To add a package, add a file under `proto/` and run `mise run proto`. ## The web app The web app is in `ui/app` (React, Vite, pnpm). The gateway does not serve it; in development Vite does, and sends `/api` to the gateway. ```sh mise run ui:setup # install its packages as pnpm-lock.yaml pins them, once mise run dev:all # the gateway on 127.0.0.1:8080, then the UI on 127.0.0.1:8081 mise run ui:dev # the UI only, against a gateway already running (AHTO_UI_PORT, AHTO_API) mise run ui:check # its typecheck and tests mise run ui:build # build it into ui/app/dist mise run ui:proto # regenerate its TypeScript from proto/ahto/source ``` The docs pages of the web app are built from `README.md` and the files of `docs/`, so a change here shows up there. ## Repository layout | Path | What is there | |---|---| | `entrypoint/` | `main.go` of `ahto`, the one binary (answers a cached `files` listing before opening DuckDB, hands the rest to `cli`); `check/main.go`, `ahto check` alone for CI (standard library only) | | `cli/` | The command line (urfave/cli v3): flags, config and logger wiring, commands | | `src/crawl/`, `src/git/` | Crawling: ref selection, fetch and ingest, over the real `git` binary | | `src/lake/` | The lake: Parquet tables, the manifest, the writer lock, the mirrors, the read models | | `src/syncer/` | The steps after a crawl that `crawl` and `serve` share, and the periodic sync | | `src/parse/` | The parsing tables, with `go/parser` and the tree-sitter grammars | | `src/query/` | SQL over the lake with DuckDB, one view per table | | `src/function/` | Functions over the lake: the built-ins and WebAssembly modules run by wazero | | `src/advisory/`, `src/deps/`, `src/secscan/` | Security: the advisory feeds, manifests and lockfiles, and the code scan | | `src/filelist/`, `src/filerole/`, `src/records/` | The `files` listing and its cache, file roles, and the output formats | | `src/protocol/` | The gateway: catalog, surfaces, transcoding | | `src/base/`, `src/source/`, `src/settings/` | The gateway's own services: base, the source service of the code browser, settings | | `src/p2p/`, `src/identity/` | The peer-to-peer node, its membership log and authority group; sign-in and people on top of them | | `src/agent/`, `src/debug/`, `src/task/` | The agents, debugger and task services of the gateway | | `src/check/`, `src/cas/` | `ahto check` and the content-addressed store behind it | | `src/egress/` | The credential proxy for agents that run with `auth: api_key` | | `src/workspace/`, `src/runs/` | Building blocks for agents (patch workspace, run table), with no command or API yet | | `src/adapters/` | Storage adapters: PostgreSQL, ClickHouse, DuckDB, Parquet | | `src/config/`, `src/logger/`, `src/perf/` | Layered settings, zerolog, profiling | | `src/internal/` | Small shared helpers (`digest`, `lru`) | | `src/pb/` | Generated Go code and the embedded descriptor set | | `proto/` | Proto sources and buf configuration | | `migrations/` | Schema migrations per adapter kind, embedded in the binary | | `third_party/` | The vendored tree-sitter grammars and their licences | | `examples/` | A WebAssembly function to start from | | `ui/app/` | The web app | | `docs/` | These docs; also the docs pages of the web app | | `scripts/`, `mise.toml` | Build and dev scripts, pinned tools and tasks | | `compose.yaml` | Local PostgreSQL and ClickHouse | | `atlas/` | Design documents: what was asked, found, decided and built | The design documents cover how the project is built, the gateway, the adapters, and parsing and the lake. (From /docs/development) --- # Licence ahto is licensed under the Apache License 2.0. Contributions are accepted under the same licence; CONTRIBUTING.md says how a change gets merged, and SECURITY.md says how to report a vulnerability privately. The third-party tree-sitter grammars ahto vendors keep their own licences, MIT or Apache-2.0, and NOTICE lists each one with its copyright. The Noir grammar is GPL-3.0, so it is compiled only with `-tags noir`, and the binaries ahto ships leave it out. A binary you build with that tag is a GPL-3.0 work (ADR 0006). (From /docs/licence)