-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsemantic_scope.py
More file actions
34 lines (24 loc) · 1.21 KB
/
semantic_scope.py
File metadata and controls
34 lines (24 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Semantic scope port — git-like federation resolution (★④).
The same term ("active user") can mean different things per team. Definitions
are stored against a :class:`Scope`; resolution walks ``Identity.scope_chain``
narrow→wide and the first hit wins. No conflicts — each scope lives in its own
branch. V1 = guild/channel/thread auto-resolution + ``/semantic show``.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol, runtime_checkable
from ..identity import Identity, Scope
if TYPE_CHECKING:
from ...semantic.types import SemanticEntry
from ...semantic.layer import SemanticLayer
@runtime_checkable
class ScopeResolverPort(Protocol):
"""Resolve the effective semantic layer for an identity's scope chain."""
async def effective_layer(self, identity: Identity) -> "SemanticLayer":
"""Merge scopes narrow→wide so the most specific definition wins."""
...
async def define(self, scope: Scope, entry: "SemanticEntry") -> None:
"""Persist one definition at an explicit scope."""
...
async def entries_at(self, scope: Scope) -> "list[SemanticEntry]":
"""Definitions stored exactly at ``scope`` (no inheritance)."""
...