memql
CLAUDE.md6 starsChanged 51 days agoApache-2.0View on GitHub
Type: AI platform -- agents and automations on a time-series memory graph Language: Go + MemQL DSL Stack: PostgreSQL + TimescaleDB extension Purpose: Run agents and automations against a time-series memory graph Positioning is load-bearing, not marketing (memql#3843). MemQL is an AI platform built on a time-series memory graph; it is not a database, and no public-facing file may say it is -- the embedded TimescaleDB Community Edition's TSL grant is withheld from a product that is "primarily [a] database…
- Installs packages
In this repository5 other files it gives its agents.
- cockpit/CLAUDE.mdCLAUDE.md
- component/CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- integrations/CLAUDE.mdCLAUDE.md
- memql-ui-designSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
20 rules. About 0 are common, 9 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 6
Purpose: Run agents and automations against a time-series memory graph
- Very specific: line 22
Before designing, implementing or reviewing a MemQL interface, read memql-ui-design, even when the session's skill catalog does not list it.
- Very specific: line 30
Use the available frontend-design skill within this MemQL brief.
- Distinctive: line 51
Keep rationale beside the decision in code.
- Distinctive: line 192
OS update indicators: Do not add unseen-update dots or navigation trails.
- Very specific: line 243
ONLY supported local run path.
- Very specific: line 280
Every Postgres-backed case self-skips when it cannot reach a database, and MEMQL_REQUIRE_DB=1 is what turns that skip into a failure …
- Distinctive: line 331
Keep required checks enforced while qualifying their native replacements, and retire competing publishers before native promotion.
- Very specific: line 334
Do not hand-build and push deployment images from an operator machine (az acr build, make release, docker push).
- Very specific: line 517
Every cross-node event-bus pub/sub needs a routing rule (node.RegisterRoutingRule) or it silently dies in cluster mode.
- Distinctive: line 519
Before calling a feature done, ask: *which node holds this state, and which node needs it?*
- Distinctive: line 534
The engine is the whole platform: Every node type ships as a
- Distinctive: line 628
When in doubt: ask the user; the default answer is gRPC.
- Very specific: line 704
Every HTTP path above needs its own Ingress rule, and that rule list is generated, not authored (cmd/frontdoorpaths, emitted between the …
- Very specific: line 753
All AI operations go through a pluggable provider system (ChatAIProvider, VisionAIProvider, TTSAIProvider, ChatStreamProvider) over OpenAI …
- Distinctive: line 839
A key's spend is METERED: Every ceiling and loop cap counts it.
- Very specific: line 1188
All DSL constructs share one model for declaring inputs and reading them.
- Distinctive: line 1230
Retired author-side forms (all rejected at parse time): Every construct is authored in the struct form.
- Very specific: line 1319
One seam, enforced by a build gate: Every model call builds a core/airoute.ResolveRequest.
- Very specific: line 1362
Every query and mutation classifies as owned (filter on row.ownerUserId == actor.userId), granted (relationship predicate gates on …
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MemQL - the AI memory platform
Type: AI platform -- agents and automations on a time-series memory graph Language: Go + MemQL DSL Stack: PostgreSQL + TimescaleDB extension Purpose: Run agents and automations against a time-series memory graph
Positioning is load-bearing, not marketing (memql#3843). MemQL is an AI platform built on a time-series memory graph; it is not a database, and no public-facing file may say it is -- the embedded TimescaleDB Community Edition's TSL grant is withheld from a product that is "primarily [a] database storage or operations" product. Describing the storage layer precisely is fine ("backed by / built on a time-series memory graph"); claiming MemQL is a database is not.
TestNoDatabaseProductClaims(database_positioning_test.go) fails the build on the latter. Compliance pack: docs/internal/ops/timescaledb-license-compliance.md.
UI/UX work: load the project design skill
Before designing, implementing or reviewing a MemQL interface, read
memql-ui-design, even when the
session's skill catalog does not list it. This applies to OS apps, shared
chrome, sign-in and setup pages, and human-facing terminal output.
AGENTS.md links to this file, so the same entry point serves Codex and Claude.
The skill routes to the existing interface language
and Supervised Visual Composition;
keep those as the authoritative rules instead of copying competing guidelines.
Use the available frontend-design skill within this MemQL brief. The owner
expects simple, minimal interfaces without losing functionality, and should
not have to repeat this preference or request a design skill each time.
Harness changes: document decisions and paths (required)
Agents and developers changing the harness must update its documentation and relevant code comments in the same change. This applies across projects, goals, models and execution routes. Explain why a non-obvious branch exists: its trigger, evidence used, chosen path, alternatives or tradeoff, fallback and stop conditions, and the invariant it protects. Cover permission and ownership checks, reuse and freshness decisions, retained versus temporary data, and what survives a retry, pause or replica change when those behaviors are affected.
A goal has no fixed lifetime while measured progress continues. Keep progress windows, per-operation watchdogs, spending limits and permission gates distinct. Execution finishing means results are ready for review; only the owner's explicit acceptance of those results or decision to close ends the goal. Initial plan approval is not result acceptance. Preserve the feedback and exact reviewed result version, and do not let a model accept its own work.
Keep rationale beside the decision in code; keep the connected workflow in the existing reference or runbook. Link the relevant regression tests and identify unverified behavior or known limitations. Do not describe intended behavior as verified, repeat obvious statements line by line, or use comments as a substitute for tests. A behavior change is incomplete while its comments or documentation still describe the old path. Start with the harness decision map and work context and recovery.
Quick Start
Prerequisites: docker, k3d, kubectl (brew install k3d kubectl), python3.
make install-deps checks them and installs protoc, its Go plugins and PyYAML
for the python3 first on PATH; for Homebrew's externally managed Python it
waits for the owner's PEP 668 opt-in (PIP_BREAK_SYSTEM_PACKAGES=1) or an
activated virtualenv. Tests in make test that run scripts/ci's Python or
the connection gate's (scripts/deploy/conn-headroom-check.sh) FAIL without
PyYAML, naming the interpreter and that fix (scripts/ci/pyyaml). The local
calls media server, which make up starts last (MEDIA=0 skips it), also
needs Docker Compose v2 and openssl; make install-deps does not check those.
# --- k3d + ArgoCD: the ONLY supported local run path ---
make up # fresh bring-up: cluster + ArgoCD + secrets + images, wait healthy
make up SERVERS=2 AGENTS=1 # multi-node (cross-node mesh testing)
make up SWITCH=1 # stop another running local stack first (stopped, not deleted)
make up MEDIA=0 # skip the local calls media server, which make up starts last
make media-up # start it alone: LiveKit, Redis and Caddy beside the cluster (:7443)
make media-down # stop it and delete its rendered credentials
make dev # inner-loop: rebuild images -> import -> restart pods
make dev NODE=bff # ...one node only (faster)
make dev PULL_INFRA=1 # ...also refresh infra images (postgres/azurite)
make scale N=2 # 2 replicas per Deployment (NAMESPACE= overrides `memql`)
make status # mesh litmus: unique MEMQL_NODE_ID per pod + one shared identity keyset
make secrets # re-seed secrets (idempotent; use after a cluster recreate)
make up-refresh # clean slate: nuke + repave (fresh DB), then bring up
make down # tear down, local calls media server first (PURGE=1 also removes the kubeconfig context and the local signing key)
# Tests -- see Testing below. A bare `go test ./...` does NOT reach the engine.
make install-deps # first, from the same shell: PyYAML for its python3
make test
# Build. The Makefile generates the ignored identity CSS bundle before Go
# packages embed it. BFF is the default (no tag needed); the other node types
# are under Distributed Node Architecture below.
make build
# Database shell (after `make up`)
psql postgres://memql:memql_dev@localhost:5432/memql
# Front door: regenerate after changing a role or adding an HTTP route
make frontdoor # hosts, then paths
make frontdoor-hosts-check # gates: fail when a generated front door
make frontdoor-paths-check # or path block is stale
# Logs
kubectl logs -n memql deploy/<node> -fProject Structure
MemQL has exactly three extension words. Do not invent a fourth. See Component vs integration vs pack.
- component — engine internals (
component/: DSL lexer/AST, HTTP servers, bus, identity) - integration — talk to other DBs/services (
integrations/). Shopify and email live here - pack — client-agnostic product feature (Plugin SDK v1 /
examples/referencepack). Intake "plugin" means this
dsl/todos, dsl/calendar, dsl/campaigns are core. Packs cannot shadow them.
memql.RegisterPlugin is the Go registration primitive. It is not a fourth runtime.
A pack's build tag decides whether it ships. Images are built with
BUILD_TAGS=<node type> and nothing else, so a pack gated on its OWN NAME
(referencepack, shopifypack) reaches nothing, and one gated on a NODE TYPE
ships to that node (examples/deploypack is //go:build identity). A
storefront pack (packs/) links into every binary with no tag and is
governed by v1:platform:packState, whose absence means the pack's DECLARED
default (dsl.RegisterPackDefault; a storefront pack declares FALSE, and a
row always wins). A shopper reaches a pack only through what it DECLARES
(component/memql/shopper_surface.go): named forms and reads, on a deployable
whose shopperForms is on, under the site owner's borrowed authority, every
row stamped with the storeId of the binding it arrived through.
building-a-pack.md.
MemQL/
├── app/ Phased service bootstrap (Go): Build() + one file per
│ phase (config -> database -> engine -> integrations ->
│ transport -> cluster)
├── dsl/ MemQL DSL tree, one dir per namespace, one file per
│ construct kind; dsl/_reference/ holds authoring skeletons
├── integrations/ External services + DSL-callable capabilities (Go)
├── brand/ Visual identity as CSS custom properties, imported by
│ BOTH clients/os and component/identity/web, never
│ copied (brand_shared_source_test.go, memql#4266)
├── clients/os/ MemQL OS -- desktop shell + graphical ops console,
│ served by component/edge as a site row
├── packs/ Storefront packs in the DEFAULT BUILD (epic memql#5532),
│ mounted on every node by app/anchor_storefront_packs.go
│ and shipped DISABLED. examples/ keeps the tag-gated packs
├── component/ Core Go components (memql, grpc, events, database,
│ server, auth, edge, language, procedure, bus, node,
│ architecture, observe, envregistry, ...)
├── core/ Shared utilities (logger, env, id) + dslfs (the
│ MEMQL_DSL_PATH on-disk override / embedded FS picker)
├── cmd/ CLI tools (healthcheck, memqlfmt, memqlmigrate,
│ memqllint, frontdoorhosts, frontdoorpaths, ...)
├── deploy/k8s/ GitOps manifests: base + components + per-env overlays
├── scripts/ Shell scripts + lib/capability.sh (capability runtime)
├── docs/ Documentation
├── docker/ Dockerfile + db init + nginx assets
└── .claude/ Claude Code project state. The repo is PUBLIC: skills/,
commands/, agents/, settings.json are tracked; the rest
is ignored (memql#3344)Key Directories
Several directories carry their own CLAUDE.md, and it is the first thing to read before editing that tree. A directory without one is normal.
| Directory | Purpose | CLAUDE.md |
dsl/<ns>/*.memql | Automations, queries, mutations, specs, tools, prompts, shapes per namespace | — |
dsl/providers/providers.memql | AI provider configurations | — |
dsl/policies/policies.memql | AI provider-selection chains (paid-last when a paid fallback exists) | — |
dsl/rules/rules.memql | The rules that map a call's metadata to a policy (all @locked) | — |
integrations/ | External service integrations + DSL capabilities (Go) | → |
clients/ | Surfaces built ON the platform (SPAs, landing pages, apps) | → |
clients/os/ | MemQL OS, served at os.<domain>. Read its README before adding an app or a live surface: the live-collection contract (a collection does nothing until retain()), which concepts are broadcast, and the arrival-cue rule (a heartbeat is not news) | → |
component/ | Core service components (Go) | → |
component/language/ | The MemQL front end: lexer, parser, rewriter, AST, compiler, registries | → |
component/node/ | Distributed node system (bootstrap, peers, mesh) | → |
component/architecture/ | Auto-generated architecture model | → |
component/observe/ | Per-invocation observability runtime | → |
sdk/go/ | Go SDK -- the public client surface | → |
docs/ | Documentation | → |
OS update indicators: Do not add unseen-update dots or navigation trails. The owner removed this OS-wide feature; update and setup controls remain in their normal app destinations without acknowledgment tracking.
Documentation
Start here: docs/public/overview/quickstart.md. Full index: GLOSSARY.md.
- Component vs integration vs pack -- the three words; intake "plugin" means pack
- Architecture · Events · Tech stack
- MemQL Language · Functions
- MemQL Authoring Rules & Gotchas -- read before writing
.memqlfiles - Removing a field from a concept BRICKS its stored rows (memql#5199,
memql#5209): schemas are
additionalProperties: falseand a mutation's read-merge validates the MERGED payload, so a stored key the concept no longer declares makes the row unwritable on its NEXT WRITE. CI cannot see it (db-testsruns on a fresh database). The same is true of dropping an enum value and of adding a@requiredfield to a concept with rows.make concept-snapshotREFUSES to drop a field fromcomponent/conceptfields/concept-fields.snapshot.jsonuntil theretiredledger records a repairing migration or a waiver. Write the migration SCOPED BY CONCEPT, never by key name - A new index on "MemoryNodes" fails the build (2026-11-29): every index
is copied to every chunk and planned by every read of the hypertable, which
saturated production's database. A feature that finds rows by a payload
field adds a key to the lookup table (
memorynodes.LookupKeys,component/database/memory-nodes/lookup_table.go); the 13 indexes that stay arememorynodes.ReviewedMemoryNodesIndexes - Node Identifier Conventions -- canonical
{concept}:{shortId}internally vs BARE ids at every wire seam (the engine bare-ifies on egress and resolves bare args inbound; clients never compose, parse or compare canonical ids) core/num-- the ONE narrowing from a decoded payload number to a Goint, in three NAMED answers (saturate / zero / caller-default). A bareint(x)on afloat64is implementation-defined out of range;TestEveryPayloadNarrowingCarriesAnAnswerfails the build on a narrowing that declares no answer (memql#4779)- LLM cost control -- read before touching
ai_guard.go, an LLM loop, or an automation that drives model calls - Database self-check -- a read that names
"MemoryNodes"is planned over every index of every chunk, so a new index there or a read that plans more failsTestStandardReadsPlanWithinTheirBudgets(component/memql/planning_budget_db_test.go); on a live installation the identity node measures the same costs daily, read-only (2026-11-29 saturation) - Tool ↔ Knowledge Domain Pattern -- operational knowledge goes in a knowledge domain the tool requires, not in the agent prompt template
- Environment variables · Auto-generated architecture diagrams
Tooling: MemQL Cockpit -- the fleet worker runtime + cluster CLI,
installed as the memql command on operator machines; its source is in
cockpit/, a separate module in this repository. This repo's bin/memql is the engine
binary, which ships only inside container images; the two never share a PATH,
so do not "fix" the name collision by renaming either.
Development Workflow
Development Environment (k3d + ArgoCD)
The k3d + ArgoCD cluster is the local dev topology (memql#2061 / E0) and the
ONLY supported local run path. It mirrors the cloud cluster (AKS + ArgoCD + the
k8s base in deploy/k8s/), so the same manifests and reconciliation path run
locally and in the cloud. Multi-node is the default (#2067): use
make up SERVERS=2 + make scale N=2 for full cross-node mesh testing.
Commands are in Quick Start above; the full k3d runbook and port-forward
reference is
docs/public/operate/reproduce-the-cloud-locally.md.
Migrations run automatically on startup.
Testing
make test # the whole tree
MEMQL_REQUIRE_DB=1 make test # ...and make a missing database a FAILURE, not a skipDo NOT verify with go test ./.... It does not run the engine (memql#4032).
This is a multi-module workspace -- go.work lists 55 modules -- and a relative
pattern resolves inside whichever module owns the directory it is rooted at.
Measured:
| Command | Packages | component/memql? |
go test ./... | 64 | no |
go test ./component/... | 3 | no |
make test (go test github.com/znasllc-io/memql/...) | 208 | yes |
So ./... misses component/memql, component/database and component/language
-- the engine, the executor, the row-authz gates and the DSL loader. make test
names the MODULE PATH instead, which is prefix-matched across every workspace
module. The failure mode is silent and confidence-INCREASING: the bare
command prints ok across 64 packages and never touched the engine.
TestDocumentedTestCommandCoversTheEngine (claude_md_test_command_test.go)
fails the build if this section ever documents a command that misses it.
A second, independent way to get a meaningless green: db-gated tests skip.
Every Postgres-backed case self-skips when it cannot reach a database, and
MEMQL_REQUIRE_DB=1 is what turns that skip into a failure
(component/database/dbtest). Two traps:
- An open port 5432 is not evidence of a database. With the k3d cluster up,
k3d-memql-serverlbpublishes 5432, so the connection is accepted and then EOFs -- it fails silently as "unreachable" and every db-gated case skips. - The default DSN is
postgres://memql:memql_dev@localhost:5432/memql. PointMEMQL_DATABASE_DSNat a real Postgres+TimescaleDB+pgvector, or run the db-gated trees the way CI does.
The trees carrying most of the engine's real coverage are owned by the
db-tests lane rather than by make test, and the set changes -- ask the
script rather than trusting a count written down here:
# what CI actually runs (the canonical set lives in the script)
scripts/ci/db-gated-packages.sh --trees
MEMQL_REQUIRE_DB=1 MEMQL_DATABASE_DSN=... go test -count=1 ./component/memql/...Source architecture output
The source topology is generated during verification, not committed or
embedded. make build, native go-checks, and the architecture test package
invoke strict canonical generation from the current checkout. make arch-model
writes ignored build/architecture/topology.model.json; make arch-model-check
checks fresh generated output. No runtime image, SDK, Fleet payload or docs
bundle consumes that file. Direct source builds need no topology bootstrap.
The separate platform.graph.json remains committed and keeps its existing
regeneration/check contract. See component/architecture/CLAUDE.md.
Image builds: LOCAL Docker for dev, MemQL pipelines for deploys (HARD RULE)
Where a container image is built depends on where it runs:
- Local development -- build images in local Docker and import them into
k3d via
make dev. These validation images are never published for a cloud deployment. - Cloud deployments -- build release images through the installed MemQL
pipeline runner on the bounded cloud build pool. The engine repository's
memql-package.yamlbuilds all seven product-agnostic node images from the exact release commit. Product repositories build their data-only DSL bundles and client images through their declared pipelines. Publish retained OCI artifacts through approved release candidates, verify publication receipts, and deploy the resulting immutable digests.
The owner directed retirement of GitHub Actions for CI/CD (#5480). Do not start an Actions image build, release dispatcher or recovery publisher as a fallback. A native path that is not yet qualified must be completed or repaired before publication; an existing legacy workflow is not authorization to use it. Keep required checks enforced while qualifying their native replacements, and retire competing publishers before native promotion.
Do not hand-build and push deployment images from an operator machine
(az acr build, make release, docker push). A release is
{engine version, bundle digest, client digest} pinned in the installation's
GitOps overlay. Merge the verified pins, then let ArgoCD reconcile. Record the
native run, exact source, candidate and publication receipts with the pins.
Coordinate controller upgrades with active release work: replacing the
pipeline controller can invalidate an in-progress run, and changing the engine
or assembly configuration requires candidate review again.
Release candidates describes the
native assembly and publication contract. Deployment composition remains in
deploy-bundle-runbook.md.
Branch Workflow
MemQL uses a single long-lived branch: main.
A change lands by the owner pushing to
main; pull requests are off (the owner's decision, 2026-11-05; design record 2026-11-05). Onmemql,memql-znas,memql-projectandmemql-fylo, only the owner's account can movemain(memql-fyloalso admits its main developer), so a session pushes as the owner. Pullmain, write the change and its tests, run the tests of what you touched, pull again and resolve any conflict yourself, then push: the session that wrote the change is the one that knows how to merge it. Work that is not ready stays on a branch of its own. Never force-push: a ruleset with no bypass refuses it, the owner included.Every push to
mainruns the full pipeline, and nothing tests a change before it lands, so a brokenmainstops every session and every release. Fix it or revert it at once, whoever broke it. Where the installation opts in, as production does, a burst of pushes runs the newest commit (a newer push supersedes the push runs waiting behind the one executing), and a push run reuses an ancestor's verified step whose inputs did not change, at most 24 hours old. Push finished work, not every commit.- Releases and deploys are done by hand; there are no release trains
(removed 2026-11-05). A release is prepared in MemQL OS (Pipelines > Releases >
Cut release) from the newest commit on
mainwhoseMemQL / memql / pushcheck passed, looking back up to 20 commits, somainneed not sit still; only a cluster owner can cut one (release-cutting.md). Deploying to the production installation follows memql-znasdocs/instance.md, "Releasing and deploying by hand": pin, sync, verify, and roll back by reverting the pin. With pull requests off, Dependabot cannot propose updates; dependency bumps are pushed like any other change. A session never reviews or approves a pull request: it acts on GitHub under the owner's account. - Pre-release -- no backwards-compat shims or deprecation windows, EXCEPT in
the DSL. For Go seams, wire contracts, gRPC messages and env vars: fix
MemQL and the consumer at once and delete what is no longer needed. The
MemQL language is the carve-out (memql#5385, memql#5390), because a
.memqlbundle mounted atMEMQL_DSL_PATHlives in a repo this one cannot see: a public language form leaves through a deprecation window -- it keeps loading, every load WARNS naming the replacement and the release it stops loading at, every use is COUNTED onmemql_dsl_deprecated_uses_total{rule}, and it refuses only after at least two minor releases. The forms in a window are published in memql.md and held tocomponent/language/deprecationby a build gate. Retiring a form outright is still right where nothing outside this repo could have written it. - Stage files by explicit path (
git add <file>) -- nevergit add -Aorgit add .. The repo owner runs multiple Claude sessions against this working tree, and another session's untracked files must not get swept in.
What triggers a frontend team ping: a change that alters a wire contract the frontend depends on (removed/renamed endpoints, changed required request fields, new required response fields, new gRPC message types). Call it out in the commit body. Backend-internal refactors that leave the wire identical need no coordination.
Architecture & Tech Stack
Core Technologies
- Language: Go 1.26.1+
- Database: PostgreSQL 16 + TimescaleDB
- API: gRPC (
MemqlService.Streamis the primary surface) + HTTP for the documented exceptions (OAuth, health, file uploads) + WebSocket bridge to the gRPC stream for browsers (/memql/ws) - AI: Centralized provider system (OpenAI, Anthropic). All AI ops on gRPC.
- Auth: in-house identity service (magic-link + JWT, JWKS-published)
- Query Language: MemQL DSL
Full tech stack details: docs/public/overview/tech-stack.md
Deploy targets
MemQL ships one installation shape (epic memql#3943). There is no
staging-versus-production dimension inside the product: an operator who wants a
second environment installs a second instance, with its own domain and its own
ArgoCD. What varies is the deploy TARGET, which carries its own field
(provider):
| Target | Database | Service | Provider |
| Local | CloudNativePG in k3d | k3d + ArgoCD (make up) | docker-local |
| Cloud | Self-hosted CloudNativePG on AKS | Azure Kubernetes Service | azure |
Key Principle: the local cluster is completely isolated from any cloud install's database -- they are separate installations, not environments of one.
Development happens on macOS and Linux (amd64/arm64). Native CI runs on Linux
cloud workbenches and opted-in Linux/macOS fleet machines, as declared in
memql-package.yaml. scripts/dev/install-deps.sh, scripts/dev/proto-gen.sh
and scripts/identity/build-css.sh all branch on darwin/linux.
System Architecture
Front door (TLS 443) -> bff gRPC :50051 (h2c)
-> bff-http :8085 (the documented HTTP exceptions)
-> agent gRPC :50051 for WorkerService only (the cockpit's stream)
|
MemQL Engine <- Automations System <- Functions System
|
+-- AI Provider Registry (OpenAI, Anthropic)
| +-- AI gRPC messages on MemqlService.Stream:
| AiChatMsg, AiSpeechMsg, AiTranscribeMsg, AiSuggestMsg
+-- Integrations (agent, workbench, library, ...)
+-- MemQL Sense (Tokenize, Complete, Diagnose, Hover, SignatureHelp)
|
PostgreSQL + TimescaleDB
(time-series memory nodes; PK: (id, createdAt))Distributed Node Architecture (Cluster Mode)
MemQL uses Go build tags to compile separate binaries for each node type.
A tag selects which app/build_*.go runs, and therefore which integrations and
transport layers a node WIRES UP. Tags are a wiring mechanism, not a size
mechanism: every node binary is within ~5.5% of every other one
(build-tags.md).
go build . # bff (default)
go build -tags agent . # agent
go build -tags planner . # planner
go build -tags edge . # edge (serves hosted sites, the OS shell among them)The seven node types are identity, bff, agent, planner, workbench, mcp, edge.
BFF is the backend for frontend; Agent runs task execution, AI work,
tool calling and streaming transcription; Planner plans and orchestrates;
Edge serves this cluster's hosted web surfaces (every hosted SPA and MemQL
OS itself, a site row with no special path) by resolving the request Host
to a v1:platform:site row (epic memql#3700). Nodes discover each other via
mesh and share one PostgreSQL + TimescaleDB database; inter-node communication
uses the NodeService gRPC bidirectional stream, and events bridge across
nodes with dedup and TTL.
RETIRING a node type is the dangerous edit, not adding one (memql#5057).
The set is spelled out in seven places: app/build_<type>.go,
app/build_default.go's deny-list, component/node/compiled_<type>.go and
its deny-list (compiled_default.go), ENGINE_NODE_TYPES in
scripts/lib/engine_build_args.sh (from which dev.sh's VALID_NODES
DERIVES), the memql-package.yaml native release image stage, and the memql-<type>
image references under deploy/k8s/. Missing one on the way OUT is silent,
because build_default.go is a DENY list: go build -tags voice . after
deleting app/build_voice.go produces a BFF under the retired name. Gates:
scripts/ci/node_type_lists_test.go, engine_build_args_for_node refusing an
unbuilt type, and the Dockerfile refusing a BUILD_TAGS with no
app/build_<type>.go. BUILD_TAGS="" stays legal; it is the bff.
component/node/compiled_<type>.go decides what a binary CALLS ITSELF
(node.CompiledNodeType(), memql#5115): the build tag wins, a disagreeing
MEMQL_NODE_TYPE is warned and ignored, and the env var selects the type for
UNTAGGED builds only.
Multi-node is the DEFAULT -- design, implement, AND test for cross-node
The cluster (2 replicas per mesh node) is the runtime in the cloud and locally,
and every feature must be designed and tested against it. Never reason about a
feature as if it runs in a single process. The blessed local repro is
make up SERVERS=2 + make scale N=2.
When implementing: state that crosses a node boundary needs EXPLICIT plumbing; it does NOT travel implicitly.
- Session / in-memory state (caches, waiters, per-stream fields) lives on
exactly ONE node, and a node handling a proxied / forwarded request
(
AiForwardRouter,proxySI,NodeServiceforwards) does NOT see it -- thread it through the message or metadata. - A read-modify-write of one row across replicas needs a Postgres lock around
the read and the write, a read that skips this node's result cache
(
memql.ContextWithFreshRead), and a version stamped after the one it read -- each alone was measured insufficient (memql#5431). - Every cross-node event-bus pub/sub needs a routing rule
(
node.RegisterRoutingRule) or it silently dies in cluster mode. - Before calling a feature done, ask: which node holds this state, and which node needs it?
When testing: a green single-node unit test is a FALSE signal for
cross-node behaviour. Tests MUST exercise the hop -- a handler on a session
WITHOUT the originating node's local state, context surviving a proxy/forward,
an event consumed on a different replica -- in test/clustere2e/ and/or
component/grpc/ai_forward_test.go, failing against single-node-assuming code
(#1448, #1412, #1388). memql#4352 closed the WORKER half (WorkerForward*)
with an IN-PROCESS hop test (integrations/agent/worker/forward_hop_test.go),
because a live-cluster gate skipped on every CI lane cannot be what stands
between a feature and its bug.
Node image source: product-agnostic engine images + runtime DSL delivery (#2472)
The engine is the whole platform. Every node type ships as a
product-agnostic engine image from THIS repo's Dockerfile
(BUILD_TAGS=<type>); there are no per-product node images, and reusable
capabilities live in the engine as generic, DSL-configurable features.
Product DSL is delivered at runtime, not compiled in. A product ships its
DSL as a tiny data-only bundle image; the dsl-bundle kustomize component
runs it as an init-container that copies the .memql tree into a shared volume
the node reads at MEMQL_DSL_PATH. dsl-bundle and dsl-packages each add
ONE init container; dsl-mount owns the volume, the mount and
MEMQL_DSL_PATH, applied exactly once (memql#4933), and the components:
order is the init-container order. Two traps a render shows and a diff does
not: the memql/product-dsl label must be applied in a layer the components
CONSUME (a labels: block beside them selects nothing), and it must name only
the mesh nodes (redis has no volumes: key). Working shapes:
deploy/k8s/components/examples/, rendered by
deploy/k8s/components/dsl-mount/component_test.go.
"Never product code" is enforced by two narrow guards (memql#3326):
TestEngineIsProductNeutral (a banned-names list) and
TestClientsDirectoryIsAllowlisted (an allowlist of clients/). Everything
else rests on review; bespoke product Go becomes a thin optional bff/ pack
module in the product repo
(platform-consolidation.md).
Environment parity -- one topology everywhere (NON-NEGOTIABLE)
The local cluster and a cloud cluster run the same topology, deployment
process and connection model; only configuration VALUES and hardware differ.
FIXED: the node topology, the GitOps base+overlay+ArgoCD path (make up
applies the same manifests ArgoCD applies), and the client connection
(ingress -> TLS -> gRPC -> bff, dialed as https://api.<domain>). ALLOWED to
vary (overlay values): image digests/tags, replicas/resources, domain, DNS
source, TLS source (mkcert vs cert-manager), ingress controller, secrets
source. Reject in review: port-forward-as-connection, target-specific
commands, if env=="local" branches, or a second way to deploy
(environment-parity.md).
One cloud overlay (deploy/k8s/overlays/cloud), one ArgoCD Application
(memql), one namespace (memql), everything in it a VALUE over
deploy/k8s/base. No if env == "..." in engine code:
TestNoEnvironmentBranchingInEngineCode fails the build on engine code so much
as NAMING the tier words, with an EMPTY exemption map. development / local
stay outside that gate: they distinguish deploy TARGETS, which carry their own
field, provider.
What makes local parity rather than a lookalike: the same manifests and
reconciliation as AKS, each pod with a unique MEMQL_NODE_ID via
fieldRef: metadata.name; clients connecting through the
api.memql.localhost traefik front door (TLS on 443, mkcert wildcard, h2c to
svc/bff:50051) with NO port-forward in the path; the domain as a VALUE
(memql#3593: make up DOMAIN=lab.example.com, the single MEMQL_DOMAIN key
every node derives issuer, CORS origins and redirect URIs from; no file under
deploy/ names a domain); the engine bff as a COMPONENT
(deploy/k8s/components/engine-bff); and make status as the litmus (per-pod
node ids plus one shared identity JWKS keyset, memql#3400).
Component Bus (Channel-Based Communication)
Components communicate via typed Go channels carrying protobuf-defined messages
(component/bus/bus.proto): true concurrency, backpressure, and symmetry with
the distributed gRPC model.
gRPC/HTTP ──► EngineRequests ──► MemQL Engine ──► Database (internal)
│
├──► IntegrationRequests ──► Integration Dispatcher
│
└──► EventPublishCh ──► Event Bus ──► Subscribers ──► Automations
All Components ──► TelemetryCh ──► Telemetry CollectorReplyTo pattern (request-response via an embedded reply channel); default
buffer 64 per channel (ChannelConfig); telemetry hooks for fill-level and
send/drop counters; every component exposes Ready() <-chan struct{}.
Endpoint Protocol Policy (gRPC-First)
IMPORTANT: This policy is a hard requirement for all MemQL development.
gRPC is the default and required protocol for all internal and service-to-service endpoints. HTTP endpoints are allowed only when an external protocol requirement makes gRPC impossible.
- Service-to-service call? → Must be gRPC: request type onto
MemqlClientMessage.oneof payloadand response type ontoMemqlServerMessage.oneof payloadincomponent/grpc/memql.proto, handler incomponent/grpc/server.go. - Consumed by a browser client? → route through the WebSocket bridge
(
/memql/ws), which tunnels toMemqlService.Stream-- still gRPC underneath. - Does the external service require HTTP? (OAuth callbacks, webhooks) → HTTP is allowed as a documented exception, below.
- When in doubt: ask the user; the default answer is gRPC. Never add a new HTTP endpoint without explicit user approval, and document the reasoning when you do.
Allowed HTTP Exceptions
These endpoints must remain HTTP because the other party dictates the wire (a browser, a mail client, a probe, a third-party webhook). Each was approved individually; a new one needs the same approval.
| Category | Endpoints | Reason |
| Auth (identity service) | /login, /auth/magic-link, /auth/complete, POST /auth/landing, GET /auth/magic-link/status, POST /auth/magic-link/finish, /auth/logout, /oauth/token, /auth/refresh, /.well-known/jwks.json, POST /auth/webauthn/{register,login}/{begin,finish}, POST /device/code, GET+POST /device, GET /enroll, GET /passkey | OAuth 2.0 / magic-link need redirects, browser form posts and JWKS publishing; WebAuthn is a browser API; RFC 8628 is defined over HTTP; /enroll is a page opened from a link. /passkey is identity's passkey window (memql#6233, owner-approved 2026-10-18): when a browser refuses MemQL OS's related-origin passkey request (Safari on a *.localhost cluster, password managers without related origins), the browser's prompt runs on identity's own origin while OS keeps begin and finish on its origin (identity's host-only cookies stay put); the page takes the public options by postMessage from the installed OS origin only, returns the credential, never sees a token and holds nothing in its URL. Magic-link split (memql#4302): the GET renders and never changes state (mail scanners), landing is the form post, status is the requesting tab's poll gated on the memql_ml cookie, finish is a real form POST because the reply is a 303 the tab must NAVIGATE. All declared on identity's own route table |
| Installer evidence (Identity only) | POST /release/installation-read | Owner-approved 2026-11-07 exception for the retained installer PAT: PAT verification belongs to Identity HTTP, the BFF rejects PATs, and general Identity gRPC is operator-only. The closed schema permits only signed published-catalog get/list, native migration/build health and the authenticated user's own row. Fresh active-PAT/owner verification on every request; no arbitrary query, write, token exchange or new credential. BFF/gRPC admission stays unchanged. TLS and signed-envelope verification, redirect refusal, original-user continuity and Secret fences remain required. Installation credential contract |
| Health check | /healthz | Docker and Kubernetes probes expect HTTP GET |
| GitHub Connect callback | GET /auth/github/callback (identity only) | GitHub redirects the BROWSER here after authorize/install (memql#4912, P11). Starts on the stream (githubConnectBegin); writes a v1:platform:sourceCredential grant, not a sign-in. State is consumed once under a Postgres advisory lock; an installation_id without a valid state updates nothing (GitHub documents it as spoofable). On identity's route table -- in component/server it would route to the bff |
| GitHub App setup | GET /auth/github/app/new, GET /auth/github/app/callback (identity only) | GitHub's MANIFEST flow begins with a browser FORM POST to github.com and ends with a redirect carrying a one-time code (owner-approved 2026-09-20; docs/superpowers/specs/2026-09-20-github-app-setup-design.md). new is a page whose one job is that form post (the OS edge serves form-action 'self' for every site), composing the manifest from the cluster's own domain and writing nothing. callback spends the state once under the advisory lock FOR ITS OWN PURPOSE, re-checks the person is still an active cluster owner, refuses a managed app or one asking beyond its manifest (repository reads plus checks write), seals the credentials under MEMQL_MASTER_KEY into v1:platform:globalSecret, then sends the browser on to install. Starts on the stream (githubAppSetupBegin) |
| Shopify Connect callback | GET /auth/shopify/callback (identity), GET /auth/shopify/complete (OS edge -> identity) | Shopify redirects the BROWSER after the shop's staff approve (docs/superpowers/specs/2026-09-23-connect-shopify-design.md); the relay to the OS-hosted completion route lets the host-only session cookie accompany validation and never spends state. Starts on the stream (shopifyConnectBegin, shop named from the storefront's publishing run); writes a v1:shopify:store row, sealed credentials and the storefront's binding (a SAVED app moves no store until approval, D12). Order of checks is the security: state LOOKED UP unspent and begun by THIS browser's session (D16), HMAC verified with shop matching, only then spent under the lock; the person re-judged under their REAL role; the code exchanged in a POST body with no redirect followed. Behind identity.ShopifyConnect (integrations/shopify, wired in app/integrations_identity.go) |
| WebSocket upgrades | /memql/ws | Browsers need an HTTP upgrade |
| Site bundle publish | POST /sites/{id}/bundles (bff only) | A CI job hands over an arbitrary tree of files, which multipart carries (memql#3713). component/edge.Publisher makes it atomic: content-addressed version prefix first, then the site row's bundleRef flips. Authorization is a class="service_account" JWT; HandlerAuthorizedPaths(), never PublicPaths(). Served by the bff, never the edge |
| Inbound webhooks | POST /inbound/{source} (bff only) | The third party dials US and will only POST to a URL (memql#2957). An env-configured source must be on the deny-by-default allowlist and verifies by its per-source HMAC or signed token; a source the cluster registers for itself (github, livekit) verifies by its own policy, livekit by a signed token carrying the body's SHA-256; HandlerAuthorizedPaths() + SelfAuthenticatedPaths(). inbound-delivery.md |
| One-click unsubscribe | GET+POST /unsubscribe (bff only) | RFC 8058 is a contract with the recipient's MAIL CLIENT (memql#3348). Mail clients PREFETCH links, so the side effect is on POST only. HMAC-signed token carrying (owner, recipient, campaign), verified before any row is read. HandlerAuthorizedPaths() + SelfAuthenticatedPaths() |
| Recipient email pages | GET+POST /email/confirm, GET+POST /email/preferences, GET /email/view (bff only) | Owner-approved 2026-10-11, email-layouts-automations design section 4.4. The caller is a recipient's browser following an email link, with no MemQL session. A page-specific sealed token authorizes the current mailbox and organization; GET only reads and POST acts because scanners prefetch. server.EmailLinkPaths() through HandlerAuthorizedPaths() + SelfAuthenticatedPaths(); exact paths with the token in the query. campaign-sending.md |
| Azure email delivery feedback | POST /email/events/azure (bff only) | Owner-approved 2026-10-12 for ACS Event Grid (#6037). A sealed per-organization bearer credential authenticates every validation and notification; expected subscription/resource and original send receipt bind each verdict. server.AzureEmailFeedbackPaths() through HandlerAuthorizedPaths() + SelfAuthenticatedPaths(). |
| Campaign open/click tracking | GET /t/o/{token}, GET /t/c/{token} (bff only) | A pixel is an <img src> and a tracked link is one a reader follows (memql#4823, P3). HMAC over the unsubscribe key ring under a DIFFERENT context string; the click destination lives INSIDE the signed payload (open-redirect-proof). Never shows a failure: the pixel always answers the GIF, a bad click token renders the "link is not valid" page. The token must be a SINGLE PATH SEGMENT (base64url): SelfAuthenticatedPaths()' exemption is bounded to one segment. server.TrackingPaths(); literals must agree with campaigns.TrackingOpenPath / TrackingClickPath |
| Library artifacts | POST /artifacts, GET /artifacts/{id}/content, POST /artifacts/uploads, GET /artifacts/uploads/{id}, PUT /artifacts/uploads/{id}/chunks/{n}, POST /artifacts/uploads/{id}/complete (bff only) | Byte transport (memql#4341, memql#4782): 16 MiB chunks staged against Azure block blobs, resumable via the inventory GET. GET .../content STREAMS through the bff after re-resolving the row under the caller's actor, honoring single-range Range (206), never a redirect (no signed URLs). One added case (design record 2026-11-24): ?pipelineRun=<runId> serves a pipeline file of that run (its logs and artifacts) to a caller at developer rank or above who does not own the run, only when they read the run through pipelineRunView, the artifact's source is pipeline, its producedByRunId is the run's work run, its owner is the run's owner and it is a live file; it is then read under that owner, as the shared-file fallback is, with Range and the blob-key check kept. No new route. Ordinary AUTHENTICATED routes; server.ArtifactPaths() routes them. Caps: MEMQL_LIBRARY_MAX_UPLOAD_BYTES (4 GiB/file), MEMQL_LIBRARY_USER_QUOTA_BYTES (100 GiB/user) |
| Account export download | GET /accounts/exports/{id}/content (bff only) | Owner-approved 2026-11-12 (account export design, section G): a finished export is one file of up to many gigabytes that a browser must save as it arrives, and no stream message carries more than 32 MiB. An ordinary authenticated route for a signed-in person's own session holding execute app:accounts/export; a person who may not, and an export that is missing, removed or unfinished, answer 404 (no sign-in is refused before the route, and a method other than GET is a 405), one Range is honoured (resumable through If-Range against a SHA-256 ETag, under a six-hour transfer ceiling on both hops), and every request writes an audit event. server.AccountExportPaths() |
| Shopper forms | POST /forms/{pack}/{name}, GET /reads/{pack}/{name} (bff only) | A member of the PUBLIC posting a plain HTML form on a hosted storefront, no JavaScript, no MemQL identity (epic memql#5532). A shopper is nobody to MemQL: reach is declared PER ROUTE by a pack (component/memql/shopper_surface.go). Reached ONLY through the edge at /_memql/forms/* on a deployable's own origin, which owns the per-site switch (site.shopperForms, off by default), the rate limit, the size cap and the stamp (site, store, owner: stripped then set). HandlerAuthorizedPaths() + servedButNotExternallyRouted, so the edge is the only way in. The stamp is a POINTER: the bff re-reads the site row UNDER the named owner, so a forged owner reads zero rows. The write runs under that owner's borrowed authority and every row carries the storeId of the binding it arrived through (D9 from D7) |
| Deployable access codes | POST /access/unlock, GET /access/session, POST /access/leave, POST /access/call, POST /access/guest (bff only) | A visitor holding a code an operator minted, with no MemQL identity (owner-approved 2026-10-29; docs/superpowers/specs/2026-10-29-deployable-access-codes-design.md), or, on the guest route, any visitor to a deployable whose operator turned guest access on (owner-approved 2026-11-08; docs/superpowers/specs/2026-11-08-deployable-guest-access-design.md). A browser has no identity to open a stream with and only an HTTP response can set an HttpOnly cookie, so the other party dictates the wire. Reached ONLY through the edge's five exact method and path pairs /_memql/access* on a deployable's own origin (POST /_memql/access, GET /_memql/access, POST /_memql/access/leave, POST /_memql/access/call, POST /_memql/access/guest), answered whatever the site's apiProxy says. The edge owns the content-type and Origin checks, the size caps (1 KiB, 64 KiB for a call), the per-replica rate limits (keyed on the right-most X-Forwarded-For, so they bound load and not guessing) and the stamp (site, owner: stripped on every path, then set). HandlerAuthorizedPaths() + SelfAuthenticatedPaths() + servedButNotExternallyRouted, so the edge is the only way in. The stamp is a POINTER: the bff reads the site's row and requires its own owner to equal it, and nothing is read until a credential of the right shape has found a row by its digest, so a stranger costs no read. The guest route is the one exception: it has no credential to check first, so every guest open costs one read by the site's guest digest, and its own edge buckets are what bound that (G-D7). The session cookie is __Host-memql_access, so a sibling site cannot plant one and it has Path=/: the edge removes it from everything it forwards but these five routes, and forwards no other credential on them. A session is not a credential: no JWT, no actor, no stream; it is read from the database on every request and nothing in the decision is cached. A call runs only a construct declared @accessGate for the code's gate, under the site owner's borrowed authority and NEVER internal origin, after reading the site and its package under that owner, which is what closes a site whose owner left its organization, with the reserved arguments (siteId, accessCodeId, accessGate, accessSubject, on a mutation only accessCodeLabel, the operator's name for the code, and accessGuest, a bool true for a guest's session and false for a code's) stamped last. Only a person mints a code, in Deployables (execute app:deployables/access) and never inside a run; it is shown once and stored as a digest. A guest pass is a code's row marked guest with no secret (its digest is of guest: and the site's id, which no typed code produces): the guest route opens a session on it for anybody who asks, so a deployable with none answers closed and DSL never opens anything to the internet. Only an operator creates one, in Deployables with execute app:deployables/access (a run may remove one, never create or re-time one), at most one stands per deployable, and the guest route draws on edge buckets of its own (10 a minute per site and address, 60 per site) so guests and unlock never spend each other's budget. Everything that ends a code ends guest access. All guests share one partition. site-access-codes.md |
| Page-change ping | GET /_memql/view.js, POST /_memql/view (served by the edge on a deployable's own origin) | Owner-approved 2026-11-08, from the website statistics design. A browser beacon is a plain POST and cannot open a stream. The edge inserts the script into every HTML document of a live, non-system deployable, where it reports a single-page app's in-app page changes and never the first load (the navigation already counted it), reads no cookie and stores nothing in the browser, and neither route is forwarded to the bff. A ping is a page view only from the site's own origin (Origin naming its host, or Sec-Fetch-Site: same-origin when Origin is absent or the null a no-referrer page sends), naming a path in at most 1 KiB and within 120 a minute per address per replica, and every outcome answers 204 so the route discloses nothing (deployables.md) |
| Calls surface | POST /calls/unlock, GET /calls/session, POST /calls/start, POST /calls/schedule, POST /calls/reschedule, POST /calls/cancel, POST /calls/join, GET /calls/queue, POST /calls/host, POST /calls/leave (bff only) | Owner-approved 2026-11-17. A person starting, joining or hosting a call holds a key, a call's link or the session one opened, and no MemQL identity; only an HTTP response can set an HttpOnly cookie. Reached ONLY through the edge at /_memql/calls/<route> on a deployable whose calls switch is on; the edge owns the switch, the size caps (1 KiB, 4 KiB for schedule and reschedule), the rate limits and the stamp (site, owner: stripped, then set). HandlerAuthorizedPaths() + SelfAuthenticatedPaths() + servedButNotExternallyRouted. The stamp is a POINTER: the bff reads the site again under the stamped owner, requires the row's owner to equal it and its switch to be on (else 404), and hands the calls service only that row's site. Nothing is read until a key, a link or a session cookie of an issuable shape is presented. Sessions are per seat (a key's after unlock, a seat's after a first join by link) in __Host-memql_calls; a session is no MemQL identity. The edge refuses a POST that is not JSON or names another origin, and serves a calls site's pages a policy that admits the camera, the media servers (MEMQL_CALLS_MEDIA_HOST_SUFFIX) and compiling WebAssembly ('wasm-unsafe-eval', for background blur). Keys, tokens, links and passes are never logged. calls.md |
| Calls agents, family consent and provider callbacks | POST /calls/family, POST /calls/workflows, GET+POST /calls/delegation, GET /calls/utcp.json, POST /calls/agent, POST /calls/stripe-webhook, POST /calls/didit-webhook (bff only) | Owner-approved 2026-11-20: typed human skill/resource workflows and UTCP over minimal HTTPS, no MCP; the workflow/agent body cap is 128 KiB with native graph and grant limits; Stripe and Didit require signed HTTP callbacks. Only the exact edge routes under /_memql/calls/ reach them. Human passkey sessions approve/revoke grants; the agent route accepts a separate bounded bearer, never a human cookie or arbitrary engine call. The edge strips incoming private credential stamps and forwards Authorization only as the internal agent credential on that route. The public manual contains no credentials. Provider routes preserve capped raw bodies for signature verification before authoritative reconciliation. Native account/global gates enforce paid-before-verification, reusable adult proof, separate usage/top-up caps and revocation. The explicit local-only family simulation binds child consent to a guardian and child browser, and terminates on supervision loss. No live provider mode. Calls lifecycle and agent contract |
| Calls media signalling | GET /media/rtc, /media/rtc/validate, /media/rtc/v1, /media/rtc/v1/validate (bff only) | Native media JWT and admission proof authorize each connection, reconnect, validation and forwarded signalling frame. A fixed registry supplies the upstream; no caller destination, generic proxy or device access. Pending handshakes remain fenced until definitive provider evidence; confirmed connections renew bounded native authority leases. The local media edge exposes only these LiveKit protocol paths through this guard and independently authenticates its private upstream hop. RTP stays direct. HandlerAuthorizedPaths() + SelfAuthenticatedPaths(); the provider protocol dictates HTTP/WebSocket. User-authorized local token reentry closure, 2026-11-26. |
The front door's HOST set is generated too (memql#3767)
The host set is DERIVED from the closed role set plus the platform's own
sites (frontdoor.PlatformSites(): the OS shell and the VS Code landing page):
| Role | Host |
| api | api.<domain> |
| identity | identity.<domain> |
| mcp | mcp.<domain> |
| sites | os.<domain> and vscode.<domain> (exact rule each), *.<domain>, plus the apex |
A platform site is a seeded v1:platform:site row, not a role (memql#5518):
systemOwned, a directory the edge image ships (/app/os, /app/vscode-site),
served through the same resolver as a customer's site. Adding a third is one
entry in PlatformSites() and its directory in PlatformSiteBundleDir(), one
seed in dsl/platform/seeds.memql, one build step and one hand-authored local
rule.
Every host is a SINGLE label under the domain -- a ROUTING fact (an Ingress
wildcard matches ONE label, so *.<domain> routes every site to the edge)
and NOT a certificate fact (memql#4224): ACME cannot issue a wildcard over
HTTP-01 and one wildcard dnsName fails the WHOLE order, so the front-door
certificate names EXACT hosts and every Ingress lists exactly its own rule
hosts under tls (deploy/k8s/overlays/frontdoor_hosts_test.go). The
wildcard RULE gets a certificate only where the overlay declares a DNS-01
issuer, which the cloud overlay does (memql#4347); the render gate reads the
SOLVER.
cmd/frontdoorhosts writes front-door.generated.yaml into each overlay;
component/envregistry/domain.go composes issuer / CORS origins / redirect
URIs from the SAME rule through component/frontdoor; the SeedMaterializer
seeds every platform site's hostname from it. A second copy would disagree,
which presents as "sign-in is broken" with every manifest looking correct.
Adding a ROLE is a design change. The LOCAL overlay's front-door files stay
hand-authored (traefik) but are gated against the same derivation, and its
mkcert pair is a wildcard, so a site that works over https locally is no
evidence it has a certificate in the cloud.
front-door.md.
How an HTTP path reaches the front door (GENERATED, memql#3703)
Every HTTP path above needs its own Ingress rule, and that rule list is
generated, not authored (cmd/frontdoorpaths, emitted between the markers in
deploy/k8s/overlays/local/api-front-door.yaml). An ingress controller's
backend protocol is per-Service, so the bff's gRPC edge (bff, :50051,
h2c) and its HTTP edge (bff-http, :8085) are two Services over one
Deployment, and a path with no rule falls through to the / h2c catch-all:
not a 404, but an HTTP/1.1 request handed to an h2c backend, which fails
with a protocol error naming nothing.
- It is per-ROUTE, not per-authentication-tier.
PublicPaths()+HandlerAuthorizedPaths()+SelfAuthenticatedPaths()answer who may reach this without a bearer; an authenticated HTTP route appears in none of them. The generator unions the aggregates and every per-route declaration a bff-tagged build mounts. - It over-approximates for a path the bff does NOT serve. Identity-only paths are kept: a spare rule costs a 404, a missing one costs a protocol error naming nothing.
- That pricing INVERTS for a path the bff DOES serve, and this is the trap.
There, a rule makes the endpoint externally reachable, and for anything in
PublicPaths()that means exposure (/metricsis unauthenticated because in-cluster-only). Hence the fourth classification,servedButNotExternallyRouted(/metrics,/api/concepts*). "When in doubt, include" applies only to the previous bullet.
Two gates: TestFrontDoorPathsAreNotStale (make frontdoor-paths-check) and
TestEveryServerPathDeclarationIsClassified, which AST-scans component/server
for every func …Paths() []string and fails when one is classified by none of
the four maps. A route mounted through handleRoute with an inline path
literal and no *Paths() declaration is invisible to the generator, and
AssertUnauthenticatedSurface runs only when the node installs no
verifier, which the bff does. Declare new HTTP routes with a *Paths()
function. Do not hand-edit the generated block, and do not "simplify" the
generator back to the three aggregates.
gRPC-Only Endpoints
Everything below lives on MemqlService.Stream; cross-node proxying rides
AiForwardRouter.
| Category | gRPC Message Types | Handler |
| AI service-to-service | AiChatMsg, AiSuggestMsg | ai_handlers.go |
| Streaming transcription | AiTranscribeStreamStart / Chunk / End + AiTranscribeStreamDelta / Complete | ai_transcribe_stream.go -- multi-message flow keyed by request_id, forwarded BFF -> Agent via AiForwardRouter.ForwardContinuation. The one caller is MemQL OS's Ask hold-to-talk |
| Concepts API | ConceptsListMsg, ConceptsSubscribeMsg (+ follow=true -> ConceptsRegistryDelta stream, memql#4238) | concepts_handlers.go |
AI Integration
All AI operations go through a pluggable provider system (ChatAIProvider,
VisionAIProvider, TTSAIProvider, ChatStreamProvider) over OpenAI (chat,
vision, TTS, STT) and Anthropic (chat, vision). Provider records live in
dsl/providers/providers.memql.
Selection is not per-call: a call declares a LEVEL and one seam decides
(epic memql#5127) -- see Levels, policies and rules
and ai-routing.md. A prompt's
@defaultProvider survives as an EXPLICIT PIN that wins over every rule, which
is why it is refused at load when it names a policy.
A vendor call is paid by an ACCOUNT, and there are two kinds (design record
2026-11-21).
The CLUSTER'S account is workload identity federation, everywhere (epics
memql#4333, memql#5088): the engine presents the pod's projected Kubernetes
token and exchanges it for a short-lived bearer; a partial set of ids REFUSES
THAT VENDOR, naming both halves (the token file's path, which every Deployment
sets, does not count on its own). The cluster has no API key and never gets
one: TestNoVendorApiKeyEntryPoint (vendor_api_key_gate_test.go) fails the
build if any retired key env var or the retired key-setting builtin reappears
in a tracked source file. Read
that file rather than restating its list here -- the gate walks this file
too; vendor_api_key as a globalSecret KIND stays legitimate (the Shopify
connector seals its secrets under it).
anthropic-federation.md ·
openai-federation.md.
A PERSON'S API key is the other kind (api-keys.md):
Anthropic or OpenAI only, added in Settings > API keys behind execute
app:settings/apikeys, which EVERY predefined role holds (bring-your-own is for
everybody; a deny withholds it), in a person's own session and never in a run.
An organization-scoped role MAY hold it (auth.ScopedRoleMayUse: the one part
of Settings besides Access such a role is not barred from, owner decision
2026-11-22); like any authored role it holds it only when given it.
The section itself has no floor: a key's owner lists and manages it whatever
their role holds. It is
checked by listing the vendor's models (no prompt, no charge), sealed under
MEMQL_MASTER_KEY by integrations/vendorkeys, and never returned, logged or
sent across the mesh. Two rows, both client-unreadable and publishing NO graph
event: v1:router:vendorKey (what its owner decides) and
v1:router:vendorKeyState (what the engine observes, written under a per-key
write gate and ordered by the time of the evidence, which is when the call was
SENT). Only the vendorKey* builtins decide what a caller sees. A key's
owner never changes, for any writer (owner_held_write_guard.go), and
transferRowOwnership skips both rows: a leaver's keys stay theirs and stop
serving.
- Which account pays is decided per call, from rows read fresh, on the node
making the call (
component/router/accounts.go,integrations/vendorkeys/resolver.go). No person behind the call, or a synthetic actor: the cluster's account only. A person's authority borrowed for a visitor: never a key. A route or pin the acting person chose THEMSELVES: their default key, then keys lent to them (earliest added first), then the cluster's WHEN IT PAYS FOR THEM. Auto and everything else: the same order, counting only keys whose owner switched Auto on. "Themselves" is the credential, not the subject (auth.ChoiceIsThePersons): a choice made through an app session, a badge, delegated access or server code acting for the person is attributed to them and counts as no choice (ChoiceByMachine, stamped where the choice is made and carried on the run's rows). - An account failure moves to the next ACCOUNT for the same model before
the route moves to its next model; the chain carries both
(
<record>@key:<id>, then<record>@cluster). A rate limit or an outage is not about the account, and neither is the cost guard's own 402 (guardStopErrorType). A request that carries a key follows no redirect. - THE CLUSTER'S ACCOUNT IS NOT A POOL FOR EVERYBODY (owner decision
2026-11-22;
component/memql/vendor_account_cluster.go). Model access is bring-your-own. The cluster's account pays for the cluster's own work (auth.ActsForNoPerson) and for a person's calls only when that person holdsexecute app:settings/clusteraccount, seeded on the OWNER role alone and given to others in Users > Access. The person judged is the one the call is FOR, from their stored role, groups and grants (MemQLEngine.clusterAccountOpenTo): borrowed authority carries a stand-in role, and a visitor's call is judged by the person it borrows from. Asked only where the cluster has an account for the record, once per vendor per resolution, and again AT THE CALL: when<record>@clusterresolves, and when a plain record name does after a local model or an app failed (accountAtCall). A provider resolved once at start is resolved for nobody, which is the cluster's own work: the Library's picture description resolves per call for the uploader (callerVision,app/ai_call_sites.go). A registry with no gate installed gives the account to no person; the engine installs its own at bootstrap, and a test fixture says who may use it. - Text surfaces only take a key. Vision, speech, transcription and images
are the cluster's account or nothing, so the router asks the same gate for
them (
clusterAccountGated). EMBEDDINGS ARE NEVER ASKED: the memory space is the cluster's, one model for everybody. - A key's spend is METERED. Every ceiling and loop cap counts it; there is no exemption and no cap per key.
- Readiness is per person (
ProviderRegistry.VendorDoorFor):inferenceStatus.federationConfiguredis whether the cluster's own account is SET UP (the same for everybody),clusterAccountOpenis whether it pays for the READER, andkeyAccountis whether the reader holds a key that can pay.eligibleanddoorsOpencount a vendor only when one of the last two holds. - Two engine-only passes, each on one bff replica behind a lease:
vendorKeysDailyCheck(04:40, lists models with keys idle for a day) andvendorKeysOwnerNotices(every ten minutes: one email per fall to the key's owner, claimed under the key's gate before it is sent, no link in it). - API is the fourth built-in route (
route:api,component/memql/routes.go): the strongest vendor model at every job, edited and restored like Local and Apps, and it listsfederation:sources ONLY (ValidateBuiltinRouteJobs, asked inSaveRouteOverride). A route's vendor job is ready for a person when a record the selector offers at THAT level has an account for them (vendorServesNow, read fromVendorDoor.Payers), and "serves now" names the model and the KIND of account, never a key. A route cannot name which account pays (R5 of the design, not built).
A LOCAL cluster federates by pasted keys (design record
2026-11-21).
A vendor cannot fetch a k3d cluster's keys, but both accept them pasted in:
make federation-keys prints them, Settings > Vendors takes the ids, and
make up keeps the cluster's signing key across recreation
(~/.memql/k3d/<cluster>/service-account.key, a secret). The install wizard
still collects no AI credential and providerFederation skips satisfied.
Each engine process signs in to a vendor ONCE per identity token
(component/memql/ai_vendor_signin.go). Anthropic accepts a token once, so a
second signer in a pod is refused: memql provider-auth check reports the
engine's record and never signs in, and a new client of a vendor takes its
bearer from processVendorSignIn, never from a credential of its own. The
engine records EVERY vendor, usable or not, and the check answers from that
record alone: 0 only when the sign-in was accepted AND the vendor's API took
the bearer, 1 refused, 3 not set up on that node, 4 cannot say yet. Never run
against a vendor yet; the runbooks say what to record.
AI Endpoints (gRPC on MemqlService.Stream)
AiChatMsg/AiChatResult/AiStreamChunk-- chat completions (streaming + non-streaming)AiSpeechMsg/AiSpeechResult-- text-to-speechAiTranscribeMsg/AiTranscribeResult-- speech-to-text (batch)AiTranscribeStreamStart/Chunk/End->AiTranscribeStreamDelta/Complete-- streaming transcriptionAiSuggestMsg/AiSuggestResult-- carriesdomain;knowledgeis the one registered domain since the portal's were retired (epic memql#4984).
The AiSuggest registration IS the feature; test it -- an unregistered
domain reaches the user as "suggestions are not available on this cluster",
the same sentence a cluster with no provider gets (memql#4667). And
AiSuggestResult.usage is ABSENT when nothing was reported: zero and "not
measured" are different answers.
Cross-node proxying (BFF -> Agent) rides AiForwardRequest /
AiForwardResponse on NodeService.Stream. Handlers:
component/grpc/{ai_handlers,ai_transcribe_stream,ai_forward}.go, which emit a
short error id via generateErrorId() (ERR-{6 hex}), visible in slog output
as "errorId":"ERR-...".
Coding Agent -- the container-executor seam
cockpit-app is the seam's first and only inhabitant (epic memql#4358):
Claude Code or Codex, headless, on a machine the USER owns, through the worker
stream, with MemQL's tools reachable over MCP.
- The seam:
component/planner'sRegisterContainerExecutor(name, exec). Lookup keys on the part BEFORE the colon, socockpit-app:claude-codereaches the one registeredcockpit-appbackend with the app id on the suffix -- growing the app list is a value change, not a release.ValidateExecutorBackendrefuses an unregistered name at TASK CREATION rather than at dispatch. - The backend:
integrations/agent/worker/cockpitapp.go, registered frominit()under theagentbuild tag. Consent is the dedicated APP GATE (app_gate.go), notpreDispatchCheck: the machine's per-clusterapps.allowplus a routing policy or pin the owner made; the computer-use kill switch blocks only when explicitly engaged. A call with no owner never selects an app. Planner/bff calls reach an app throughAppCallForwardto the agent holding the machine's stream.
Local apps as execution surfaces (epic memql#4358)
Delegating a task to an app the user already pays for, on a machine they own. Full record: local-apps.md.
Transport is the worker stream; MCP is the back-channel. The stream the
cockpit opened outward IS the tunnel; each run gets a per-run credential and
the mcp.<domain> endpoint.
- The runnable app set is CLOSED in the engine (
claude-code,codex); unknown ids are stored on the registration and produce no routing label. - A machine is selectable only when BOTH
allowed(itspolicy.yaml apps.allow) andsignedIn, and measuredready. Cockpit checks on a schedule; only a Cockpit that predates the checks, which sends no word at all, stays selectable unmeasured. Selection is the Fleet router asked for theapp:<id>label. A session runs only on the replica holding that machine's stream; a machine on a sibling replica is SKIPPED, not failed. - A run is a SESSION, not a dispatch.
AppSessionStart / Chunk / Control / EndonWorkerService.Stream; chunkseqis monotonic and out-of-order or duplicate chunks are DROPPED. - Delegation is a PREFERENCE WITH A FALLBACK (
v1:worker:delegationPolicy): no allowed, signed-in, online machine means the task runs in-process. - An app that stops partway hands over; nothing else moves work that was done
(
component/memql/app_takeover.go). On the machine'sstop_reasonand a complete journal, the next ready app carries on with the record of what ran. - The back-channel credential's
subis the OWNING USER's id, so row authz applies to the app as to their browser; the surface pin plusrole=systemkeep it off every credential mutation and cluster-owner gate. Minted viaPOST /node/bootstrapwithtokenClass="app_session": the user must exist, TTL capped at 8h, read/query-pinned, session id as the token label. It carriesclass="app_session", NOTservice_account(memql#4857): the one machine class whose subject is a person, admitted to the Library's byte routes as that user;POST /sites/{id}/bundlesstill namesservice_account, so an app session cannot publish a site. NOT revocable (DB-free JWKS verify); the short lifetime, the cockpit deleting the MCP config at end, and renewal-in-place stand in. - Subscription spend is counted and does not burn the dollar ceiling
(
v1:router:call.billing+executionSurface): the DOLLAR ceiling EXCLUDES subscription tokens, the LOOP caps INCLUDE the call. Billing falls tounknownwhen the usage report or the subscription signal is silent.
The cockpit half lives in cockpit/; this repository fixes the protocol and
the engine side.
Workers (computer_use_headless / computer_use_embodied)
Agents drive the user's own machine: shell exec, filesystem, HTTP fetch, and
(under the computer-use build) mouse + keyboard + screenshot. The FALLBACK for
what the sandboxed Workbench below cannot do. The full write-up -- capabilities
and their expansion map, the WorkerService gateway and mql_wkr_ tokens, the
three-layer permission model, the router and its four strategies, the two label
maps, cross-node dispatch, row tier and borrowed authority, the Fleet operator
surface -- is in
feature-notes.md;
the runbook is
workers-runbook.md. Four rules reach
outside that write-up:
- Per-user routing, and NO machine id. The dispatch builtins take
requireLabels/preferLabelsand noworkerId(D4), so a hallucinated machine id is a failure mode this surface does not have. Labels match EXACTLY -- there is no "any value" form. onlineis DERIVED, never stored: unrevoked ANDlastSeenAtwithin 30s. Exactly two implementations,component/worker.IsOnlineandclients/os/src/apps/fleet/online.ts, held together byTestFleetOnlineWindowMatchesTheClients.- Consent is decided BEFORE routing, so routing only ever chooses among
machines already consented to;
refused_before_startis the cross-node re-pick predicate and the one wire field that must never be guessed. - Borrowed authority, and no internal-origin stamp.
component/worker's store runs every registration read and write underauth.ContextWithUserActorfor the token's owner, and is deliberately absent fromcall_origin.go's allowlist.
Workbench (workbench_use)
The default first-choice surface for HEADLESS agent work (files, shell, URLs) as a per-RUN sandboxed Linux working directory in the cluster; nothing on the user's machine is touched. Computer-use is the FALLBACK for what the workbench cannot do (macOS-only tooling, computer-use control, files already on the user's computer). workbench-runbook.md · workbench-production.md.
- Capability:
workbench_use, universal (injected into every role'slockedToolSlugs); no scope grants, no kill switch. - Tool:
workbenchHost, discriminated byaction(exec / fs_read / fs_write / fs_list / fs_stat / http_fetch), in a product DSL bundle; the wire path is theworkbenchDispatchHostbuiltin (dsl/workbench/builtins.memql) tointegration.workbench.dispatchHost. - The environment hint and the reroute (memql#4353).
workbenchDispatchHosttakes an OPTIONALenvironment { os, needs[] },needsfrom the closed setdisplay/docker/gpu/macos_tooling/user_files. A mismatch returns a typedenvironment_mismatchhaving run NOTHING; an UNKNOWN need isinvalid_environment_hint, so a typo can never send a call to somebody's laptop. Omitted means no hint; there is no default. On a mismatch the tool loop re-dispatches the SAME call to the fleet; onlydenied_no_per_task_approval/denied_by_scoperaise the consent card.needs-> scope/labels:integrations/agent/worker/scope.go. - Per-RUN workspace under
MEMQL_WORKBENCH_ROOT/{runId}/(default/var/lib/memql/workbenches/): lazy-provisioned, persists within a run, torn down on run terminal status byreleaseWorkspaceOnRunTerminal, whose terminal set has FOUR values becauseabandonedis terminal for a run. Row:v1:workbench:workspace,@rowAuthz(owner=..., clusterOwner),ownerUserIdstamped from the parent run's owner; arunIdthat does not resolve to a readable run is REFUSED (workspace_owner_unresolved), because a row written under a blank actor is readable by nobody (memql#4354). - Replica affinity (memql#4354). A workspace is a FILESYSTEM.
nodeIdnames the replica holding it and the peer picker prefers it. On node loss the orphan row is releasednode_lostand a FRESH workspace is provisioned: files are NOT migrated. - Modes. Cluster mode is the default: a dedicated
workbenchbinary hosts the workspaces, agent nodes route viaWorkbenchForwardRequest/ResponseonNodeService.Stream. Base setsMEMQL_WORKBENCH_REMOTE=1; the dialer needsMEMQL_WORKER_PEERS=workbench=<addr>. The remote flag is an ASSERTION: set with no reachable peer, a call is REFUSED (no_workbench_peer). In-process fallback is the flag unset, orMEMQL_WORKBENCH_LOCAL_FALLBACK=1under it. - Operator surface:
/fleet/workbenchesand/fleet/machines, live because thegraph.node.*events forv1:worker:registration,routingPolicyandv1:workbench:workspacecarry broadcast routing rules (component/node/routing.go); without them the list is correct on load and frozen after.v1:worker:invocationis excluded on volume grounds. - Routing preference: the agent reply prompt and the
workbenchknowledge domain (auto-attached byreplier.gowhen the tool list includesworkbenchHost) prefer workbench over computer-use and surface a "workbench can't do this" message rather than silently retrying.
Authentication
The in-house identity service (component/identity) runs as its own
node-type binary and owns magic-link auth, WebAuthn passkeys, enrolment tokens,
OAuth-style token endpoints (/oauth/token, /auth/refresh), the JWKS feed at
/.well-known/jwks.json, the public web UI (/login, /auth/complete,
/setup, /legal/*, /me/*) and PAT issuance (mql_pat_<...>). Other
binaries verify identity-issued JWTs locally via component/identity/verifier
(JWKS on a 5-min refresh and on demand for unknown kid) and never see the
private key. MEMQL_IDENTITY_VERIFIER_BASE_URL configures the verifier,
MEMQL_IDENTITY_BASE_URL the service.
- Magic links are device-bound and approve-on-click (epic memql#4300). The
requesting browser holds the
memql_mlcookie whose digest ismagicLinkRequest.bindingHash; a link only COMPLETES there, and a click elsewhere only APPROVES while the requesting tab polls. A session can only land on the device that asked for it.GET /auth/completewrites nothing; consume is a compare-and-swap under a Postgres advisory lock. signInPolicyonv1:identity:user(memql#4304):anyorpasskey_only, which disables sign-in LINKS (no row, no link, identical redirect, a mailed notice); requires an active passkey. Owners/admins can RESET it toanyoverIdentityAdminMsg, one direction only.- A new-sign-in email fires on every
authSessionrow (memql#4305), with no action link (an unauthenticated revoke link is a DoS handle). Refresh rotations never send it. - Passkeys are usernameless (memql#3407): EMPTY
allowCredentials, resolved by credential id alone (unique cluster-wide). RP id derives fromMEMQL_IDENTITY_BASE_URL, never the request Host; no client learns which factor ran. A sign-count regression is refused and audited. Revoke on/me/devicesis a SOFT delete; the credential id stays taken. - Enrolment tokens (
mql_enr_<43>, memql#3408): single-use, TTL'd, authorizing exactly ONE action (register a passkey as the named user).GET /enrollrenders; the ceremony presentsAuthorization: Enrolment <token>. - The admin web app is gone.
/admin/*keeps the sign-in pages and a410 Goneroot; the screens live in MemQL OS overIdentityAdminMsg(component/identity/adminops).DeployControlServiceexists only on the identity node; a bff FORWARDS the deploy RPCs overNodeService.Streamcarrying the caller as a verifiedForwardedAuthority(component/grpc/deploy_control_forward.go).
Authentication is ON by default everywhere. MEMQL_IDENTITY_ENABLED=false
is ONLY for troubleshooting: the node skips the verifier and admits every
stream as a synthetic local-dev cluster owner
(component/grpc/local_dev_stream_interceptor.go) with a loud SECURITY
warning and memql_auth_enabled pinned to 0. Never set it false in a cloud
cluster. Blanking MEMQL_IDENTITY_VERIFIER_BASE_URL is not the way to
disable auth; it fatals the node.
Two operator credentials, deliberately separate (memql#3519):
MEMQL_MASTER_KEY DECRYPTS; MEMQL_OPERATOR_KEY AUTHENTICATES the
Authorization: Operator <key> bearer that admits a stream as a synthetic
cluster owner. No fallback: an unseeded cluster refuses operator streams.
See docs/public/operate/auth/:
access-model.md ·
user-provisioning.md ·
identity-service.md ·
operator-credential.md ·
service-account-jwt.md
(class="service_account", #691: verifies on the BFF via JWKS,
read/query-pinned) ·
oidc-federation.md (Entra ID /
generic OIDC upstream, epic memql#4611: the email must be VERIFIED before it
can link, (issuer, subject) outranks email once it exists, exclusive
mode exempts the OWNER; a half-configured provider REFUSES BOOT) ·
recovery-key.md (the owner
BREAK-GLASS credential, epic memql#3958: mql_rec_<43>, bound to one owner,
one passkey registration, REFUSED while the owner still has a sign-in route;
redeeming spends it and mints an unclaimed successor).
DSL Tree Layout
The DSL tree is flattened per construct: every namespace gets one directory
under dsl/<namespace>/, and within it each construct kind is consolidated into
a single <construct>s.memql file (e.g. dsl/library/queries.memql,
dsl/identity/concepts.memql, dsl/providers/providers.memql). The flattened
tree is produced by
scripts/restructure-by-construct.
Authoring reference skeletons live under dsl/_reference/, one per construct
(_concept.memql, _logic.memql, _automation.memql, ...). Loaders read through Source(), which
routes through core/dslfs.
MEMQL_DSL_PATH — runtime product-DSL delivery
MEMQL_DSL_PATH mounts additional product-DSL domains from disk at boot,
so a product-agnostic engine image runs a product's DSL with no compiled-in
product code (#2472). dsl.MountRuntimeDomainsFromEnv scans the root for
product-domain sub-directories and registers each via
RegisterTree(domain, os.DirFS(<root>/<domain>)), the same call the embedded
tree uses. Layout mirrors the embedded tree, one directory per namespace:
$MEMQL_DSL_PATH/
<productDomain>/
memql.toml concepts.memql queries.memql mutations.memql ...
prompts/*.tmpl- Every domain declares its language line in its own
memql.toml(memql = "1.0",edition = "2026"); one at the root is never read. A domain with none, or one newer than the engine, refuses boot (memqlmigrate --rewrite=language-line -w <root>adds it). - Adds new domains only: a directory colliding with a core embedded domain is skipped.
- Fail-loud: the mounted tree loads through the same strict-boot gate as
the embedded tree (
MEMQL_DSL_ALLOW_SKIPSis the break-glass). - Directories beginning with
_/.are skipped (soft-disable / hidden).
DSL dependency tree
Each layer depends only downward; cycles are rejected at load time.
Concepts schemas + reserved intrinsics; the base of everything
|-- Shapes @row / @actor field projections (+ traits)
| '-- Specs signature-bound predicates
| '-- Queries concept + filter (specs) + projection (shapes) + args
|-- Mutations insert / update on rows
|-- Builtins Go-backed executors
'-- Providers AI vendor + model
'-- Prompts template + input schema
Queries + Prompts --> Automations (event -> side-effect) <-- Tools (AI-callable)
Prompts (@level) --> Rules (call metadata -> policy)
'-- Policies (an ordered chain of doors)
Roles + Capabilities --> @requiresRank / @requiresCapability (who may CALL)A trait is the one deliberately-unbound row predicate; policies are
provider selection only (caller-based authz / feature-gating decisions are
specs); a rule is the half a policy cannot express, because a chain
says WHERE to look and never WHICH CALLS it is for. Construct files live under
dsl/<namespace>/<construct>s.memql; dsl/policies and dsl/rules are CORE,
so a pack cannot mount them. An automation loads only from its domain's
automations.memql (memql#5437): one declared in any other file refuses the
load (construct_misplaced, dsl/construct_placement.go).
Argument resolution
All DSL constructs share one model for declaring inputs and reading them.
ctx is gone from the author surface entirely.
| Construct kind | Where args go |
| Query / mutation / logic / automation | args { ... } sub-block inside the body |
| Builtin / tool / prompt | Body fields directly — the body IS the schema |
args { ... } field syntax:
<name> <type> [@required] [@enum("a", "b", ...)] [@maxLength(N)] [@pattern("re")] [@minimum(N)] [@maximum(N)].
Describe a field with a /// doc comment on the line above it; @description
and @default are both rejected at load (memql#3336, #991).
| Name pattern | Source | Available in |
args.X | Caller-passed arg declared in args { ... } | every body |
actor.X | Resolved auth context (userId, role, identityId, isClusterOwner, primaryEmail, now) | every body |
now | RFC3339 timestamp captured at eval start | every body |
partition | Active partition for this call | every body |
config.X | Allow-listed config (component/config/policy_exposable.go) | every body |
row.X, row.id, row.concept, row.type, row.createdAt, row.createdBy | The row, through the lambda parameter a predicate names (filter row => ...) | a query's filter and refine, a spec or trait body, a trigger @filter |
A bare name is never a payload field: it is a lambda parameter, a reserved
root, a local or step name, or (when called) a predicate or catalog function.
The exception is a shape body, a path list where name is a payload field and
row.id an intrinsic.
For automations, the trigger payload is bound INTO the declared args { ... }
contract at fire time and validated (@required / type / @enum /
@pattern); a violation refuses the run (component/automations/args_binding.go,
memql#2352). The triggering event rides its own event envelope
(event.topic / event.kind / event.payload.<field>), forwarded to logic
as logic name(event: event); the logic declares event in its args block
and reads args.event.payload.<field>.
Declared and used, in both directions: an args field declared but never
referenced is refused at load, and so is an args.X a body READS but never
declares (memql#3626). Reserved engine names now, actor, partition,
config, trace are rejected as args fields and refused in argument
position at the call site; a repeated argument name (m(a: 1, a: 2)) is
refused too.
Retired author-side forms (all rejected at parse time). Every construct is
authored in the struct form. The parser refuses each retired shape and NAMES
its replacement, so the enumeration lives in the language reference
(memql.md) rather than here --
do not write them, and do not "restore" one when you see it in an old diff.
The families: receiver-function wrapping (func (Query) NAME(ctx any), which
survives only as the internal rewriter target the engine's parser consumes),
the @use* annotation family (replaced by file-top use imports),
@concepts(...) / @shape("name") bindings (replaced by the two-identifier
construct signature), @input { ... }, include in a shape body, and the
retired body forms of epic memql#5370 -- body { }, step blocks, the terse
=> logic automation header, steps.<id>, a bare argument read, partition=
on @trigger, the @schedule annotation and mutate as the mutation keyword
(it is mutation, D13). memqlmigrate --rewrite=bodies rewrites the body
forms; the step accessors (step("x"), input(), item(), index()) have
none. Only dsl/_reference/*.memql still shows these, deliberately, as
don't-do-this skeletons.
Retired expression spellings (edition 2026). Each is refused at parse,
wherever a .memql file writes it, naming its replacement and
memqlmigrate --rewrite=expressions, which rewrites it (in VS Code the
language server's Rewrite to edition 2026 quick fix makes the same edit).
The full list is memql.md
and parser.V1RetiredForms is the one copy of it; the shapes to recognise are
the when(args.x) { ... } guard and the ?. prefix, ; and , as
connectives, has and not in, the cond( / concat( / coalesce( /
exists( / len( / count(x) / contains(s, sub) function family, null,
a filter or @filter without its lambda header, a spec or trait body
written { return ... }, and $args. in a tool handler. The string a client
sends to Execute is the internal query form, which keeps its own grammar --
but it too refuses ; and , as connectives (retired_comma_connective,
memql#5439; parentOf(a, b) is parentOf(a || b)).
Levels, policies and rules
Three nouns decide every model call, and a call site names none of them but the first (epic memql#5127; ai-routing.md).
- A level is how much intelligence a call needs: a CLOSED set of four,
fast,strong,reasoning,embeddings.@levelis REQUIRED on everyprompt, embedded or bundle-mounted, and a Go call site with no prompt names its level in the request. Modality is never declared; it is derived from the call and interface-checked. A model name at a call site is a release every time the fleet changes. - A policy is an ordered chain of places to look, a closed grammar: a
provider name;
fleet:strongest/fleet:fastest/fleet:<modelId>;app:*/app:<id>/app:<id>:<model>;federation:cheapest/federation:strongest/federation:<providerName>;policy:<name>. The two vendor selectors choose among the records that DECLARE the level the call is served at (params { levels "strong reasoning" rank 900 },component/memql/provider_job.go; a rule's@levelmoves the call first): strongest is highestrankfirst, cheapest is lowest input plus output price first, ties by name. A record that declares no level resolves by name and both selectors pass it over; a badlevelsorrankrefuses the record at load.fleet:*is retired and refuses load. An app id is held to the engine's closed runnable set at LOAD (core/airoute/apps.go);app:*:<model>is REFUSED.policy:<name>is expanded at load and a cycle refuses load. The shipped set isdsl/policies/policies.memql. - A rule maps a call's metadata to a policy, first match in precedence
order.
@whentakes a closed key set (level,modality,prompt,role,actorRole,tag,touches), all present keys ANDed. Every shipped rule is@locked.
@when(prompt="agentReply", role="operator")
@level("reasoning")
@policy("localFirst")
@precedence(60)
@onUnavailable("degrade")
@locked
rule operatorReasoning { }roleandactorRoleare different questions (what is acting vs who is watching). An ABSENT@whenkey is no condition; a key written EMPTY matches only an empty value.- A precedence tie is a LOAD ERROR, naming both rules and files.
@lockedmeans three things, all enforced: evaluates before every unlocked rule regardless of precedence; re-read from the embedded tree on every boot; no runtime-authored rule may carry it or take a shipped name. Both registries REFUSE a duplicate name across the whole corpus.embeddingsnever degrades, at any@onUnavailablesetting (a degraded embedder answers in a DIFFERENT VECTOR SPACE).fastis the floor;reasoningwalks down tostrongtofast, andservedLevel/degradedare on every decision record.@maxLatencyMs,@maxTimeToFirstTokenMs,@preferredRoleandDefaultForRoleare REMOVED.
One seam, enforced by a build gate. Every model call builds a
core/airoute.ResolveRequest; a Go AST gate fails the build on a direct
provider-registry accessor (Entry / ProviderEntry / ChatProvider /
DefaultChatProvider / StructuredChatProvider / ChatStructuredProvider /
SuggestChatProvider / ChatStreamProvider / VisionProvider /
EmbeddingProvider) outside component/router and the registry. The
vocabulary lives in core/airoute because component/router imports
component/memql, where the call sites live.
Every resolution is a decision record. v1:router:call carries level,
requestedLevel, servedLevel, servedModel, servedEffort, degraded,
rule, policy, door, considered, touches, minContextTokens,
machineOwnerUserId, callerKind and cacheKind, read through
routerDecisionsRecent, never broadcast. considered is KEPT ON SUCCESS.
callerKind makes an empty userId an ANSWER (memql#5581: system is a sweep or seed, unattributed a Go call site that stamped no caller). cacheKind names the cache that answered: a hit is a decision with no provider call and REAL ZEROS for tokens and cost, ABSENT means a provider answered. One bounded queue, one writer; a full queue drops and counts. servedModel / servedEffort are
what the SURFACE REPORTED, EMPTY when it said nothing (epic memql#5391, D9).
A tool-needing call resolved to an app: door becomes a SESSION (epic
memql#5391, D7), door's fourth value beside local / app / federation:
the app takes the whole STEP, drives its own loop, reaches MemQL's tools over
MCP and answers once with no tool calls. The step records a childRunId; a
call carrying NO step is refused at resolution; a session winner's chain is
itself alone, so a failed session parks rather than becoming a silent paid
call. Every artifact a session produces is stamped producedBy
{app, model, effort, sessionId}.
Mechanism stays in Go. Door classification, provider availability, the
refusal codes, ai_guard.go / ai_guard_fleet.go and
component/work/budget.go are not authorable and no rule reaches them. The
two halves meet at one place: the federation hop asks the cost ceiling
before it is taken, and only when a local door preceded it in the chain.
There is no decision-policy tier. Auth / feature-gating / vendor decisions
live in Go (component/safety ships the risk×scope decision matrix) and in
specs (requiresOwner(actor)). engine.EvaluatePolicy and func (Policy)
do not exist.
Key Concepts
Authorization model
Per-row authorization is the only gate
(per-row-authz-audit.md).
Every query and mutation classifies as owned (filter on
row.ownerUserId == actor.userId), granted (relationship predicate gates
on actor.userId), admin (cluster-owner spec), or public (@public);
test/dslconformance/conformance_test.go hard-fails on a new unclassified
construct.
Row admission also gates SUBSCRIPTIONS (memql#4309): a graph.node.* event
reaches a stream only if the function admitting the row on a read admits it
for that stream's actor, and a concept that declares nothing admits everyone
on BOTH paths. A granted row arrives id-only with payload_omitted.
Non-graph kinds (TELEMETRY / MESSAGE / AI_STREAM / ALL) are
owner/admin-only at subscribe time (memql#4311).
@rowAuthz(owner="<field>", clusterOwner) is the owned tier with the admin
gate ORed in, not a new tier (memql#4312); a plain owner= tier has no
cluster-owner bypass, so declaring an operator surface plain-owned hides every
other user's rows from the operator. The write guard ignores the second
argument.
account="<field>" (epic memql#5165) is one more ARGUMENT of the owned
tier: it ORs "anyone whose group ties them to this row's account" onto the
admission, resolved per request from v1:identity:groupMembership and
v1:identity:group. It widens WRITES as well as reads, the field may be a
string or a string list, and its type is checked at load (the lowering is a
jsonb containment test, which would also match a map key). Developer rank and
above are standing members of every account-kind group as a RULE.
RANK (epic memql#4832) adds three more ARGUMENTS of the owned tier, not more tiers (four sites switch on the owned tier and a new tier value falls silently out of all four):
rankVisible-- reads widen to the owner OR anyone at or above the OWNER'S rank (D2,<=), excluding developer peers. Sharing an account also does not admit another developer's private rows; the account owner retains oversight. SQL pagination and subscription gates use the same exclusion.rankStrict-- writes widen to your own row or one owned by someone STRICTLY below you (D3), and WITHDRAW the cluster-owner write escape. RequiresrankVisible.unowned="<role>"-- a PRESENT but EMPTY owner is the deployment's row; this names the rank from which it is readable. An ABSENT owner key stays denied.
The owner's rank is resolved per request, never stamped on the row. The
SQL half pushes down as an in list (a post-filter-only rank term makes a
page of peer-owned rows read as EXHAUSTION). An unresolvable rank floor
DENIES. D4: MaintenanceActor, the seed materializer, an automation's system
actor and borrowed authority carry AccessContext.Unranked, or every sweep
and boot seed would become a peer-write and stop.
rankFloor="<role>" is a READ floor, legal beside a bare clusterOwner
(memql#5216) and on the owned tier (design record 2026-11-24,
v1:pipelines:run): reads widen to every caller at or above that rung, writes
never, and a role scoped to one organization never passes it.
@requiresRank("<role>") is the SURFACE half (D6): an actor-rank FLOOR on
a query / mutation / logic / tool (on a tool it judges the person the call is
for, and decides what is listed to them, memql#5438), validated at LOAD and
enforced at execution. It gates WHO MAY CALL; @rowAuthz decides WHICH ROWS
come back. MemQL OS's per-surface requires: "app:<id>" (epic memql#5289) is
its mirror, not a stand-in.
@requiresCapability("<verb>", "<resource>") is its SIBLING (epic
memql#5166, D11): validated at LOAD against the five verbs and the seeded
resource kinds, enforced on the direct call and on every plan that EXPANDS the
construct. A rank is a FLOOR and a capability is a GRANT: a role may rank
above another and hold fewer verbs (developer did on principal until
2026-11-25, design record developer access). Declared
together, both must pass. requiresAdmin, requiresOwnerOrAdmin and
requiresDeveloperOrAbove are DELETED. @requiresCapability is legal on a
BUILTIN (epic memql#5288), whose executor asks itself; @requiresRank is not.
Apps are resources (epic memql#5288, D7): read app:<id> opens an OS app,
execute app:<id>/<part> is a named part, and a part EXISTS by being seeded on
a role in dsl/rbac/seeds.memql (a misspelled part refuses boot). The OS
registry names resources, never floors (epic memql#5289, D10): manifests,
floored sections and widgets carry requires: "app:<id>" /
"app:<id>/<part>", the shell reads effectiveCapabilitiesForActor() at
sign-in (again on focus and after a grant written in that browser) and draws
a surface when the set holds read on its name. holds() in
clients/os/src/system/roles.ts is the one predicate, accessEpoch the
reactivity signal, roles: { min } is REFUSED, and
TestOsRegistryRequiresMatchTheAppSeeds pins every requires: to a seeded
read app:* row (module lists are needs:). A missing PART hides its
control; a call that reaches the engine anyway is refused
capability_not_held:-prefixed. Settings > Access
(requires: "app:settings/access") writes and reads back grants.
One role ladder, and the shell holds none of it (D1): v1:rbac:role
carries rank plus aliases (writer/reader alias user/viewer), the OS
reads activeRoles, and component/auth/role_ladder_client_parity_test.go
fails the build on a client ordering of its own. developer (300) outranks
admin (200).
A ROLE IS A ROW, AND THE ROWS ARE THE TRUTH (epic memql#5166). A runtime
CATALOG loaded from v1:rbac:role and v1:rbac:capability at boot
(component/memql/rbac_catalog.go) is the ONE resolver every Capable call
reads, reloaded on both concepts' broadcast events; rankLadder reads the
same structure. The compiled capabilitySets map is the seed's MIRROR,
answering only before the rows are readable (TestSeedMatchesCompiledMirror).
An unknown slug holds nothing and ranks 0. v1:identity:user.role,
invitation.inviteeRole and delegation.roleCeiling are STRINGS carrying a
catalog slug or alias. roleCreate / roleUpdate / roleDeactivate author
one under rank-below-creator, rank-not-taken, grants-a-subset-of-the-caller's
and predefined-immutable; auth.MayAssignRole is the ONE rule both assignment
seams call. access-model.md.
Account hierarchy (2026-11-26): each primary or client account has one
owner, named by accounts:account.ownerUserId. accountAccessUpdate transfers
ownership atomically; ordinary role assignment and invitations cannot add an
owner. The canonical account membership carries Developer, Admin, Member or
Viewer. Account managers manage only lower roles, and client managers distribute
only apps within the primary owner's account ceiling. accountAccess supplies
the reduced management roster. See the
design record.
A GRANT is what a person or a group holds over and above their role (epic
memql#5287): v1:rbac:grant, one allow / deny per (verb, resource),
resolved by auth.CapableFor(ctx, subject, verb, resource) at every gate --
most specific wins across role, group and user, deny wins within a level, read
per request and never cached. Written only through grantSet / grantRevoke,
audited as targetType: grant
(grants).
The partition dimension is retired (#56): the partition wire field is
reserved in component/grpc/memql.proto, and partition="*" on a trigger is
refused at parse (trigger_partition_retired, epic memql#5370).
Concepts
Schemas for nodes (like tables in SQL).
concept agent {
ownerUserId string @required
// ...
}Relationships carry two independent axes (memql#3652):
@relationship(type="references", as="respondsAs", field="agentId", target=agent, direction="outgoing")type— what the ENGINE does with the edge. A closed set:parent,owns,createdBy,alias,equals,contains,references. It drives id canonicalization, traversal and the collection/reference node-type invariants; an unrecognized value refuses boot, namingas=as the way out.as— what the edge MEANS to the domain (assignedTo,repliesTo). Open: any lowerCamelCase identifier, validated for FORM only. Optional. Never add a membership check toas; a test guards it (memql#3655).
field may be a dotted path into a nested object block
(field="lineage.originatingPlanId", memql#3672); it must be declared on the
concept -- on the TARGET concept for direction="incoming". Reference:
memql.md and
dsl/_reference/_concept.memql section 11.
Nodes
Individual records with time-series history. IDs are
{concept}:{shortId}:
v1:common:agent:a9f3b7c2...
v1:cluster:node:bff-localAutomations
Automation cycles require a disproving trigger filter or @loop; @mode
controls concurrent runs per process. Prefer before-write bodies for
triggering-row adjustments. The default chain depth cap is 16
(loop protection).
@trigger keys off an event name plus the target concept, and the
automation's args { } block is the contract the triggering row's payload is
bound into:
/// On to-do creation, promote it into the Library Records lens.
@trigger(event="node.created", concept="v1:todos:todo")
automation indexTodoOnCreate {
args {
id any
ownerUserId any
title any
}
persist := mutation createArtifact(
sourceConceptRef: args.id,
ownerUserId: args.ownerUserId,
lens: "record",
kind: "todo",
source: "agent_generated",
title: args.title ?? "Untitled to-do",
live: false
)
}A time-driven automation uses @trigger(schedule="0 */10 * * * *") (six-field
cron, leading seconds); the @schedule annotation and partition= on a
trigger are refused at parse. An automation's statements are the body language
Logic describes, plus publish, automation and action calls,
which only an automation makes.
Functions
Reusable query and mutation functions, in the struct form.
Concept binding lives in the construct signature: query <Concept> <name>,
mutation <Concept> <name>, seed <Concept> <name> and
shape <Concept> <name>; the loader resolves the name through the file-top
imports, and one that does not resolve refuses the load naming the import to
add (signature_concept_unresolved, memql#5433). Cross-file dependencies go
through file-top use imports (shapes, traits, specs, mutations, queries,
logic, builtins, prompts, providers, tools):
use worker.concepts.{ registration }
use worker.shapes.{ registrationFull }
use common.traits.{ isActiveRecord, isNotDeleted }The dotted path maps to a file on disk (worker.concepts →
dsl/worker/concepts.memql). A filter reads the bound concept's row through
its lambda parameter; a mutation body writes it through the bare insert { }
/ update { } block.
Where the rules below are enforced (memql#3629, memql#4051). The CONTRACT gates (retired operator forms, the
row.namespace rules, the per-row authz bucket, the admin-gate composition rule, the cross-namespace import rule) run insideMemQLEngine.Init, land on theLoadReport, and are refused by strict boot (MEMQL_DSL_ALLOW_SKIPSis the break-glass) -- which is what covers a product bundle atMEMQL_DSL_PATH;cmd/memqllintruns the sameInitoffline. House-style gates stay test-only. Write a new gate againstdslgate.ScanFiles, which takes the whole corpus.
Canonical filter-clause syntax (edition 2026; the parser refuses every
retired spelling naming its replacement, and MemQLEngine.Init lowers every
filter against the tier manifest, so a filter that cannot push down refuses
the load):
- A filter is a lambda over the row:
filter row => row.status == args.status && isActiveRecord(row). Every field goes through the parameter -- payload properties and intrinsics (row.id,row.concept,row.type,row.createdAt,row.createdBy,row.provenance.<leaf>) alike. A long filter continues on lines opening with&&or||. - Sort keys keep their string form and the
row.namespace for intrinsics --sort "row.createdAt", "desc"; payload sort keys stay bare;provenancehas no sort form. An authored key must name a declared field or a sortable intrinsic, a direction isasc/descin any case (sort_key_unknown/sort_direction_unknown), and a clause is written once (query_clause_duplicate; memql#5429). - One boolean grammar:
&&,||,!and parentheses (precedence); no truthiness, so a condition must be boolean. - Membership is
v in list. Prefix selection isrow.<field> startsWith <prefix>(memql#4208): a string literal, a list of them, or anargs.<field>resolving to either; an EMPTY list and a BLANK prefix match nothing. - An optional argument is guarded by an ordinary predicate:
(args.x == nil || row.f == args.x)under&&,(args.x != nil && row.f == args.x)under||; the guard reads no row and folds to a plan constant. - A missing field, JSON null,
niland""are one unset value in==and!=, and!=is null-safe (absent values). - Specs and traits are applied to their receiver:
isActiveRecord(row),requiresOwner(actor). Where a trait covers the predicate it is mandatory; the conformance test rejects the inline comparison.
Annotations in the args block: @required; @enum("a", "b", "c") (string
literals only -- express a small numeric set as bounds plus a UI that offers
only the members); @maxLength(N); @pattern("re"); @minimum(N) /
@maximum(N), INCLUSIVE numeric bounds (memql#4522). @description is not
valid on an args field (the /// doc comment is; a tool / prompt /
builtin field keeps it). @default is not valid on an args field nor on
a concept field (epic memql#5375; neither was ever applied on insert); apply a
default in the body with args.X ?? <default>, the only mechanism that fills
a value. It stays on a tool / prompt field (a builtin field refuses
it as misplaced), where the body IS the schema handed to the model and the
value must be a literal of the field's type (memql#5430). a ?? b ?? c
returns the first operand that does not fall through. ?? is
BLANK-coalescing: it falls through on an empty or whitespace-only string as
well as absent/null (false / 0 / [] / {} are kept), so a deliberately
cleared text field gets the default written back
(authoring-rules.md §28; @noUnset
is the targeted opt-out).
Queries:
use worker.concepts.{ registration }
use worker.shapes.{ registrationFull }
use common.traits.{ isActiveRecord }
@description("Get a user's registered machines")
query registration registrationsForOwner {
args {
ownerUserId string @required
}
filter row => row.ownerUserId == args.ownerUserId && isActiveRecord(row)
shape registrationFull
}Mutations:
use library.concepts.{ folder }
@description("Create a Library folder")
mutation folder createFolder {
args {
folderId string @required
name string @required
}
insert {
id: args.folderId
name: args.name
status: "active"
createdAt: now
createdBy: actor.userId
}
}update { id: ..., ... } is the partial-update counterpart
(read-merge-validate-write). Exactly one insert OR update block per
mutation.
Logic
A procedure an automation or another logic calls. args { ... } declares its
inputs, and its statements follow, the last of them a return. The
one-statement form is the common case:
/// Pure decide for the workspace-release sweep: every v1:workbench:workspace
/// of the updated run.
logic releaseWorkspaceOnRunTerminal {
args {
event object!
}
return query workspaceForRun(runId: args.event.payload.id ?? "")
}A construct call names its kind and its arguments -- query workspaceForRun(runId: ...),
mutation createLibraryFolder(folderId: args.folderId, name: args.name). The
object-literal form name({ k: v }) is refused, and the bare-name pun
(logic decide(event) for event: event) is retired.
A logic and an automation share one body language (epic memql#5370):
name := <call> binds, if / for / switch / parallel / return,
trailing retry(n) and on error continue. Statements run in the order
written; nothing is reordered by dependency, and there is no
ctx.output = .... A logic may call queries, mutations, logic and builtins
and ends with return; publish, automation and action calls are an
automation's. Full language: memql.md.
Prompts
AI prompt templates with input schemas and default providers. Struct form; the
body is a bare input-schema field list, no @input wrapper. Logic prompts
(routing / suggest / classification) use the structured-output path
(ChatStructuredProvider.CallChatStructured); prose prompts use regular chat.
@description("Generate an agent reply for a space")
@defaultProvider("chat54Mini")
@templateFile("agentReply.tmpl")
prompt agentReply {
space object @required
history []object
spaceContext object
}Providers
AI provider configurations (OpenAI, Anthropic -- the only supported vendors). Base providers carry vendor-level auth + type.
@base
@vendor("OpenAI")
provider openai {
auth {
identityProviderId env("MEMQL_AI_OPENAI_IDENTITY_PROVIDER_ID")
serviceAccountId env("MEMQL_AI_OPENAI_SERVICE_ACCOUNT_ID")
identityTokenFile env("MEMQL_AI_OPENAI_IDENTITY_TOKEN_FILE")
}
}
@description("OpenAI GPT-5.4 Mini -- balanced cost/latency chat")
@extends("openai")
@model("gpt-5.4-mini")
provider chat54Mini {
params {
levels "fast"
rank 340
contextWindow 272000
maxCompletionTokens 16384
inputCostPerMillion 0.75
outputCostPerMillion 4.50
}
}A vendor text record says what it is FOR, and the file's own header says
how its numbers are kept (read from the vendors' pages on a named day, never
from memory): levels, rank, the price, and a contextWindow that is the
prompt size the one price is true for. A record name is never removed
(bundles pin names): a model its vendor shut down is repointed and declares no
level. A Claude record for a current model says structuredOutput "format",
because Claude Opus 5.5 and Sonnet 5.5 refuse the forced tool choice the older
records use (component/memql/ai_anthropic_structured.go), and keeps
maxTokens under 21,333, above which the vendor's SDK refuses a call that
does not stream. The format takes closed objects only, so an open one (a map,
or no declared properties) is REFUSED naming the field, never closed
silently. A reply a Claude model declined is an error, not an empty
answer (ErrModelDeclined, stop reason refusal; also a structured reply
cut off at the output limit): the route's next source serves and the decision
line reads model_declined.
@disabled (the lifecycle flag shared by functions / builtins / prompts /
specs / seeds) skips the provider at load -- not registered, no auth
resolution, zero warnings -- while keeping it in the tree; on a @base it
propagates to every child. Dependents degrade gracefully (a policy routes via
its @fallback, a prompt falls back to the default). @enabled is RETIRED
(epic memql#5375) and refused at load naming
memqlmigrate --rewrite=attributes. @disabled means "not active right now",
not deprecated or exempt from refactors -- that is the separate @deprecated
axis (component/language/ast/ast.go, AttrEnabled / AttrDisabled).
Shapes
Reusable data projections. Each shape declares its kind via @row and/or
@actor (at least one; both allowed). Each path becomes a template entry keyed
by its terminal segment.
Row shapes project a concept's payload + row intrinsics, bound by the
signature shape <Concept> <name>:
use library.concepts.{ folder }
@description("Folder summary card")
@row
shape folder folderCard {
row.id
name
description
row.createdAt
}Actor shapes project the engine envelope and carry no signature concept.
Closed field set, enforced at load: actor.userId / actor.role /
actor.identityId / actor.isClusterOwner / actor.primaryEmail /
actor.now. Bare config.<key> is the config read; shapes do not project it.
@description("Actor identity envelope")
@actor
shape actorEnvelope {
actor.userId
actor.role
actor.identityId
actor.isClusterOwner
}Mixed shapes carry both. No composition: include is REJECTED at load;
repeat the paths, or drop the body and take the default projection. Every
body path is checked at load: a bare payload property must be a declared
field of the bound concept, the concept must resolve (an ambiguous bare name
disambiguates through the shape's own domain), two paths may not collapse onto
the same terminal key, and the declared kind must match the body. Shapes have
no inputs and no return.
Specs
Atomic boolean predicates, signature-bound (epic #2281):
spec <boundName> <name> = row => <predicate>, binding exactly one shape XOR
concept resolved via the file-top use import. The binding picks the strategy:
- Row-specs bind a concept or a
@rowshape and compile into a SQLWHEREfragment. - Context-specs bind an
@actorshape (the only gateway to the auth envelope), takeactor, evaluate in-process and are applied to the caller:requiresOwner(actor).
The parameter reads only what the binding projects. A trait is the one
deliberately-unbound row predicate (fields validated at the call site).
use worker.concepts.{ registration }
@description("Matches revoked machine registrations")
spec registration isRevokedRegistration = row => row.revokedAt != nil // concept-bound row-spec
use common.shapes.{ actorEnvelope }
@description("Caller must hold the owner role -- the rollback gate (#1876)")
spec actorEnvelope requiresOwner = actor => actor.role == "owner" // @actor-bound context-spec
@description("Matches records with active==true field")
trait isActiveRecord = row => row.active == true // unbound cross-concept traitThere is no ctx envelope; the { return <expr> } body is retired and refused
with memqlmigrate --rewrite=expressions as the fix. Caller-context checks
use specs, not policies: author the predicate as a context-spec in
dsl/<namespace>/specs.memql and apply it to actor in the filter.
Tools
AI-callable tool definitions. The body is a list of input-schema fields
(@required, @default, @enum, @description).
@description("Search for users")
@handler(type="query", query="paginate(query searchUsers(active: args.active), args.limit)")
@executionTime("fast")
tool searchUsers {
active boolean @description("Filter by active status")
limit integer @default("10") @description("Max results to return")
}A tool declaration is CHECKED at load, fail-loud:
@handlerargument names are closed (type,name,query,url,method) andtypeis required.@rateLimitand@scopesare RETIRED (epic memql#5375: stored, advertised and enforced nowhere).@allowedRolesis DEPRECATED (memql#5438, refused from 0.26): it mixed the agent's role and the person's. Write@requiresAgentRole(...)(which agent calls, held tov1:agents:agent.role) and@requiresRank(the person);memqlmigrate --rewrite=allowed-rolesrewrites it.- The handler is validated at load and a tool must carry one. A query
handler is ONE construct call, or that call inside
paginate(...), whose arguments readargs.<name>; a raw filter or the retired$args.placeholder refuses the load. A webhook's url is one expression.@clientExecutionis REFUSED at parse (it went with the conversational product, epic memql#4988). - The handler's TARGET is resolved against the function + builtin registry
at boot (
tool_handler_resolution.go). A builtin is reached through@handler(type="function", name="<builtin>"); there is no"builtin"type. Every field the builtin REQUIRES must be a tool field too (tool_handler_arg_undeclared, memql#5436). - Field types and field annotations are closed sets. An unknown type is
refused rather than emitted as
"string", and a@defaultmust be a literal of the field's type (tool_default_type, memql#5430).
Integration Capabilities
Go-backed operations callable from the DSL via @executor("integration.X.Y").
The body's field list is the builtin's input schema.
@description("Run one command on a per-run workbench workspace")
@executor("integration.workbench.dispatchHost")
@args(profile="object")
builtin workbenchDispatchHost {
runId string @required
action string @required
command string
}Core integrations (registered via the plug-in system): agents, auth, database,
deployversion, email, embedding, files, azureblob (as storage),
harnessRecall, identity, knowledge, library, rbac, router, shopify,
similarity, timeutil, vendorkeys, workbench, workTrace, plus node-type-scoped
ones (agent, stt) wired in app/integrations_*.go. training is a product-repo pack.
shopify is a CONNECTOR, the reference implementation of
component/memql/sync.Connector (epic memql#4389): it owns one external
system's data, its model is GENERATED from that system's schema at a pinned
version (cmd/shopifyschema -> dsl/shopify/generated/), and its five verbs
return MirrorWrites for the runtime to apply. Read
integrations/CLAUDE.md before writing a second one;
runbooks: shopify-connector.md,
shopify-storefront-checklist.md.
Extension Points
Three ways to extend MemQL, in preference order:
- DSL files (
.memql) -- always the first choice. - Self-registering plug-ins -- Go integrations that call
memql.RegisterPlugin(name, factory)frominit(), receiving a narrowPluginContext(Logger, Engine, BunDB getter, ResolveVisionProvider, ResolveEmbeddingProvider, partition/variable resolvers). Build tags on the calling file control which binaries include the registration (component/memql/plugins.go). - Explicit
app/wiring -- for first-party integrations whose dependencies don't fitPluginContext(agent, stt), inapp/integrations_*.gowith build tags.
Event routing is also plug-in-registerable: node.RegisterRoutingRule(...)
from init(). Forwarding is default-deny -- block rules first, then forward
rules, and an event matching neither stays local. There is no
concept-ownership registry: which node does a concept's work is decided by
routing rules plus which binary's build tags compile the subscriber.
MemQL Sense (Language Intelligence)
Language service for .memql files, exposed via gRPC on MemqlService.Stream:
Tokenize (semantic tokens), Complete (context-aware autocompletion),
Diagnose (lexer / parser / semantic errors; given the file's path under the
DSL root, also Lower's lower_* load refusals, memql#5434), Hover (symbol info) and
SignatureHelp. Package: component/memql/sense/ -- pure Go, no gRPC
dependency; handlers in component/grpc/sense_handlers.go.
Data origins -- Mirror, Origin, Native (epic memql#4378)
MemQL is the origin of what it owns, a faithful mirror of what it does not, and every concept says which. Two declarations, three states, and deliberately no "shared":
| State | Changes made at | Copies elsewhere | Writable here |
| Mirror | an external origin | MemQL | no -- read-only by construction |
| Origin | MemQL | external mirrors, synced outbound | yes, and it propagates |
| Native | MemQL | nobody | yes |
@origin("shopify") concept product { ... } // mirror
@origin("memql") @mirroredTo("shopify") concept creditLimit { ... } // origin
concept plan { ... } // native"Read-only by construction" is literal, and STRICTER than the row-authz
write guard. executeWrite refuses every write to a mirror concept that does
not come from the connector its @origin names (mirror_write_refused{origin}
plus an audit line), internal origin and cluster owner included. A mutation
bound to a mirror must be @serverOnly
(TestMirrorConceptsHaveNoClientReachableMutation).
Connectors are named actors, not a bypass. auth.ConnectorActor(name) is
admitted to the concepts whose @origin or @mirroredTo names it, regardless
of tier, and to nothing else; no request can mint one (RoleConnector is
outside ValidRoles() and the rank model). A connector is an integration
implementing component/memql/sync, not a fourth extension word.
Registration has two halves. sync.Declare(name) from an init() says
this build serves the connector; sync.Bind(c) attaches the implementation
later, because MemQLEngine.Init runs BEFORE integrations are wired. An
unresolvable name refuses boot: a mirror nobody fills reads as an empty
catalog, silently. data-origins.md.
Which account a row belongs to -- @belongsTo
Every concept says whose its rows are, and a reader asks the declaration,
never a field name (first piece of the accounts program; design record
2026-11-12,
reference memql.md).
The field is always accountId.
@belongsTo(account) concept note { accountId string ... }
@belongsTo(account, via="goalId") concept run { ... } // follows its parent
@belongsTo(account, via="storeId", parent="v1:shopify:store") concept review { ... } // a bare id with no @relationship
@belongsTo(account, shared) concept skill { ... } // no account = the cluster's own row
@belongsTo(account, stated) concept campaign { ... } // its own mutations name the account
@belongsTo(cluster) concept node { ... }- Engine-managed means account-scoped and not
stated(BelongsToDecl.EngineManaged). The engine fillsaccountIdon those inexecuteWrite(component/memql/account_stamp.go): the parent's account, else the call's account on a create (component/memql/call_account.go), else nothing. It never defaults toselfand never changes a recorded account: a child whose parent has no account yet waits for it. Astatedconcept is never touched; the organization rules (organization_ownership.go) stay in charge of theirs. - Recording is not sharing.
@belongsTorecords;@rowAuthz(account=...)is what opens rows to an account's members. No read changed. - A new concept needs one.
TestEveryShippedConceptDeclaresBelongsTo(test/dslconformance) fails the build on an undeclared concept indsl/,packs/ordeploy/fleet/dsl. A bundle's undeclared concept still loads: one warning at load,memql_dsl_belongs_to_undeclared, and amemqllintwarning. Aviathat leads to a cluster-wide concept, an unknownparent=or a cycle refuses the load. - Recording starts behind a one-way switch, the reader handshake on
account_stamping_storage/account_stamping_readers: off until every node that has not stopped advertises, because an older engine refuses to update a row carrying a field its schema does not declare.MEMQL_ACCOUNT_STAMPING_ACTIVATE=falseon EVERY node holds it. Tests run with it off; one that wants the stamp callsSetAccountStampingEnabled(true). - Existing rows are assigned by a background job behind the same switch
(
component/memql/account_assignment.go): newest version only, in place, no event, parents first, progress inaccount_assignment_progress, and what it will not guess inaccount_assignment_conflict. - Readers match both spellings of the id. The stamp writes the bare id; a
concept with an authored
@relationshipon the field stores the canonical one.
Account export, and moving rows between accounts
An export is one checked file of everything one account holds, and what goes into it is decided by declarations, never by a field name (second piece of the accounts program; design record 2026-11-12, runbook account-export.md).
- Three declarations decide a kind's part in a file.
stays="signin"/"transit"/"machine"on@belongsTokeeps a kind's rows on the installation.@bytes(under="library/{ownerUserId}")on a field says the field names bytes and WHERE that row's bytes live;treeis a tree of objects,countedis sized and never read.@secretNamenames a secret. A@secretfield never travels, at any depth. A component with tables of its own registers a hand-over (accountexport.RegisterHandOver). - A place has to tie the bytes to the row. A place needs a placeholder,
and a placeholder is the row's
{id}or its@rowAuthzowner field (countedfields are exempt). A reference outside the place is recorded as refused and never read. This iscore/librarykey's rule, declared. - One reader says whose a row is (
component/memql/account_rows.go): the row's NEWEST version names the account. It decides from index columns and never reads a payload per row: payloads average several KB, are stored out of line, and a read per row of an account is a read in every chunk. Measure a new account-wide read on a table shaped like a real one before trusting it. - A run is one snapshot. One export runs at a time on an installation: an
agent node claims it (
integrations/accounts/export_runner.go), reads everything in one REPEATABLE READ transaction, counts each kind twice, streams to blob storage under a key of its own attempt, reads the object back and checks it. The passphrase is shown once and cleared at every final state. - Acts need a person. Starting, cancelling, downloading or removing an
export, and moving or placing rows, ask
auth.RequirePersonSessionas well as their capability (execute app:accounts/export,execute app:accounts/move). - A row's children follow it, and the assignment job carries them. A change
of a row's account is recorded (
account_row_movesfor a person's explicit change,account_follow_tasksfor every change), and the job gives a row whose parent left its account the parent's account as it stands. Neither record is ever deleted: a record carries only rows older than the moment the job first read it (seen_at, never the record's own time: a row written while the change was uncommitted was filed by the old account), and a child's ownaccount_row_movesline is what keeps a person's decision about it. Nothing locks ordinary writes: a version appended by a write that read the row before it moved is repaired by the job's next pass. campaigns.sendJob.campaignAccountIdis not a copy ofaccountId. It is the account a send was queued for, which the send worker compares at send time. Do not retire it.- A concept with no
@belongsTois in a deprecation window (concept_belongs_to_undeclared), and an export refuses to run while one is loaded.
Infrastructure concepts
Field inventories live in the .memql files; this is only what the schema
does not say.
- Platform (
dsl/platform/concepts.memql) --site, a hosted web surface and "deployable" (memql#4344): the edge resolves the requestHostto one of these rows and serves itsbundleRef, which names only that site's own versions (memql.SiteNamesItsOwnBundle, on the write and at the edge, no actor exempt). A user's hostname is<slug>.<domain>against a reserved set DERIVED fromfrontdoor.Roles()+ the OS shell. Android / iOS / macOS have NO enum values; they are a written-down TARGET shape (epic memql#4885), reporteddeployable_target_not_offered(deployables.md).package/packageDeploymentare the SOURCE and its append-only run timeline (packages.md);sourceCredentialis the personal token a private source fetches under, sealed once server-side and resolved under the package owner's actor (someone else's credential resolves zero rows:credential_not_found). There is no cluster-wide source credential. A source credential and a source connection never change owner, for any writer (owner_held_write_guard.go): a transfer moves a leaver's packages and leaves their source access with them, so a handed-over package stops fetching until its new owner selects a connection of their own.siteAccessCode/siteAccessSessionare a deployable's access codes and the visits they opened (site-access-codes.md): the part isapp:deployables/access(owner and developer), both concepts are@serverWritten, publish no graph event and are unreadable by any client except through the sixsiteAccess*builtins that pass the part and the organization gate, and only a digest is stored. AlsoglobalSecret/globalVariable,outboundRequest/inboundRequest,missingCapability, anddataOrigin(a VIRTUAL projection, never persisted).globalSecretandpartitionSecretdeclare plain@rowAuthz(clusterOwner): the ROW is the cluster owner's, and a VALUE is read only throughResolveSecret/ResolveSystemSecret, whose lookup runs as the deployment whatever context it was handed (secretReadContext,component/memql/engine_variables.go). A writer that is not a cluster owner authorizes its caller, then stamps internal origin for the one write (the two secret concepts).globalVariableandpartitionVariabletake the same WRITE rule and declare no tier: every signed-in caller, and engine code holding no identity, reads them, so only writes are held (component/memql/platform_variable_write_guard.go). A settings surface for anyone below the cluster owner is a capability that derives the row's name itself (the two variable concepts).sourceCredentialis server-written: without internal origin a row is not created and nothing but its revocation changes, whatever construct or raw literal the write arrives through (component/memql/platform_source_credential_write_guard.go). - Library (
dsl/library/concepts.memql) --artifactis a thin INDEX row owning no content (memql#693);fileis the only backing row with bytes (memql#4340);fileChunkholds its embeddings. All three declare@rowAuthz(owner="ownerUserId", clusterOwner); the index'ssourceenum is the UNION of every backing concept's (library.md). Archive is a soft delete and RESTORE its inverse (memql#4784), as a CLIENT-DRIVEN PAIR (a mirror ofarchiveFileOnArtifactArchivewould close a cycle).file.linkState(epic memql#4783):syncedis stamped on any upload naming(uploadedFromWorkerId, uploadedFromPath), also the re-push key, and the engine only ever FLAGS.watchedFolder(memql#4841) is one folder on one of the owner's machines, swept by its cockpit; the PATH is the machine's to refuse (policy.yamlbackup.roots, default-deny ->originState=refused_by_policy). An ABSENToriginStateis "no cockpit has reported yet", neverok. - Cluster (
dsl/cluster/concepts.memql) --node,nodeType,spawnEvent,cluster/database/identityProvider, plusdeployment(append-only, one timeline per deploymentId, #1872) anddeploymentNodeSpec(per-node-type child; an emptyversionresolves against the deployment's engine version). Read the set vianodeSpecsForDeployment.databaseandidentityProviderare singletons at LITERAL ids (v1:cluster:database:primary,v1:cluster:identityProvider:primary,v1:cluster:cluster:self, memql#4766), refreshed on every bff start under theclusterInfraRefreshgate, NOTbootstrapCluster. Neither carries astatusfield; do not re-add one -- probe live and say when you looked. - Observability (
dsl/observability/, every node) --codeProfile(live per-FQN verbosity override),invocation(thecode_invocationhypertable) andcodeMetric(the_1m/_1hcontinuous aggregates), read throughcodeMetricsInWindow(design).logLineis the log store (epic memql#4893): every node's log lines in thelog_linehypertable, forwarded bycore/logger's fan-out sink and batched bycomponent/logstore(bounded, non-blocking, drops onmemql_logs_dropped_total{reason}), plus the OS front end's errors vialogsRecordClient. Rows never enter the graph and never broadcast; the reads are@sdkbuiltins (logsSearch,logsTail,logsSources,logsStatus) floored at admin IN THEIR HANDLERS.logger.Subject(concept, id)is the seam between a line and its subject. Retention is the nightlylogsRetentionSweepon the cron leader: archive to blob storage FIRST, and no archive means no delete. logs.md · design. - Identity (
dsl/identity/concepts.memql, every node) --user,authSession,magiclink,accessRequest,invitation,delegation,enrolmentToken, andidentity, a discriminated union keyed onidentityType; thepasskeyvariant's stored material is PUBLIC (a COSE key). access-model.md. - Two audit logs, not one (memql#4328):
auditEventrecords DECISIONS and security signals,authActivityrecords routine MECHANICS (token rotations, grace-window accepts, PAT-authenticated requests), two orders of magnitude more numerous, on@rowAuthz(owner="<field>", clusterOwner)(a non-owner admin getsauthActivityForSelf). ItsretiredTokenHashis what refresh-token reuse detection keys on (memql#4329); retentionMEMQL_IDENTITY_AUTH_ACTIVITY_RETENTION_DAYS(default 30), hard-deleted daily, so detection reaches back exactly that far.
Feature Notes
The per-epic write-ups -- what each shipped feature area is, and the rules about it the code does not say -- live in feature-notes.md: email campaigns + the sending engine, the work spine (goals, runs, steps), the proving suite, workers (computer use, the fleet router, the Fleet app), invitations, Nexus, views / layouts (retired) and planner / knowledge / validation. Read it before touching any of them.
Three of its rules reach far enough outside their own area to state here:
v1:planner:plan,taskandtaskStateARE RETIRED (epic memql#5000). The work spine --v1:work:{goal,run,step,modelCall,approval,observation}, every concept on the composite owner tier -- is the only model:agent()andproduceArtifactopen goals, a tool call is av1:work:observation, and training is a goal.v1:planner:responsibilitySTAYS.- The run ceilings are enforced at the MODEL SEAM (
component/memql'smodelSeam, memql#5580), and a breach PARKS the run on abudgetapproval rather than failing it. Dollar ceilings EXCLUDE subscription and local spend; loop caps INCLUDE every call, whoever answered it. - MemQL OS has no runtime arrangement engine and is not getting one by
default (epic memql#4984): its answer is hand-built sections under the
twelve interface rules in
clients/os/DESIGN.md.
Procedure learning (epic memql#5402)
Recordings generalized into parameterized constructs by a PURE module that
spends no model. component/procedure is a leaf module that requires NOTHING
but the standard library (a build-graph fact its own purity_test.go asserts;
every goalSignature it groups by is read off a row by the wiring), holding
canonicalize / symbolize / mine / structure / generalize / classify / score /
select as functions over values. integrations/procedure is the only half
that reads a row. Record: section 4 epic C of
the recording-and-learning program.
- Holes classify in D13's order -- data flow, then constant, then free --
on EVERY instance.
unexplained(PARTIAL evidence) is the ONLY class that may reach the one bounded model call; a free hole asks nothing. A model's answer is parsed against a closed grammar and re-checked against every instance. - Compression is the score, two uses is the floor (D14). A free parameter
is priced ABOVE a data-flow hole;
Selectrewrites the corpus between acceptances. - The corpus is ONE owner's, read under their actor. A disliked recording
is excluded in the loader; a run with no
goalSignatureis skipped. goalSignatureis written LAST, after the compile gate. Nothing auto-activates.
@serverOnly is refused on a builtin at parse, so both builtins carry their
gate in the HANDLER. component/procedure/reference is a research harness
(D6), skipped when python3 is absent.
Certification and replay (epic memql#5408) put a learned procedure on a
ladder (candidate, shadow, canary, trusted, retired) decided by pure functions
in component/work (Advance, DecideServe, Compare) over the seeded
v1:authoring:ladderPolicy:primary row. A person approves once, and only
the ladder writes the ladder: shadow to canary is one procedurePromotion
approval pinned to procedureHash; the ladder fields are written with
internal origin only (component/memql/construct_ladder_write_guard.go). A
replay run is never a recording (triggeredBy: procedure:<mode>); a
recording inherits the goal's input WITHOUT the replay's own variable
(component/work.GoalInput). A parameter is a value, never code
(component/procedure.Materialize; a version whose parameter would be code
stays a candidate, ReplayRisks).
learned-procedures.md.
Intervention, feedback and reuse (epic memql#5414)
A person steps into a finished run: rerunStep (a new VERSION with a
different level, model, effort, prompt or inputs), moveRunHead, branchRun,
recordFeedback (the AI Fluency framework's Discernment axes); long work is
cut into sections that ask the catalog before intelligence.
intervention-and-feedback.md.
- An override is ONE version of ONE step, riding
common.RunContext.Overridefor that execution only. Its prompt is the WHOLE session prompt only when an app session answered the version it replaces (wholePrompt). - The head is re-asserted, not only recorded: moving it writes the chosen
version again as the step's newest row-version (
reassertWorkStepVersion), bringing the upstream it was computed from (step.basis). - A branch serves its prefix BY REFERENCE; the prefix never executes.
- A replay cannot honour an override: a changed re-run of a
procedure-served step hands the goal to the app
(
integrations/procedure/rerun.go). - Feedback is a
feedbackobservation, and the validator never certifies.data.verdict,data.target.{stepKey, version},data.axes,data.reason; a dislike with no axis is refused, a later verdict is a new row. The answer validator writes adecisionobservation andrun.validation, never a like (D22).
Notes for Claude Code CLI
- Use GLOSSARY.md to find specific documentation, and read a tree's own CLAUDE.md (Key Directories above) before editing that tree.
Makefile + shell-script convention
The Makefile is for simple commands and target wiring. Anything multi-step,
conditional, or long enough to need line-continuations gets extracted into a
shell script under scripts/, and the Makefile target becomes a one-liner that
calls it.
- Stays inline: single commands (
go build,go test,kubectl rollout restart), short pipelines (~3 lines or fewer),.PHONY, target dependencies, simple variable substitutions. - Goes into
scripts/<area>/<name>.sh: conditionals, retry loops, multi-step orchestration, user-facing error messages -- anything "complex enough that you'd want to test it independently of make."
Shell-script rules: #!/usr/bin/env bash + set -euo pipefail (drop -e for
status reporters where one failure shouldn't abort the rest); function-based
structure with main() at the bottom, never a sequential blob; source a
shared scripts/<area>/*.sh helper for common functions; .sh extension,
executable. Reference: scripts/k3d/{up,dev,status}.sh behind one-liner targets.
Capability scripts (the hardened successor)
A capability script is a deploy/ops script that is also the deterministic
backend behind a DSL action, so it must run identically whether an
automation or a human invokes it. It adopts the capability-script contract
(capability-script-contract.md,
#2221) -- the convention above plus: non-interactive (a destructive
confirmation is an explicit --confirm=<phrase> param, never a prompt);
structured params in (--flag=value > stdin JSON via --params-stdin >
documented defaults; no positional args); exactly one JSON envelope on
stdout, all human logs on stderr; honest, stable exit codes (0 ok; 2
bad param; 3 refused; 4 prerequisite missing; 5 op failed); no decisions
inside (no branching on environment/version/role -- that lives in DSL logic;
only mechanical idempotency branches).
They source scripts/lib/capability.sh (cap_init / cap_param / cap_ok /
cap_fail / cap_info-to-stderr / --print-spec). A boolean is read only
with cap_bool (if cap_bool apply; then), never cap_flag: its raw
"false" is non-empty, so --apply=false passed every -n test.
scripts/lib/capability_contract_test.go enforces the contract on every script
that sources the library and gates non-interactivity across
scripts/{k3d,deploy,release,docs}; the Go effect seam parses the envelope via
capabilityresult.ParseCapabilityResult.
Documentation Style Guidelines
No Emojis: All documentation, skills, and CLI responses must use
professional formatting without emojis. Use checkboxes ([ ] / [x]), text
indicators ("SUCCESS:", "ERROR:", "WARNING:", "INFO:") and standard markdown for
emphasis. This applies to documentation files, skill outputs, CLI responses, and
all user-facing text.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

