Skip to content

Configuration ​

Status: Approved; existing-type assignment is ongoing
Date: 2026-07-28
Beads issue: archie-core-5d7

Ownership ​

Configuration has two separate responsibilities:

  1. internal/infrastructure/configuration loads files, environment variables, secret references, overlays, and compatibility representations.
  2. Each domain and plugin owns the typed runtime settings required for its behaviour.

internal/app translates external input into those settings, validates cross-capability combinations, and supplies each component only its own settings.

The following are prohibited:

  • passing complete application configuration into a domain;
  • making a domain depend on TOML, YAML, environment-variable names, secret references, or a configuration library;
  • defining a central runtime configuration type imported across the system;
  • placing plugin options in an unrelated global configuration model.

Private input document ​

internal/infrastructure/configuration MAY use a complete decoded document while discovering files, decoding sections, and applying overlays. It is an input-boundary DTO only.

The document:

  • remains private to the configuration infrastructure;
  • is composed from separately defined feature sections;
  • is immediately translated by application composition;
  • is never returned as the application's runtime model;
  • is never passed through runtime components.

External DTOs and domain runtime settings are separate types.

Plugins supply external configuration definitions through a narrow extension contract. The core loader MUST NOT gain a field or recognized filename for every plugin.

Invalid configuration input MUST NOT replace active valid settings or terminate unaffected capabilities. Configuration changes use the candidate validation, promotion, audit, and recovery requirements in safe-change-and-recovery.md.

Dissolution of internal/config ​

internal/config has no target location. It MUST be dissolved and MUST NOT survive as a shared package, configuration domain, or renamed global model.

Its loading behaviour moves to internal/infrastructure/configuration. Existing types and methods are reassigned by behaviour. Repository execution policy, dispatch policy, retry policy, ecosystem defaults, tool policy, memory settings, indexing settings, provider settings, and channel settings move to their respective owners.

Repository settings ​

The existing config.Repo MUST NOT move intact into a repository domain or shared settings package. A managed repository is an application association:

  • work intake owns which repository references an identity monitors;
  • task execution owns gates, preflight, test protection, ecosystem behaviour, and change limits;
  • task lifecycle owns retry behaviour;
  • scheduling owns concurrency policy;
  • workspace management owns base branch and persistent-storage requirements.

Application composition correlates these settings by repository reference. No domain receives a universal repository profile.

Documentation ​

Generated configuration reference describes external sections and their owning capabilities. It MUST NOT establish a global Go configuration structure as the public contract.

Value classification rule ​

Every value that controls behaviour MUST have an explicit owner and MUST be classified as exactly one of:

  1. Invariant — changing it changes the meaning of the program, a wire protocol, or a domain concept. It may be a Go constant.
  2. Runtime setting — an operator, identity, domain, plugin, or deployment may legitimately choose a different value. It is typed configuration owned by the affected capability.
  3. Policy value — it expresses what is allowed, limited, routed, retried, protected, or gated. Its typed definition belongs to the owning domain and it is evaluated through the policy system.
  4. Derived value — it is computed from other settings and is not independently mutable.
  5. Runtime state — it changes as the application operates, such as the active model for a conversation. It is changed by a domain command and is not configuration merely because it can be changed.

An unclassified behavioural literal is a defect.

const MUST NOT be used merely because a value currently has one default. Constants are reserved for actual invariants: enum discriminants, protocol versions, fixed compatibility tokens, and values whose alteration would change the program's semantics rather than configure an installation.

In Go, a constant is a compile-time value and does not represent mutable runtime storage. It generally has no address that can be observed or changed. Architecturally, a constant therefore asserts that the value cannot change for the lifetime of the application. Any value that may legitimately change while the application is running, between application instances, or between deployments is not a constant.

A runtime setting may have a default, but the default is not its only access path. The owner exposes a typed settings structure, validation, and a DefaultSettings constructor or equivalent. Private constants used to implement defaults do not turn those defaults into invariants and MUST NOT be consumed directly by runtime code.

Each runtime setting and policy value MUST declare:

  • its owner;
  • type, units, validation constraints, and safe bounds;
  • default and derivation, if any;
  • whether it is startup-only, live-reloadable, or restart-required;
  • whether it may differ by installation, identity, repository, workflow, channel, or plugin instance;
  • whether it is secret, sensitive, or safe to report;
  • its current source, effective value, version, and last-known-good version;
  • the command and identity required to change it.

Current configuration migration ledger ​

This ledger records the current meanings hidden inside internal/config. It is the source inventory for dissolving that package; rows are split where the existing structure combines different owners.

Current valuesCurrent locationTarget owner and requirement
WorkDir, DBPathroot ConfigWorkspace/storage infrastructure settings. Defaults derive from the platform data directory.
SkillsDir, PluginDirroot ConfigSkill and plugin infrastructure settings, independently typed.
PollIntervalroot ConfigWork-intake scheduling setting; not a daemon-wide constant.
Label, BotUser, BotEmailroot ConfigIdentity and dispatch associations. BotEmail may be derived from the selected forge account but remains overrideable.
MaxRetriesroot Config, RepoRetry policy owned by the operation being retried. The duplicate global/repository representation must disappear.
DiffCapLinesroot ConfigAgent-change policy value.
MaxSteps, MaxTokens, WallClock, GateMaxFailuresBudgetsWorkflow-execution policy, with units and zero/unlimited semantics made explicit.
Class, APIKeyEnv, BaseURLProviderProvider instance settings. Secret lookup becomes a SecretRef, not an environment variable name leaking into the provider domain.
Mode, Command, EnvAgentAgent-execution infrastructure settings. Arbitrary environment injection is explicitly trust-sensitive.
Type, Host, Token/legacy TokenEnvForgeForge adapter settings. Legacy input is accepted only at the loader boundary.
Trigger, AckReaction, label namesDispatchWork-intake and forge presentation policy. Label vocabulary is configurable per forge/identity association.
Provider, ProviderConfig, SessionTTLMemoryConfigMemory capability settings. Provider-specific data remains owned and validated by that provider.
Name, Transport, Command, Args, WorkDir, URLMCPServerOne typed MCP server instance specification. Transport-specific variants must reject fields belonging to other variants.
MaxResultChars, ParallelExecutionToolPolicyTool-execution policy values, not generic daemon configuration.
URL, TokenEnvNATSConfigNATS transport settings with a secret reference replacing the environment-name field.
Enabled, Image, MaxConcurrency, MaxUptime, VolumeTTL, PullPolicy, NetworkContainerConfigContainer-execution infrastructure settings and resource policy.
model mappings, email, webhook, TelegramChatConfigSeparate channel instance settings plus channel-routing associations; there is no chat-wide settings owner.
AllowedUserIDs, TokenEnv, update commandsTelegram configTelegram adapter settings and access policy. Secret and policy fields are distinct.
listen/relay addressesemail configEmail adapter instance settings.
webhook targetNotifyNotification adapter instance settings.
web listen addressWebWeb transport settings.
index directory and database pathIndexingIndex infrastructure settings, derived from storage settings unless explicitly overridden.
forge, dispatch, models, providers, agent, containers, memory, tools, indexing and repositoriesIdentityConfigExisting composite duplicates unrelated settings. Replace it with associations from an IdentityID to independently owned configured instances.
owner, name, base, gate, protection, ecosystem, preflight, storage, retry and concurrencyRepoSplit across work intake, workspace, workflow execution, policy, gate, and scheduling as described in Repository settings.
TaskConfig, TaskForgeworker snapshotReplace with the minimum immutable, versioned WorkflowExecution input assembled by the application. It is not a second configuration model.
Extra and arbitrary mapsroot/provider configAllowed only at an extension boundary whose owning plugin/provider supplies schema and validation. Core configuration never consumes an untyped catch-all.

Behavioural literals and incorrectly fixed values ​

The following current values affect useful behaviour but are not represented as owned typed settings or policy. They MUST be classified and migrated before the old configuration package is removed. The listed target is the architectural decision; exact setting names are implementation details.

CapabilityValues fixed in current codeRequired classification
Chat agentmaximum steps 8 in cmd/archiedWorkflow/chat execution policy.
Context compressionenabled, threshold 0.5, context size 128000, protect first 3 and last 20, compression marker, token estimate of four characters per tokenModel/context runtime settings. The marker is presentation; the estimate is provider/model strategy, not a universal truth.
Tool guardrailsescalation thresholds 3, 5, 10, 2Tool-use policy with named meanings and bounded defaults.
Tool outputturn budget 200000 characters and preview 500 charactersTool-execution resource and presentation settings.
Pairing/accesscode TTL 1h, maximum pending 3, rate window 10m, failures 5, lockout 1h, maximum lockout 24hAccess policy. Code length/alphabet and salt length require an explicit security-constraint decision; they are not automatically valid constants.
NATS daemon consumerstream ARCHIE_TASKS, consumer archie-daemon, deduplication 2m, poll 2s, deliveries 3, acknowledgement wait 5m, inactive threshold 24h, subjectsNATS topology settings plus delivery policy. Subject grammar or protocol headers may be invariants only if declared as versioned wire contracts.
NATS worker consumerstream ARCHIE_TASKS, consumer archie-agent, deduplication 2m, poll 5s, acknowledgement wait 30m, deliveries 3, inactive threshold 24h, queue group and retry delay 1sWorker transport settings and delivery/retry policy. Shared stream defaults must have one owner rather than two copies.
Worker readinessreadiness timeout 20s, retry delay 250msWorker lifecycle and retry policy.
Execution/RPCagent execution 30m, task-run RPC 60s, worktree RPC 15mPer-operation timeout policy.
Indexingbuild timeout 10m, metadata timeout 5sIndex operation policy.
Plugin/tool cleanupplugin rollback 10s, tool-provider cleanup 10s, MCP-provider cleanup 10sLifecycle shutdown/rollback policy owned by each engine, with a shared policy vocabulary where appropriate.
Memorysync buffer 100, prefetch 8s, shutdown 10s, single external-provider limitMemory resource/lifecycle settings. The provider-count restriction is a product rule only if deliberately retained.
Built-in memory storefile limit 100KiB, section-name length/character rules, query/match truncation limits, built-in provider/tool namesSplit into memory resource policy, input policy, presentation settings, and genuine registered identifiers.
Memory safety scannercompiled prompt-injection and sensitive-data patterns with fixed warn/block consequencesVersioned memory-domain policy definitions. Patterns and consequences must be inspectable and replaceable without editing scanner code.
MCP stdioinitial backoff 500ms, maximum backoff 30s, unlimited default retries, send and shutdown 5sMCP transport retry, request, and lifecycle policy. Unlimited retries must be explicit rather than a zero-value accident.
MCP SSE/HTTPreconnect 1s to 30s, POST/request timeout 30sMCP transport settings and retry policy.
Message framingMCP frame 4MiB, worker protocol frame 8MiB, diagnostic 64KiB, media/base64 64MiBResource/security policy unless a published wire protocol mandates the limit. Limits must be configurable only within safe bounds.
Webhooks and web UIwebhook bind 0.0.0.0:8644, webhook shutdown 5s, web read-header 5s, web shutdown 2sTransport instance and lifecycle settings.
Telegramtyping refresh 4s, draft interval 700ms, update-action TTL 10mTelegram adapter presentation and lifecycle settings.
Telegram limitsmessage length 4000 and callback/update prefixesRecord the upstream platform constraint and version it as an adapter compatibility limit; prefixes may remain wire constants when changing them would invalidate outstanding callbacks.
Containersstop and pull timeouts 10s and 30sContainer lifecycle policy.
HTTP clientsfeasibility notification timeout 10s; other paths use http.DefaultClientAdapter request policy. Every outbound client requires an explicit timeout profile.
Workflow routinglabels bug, feature, bootstrap; workflows tdd, feasibility, bootstrap; fallback implementAgent-system routing policy. Workflow identifiers are references, not compiled routing decisions.
Filesystem/deployment.agents/skills, .archie/stages, .archie/gate.go, /data/worktree, /data/repo, cache names/paths and prepared sentinelSplit into deployment settings, repository conventions, and genuine internal protocol markers. Paths an installation may relocate are settings.
Packaged release data/usr/share/archie/CHANGELOG.archied.md and /usr/share/archie/CHANGELOG.archie.mdPackaging/deployment settings or paths derived from an installation prefix.
Forge presentationdefault label colour bfd4f2 and state-label coloursForge adapter presentation settings.
Fallback system promptcompiled fallback promptAgent-system default content, versioned and replaceable through its owning settings; safety constraints remain policy/code.
Default paths and identitiesconfig path, data paths, listen addresses, model roles and workflow namesTyped defaults belonging to their respective owners, never global constants consumed throughout the application.

This inventory is intentionally broader than exported Go const declarations. A literal hidden in a constructor, timeout, switch, retry loop, path join, prompt, label map, or client setup restricts behaviour just as effectively as an incorrectly used constant.

Constants that may remain ​

A value may remain constant only when its owner documents why runtime variation would be invalid. Typical valid cases are:

  • domain enum values and state names;
  • a versioned wire-protocol version or framing token;
  • reserved internal headers and callback prefixes that peers must interpret identically;
  • compile-time mathematical relationships;
  • sentinel errors and internal type identifiers.

Names such as a stream, consumer, label, workflow, file, directory, network, model role, timeout, retry count, capacity, size limit, colour, prompt, command, or executable are not invariants merely because the current application has only one of them.

Architecture tests SHOULD reject exported behavioural constants outside approved invariant packages and SHOULD detect direct consumption of private default constants outside their owning DefaultSettings construction.

Current mutation and reload ledger ​

The application currently changes behavioural values through unrelated paths:

Current change seamCurrent behaviourRequired target
Telegram /restart in cmd/archiedRe-reads the global document and directly replaces Telegram token and allowed-user IDs; failure retains old values.Submit a Telegram-settings candidate through the universal change protocol. Validate the complete candidate, promote atomically, audit the acting identity, and retain last-known-good.
Active model selectionchatModelManager.SetActiveModel changes a model reference.A conversation/session command changing runtime state. Validate against configured model instances and audit it; do not rewrite configuration.
Active provider selectionchatModelManager.SetActiveProvider changes provider selection.A conversation/session command changing runtime state, with the same distinction from provider-instance configuration.
Persona selectionPersonaRegistry.SetActive mutates an in-memory per-session choice.Agent-system session state. Persistence and audit requirements are owned by that domain, not the configuration loader.
Memory provider SaveConfigAccepts an untyped map, delegates validation/persistence to an optional provider interface, then providers reload backing files.A typed provider-owned configuration command using candidate validation, versioning, atomic promotion, health observation, audit, and rollback.
File and environment overlaysApplied while loading internal/config; defaults are filled by mutation in finalize.Configuration-infrastructure input processing that produces separately typed candidates. Defaults and derivations remain visible in provenance.

Any further mutation seam discovered during migration MUST be added here before it is changed. Direct field assignment on a live settings object is prohibited.

Universal change protocol ​

Changing configuration is an application command performed by an identity. It MUST:

  1. resolve the target owner and current version;
  2. parse into that owner's typed settings;
  3. validate syntax, semantic constraints, policy, references, and safe bounds;
  4. stage a candidate without altering the active value;
  5. run owner-defined readiness and health checks;
  6. atomically promote the candidate and record actor, source, reason, diff, prior version, and new version;
  7. observe the affected capability for a bounded period;
  8. retain the new version on success, or automatically restore last-known-good on failure;
  9. report the rejected or rolled-back candidate without terminating unaffected capabilities.

Startup loading uses the same candidate rules. A bad user value therefore does not partially mutate the application or make a previously healthy capability unavailable.

Settings that cannot safely reload in-process are marked restart-required. The change may still be validated and versioned immediately, but promotion occurs through a controlled restart with the same health and rollback semantics.

Completion criteria ​

The configuration rearchitecture is complete only when:

  • internal/config no longer exists;
  • every behavioural value has one classification and owner;
  • every current field and hard-coded value in the ledgers has a recorded disposition;
  • domains and plugins receive only their typed settings;
  • all changes use semantic commands and the universal change protocol;
  • active, candidate, rejected, rolled-back, and last-known-good versions are queryable with secret-safe provenance;
  • generated documentation lists every external key, default, constraint, mutability class, owner, and deprecation;
  • architecture tests prevent a new central runtime configuration model, direct live-setting mutation, and incorrectly fixed behavioural values.

Built with VitePress.