mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
refactor(agents): move permissions to app/agents/shared (slice 4a)
Relocate the permission evaluator (wildcard matcher + rule evaluation) to the
shared kernel and flip 43 non-frozen importers. A re-export shim remains at
new_chat/permissions.py for the frozen single-agent stack (chat_deepagent and
subagents/{config,providers/linear,providers/slack}); it will be removed when
that stack is retired.
This commit is contained in:
parent
3efe51e6ec
commit
8fca2753aa
45 changed files with 260 additions and 231 deletions
|
|
@ -49,7 +49,7 @@ from app.agents.multi_agent_chat.middleware.shared.permissions.ask.request impor
|
|||
from app.agents.multi_agent_chat.subagents.shared.hitl.approvals.self_gated import (
|
||||
request_approval,
|
||||
)
|
||||
from app.agents.new_chat.permissions import Rule
|
||||
from app.agents.shared.permissions import Rule
|
||||
|
||||
|
||||
class _SubState(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from typing_extensions import TypedDict
|
|||
from app.agents.multi_agent_chat.middleware.shared.permissions.ask.request import (
|
||||
request_permission_decision,
|
||||
)
|
||||
from app.agents.new_chat.permissions import Rule
|
||||
from app.agents.shared.permissions import Rule
|
||||
|
||||
|
||||
class _State(TypedDict, total=False):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from app.agents.multi_agent_chat.middleware.shared.permissions.ask.payload impor
|
|||
build_permission_ask_payload,
|
||||
)
|
||||
from app.agents.shared.feature_flags import AgentFeatureFlags
|
||||
from app.agents.new_chat.permissions import Rule, Ruleset
|
||||
from app.agents.shared.permissions import Rule, Ruleset
|
||||
|
||||
|
||||
class _NoArgs(BaseModel):
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from app.agents.multi_agent_chat.middleware.shared.permissions import (
|
|||
build_permission_mw,
|
||||
)
|
||||
from app.agents.shared.feature_flags import AgentFeatureFlags
|
||||
from app.agents.new_chat.permissions import Rule, Ruleset
|
||||
from app.agents.shared.permissions import Rule, Ruleset
|
||||
|
||||
|
||||
def _kb_style_ruleset() -> Ruleset:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from app.agents.multi_agent_chat.middleware.shared.permissions import (
|
|||
build_permission_mw,
|
||||
)
|
||||
from app.agents.shared.feature_flags import AgentFeatureFlags
|
||||
from app.agents.new_chat.permissions import Rule, Ruleset
|
||||
from app.agents.shared.permissions import Rule, Ruleset
|
||||
|
||||
|
||||
class _NoArgs(BaseModel):
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from app.agents.multi_agent_chat.subagents.shared.subagent_builder import (
|
|||
pack_subagent,
|
||||
)
|
||||
from app.agents.shared.feature_flags import AgentFeatureFlags
|
||||
from app.agents.new_chat.permissions import Rule, Ruleset, evaluate
|
||||
from app.agents.shared.permissions import Rule, Ruleset, evaluate
|
||||
|
||||
|
||||
class RateLimitError(Exception):
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from app.agents.new_chat.permissions import (
|
||||
from app.agents.shared.permissions import (
|
||||
Rule,
|
||||
Ruleset,
|
||||
aggregate_action,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
|
||||
from app.agents.new_chat.middleware.permission import PermissionMiddleware
|
||||
from app.agents.new_chat.permissions import (
|
||||
from app.agents.shared.permissions import (
|
||||
Rule,
|
||||
Ruleset,
|
||||
aggregate_action,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from app.agents.new_chat.middleware.permission import (
|
|||
PermissionMiddleware,
|
||||
_normalize_permission_decision,
|
||||
)
|
||||
from app.agents.new_chat.permissions import Rule, Ruleset
|
||||
from app.agents.shared.permissions import Rule, Ruleset
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from app.agents.new_chat.permissions import (
|
||||
from app.agents.shared.permissions import (
|
||||
Rule,
|
||||
Ruleset,
|
||||
aggregate_action,
|
||||
|
|
|
|||
|
|
@ -332,6 +332,6 @@ class TestDenyPatternsCoverage:
|
|||
|
||||
def _wildcard_matches(pattern: str, value: str) -> bool:
|
||||
"""Helper using the same matcher the rule evaluator does."""
|
||||
from app.agents.new_chat.permissions import wildcard_match
|
||||
from app.agents.shared.permissions import wildcard_match
|
||||
|
||||
return wildcard_match(value, pattern)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue