harborrag-runtime 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- harborrag_runtime/__init__.py +22 -0
- harborrag_runtime/application/README.md +39 -0
- harborrag_runtime/application/__init__.py +39 -0
- harborrag_runtime/application/chat/__init__.py +7 -0
- harborrag_runtime/application/chat/citations.py +149 -0
- harborrag_runtime/application/chat/client.py +201 -0
- harborrag_runtime/application/chat/completion.py +92 -0
- harborrag_runtime/application/chat/completion_request.py +130 -0
- harborrag_runtime/application/chat/evidence.py +202 -0
- harborrag_runtime/application/chat/options.py +43 -0
- harborrag_runtime/application/chat/preparation.py +135 -0
- harborrag_runtime/application/chat/presenters.py +130 -0
- harborrag_runtime/application/chat/prompting.py +127 -0
- harborrag_runtime/application/chat/query_scope.py +146 -0
- harborrag_runtime/application/chat/replay.py +141 -0
- harborrag_runtime/application/chat/request_filters.py +134 -0
- harborrag_runtime/application/chat/retrieval.py +127 -0
- harborrag_runtime/application/chat/service.py +371 -0
- harborrag_runtime/application/composition/__init__.py +1 -0
- harborrag_runtime/application/composition/factories.py +106 -0
- harborrag_runtime/application/composition/resources.py +141 -0
- harborrag_runtime/application/composition/selection.py +65 -0
- harborrag_runtime/application/composition/service.py +550 -0
- harborrag_runtime/application/composition/tenant_models.py +45 -0
- harborrag_runtime/application/control_plane/__init__.py +1 -0
- harborrag_runtime/application/control_plane/active_runs.py +38 -0
- harborrag_runtime/application/control_plane/connection_models.py +109 -0
- harborrag_runtime/application/control_plane/connection_testing.py +91 -0
- harborrag_runtime/application/control_plane/connection_writes.py +227 -0
- harborrag_runtime/application/control_plane/connections.py +749 -0
- harborrag_runtime/application/control_plane/effect_recovery.py +235 -0
- harborrag_runtime/application/control_plane/projects.py +313 -0
- harborrag_runtime/application/control_plane/settings_import.py +239 -0
- harborrag_runtime/application/control_plane/settings_service.py +233 -0
- harborrag_runtime/application/control_plane/tenants.py +55 -0
- harborrag_runtime/application/errors.py +110 -0
- harborrag_runtime/application/ingestion/__init__.py +1 -0
- harborrag_runtime/application/ingestion/client.py +65 -0
- harborrag_runtime/application/ingestion/connection_sources.py +96 -0
- harborrag_runtime/application/ingestion/direct.py +120 -0
- harborrag_runtime/application/ingestion/follower.py +83 -0
- harborrag_runtime/application/ingestion/ports.py +174 -0
- harborrag_runtime/application/ingestion/progress_bridge.py +221 -0
- harborrag_runtime/application/ingestion/retry_selection.py +71 -0
- harborrag_runtime/application/ingestion/service.py +564 -0
- harborrag_runtime/application/ingestion/starter.py +78 -0
- harborrag_runtime/application/memory/__init__.py +21 -0
- harborrag_runtime/application/memory/client.py +114 -0
- harborrag_runtime/application/memory/composition.py +90 -0
- harborrag_runtime/application/memory/context.py +45 -0
- harborrag_runtime/application/memory/sessions.py +117 -0
- harborrag_runtime/application/ports.py +133 -0
- harborrag_runtime/application/retrieval/__init__.py +1 -0
- harborrag_runtime/application/retrieval/access.py +26 -0
- harborrag_runtime/application/scheduling/service.py +58 -0
- harborrag_runtime/application/schemas.py +15 -0
- harborrag_runtime/chat/README.md +40 -0
- harborrag_runtime/chat/__init__.py +18 -0
- harborrag_runtime/chat/composition.py +53 -0
- harborrag_runtime/chat/facade.py +46 -0
- harborrag_runtime/chat/service.py +183 -0
- harborrag_runtime/chat/tenant_clients.py +341 -0
- harborrag_runtime/chat/tenant_config.py +235 -0
- harborrag_runtime/chat/tenant_models.py +22 -0
- harborrag_runtime/composition/__init__.py +5 -0
- harborrag_runtime/composition/config_store.py +53 -0
- harborrag_runtime/composition/connection_removal.py +120 -0
- harborrag_runtime/composition/connection_stores.py +107 -0
- harborrag_runtime/composition/control_plane.py +401 -0
- harborrag_runtime/composition/mcp_auth.py +39 -0
- harborrag_runtime/composition/readers.py +113 -0
- harborrag_runtime/composition/resources.py +336 -0
- harborrag_runtime/composition/storage_providers.py +113 -0
- harborrag_runtime/config/__init__.py +84 -0
- harborrag_runtime/config/checkout.py +212 -0
- harborrag_runtime/config/chunking.py +167 -0
- harborrag_runtime/config/connectors/__init__.py +19 -0
- harborrag_runtime/config/connectors/fingerprints.py +54 -0
- harborrag_runtime/config/connectors/importing.py +611 -0
- harborrag_runtime/config/connectors/loader.py +95 -0
- harborrag_runtime/config/connectors/models/__init__.py +30 -0
- harborrag_runtime/config/connectors/models/atlassian.py +199 -0
- harborrag_runtime/config/connectors/models/builder.py +208 -0
- harborrag_runtime/config/connectors/models/common.py +45 -0
- harborrag_runtime/config/connectors/models/fields.py +134 -0
- harborrag_runtime/config/connectors/models/github.py +143 -0
- harborrag_runtime/config/connectors/models/local_file.py +119 -0
- harborrag_runtime/config/connectors/models/registry.py +149 -0
- harborrag_runtime/config/connectors/models/sharepoint.py +186 -0
- harborrag_runtime/config/connectors/models/spec.py +563 -0
- harborrag_runtime/config/connectors/parsing.py +275 -0
- harborrag_runtime/config/connectors/providers.py +177 -0
- harborrag_runtime/config/connectors/schemas.py +215 -0
- harborrag_runtime/config/errors.py +26 -0
- harborrag_runtime/config/graph_build.py +335 -0
- harborrag_runtime/config/graph_build_loading.py +38 -0
- harborrag_runtime/config/loading.py +245 -0
- harborrag_runtime/config/models.py +95 -0
- harborrag_runtime/config/ontology_loading.py +76 -0
- harborrag_runtime/config/parsers/__init__.py +19 -0
- harborrag_runtime/config/parsers/loader.py +85 -0
- harborrag_runtime/config/parsers/parsing.py +285 -0
- harborrag_runtime/config/parsers/providers.py +305 -0
- harborrag_runtime/config/parsers/schemas.py +614 -0
- harborrag_runtime/config/settings.py +378 -0
- harborrag_runtime/config/settings_document.py +133 -0
- harborrag_runtime/config/temporal.py +331 -0
- harborrag_runtime/config/temporal_loading.py +310 -0
- harborrag_runtime/config_store/__init__.py +5 -0
- harborrag_runtime/config_store/defaults.py +47 -0
- harborrag_runtime/config_store/provider.py +153 -0
- harborrag_runtime/config_store/run_settings.py +72 -0
- harborrag_runtime/connections/__init__.py +27 -0
- harborrag_runtime/connections/secrets.py +348 -0
- harborrag_runtime/contracts.py +237 -0
- harborrag_runtime/document_stage_catalog.py +82 -0
- harborrag_runtime/errors.py +64 -0
- harborrag_runtime/events/__init__.py +3 -0
- harborrag_runtime/events/in_process.py +100 -0
- harborrag_runtime/execution/__init__.py +26 -0
- harborrag_runtime/execution/contracts.py +32 -0
- harborrag_runtime/execution/direct.py +169 -0
- harborrag_runtime/execution/gateway.py +97 -0
- harborrag_runtime/execution/source_conversion.py +61 -0
- harborrag_runtime/execution/source_submission.py +278 -0
- harborrag_runtime/execution/submission.py +64 -0
- harborrag_runtime/execution/task_registry.py +387 -0
- harborrag_runtime/execution/temporal.py +165 -0
- harborrag_runtime/ingestion/README.md +79 -0
- harborrag_runtime/ingestion/__init__.py +59 -0
- harborrag_runtime/ingestion/chunking_profile.py +97 -0
- harborrag_runtime/ingestion/composition.py +279 -0
- harborrag_runtime/ingestion/connection_checks.py +239 -0
- harborrag_runtime/ingestion/connections.py +507 -0
- harborrag_runtime/ingestion/document/__init__.py +1 -0
- harborrag_runtime/ingestion/document/normalization.py +14 -0
- harborrag_runtime/ingestion/document/normalizers/__init__.py +9 -0
- harborrag_runtime/ingestion/document/normalizers/builtins.py +39 -0
- harborrag_runtime/ingestion/document/normalizers/transform.py +30 -0
- harborrag_runtime/ingestion/document/run_tools.py +152 -0
- harborrag_runtime/ingestion/failure_classification.py +82 -0
- harborrag_runtime/ingestion/field_indexes.py +56 -0
- harborrag_runtime/ingestion/maintenance/__init__.py +1 -0
- harborrag_runtime/ingestion/maintenance/connection_removal.py +115 -0
- harborrag_runtime/ingestion/maintenance/projection_admin.py +180 -0
- harborrag_runtime/ingestion/maintenance/relation_repair.py +555 -0
- harborrag_runtime/ingestion/maintenance/retention.py +353 -0
- harborrag_runtime/ingestion/observability.py +3 -0
- harborrag_runtime/ingestion/profiles.py +127 -0
- harborrag_runtime/ingestion/runtime_builder.py +339 -0
- harborrag_runtime/ingestion/source/__init__.py +1 -0
- harborrag_runtime/ingestion/source/descriptor_mapping.py +144 -0
- harborrag_runtime/ingestion/source/discovery.py +290 -0
- harborrag_runtime/ingestion/source/documents.py +184 -0
- harborrag_runtime/ingestion/source/finalization.py +288 -0
- harborrag_runtime/ingestion/source/operations.py +175 -0
- harborrag_runtime/ingestion/source/plan.py +413 -0
- harborrag_runtime/ingestion/source/retry.py +150 -0
- harborrag_runtime/ingestion/source/service.py +470 -0
- harborrag_runtime/ingestion/source/skips.py +172 -0
- harborrag_runtime/ingestion_contracts.py +107 -0
- harborrag_runtime/memory/__init__.py +81 -0
- harborrag_runtime/memory/access.py +47 -0
- harborrag_runtime/memory/administration.py +460 -0
- harborrag_runtime/memory/context/__init__.py +5 -0
- harborrag_runtime/memory/context/result.py +20 -0
- harborrag_runtime/memory/directory.py +166 -0
- harborrag_runtime/memory/erasure.py +122 -0
- harborrag_runtime/memory/locks.py +170 -0
- harborrag_runtime/memory/messages.py +202 -0
- harborrag_runtime/memory/presenters.py +117 -0
- harborrag_runtime/memory/projects.py +38 -0
- harborrag_runtime/memory/tiers/__init__.py +1 -0
- harborrag_runtime/memory/tiers/in_memory.py +491 -0
- harborrag_runtime/memory/titles.py +32 -0
- harborrag_runtime/memory/usage.py +131 -0
- harborrag_runtime/observability/__init__.py +1 -0
- harborrag_runtime/observability/connector_metrics.py +14 -0
- harborrag_runtime/observability/discovery_metrics.py +46 -0
- harborrag_runtime/observability/model.py +410 -0
- harborrag_runtime/observability/observability_types.py +47 -0
- harborrag_runtime/observability/stage_observation.py +96 -0
- harborrag_runtime/observability/tool_audit.py +17 -0
- harborrag_runtime/plugins.py +56 -0
- harborrag_runtime/rate_limiting.py +39 -0
- harborrag_runtime/reader_contracts.py +149 -0
- harborrag_runtime/retrieval/__init__.py +1 -0
- harborrag_runtime/retrieval/composition.py +174 -0
- harborrag_runtime/retrieval/facades.py +224 -0
- harborrag_runtime/scheduling/__init__.py +48 -0
- harborrag_runtime/scheduling/config.py +185 -0
- harborrag_runtime/scheduling/errors.py +37 -0
- harborrag_runtime/scheduling/models.py +146 -0
- harborrag_runtime/scheduling/service.py +297 -0
- harborrag_runtime/scheduling/validation.py +213 -0
- harborrag_runtime/sdk/__init__.py +86 -0
- harborrag_runtime/sdk/configuration.py +44 -0
- harborrag_runtime/sdk/facades.py +47 -0
- harborrag_runtime/sdk/runtime.py +242 -0
- harborrag_runtime/security/__init__.py +1 -0
- harborrag_runtime/security/api_key_operations.py +236 -0
- harborrag_runtime/serialization.py +35 -0
- harborrag_runtime/temporal/__init__.py +19 -0
- harborrag_runtime/temporal/activity_observability.py +313 -0
- harborrag_runtime/temporal/client.py +580 -0
- harborrag_runtime/temporal/connection.py +39 -0
- harborrag_runtime/temporal/conversion.py +147 -0
- harborrag_runtime/temporal/dispatch.py +38 -0
- harborrag_runtime/temporal/document_workflow.py +154 -0
- harborrag_runtime/temporal/failure_handling.py +68 -0
- harborrag_runtime/temporal/gateway.py +121 -0
- harborrag_runtime/temporal/heartbeats.py +67 -0
- harborrag_runtime/temporal/identity.py +14 -0
- harborrag_runtime/temporal/ingestion_activities.py +435 -0
- harborrag_runtime/temporal/maintenance_activities.py +251 -0
- harborrag_runtime/temporal/maintenance_schemas.py +88 -0
- harborrag_runtime/temporal/optional.py +19 -0
- harborrag_runtime/temporal/plan_resolver.py +149 -0
- harborrag_runtime/temporal/policies.py +18 -0
- harborrag_runtime/temporal/reindex_workflow.py +71 -0
- harborrag_runtime/temporal/retry_activities.py +147 -0
- harborrag_runtime/temporal/retry_workflow.py +222 -0
- harborrag_runtime/temporal/sandbox.py +51 -0
- harborrag_runtime/temporal/schedules.py +341 -0
- harborrag_runtime/temporal/schemas.py +482 -0
- harborrag_runtime/temporal/source_activities.py +590 -0
- harborrag_runtime/temporal/source_batch_workflow.py +226 -0
- harborrag_runtime/temporal/source_workflow.py +908 -0
- harborrag_runtime/temporal/submission.py +23 -0
- harborrag_runtime/temporal/worker.py +478 -0
- harborrag_runtime/temporal/worker_registry.py +141 -0
- harborrag_runtime/temporal_models.py +227 -0
- harborrag_runtime/testing/chat_fakes.py +309 -0
- harborrag_runtime/testing/chat_service_double.py +126 -0
- harborrag_runtime/testing/connection_fakes.py +278 -0
- harborrag_runtime/testing/memory_fakes.py +128 -0
- harborrag_runtime/topology/__init__.py +1 -0
- harborrag_runtime/topology/budgeted_extractor.py +110 -0
- harborrag_runtime/topology/chunk_runner.py +41 -0
- harborrag_runtime/topology/composition.py +168 -0
- harborrag_runtime/topology/configuration.py +126 -0
- harborrag_runtime/topology/contextual.py +140 -0
- harborrag_runtime/topology/derived.py +238 -0
- harborrag_runtime/topology/derived_coverage.py +5 -0
- harborrag_runtime/topology/derived_dispatch.py +63 -0
- harborrag_runtime/topology/derived_factory.py +175 -0
- harborrag_runtime/topology/derived_models.py +251 -0
- harborrag_runtime/topology/derived_projection.py +127 -0
- harborrag_runtime/topology/description_factory.py +81 -0
- harborrag_runtime/topology/embedding_profile.py +85 -0
- harborrag_runtime/topology/entity_summary_index.py +304 -0
- harborrag_runtime/topology/maintenance.py +126 -0
- harborrag_runtime/topology/operations.py +277 -0
- harborrag_runtime/topology/parent_materializer.py +167 -0
- harborrag_runtime/topology/run_cost.py +43 -0
- harborrag_runtime/topology/security_operations.py +46 -0
- harborrag_runtime/topology/service.py +349 -0
- harborrag_runtime/topology/summary_factory.py +164 -0
- harborrag_runtime/topology/summary_inputs.py +129 -0
- harborrag_runtime/topology/summary_operations.py +128 -0
- harborrag_runtime/topology/summary_policy.py +39 -0
- harborrag_runtime/topology/summary_products.py +43 -0
- harborrag_runtime/topology/summary_service.py +625 -0
- harborrag_runtime/topology/summary_worker.py +129 -0
- harborrag_runtime/topology/summary_workflow.py +32 -0
- harborrag_runtime/topology/worker.py +101 -0
- harborrag_runtime/topology/workflow.py +32 -0
- harborrag_runtime-2.0.0.dist-info/METADATA +267 -0
- harborrag_runtime-2.0.0.dist-info/RECORD +271 -0
- harborrag_runtime-2.0.0.dist-info/WHEEL +4 -0
- harborrag_runtime-2.0.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Separate task queue and durable source-coalesced dispatch for summary generation."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
|
|
7
|
+
from temporalio import activity
|
|
8
|
+
from temporalio.client import Client
|
|
9
|
+
from temporalio.common import WorkflowIDReusePolicy
|
|
10
|
+
from temporalio.exceptions import WorkflowAlreadyStartedError
|
|
11
|
+
from temporalio.worker import Worker
|
|
12
|
+
|
|
13
|
+
from .summary_factory import SummaryRuntimeFactory
|
|
14
|
+
from .summary_service import SummaryProjectionService
|
|
15
|
+
from .summary_workflow import SummaryProjectionWorkflow, SummaryWorkflowInput
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger("harborrag.runtime.topology.summary_worker")
|
|
18
|
+
# A failing pass (a database failover, a reset connection) backs the poll off up
|
|
19
|
+
# to this ceiling instead of hammering the database every few seconds.
|
|
20
|
+
_MAX_BACKOFF_SECONDS = 300.0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SummaryActivities:
|
|
24
|
+
def __init__(self, service: SummaryProjectionService) -> None:
|
|
25
|
+
self.service = service
|
|
26
|
+
|
|
27
|
+
@activity.defn(name="harborrag.project_summaries")
|
|
28
|
+
async def project(self, request: SummaryWorkflowInput) -> str:
|
|
29
|
+
return await self.service.run_once(
|
|
30
|
+
request.tenant_id,
|
|
31
|
+
source_scope_id=request.source_scope_id,
|
|
32
|
+
heartbeat=lambda: activity.heartbeat(request.source_scope_id),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async def serve_summaries(
|
|
37
|
+
client: Client,
|
|
38
|
+
factory: SummaryRuntimeFactory,
|
|
39
|
+
tenant_ids: tuple[str, ...],
|
|
40
|
+
*,
|
|
41
|
+
stop_event: asyncio.Event | None = None,
|
|
42
|
+
) -> None:
|
|
43
|
+
"""Serve one queue and reconcile every explicitly managed tenant."""
|
|
44
|
+
tenant_ids = tuple(dict.fromkeys(tenant_ids))
|
|
45
|
+
if not tenant_ids:
|
|
46
|
+
return
|
|
47
|
+
settings = factory.settings
|
|
48
|
+
activities = SummaryActivities(factory.service())
|
|
49
|
+
for tenant_id in tenant_ids:
|
|
50
|
+
await factory.initialize(tenant_id)
|
|
51
|
+
await factory.synchronize(tenant_id)
|
|
52
|
+
async with Worker(
|
|
53
|
+
client,
|
|
54
|
+
task_queue=settings.summary_task_queue,
|
|
55
|
+
workflows=[SummaryProjectionWorkflow],
|
|
56
|
+
activities=[activities.project],
|
|
57
|
+
max_concurrent_activities=settings.temporal_max_concurrent_activities,
|
|
58
|
+
graceful_shutdown_timeout=timedelta(seconds=settings.temporal_graceful_shutdown_seconds),
|
|
59
|
+
):
|
|
60
|
+
failed_passes = 0
|
|
61
|
+
while stop_event is None or not stop_event.is_set():
|
|
62
|
+
# Newly published sources must acquire policy without a worker restart.
|
|
63
|
+
failed = False
|
|
64
|
+
for tenant_id in tenant_ids:
|
|
65
|
+
if not await _dispatch_guarded(client, factory, tenant_id):
|
|
66
|
+
failed = True
|
|
67
|
+
failed_passes = failed_passes + 1 if failed else 0
|
|
68
|
+
await _poll_delay(_backoff(settings.topology_poll_seconds, failed_passes), stop_event)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def watch_summaries(
|
|
72
|
+
client: Client,
|
|
73
|
+
factory: SummaryRuntimeFactory,
|
|
74
|
+
tenant_id: str,
|
|
75
|
+
*,
|
|
76
|
+
stop_event: asyncio.Event | None = None,
|
|
77
|
+
) -> None:
|
|
78
|
+
"""Backward-compatible single-tenant entry point for the topology CLI."""
|
|
79
|
+
await serve_summaries(client, factory, (tenant_id,), stop_event=stop_event)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
async def _dispatch_guarded(client: Client, factory: SummaryRuntimeFactory, tenant_id: str) -> bool:
|
|
83
|
+
"""Dispatch one tenant; a failure is logged, never raised.
|
|
84
|
+
|
|
85
|
+
This loop shares its host's ``asyncio.gather`` with every ingestion worker,
|
|
86
|
+
so one escaped error here would shut all of them down. Summaries are an
|
|
87
|
+
optional projection: the next poll retries, and the other tenants go on.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
await _dispatch(client, factory, tenant_id)
|
|
92
|
+
except Exception: # noqa: BLE001 - an optional projection must not stop ingestion
|
|
93
|
+
logger.error("Summary dispatch failed tenant_id=%s", tenant_id, exc_info=True)
|
|
94
|
+
return False
|
|
95
|
+
return True
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _backoff(seconds: float, failed_passes: int) -> float:
|
|
99
|
+
if not failed_passes:
|
|
100
|
+
return seconds
|
|
101
|
+
return min(seconds * 2.0 ** min(failed_passes, 16), max(seconds, _MAX_BACKOFF_SECONDS))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
async def _dispatch(client: Client, factory: SummaryRuntimeFactory, tenant_id: str) -> None:
|
|
105
|
+
settings = factory.settings
|
|
106
|
+
await factory.synchronize(tenant_id)
|
|
107
|
+
await factory.control.summaries.reconcile(tenant_id)
|
|
108
|
+
for scope, revision, fence in await factory.control.summaries.runnable_scopes(tenant_id):
|
|
109
|
+
try:
|
|
110
|
+
await client.start_workflow(
|
|
111
|
+
SummaryProjectionWorkflow.run,
|
|
112
|
+
SummaryWorkflowInput(tenant_id, scope, settings.topology_job_seconds),
|
|
113
|
+
id=f"harborrag-summary:{tenant_id}:{scope}:{revision}:{fence}",
|
|
114
|
+
task_queue=settings.summary_task_queue,
|
|
115
|
+
execution_timeout=timedelta(seconds=settings.topology_job_seconds + 3600),
|
|
116
|
+
id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,
|
|
117
|
+
)
|
|
118
|
+
except WorkflowAlreadyStartedError:
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
async def _poll_delay(seconds: float, stop_event: asyncio.Event | None) -> None:
|
|
123
|
+
if stop_event is None:
|
|
124
|
+
await asyncio.sleep(seconds)
|
|
125
|
+
return
|
|
126
|
+
try:
|
|
127
|
+
await asyncio.wait_for(stop_event.wait(), timeout=seconds)
|
|
128
|
+
except TimeoutError:
|
|
129
|
+
pass
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Durable summary orchestration; large content stays inside activities."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from datetime import timedelta
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from temporalio import workflow
|
|
8
|
+
from temporalio.common import RetryPolicy
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class SummaryWorkflowInput:
|
|
13
|
+
tenant_id: str
|
|
14
|
+
source_scope_id: str
|
|
15
|
+
job_seconds: float = 3600
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@workflow.defn(name="harborrag.summary_projection")
|
|
19
|
+
class SummaryProjectionWorkflow:
|
|
20
|
+
@workflow.run
|
|
21
|
+
async def run(self, request: SummaryWorkflowInput) -> str:
|
|
22
|
+
return cast(
|
|
23
|
+
str,
|
|
24
|
+
await workflow.execute_activity(
|
|
25
|
+
"harborrag.project_summaries",
|
|
26
|
+
request,
|
|
27
|
+
start_to_close_timeout=timedelta(seconds=request.job_seconds + 30),
|
|
28
|
+
heartbeat_timeout=timedelta(seconds=60),
|
|
29
|
+
retry_policy=RetryPolicy(maximum_attempts=1),
|
|
30
|
+
result_type=str,
|
|
31
|
+
),
|
|
32
|
+
)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Temporal worker plus transactional-outbox dispatcher for an explicit tenant."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from datetime import timedelta
|
|
7
|
+
|
|
8
|
+
from temporalio import activity
|
|
9
|
+
from temporalio.client import Client
|
|
10
|
+
from temporalio.common import WorkflowIDReusePolicy
|
|
11
|
+
from temporalio.exceptions import WorkflowAlreadyStartedError
|
|
12
|
+
from temporalio.worker import Worker
|
|
13
|
+
|
|
14
|
+
from harborrag_core.ports.topology import TopologyDispatchRepositoryPort
|
|
15
|
+
from harborrag_runtime.config.settings import RuntimeSettings
|
|
16
|
+
from harborrag_runtime.config.temporal import TemporalRuntimeConfig
|
|
17
|
+
from harborrag_runtime.temporal.connection import connect_temporal_client
|
|
18
|
+
|
|
19
|
+
from .composition import connect_topology_runtime
|
|
20
|
+
from .derived_dispatch import DerivedDispatcher
|
|
21
|
+
from .service import TopologyEnrichmentService
|
|
22
|
+
from .summary_factory import SummaryRuntimeFactory
|
|
23
|
+
from .summary_worker import watch_summaries
|
|
24
|
+
from .workflow import TopologyEnrichmentWorkflow, TopologyWorkflowInput
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TopologyActivities:
|
|
28
|
+
def __init__(self, service: TopologyEnrichmentService) -> None:
|
|
29
|
+
self._service = service
|
|
30
|
+
|
|
31
|
+
@activity.defn(name="harborrag.enrich_topology")
|
|
32
|
+
async def enrich(self, request: TopologyWorkflowInput) -> str:
|
|
33
|
+
result = await self._service.run_once(
|
|
34
|
+
request.tenant_id,
|
|
35
|
+
job_id=request.job_id,
|
|
36
|
+
heartbeat=lambda: activity.heartbeat(request.job_id),
|
|
37
|
+
)
|
|
38
|
+
return result.state
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async def dispatch(
|
|
42
|
+
client: Client,
|
|
43
|
+
repository: TopologyDispatchRepositoryPort,
|
|
44
|
+
settings: RuntimeSettings,
|
|
45
|
+
tenant_id: str,
|
|
46
|
+
) -> int:
|
|
47
|
+
await repository.reconcile(tenant_id)
|
|
48
|
+
jobs = await repository.runnable_jobs(tenant_id, limit=100)
|
|
49
|
+
started = 0
|
|
50
|
+
for job in jobs:
|
|
51
|
+
try:
|
|
52
|
+
await client.start_workflow(
|
|
53
|
+
TopologyEnrichmentWorkflow.run,
|
|
54
|
+
TopologyWorkflowInput(tenant_id, job.job_id, settings.topology_job_seconds),
|
|
55
|
+
id=f"harborrag-topology:{job.job_id}:{job.attempts}",
|
|
56
|
+
task_queue=settings.topology_task_queue,
|
|
57
|
+
execution_timeout=timedelta(seconds=settings.topology_job_seconds + 3600),
|
|
58
|
+
id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY,
|
|
59
|
+
)
|
|
60
|
+
started += 1
|
|
61
|
+
except WorkflowAlreadyStartedError:
|
|
62
|
+
pass
|
|
63
|
+
return started
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
async def run_temporal_worker(settings: RuntimeSettings, tenant_id: str) -> None:
|
|
67
|
+
async with connect_topology_runtime(settings) as runtime:
|
|
68
|
+
settings = runtime.settings
|
|
69
|
+
client = await connect_temporal_client(TemporalRuntimeConfig.from_settings(settings))
|
|
70
|
+
activities = TopologyActivities(runtime.service)
|
|
71
|
+
async with Worker(
|
|
72
|
+
client,
|
|
73
|
+
task_queue=settings.topology_task_queue,
|
|
74
|
+
workflows=[TopologyEnrichmentWorkflow],
|
|
75
|
+
activities=[activities.enrich],
|
|
76
|
+
max_concurrent_activities=settings.temporal_max_concurrent_activities,
|
|
77
|
+
graceful_shutdown_timeout=timedelta(
|
|
78
|
+
seconds=settings.temporal_graceful_shutdown_seconds
|
|
79
|
+
),
|
|
80
|
+
):
|
|
81
|
+
async with asyncio.TaskGroup() as tasks:
|
|
82
|
+
tasks.create_task(
|
|
83
|
+
watch_summaries(
|
|
84
|
+
client,
|
|
85
|
+
SummaryRuntimeFactory(
|
|
86
|
+
settings,
|
|
87
|
+
runtime.control,
|
|
88
|
+
runtime.artifact_reader,
|
|
89
|
+
runtime.artifact_writer,
|
|
90
|
+
),
|
|
91
|
+
tenant_id,
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
tasks.create_task(
|
|
95
|
+
DerivedDispatcher(runtime.control.topology, runtime.derive, settings).watch(
|
|
96
|
+
tenant_id
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
while True:
|
|
100
|
+
await dispatch(client, runtime.control.topology, settings, tenant_id)
|
|
101
|
+
await asyncio.sleep(settings.topology_poll_seconds)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Independent enrichment workflow: existing document histories are unchanged."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from datetime import timedelta
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from temporalio import workflow
|
|
8
|
+
from temporalio.common import RetryPolicy
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class TopologyWorkflowInput:
|
|
13
|
+
tenant_id: str
|
|
14
|
+
job_id: str
|
|
15
|
+
job_seconds: float = 3600
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@workflow.defn(name="harborrag.topology_enrichment")
|
|
19
|
+
class TopologyEnrichmentWorkflow:
|
|
20
|
+
@workflow.run
|
|
21
|
+
async def run(self, request: TopologyWorkflowInput) -> str:
|
|
22
|
+
return cast(
|
|
23
|
+
str,
|
|
24
|
+
await workflow.execute_activity(
|
|
25
|
+
"harborrag.enrich_topology",
|
|
26
|
+
request,
|
|
27
|
+
start_to_close_timeout=timedelta(seconds=request.job_seconds + 30),
|
|
28
|
+
heartbeat_timeout=timedelta(seconds=60),
|
|
29
|
+
retry_policy=RetryPolicy(maximum_attempts=1),
|
|
30
|
+
result_type=str,
|
|
31
|
+
),
|
|
32
|
+
)
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: harborrag-runtime
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Direct and durable production execution for HarborRAG.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: harborrag-adapters==2.0.0
|
|
10
|
+
Requires-Dist: harborrag-core==2.0.0
|
|
11
|
+
Requires-Dist: harborrag-engine==2.0.0
|
|
12
|
+
Requires-Dist: opentelemetry-api<2,>=1.45.2
|
|
13
|
+
Requires-Dist: prometheus-client<1,>=0.19
|
|
14
|
+
Requires-Dist: pydantic-settings>=2.2
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.13
|
|
16
|
+
Requires-Dist: python-dotenv<2,>=1
|
|
17
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
18
|
+
Provides-Extra: chat
|
|
19
|
+
Requires-Dist: harborrag-adapters[llm]==2.0.0; extra == 'chat'
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: types-pyyaml<7,>=6.0; extra == 'dev'
|
|
22
|
+
Provides-Extra: production
|
|
23
|
+
Requires-Dist: harborrag-adapters[chunking,chunking-code,control-plane,falkordb,langfuse,llm,opentelemetry,parsers,pdf-liteparse,postgres,qdrant,redis,s3,tables]==2.0.0; extra == 'production'
|
|
24
|
+
Provides-Extra: reader
|
|
25
|
+
Requires-Dist: harborrag-adapters[control-plane,falkordb,llm,postgres,qdrant,s3]==2.0.0; extra == 'reader'
|
|
26
|
+
Provides-Extra: temporal
|
|
27
|
+
Requires-Dist: temporalio<2,>=1.37; extra == 'temporal'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# harborrag-runtime
|
|
31
|
+
|
|
32
|
+
Composes [HarborRAG](https://github.com/cbtw-apac/HarborRAG) for production: it builds the
|
|
33
|
+
repositories, model clients and engine policies from settings, and runs ingestion either
|
|
34
|
+
inline or durably on Temporal. It also hosts the SDK facade, retrieval, chat and memory
|
|
35
|
+
composition, schedules, topology enrichment and the application services that the
|
|
36
|
+
`harborrag-app` HTTP API and CLI call. Domain types and ports live in `harborrag-core`;
|
|
37
|
+
the retrieval, ingestion and topology use cases live in `harborrag-engine`; adapters and
|
|
38
|
+
the engine stay unaware of Temporal.
|
|
39
|
+
|
|
40
|
+
To use HarborRAG as a library, install the [`harborrag`](https://pypi.org/project/harborrag/)
|
|
41
|
+
facade instead, which re-exports this package's SDK.
|
|
42
|
+
|
|
43
|
+
| I want to… | Start here |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| Ingest or search from Python | [Use the SDK from Python](#use-the-sdk-from-python). |
|
|
46
|
+
| Start an ingestion worker | [Run ingestion durably on Temporal](#run-ingestion-durably-on-temporal). |
|
|
47
|
+
| Find code to change | [Find your way around the package](#find-your-way-around-the-package). |
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install "harborrag-runtime[temporal]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The install brings `harborrag-core`, `harborrag-engine` and `harborrag-adapters`. The
|
|
56
|
+
`temporal` extra adds the Temporal client that durable ingestion
|
|
57
|
+
needs. `reader` adds the clients retrieval needs, `production` the clients the ingestion
|
|
58
|
+
worker needs and `chat` the model client.
|
|
59
|
+
|
|
60
|
+
## Use the SDK from Python
|
|
61
|
+
|
|
62
|
+
`harborrag_runtime.sdk.HarborRAG`, re-exported by the `harborrag` package, is an async
|
|
63
|
+
context manager. Direct execution is the lightweight default for local development, smoke
|
|
64
|
+
tests and embedding HarborRAG as a library; Temporal execution adds durable `submit`,
|
|
65
|
+
`status`, `pause`, `resume` and `cancel`. Both run the same engine policies and production
|
|
66
|
+
repository graph. Examples and the settings the SDK reads are in the
|
|
67
|
+
[Python SDK guide](https://github.com/cbtw-apac/HarborRAG/blob/main/docs/users/python-sdk/README.md).
|
|
68
|
+
|
|
69
|
+
Installed plugins are discovered only with `discover_plugins: true`. The entry-point
|
|
70
|
+
groups are `harborrag.connectors`, `harborrag.parsers`, `harborrag.model_providers`,
|
|
71
|
+
`harborrag.vector_repositories`, `harborrag.graph_repositories` and
|
|
72
|
+
`harborrag.object_stores`. Every plugin declares its capabilities and an explicit
|
|
73
|
+
`register()` operation; importing a module alone never registers it.
|
|
74
|
+
|
|
75
|
+
## Run ingestion durably on Temporal
|
|
76
|
+
|
|
77
|
+
To start the worker for the first time, follow the
|
|
78
|
+
[local stack quick start](https://github.com/cbtw-apac/HarborRAG/blob/main/docs/getting-started/quick-start.md).
|
|
79
|
+
For an existing local stack with data services and Temporal running, use
|
|
80
|
+
`scripts/deployment/dev.sh worker` from the checkout. Follow a run in the Temporal UI to
|
|
81
|
+
check that the worker is polling and processing documents.
|
|
82
|
+
|
|
83
|
+
The worker builds one production `IngestionRuntime` per process from the configured
|
|
84
|
+
connector, parser, model, state, object, vector and graph settings, and polls the task
|
|
85
|
+
queues named in `config/temporal.yaml`. Its configuration files default to the paths
|
|
86
|
+
below; the variables override them:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
export HARBORRAG_TEMPORAL_CONFIG_PATH=config/temporal.yaml
|
|
90
|
+
export HARBORRAG_CONNECTOR_CONFIG_PATH=config/sources/connectors.yaml
|
|
91
|
+
export HARBORRAG_PARSER_CONFIG_PATH=config/ingestion/parsers.yaml
|
|
92
|
+
export HARBORRAG_MODEL_CONFIG_PATH=config/models/models.yaml
|
|
93
|
+
python -m harborrag_runtime.temporal.worker
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The worker images run the same module. In the local stack, `scripts/deployment/dev.sh`
|
|
97
|
+
starts the worker in Docker; see the
|
|
98
|
+
[deployment guide](https://github.com/cbtw-apac/HarborRAG/blob/main/docs/developers/deployment/README.md).
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
SourceIngestionWorkflow
|
|
102
|
+
-> SourceBatchWorkflow
|
|
103
|
+
-> DocumentIngestionWorkflow
|
|
104
|
+
fetch -> parse -> canonical -> chunk -> encode
|
|
105
|
+
-> vector + graph -> verify -> publish
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Workflow history holds document-version identifiers and object-store references, never
|
|
109
|
+
raw documents, chunk bodies, tables, embeddings or graph batches. Activities treat
|
|
110
|
+
Postgres as the publication authority and Qdrant and FalkorDB as rebuildable projections.
|
|
111
|
+
|
|
112
|
+
The Temporal YAML owns connection defaults, task queues, retry budgets, worker capacity and
|
|
113
|
+
timeouts. Environment values such as `HARBORRAG_TEMPORAL_TARGET` override them per
|
|
114
|
+
deployment. Every supported field is listed in
|
|
115
|
+
[Temporal configuration](https://github.com/cbtw-apac/HarborRAG/blob/main/deploy/temporal/README.md).
|
|
116
|
+
Keep `HARBORRAG_TEMPORAL_API_KEY` in `env/.env.temporal` or a secret manager.
|
|
117
|
+
|
|
118
|
+
Operators drive the same runtime with the `harborrag ingestions` commands of a repository
|
|
119
|
+
checkout. How they name a connection and follow a run is in the
|
|
120
|
+
[CLI reference](https://github.com/cbtw-apac/HarborRAG/blob/main/docs/users/cli-reference/README.md#run-and-control-ingestion).
|
|
121
|
+
|
|
122
|
+
Applications that bypass the SDK can submit to Temporal with
|
|
123
|
+
`temporal.client.IngestionTemporalClient`. `temporal.submission.build_source_input(settings,
|
|
124
|
+
submission, connection=...)` needs the `ResolvedConnection` that
|
|
125
|
+
`ingestion.connections.ConnectionResolver.resolve(tenant_id=..., source_key=...)` returns;
|
|
126
|
+
resolving a connection also saves a connection revision to the control database. The
|
|
127
|
+
client's `start_ingestion` returns a reference whose `run_id` is the task ID that
|
|
128
|
+
`get_status` takes.
|
|
129
|
+
|
|
130
|
+
## Topology operator services
|
|
131
|
+
|
|
132
|
+
`topology/` holds the operator services for topology enrichment: tenant configuration,
|
|
133
|
+
status, runs, rebuild, entity and build inspection, summary projection, cleanup and ACL
|
|
134
|
+
snapshot import, plus `ingestion/maintenance/projection_admin.py` for the projection
|
|
135
|
+
inventory. The `harborrag topology` commands that called them were removed in 2.0.0, and
|
|
136
|
+
no HTTP route or MCP tool calls them yet, so they have no operator entry point.
|
|
137
|
+
|
|
138
|
+
## Retrieve and rerank
|
|
139
|
+
|
|
140
|
+
The retrieval use cases (permission-scoped search, evidence selection, graph and reader
|
|
141
|
+
workflows) live in the
|
|
142
|
+
[`harborrag_engine.retrieval.service`](https://github.com/cbtw-apac/HarborRAG/tree/main/packages/harborrag-engine/src/harborrag_engine/retrieval/service)
|
|
143
|
+
package, where `RuntimeRetrievalService` is `retrieval/service/service.py`. This
|
|
144
|
+
package's `retrieval/` module wires it to adapters: `connect_retrieval_service` composes
|
|
145
|
+
the same embedding model, active Qdrant collection, FalkorDB graph and canonical chunk
|
|
146
|
+
object store that ingestion writes. Query embeddings are marked sensitive and
|
|
147
|
+
non-cacheable.
|
|
148
|
+
|
|
149
|
+
The rerank stage is `PassageReranker` in the engine's
|
|
150
|
+
[`reranking.py`](https://github.com/cbtw-apac/HarborRAG/blob/main/packages/harborrag-engine/src/harborrag_engine/retrieval/service/reranking.py).
|
|
151
|
+
It orders passages the caller may already read, using the client built from the `rerank`
|
|
152
|
+
section of the model catalog. It puts the model's score in `metadata["rerank_score"]` and
|
|
153
|
+
leaves `relevance` at the lane's similarity. Passage text is sent to the rerank provider
|
|
154
|
+
as sensitive and non-cacheable.
|
|
155
|
+
|
|
156
|
+
## Monitor ingestion
|
|
157
|
+
|
|
158
|
+
Every ingestion activity emits an OpenTelemetry span with a controlled stage name, plus
|
|
159
|
+
low-cardinality Prometheus metrics. The Compose worker serves its process registry on port
|
|
160
|
+
`9464`, and `deploy/prometheus/prometheus.yml` scrapes it as
|
|
161
|
+
`harborrag-ingestion-worker`. The metrics cover stage outcomes and durations, document
|
|
162
|
+
lifecycle counts, durable artifact bytes, route and evidence chunks, Temporal retries,
|
|
163
|
+
projection verification failures, cleanup failures, stale retrieval candidates and
|
|
164
|
+
connector rate-limit waits.
|
|
165
|
+
|
|
166
|
+
Model telemetry uses the adapters' privacy sanitizer. OpenTelemetry is on for embedding
|
|
167
|
+
calls; Langfuse is opt-in with `HARBORRAG_LANGFUSE_ENABLED=true` and is never attached to
|
|
168
|
+
canonical documents, chunk payloads, Qdrant points or FalkorDB properties.
|
|
169
|
+
|
|
170
|
+
## Load the connector and parser catalogs
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from harborrag_runtime.config import load_connector_catalog, load_parser_catalog
|
|
174
|
+
|
|
175
|
+
connectors = load_connector_catalog("config/sources/connectors.yaml").build_enabled()
|
|
176
|
+
parsers = load_parser_catalog("config/ingestion/parsers.yaml").build_harbor_parser()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`build_enabled()` raises `ConnectorConfigurationError` until every environment variable
|
|
180
|
+
the enabled connectors reference is set, such as `LOCAL_SOURCE_PATH` or
|
|
181
|
+
`CONFLUENCE_BASE_URL` from `env/.env.connector`.
|
|
182
|
+
|
|
183
|
+
## Find your way around the package
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
src/harborrag_runtime/
|
|
187
|
+
sdk/ # stable SDK facade: HarborRAG, its configuration and service facades
|
|
188
|
+
execution/ # direct and durable execution strategies, source submission, task registry
|
|
189
|
+
temporal/ # workflows, activities, client, gateway, schedule backend and the worker
|
|
190
|
+
ingestion/ # document normalization and per-run parser choice, source orchestration, relation repair, retention and failure classification
|
|
191
|
+
retrieval/ # composition of the retrieval service from settings, and service facades
|
|
192
|
+
chat/ # chat service, model-client composition and per-tenant chat clients
|
|
193
|
+
application/ # application services that harborrag-app calls: chat, memory, ingestion, control plane, retrieval access, scheduling
|
|
194
|
+
memory/ # chat conversation history: messages, titles, turn locks, usage records,
|
|
195
|
+
# the conversation directory, administration and erasure; imports only core
|
|
196
|
+
scheduling/ # schedule management on top of the execution engine
|
|
197
|
+
topology/ # opt-in durable topology enrichment, independent of publication
|
|
198
|
+
composition/ # control-plane repositories, MCP reader composition, storage factories
|
|
199
|
+
config/ # HARBORRAG_* settings, Temporal configuration, connector and parser catalogs
|
|
200
|
+
config_store/ # runtime access to settings stored in the control database
|
|
201
|
+
connections/ # connection services shared by the API and the workers
|
|
202
|
+
security/ # operator-side security operations
|
|
203
|
+
observability/ # telemetry shared by reader and ingestion compositions
|
|
204
|
+
events/ # runtime event contracts and publication
|
|
205
|
+
ingestion_contracts.py # provider-neutral durable ingestion gateway and its outcomes
|
|
206
|
+
contracts.py # stable request and response contracts of the SDK
|
|
207
|
+
reader_contracts.py # compatibility exports for reader contracts
|
|
208
|
+
document_stage_catalog.py # sandbox-safe catalog of document stages
|
|
209
|
+
temporal_models.py # replay-safe routing and retry models
|
|
210
|
+
plugins.py # entry-point plugin discovery and registration
|
|
211
|
+
rate_limiting.py # connector rate-limit coordination
|
|
212
|
+
serialization.py # deterministic JSON conversion of runtime values
|
|
213
|
+
errors.py # runtime and Temporal boundary errors
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The ingestion services and their dependency rules are described in the
|
|
217
|
+
[ingestion runtime notes](https://github.com/cbtw-apac/HarborRAG/blob/main/packages/harborrag-runtime/src/harborrag_runtime/ingestion/README.md),
|
|
218
|
+
the application services in the
|
|
219
|
+
[application notes](https://github.com/cbtw-apac/HarborRAG/blob/main/packages/harborrag-runtime/src/harborrag_runtime/application/README.md),
|
|
220
|
+
and chat composition in the
|
|
221
|
+
[runtime chat notes](https://github.com/cbtw-apac/HarborRAG/blob/main/packages/harborrag-runtime/src/harborrag_runtime/chat/README.md).
|
|
222
|
+
|
|
223
|
+
The public `harborrag_runtime.sdk` module is a stable facade. Its data contracts,
|
|
224
|
+
configuration parsing, execution strategies and retrieval service live in focused modules
|
|
225
|
+
behind it. Direct and Temporal strategies use the same submission builder, so the
|
|
226
|
+
execution mode does not change request identity or filtering semantics.
|
|
227
|
+
|
|
228
|
+
Applications submit durable ingestion through `ingestion_contracts.IngestionGateway`. Its
|
|
229
|
+
submission, retry, status and result types hold no Temporal replay state or workflow
|
|
230
|
+
options; `temporal.gateway.TemporalIngestionGateway` translates them to Temporal payloads
|
|
231
|
+
and back. Connector preparation and task registration live in
|
|
232
|
+
`execution/source_submission.py` and `execution/task_registry.py`, so changing the
|
|
233
|
+
execution provider does not change the application's ingestion services. The application
|
|
234
|
+
composition takes a gateway factory that receives `RuntimeSettings`, plus a separate
|
|
235
|
+
provider description for health reporting. The default composition turns the Temporal YAML
|
|
236
|
+
policy into `SourceSubmissionDefaults`; another composition can call
|
|
237
|
+
`prepare_source_submission` with its own defaults without loading Temporal configuration.
|
|
238
|
+
|
|
239
|
+
`document_stage_catalog.py` and `temporal_models.py` stay lightweight top-level modules on
|
|
240
|
+
purpose. Temporal imports them inside its restricted workflow sandbox, so placing them
|
|
241
|
+
below provider-owning packages would run adapter initialization during workflow
|
|
242
|
+
registration.
|
|
243
|
+
|
|
244
|
+
Resource lifecycle and runtime observation stay with the components that own them. There
|
|
245
|
+
is no generic lifecycle port, local job queue or supervisor: durable orchestration,
|
|
246
|
+
including recurring schedules, runs on Temporal, and the core repository ports in
|
|
247
|
+
`harborrag-core` are the authoritative persistence contracts.
|
|
248
|
+
|
|
249
|
+
## Contributing
|
|
250
|
+
|
|
251
|
+
See [CONTRIBUTING](https://github.com/cbtw-apac/HarborRAG/blob/main/CONTRIBUTING.md).
|
|
252
|
+
Tests for this package live in `packages/harborrag-runtime/tests/`. Run them from the
|
|
253
|
+
repository root:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
uv run pytest packages/harborrag-runtime/tests
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The deployed ingestion smoke test checks the real Temporal runtime and every projection
|
|
260
|
+
store. It clears every logical database on the configured Redis instance. Use a dedicated
|
|
261
|
+
Redis instance for the smoke test and read its
|
|
262
|
+
[README](https://github.com/cbtw-apac/HarborRAG/blob/main/packages/harborrag-runtime/tests/runtime_ingestion/smoke/README.md)
|
|
263
|
+
before you run it.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
Apache License 2.0.
|