Every memory write hits five rule layers in order: validation → scope → governance → namespace standard → parent-namespace inheritance. Each layer is independently configurable. Each layer can refuse the write with a specific reason. Together they let you take a flat memory store and turn it into a multi-tenant, audit-friendly, compliance-ready substrate.
A write that survives all five layers gets persisted. A write that fails any one layer gets a 4xx with a specific reason — AI clients can quote the rejection verbatim. There is no "rule somewhere" — every gate is named, and every reason is human-readable.
src/validate.rs. Reject malformed input before anything else runs. The same checks run on HTTP, MCP, CLI, and federation receive — there is no privileged path that bypasses them.validate_title — non-empty, ≤512 chars, no control charsvalidate_content — non-empty, ≤65 536 bytes, no control charsvalidate_namespace — ≤512 chars, ≤8 segments, no path-traversal (.. rejected per red-team #240)validate_metadata — JSON object only, ≤65 536 bytes serialized, ≤32 nesting depthvalidate_priority — 1–10 rangevalidate_confidence — 0.0–1.0, finite (no NaN, no Inf)validate_tags — ≤50 tags, ≤128 bytes eachvalidate_ttl_secs — positive, ≤1 year (caps "accidental immortality")validate_source — closed set: user, claude, hook, api, cli, import, consolidation, system, chaos, notifymetadata.scope in { private, team, unit, org, collective }. The query layer filters reads against the calling agent's namespace position (as_agent param). Memories with no explicit scope are treated as private.store, promote, delete. Four levels: Any, Registered, Owner, Approve. Three approver types: Human, Agent(id), Consensus(N). The default policy opens writes/promotes wide and gates deletes to owners — operators tighten as needed.metadata carries the per-namespace policy. The standard's metadata holds the governance block (L3 source) and the default scope for new memories. Setting / clearing a standard is itself an MCP operation: memory_namespace_set_standard / get_standard / clear_standard.alphaone/engineering/platform/team-a/squad-1 can inherit from alphaone/engineering/platform without setting its own. parent_namespace can be set explicitly on the standard, or auto-detected via auto_detect_parent. v0.6.2 (S35) propagates the namespace_meta row across federation peers so inheritance walks return identical answers everywhere.Set scope=team as the namespace standard's default. New memories get team-only visibility automatically. Tenants can't read each other's notes even though they share the same daemon + DB.
Set TTL caps in the namespace standard. Set delete: owner so other agents can't drop your evidence. Set promote: approve + consensus(3) so "this stays forever" is a 3-vote decision with a paper trail in pending_actions.
Junior agent's namespace gets write: approve, approver: {agent: "supervisor-1"}. Every memory the junior tries to store queues for supervisor approval. Supervisor reviews via memory_pending_list, decides via memory_pending_approve / _reject.
Set the org-wide standard at the root namespace once. Every sub-namespace inherits unless it sets its own. Adding a new team becomes mkdir -p: write under the new namespace and the existing rules apply.
Different namespace standards for dev, staging, prod. Dev keeps writes wide-open. Prod tightens to registered writes + consensus(2) promotes. Same daemon, same code, namespace-scoped behavior.
Each layer fails with its own error message; AI clients can quote the reason verbatim. Here's a 1-line cheatsheet of which layer the rejection came from.