feat(N1): Scope-Registry via Contract — workspace_scopes() Deklarationen + /scope-definitions Endpoint (#365)
Check Cross-Plugin Imports / check (push) Has been cancelled

- workspace_scopes() Contract-Hook (document_placeholders-Muster): Plugins deklarieren Scope-Dimensionen inkl. Wertequellen
- Deklarationen: contacts (Ordner/Typen/Saved-View), dms (Ordner/Datei-Typen), mail (Postfächer), calendar (Kalender/Standard-Ansicht)
- Pydantic fail-closed (schemas/workspace.py): ScopeOption, ScopeValueSource (nur interne /api/v1-Pfade, SSRF-sicher), WorkspaceScopeDimension, WorkspaceModuleScopes
- Aggregator workspace_scope_service.py: discovered-Plugins, ARCH-014-safe, Crash-sicher, ungültige Deklarationen verworfen
- GET /api/v1/workspaces/scope-definitions (workspaces:configure_modules) vor /{workspace_id} registriert
- Security-Invariante: Scope = reine UND-Einschränkung (Workspace ∧ RLS ∧ ABAC ∧ Permissions)
- Tests: 18/18 neu (TDD rot→grün), Regression 17/17, Checker 0 Verstöße, Ruff clean
- Doku: api-documentation.md Workspaces-Sektion, PROGRESS.md Phase N1
This commit is contained in:
Agent Zero
2026-08-31 23:17:54 +02:00
parent 6ed4bb7f98
commit c25356c257
10 changed files with 652 additions and 3 deletions
@@ -47,6 +47,41 @@ class CalendarContract:
]
}
# ─── Workspace Scopes contribution (Phase N1, #359 pattern) ───
@staticmethod
def workspace_scopes() -> list[dict]:
"""Scope-Dimensionen des calendar-Moduls für den Workspace-Editor (N1)."""
return [
{
"module_key": "calendar",
"dimensions": [
{
"key": "calendar_ids",
"label": "Kalender",
"control": "multiselect",
"value_source": {
"endpoint": "/api/v1/calendars",
"items_path": "",
"value_key": "id",
"label_key": "name",
},
},
{
"key": "default_view",
"label": "Standard-Ansicht",
"control": "select",
"options": [
{"value": "day", "label": "Tag"},
{"value": "week", "label": "Woche"},
{"value": "month", "label": "Monat"},
{"value": "range", "label": "Zeitraum"},
],
},
],
}
]
@classmethod
def get_function(cls, name: str):
"""Return a callable exposed by this contract, or None if absent."""
@@ -349,6 +349,53 @@ class ContactsContract:
data[key] = value if value is not None else ""
return data
# ─── Workspace Scopes contribution (Phase N1, #359 pattern) ───
# Declares the scope dimensions the contacts module supports; the N2
# workspace editor renders its filter UI from these definitions. Scope
# VALUES live per workspace in workspace_modules.config (JSONB).
@staticmethod
def workspace_scopes() -> list[dict]:
"""Scope-Dimensionen des contacts-Moduls für den Workspace-Editor."""
return [
{
"module_key": "contacts",
"dimensions": [
{
"key": "folder_ids",
"label": "Kontakt-Ordner",
"control": "multiselect",
"value_source": {
"endpoint": "/api/v1/contact-folders",
"items_path": "items",
"value_key": "id",
"label_key": "name",
},
},
{
"key": "contact_types",
"label": "Kontakt-Typen",
"control": "multiselect",
"options": [
{"value": "company", "label": "Firmen"},
{"value": "person", "label": "Personen"},
],
},
{
"key": "default_saved_view_id",
"label": "Standard-Ansicht",
"control": "select",
"value_source": {
"endpoint": "/api/v1/saved-views?entity_type=contact",
"items_path": "",
"value_key": "id",
"label_key": "name",
},
},
],
}
]
@classmethod
def get_function(cls, name: str):
"""Return a callable exposed by this contract, or None if absent."""
+34
View File
@@ -15,6 +15,40 @@ class DmsContract:
DmsFile = DmsFile
Folder = Folder
@staticmethod
def workspace_scopes() -> list[dict]:
"""Scope-Dimensionen des dms-Moduls für den Workspace-Editor (N1)."""
return [
{
"module_key": "dms",
"dimensions": [
{
"key": "folder_ids",
"label": "DMS-Ordner",
"control": "multiselect",
"value_source": {
"endpoint": "/api/v1/dms/folders",
"items_path": "",
"value_key": "id",
"label_key": "name",
},
},
{
"key": "file_types",
"label": "Datei-Typen",
"control": "multiselect",
"options": [
{"value": "application/pdf", "label": "PDF"},
{"value": "image/", "label": "Bilder"},
{"value": "spreadsheet", "label": "Tabellen"},
{"value": "word", "label": "Dokumente"},
{"value": "other", "label": "Sonstige"},
],
},
],
}
]
@classmethod
def get_function(cls, name: str):
"""Return a callable exposed by this contract, or None if absent."""
+24
View File
@@ -64,6 +64,30 @@ class MailContract:
]
}
# ─── Workspace Scopes contribution (Phase N1, #359 pattern) ───
@staticmethod
def workspace_scopes() -> list[dict]:
"""Scope-Dimensionen des mail-Moduls für den Workspace-Editor (N1)."""
return [
{
"module_key": "mail",
"dimensions": [
{
"key": "account_ids",
"label": "Postfächer",
"control": "multiselect",
"value_source": {
"endpoint": "/api/v1/mail/accounts",
"items_path": "",
"value_key": "id",
"label_key": "email",
},
},
],
}
]
@classmethod
def get_function(cls, name: str):
"""Return a callable exposed by this contract, or None if absent."""