Knotrel Docs

ADR 0015: graph runtime and registry

Status: Accepted on 2026-11-29 (knotrel/knotrel#224). Scope decisions Q1, Q2 and Q4 approved by the maintainer on 2026-11-29. Issues: #154 (contracts), #156 (runtime), #155 (graph resources). The “no public item” clause of decision 2 is superseded by ADR 0018 (additive core API in 1.x).

Related: ADR 0016 (authority, snapshots and restore), ADR 0017 (authentication and trust boundary).

Context

Knotrel 1.2 serves one graph per process. knotrel-server keeps that graph in a single GraphState behind one read-write lock, together with everything that belongs to it: revision, generation, the synchronization state of source-managed mode, the feeder session and lease, the deduplication window, the readiness word and the fail-stop flag. The admission lanes and the B2 query limiter are process-wide.

v1.3.0 adds several independent graphs per process, each owned by a tenant (#153). Graph rules (single writer, readiness, fencing, fail-stop) must then hold per graph, and one tenant must not be able to exhaust the process. The existing single-graph routes and configuration must keep their documented meaning.

Decision

  1. A new crate, knotrel-runtime, owns the graphs. It holds a registry keyed by tenant and graph ID and, for each graph, the state that GraphState holds today. It owns the graph lifecycle (creation, loading, draining, deletion), pinning of in-use graphs, per-graph fail-stop and admission. It exposes typed operations, not HTTP. A lookup with the wrong tenant is indistinguishable from a missing graph.
  2. Dependency direction: the server depends on the runtime, the runtime on knotrel-core (and optionally on knotrel-storage, ADR 0016). The core gains no dependency and no public item in v1.3.0; a missing core capability is a change request to this ADR. Q2: the runtime may depend on tokio with the sync feature only, for synchronization primitives; HTTP and networking stay in the server.
  3. Q1: the existing routes also go through the registry, on an internal default graph created at startup from today’s configuration (KNOTREL_MODE, engine, limits) and owned by the local default tenant. The server keeps a direct handle to it, so these routes do no registry lookup. The existing HTTP contract is unchanged.
  4. Q4: limits are split by what they protect.

    Scope Limits
    Process Connections, maximum request body size, import permits
    Tenant Quotas on graphs, pending jobs and concurrently executing jobs
    Graph Admission lanes (shared, feeder data, feeder control), graph limits, the B2 query limiter re-expressed per graph

    Creating more graphs therefore does not multiply the imports the server allows at once, and one tenant’s load cannot take another tenant’s capacity.

  5. A worker panic fails only its graph. Other graphs keep serving. This narrows the 1.x fail-stop rule (threat model T1.15) to one graph.
  6. Graph IDs are opaque and server-generated; their format is part of the API contract (graph resources). The stability class of the runtime’s public API is in stability.

Alternatives considered

Consequences