Architecture decision records
The specification (section 20) leaves technology choices open and asks for each consequential choice to be recorded
with alternatives and trade-offs. These records describe the choices this implementation made, most of them while
building phases 1 to 3. Status is “accepted” unless noted. A change to one of them is a new record that supersedes it.
ADR-001 Runtime: Classic ASP on AxonASP
- Context: the project started from an existing Classic ASP MVC starter and must run in a Linux container.
- Decision: VBScript on AxonASP (a Go implementation of Classic ASP), the portable language subset of AGENTS.md
section 2, native libraries (G3DB, G3CRYPTO, G3STRINGBUILDER) where they exist.
- Alternatives: rewrite in a mainstream stack (Python, Go, Node); IIS on Windows.
- Consequences: one small container, no build step, and the starter's MVC framework reused. In exchange the runtime has
quirks that cost real time (AGENTS.md section 8: error handling, class constants, string builtins that scale with
length, no characters above U+FFFF), and the image is pinned by digest so upgrades are deliberate and re-tested.
ADR-002 Canonical store: SQLite through G3DB
- Decision: one SQLite file (
db/app.sqlite, WAL mode) is the source of truth for every record; schema changes only
through migrations. FTS5 provides lexical search with BM25.
- Alternatives: PostgreSQL (with pgvector), a document store.
- Consequences: no database server to run, backups with
VACUUM INTO, simple restores. One writer at a time and one
application process per database, which fits a team-sized installation; a hosted multi-tenant service (roadmap
phase 6) would need PostgreSQL. G3DB limits (8 parameters, no column names, open result sets) shape the data code.
The database must never be opened from the host (WAL file ownership, see AGENTS.md).
ADR-003 Semantic retrieval: Ollama embeddings, Qdrant vectors, rank fusion
- Decision: embeddings from a local Ollama model (
nomic-embed-text, 768 dimensions), vectors in Qdrant, both as
containers. Lexical and vector rankings are fused with reciprocal rank fusion (k = 60); vector hits below
EmbeddingMinScore 0.6 are ignored. SQLite's embedding_index table tracks model, dimensions and revision per item,
so the vector store can be rebuilt from SQLite at any time (embed.cmd reindex).
- Alternatives: a hosted embedding API (data leaves the network, per-call cost); vectors inside SQLite (would need a vector
extension loaded into the runtime's SQLite driver); score-weighted fusion (needs calibrated scores from both rankers).
- Consequences: everything stays on the local network. Retrieval degrades to lexical with a warning when either
service is down, and writes never fail because of indexing. The 0.6 cutoff is model-specific; the retrieval
benchmark (
tests/retrieval-benchmark.sh) must be rerun before changing the model or the cutoff.
ADR-004 JSON: pure VBScript parser for request bodies
- Decision: API controllers parse JSON with
core/lib.JsonLite.asp and compose responses as text.
- Alternative: the native
G3JSON. Rejected because, in a request that also uses G3DB, it caused silent lost writes and
stale values (AGENTS.md section 8).
- Consequences: correct and predictable. Parsing large bodies needs care for speed (one RegExp tokenizer) and the import
size is capped at 8 MiB.
ADR-005 Jobs: a table-backed queue with leases
- Decision: ingestion jobs live in the
jobs table with their input. Processing is claimed with a conditional UPDATE
and a 5-minute lease; the embed-worker container picks up queued, interrupted and retryable jobs every 30 seconds.
Publishing and the job update share one transaction.
- Alternatives: a message broker (RabbitMQ, Redis); processing only inside the request.
- Consequences: no extra service, and job state is backed up with the data. Throughput is bounded by one worker and
SQLite's single writer, which suits documents up to the 8 MiB request limit.
ADR-006 Identity: hashed API keys, tenant from the key, 404 for no access
- Decision: callers authenticate with bearer API keys stored as SHA-256 hashes (with an 8-character prefix for
identification). The tenant comes from the key, never from the request. Missing permission on a namespace answers
404, the same as a missing item, so ids cannot be probed.
- Alternatives: an external identity provider (OIDC) and per-request tenant headers.
- Consequences: simple provisioning through
provision.cmd/ops.sh and no dependency on an identity service. Key
rotation and revocation are manual. An OIDC front end can be added later without changing the data model.
ADR-007 Learning: proposals reviewed by another principal
- Decision: agents propose lessons and facts with evidence (
POST /learn); a principal with verify reviews them, and
the author cannot approve its own proposal without admin. Verification is stored per revision, so a correction
starts unverified. Trusted retrieval returns only verified items by default.
- Alternatives: automatic acceptance with confidence scores; AI-assisted review (roadmap phase 5).
- Consequences: the knowledge base only grows through reviewed items, at the cost of a review step that someone must
perform (
kb.sh candidates / review).
ADR-008 Context budget: estimated tokens
- Decision:
POST /context counts tokens as characters / 4 (counting_method estimate_chars_div_4, stated in every
response). Constraints are required: if they do not fit, the answer is 422 context_budget_exceeded.
- Alternative: a model-specific tokenizer. Not available in the runtime, and different for every agent's model.
- Consequences: callers get a declared, conservative method and can leave headroom.
ADR-009 Portability: a versioned canonical export
- Decision: exports use the
agent-memory-export format, schema_version 1, with a SHA-256 digest over the exact data
text. Imports keep ids, revisions, timestamps and author ids, rebuild derived data and are all-or-nothing. Unknown
author ids get placeholder principals (no keys, cannot sign in).
- Consequences: a new canonical table or column means a new schema version and an importer for the old one.
ADR-010 Operations: stdout logs, in-process metrics, file backups
- Decision: one JSON access-log line per API response on stdout (no bodies, query strings or keys), Prometheus metrics
at
/api/v1/metrics behind a token, counters held in process memory. Backups are verified SQLite copies in
db/backups/, restored with the server stopped.
- Alternatives: OpenTelemetry export, a metrics database, continuous replication (for example Litestream).
- Consequences: nothing extra to run. Counters reset on restart, and backups need a schedule and an off-machine copy
(open item on the production server).
ADR-011 Management API: delegated administration without escalation
- Context: provisioning went through a CLI on the server (
provision.cmd / ops.sh), which needs shell access to the
host. The specification lists management endpoints as mandatory “API or secure configuration”.
- Decision: management endpoints inside a tenant (
/me, /namespaces, /principals, /principals/{id}/keys,
/keys/{id}, /grants) with authorization derived from the existing namespace grants, no new role:
admin on a namespace allows granting and revoking access on it; granting with inherit, and creating namespaces
below it, needs an admin grant that itself inherits.
- Listing and creating principals needs admin somewhere; a new principal has no access until granted.
- Issuing keys for, disabling or enabling another principal needs admin over every namespace where that principal
has a grant (inheriting where its grant inherits). A key therefore never lets the caller act with more access than
it already holds. Callers may manage their own keys but not their own status or grants.
- No permission answers 404; keys are returned once with
Cache-Control: no-store; no Idempotency-Key replay for
responses that contain a key.
- Tenants, top-level namespaces and purges stay with the CLI (operator actions).
- Alternatives: a tenant-wide administrator role (simpler, but all-or-nothing); exposing tenant creation (needs a
service-level operator identity that does not exist yet).
- Consequences: teams can run their own namespaces without shell access to the server. The rule has to be kept by any
future endpoint that issues credentials or access (AGENTS.md).