# 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`,
   `<environment>.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
  `<YYYY-MM-DD>.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.