Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture Decision Records

This section tracks the architectural decisions made in mnemra-core using the MADR (Markdown Architectural Decision Records) format.

What is an ADR?

An Architecture Decision Record (ADR) captures a single architectural decision along with its context and rationale. An accepted ADR changes by a dated, in-place ## Amendment YYYY-MM-DD section appended to the record (maintainer ruling 2026-10-19, #4018 activity 7793, confirming the practice of P-0003 “Amendment 2026-06-30” and “Amendment 2026-07-07” and P-0010 “Amendment 2026-10-19”): the original decision text is never rewritten, the amendment states what it supersedes and why, and the superseded text stays in the file as the record. The supersedes / superseded_by frontmatter and the superseded status remain available for a decision that is wholly replaced by a new record. Rejected alternative, kept with its reason: “ADRs are immutable once accepted — superseded by newer ADRs, never edited” (this file’s earlier rule). It lost because practice had already amended in place twice, a per-amendment successor file splits one decision’s lineage across records a reader must reassemble, and the in-place section keeps the decision and its history in one place — the same amend-don’t-erase discipline, applied inside the record.

ADR Lifecycle

Each ADR moves through the following statuses:

StatusMeaning
proposedUnder discussion; not yet accepted
rejectedDiscussed and explicitly declined
acceptedThe current decision in effect
deprecatedWas accepted; no longer applies (context changed)
supersededWholly replaced by a newer ADR; see superseded_by field. A partial change is an in-place dated amendment section, not a new status

G/P Prefix Projection Pattern

ADRs in this project use a two-tier identifier convention that reflects where a decision originates and how it propagates.

  • G-NNNN (general) — workspace-wide architecture decisions. These do not live as individual files in this directory. Instead, they are projected once into DEFAULTS.md — a one-time snapshot recording each general standard as a concise entry, without the full rationale chain. DEFAULTS.md is frozen at projection time; upstream changes to a G-* decision do not auto-sync into this file.
  • P-NNNN (project) — project-specific architecture decisions, stored as individual P-NNNN-*.md files in this directory. Two sub-categories:
    • Project-specific: a decision with no workspace-wide analog — a constraint or tradeoff unique to mnemra-core.
    • Override: a deviation from a DEFAULTS.md baseline entry. An override P-ADR names the default it overrides explicitly in its Status field (e.g., Status: accepted, Overrides G-0017).

The default is the starting point; any deviation is a new P-ADR.

Using the Template

To record a new project ADR, copy template.md to a numbered file (e.g., adrs/P-0001-topic.md), fill in all frontmatter fields, and write the body sections. If the decision overrides a DEFAULTS.md entry, state that explicitly in the Status section.

Current ADRs

Nine Tier-A ADRs authored in WS-E-2 Stage 3, plus the storage substrate/engine ADR (P-0010) folded in 2026-06-08 from a post-spec-lock storage-engine evaluation, plus the logging-facade ADR (P-0011) recording the tracing facade-from-binary choice merged 2026-06-17, plus the plugin-runtime + MCP-SDK ADR (P-0012) recording the raw-Wasmtime-over-Extism runtime choice (retroactive; shipped Tasks 20–22) and the official-rmcp-SDK-over-hand-rolled-MCP protocol choice (forward; implemented by Task 23) — correcting the two halves of the never-ratified adr-001-plugin-runtime research proposal, which the build reversed on both halves without an ADR. The 2026-06-09 observability re-derivation (P-0010 D8’s E1 disposition — generation⊥storage separation) was re-altituded out of the project-ADR layer: observability shape is a theory trait + chassis mechanism, not a per-project ADR, so its decisions live in the observability baseline and the original observability ADR P-0004 is deprecated (no successor ADR). P-0011 is not an observability-shape ADR — it is a dependency-selection + crate-topology decision (P-0010-shaped: a concrete library choice behind a locked contract), and is the plumbing foundation under that baseline. All Tier-A placeholder slots resolved (see placeholder-resolution.md for full status). The three retrieval-cluster ADRs (P-0014/P-0015/P-0016, authored 2026-07-02 at the retrieval-cluster Stage 3) resolve that cluster’s Frame slots; they are accepted (2026-07-02, at the retrieval-cluster spec-exit gate). The two reporting-engine ADRs (P-0020/P-0021, authored 2026-07-04 at the reporting-engine Stage 3) resolve that cluster’s Frame slots; they are accepted (2026-07-04, at the reporting-engine spec-exit gate). The single coordination-cluster ADR (P-0022, authored 2026-07-07 at the coordination-wedge Stage 3) resolves that cluster’s one Frame slot ({{P-CoordinationCluster}} — a single slot, not a split); it is accepted (2026-07-07, at the coordination-wedge spec-exit gate, as part of the Stage-3 package the gate reviewed alongside the cluster spec). The distribution ADR (P-0023, authored 2026-07-07 at the plugin-distribution Stage 3) resolves that Frame’s {{P-PluginDistribution}} slot; it is accepted (2026-07-11, at the plugin-distribution spec-exit gate, as part of the Stage-3 package the gate reviewed alongside the cluster spec).

ADRSummary
P-0001-storage-layoutC1 single-document layout: whole artifact in one row, JSONB frontmatter + body + system fields, per-artifact-type tables; non-breaking C2 evolution path via the projection layer. Sits under P-0010 (the Postgres implementation under the swap trait).
P-0002-core-plugin-partitionVerb-on-content cohesion criterion: 4 core: true plugins (tasks / repos / two further artifact-family plugins) covering 0.2.0–0.13.0; 7 builtins covering foundational substrate; 0.14.0 migration as builtin handler.
P-0003-plugin-manifestV0 manifest schema: universal content.emit verb shape, schema_version: 1, typed host-fn allowlist compiled per-instance from signed manifest; workspace_id structurally excluded from write-path ABI.
P-0004-observability-shapedeprecated — no successor ADR. (Historical.) Per-verb metrics surface, TimescaleDB retention policies (90d/365d/30d), health-endpoint detail body, and 1-hour continuous-aggregate window — conflated observability storage (TimescaleDB hypertables) into the app’s own Postgres substrate. Its storage core was falsified by P-0010 D8; the generation-side decisions were re-altituded to the observability baseline (a theory-trait baseline, not an ADR).
P-0005-v0-signing-chainV0 minimum-viable signing-key custody: build-host-on-disk at mode 600, synchronous fail-closed plugin load verification, multi-deployment trip-wire to {{P-SigningKeyCustodyHardening}} (Tier C).
P-0006-v0-tenant-enforcementTyped WorkspaceCtx parameter binding at the host-fn boundary as the V0 application-layer workspace isolation mechanism; WHERE-clause-mandatory discipline; upstream of RLS policy enforcement (V0.1+).
P-0007-plugin-resource-limitsWasmtime per-instance resource limits: fuel (10B ticks), epoch-interruption (5s), memory ceiling (64 MiB), table/instance limits at Wasmtime defaults; both fuel and epoch ON at V0.
P-0008-admin-token-shapeStatic admin token: opaque 32-byte random value, BLAKE3-hashed in DB, workspace claim from server-side lookup row; trivial revocation, no second signing key at V0.
P-0009-rls-admin-tokenBinary admin/read-observer role enum; permission matrix per role for MCP verb categories and CLI control-plane ops; WorkspaceCtx carries token_id for write attribution; V0 app-layer enforcement with V0.1+ RLS policy hardening path.
P-0010-storage-substrate-enginePostgreSQL ratified on merits behind an engine-agnostic swappable Storage trait (one implementation); V0 engine a separate, operator-run PostgreSQL instance (Amendment 2026-10-19, approved; was embedded Postgres); A1-clean V0 stack (pgvector HNSW + native FTS + recursive CTEs + JSONB); keyword/graph/time-series on named trip-wires (D3/D4/D8 — TimescaleDB demoted); D6 method-borrows deferred to the retrieval ADR; D7 managed-tier skipped. Reframes P-0001/Frame/overview. Escalation E1 (D8 vs observability hypertables) dispositioned 2026-06-09 → re-altituded out of the ADR layer to the observability baseline; P-0004 deprecated, no successor ADR.
P-0011-logging-facadetracing + tracing-subscriber (Green/MIT) as the logging facade, wired facade-from-binary: the binary (cmd/mnemra) owns the one global subscriber (JSON → stdout + EnvFilter); library crates use tracing macros only and never depend on tracing-subscriber. Macros = locked contract, subscriber = binary-owned implementation. Foundation + crate-topology only (impl-crate-only); the full emission layer (semantics, per-verb metrics, OTel export, redaction) is deferred to Task 25 / R-0004. A dependency/topology choice (P-0010-shaped), not an observability shape decision (which the 2026-06-09 E1 disposition keeps in the observability baseline).
P-0012-plugin-runtime-and-mcp-sdkTwo orthogonal substrate-layer choices the never-ratified adr-001-plugin-runtime proposal had bundled, and the build reversed on both halves without an ADR. Decision A (retroactive; shipped Tasks 20–22): host plugins on raw Wasmtime, not Extism — P-0007’s resource-limit mechanism (fuel + epoch + ResourceLimiter) needs direct Wasmtime Config/Store control an Extism abstraction would mediate. Decision B (forward; implemented by Task 23): adopt the official MCP Rust SDK rmcp v1.7.0 (Apache-2.0/Green) (Amendment 2026-10-25: the SDK, not a release of it; no crate version is a design value) for the single stdio MCP server rather than hand-rolling MCP/JSON-RPC — R-0010-a mandates MCP-2025-06-18 conformance (Amendment 2026-10-25, MCP protocol revision, approved 2026-10-29 (#4249 activity 9183): target MCP 2025-11-25; the host never speaks a draft revision, serves exactly the released 2025-06-18 and 2025-11-25, and answers any other revision requested at initialize with 2025-11-25. The host enforces that set itself; tests pin it at initialize and before the handshake, and the pin after the handshake is #4326 (open). Conformance also requires a -32700 reply with id null to a line that is not valid JSON, with the session kept open; #4323 adds it.) (Refined 2026-10-29, #4249 activities 9258 and 9311: an empty line gets no reply, and each malformed line, and each line of valid JSON that is not a well-formed message, is logged by its byte length only, rate-limited per session.) and the MCP server is the auth+dispatch trust boundary, the worst place to hand-roll a mandated external wire contract; mnemra’s R-0010 handler logic rides on top as the rmcp ServerHandler, unchanged (Amendment 2026-10-25, MCP protocol revision: the host also carries an initialize gate, a line-capped reader and an initialize override at that boundary, beside its ServerHandler). Dependency-selection decisions (P-0010/P-0011-shaped), anchored to P-StackDiscipline applied per-layer.
P-0013-plugin-invocation-modelTyped per-verb content exports (create/get/list/update/delete) invoked per authenticated verb; the universal run(input: string) -> string string-dispatch export is RETIRED; symmetric typing both directions, no string verb-resolution on the V0 surface. Fills the export/invocation-side gap P-0012 scoped out; accepted-on-landing (maintainer lock 2026-06-20).
P-0014-retrieval-architectureRetrieval topology for the retrieval cluster: per-shape chunking + one collapsed-tree multi-resolution index behind a TreeBuilder seam (authored-first under a named eval); hybrid FTS+dense fused by application-side RRF with local cross-encoder rerank; three host-served MCP verbs with disclosure-budget mechanics; degraded-mode matrix (zero-egress a supported configuration; model artifacts deploy-time-provisioned, never runtime-fetched); instrumentation shape; model pin+verify (TB-5) + encoder footprint disclosure. P-0010 D6’s four method-borrows land here (deferral closed).
P-0015-provenance-envelope-source-rolesThe two-axis envelope contract: a policy permissions record (dont_use / model_egress / visibility / tenant_share — mechanical validators, permissive not-set DDL defaults, named enforcement points, undecidable-only fail-closed poles) under the eight ratified mechanics and a single PARC-shaped decision port with per-channel serving-predicate placement + differential conformance; a trust axis (outdated/authoritative/background, origin-weighted supersession); freshness schema (handle kinds, decay classes, structural overrides); the closed three-kind displacement-event registry; citation form + per-dimension citation dispositions (dont_use stub vs visibility not-found); the V0 write-authorization invariant. sensitive dissolves into model_egress: deny + visibility: admin-only.
P-0016-edge-schemaOne superset edge table extending the 0.8.0 substrate: closed eight-type vocabulary; edge_class + origin discriminating columns with the supersedes classing rule; one-logical-edge uniqueness with origin-authority upgrade (system > declared > extracted); the superseded-by forward pointer defined as the directional view of the origin-weighted supersedes edge (no second field); extraction contract (source-span provenance, idempotent re-extraction, per-run measured coverage); recursive-CTE traversal contract carrying workspace + policy predicates at every recursion level with the D4 instrument field set; dual-writer manifest ownership.
P-0017-storage-cluster-modelRefines P-0001: per-artifact-type tables classified by a closed four-shape data-shape taxonomy (state-bearing / narrative / reference / associative), with cluster membership — not the table — carrying the shared index/RLS/retention/projection/promotion policy. Locks the source-of-truth principle (content row authoritative; derived surfaces rebuildable; cross-plugin refs are soft, only core entities are hard FK targets) and the column-promotion policy (JSONB default; additive/non-destructive; physical extraction forbidden at V0). Carves out P-0001’s tasks_history trigger-shadow, superseded by host-fn audit emission.
P-0018-core-entity-manifestThe core opinionated entity set every plugin may reference: projects, actors (single table, actor_type ∈ {human, agent, system}), tags, attachments as the four hard-FK-target core entities, plus audit-log/events as a core-owned emit-target surface (storage deferred to the observability baseline + event-bus ADR). Locks the negative space: workflow primitives (tasks, dispatches, skill-runs, specs, comments) are NOT core — they are plugin-introduced.
P-0019-plugin-contractFoundational plugin-contract capstone: Path B (WebAssembly Component Model + WIT), locked 2026-05-04, proven by the V0.01 spike (c9018e3). Locks the cross-cutting contract no sibling owns — WIT ABI shape invariants (sync WIT both directions, Layer-1 async, per-concern interfaces, @since/@unstable/@deprecated gates, host-derived workspace-ctx), Wasmtime >=44 floor (Amendment 2026-10-25: restated as the three Wasmtime capabilities it stood for), wasm32-wasip2-via-wit-bindgen toolchain, the closed Extism door, and the composite lifecycle. Four tripwired deferrals; cites P-0003/P-0007/P-0012/P-0013 for the detail each owns; supersedes/overrides null.
P-0020-report-execution-contextThe reporting engine’s dedicated read-only Postgres execution context: a SELECT-only report role + READ ONLY transaction (two independent write-blocks), table + function-EXECUTE allow-lists with default-deny exclusions (admin_tokens, policy-audit stores), a scoped RLS exception keyed on per-execution SET LOCAL session settings with session-key tamper-resistance via GUC-setter revocation (chosen over SET ROLE/current_user keying), the ownership/BYPASSRLS/FORCE ROW LEVEL SECURITY model as a correctness precondition, timeout/row-cap/bounded-pool cost containment, and the OC-10 reconciliation check. Scoped exception to the P-0006/P-0009 deferred-RLS posture on exactly the caller-authored-SQL path; converges with the general R-0001 activation. Resolves the reporting-engine Frame {{P-ReportExecutionContext}} slot.
P-0021-report-definition-typeThe report-definition content type: a host-core-owned reference-cluster content artifact written through the existing content-write machinery — argued deliberately OFF the P-0018 core-entity short list (referenced by name at lookup, never a hard FK target; a third host-owned-content category). Locks the definition schema, write-time validation (including rejection of data-modifying CTEs so an invalid definition never registers), full P-0015 policy-record inheritance (visibility not-found / dont_use stub dispositions), reserved-built-in-name reservation, and (workspace_id, name) uniqueness. Resolves the reporting-engine Frame {{P-ReportDefinitionType}} slot.
P-0022-coordination-clusterThe coordination cluster’s one-slot contract record: a core host subsystem (the P-0002 verb-on-content walk — not a plugin, mints no signed artifact, does not fire the P-0013 domain-verb tripwire) with actors as durable role-instance identity (sessions are ephemeral host-derived attachments; one-live-attachment, agent-type-only, audited succession), leases as the mutual-exclusion primitive on the duration line (substrate-atomic acquisition, TTL, expired-only always-audited takeover, a registered resource-identifier scheme), and addressed messages as rows with post-send immutability, a monotonic sent→delivered→acknowledged→dispositioned lifecycle, a closed {completed, declined, obsolete} disposition vocabulary, and code-registered types (merge-request v1 + handoff v1). Two agent-visible MCP tools (claim + message, actions as closed enums) inside the 8-of-≤9 verb budget; reads default-visible in-workspace / writes strictly authority-scoped with a multi-team + trust-differentiated-actor tripwire; own storage placement outside the P-0017 four-shape content taxonomy, hard-FK to core entities only, standalone over zero content. Merger stays instance-shaped (re-arm on push transport). Log topology, audit-store detail, and the auth-bundle policy composition are explicitly out of slot. Resolves the coordination-wedge Frame {{P-CoordinationCluster}} slot.
P-0026-db-connection-authentication-transport … P-0031-test-substrate-isolation(2026-10-19, accepted with the operator-run Postgres amendment — #4018 activities 7793 and 7800) Six control-class ADRs for the operator-run PostgreSQL instance — connection authentication and transport (P-0026), authorization and role separation (P-0027), requirements-check integrity (P-0028), DB credential files (P-0029), delegated-policy inventory and supply chain (P-0030), test-substrate isolation (P-0031); each points at the V0 substrate spec clauses R-0117–R-0121 that implement it. P-0032 (probe and readiness surface) is reserved and written with the HTTPS transport amendment (#4127).
P-0023-plugin-distributionThe distribution layer’s contract record (W2-1): uniform multi-artifact OCI bundle (N≥1, wasm = layers[0], signed inner manifest as config descriptor, one flat manifest, uncompressed-only at V0); keyed-in-tree package signature (P-0005 root over the domain-separated outer-manifest digest, OCI 1.1 referrer, signer-key-pinned, never TOFU); two R-NoExternalHost transports (image-layout fs, self-hosted distribution API) behind one store contract; the bounds-first pre-phase (fetch-within-bounds → verify-package-signature → verify-blob-digests → unpack-within-bounds) behind the locked PackageVerifier seam (TUF slots behind it at R-0005-e); hard cutover, no bare/legacy load path; single-root custody exposure recorded (register R-0009). Pulls P-0019 DEF-2’s single-publisher scope ahead of its tripwire and supersedes its cosign-on-wkg shape; the [[artifacts]] schema lands as P-0003 §Amendment 2026-07-07. Resolves the plugin-distribution Frame {{P-PluginDistribution}} slot.