Access controlled knowledge gateway functionality

This commit is contained in:
2026-05-04 15:00:16 +02:00
parent e87406ac9e
commit d923661852
20 changed files with 1486 additions and 14 deletions

View File

@@ -294,6 +294,32 @@ class LocalSnapshotStore:
for row in rows
]
def search_with_policy(
self,
query: str,
*,
subject: str,
gateway: Any,
action: str = "search",
limit: int = 20,
context: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""Search and apply a policy gateway before returning result rows."""
matches = []
for result in self.search(query, limit=limit):
item = result.to_dict()
item["policy"] = self.policy_metadata(result.path)
matches.append(item)
return gateway.filter_results(subject, action, matches, context=context)
def policy_metadata(self, path: str) -> dict[str, Any]:
"""Return document-derived policy metadata for an indexed source path."""
from markitect_tool.policy import policy_metadata_from_document
return policy_metadata_from_document(self.get_document(path), path=path)
def build(
self,
paths: list[str | Path],