feat: add opt-in MCP decomposition hook points (design §10)
Adds the seven §10.2 hook-point modules + five env vars so Astrolabe Cloud can offload document processing to the external document-processor / embedding gateway. Purely additive: with every setting unset the server behaves exactly as today, so self-hosters are unaffected (Deck #92). Hook points (all default to current monolith behavior): - config: EMBEDDING_PROVIDER, INGEST_MODE, STATUS_BACKEND, COLLECTION_METADATA_SOURCE, FACT_EVENT_EMITTER (+ supporting settings), validated in Settings.__post_init__ (fail-fast STATUS_BACKEND=local with INGEST_MODE=external); shared canonical.py. - vector/payload_keys.py + acl_hash.py: cross-impl NAMESPACE/point_id (§2.2) and BLAKE2b-128 ACL hash (§11), pinned by fixtures shared with the document-processor repo. - embedding/gateway_client.py: OpenAI-compatible GatewayProvider authenticating via M2M OIDC client-credentials (separate realm); manual-only registry entry. - vector/collection_metadata.py: sentinel-point / API metadata source with env fallback. - vector/queue/: hexagonal ingest producer ports + memory/NATS adapters (Postgres seam); INGEST_MODE=external publishes mcp.ingest.requested.{tenant} instead of the in-memory stream and skips the in-process processor pool. The lifespan becomes a composition root across both deployment branches. - vector/queue/status.py: STATUS_BACKEND=bus subscriber feeding a StatusStore the vector-sync status endpoint reads. - admin/payload_backfill.py: POST /api/v1/admin/payload-backfill (admin scope); processor writes the new payload keys; query-side ACL pre-filter gated behind ACL_PREFILTER_ENABLED (default off). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c7da612f20
commit
d883052fb8
@@ -0,0 +1,45 @@
|
||||
"""In-memory ``TaskProducer`` — the default (local) ingest transport.
|
||||
|
||||
A thin adapter over anyio's ``MemoryObjectSendStream`` so the local path is an
|
||||
explicit :class:`TaskProducer` (rather than relying on structural typing of a
|
||||
third-party class). Semantics are identical to using the stream directly:
|
||||
``send`` enqueues, ``clone`` yields an independent per-user handle, ``async
|
||||
with`` / ``aclose`` close the (cloned) send end so the processor pool's
|
||||
receivers observe end-of-stream.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import TracebackType
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from anyio.streams.memory import MemoryObjectSendStream
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..scanner import DocumentTask
|
||||
|
||||
|
||||
class MemoryTaskProducer:
|
||||
def __init__(self, stream: MemoryObjectSendStream[DocumentTask]):
|
||||
self._stream = stream
|
||||
|
||||
async def send(self, task: DocumentTask, /) -> None:
|
||||
await self._stream.send(task)
|
||||
|
||||
def clone(self) -> MemoryTaskProducer:
|
||||
return MemoryTaskProducer(self._stream.clone())
|
||||
|
||||
async def __aenter__(self) -> MemoryTaskProducer:
|
||||
await self._stream.__aenter__()
|
||||
return self
|
||||
|
||||
async def __aexit__(
|
||||
self,
|
||||
exc_type: type[BaseException] | None,
|
||||
exc: BaseException | None,
|
||||
tb: TracebackType | None,
|
||||
) -> None:
|
||||
await self._stream.__aexit__(exc_type, exc, tb)
|
||||
|
||||
async def aclose(self) -> None:
|
||||
await self._stream.aclose()
|
||||
Reference in New Issue
Block a user