DEV Community

Sui Gn
Sui Gn

Posted on

Algebra of Contexts

where space ⊇ subspace replaces schemas, RBAC, and reducers
We’ve been modeling data backwards.

Today: Schemas define shape. Permissions live in a separate table. Context is if(user.role === 'doctor') scattered everywhere.

Algebra of Contexts flips it:

space ⊇ subspace ⊇ subspace
Everything is a space. Context is a subspace. Privacy is set membership.

`// Spaces nest
me.profile.name("Abella");
me.profile.contact.email("abella@neurons.me");
me.wallet["_"].balance = 1000;

// Refinement = smaller semantic region
profile.contact.email ⊆ profile.contact ⊆ profile

// Privacy is structural, not a policy
me.wallet["_"] // A = {self} by construction
me.explain("wallet.balance") // => ●●●●`

6 lines hidden
The 4 set views of any space:

A = audience set  // who can read
T = topology set  // where it lives
C = capability set // what you can do  
P = path / subspace set // how you navigate
Enter fullscreen mode Exit fullscreen mode

Adjectives are just set statements:

private → A = {self}
shared → |A| > 1
public → A tends to open
encrypted → A enforced cryptographically
replicated → |T| > 1

Encryption doesn’t create a different universe. It creates stricter readable membership over the same space.

T = {home, office, phone} // replicated everywhere
A = {me, wife} // readable by two people
Why this matters: O(K) reactivity

Since context is a subspace, updates are local. Change me.sensors.temp and only dependent subspaces recompute.

Benchmark: 1M nodes. 6 dependents recompute in 0.256ms. Rest of graph untouched.

Demos:
Robots: Same canister = "biohazard" for surgeon, "box" for loader. Meaning computed from context path.
Smart City: districts[overCapacity == true] updates live as load changes. No SQL.
Key shift: We don’t start with system types. We start with space.

You’re not modeling files, permissions, or endpoints.
You’re modeling: who can perceive what, where it exists, and what can be done about it.

Everything else is derived.

MIT. TS/Python/Rust.
Code: https://github.com/neurons-me/monad
Docs: https://neurons-me.github.io/.me

Is space ⊇ subspace the missing primitive for context-aware systems?

Top comments (0)