Codumentor logo Codumentor Enterprise

Configuration

Codumentor is configured through YAML, typically named codumentor.yaml. That file is one layer of configuration. It is the instance only when you pass --config or the process uses workspace home (the usual enterprise-edition server). Community / user-home runs keep data under $CODUMENTOR_HOME even when a project YAML is discovered as an overlay.

This file controls repositories to analyze, file patterns, model settings, and tool behavior.

How this page is organised. It is the complete reference — every option, including authentication, the API server, logging, and config inheritance. Start with the minimal example below if you just want an instance running. Community "install once, run anywhere" is in Community. To stand up a team/production instance end-to-end, follow the Self-Hosting Walkthrough.

Tip — edit config from a chat. Instead of hand-editing this YAML, admins can use the Configuration Assistant: an admin-only chat (Admin page → Configuration Assistant) that changes the running instance's config in plain language. It grounds itself in this reference and the live schema, validates the change, shows you the exact YAML diff and whether it applies live / needs a restart, and only writes after you approve — with a timestamped backup and one-step rollback. Enable it with the configuration_assistant plugin. Pass target=user for models and keys, target=project for repos and project plugins, or a loaded file's path (an extends: base, for instance) to edit that file.

Minimal example

A complete working configuration:

repos:
  - "https://github.com/your-org/your-repo.git"

models:
  embedding: "text-embedding-004"
  embedding_base_url: "https://generativelanguage.googleapis.com/v1beta/openai/"
  embedding_api_key: "${GOOGLE_API_KEY}"
  agent: "gemini-2.0-flash"
  agent_base_url: "https://generativelanguage.googleapis.com/v1beta/openai/"

vector_db:
  path: "./data/vector_db"

plugins:
  - module: "codumentor.plugins.telemetry"
    class: "TelemetryPlugin"

Two axes: config layers vs instance home

These are independent. Mixing them is allowed; naming them is the product.

Config layers (what the process believes), later wins:

bundled flavor default  →  user overlay  →  project overlay  →  --config

Instance home (where bytes live): workspace (next to the YAML) · user ($CODUMENTOR_HOME) · ephemeral (tempdir).

Community without --config uses user home. A discovered codumentor.yaml is then a project overlay (repos / project plugins only; it cannot redirect model URLs or auth). Enterprise edition with a project YAML uses workspace home: that YAML is the instance. --config is always trusted.

See How a process finds its configuration below for origins and the untrusted-overlay strip.

Environment Variable Substitution

All string values in the configuration file support environment variable substitution using ${VAR_NAME} syntax. This allows you to keep sensitive values (like API keys) or environment-specific paths out of your configuration files.

Example:

models:
  agent: "${AGENT_MODEL}"
  agent_base_url: "${BASE_URL}/v1"
  embedding_api_key: "${GOOGLE_API_KEY}"

vector_db:
  path: "${DATA_DIR}/vector_db"

repos_dir: "${REPOS_DIR}"

Environment variables are substituted when the configuration is loaded. If a variable is not set, the original ${VAR_NAME} string is kept as-is.

Note: Environment variable substitution works for all string values throughout the configuration, including nested dictionaries and list items.

Config inheritance with extends

You can let one config build on another using the extends key. The value can
be a relative path (resolved from the file that declares it) or an absolute
path. Extends are applied depth-first: parents load first, then the child
overrides them.

# child.yaml
extends: base.yaml        # or a list: [base.yaml, extras/feature.yaml]
models:
  agent: "gemini-2.0-pro" # overrides the parent value
vector_db:
  path: "./data/vector_db_variant" # override while inheriting other settings

Cycles are detected and raise an error. Extends works together with the CLI
-c/--config merging: each file is resolved with its own extends chain, then
the resulting configs are merged in the order you pass on the CLI.

How a process finds its configuration

An effective config is always a merge, later wins:

bundled flavor default  →  user overlay  →  project YAML / --config

codumentor status and GET /ui/config report which layers contributed.

A discovered project YAML (found in CWD or via the git-root search, not
passed as --config) is an overlay when the instance home is user
(community / cd into a clone). That overlay cannot override inference
redirects: models.* base URL and API key fields, and the entire auth:
section. A cloned repo can still name repos and the agent model; it cannot
point the process at an attacker's proxy. When the YAML is the instance
(workspace home, enterprise edition), it is trusted. Explicit --config is always
trusted.

OriginWhen
bundledThe packaged flavor default. Always the first layer on a loader-produced config.
user$CODUMENTOR_HOME/config.yaml contributed (skipped if the file is missing).
explicitYou passed -c / --config PATH.
discoveredThe flavor's default filename (codumentor.yaml, or codumentor-<flavor>.yaml) was found in CWD, at the git root, or in the git root's parent.
ephemeralRetained for reload of processes that recorded this origin before the floor flip. New no-YAML loads record the bundled file as bundled; instance home kind=ephemeral is the persistence axis.

Inspect a running (or about-to-run) process:

codumentor status           # banner: instance home, workspace, config, flavor
codumentor status --json

Under the workspace line, both the banner and status list each repository's
resolved on-disk root — the answer to "is this process pointed at the
checkout I meant". It is worth reading, because a relative repos_dir (and a
relative path: in repos:) is anchored to the directory holding the config
file, never to the directory you launched from: launch inside a worktree
whose config says repos_dir: ".." and the roots are the parent's checkouts.
The startup banner stops after five roots and says how many it withheld;
codumentor status prints them all, and status --json carries them as
workspace.repos.

GET /ui/config includes the same facts as instance_home and config_layers.

Omitted keys inherit the flavor file

A workspace YAML is merged over the bundled flavor file, so a key it omits
takes the flavor's value, not the Pydantic default. For example,
default_enterprise.yaml ships a language whitelist for include_patterns;
to ingest every known extension instead, set it explicitly:

include_patterns: []

Keys the flavor file also omits use Pydantic defaults.

flavor:

flavor: enterprise    # or personal | marketing | minimal | root | investigate

The build-time edition (what the binary contains) is a different axis;
see Community vs Enterprise.

--flavor / CODUMENTOR_FLAVOR / invoking codumentor-<flavor> select the
bundled default_<flavor>.yaml floor (and the first-run scaffold when no
file exists). An existing file that sets flavor: still wins. An explicit
--flavor that the merge result contradicts is a hard error.

Configuration File Structure

The configuration file uses the following structure:

repos:
  - "https://github.com/user/repo1.git"
  - "path/to/local/repo2"

repos_dir: "repos"

# include_patterns: []  # empty = ingest every known extension; omit = flavor whitelist
# exclude_patterns use sensible defaults (see below)

ingestion:
  max_file_size: 1048576  # 1 MB (default) — skip files larger than this

chunking:
  size: 1000
  overlap: 100

models:
  embedding: "text-embedding-004"
  embedding_base_url: "https://generativelanguage.googleapis.com/v1beta/openai/"
  agent: "gemini-2.0-flash"
  agent_base_url: "https://generativelanguage.googleapis.com/v1beta/openai/"
  # agent_max_tokens: 8192  # optional output-token cap per model reply

vector_db:
  backend: "chroma"
  path: "./data/vector_db"

cache:
  embedding_enabled: true
  embedding_db_path: null
  embedding_max_age_days: 365

agent:
  max_iterations: 30  # explicit tool-loop step cap; omit to inherit the bundled flavor
  storage_dir: "./data/agent_storage"

tools:
  tool_result_max_content_length: 30000  # Max chars before tool output is chunked
  shell_output_max_size: 10240
  file_listing_max_size: 10240
  shell_timeout: 900
  search_concurrency: 5

permissions:
  allow: []                    # operator allow rules (a floor; read-only over the API)
  deny: []                     # operator deny rules — highest priority anywhere
  default_mode: acceptEdits    # default | acceptEdits | auto | plan | bypassPermissions
  allow_bypass: true           # false: users cannot choose "Always allow"
  allow_auto: true             # false: users cannot choose Auto
  reason_argument: required    # required | optional | off

api:
  host: "127.0.0.1"
  port: 2638
  reload: false
  enable_web_ui: true        # Serve the protocol-native /ui/* API + SPA
  enable_openai_api: false   # OpenAI-compatible /v1/* surface (opt-in)
  stream_flush_ms: 250       # Coalesce streamed deltas into one UI event per beat (0 = per-chunk)
  stream_flush_bytes: 4096   # Flush the delta buffer early once it reaches this size
  max_concurrent_turns_per_user: 10  # Running agent turns per user; one more gets 429 (0 = no cap)
  max_event_streams_per_user: 32     # Open live event streams per user (0 = no cap)

ui:
  welcome_title: "Welcome to Codumentor"
  welcome_description:
    en: "Your own Intelligent Work Environment (IWE). As the orchestrator, set the direction and coordinate the work of the AI agents across your entire software ecosystem — from interconnected services and legacy systems to undocumented codebases. Decide what happens, approve important operations, and keep the process in your hands throughout."
    hu: "A Codumentor a saját Intelligens Munkakörnyezeted (IWE). Orchestrátorként meghatározod az irányt, és összehangolod az AI-ügynökök munkáját a teljes szoftveres ökoszisztémádban — az összekapcsolt szolgáltatásoktól és legacy rendszerektől a dokumentálatlan kódbázisokig. A fontos műveletek jóváhagyása nálad marad, a folyamatot pedig végig kézben tartod."
  disabled_extensions: []

auth:
  provider: "none"  # Options: "none", "gitea"
  gitea:
    base_url: "https://gitea.example.com"
    token_cache_ttl_minutes: 30  # Token cache TTL in minutes

prompt:
  template_dir: "prompts"
  system_prompt_template: "system_prompt.jinja2"
  max_iterations_notification_template: "max_iterations_notification.jinja2"
  custom_instructions: []
  debug_mode: false
  show_tool_calls: true

logging:
  level: "INFO"
  file: "./logs/codumentor.log"
  logger_levels: {}

plugins:
  - module: "codumentor.plugins.websearch"
    class: "WebSearchPlugin"

Configuration Options

repos

List of repositories to analyze. Entries can be either simple strings (Git URLs or local paths) or structured objects that describe alternative SCM providers:

repos:
  # Git support (string form)
  - https://github.com/example/project.git

  # Explicit configuration for alternate SCMs provided by plugins
  # (svn and filesync ship in the Enterprise Edition only)
  - scm: svn
    url: https://svn.example.com/repos/legacy
    name: legacy_svn
    options:
      branch: trunk

  # Pin to a branch/commit
  - url: https://github.com/example/project.git
    branch: release         # or commit: <sha> / pin: <tag>

  # Inline ref pin using URL suffix (common git syntax)
  - https://github.com/example/project.git@release
  - https://github.com/example/project.git#v1.2.3

  # Use an existing local checkout
  - path: /opt/shared/repo
    branch: feature/search  # optional: will checkout this ref before ingestion

  # Pre-synced directories (requires filesync plugin)
  - scm: filesync
    name: shared_docs
    path: "\\\\fileserver\\engineering\\docs"

  # Ingest only part of a repository
  - name: knowledge-repo
    path: /srv/kb
    ingest_paths: knowledge      # or a list: [knowledge, docs]

##### Managing repositories from the UI

Administrators can add, edit and remove repositories from **Admin →
Repositories** (/admin/repos) instead of editing this file by hand. There is no
separate repository store: this YAML file remains authoritative. The page
edits the repos: list in the leaf config file (the last entry of
CODUMENTOR_CONFIG_FILES) and then drives the same hot-reload the
/admin/config button does, so a hand-edit on the host and a UI edit can never
disagree. Requires the admin:config permission.

What it writes, for an entry added through the form:

repos:
  # your existing entries and their comments are left untouched
  - name: service          # the identity: the clone folder, the file-key prefix
                           # and the @-mention token
    url: https://gitea.example.com/team/service.git
    branch: develop        # omitted entirely when you keep "Remote default"
    options:
      platform: gitea      # pre-filled from the host when recognizable

In the Enterprise Edition, an scm: svn entry and an scm: filesync one:

repos:
  - name: legacy-erp
    scm: svn
    url: https://svn.example.com/erp/trunk
    options:
      username: builduser
      password: ${SVN_PASSWORD}   # a reference — never the password itself
      revision: "48213"           # omit to follow the latest
  - name: shared-docs
    scm: filesync
    path: "\\\\fileserver\\projects\\docs"   # the source; copied, never modified
    options:
      target_dir: /srv/codumentor/repos/shared-docs
      clear_target: true          # the target is emptied before every copy

Notes on behaviour worth knowing before you rely on it:

##### Git repository authentication

Codumentor supports both SSH and HTTPS Git repository URLs. Public HTTPS
repositories need no credentials; private repositories require credentials that
the Codumentor server can use, not credentials in the administrator's browser.
There is no Git password/token field in the add-repository dialog.

For a private repository over HTTPS:

  1. Configure the account running Codumentor. Git reads configuration and credentials in that operating-system account's environment. Setting up Git on your laptop, or under another account on the server, does not configure the Codumentor service. In a container deployment, the configuration and helper must be available inside the container, with any required storage persisted.
  2. Choose and configure a credential helper. A helper is a program Git asks for a username and password/token. Follow Git's credential documentation to choose an appropriate helper and its setup instructions. Use a dedicated service credential with the minimum repository permissions needed for cloning and fetching. If your Git host requires an access token instead of a password, follow that host's token instructions.
  3. Make it work unattended. Provision the credential before using the form. The repository connection check disables interactive prompts, and background indexing has no user available to answer one. A helper that requires a desktop login, an unlock dialog, or an interactive sign-in must also support the service's unattended environment.
  4. Check and retry. Under the same account and environment as the service, git config --show-origin --get-all credential.helper shows the configured helpers and where they were configured; no output means none is configured. This lists configuration, not proof that a usable credential is stored. Enter the repository URL (for example, https://gitea.example.com/team/service.git) in Add repository and use Check. If authentication fails, the report lists the helpers visible to the server to help diagnose the setup.

Keep credentials out of repository URLs and shell commands. Prefer a secure
credential manager or secret store suitable for your deployment. Git's
credential-store helper saves
credentials unencrypted on disk; it is not a secure vault. Do not paste a
literal password or token into the repository URL: configuration backups and a
clone's remote configuration can retain it.

For SSH URLs such as git@gitea.example.com:team/service.git, provision the
service account's SSH key/agent and host trust instead. An SSH key on your own
computer is not automatically available to the server.

These are server credentials for cloning and background indexing, separate
from the per-user credentials in Settings → SCM Push. Configuring one does
not configure the other. Likewise, a ${secret:…} user-secret reference cannot
supply a background clone, because no conversation user is attached to it.

##### ingest_paths: ingesting part of a repository

include_patterns / exclude_patterns are global; ingest_paths is per-repo,
and it narrows the walk rather than filtering its result, so excluded files
are never opened, hashed, or embedded. Use it when a repository's contents are
not homogeneous:

Notes:

Plugins can register additional SCM providers (e.g., "svn", "filesystem") to handle these entries during ingestion.

Generic *_overrides

Any top-level key can have a companion <key>_overrides entry. After configs
are merged (and env vars substituted), overrides are applied automatically:

repos_overrides entries can be plain URL strings (same formats accepted by
repos) — they are normalized to dicts before merging.

Examples:

# base.yaml
logging:
  level: INFO
  logger_levels:
    codumentor.tools: WARNING

repos:
  - name: kb
    url: https://example.com/kb.git
    branch: main

# variant.yaml
logging_overrides:
  json_logging: true
  logger_levels:
    codumentor.tools: ERROR
    codumentor.agent: DEBUG

include_patterns_overrides:
  - "**/*.md"

repos_overrides:
  # Match existing repo by name — only override the branch
  - name: kb
    branch: feature-branch
  # Add a new repo using a plain URL string
  - ssh://git@gitea.example.com:2244/org/sandbox.git
  # Add a new repo with full dict syntax
  - scm: svn
    url: "https://svn.example.com/trunk"
    name: legacy-svn

logging keeps level: INFO, enables JSON logging, and merges logger levels.
include_patterns gains the additional patterns while preserving the base ones.
repos gets the kb repo's branch updated to feature-branch, plus two new
repos appended.

##### Nested *_overrides

*_overrides also works deeper than the top level, using the same merge
rules. This is handy for surgically overriding one item in a nested list of
named items — e.g. a single LDAP directory under auth.ldap_directories —
without restating the whole list (a plain dict merge would replace it).

A nested <key>_overrides entry merges into its sibling <key> when present;
when <key> is absent (e.g. a parent config dropped it), the override applies
to an empty base, so list entries are added and dict values are set directly.

Because any key ending in _overrides is treated as a merge directive at
every level, config field names must never end in _overrides.

# base.yaml
auth:
  provider: ldap
  ldap_directories:
    - name: corp
      server_url: ldaps://corp.example.com
      bind_dn: cn=svc,dc=corp
      bind_password: pw
      base_dn: dc=corp
      security_mode: ldaps
    - name: partner
      server_url: ldaps://partner.example.com
      bind_dn: cn=svc,dc=partner
      bind_password: pw
      base_dn: dc=partner

# variant.yaml — flip only the corp directory to STARTTLS
auth:
  ldap_directories_overrides:
    - name: corp
      security_mode: starttls

corp keeps every other field and switches to starttls; partner is
untouched. An override entry whose name is not present is appended as a new
directory.

plugins

Codumentor supports plugins to extend functionality. Plugins are configured as a list of plugin specifications:

plugins:
  - module: "codumentor.plugins.mcp"
    class: "MCPPlugin"
    args:
      executable: "python"
      args: ["-c", "from mssql_mcp_server import main; main()"]

To change one plugin without restating the whole list, use plugins_overrides
on an extends: child. Entries match by module+class (see
Generic *_overrides above), not by name.

New default plugins on upgrade

Set the top-level new_default_plugins to auto, notify, or off (takes
effect after restart). auto (community default) loads missing bundled defaults
in memory without rewriting the file. notify (enterprise default) logs them
and offers Enable, Never, and Not now in Settings → Extensions.
off only logs missing defaults at DEBUG. Existing disabled_plugins entries,
configured entries with args.enabled: false, and effective remove/drop
overrides remain opt-outs; simply deleting a default from plugins is not an
opt-out in auto mode.

Enable and Never edit the instance leaf, or return YAML for manual
application if it is read-only. An action that copies an inherited list into
the leaf pins that list, so later changes to the same shared base list do not
flow through. See New default plugins on upgrade
for details.

Workspace Isolation Plugin

The workspace isolation plugin sandboxes each conversation session using Linux bubblewrap with overlay filesystems. It requires bubblewrap with overlay support (apt install bubblewrap on current distros), an overlayfs-capable kernel, and — on Ubuntu 24.04+ — userns allowed for the bwrap binary under AppArmor; see Plugins → Workspace isolation prerequisites for the install steps.

plugins:
  - module: codumentor.plugins.workspace_isolation
    class: WorkspaceIsolationPlugin
    priority: 5
    args:
      enabled: true
      workspace_ttl: 86400         # 24 hours
      persistent_home: true        # Persistent, shared $HOME (default: true)
      sandbox:
        unshare_net: true         # Block networking inside sandbox (default)
        network_per_call: true    # One user-approved call may have it; false = never
        allow_nested_sandboxes: false # Targeted seccomp relaxation for nested bwrap

Key options:

OptionTypeDefaultDescription
enabledbooltrueEnable/disable workspace isolation
workspace_ttlint86400Workspace time-to-live in seconds
persistent_homebooltrueBind-mount a persistent HOME (<workspace>/home/) instead of tmpfs. When true, $HOME survives across sandbox invocations and is shared among the main agent, subagents, and external agents. Set to false for legacy ephemeral HOME.
sandboxdict{}Sandbox hardening (see plugin README)
sandbox.allow_nested_sandboxesboolfalsePermit nested user namespaces and legacy bwrap mount setup while retaining the other seccomp rules. Actual YAML boolean only; restart/new session required. Increases kernel attack surface, not host-root/network access. Ancestor filters and host policy can still block nesting; see security trade-off

repos_dir

Base directory where repositories will be cloned and stored.

What the file tools may reach outside it. read_file and ripgrep accept
an absolute path outside repos_dir — reading a scratch file the agent just
produced with shell (objdump -d prog > /tmp/dis.txt) does not need to be
moved into the workspace first. There is no setting for this; the answer is
read from boundaries that are already declared elsewhere, and reads outside the
workspace are refused whenever one of them is in force:

In forceReads outside repos_dirWhy
workspace_isolation (overlay mode; Enterprise Edition)refusedthe sandboxed shell cannot see the host either — the file tools must not become a wider door than the shell
An access profile scoped to named repos (repos: [names] or repos: none), or one that withholds the shell tool (qa_readonly)refusedthe operator declared a boundary; for a principal without shell, "it could read it anyway" is false. Note chat_only does hold shell — what refuses its host reads is the repository scope beside it, and the sandbox it is required to run under
Neither (the default single-host install)allowed, after an approval promptshell is unconfined, so refusing the same path to read_file stopped nothing — but shell asks before reading a host file, so the file tools ask through the same permission provider (a Read(<path>) rule, auto-approved wherever shell is). Reads inside the workspace prompt for nothing

Writes are never relaxed. write_file, replace_in_file and the Office
save tools stay confined to the workspace in every configuration, so a run
cannot leave artifacts outside it. Relative paths (../..) are always resolved
inside their repository — only an absolute path can name a host location.

The instance's own config and data are never served, wherever they are.
Prefer a repos_dir that does not contain the instance home: point it at
a repos/ folder beside codumentor.yaml rather than at . (or .. in a
source checkout). Where it does cover them (root and project-dir installs,
local development), every agent tool and file view refuses them outright, with
no approval offered: the data dir (CODUMENTOR_DATA_DIR, by default data/
beside the config: every user's conversations and SQLite stores), the configured
store paths (agent.storage_dir, vector_db.path, cache.embedding_db_path,
the logging files and their directory, a plugin's args.data_dir, the
CODUMENTOR_*_PATH overrides), every loaded config file (-c files, their
extends: chain, the user overlay) and $CODUMENTOR_HOME. This covers
read_file, ripgrep (the locations are skipped in searches), the write and
Office tools, @-mentions, the shell's sandbox (light sandbox deny-list;
masked in the isolation overlay), and the file browser's /download, /view
and tree routes (403, and hidden from listings). Symlinks and .. spellings
are resolved first. Changing the configuration from a conversation goes
through the configuration assistant. Implementation:
utils/instance_private.py (repo-paths).

When repos_dir or a configured repository root contains the instance home,
its config file directory or its data dir, the server and the TUI log a startup
warning naming the overlapping path. The files stay denied, but the layout
should be changed so the workspace does not contain the instance at all.

include_patterns and exclude_patterns

File patterns using gitignore-style glob syntax. These control which files are
considered for ingestion. Files must also pass binary detection and the
max_file_size limit (see ingestion below).

include_patterns (flavor default: language whitelist; Pydantic: [])

When empty, all files with known extensions are included automatically.
Codumentor recognizes ~180 file extensions covering source code, config
files, templates, markup, and documentation. Files with unknown extensions
are still included if they pass a binary-detection heuristic (first 8 KB
checked for null bytes and printable-byte ratio).

default_enterprise.yaml ships a language whitelist (*/.py,
*/.md, …) rather than []. Because that file is the merge floor,
a YAML that omits include_patterns inherits the whitelist. Set
include_patterns: [] explicitly if you want ingest-by-extension.
See Omitted keys inherit the flavor file.

When non-empty, only files matching at least one pattern are included (whitelist
mode).

exclude_patterns (broad defaults)

# Default exclude_patterns:
exclude_patterns:
  - "**/.git/**"
  - "**/.svn/**"
  - "**/.hg/**"
  - "**/node_modules/**"
  - "**/vendor/**"
  - "**/packages/**"
  - "**/.nuget/**"
  - "**/__pycache__/**"
  - "**/venv/**"
  - "**/.venv/**"
  - "**/*.egg-info/**"
  - "**/.tox/**"
  - "**/.mypy_cache/**"
  - "**/.pytest_cache/**"
  - "**/bin/**"
  - "**/obj/**"
  - "**/dist/**"
  - "**/build/**"
  - "**/out/**"
  - "**/target/**"
  - "**/.idea/**"
  - "**/.vscode/**"
  - "**/.vs/**"
  - "**/.env/**"
  - "**/coverage/**"
  - "**/htmlcov/**"
  - "**/*.min.js"
  - "**/*.min.css"

Pattern syntax:

Important: Setting include_patterns or exclude_patterns in your config
replaces the defaults entirely. To append patterns without losing the
defaults, use the _overrides suffix instead:

# REPLACES defaults — you lose all built-in excludes:
exclude_patterns:
  - "**/my_custom_dir/**"

# APPENDS to defaults — built-in excludes are preserved:
exclude_patterns_overrides:
  - "**/my_custom_dir/**"

The same applies to include_patterns_overrides.

ingestion

Controls document ingestion behavior:

chunking

Controls how documents are split into chunks for vector storage:

models

Model configuration for different AI services:

API keys can be specified in the configuration or through environment variables:

Note: API keys support environment variable substitution using ${VAR_NAME} syntax (e.g., embedding_api_key: "${GOOGLE_API_KEY}"). See Environment Variable Substitution above for details.

Thinking/Reasoning Mode:

Truncated-reply retry policy:

When a reply comes back with finish_reason: length and carries no content and no tool call, the whole reply budget was spent on something unusable (usually reasoning). The agent loop re-rolls that call, bounded at two retries per turn, and then surfaces an error naming agent_max_tokens.

How to tell it took effect. A knob can be accepted with a 200 and discarded before the chat template renders — agent_reasoning_passback above is exactly that on vLLM/SGLang — so "we sent the field" is not evidence. Codumentor logs the retry and its outcome as a pair at WARNING on the codumentor.agent logger:

truncated reply: retrying with {'extra_body': {'chat_template_kwargs': {'enable_thinking': False}}} (mode=less_deliberation), not the identical request
truncation retry probe: mode=less_deliberation attempt=1 overrides={...} -> finish_reason=stop reasoning_chars=0 (attempt that truncated: finish_reason=length reasoning_chars=46012)

If the second line reports the same finish_reason=length and a reasoning size of the same order as the attempt that failed, the ingress took the field and ignored it: the policy is inert and agent_truncation_retry_extra_body is where to state the spelling your ingress does read.

HTTP Timeouts:

Model Profiles (per-subagent model selection):

By default, all subagents use the same model as the main agent. Model profiles let you assign different models to different subagent types — for example, a powerful reasoning model for the main agent and a cheaper, faster model for subagents.

A profile is a named bundle of model configuration: model ID, endpoint, API key, and optional parameters. Profiles are defined under models.profiles and referenced by name from subagent_default (applies to all subagents) or subagent_profiles (per-tool assignments).

models:
  agent: "claude-sonnet-4-20250514"
  agent_base_url: "https://api.anthropic.com/v1/"
  agent_api_key: "${ANTHROPIC_KEY}"

  profiles:
    local-fast:
      model: "qwen3-8b"
      base_url: "http://localhost:8000/v1/"
      api_key: "none"
    cloud-cheap:
      model: "gpt-4o-mini"
      base_url: "https://api.openai.com/v1/"
      api_key: "${OPENAI_KEY}"

  # Default profile for all subagents
  subagent_default: "local-fast"

  # Per-tool assignments (take precedence over subagent_default)
  subagent_profiles:
    explore: "local-fast"
    subagent: "cloud-cheap"
    web_retrieve:
      model: "gpt-4o"
      base_url: "https://api.openai.com/v1/"
      api_key: "${OPENAI_KEY}"

Resolution order: subagent_profiles[tool_name] > subagent_default > global agent settings.

Override values can be a profile name (string) or an inline profile definition (dict). When a profile omits api_key, the global agent API key fallback chain is used.

Available profile fields:

ChatGPT/Codex subscription profiles (provider: openai-subscription)

There are two ways to run on a ChatGPT/Codex subscription, and only one of them
is configured here:

models:
  profiles:
    codex:
      model: gpt-5.5
      base_url: https://chatgpt.com/backend-api/codex/responses
      provider: openai-subscription
      backend_options:
        credentials_source: import   # the default; stated for clarity

import reads one encrypted operator row, populated by the host operator
running codex login then codumentor codex import, once. It never reads a
subscription a user connected in Settings.

A profile or connection with backend_options.credentials_source: oauth (each user's own
sign-in) is ignored, with a warning — the same as if it were removed. It
would only list the user's plan a second time beside their personal
connection, and offer it to users who may not sign in. A reference to an
ignored entry (fallback_profile, subagent_profiles, thinking_modes,
model_selection) fails at load, saying it was ignored. See
plugin-dev/catalog/openai_codex.md.

Reasoning capability (reasoning)

Each model exposes reasoning differently (Qwen hybrids a chat-template switch, OpenAI/OpenRouter an effort enum, gpt-oss a system-prompt string). The record declares that once, per profile. agent_reasoning is the same record for the global agent model.

levels is the ladder this model offers — the rungs the picker draws, named in Codumentor's words and taken from the closed set off · minimal · low · medium · high · xhigh · max (max sits strictly above xhigh). It is a product decision, not a read-out of the endpoint's vocabulary: a token the endpoint accepts but you do not want offered simply stays out of levels. Two optional tables carry the rest:

So a request travels closed scale → rung_map → levels → effort_values → wire. See thinking-modes-vocabulary.md and thinking-modes-rung-mapping.md.

reasoning:
  control: chat_template_kwarg   # none | always | chat_template_kwarg | effort_enum |
                                 # budget_tokens | system_prompt | soft_switch
  levels: [off, low, high]       # the ladder this model offers — the picker's segments
  default: high                  # used when a caller asks for no particular rung
  effort_values: {high: xhigh}   # what the endpoint hears for the `high` segment
  rung_map:                      # optional; unset rungs clamp to the nearest offered one
    medium: low                  #   "medium is low on this model"
    xhigh: high
    max: high
  echo: tool_turns               # never | tool_turns | always — reasoning passback policy

Known subagent tool names: subagent, explore, agentic_developer, web_retrieve, web_search, context_summarization.

Connections (models.connections):

A connection is one endpoint and the models it serves — a company OpenAI key exposing several models, an OpenRouter account, a gateway. Where a profile names one model, a connection lists many, and each listed model becomes a profile named <connection>/<model> that subagent_default, subagent_profiles, fallback_profile and a thinking mode's main/roles can name like any other.

models:
  connections:
    company-openai:
      title: Company OpenAI
      base_url: https://api.openai.com/v1/
      api_key: ${OPENAI_API_KEY}
      models: [gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna]
      light_model: gpt-5.6-luna      # omit = the provider catalog's default
      # privacy: org_cloud           # omit = derived from the host
      temperature: 1.0               # any profile field here applies to every model
      model_settings:                # profile fields per model, replacing the above
        gpt-5.6-sol: {context_window: 400000}
    openrouter:
      base_url: https://openrouter.ai/api/v1/
      api_key: ${OPENROUTER_API_KEY}
      models: [deepseek/deepseek-v4.1-flash]

  subagent_profiles:
    explore: company-openai/gpt-5.6-luna
    web_retrieve: openrouter/deepseek/deepseek-v4.1-flash

model_selection.picker — how models are described to agents

The agent chooses models itself in two places: the model and effort of a subagent it starts (when Let the agent pick a model and effort per subagent is on), and the model and effort of each goal worker it sets up or edits. Both see the same list, one line per model:

Luna [cost 1]: Fast and cheap; good for searching and collecting — Company OpenAI
Sol [cost 3]: Strongest; use for hard reasoning and code changes — Company OpenAI
claude-sonnet: claude-sonnet — organization-claude     ← nothing configured

A model with no description reads only as its name and connection (as claude-sonnet above), which gives the agent nothing to choose by, so it tends to pick the strongest model at high effort for everything. Describe each model once, keyed by its reference (<connection>/<model>, or a models.profiles name):

model_selection:
  picker:
    company-openai/gpt-5.6-luna:
      short: Luna
      description: Fast and cheap; good for searching and collecting
      cost: 1
    company-openai/gpt-5.6-sol:
      short: Sol
      description: Strongest; use for hard reasoning and code changes
      cost: 3
FieldDefaultDescription
descriptionthe connection's own description, else noneOne line on what the model is good for. Shown under the model in the composer's picker, and to the agent as the model's line when it picks a model for a subagent or a goal worker. Say when to use it ("fast and cheap; for reading and collecting"), not the vendor's marketing.
costunsetRelative cost, a whole number 1 (cheapest) to 3. Shown to the agent as [cost N] next to the model. Unset shows no marker. A value outside 1–3 stops the config from loading.
shorttitle, else the connection's name for the model, else the model idThe model's short name: the chip label, and the name the agent passes as model (the full reference when two models share a short name).
titlethe connection's name for the model, else the model idFull label in the picker; the agent's line uses it when there is no description.
effortmodel_selection.default.effortThe model's default effort.

thinking_modes

Curated thinking modes — one named setting per conversation that decides which model answers, which model each background role uses, and how hard the assistant reasons. A mode is one altitude above models.profiles: it references profiles rather than replacing them. Delivered by the Thinking Modes plugin, which is enabled in the shipped default config.

Omitting the section ships two built-in modes — Fast and Slow, named after the two ways a person works a problem (why) — plus Custom, the user's own per-role mix of the two. They differ in deliberation alone and name no model, and the default is Slow, so nothing about your requests changes until someone picks Fast. The retired ids balanced and deep still resolve to slow, so stored selections and /mode deep keep working.

thinking_modes:
  default: slow                    # mode for a user who has expressed no preference
  modes:
    fast:
      title: Fast
      description: Answers from what it can see and look up.
      icon: bolt
      cost: 1                      # 1-3 relative badge
      main: local-qwen             # a name from models.profiles
      effort: { default: "off" }   # starts at off; the user can still turn it up
    slow:
      title: Slow
      description: Plans before acting, strongest model for code changes.
      cost: 3
      main: cloud-strong
      roles: { context_summarization: local-qwen, explore: local-qwen }
      effort: { default: medium, allowed: [off, minimal, low, medium, high, xhigh] }
                                   # a ceiling — never `max` on the cloud model
      prompt: |
        Before editing, write a short plan and verify it against the code.

effort is the deliberation dial: how long the assistant reasons before each step, not how many steps it takes. Read the rungs as which instruction the model is given rather than as a quantity of intelligence — medium is the model unsteered, not a midpoint between low and high. See the plugin page for the per-rung table.

FieldDefaultDescription
defaultfirst declared modeMode a user with no preference lands on.
modes.<id>.titlerequiredLabel shown in the picker.
modes.<id>.description""One line under the title.
modes.<id>.iconunsetIcon token for the picker.
modes.<id>.cost2Relative cost/speed badge, 1–3.
modes.<id>.mainunsetProfile the main agent uses, and what unlisted roles inherit. Unset leaves model selection to models:.
modes.<id>.roles{}role → profile name, overriding main for that role.
modes.<id>.effort.defaultunsetRung the mode starts at. Unset = the resolved model's own default.
modes.<id>.effort.allowedunsetRungs a user may select. Unset = every rung the model supports. Intersected with the model's reasoning capability, through its rung_map — a segment is offered when any rung that lands on it is allowed.
modes.<id>.promptunsetInstruction block injected as a stable prefix note while this mode is active.

speech

Speech-to-text / text-to-speech service used by the read_aloud message action, the Voice Mode overlay, and Telegram voice replies. It is a sibling of models, not part of it, because the audio provider is usually a different endpoint than the chat-model gateway (e.g. a local vLLM box serves chat but not Whisper/TTS). Uses OpenAI-compatible audio endpoints (/v1/audio/transcriptions, /v1/audio/speech).

speech:
  enabled: true
  base_url: "https://api.openai.com/v1"
  api_key: "${OPENAI_API_KEY}"
  tts_model: "tts-1"
  tts_voice: "alloy"
FieldDefaultDescription
enabledfalseExplicit opt-in for speech and the authenticated-user key fallback. Push-to-talk needs only usable speech; read-aloud also needs its plugin. Advanced live voice has separate readiness rules (see below).
base_urlhttps://api.openai.com/v1OpenAI-compatible audio endpoint base URL.
api_keynullDeployment credential; a usable value takes priority over the authenticated user's stored speech key. Supports ${ENV_VAR}; ${secret:<name>} still requires an agent-turn context and is not the web fallback mechanism. Use an environment-backed deployment key for shared service use.
allow_user_api_keyCommunity: true; Enterprise: falseAllow web speech to fall back to the authenticated user's stored secret when no usable deployment key exists. Requires enabled: true, an active authenticated account, and user_secrets:manage. Does not change Telegram's credential semantics.
user_api_key_secretspeech_api_keyExact stored-secret name for that fallback. Both ordinary and Host-only secrets work; Host-only is recommended. Store a literal provider key, not a placeholder.
stt_modelwhisper-1Speech-to-text model.
stt_languagenullnull = let the provider auto-detect the spoken language.
stt_max_audio_bytes26214400 (25 MB)Reject larger uploads before hitting the provider.
tts_modeltts-1Text-to-speech model.
tts_voicealloyTTS voice.
tts_formatopusopus → Ogg/Opus (native Telegram voice note). Also: mp3, aac, flac, wav, pcm.
tts_speed1.0Playback speed multiplier.
tts_max_input_chars4096Guard against synthesising an enormous reply. 0 disables it.
read_timeout120.0HTTP read timeout (seconds).
max_retries2Retry count for transient provider errors.

The fallback is a dedicated host-side credential lookup, not general ${secret:…} resolution outside agent turns. A provider rejecting a deployment key does not cause a retry with a personal key. User Secrets is enabled in newly generated personal default configurations only; existing instances must enable the plugin themselves. Push-to-talk is independent of hands-free; optional hands-free requires the enabled voice_mode plugin. Advanced live voice requires voice_mode and live.enabled; a usable live/deployment credential can work without speech.enabled, but the personal-key fallback always requires it.

See Plugins → Speech for the operational checklist, or the English / Hungarian setup guide.

vector_db

Vector database configuration:

cache

Embedding caching configuration:

agent

Agent behavior configuration:

tools

Tool-specific configuration:

Access permission policies

Access Profiles defines access.permission_policies, profile
permissions and mediation run_permissions (each a policy name or an inline
preset/allow/deny/shared_credentials block). These decide which permissions
exist for a principal/run; strict task profiles can only narrow effective access.
Mediation repository selections are additions, not replacement standing scope.

The top-level permissions below is the separate interactive approval gate. An
approval, role grant or Auto verdict never widens effective access.

permissions

The tool-approval gate's operator floor. Everything here is read-only over the API: no user setting, conversation mode or Auto verdict can widen it. See Permissions for the user-facing behaviour.

What reaches the gate. The full list, because two of these are easy to miss:

An MCP app's tool call and the last three do not pass through the agent's tool gate, so they carry no model-written reason — see reason_argument below.

File edits inside the workspace do not reach the gate: no file-editing tool requests a permission, so in a conversation no mode and no Write(…) rule stops one. Print mode is the exception, and it is a different mechanism — codumentor -p refuses the file-editing tools by name under default and plan (see default_mode below). The file_write permission type is reserved for the path-aware gating that has not shipped yet — until it does, what confines a write in a conversation is the workspace boundary (see repos_dir), not this block.

Hot-reload class: APPLY — the gate re-reads this block on every tool call, so an edit takes effect on the next one. reason_argument is the exception: it is baked into an agent's tool schema, so cached agents are flushed on reload.

permissions:
  allow: []                    # operator allow rules, same syntax as UI rules
  deny: []                     # operator deny rules — highest priority anywhere
  default_mode: acceptEdits    # what a conversation starts in
  allow_bypass: true           # false: "Always allow" unavailable to users
  allow_auto: true             # false: Auto unavailable to users
  reason_argument: required    # required | optional | off

  auto:                        # Auto mode's triage
    judge_role: permission_judge
    judge_timeout_s: 12
    include_reason: false
    judge_arm_comparison_rate: 0   # 0-1: run both include_reason arms and log the pair
    max_auto_allows_per_turn: 100
    max_judge_calls_per_turn: 100
    revert_to_ask_after:
      consecutive_user_denials: 3
      total_asks: 20
    always_ask_types: [gmail.send, gitea.submit_review, write_system_config]
    user_turns_window: 12
    trajectory_window: 8

  structural:                  # the deterministic command analyser
    readonly_allow: []         # empty = the built-in read-only command set
    max_complexity: 6
    extra_escalate_patterns: []
    project_code_allow_when_isolated: true
FieldTypeDefaultDescription
allowlist[]Operator allow rules (Shell(git status), Read(*.json), MCP(github_create_issue)). Matched per simple command: every part of a compound command must match, and a command carrying an escalating flag can never be covered.
denylist[]Operator deny rules. The highest priority in the system — no user rule, mode or Auto verdict lifts one. A deny matching any part of a compound command denies the whole thing.
default_modestracceptEditsWhat a conversation starts in when the user has no default of their own. One of default, acceptEdits, auto, plan (read-only), bypassPermissions. default and acceptEdits behave identically in a conversation — in-workspace file edits are ungated either way; they differ only in print mode (-p), where default also refuses the file-editing tools unless --allowed-tools names them.
allow_bypassbooltruefalse removes "Always allow" from every user's choices, including a default they set earlier.
allow_autobooltruefalse removes Auto the same way.
reason_argumentstrrequiredWhether permission-gated tools carry the approver-facing reason argument. optional keeps the field but drops it from required (for providers with strict schema validation); off injects nothing. Costs roughly 35 schema tokens per gated tool and 25 output tokens per gated call.

##### permissions.reason_argument and what carries a reason

The reason is an argument on a tool schema, so it exists only for approvals that come from a tool call the model made: shell commands and every gated plugin tool. The four approvals raised elsewhere carry none, and both dialogs simply omit the line — an out-of-workspace file read (raised inside a read, by the file tool), sandbox_network (asked before the turn's first command runs), an MCP app's tool call, and a nested external agent's call back into Codumentor. A missing reason there is not a model that declined to explain itself.

permissions.auto

Only consulted in Auto mode (whether a user chose it, default_mode set it, or scheduler.permission_mode did).

FieldTypeDefaultDescription
judge_rolestrpermission_judgeThe model_role the tier-2 judge resolves through — map it in models.subagent_profiles to put the judge on a cheaper model. Must not collide with an agent role. Defaults to the agent model with thinking disabled.
judge_timeout_sfloat12.0A judge that has not answered by then prompts instead.
include_reasonboolfalseFeed the agent's reason to the judge as a labelled, grounding-checked claim. Off by default: our evaluation found the channel changed no verdict on 88 of 89 hostile items and, on the 89th, let a rationalising reason turn an ask into an allow. Turning it on gives the judge more to read at the cost of a persuasion channel; the switch exists so the trade-off can be re-measured as the corpus grows.
judge_arm_comparison_ratefloat0.0Fraction of judged calls (0-1) that ask the judge both ways — with the reason and without — in parallel, and answer with the safer of the two: the configured arm's verdict, downgraded to a prompt if the other arm wanted one. It can only ever turn a silent approval into a prompt, never the reverse. Each sampled call costs two judge calls instead of one and writes one line to the log (PERMISSION_JUDGE_ARMS {json}: both verdicts, both notes, agree, and the command and reason clipped to 240 characters). This exists because the setting above is decided one way per install, so no ordinary approval record can say what the other setting would have done; turn it up on a staging instance, or low (0.05) on a busy one, when you want that answer for your own traffic. Calls with no reason are not sampled, and a comparison is skipped when the turn's judge budget has room for only one call.
max_auto_allows_per_turnint100Silent approvals per turn; the next gated call prompts.
max_judge_calls_per_turnint100Judge calls per turn; beyond it, prompt.
revert_to_ask_after.consecutive_user_denialsint3Denying this many Auto-produced prompts in a row switches the conversation back to Ask. A user allow resets the counter.
revert_to_ask_after.total_asksint20Auto asking this many times in one conversation switches it back to Ask.
always_ask_typeslist[gmail.send, gitea.submit_review, write_system_config]Permission types that always prompt, without consulting a judge — the irreversible and outward-facing ones.
user_turns_windowint12How many of the user's own messages the judge sees (first turn plus the last N).
trajectory_windowint8How many recent gated calls appear in the judge's trajectory digest.

The judge never sees tool results, file contents, web pages, the agent's prose or thinking, conversation summaries, or repository instruction files. It cannot approve without quoting words the user actually typed, and any error, timeout or malformed answer prompts.

permissions.structural

The deterministic analyser feeds rule matching, the approval dialogs' badges and Auto's first tier, so a change here is visible in every mode. All three see the operator's knobs below — the gate re-derives a request's analysis from this block before it decides, so these apply with or without workspace_isolation loaded.

Two environments, one analyser. The analyser is given the conversation's sandbox facts where they are reachable, and one flag changes severity with them: network_egress is escalating when the network is reachable and informational when the sandbox has no network of its own. The rule engine cannot see the execution strategy — it is handed a request, not a conversation — so rule matching always analyses in the default environment: unsandboxed, networked, workspace boundary unknown. The consequence operators hit: Shell(git:*) never covers git push, in any sandbox configuration, while the badge on the dialog for that same command may still render in the quiet colour. That asymmetry is the conservative direction and is deliberate; both halves are documented in the user guide.

FieldTypeDefaultDescription
readonly_allowlist[]Overrides the built-in read-only command set. Empty means "use the built-in set" — an empty list is far more likely to be an accident than an intent, so use max_complexity or an escalate pattern to tighten instead. Adding a command here vouches for its whole option surface. The built-in set is narrowed per tool for the options that write a file, run a program or read something the command line never named (sort -o, rg --pre, fd -x, awk's program text, git remote add, …); a name you add gets no such narrowing, so any invocation of it counts as a read. Prefer a tool that cannot write or exec at all.
max_complexityint6Above this many commands + pipes + redirects + heredocs, the command is flagged long_command.
extra_escalate_patternslist[]Regexes matched against the raw command string. A hit escalates, which means no allow rule can cover the command and Auto can never approve it silently. An invalid regex is rejected at config load, not at gate time.
project_code_allow_when_isolatedbooltrueWhether Auto's first tier may approve a command that runs project code (pytest, make, npm test) when the workspace is an isolated sandbox with no shared network. This is an Auto policy, not an analyser input: the analyser always reports the fact.
# Single-user developer install: quiet, still audited.
permissions:
  default_mode: auto
# Multi-user team server: users may not switch the gate off, and the
# operator's deny rules are the floor.
permissions:
  allow_bypass: false
  deny:
    - "Shell(sudo:*)"
    # Read(...) covers reads outside the workspace only — a .env inside a
    # repository is read without asking.
    - "Read(.env)"
    - "Read(.env.*)"
# Read-only demo instance.
permissions:
  default_mode: plan
  allow_bypass: false
  allow_auto: false

api

API server configuration:

##### Restarting the server from the Admin page

Administrators with admin:* (the same permission as Config Reload) can
restart a running API process from the web UI — no shell and no change to
systemd or Docker. See Process supervisor
for how the built-in supervisor brings the process back.

On the Admin hub (/admin), the Server section shows version,
edition, how long the process has been up, and whether restart is available.
Restart server… opens a confirmation dialog. The lead line is that
everyone using the server is disconnected for a few seconds. The dialog lists
active work and what happens to it: agent turns resume after the new
boot (when resume_interrupted_turns is on); **in-flight ingestion and
scheduled / triggered runs are aborted and marked failed**, not resumed;
approval waits survive. There is no drain mode — Restart now shuts down
immediately.

If restart is unavailable (for example the server was started with
--no-supervisor, or the home is ephemeral), the button is disabled and the
panel explains why.

On Admin → Config Reload (/admin/config), a "restart required" banner
after a hot-reload that could not apply every change includes Restart now,
which opens the same dialog.

After a restart is accepted, every connected client shows a non-dismissable
Codumentor is restarting… overlay and polls /health until a new boot id
appears, then reconnects.

Sandbox origins: the minimal deployment

Every sandbox tier below (MCP Apps, published apps and their per-app hosts,
the file-preview sandbox, port previews) needs a browser origin other than
the main one. All of them may be names under the main host, so an
instance needs only two DNS names and one wildcard certificate:

api:
  external_url: "https://codumentor.example.com"
  mcp_apps:
    sandbox_origin: "https://mcp.codumentor.example.com"
  apps:
    origin: "https://apps.codumentor.example.com"
    wildcard_origin: "https://*.codumentor.example.com"
  app_preview:
    sandbox_origin: "https://preview.codumentor.example.com"
    wildcard_origin: "https://*.codumentor.example.com"

Label scheme on the shared wildcard domain:

HostServes
codumentor.example.comthe product (UI and API); never a sandbox route
a-<app_id>.codumentor.example.comone published app (backend and capability apps)
p-<capability>.codumentor.example.comone running port preview
the fixed names you configure (apps., preview., mcp. above)that tier only
any other name on the domain404 (a WebSocket upgrade is closed with 1008)

Rules the gates enforce (a refused tier logs the reason and stays off, or
degrades, without stopping the server):

Reverse proxy: route both names to the process and forward the original
Host header unchanged (X-Forwarded-Host is not used for this routing):
with a rewritten Host, every tier host is treated as the main host. Allow WebSocket
upgrades (see the nginx example under Port previews on their own origins,
with server_name codumentor.example.com *.codumentor.example.com;), and
never set a cookie with Domain=codumentor.example.com (or a parent of
it) at the proxy or in any other application on these names. Every tier is a
separate origin only as long as nothing shares cookies across the domain.

Why this is safe: a subdomain of the main host is same-site with it, like
a sibling host. The main origin defends itself against same-site hosts
(audit finding WS1-5):

See doc/admin/authentication.md.

Residual risks compared with a separate registrable domain (for example
*.codumentor-usercontent.example.net), which remains the stronger,
optional setup:

The preview's Clear-Site-Data response header clears "storage" only, never
"cookies", which would act on the whole registrable domain and log users out.

api.mcp_apps

Interactive MCP Apps are enabled
by default only after the deployment supplies a valid sandbox origin. With
no sandbox_origin, or with an unsafe one, Codumentor stays text-only and does
not advertise the Apps extension to MCP servers.

api:
  external_url: "https://codumentor.example.com"
  mcp_apps:
    sandbox_origin: "https://mcp-app-sandbox.example.net"

Local install: set sandbox_origin: "http://localhost:2638" (your
api.port) and open the UI at http://127.0.0.1:2638 — never via localhost,
which then serves only the sandbox shell. See
MCP Apps.

The sandbox hostname can reverse-proxy to the Codumentor process. The process
serves only /mcp-app-sandbox.html on that virtual host and returns 404 for API
and SPA routes. Do not attach a broad Domain= cookie to a parent domain shared
by the host and sandbox. If content_security_policy is custom, its
frame-src must explicitly include the normalized sandbox origin.

Roll out by configuring the origin on one instance, confirming the log does not
report an MCP Apps availability reason, and watching
GET /ui/admin/mcp-apps-metrics. Useful signals are lifecycle failed versus
initialized, resource failures/cache hits, RPC outcomes and p95 latency, and
security rejections. The endpoint requires admin:*; POST the corresponding
/ui/admin/mcp-apps-metrics/reset endpoint before a compatibility exercise.
If failures rise, set api.mcp_apps.enabled: false; textual tool results remain
available and existing conversation data needs no migration.

api.apps — Published apps

Lets the agent publish a small static web app (app_create, app_publish,
app_checkout) at a stable URL that other signed-in users can open, listed on
the Apps page (/apps). Published apps are served from a **dedicated app
origin**: one more DNS name pointed at the same process, like
api.app_preview.sandbox_origin. Apps live at <origin>/a/<app_id>/.

api:
  external_url: "https://codumentor.example.com"
  apps:
    origin: "https://apps.codumentor-usercontent.example.net"

Backends (api.apps.backend). An app whose app.yaml declares
backend: backend/main.py is served on its own host (this needs
api.apps.wildcard_origin, below) and answers
ANY a-<app_id>.<domain>/a/<app_id>/api/... from a
warm pool of sandboxed Python workers (bubblewrap: read-only /app, the app's
data/ read-write at /data, tmpfs /tmp, no network, empty environment).
The host verifies the viewer and passes their identity; workers never see a
token. Only /a/<app_id>/api/ (and the exact path
/a/<app_id>/_codumentor/handoff, POST only; see below) accepts methods
other than GET/HEAD.

api:
  apps:
    backend:
      request_timeout_seconds: 10
      rate_limit_per_minute: 60
      storage_quota_mb: 512

Viewer-facing errors are generic JSON with an error_id that also appears in
the log. App data and logs are deleted with the app.

Conversation handoff (api.apps.handoff). An app can hand its viewer to
their own agent: the frontend SDK's CodumentorApp.handoff({title, prompt,
data})
(or a backend's req.handoff(...) descriptor, posted by the SDK)
sends POST <origin>/a/<app_id>/_codumentor/handoff with the app session.
The payload is stored server-side, bound to the viewer, the app and its
published version, and the viewer lands on <external_url>/handoff/<token>:
a composer showing "Started from app v<N> (by <owner>)", the proposed<br> prompt (editable) and the data as an expandable card. Nothing runs until they<br> press send; then the token is spent, a conversation is created with<br> <code>metadata.source_type: app_handoff</code>, and the data reaches the agent as a<br> provenance-marked context note ("data, not instructions"). Only the viewer<br> the handoff was made for can open it; anyone else gets 404. The Apps page's<br> <strong>Ask about this app</strong> action is a handoff of the app's manifest (plus its<br> version list, for the owner).</p> <pre><code class="language-yaml">api: apps: handoff: max_payload_bytes: 262144 ttl_seconds: 1800</code></pre> <ul> <li><code>enabled</code> (default: <code>true</code>): <code>false</code> makes the handoff endpoint and the Ask action 404 and drops <code>req.handoff</code> from backends.</li> <li><code>max_payload_bytes</code> (default: 262144, 256 KiB): ceiling on the JSON body; 413 beyond.</li> <li><code>ttl_seconds</code> (default: 1800): how long an unused handoff link stays valid.</li> </ul> <p>Handoffs are rate-limited to 20 per minute per (app, viewer). Each one writes<br> an <code>app.handoff.created</code> audit event (app, version, handoff id, payload size;<br> not the payload itself). Pending payloads live in<br> <code><data_dir>/apps/.auth/handoffs.db</code>, next to the one-time sign-in codes.</p> <p><strong>Capabilities (<code>api.apps.wildcard_origin</code>, <code>api.apps.capabilities</code>).</strong> An<br> app may declare capabilities in its <code>app.yaml</code>, e.g.<br> <code>capabilities: [{kind: db.query, connection: sales}]</code>; its backend then calls<br> <code>req.capabilities.db_query("sales", sql, params)</code> and the host runs the query<br> <strong>as the viewer</strong> (their own <code>password_secret</code>, never the author's), forced<br> read-only, capped at 500 rows, 1 MiB and 5 s (each also bounded by the<br> database plugin's own limits). Secrets never enter the sandbox.</p> <pre><code class="language-yaml">api: apps: origin: "https://apps.example.net" wildcard_origin: "https://*.apps.example.net" capabilities: disabled_kinds: [] # e.g. [db.query] rate_limit_per_minute: 60 # per (app, viewer, kind)</code></pre> <ul> <li><code>wildcard_origin</code> (default: unset): <code>scheme://<em>.<domain>[:port]</code>. Each app with a backend or capabilities is served only on its own host, <code>a-<app_id>.<domain></code>, never on the shared <code>origin</code>, and its session cookie is host-only on that host, so no other app can call its backend as the viewer. It follows the same syntax, HTTPS, overlap and <code>frame-src</code> rules and the same DNS + wildcard-certificate recipe as <code>api.app_preview.wildcard_origin</code> (see </em>Port previews on their own origins* under <code>api.app_preview</code> below), and may be the very same value (the <code>a-</code> and <code>p-</code> labels do not collide). <code>apps.origin</code> must not be its domain, above it, or an <code>a-</code>/<code>p-</code> name below it. Without it, publishing an app with a backend or capabilities fails with a message naming this key; static apps are unaffected and stay on the shared <code>origin</code>. (A path-scoped cookie is no boundary there: another app's script could call a backend as the viewer, including their per-viewer storage.)</li> <li>Capability apps are refused under <code>auth.provider: none</code> (a grant is one signed-in user's decision).</li> <li><code>capabilities.disabled_kinds</code> (default: <code>[]</code>): the per-kind kill switch. A listed kind cannot be published, and every call of it is refused at once with <code>capability_denied</code>.</li> <li><code>capabilities.rate_limit_per_minute</code> (default: 60).</li> </ul> <p><strong>Consent.</strong> On first open of a capability app, and again whenever its<br> declared set grows, <code>/apps/authorize</code> shows a consent screen on the main<br> origin (<em>"<title> (by <owner>, v<N>) wants to: …"</em>). Declining still opens<br> the app, but its capability calls fail. A shrinking set does not ask again.<br> Grants pin the capability set (its hash), not the app version: new code with<br> the same capabilities keeps the grant. Viewers revoke grants on the Apps<br> page. If a viewer has not set the secret a capability needs, the screen says<br> so and links to their secrets; their calls fail with <code>missing_secret</code><br> until they set it (setting secrets needs <code>user_secrets:manage</code>, <code>power_user</code><br> by default; no role changes are made for apps). Grants live in<br> <code><data_dir>/apps/.auth/grants.db</code>. Audit events: <code>app.grant.created</code>,<br> <code>app.grant.declined</code>, <code>app.grant.revoked</code>, and <code>app.capability.call</code> per<br> call (kind, constraints, viewer, app, version, result size, duration,<br> outcome; never rows or SQL parameters).</p> <p><strong>Sign-in:</strong> a visitor without a session is redirected to<br> <code><external_url>/apps/authorize</code>, which checks visibility (<code>private</code> = owner<br> only, <code>org</code> = every signed-in user) and returns them to the app with a<br> single-use code. The app origin then sets an <code>httponly</code>, <code>SameSite=Lax</code> cookie<br> scoped to <code>Path=/a/<app_id>/</code>.</p> <p><strong>Permissions:</strong> <code>apps:create</code> (author and publish; <code>user</code> and <code>power_user</code> by<br> default), <code>apps:publish_org</code> (make an app visible to everyone; same default —<br> remove it from <code>user</code> to restrict sharing) and <code>admin:apps</code> (manage or disable<br> anyone's app; <code>admin</code>).</p> <p><strong>Storage:</strong> versions are immutable copies under <code><data_dir>/apps/<app_id>/</code>;<br> rollback only moves the published pointer. Back this directory up with the<br> rest of <code>data_dir</code>.</p> <p><strong>Local install:</strong> use another loopback alias, e.g. <code>origin:<br> "http://127.0.0.3:2634"</code> (your <code>api.port</code>), and for backend apps<br> <code>wildcard_origin: "http://*.apps.localhost:2634"</code> (browsers resolve every<br> <code>*.localhost</code> name to loopback without DNS); open the UI at<br> <code>http://127.0.0.1:2634</code>. The process serves only <code>GET</code>/<code>HEAD /a/...</code> (any<br> method under <code>/a/<app_id>/api/</code>) on that host and returns 404 for API and SPA<br> routes. As with the other sandbox origins,<br> do not set a parent-domain <code>Domain=</code> cookie shared by the main host and the app<br> origin.</p> <h4 id="apiapp_preview"><code>api.app_preview</code></h4> <p>Runs an agent-built static web app in a sandboxed iframe, so *"build me a small<br> web app"* ends with something the user can click rather than a file listing.<br> Same shape and same reasoning as <code>api.mcp_apps</code> above — one more DNS name<br> pointing at the same process — and deliberately so: an operator should have to<br> learn this mechanism once.</p> <pre><code class="language-yaml">api: external_url: "https://codumentor.example.com" app_preview: sandbox_origin: "https://preview.example.net"</code></pre> <ul> <li><code>enabled</code> (default: <code>true</code>): kill switch. <code>false</code> removes the preview endpoints, the <code>/preview</code> command and the <code>preview_app</code> tool entirely.</li> <li><code>sandbox_origin</code>: dedicated origin for the previewed app. Production requires HTTPS and an origin different from <code>external_url</code>; two loopback HTTP origins are allowed for development, and the whole <code>127.0.0.0/8</code> block counts — so <code>external_url: http://127.0.0.1:2638</code> plus <code>sandbox_origin: http://127.0.0.2:2638</code> gives a dev box a working second origin with no DNS at all.</li> <li><code>session_ttl_minutes</code> (default: <code>60</code>): capability lifetime, sliding on use, hard-capped at 8 hours.</li> <li><code>max_file_bytes</code> (default: 25 MiB) / <code>max_session_bytes</code> (default: 200 MiB) / <code>max_sessions_per_user</code> (default: <code>8</code>, LRU-evicted).</li> <li><code>max_port_response_bytes</code> (default: 100 MiB): the largest single response streamed from a dev server through a port preview (below). Port previews have no session byte budget; this cap and <code>rate_limit.preview_port_per_minute</code> bound them instead.</li> <li><code>allow_shared_sandbox_origin</code> (default: <code>false</code>): permit pointing this at the MCP Apps origin <em>while MCP Apps are also enabled</em>. Refused by default, because a concurrently-open MCP App can reach a sibling preview frame by index, become same-origin with it and read the preview's session id out of its <code>location</code>. Sharing when MCP Apps are disabled needs no flag — the gate works that out for itself.</li> </ul> <p><strong>Port previews (dev servers).</strong> With a <code>sandbox_origin</code> and workspace<br> isolation, the agent can start a server in the conversation's sandbox with<br> <code>shell(run_in_background: true, preview_port: N)</code> and hand it over with<br> <code>preview_app(process_id: …)</code>. The server keeps its private network namespace;<br> Codumentor reaches it through a small forwarder that joins that namespace<br> (Linux 5.8+, no extra package) and proxies it under<br> <code><sandbox_origin>/_app-preview/p/<capability>/</code>, with the same response<br> headers as a file preview. The capability lives as long as the process (at<br> most <code>background_processes.default_max_runtime_seconds</code>). Not available on<br> the degraded tier, or for a <code>network: true</code> command.</p> <p><strong>Port previews on their own origins (<code>wildcard_origin</code>).</strong> On the path tier<br> above, a dev server must be started with its base set to<br> <code>$CODUMENTOR_PREVIEW_BASE</code> (<code>vite --base</code>, Astro <code>base</code>, Next <code>basePath</code>), or<br> its hot-reload socket may not connect. With a wildcard domain, every dev server<br> gets an origin of its own, <code>p-<capability>.<domain></code>, and runs at <code>/</code> as it<br> does in production (<code>$CODUMENTOR_PREVIEW_BASE</code> is then <code>/</code>). Previews are also<br> isolated from each other and from file previews.</p> <pre><code class="language-yaml">api: external_url: "https://codumentor.example.com" app_preview: sandbox_origin: "https://preview.example.net" wildcard_origin: "https://*.dev.example.net"</code></pre> <ul> <li><code>wildcard_origin</code> (default: unset): <code>scheme://<em>.<domain>[:port]</code>, exactly one leading <code></em>.</code> label, no path. It needs a working <code>sandbox_origin</code> (file previews keep using it). HTTPS is required unless both it and <code>external_url</code> are loopback (<code>http://<em>.localhost:<port></code>). Its domain may be the main host's own name or below it (<code></em>.codumentor.example.com</code> next to <code>codumentor.example.com</code>, see <em>Sandbox origins: the minimal deployment</em>), but not above it (<code>*.example.com</code>: a preview could set cookies for the Codumentor host). <code>sandbox_origin</code> and <code>mcp_apps.sandbox_origin</code> must not be the domain, above it, or a <code>p-</code>/<code>a-</code> name directly below it.</li> <li>A registrable domain of its own (<code>*.dev.example.net</code> next to <code>codumentor.example.com</code>) is the stronger, optional setup; the residual risks of a same-site domain are listed in the section above.</li> <li>If it fails a check, port previews stay on the path tier and the log names the reason (<code>invalid_wildcard_origin</code>, <code>wildcard_requires_https</code>, <code>wildcard_above_main_origin</code>, <code>wildcard_under_main_requires_https</code>, <code>wildcard_overlaps_sandbox_origin</code>, <code>wildcard_overlaps_mcp_apps_origin</code>, <code>wildcard_blocked_by_host_csp</code>).</li> <li>With a custom <code>content_security_policy</code>, <code>frame-src</code> must list exactly this value (<code>https://<em>.dev.example.net</code>), as well as <code>sandbox_origin</code>. Any </em>other* wildcard host in <code>frame-src</code> still drops the whole preview to <code>degraded</code>. The default policy adds both by itself.</li> <li>On the wildcard domain the process answers only <code>p-<capability></code> hosts of running port previews on the configured port, and only with that dev server (plus <code>a-<app_id></code> hosts when <code>api.apps.wildcard_origin</code> shares the domain, and the configured fixed names). Anything else on the domain — the bare domain itself unless it is the main host, deeper names, a missing or different port — is a 404 (a WebSocket upgrade is closed with 1008), and a port preview is then no longer served on the shared <code>sandbox_origin</code>.</li> </ul> <p>What it takes on the network side:</p> <ol> <li><strong>DNS:</strong> a wildcard record pointing at the reverse proxy, e.g. <code>*.dev.example.net. CNAME codumentor.example.com.</code></li> <li><strong>Certificate:</strong> one wildcard certificate for <code><em>.dev.example.net</code>. A wildcard certificate covers exactly one label, which is what <code>p-<capability></code> is. With Let's Encrypt this needs the DNS-01 challenge (<code>certbot certonly --dns-<provider> -d '</em>.dev.example.net'</code>).</li> <li><strong>Reverse proxy:</strong> pass the original <code>Host</code> through, port included, and allow WebSocket upgrades and long-lived responses (dev servers keep a hot-reload socket open). nginx's <code>$host</code> drops the port, which is fine on 443; for a wildcard on another port (<code>https://*.dev.example.net:8443</code>), use <code>proxy_set_header Host $http_host;</code> instead, or every preview is a</li> <li>nginx:</li> </ol> <p> ```nginx<br> map $http_upgrade $connection_upgrade { default upgrade; '' close; }</p> <p> server {<br> listen 443 ssl;<br> server_name *.dev.example.net;<br> ssl_certificate /etc/ssl/dev.example.net/fullchain.pem;<br> ssl_certificate_key /etc/ssl/dev.example.net/privkey.pem;</p> <p> location / {<br> proxy_pass http://127.0.0.1:2638; # the Codumentor process<br> proxy_http_version 1.1;<br> proxy_set_header Host $host; # required: the host names the preview<br> # ($http_host on a non-443 port)<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection $connection_upgrade;<br> proxy_set_header X-Forwarded-Proto $scheme;<br> proxy_buffering off;<br> proxy_read_timeout 1h;<br> }<br> }<br> ```</p> <p> Do not set a cookie with <code>Domain=dev.example.net</code> (or any parent of it)<br> anywhere: each preview is a separate origin only as long as nothing shares<br> cookies across the domain.</p> <p><strong>Local install, no DNS:</strong> browsers resolve every <code>*.localhost</code> name to<br> loopback by themselves, so a dev box can use the wildcard tier with one more<br> line:</p> <pre><code class="language-yaml">api: external_url: "http://127.0.0.1:2638" app_preview: sandbox_origin: "http://127.0.0.2:2638" wildcard_origin: "http://*.localhost:2638"</code></pre> <p><code>external_url: "http://localhost:2638"</code> works too: the bare <code>localhost</code> is<br> then the main host and every tier may sit below it (<code>*.localhost</code>). The<br> server must listen on <code>127.0.0.1</code> (or on all addresses). Verified in Chromium<br> and WebKit.</p> <p><strong>Without a valid <code>sandbox_origin</code> the feature does not disappear</strong>; it runs in<br> the <code>degraded</code> tier, served from the main origin inside an <code>allow-scripts</code>-only<br> frame. Relative assets load, so a multi-file build renders; <code>localStorage</code> and<br> the app's own same-origin <code>fetch()</code> do not, because an opaque origin has no<br> storage and is same-origin with nothing. (<code>history.pushState()</code> to a same-URL<br> path <em>does</em> work there — measured, contrary to what the design doc predicted.)<br> The overlay says so in one line.<br> Root-absolute asset paths (<code><script src="/assets/index.js"></code>, the Vite default)<br> also only resolve on the <code>app</code> tier; build with a relative base<br> (Vite's <code>base: './'</code>) or set <code>sandbox_origin</code>.</p> <p>The sandbox hostname can reverse-proxy to the Codumentor process. On that<br> virtual host the process serves only <code>/_app-preview/*</code> and returns 404 for API<br> and SPA routes — and, symmetrically, <code>/_app-preview/*</code> returns 404 on the<br> <em>primary</em> host once a valid sandbox origin exists, so the second origin is not<br> merely optional decoration. As with MCP Apps: do not attach a broad <code>Domain=</code><br> cookie to a parent domain shared by the host and sandbox, and if<br> <code>content_security_policy</code> is custom its <code>frame-src</code> must explicitly include the<br> normalized preview origin or the feature drops to <code>degraded</code>.</p> <p>A preview is read-only, confined to one directory subtree, re-authorized<br> against the minting user's access profile on <strong>every</strong> request, and served with<br> <code>connect-src 'self'</code> — the previewed app can fetch its own files and nothing<br> else. The same policy blocks every off-origin subresource, so an app built<br> against a CDN will not load its script, stylesheet or font: that is the point<br> (it is what stops repo bytes leaving through the app), and the overlay's console<br> badge names the refused requests rather than showing a blank page.</p> <p>One exposure is worth knowing, because no <code>Content-Security-Policy</code> closes it:<br> a document can always <strong>navigate itself</strong> away, so a previewed app <em>could</em> put<br> data in a URL and go there. In the overlay the page framing it refuses that<br> navigation — which is why a custom <code>content_security_policy</code> whose <code>frame-src</code><br> is broad (<code>*</code>, a bare <code>https:</code>, or a wildcard host other than<br> <code>wildcard_origin</code>) drops this feature to <code>degraded</code> rather than being<br> accepted. The configured <code>wildcard_origin</code> is the one exception: its domain is<br> answered by this process alone, so a preview that navigates there reaches<br> nothing but a 404 or another preview's capability it would have to guess. The overlay's <strong>Open in new tab</strong> opens<br> the preview with no framing parent and therefore without that refusal; it is<br> labelled accordingly, and a deployment that does not want it can turn the<br> feature off or run without a <code>sandbox_origin</code> (the degraded tier hides the<br> button). See <code>doc/core-dev/design/spa-preview.md</code> §7 for the threat model.</p> <h4 id="apirate_limit"><code>api.rate_limit</code></h4> <p>Budgets are <strong>per client IP per minute</strong>; <code>0</code> drops a rule. Only the paths listed<br> are limited — there is deliberately no blanket cap, which would throttle the<br> SSE stream and the UI's own polling. A refused request gets <code>429</code> with<br> <code>Retry-After</code>.</p> <ul> <li><code>enabled</code>: Master switch (default: <code>true</code>). Turning it off logs a warning and accepts unlimited login attempts.</li> <li><code>login_per_minute</code>: <code>POST /auth/login</code> (default: <code>10</code>).</li> <li><code>refresh_per_minute</code>: <code>POST /auth/refresh</code> (default: <code>30</code>).</li> <li><code>logout_per_minute</code>: <code>POST /auth/logout</code> (default: <code>30</code>) — unauthenticated by design, so that a tab whose access token expired can still log out, and it writes to the token deny-list.</li> <li><code>webhook_per_minute</code>: <code>/ops/webhook/*</code> (default: <code>120</code>) — a monorepo can burst on a force-push.</li> <li><code>ops_per_minute</code>: the rest of <code>/ops/*</code>, e.g. ingest (default: <code>30</code>).</li> <li><code>share_per_minute</code>: <code>/ui/share/*</code> (default: <code>240</code>) — one share view fans out into a file request per image.</li> <li><code>preview_port_per_minute</code>: <code>/_app-preview/p/*</code>, port previews of a dev server (default: <code>3000</code>) — a Vite dev page loads hundreds of unbundled modules, so this replaces <code>preview_per_minute</code> for that prefix.</li> <li><code>preview_per_minute</code>: <code>/_app-preview/*</code> (default: <code>600</code>) — unauthenticated by construction (the capability is in the path), and one page load of a bundled SPA is dozens of asset requests, so this is an order of magnitude above the others. It bounds a flood; it is not meant to pace a preview.</li> <li><code>login_failure_threshold</code> / <code>login_lockout_seconds</code> / <code>login_lockout_max_seconds</code>: Consecutive failed logins tolerated before a lockout starts, and its duration (defaults: <code>5</code>, <code>60</code>, <code>900</code>). Each further failure doubles the wait up to the max; a success clears it. Applied <strong>per username-and-client-IP pair and per client IP</strong>, and checked before the auth provider is called, so a guessing run does not keep costing a live LDAP bind. A username is only locked for the address that failed against it, so nobody can lock an account out for its owner from elsewhere; the client IP is resolved as for the audit log (see <code>trust_forwarded</code>). A locked-out username answers <code>429</code> whether or not the account exists, so this is not an account-existence oracle.</li> <li><code>max_tracked_keys</code>: Ceiling on tracked addresses/usernames (default: <code>20000</code>), so the counters cannot themselves be exhausted by an attacker rotating source addresses.</li> </ul> <p>Two caveats worth knowing. A shared egress IP (corporate NAT) shares a budget —<br> raise the share limits first if that bites, not the login limit, since the<br> failure backoff is what actually stops guessing. And the counters are<br> in-process: a multi-worker deployment divides every budget by the worker count.</p> <h4 id="apibody_limit"><code>api.body_limit</code></h4> <p>Ceilings on the request body for the paths reachable without a session, enforced<br> before the body is buffered (so before any login, signature or ops-key check). A<br> <code>Content-Length</code> above the ceiling is refused with <code>413</code> at once; a chunked body<br> is counted as it arrives and refused with <code>413</code> once it crosses the ceiling.<br> Authenticated routes are not affected; uploads keep their own per-route limits.</p> <ul> <li><code>enabled</code>: Master switch (default: <code>true</code>). Turning it off logs a warning.</li> <li><code>max_bytes</code>: <code>/auth/<em></code>, <code>/ops/</em></code> (other than webhooks) and <code>/ui/share/*</code> (default: <code>1048576</code>, 1 MiB). <code>0</code> = no ceiling.</li> <li><code>webhook_max_bytes</code>: <code>/ops/webhook/*</code> (default: <code>26214400</code>, 25 MiB, GitHub's own delivery cap). Raise it if a source sends larger deliveries. <code>0</code> = no ceiling.</li> </ul> <h3 id="ui"><code>ui</code></h3> <p>Web UI customization:</p> <ul> <li><code>welcome_title</code>: Title shown on the conversation opening page. Can be a plain string (used for all languages) or a locale map.</li> <li><code>welcome_description</code>: Description shown below the title. Same format as <code>welcome_title</code>.</li> <li><code>disabled_extensions</code>: List of plugin IDs whose UI extensions should be hidden (default: <code>[]</code>).</li> </ul> <p>When <code>welcome_title</code> or <code>welcome_description</code> are not set, the built-in translated defaults are used.</p> <p><strong>Plain string (same text for every language):</strong></p> <pre><code class="language-yaml">ui: welcome_title: "Welcome to ACME CodeBot" welcome_description: "Ask questions about our internal services and libraries."</code></pre> <p><strong>Per-locale map (i18n):</strong></p> <pre><code class="language-yaml">ui: welcome_title: en: "Welcome to ACME CodeBot" hu: "Üdvözöl az ACME CodeBot" welcome_description: en: "Ask questions about our internal services and libraries." hu: "Kérdezz a belső szolgáltatásainkról és könyvtárainkról."</code></pre> <p>You can mix the two styles — for example a plain <code>welcome_title</code> with a locale-mapped <code>welcome_description</code>.</p> <h3 id="auth"><code>auth</code></h3> <p>Authentication configuration for API access:</p> <ul> <li><code>provider</code>: Authentication provider to use. A generated config sets <code>"local"</code> with one env-var-password account; the field's own fallback when no <code>auth</code> block exists at all is <code>"none"</code>.</li> <li><code>"local"</code>: Username/password users defined directly in config (the shipped default)</li> <li><code>"gitea"</code>: Use Gitea personal access tokens for authentication</li> <li><code>"ldap"</code>: Use LDAP/Active Directory for authentication</li> <li><code>"none"</code>: No authentication required. Refused on any bind address other than loopback unless <code>allow_unauthenticated_network_access</code> is set — see <a href="authentication.html#no-authentication-provider-none">Authentication</a></li> <li>(<code>"test"</code> exists for the test suite only — never use it in a real deployment)</li> <li><code>ui_provider</code> / <code>api_provider</code>: Optional per-surface overrides. <code>ui_provider</code> takes precedence over <code>provider</code> for the UI; <code>api_provider</code> applies only when <code>api.enable_openai_api</code> is true. If omitted or <code>null</code>, it inherits the resolved UI provider; <code>"none"</code> requests anonymous access. See <a href="authentication.html#overview">Authentication</a>.</li> <li><code>jwt_secret</code>: Deployment-wide secret that signs persistent login sessions <strong>and</strong> seeds at-rest encryption for the <code>user_secrets</code> / <code>model_profiles</code> / <code>oauth</code> stores. Read it from an env var (<code>"${CODUMENTOR_JWT_SECRET}"</code>). A user-home install with that variable unset generates <code>$CODUMENTOR_HOME/jwt_secret</code> on first start and uses it immediately. A project config does not: the placeholder is dropped with a loud error, sessions become ephemeral, and those stores are written <strong>unencrypted</strong>. See <a href="authentication.html#session-persistence-and-at-rest-encryption-jwt_secret">Authentication → jwt_secret</a>.</li> <li><code>issuer</code>: <code>iss</code> claim minted into this instance's tokens and required of every token it validates (default: unset = not checked). Set a distinct value per instance when several instances share a <code>jwt_secret</code> — on one host they also share a cookie jar, since cookies are not scoped by port, and a sibling's session would otherwise authenticate here and then silently degrade to the restricted access profile. Enabling it logs everyone out once. See <a href="authentication.html#several-instances-on-one-host-issuer">Authentication → issuer</a>.</li> <li><code>session_lifetime_days</code>: How long a browser stays signed in without being used (default: <code>7</code>). Each use renews the session, so someone who opens the app at least that often is never asked to log in again; the setting bounds an idle session — and how long a stolen session cookie stays usable if nobody logs out. Fractions work (<code>0.5</code> = 12 hours). The access token inside the session stays at 8 hours, or the session lifetime if shorter. Takes effect for sessions started or renewed after a restart.</li> <li><code>none.default_roles</code>: Roles granted to the anonymous user when <code>provider: none</code> (default: <code>["user"]</code>).</li> <li><code>cookie_secure</code>: Force the session cookie's <code>Secure</code> flag (default: unset = auto). Auto means <code>Secure</code> is set when the request arrived over HTTPS or <code>api.external_url</code> is an <code>https://</code> URL. Set <code>true</code> to require HTTPS unconditionally; <code>false</code> only for a deliberately plain-HTTP deployment.</li> <li><code>cookie_samesite</code>: <code>SameSite</code> policy for the session cookie (default: <code>"lax"</code>). <code>lax</code> keeps cross-site requests from carrying the session. Unsafe-method requests from another host or site are also refused by <code>Origin</code>/<code>Sec-Fetch-Site</code> (see <a href="authentication.html#session-cookies-and-cross-site-requests">Authentication → cookies and cross-site requests</a>); do not move to <code>"none"</code> without a reason.</li> </ul> <blockquote><p>A browser login sets <strong>two</strong> cookies, both <code>HttpOnly</code>, and both covered by the<br> settings above: <code>codumentor_session</code> (the access token) and<br> <code>codumentor_refresh</code> (the refresh token, <code>SameSite=strict</code>; scoped to<br> <code>Path=/auth/refresh</code> over plain HTTP). Over HTTPS both names carry the<br> <code>__Host-</code> prefix (<code>Path=/</code>, no <code>Domain</code>). Neither token is ever returned in a response body to<br> the browser, so no script — including an injected one — can read or exfiltrate<br> a session. Programmatic clients are unaffected: they still get tokens in the<br> body of <code>POST /auth/login</code> and send them back as<br> <code>Authorization: Bearer <jwt></code>. With <code>issuer</code> set, both cookie names get the<br> issuer as a suffix (<code>codumentor_session_<issuer></code>), so instances on one host<br> keep separate sessions.</p></blockquote> <blockquote><p>The configured provider is the <strong>only</strong> one that can serve an interactive<br> login: <code>POST /auth/login</code> refuses a caller-supplied <code>provider</code>, and<br> <code>GET /auth/providers</code> lists only that provider. A provider named in config<br> whose configuration block is missing is a startup error rather than a silent<br> fallback to unauthenticated access.</p></blockquote> <blockquote><p><strong>Sessions are revocable.</strong> Logging out invalidates both tokens server-side,<br> refreshing invalidates the token it consumed, and deactivating a user (or<br> taking a role away) invalidates everything they hold — so those are real events<br> rather than client-side gestures, and a copied token stops working. Revocations<br> live in <code>data/auth/revoked_tokens.db</code> so a restart cannot resurrect a<br> logged-out session; entries are purged automatically once the token they name<br> has expired anyway. No configuration; see<br> <code>doc/security/session-credentials.md</code> §6.</p></blockquote> <p>See the <a href="authentication.html">Authentication</a> guide for the full per-provider reference.</p> <h4 id="gitea-provider">Gitea Provider</h4> <ul> <li><code>gitea.base_url</code>: Base URL for Gitea instance (required when provider is "gitea")</li> <li><code>gitea.token_cache_ttl_minutes</code>: Token validation cache TTL in minutes (default: 30)</li> <li>Caches successful validations to reduce Gitea API calls</li> <li>Set to <code>0</code> to disable caching</li> <li>Recommended range: 15-120 minutes for production use</li> <li><strong>Security Note</strong>: Only valid tokens are cached; invalid tokens are never cached</li> </ul> <h4 id="local-provider">Local Provider</h4> <p>A fixed set of username/password users defined in config. The simplest way to give a small team real logins without Gitea or LDAP:</p> <pre><code class="language-yaml">auth: provider: local jwt_secret: "${CODUMENTOR_JWT_SECRET}" # keep persistent sessions across restarts local: users: - username: admin password: "${CODUMENTOR_ADMIN_PASSWORD}" # plaintext or pbkdf2_sha256$ hash email: admin@example.com roles: ["admin", "user", "power_user"] - username: dev password: "${CODUMENTOR_DEV_PASSWORD}" roles: ["user"]</code></pre> <p>Each entry takes <code>username</code> (required, unique), <code>password</code> (required — plaintext or a <code>pbkdf2_sha256$...</code> hash, <code>${ENV_VAR}</code> substitution supported), and optional <code>email</code>, <code>display_name</code>, and <code>roles</code> (default <code>["user"]</code>). Generate a hash with <code>python -c "from codumentor.auth.providers.local import hash_password; print(hash_password('s3cret'))"</code>. See <a href="authentication.html#local-provider-local">Authentication → Local</a> for details.</p> <h4 id="ldap-provider">LDAP Provider</h4> <p>For enterprise environments using LDAP or Active Directory:</p> <pre><code class="language-yaml">auth: provider: ldap ldap: # Connection settings (required) server_url: "ldaps://ldap.example.com" # or ldap:// for non-SSL bind_dn: "cn=service,dc=example,dc=com" bind_password: "${LDAP_BIND_PASSWORD}" base_dn: "dc=example,dc=com" # Server type: "active_directory", "openldap", or "generic" server_type: "openldap" # Security: "ldaps" (SSL), "starttls", or "none" security_mode: "ldaps" # User search settings user_search_filter: "(&(objectClass=inetOrgPerson)(uid={username}))" user_search_base: "ou=users,dc=example,dc=com" # defaults to base_dn username_attribute: "uid" # "sAMAccountName" for AD email_attribute: "mail" display_name_attribute: "displayName" # Group settings (for role mapping) group_search_base: "ou=groups,dc=example,dc=com" group_member_attribute: "memberOf" # Role mapping: LDAP groups → Codumentor roles group_role_mapping: "cn=admins,ou=groups,dc=example,dc=com": ["admin"] "cn=developers,ou=groups,dc=example,dc=com": ["developer"] default_roles: ["user"] # Optional: require membership in a specific group require_group: "cn=codumentor-users,ou=groups,dc=example,dc=com" # SSL certificate validation validate_cert: true ca_cert_file: "/path/to/ca-cert.pem" # optional</code></pre> <p><strong>Active Directory defaults</strong> (when <code>server_type: active_directory</code>):</p> <ul> <li><code>user_search_filter</code>: <code>(&(objectClass=user)(sAMAccountName={username}))</code></li> <li><code>username_attribute</code>: <code>sAMAccountName</code></li> <li><code>group_search_filter</code>: Uses AD's nested group resolution</li> </ul> <p><strong>OpenLDAP defaults</strong> (when <code>server_type: openldap</code>):</p> <ul> <li><code>user_search_filter</code>: <code>(&(objectClass=inetOrgPerson)(uid={username}))</code></li> <li><code>username_attribute</code>: <code>uid</code></li> <li>Nested group resolution disabled by default</li> </ul> <p><strong>Multiple LDAP directories.</strong> Replace the <code>ldap:</code> block with a list under<br> <code>ldap_directories:</code> to authenticate against several independent directories.<br> Each entry takes the full set of LDAP options shown above plus a unique<br> <code>name</code>. On login the directories are tried in declared order; the first<br> successful bind wins. See <a href="authentication.html#multiple-ldap-directories">Authentication</a><br> for the routing rules, identity behaviour, and audit-log labelling.</p> <pre><code class="language-yaml">auth: provider: ldap ldap_directories: - name: corp server_url: "ldaps://corp.example.com" # ... full LDAP options ... - name: contractors server_url: "ldaps://contractors.example.com" # ... full LDAP options ...</code></pre> <h3 id="prompt"><code>prompt</code></h3> <p>Prompt/template system configuration (see Prompt System for the full reference):</p> <ul> <li><code>template_dir</code>: Directory containing prompt template files (default: "prompts"). Override at runtime with <code>--prompt-dir</code>.</li> <li><code>system_prompt_template</code>: System prompt template file (default: "system_prompt.jinja2")</li> <li><code>max_iterations_notification_template</code>: Template for max iterations notification (default: "max_iterations_notification.jinja2")</li> <li><code>custom_instructions</code>: Additional custom instructions to include in prompts</li> <li><code>debug_mode</code>: Whether to enable debug mode for prompt templates (default: false)</li> <li><code>show_tool_calls</code>: Whether to show tool call descriptions in the output stream for both main and subagents (default: true). When true, tool calls will be shown to the user on the API.</li> </ul> <h3 id="tools-1"><code>tools</code></h3> <p>Tool-specific configuration:</p> <ul> <li><code>shell_output_max_size</code>: Maximum size (in bytes) for shell command output (default: 10240)</li> <li><code>file_listing_max_size</code>: Maximum size (in bytes) for file listings (default: 10240)</li> <li><code>shell_timeout</code>: Timeout in seconds for shell command execution (default: 900)</li> <li><code>shell_always_allow</code>: <strong>Deprecated</strong>, a shim for the operator allow rule <code>Shell</code> — see <a href="#permissions"><code>permissions</code></a> (default: false)</li> <li><code>disable_vector_search</code>: Whether to disable vector database search functionality (default: false)</li> <li><code>search_concurrency</code>: Maximum number of per-repository searches to run in parallel (default: 5)</li> </ul> <p>When <code>disable_vector_search</code> is set to <code>true</code>, the agent will not use the vector database for semantic search, relying instead on other methods like file reading and shell commands to find information.</p> <h3 id="background_agents"><code>background_agents</code></h3> <p>Background work and how it reports back. A background shell job, a one-off<br> task run started from a conversation, or a subagent run in the background<br> keeps going after the turn that started it; when it finishes, the result<br> reaches the conversation's agent. If no turn is running, the conversation<br> <strong>wakes</strong>: the agent gets an automated turn, shown in the transcript as a<br> card rather than a message from the user, and answers like any other turn<br> (a Telegram/Slack-bound conversation gets that answer as a reply). Every key<br> applies from the next spawn or delivery after a config reload.</p> <pre><code class="language-yaml">background_agents: max_per_conversation: 3 # background agents running at once in one conversation max_per_user: 10 # ... for one user, across conversations wake: true # wake an idle conversation when results arrive max_automated_wakes: 10 # automated turns in a row without a message from the user wake_coalesce_seconds: 2.0 # results within this window become one wake</code></pre> <ul> <li><code>wake: false</code> leaves results for the user's next message, as before. An access profile can turn it off for its users (<code>access.profiles.<name>.background_wake</code>); mediated profiles and scheduled-run conversations never wake.</li> <li>After <code>max_automated_wakes</code> wakes in a row with no message from the user, results wait for the user; the UI shows how many are waiting. Any message from the user (or steered into a running turn) starts the count again. <code>0</code> never wakes.</li> <li>A wake turn counts against <code>api.max_concurrent_turns_per_user</code>; when the user is at the limit, it waits for a slot.</li> <li>A message sent while a wake turn runs is steered into that turn rather than starting a second one.</li> <li>The agent manages its background agents with <code>bg_list</code>, <code>bg_wait</code>, <code>bg_kill</code> (which also stops the shell jobs the agent's subagents started) and <code>send_message</code> (instructions to a running agent, or a follow-up task for a finished one). They come with <code>agent.enable_subagents</code>, also when <code>background_processes.enabled</code> is off.</li> </ul> <h3 id="tasks"><code>tasks</code></h3> <p>Controls the task engine — the component that fires recurring and one-off jobs onto the job queue (scheduled agent runs, periodic reports, ingestion refresh, etc.).</p> <p>The task engine shares its SQLite file with the job queue (<code>jobs.sqlite3</code> by default, overridable via <code>CODUMENTOR_JOBS_DB_PATH</code>). WAL is enabled automatically.</p> <pre><code class="language-yaml">tasks: enabled: true idle_poll_interval: 30.0 # max seconds between loop ticks when idle disable_after_failures: 5 # consecutive infra failures before auto-disable max_catchup_age: 86400.0 # 24h — skip fires older than this max_tasks_per_user: 1000 min_cron_interval_seconds: 0 # floor between fires of a user's cron task; 0 = none default_timezone: "UTC" max_chain_depth: 3 # event triggers: how deep a causal chain may go max_fires_per_minute: 60 # event triggers: instance-wide circuit breaker event_retention_days: 30 # event triggers: how long the event ledger keeps a row allow_agent_created: true # may an agent create tasks from a conversation? # default_run_token_budget: 200000 # per-run token cap; unset = unlimited # default_webhook_run_token_budget: 100000 # same, for webhook-fired runs # max_run_token_budget: 2000000 # ceiling on any per-run budget permission_mode: bypassPermissions # what an unattended turn may do</code></pre> <table> <thead> <tr><th>Field</th><th>Type</th><th>Default</th><th>Description</th></tr> </thead> <tbody> <tr><td><code>enabled</code></td><td>bool</td><td><code>true</code></td><td>Master switch. When <code>false</code>, the task engine loop never starts and <code>schedule_*</code> operations will fail. Existing tasks remain in the DB.</td></tr> <tr><td><code>idle_poll_interval</code></td><td>float</td><td><code>30.0</code></td><td>Maximum seconds the loop sleeps between ticks when no fires are imminent. Lowering this costs a bit more DB I/O; raising it delays reaction to newly-created tasks up to this bound.</td></tr> <tr><td><code>disable_after_failures</code></td><td>int</td><td><code>5</code></td><td>After this many consecutive <em>infrastructure</em> failures (e.g. <code>database is locked</code> on enqueue), the task is auto-disabled and its <code>status</code> becomes <code>disabled</code>. Handler exceptions do <strong>not</strong> count — they mark the fired <em>job</em> failed, not the task.</td></tr> <tr><td><code>max_catchup_age</code></td><td>float</td><td><code>86400.0</code></td><td>If the task engine has been offline and a scheduled fire is older than this many seconds, skip it silently and jump to the next occurrence. Prevents firing a week-long backlog of stale runs after an outage.</td></tr> <tr><td><code>max_tasks_per_user</code></td><td>int</td><td><code>1000</code></td><td>Cap on active+paused tasks per <code>owner_user_id</code>. Protects against unbounded growth if users can create tasks interactively.</td></tr> <tr><td><code>min_cron_interval_seconds</code></td><td>int</td><td><code>0</code></td><td>Shortest gap allowed between two fires of a cron task a user (or their agent) creates or reschedules; a busier expression is refused with the reason. <code>0</code> = no floor (every-minute schedules are valid). Tasks declared in this config are exempt. Set e.g. <code>300</code> on a shared instance to stop one account filling the run queue with every-minute agent runs; existing tasks keep running, the floor applies when a task is created or its schedule changed.</td></tr> <tr><td><code>default_timezone</code></td><td>str</td><td><code>"UTC"</code></td><td>Default IANA timezone for tasks that don't specify one.</td></tr> <tr><td><code>max_chain_depth</code></td><td>int</td><td><code>3</code></td><td><strong>Event triggers.</strong> How many hops a causal chain of events may fire before the router refuses. An event arriving from outside (a webhook, an ingestion) is depth 0, and events a run emits are depth+1, so this bounds <em>any</em> cycle at this many fires whatever its shape — A fires B fires A included. A refused fire records a <code>skipped</code> run row with reason <code>chain_depth</code> and logs a WARNING carrying the <code>chain_id</code>, so the whole chain is one <code>list_events(chain_id=...)</code> query. A task may narrow this for itself; it cannot widen it.</td></tr> <tr><td><code>max_fires_per_minute</code></td><td>int</td><td><code>60</code></td><td><strong>Event triggers.</strong> Instance-wide circuit breaker across all tasks. Tripping it is logged at ERROR, not WARNING: at this rate something is wrong, not busy. Coalesced events do not each count — a burst that merges into one pending run is charged once. <code>0</code> (or negative) disables the breaker; to stop event tasks firing at all, pause them or set <code>enabled: false</code>.</td></tr> <tr><td><code>event_retention_days</code></td><td>int</td><td><code>30</code></td><td><strong>Event triggers.</strong> How long the event ledger keeps an event row, purged by the <code>task_runtime</code> maintenance sweep (the same daily loop that ages out run history). The capped, debug-only raw webhook body is nulled far sooner — 48h — because it is the bulky part and stops being interesting first. <code>0</code> keeps events forever.</td></tr> <tr><td><code>allow_agent_created</code></td><td>bool</td><td><code>true</code></td><td>Whether the agent-callable <code>create_task</code> tool may create tasks. Set <code>false</code> to make automation an operator-only act: the tool stays visible and refuses with a reason (so the model is told no rather than inventing a workaround), the task engine keeps running, and user- or config-created tasks are untouched. Independent of the trust boundary — an agent may never create a task firing on a webhook-sourced event type (<code>repo.<em></code>, <code>scm.</em></code>, <code>webhook.*</code>) whatever this says, because an outside party would then influence both whether an unattended turn runs and what text is in its prompt. See triggers §12.1.</td></tr> <tr><td><code>default_run_token_budget</code></td><td>int</td><td>unset</td><td>Token budget a scheduled/event run gets when its task (or goal worker) sets none. Counts every token sent to or received from the model, <strong>including cached prompt tokens</strong>. A run that spends it stops at the next step boundary and is recorded <code>failed</code> with <code>error_kind: token_budget</code> (counts toward a goal worker's auto-disable like a timeout). Unset = unlimited. Minimum <code>10000</code> (the base prompt alone is several thousand tokens); a smaller value is lifted to <code>10000</code> with a warning.</td></tr> <tr><td><code>default_webhook_run_token_budget</code></td><td>int</td><td>unset</td><td>Same, for runs fired by a webhook-sourced event (<code>repo.<em></code>, <code>scm.</em></code>, <code>webhook.*</code>); takes precedence over <code>default_run_token_budget</code> for those runs. Precedence for one run: the task's own <code>token_budget</code> > this (webhook-fired runs) > <code>default_run_token_budget</code> > unlimited.</td></tr> <tr><td><code>max_run_token_budget</code></td><td>int</td><td>unset</td><td>Ceiling applied to whichever budget wins above, agent- and user-set ones included (like the 6h ceiling on <code>timeout_seconds</code>). Unset = no ceiling; it never turns an unlimited run into a limited one. Minimum <code>10000</code>, like the other two.</td></tr> <tr><td><code>permission_mode</code></td><td>str</td><td><code>"bypassPermissions"</code></td><td>The approvals mode an <strong>unattended</strong> turn runs in — a scheduled run or a Gitea webhook turn. See below.</td></tr> </tbody> </table> <p><strong>Unattended approvals.</strong> A scheduled or webhook turn has nobody to answer a<br> permission prompt, so it does not use the conversation's or the user's mode; it<br> uses this one. The default, <code>bypassPermissions</code>, is the behaviour Codumentor has<br> always had: allow everything the operator's deny rules do not refuse.</p> <p><code>auto</code> runs the same triage an interactive Auto conversation gets — the<br> deterministic analyser, then the judge — and because there is nobody to ask,<br> <strong>a call that would have prompted is denied instead</strong>. The refusal names the<br> command, the analyser's flags, the judge's note and the agent's own reason, and<br> goes three places: the tool result the model reads (so the run's final message<br> can say what it could not do), the transcript card, and the durable audit row<br> (<code>decided_by = unattended</code>). The model is told, keeps going, and the run ends<br> with a report rather than a hang. <code>plan</code> makes unattended turns read-only.<br> <code>default</code> and <code>acceptEdits</code> degrade the same way as <code>auto</code> but without the<br> triage, which makes them strict-deny modes rather than useful ones.</p> <p><strong>Per-run token budgets.</strong> A budget bounds one unattended run's spend the way<br> <code>timeout_seconds</code> bounds its wall time. It is set per task (<code>create_task</code> /<br> <code>update_task</code> <code>token_budget</code>), per goal worker (<code>token_budget</code> in its<br> <code>definition.yaml</code>, <code>update_worker</code>, the worker edit form), per declared task<br> (<code>run.token_budget</code>), or falls back to the defaults above. The effective value<br> is resolved once when the run starts and stored on the run row, so run history<br> shows the limit each run actually had. What is counted and when it stops:</p> <ul> <li><strong>Agent tokens only.</strong> Every LLM call of the run's main loop and of its subagents (they share the run's ledger), plus the tokens an external agent (<code>external_agent</code> tools) reports for its call. Auxiliary calls are <strong>not</strong> counted: auto title, turn summaries, memory recall, the Auto-mode and script-filter judges, context compaction, the merge resolver.</li> <li><strong>Cached input counts fully.</strong> The unit is total input (cache reads and writes included) plus output — it is a runaway guard, not a bill. A call whose provider reports no usage is charged its estimate.</li> <li><strong>Stops at a step boundary.</strong> The check runs at the top of each agent-loop iteration, so a run can exceed its budget by up to one iteration (one LLM call plus the tool batch it started; each parallel subagent can add one call; an external agent's whole call is charged when it returns). At 80 % the main agent gets a one-time "save your work and conclude" note. The stop ends the turn cleanly (no extra summary call) with a notice in the transcript.</li> <li><strong>Outcome.</strong> <code>status: failed</code>, <code>error_kind: token_budget</code>, error <code>Stopped at its token budget (N of M tokens)</code>. Like a timeout it counts toward <code>disable_after_failures</code> (a goal worker's consecutive-failure auto-disable) and does not satisfy a <code>task.run_finished … status eq success</code> chain.</li> <li><strong>Approvals.</strong> A run whose turn suspends on an approval keeps its budget across the resume: the run stays <code>running</code> and is finished by the resumed turn. An approval left unanswered past the <code>task_runtime</code> plugin's <code>parked_run_ttl_seconds</code> (default 7 days) ends the run <code>failed</code> / <code>stale</code>.</li> <li><strong>Restarts.</strong> The ledger is in memory. A server restart loses the tokens a run spent while it was still running. A run waiting on an approval keeps the tokens it had spent so far, but cannot be resumed after a restart: it ends <code>failed</code> / <code>stale</code>, and answering its approval later does not continue the turn.</li> </ul> <p>Every run (budgeted or not) records input, cached, cache-write, output and<br> total tokens on its run row; the run card and the goals run panel show them,<br> with the budget and % used. Cost reads <code>unknown</code> for a model without a price<br> (never <code>$0</code>); a total mixing priced and unpriced models is a lower bound.<br> Design: run-token-budgets.</p> <p><strong>Event triggers.</strong> The three <code>max_chain_depth</code> / <code>max_fires_per_minute</code> / <code>event_retention_days</code> fields govern event-driven tasks (<code>on: repo.ingested</code>, <code>on: task.run_finished</code>, …) rather than clock-driven ones; they are inert on an instance with no event tasks. Per-task caps (<code>debounce_seconds</code>, <code>max_delay_seconds</code>, <code>max_fires_per_hour</code>, <code>allow_self</code>) live on the task itself. See triggers §11.</p> <h4 id="tasksdeclared-operator-declared-event-tasks"><code>tasks.declared</code> — operator-declared event tasks</h4> <p>A list of tasks the <em>config file</em> owns. They are reconciled against the running<br> task engine at startup and on every <code>tasks:</code> reload: entries are created,<br> updated and cancelled to match the list, and nothing a user or an agent created<br> is touched.</p> <p>This is also the <strong>only</strong> surface allowed to declare a task that fires on a<br> webhook-sourced event type (<code>repo.<em></code>, <code>scm.</em></code>, <code>webhook.*</code>). Such a task lets an<br> outside party decide both <em>whether</em> an unattended, tool-auto-approving turn runs<br> and <em>what text is in its prompt</em>, which is an operator decision rather than a<br> conversational one — so it is refused to an agent whatever <code>allow_agent_created</code><br> says, and it is refused here without an <code>access_profile</code>. See<br> triggers §12.1 and §12.4.</p> <blockquote><p><strong>Quote the <code>on:</code> key.</strong> PyYAML implements YAML <strong>1.1</strong>, whose booleans are<br> <code>y|yes|n|no|true|false|on|off</code>, so a bare <code>on:</code> parses as the boolean <code>True</code><br> and the entry never sees the field it is named after. Write <code>"on":</code>. The<br> entry is <strong>refused</strong> with a message spelling out the fix rather than quietly<br> repaired — accepting the boolean key would make <code>on:</code> work here and nowhere<br> else you might expect symmetry.</p></blockquote> <pre><code class="language-yaml">tasks: declared: - name: review-on-pr "on": scm.pull_request # note the quotes scope: my-repo # optional: the event's scope_key when: - [action, in, [opened, synchronize]] mode: per_event on_overlap: queue access_profile: pr-reviewer run_as: review-bot # optional: a real account to run as description: Review a pull request when it opens or gets new commits. run: prompt: | Review pull request #${event.pr.number} in ${event.repo}. Title: ${event.pr.title} timeout_seconds: 1800</code></pre> <table> <thead> <tr><th>Field</th><th>Required</th><th>Description</th></tr> </thead> <tbody> <tr><td><code>name</code></td><td>yes</td><td><strong>The reconciliation key.</strong> See the semantics below. Also shown on the run card.</td></tr> <tr><td><code>"on"</code></td><td>yes</td><td>The event type to fire on. A typo is refused at load: for <code>plugin.*</code> types the plugin's declared <code>emits</code> vocabulary is checked too. Use the <code>list_event_types</code> tool to see the vocabulary and what each event carries.</td></tr> <tr><td><code>run.prompt</code></td><td>yes</td><td>The turn's instruction text. May carry <code>${event.<path>}</code> placeholders.</td></tr> <tr><td><code>run.timeout_seconds</code></td><td>no</td><td>Wall-clock cap on the fired job. Omitted leaves the queue's own per-queue default in force.</td></tr> <tr><td><code>run.token_budget</code></td><td>no</td><td>Token cap on the fired run (see <code>default_run_token_budget</code>). Omitted falls back to <code>default_webhook_run_token_budget</code> / <code>default_run_token_budget</code>; clamped to <code>max_run_token_budget</code>.</td></tr> <tr><td><code>access_profile</code></td><td>conditional</td><td><strong>Required</strong> for a webhook-sourced <code>on:</code>; a config error without one. Never event-chosen.</td></tr> <tr><td><code>run_as</code></td><td>no</td><td>The <strong>run identity</strong>: it becomes <code>job_args["user_id"]</code>, which is the account the turn executes as and what per-user secrets are keyed on — so a declared task that must call a tool holding a personal access token needs it. Read only from this file and <strong>never</strong> derived from an event, so an outside party cannot choose the identity its trigger runs as. A <code>system:*</code> principal is refused (nothing can log in as one, so there is no credential to borrow), and the id is vetted against the same creation ceiling a task creation faces. Omitted, the run executes as <code>system:config</code>, which holds no per-user secrets. The task <strong>row's</strong> <code>owner_user_id</code> stays <code>system:config</code> either way — that is what reconciliation uses to tell its own rows from a user's.</td></tr> <tr><td><code>scope</code></td><td>no</td><td>Cheap indexed narrowing — a repo name, a goal id.</td></tr> <tr><td><code>when</code></td><td>no</td><td><code>[path, op, value]</code> clauses, <strong>ANDed</strong>, evaluated over the normalized payload. "Either/or" is spelled as two entries.</td></tr> <tr><td><code>mode</code></td><td>no</td><td><code>coalesce</code> (default) merges a burst into one run; <code>per_event</code> runs once per event.</td></tr> <tr><td><code>enabled</code></td><td>no</td><td><code>false</code> reconciles the task to <code>cancelled</code> while leaving the lines in the file to document what it was — the same terminal state as deleting the entry, and the entry is not validated either (turning a task off must not first require fixing it).</td></tr> <tr><td><code>description</code></td><td>no</td><td>Free text, stored on the row.</td></tr> <tr><td><code>metadata</code></td><td>no</td><td>Extra task metadata. Keys carrying run identity, job routing or engine-stamped provenance are <strong>refused</strong>, not stripped — a declaration free to write <code>task_id</code> would be a forgeable audit trail. <code>access_profile</code> and the timeout have their own fields.</td></tr> <tr><td><code>bind</code></td><td>no</td><td>Explicit <code>${event.<path>}</code> → <code>job_args</code> bindings. Rarely needed: placeholders in <code>run.prompt</code> are compiled into this automatically.</td></tr> <tr><td><code>job_type</code></td><td>no</td><td>Defaults to <code>agent_task_run</code>; <code>repo_ingest</code> is the only other accepted value.</td></tr> <tr><td><code>target_queue</code></td><td>no</td><td>Defaults to <code>agent_runs</code>.</td></tr> <tr><td><code>on_overlap</code></td><td>no</td><td><code>skip</code> (default), <code>queue</code> or <code>cancel_previous</code>.</td></tr> <tr><td><code>debounce_seconds</code></td><td>no</td><td><code>coalesce</code> window. Default <code>30.0</code>; <code>0</code> fires on the next loop tick.</td></tr> <tr><td><code>max_delay_seconds</code></td><td>no</td><td>Cap on debounce extension, measured from the first event of the burst. Default <code>300.0</code>, and never below <code>debounce_seconds</code>.</td></tr> <tr><td><code>max_in_flight</code></td><td>no</td><td>How many of this task's jobs may be pending or running at once. Default <code>3</code>.</td></tr> <tr><td><code>max_fires_per_hour</code></td><td>no</td><td>Per-task storm cap. Default <code>12</code>. Three times the cap in <em>routing attempts</em> within an hour auto-pauses the task.</td></tr> <tr><td><code>allow_self</code></td><td>no</td><td>Whether an event caused by this very task's own run may fire it again. Default <code>false</code>.</td></tr> <tr><td><code>max_chain_depth</code></td><td>no</td><td>Narrows <code>tasks.max_chain_depth</code> for this task. It can never widen it.</td></tr> </tbody> </table> <p>An unknown key in an entry is <strong>refused</strong>, not ignored: a mistyped line in a<br> declaration that decides whether an unattended, tool-auto-approving turn runs<br> must not be silently dropped. Two entries sharing a <code>name</code> are refused for the<br> same reason rather than resolved last-one-wins — the name is the key, so one of<br> them would silently not exist.</p> <p><strong>Reconciliation semantics.</strong> <code>name</code> is the key, and everything follows from<br> that:</p> <table> <thead> <tr><th>You do</th><th>Reconciliation does</th></tr> </thead> <tbody> <tr><td>Add an entry</td><td>Creates the row.</td></tr> <tr><td>Change an entry</td><td>Updates the row <strong>in place</strong>, keeping its id and run history. Changing the <em>firing spec</em> discards any pending arming (it was matched against a spec that no longer applies); changing <code>job_type</code> or <code>target_queue</code> cannot be updated in place and is a delete plus a create.</td></tr> <tr><td>Remove an entry, or set <code>enabled: false</code></td><td><strong>Cancels</strong> the row — it is not deleted. The history stays visible, and an in-flight run is left to finish exactly as your own cancel would leave it.</td></tr> <tr><td>Rename an entry</td><td><strong>Delete plus create.</strong> There is no rename detection and deliberately none: two entries that swapped names could only be matched by guessing. The old name's row is cancelled and the new name gets a fresh one, with no history carried over.</td></tr> <tr><td>Re-add a name you removed</td><td>Deletes the cancelled tombstone and creates fresh, so a remove/re-add cycle cannot accumulate one row per cycle.</td></tr> <tr><td>Pause a declared task, or let <code>disable_after_failures</code> disable it</td><td>Nothing. Reconciliation decides a task's <em>existence and shape</em>, never its activity — a paused declared task stays paused across edits and restarts, and is resumed with <code>resume_task</code>.</td></tr> </tbody> </table> <p><strong>A bad entry costs different things at different times.</strong> At <strong>startup</strong> each<br> entry is compiled independently: one that fails is logged at ERROR and skipped,<br> and its existing row is left <em>alone</em> rather than cancelled, so a typo<br> introduced while editing one task cannot delete a different one. On <strong>reload</strong><br> a <code>tasks:</code> edit is <strong>all-or-nothing</strong>: any compile error rolls the whole<br> section back to the last list that validated, re-reconciles against that, and<br> reports the section as failed.</p> <p><strong>Reloading.</strong> <code>tasks:</code> is REBUILD-classified, so editing <code>declared:</code> takes<br> effect on the next reload without a restart (<code>SIGHUP</code>, the admin endpoint, or<br> the <code>auto_reload</code> watcher). The caps in the same section are read live off the<br> config object. <code>tasks.enabled</code> is the exception — it is read once at startup,<br> and a reload that changes it raises a "restart required" caveat.</p> <p><strong>What ships by default.</strong> The default config carries three entries:<br> <code>ingest-on-push</code> (the built-in ingestion task — see<br> <a href="webhooks.html#ingestion-is-a-task">Webhooks</a>), and <code>gitea-review-on-pr</code> /<br> <code>gitea-review-on-request</code> (Enterprise Edition, which has the <code>gitea_pr</code> plugin), both <code>enabled: false</code> because a review run posts to a<br> public pull request unattended. Turning those two on means adding the<br> <code>gitea_pr</code> plugin, defining the <code>pr-reviewer</code> access profile they name,<br> creating the <code>gitea-review-bot</code> account their <code>run_as:</code> names (with a<br> <code>gitea_api_token</code> user secret on it), and setting the plugin's<br> <code>auto_post_on_review_comment: true</code> — until that last one an unattended run<br> holds no <code>gitea_*</code> write tool and posts nothing, which makes it a working<br> kill-switch even with the entries enabled; see<br> <a href="../../plugin-dev/en/catalog/gitea_pr.html"><code>gitea_pr</code></a>. The <code>minimal</code>, <code>marketing</code> and<br> <code>root</code> flavor configs carry <code>ingest-on-push</code> alone; <code>investigate</code> declares none<br> and turns the task engine off entirely.</p> <p><strong>Routing.</strong> By default, scheduled fires land on the shared <code>agent_runs</code> job queue. Plugins that need per-user isolation can pass a per-user queue name at task creation (<code>target_queue=f"agent_runs_{user_id}"</code>). Be aware that each distinct queue name spawns its own processor task — don't multiply them casually.</p> <p><strong>Disabling at runtime.</strong> Set <code>enabled: false</code> and restart. Tasks persist in the DB and resume when re-enabled. To stop a single task without touching config, use <code>task_engine.pause(id)</code> or <code>task_engine.cancel(id)</code> from code.</p> <p>See the task engine guide for the plugin-developer view and firing semantics.</p> <h3 id="webhooks"><code>webhooks</code></h3> <p>Push-notification webhook endpoint — lets Gitea/GitHub trigger ingestion automatically. See <a href="webhooks.html">Webhooks</a> for full setup.</p> <ul> <li><code>enabled</code>: Master switch. When <code>false</code> (default) the endpoint returns 404.</li> <li><code>secrets</code>: List of accepted shared secrets. The request is accepted if <strong>any</strong> entry matches. Supports environment substitution (<code>${VAR_NAME}</code>) and zero-downtime rotation (add new, remove old). Leaving this empty while <code>enabled: true</code> returns 503.</li> </ul> <pre><code class="language-yaml">webhooks: enabled: true secrets: - "${CODUMENTOR_WEBHOOK_SECRET}" - "${CODUMENTOR_WEBHOOK_SECRET_PREVIOUS}"</code></pre> <h3 id="updates"><code>updates</code></h3> <p>The in-app updater of an installed (<code>.run</code>) build. <code>codumentor update</code> checks the signed update channel and stages a newer version; <code>--apply</code> makes it the version the next start runs, and <code>--rollback</code> goes back to the previous one on disk.</p> <ul> <li><code>mode</code>: <code>auto</code>, <code>advisory</code> or <code>off</code>. It can only lower what the install supports: a container, a root-owned <code>/opt</code> install or a source checkout never replaces its own program, whatever this says. Unset: <code>auto</code> for the community edition, <code>advisory</code> (report only) otherwise.</li> <li><code>channel</code>: Release channel (default <code>stable</code>).</li> <li><code>base_url</code>: The update server, <code>https://</code> only.</li> <li><code>token</code>: Download token for a token-gated channel. Supports <code>${VAR_NAME}</code>.</li> <li><code>keep_versions</code>: Version directories kept on disk, at least 2 (the running one and the rollback target).</li> <li><code>check_interval</code>: How often the background check runs, as <code><count><unit></code> with unit <code>m</code>, <code>h</code> or <code>d</code> (default <code>24h</code>).</li> </ul> <p>Air-gapped installs set <code>mode: off</code> and update from copied channel files: <code>codumentor update --from latest.json --apply</code> (the payload next to it; its signature is checked exactly as online).</p> <p>Changes to <code>updates</code> take effect on the next start; they are not hot-reloaded. Install modes, the <code>update</code> command, data snapshots and rollback are described in <a href="updates.html">Updates</a>.</p> <pre><code class="language-yaml">updates: mode: advisory token: "${CODUMENTOR_UPDATES_TOKEN}"</code></pre> <h3 id="logging"><code>logging</code></h3> <p>Logging configuration:</p> <ul> <li><code>level</code>: Base log level (default: "INFO")</li> <li><code>file</code>: Log file path (default: "./logs/codumentor.log")</li> <li><code>logger_levels</code>: Logger-specific log levels that override the base level</li> <li><code>console</code>: Optional boolean. If set, controls whether log lines are also written to <strong>standard error</strong> in every mode (API server, CLI, TUI). If omitted, Codumentor chooses a default: the <strong>API</strong> process logs to stderr as well as the log file; <strong>CLI and TUI</strong> log <strong>only to the file</strong> so stdout/stderr stay free for command output and the terminal UI. Set <code>console: true</code> to mirror API-style logging during local CLI/TUI runs, or <code>console: false</code> to keep API logs file-only (for example when a process manager already tails the log file).</li> </ul> <p><strong>Built-in log rotation.</strong> Codumentor can rotate the log file itself (a <code>TimedRotatingFileHandler</code>), independent of an external <code>logrotate</code>:</p> <pre><code class="language-yaml">logging: level: INFO file: ./logs/codumentor.log rotation_enabled: true rotation_when: midnight # "midnight", "H" (hourly), "D" (daily), "W0".."W6", "S", "M" rotation_interval: 1 # rotate every N of the above unit rotation_backup_count: 30 # keep this many rotated files rotation_utc: true # compute rollover times in UTC</code></pre> <table> <thead> <tr><th>Field</th><th>Default</th><th>Description</th></tr> </thead> <tbody> <tr><td><code>rotation_enabled</code></td><td><code>false</code></td><td>Enable timed rotation of the log file.</td></tr> <tr><td><code>rotation_when</code></td><td><code>"midnight"</code></td><td>Rollover unit (Python <code>TimedRotatingFileHandler</code> codes).</td></tr> <tr><td><code>rotation_interval</code></td><td><code>1</code></td><td>Number of <code>rotation_when</code> units between rollovers.</td></tr> <tr><td><code>rotation_backup_count</code></td><td><code>30</code></td><td>How many rotated files to retain; older ones are deleted.</td></tr> <tr><td><code>rotation_utc</code></td><td><code>true</code></td><td>Use UTC when deciding rollover boundaries.</td></tr> </tbody> </table> <p><strong>LLM payload tracing.</strong> Full request dumps -- every message and tool schema of every model call -- are written to a separate, non-propagating logger, <code>codumentor.trace.payload</code>, which is <strong>off by default</strong>. The main log gets one summary line per call instead (<code>LLM request (stream): messages=… content_chars=… tools=… tools_digest=…</code>). Enable tracing for a debugging session with <code>trace_payload: true</code>, a <code>logger_levels</code> entry <code>codumentor.trace.payload: DEBUG</code>, or the environment variable <code>CODUMENTOR_TRACE_PAYLOAD=1</code>. The trace goes to its own size-capped file (JSON when <code>json_logging</code> is on):</p> <table> <thead> <tr><th>Field</th><th>Default</th><th>Description</th></tr> </thead> <tbody> <tr><td><code>trace_payload</code></td><td><code>false</code></td><td>Write full LLM request payloads to the trace file.</td></tr> <tr><td><code>trace_file</code></td><td><code><file stem>.trace.log</code></td><td>Trace file path, next to the main log by default.</td></tr> <tr><td><code>trace_max_bytes</code></td><td><code>52428800</code> (50 MB)</td><td>Size at which the trace file rotates.</td></tr> <tr><td><code>trace_backup_count</code></td><td><code>2</code></td><td>Rotated trace files to keep.</td></tr> </tbody> </table> <p><strong>JSON logging</strong> (for ELK/Splunk/Datadog — see also <a href="deployment.html#json-logging">Deployment → JSON Logging</a>):</p> <table> <thead> <tr><th>Field</th><th>Default</th><th>Description</th></tr> </thead> <tbody> <tr><td><code>json_logging</code></td><td><code>false</code></td><td>Emit structured one-line-JSON logs.</td></tr> <tr><td><code>json_log_file</code></td><td><code>null</code></td><td>Separate file for JSON logs. If unset, JSON is written alongside the text log.</td></tr> <tr><td><code>json_include_context</code></td><td><code>true</code></td><td>Include the per-record <code>context</code> dict (session id, etc.).</td></tr> <tr><td><code>json_include_stack_info</code></td><td><code>false</code></td><td>Include stack info on records that carry it.</td></tr> <tr><td><code>json_include_process_info</code></td><td><code>false</code></td><td>Include process/thread identifiers.</td></tr> <tr><td><code>json_date_format</code></td><td><code>null</code></td><td>Override the timestamp format.</td></tr> </tbody> </table> <p>The text file handler (and the JSON handler when enabled) is always configured when a log <code>file</code> path is set.</p> <h3 id="shell-interpreter-on-windows">Shell interpreter on Windows</h3> <p><code>tools.shell_interpreter</code> is read again for each command, so changes apply<br> without a restart. The default is <code>bash</code>; <code>auto</code> also prefers detected bash on<br> Windows. Discovery checks the standard Git-for-Windows locations, the Git<br> location derived from <code>PATH</code>, <code>bash</code> on <code>PATH</code>, per-user and system-wide Scoop<br> Git installations, and the standard MSYS2 and Cygwin bash locations. A<br> Chocolatey installation can be discovered through its <code>PATH</code> entry. The final<br> fallback is the Windows command interpreter (<code>ComSpec</code>, normally <code>cmd.exe</code>).</p> <p>To choose a native Windows shell explicitly:</p> <pre><code class="language-yaml">tools: shell_interpreter: pwsh # PowerShell 7, when installed and on PATH</code></pre> <p>Other choices are <code>powershell</code> (Windows PowerShell), <code>cmd</code>, <code>sh</code>, <code>zsh</code>, or an<br> absolute interpreter path. Windows resolves symbolic names through <code>PATH</code><br> (<code>bash</code> uses the discovery above); a missing requested interpreter falls back<br> to the Windows command interpreter with a warning. PowerShell is launched with<br> <code>-NoLogo -NoProfile -NonInteractive -Command</code>; cmd uses <code>/d /s /c</code> when launched<br> explicitly by path. Other interpreters must support <code>-c</code>.</p> <p>The agent is told the selected runtime shell. Commands must use that shell's<br> syntax; selecting PowerShell does not translate bash commands. Neither token<br> savings nor faster execution is guaranteed by changing shells. On POSIX,<br> existing <code>auto</code>/<code>sh</code>, bash/zsh and absolute-path resolution is unchanged; the<br> Windows-specific symbolic choices are not portable POSIX shell selections.</p> </div> </div> <script> (function() { var toggle = document.getElementById('menuToggle'); var sidebar = document.getElementById('sidebar'); var overlay = document.getElementById('sidebarOverlay'); function close() { sidebar.classList.remove('open'); overlay.classList.remove('open'); } toggle.addEventListener('click', function() { sidebar.classList.toggle('open'); overlay.classList.toggle('open'); }); overlay.addEventListener('click', close); })(); </script> </body> </html>