symfonic.capabilities.memory.scope¶
scope ¶
The memory scope: three levels, one separator, and a total visibility rule.
Every port signature in this capability is keyed by a scope, and the reason is SEC-TEN-5: a backend must be able to enforce tenant isolation without importing the platform that derived the tenant. A scope value that carries its own hierarchy is what makes that possible — the backend answers "is this memory visible here?" by comparing segments, not by asking anyone.
Visibility runs one way only. A memory written at acme is visible inside
acme/alice/s1, because a tenant-wide fact is true of every session in the
tenant. A memory written at acme/alice/s1 is not visible at acme:
promoting session content upward is a consolidation decision (T3.3.3), and a
retrieval that did it implicitly would leak one user's session into another's.
The charset is not cosmetic. / separates levels, so a segment containing one
forges a level — MemoryScope("acme/evil") would otherwise claim to be a
tenant while comparing equal to a descendant of acme.
MemoryScope
dataclass
¶
Where a memory lives: tenant, then principal, then session.
The levels are positional and gapless. A session without a principal is a hole in the hierarchy — it would compare as a child of the tenant while naming something the tenant cannot enumerate — so it is refused at construction rather than normalised into something plausible.
covers ¶
Whether a memory written at self is visible at other.
Segment-wise, never string-prefix: acme does not cover acmecorp,
and a rule written with :meth:str.startswith would say it does.
Source code in src/symfonic/capabilities/memory/scope.py
distance ¶
Levels from self down to other, or -1 when not covered.
-1 rather than an exception: distance is asked once per candidate
during ranking, and "not visible from here" is an ordinary answer there.
Source code in src/symfonic/capabilities/memory/scope.py
validate ¶
Refuse every scope this capability cannot compare.
Source code in src/symfonic/capabilities/memory/scope.py
scope_from_path ¶
Parse the canonical path form back into a scope.