Namespaces
A five-level hierarchy that scopes every record to an organization, project, environment or job. A child can only narrow what its parent allows.
Overview
A namespace is a scope. Every record belongs to exactly one namespace, and namespaces form a five-level hierarchy where each level narrows the one above. Children inherit from their parent and can only narrow it, never expand it.
Namespaces keep organizations apart (one ORG can't see another's records), keep projects separate (your payments work doesn't leak into analytics), separate environments (staging and production), and give a single run its own scope that can be cleaned up when done.
If you skip namespaces, everything lives in the implicit default namespace and works fine. You only need them when your team grows beyond one identity, when you want to separate a customer's data from your own, or when you enforce per-environment policies.
The five levels
DEFAULT → ORG → PROJECT → ENV → JOB| Level | Example ID | Purpose | When you'd create one |
|---|---|---|---|
| DEFAULT | default | The baseline. Always exists and can't be deleted. | Never, it always exists. |
| ORG | acme-corp | One company, team or customer. | When you onboard a second customer or split your team into independent units. |
| PROJECT | acme-corp/payments | A workstream within an org. | When two projects under the same org need independent budgets, autonomy settings, or rule sets. |
| ENV | acme-corp/payments/staging | A stage within a project. | When you have staging and production for the same project and you want rules that apply to only one. |
| JOB | acme-corp/payments/staging/job-42 | A per-execution scope. | When a long-running run needs its own temporary scope. |
The maximum depth is four segments under DEFAULT. You can stop at any level: acme-corp alone is a valid namespace.
How records get a namespace
Every record carries its namespace in body.namespace:
{
"act": "INTEND",
"actor": "did:sync:user:alice",
"thread": "th_payments_deploy",
"body": {
"namespace": "acme-corp/payments/staging",
"goal": "Deploy v2.3 to staging"
},
"clock": 0,
"data_type": "VOID"
}Records without body.namespace go in default, which is always Active.
Lifecycle
A namespace has three states:
- Active: accepts records, enforces policy. The normal state.
- Archived: read-only. No new records may be written to this namespace or any namespace under it. History is kept.
- Deleted: treated as nonexistent for new records, but kept for the audit trail.
Transitions:
spl namespace create
↓
Active ──→ Archived ──→ Deleted
←──
spl namespace
unarchive
(re-create)To re-activate an archived namespace, run spl namespace create again with the same ID. The latest record wins.
The narrowing rule
The single most important property of namespaces: a child can never claim capabilities its parent doesn't grant. Every time a record is written, Syncropel checks the namespace and every ancestor up to DEFAULT, and rejects the record if any is missing or not Active.
Record claims: acme-corp/payments/staging/job-42
Walk: acme-corp/payments/staging/job-42 → Active? ✓
acme-corp/payments/staging → Active? ✓
acme-corp/payments → Active? ✓
acme-corp → Active? ✓
default → Active? ✓ (always)
Decision: ACCEPTBut:
Record claims: acme-corp/payments/staging/job-42
Walk: acme-corp/payments/staging/job-42 → Active? ✓
acme-corp/payments/staging → Active? ✓
acme-corp/payments → Active? ✗ (Archived)
Decision: 403 NAMESPACE_REJECTED
"namespace 'acme-corp/payments/staging/job-42' rejected:
ancestor 'acme-corp/payments' is not Active in the registry."Archiving an org immediately stops writes to everything under it. A deeper namespace can't keep writing after its parent is turned off.
Why this design
This shape gives you:
1. Simple cleanup. When a customer leaves or a project ends, archive its top-level namespace. Everything under it stops accepting writes, and you don't need to clean up each piece by hand.
2. Separation between customers. One workspace can serve several organizations. Someone with a credential for acme-corp cannot write records claiming bigcorp, because the registry has no bigcorp for them to pass through.
3. No way to gain access by going deeper. The effective policy at any level is the overlap of every ancestor's policy. You can answer "what could a job-42 run ever do?" by looking at the chain of policies.
When NOT to use namespaces
- You're a solo developer running spl on your laptop. Stay in
default. There's nothing to gain. - You have one team and one production environment. A single ORG is overkill,
defaultis fine. - You're prototyping. Namespaces are about boundaries, and prototyping is about not having boundaries. Add namespaces when the boundaries become real (a second customer, a second product, a regulated environment).
The default namespace is always there and always Active.
Known limits
Syncropel checks that a record's namespace and every ancestor exist and are Active. This stops anyone from writing records into namespaces that don't exist.
- Policy is not composed. The
policyfield on a namespace is stored as plain text. The check covers existence and status, not whether a child's permissions fit within its parent's. - Reads are not partitioned by namespace. Records are tagged with a namespace, but a read returns records from all the namespaces the caller has access to.
Next steps
- Commands: see
spl namespacein the CLI reference for the create/list/show/archive/delete commands. - Rules scoped to namespaces: the
current_namespace()function andrecord.body.namespacefield are available in every expression. See Expressions. - Worked example: see the Namespaces guide for a full setup from
spl namespace createto a working multi-environment workspace.
Patterns
How a workspace learns from work that keeps succeeding the same way, reuses the outcome instead of reasoning it out again, and stops reusing it once it starts to fail.
Governance
Permissions live in the protocol, not bolted on. Every act produces a record. Without a matching allow, the answer is no.