2025-12-17 21:40:43 +00:00
|
|
|
from dataclasses import dataclass, field
|
2025-08-04 21:42:57 +01:00
|
|
|
from ..core.primitives import Triple, Error
|
Pub/sub abstraction: decouple from Pulsar (#751)
Remove Pulsar-specific concepts from application code so that
the pub/sub backend is swappable via configuration.
Rename translators:
- to_pulsar/from_pulsar → decode/encode across all translator
classes, dispatch handlers, and tests (55+ files)
- from_response_with_completion → encode_with_completion
- Remove pulsar.schema.Record from translator base class
Queue naming (CLASS:TOPICSPACE:TOPIC):
- Replace topic() helper with queue() using new format:
flow:tg:name, request:tg:name, response:tg:name, state:tg:name
- Queue class implies persistence/TTL (no QoS in names)
- Update Pulsar backend map_topic() to parse new format
- Librarian queues use flow class (persistent, for chunking)
- Config push uses state class (persistent, last-value)
- Remove 15 dead topic imports from schema files
- Update init_trustgraph.py namespace: config → state
Confine Pulsar to pulsar_backend.py:
- Delete legacy PulsarClient class from pubsub.py
- Move add_args to add_pubsub_args() with standalone flag
for CLI tools (defaults to localhost)
- PulsarBackendConsumer.receive() catches _pulsar.Timeout,
raises standard TimeoutError
- Remove Pulsar imports from: async_processor, flow_processor,
log_level, all 11 client files, 4 storage writers, gateway
service, gateway config receiver
- Remove log_level/LoggerLevel from client API
- Rewrite tg-monitor-prompts to use backend abstraction
- Update tg-dump-queues to use add_pubsub_args
Also: pubsub-abstraction.md tech spec covering problem statement,
design goals, as-is requirements, candidate broker assessment,
approach, and implementation order.
2026-04-01 20:16:53 +01:00
|
|
|
from ..core.topic import queue
|
2025-08-04 21:42:57 +01:00
|
|
|
from ..core.metadata import Metadata
|
|
|
|
|
from .document import Document, TextDocument
|
|
|
|
|
from .graph import Triples
|
|
|
|
|
from .embeddings import GraphEmbeddings
|
2025-05-06 23:44:10 +01:00
|
|
|
|
2025-05-07 11:13:21 +01:00
|
|
|
# get-kg-core
|
2025-05-06 23:44:10 +01:00
|
|
|
# -> (???)
|
|
|
|
|
# <- ()
|
|
|
|
|
# <- (error)
|
|
|
|
|
|
|
|
|
|
# delete-kg-core
|
|
|
|
|
# -> (???)
|
|
|
|
|
# <- ()
|
|
|
|
|
# <- (error)
|
|
|
|
|
|
|
|
|
|
# list-kg-cores
|
|
|
|
|
# -> (user)
|
|
|
|
|
# <- ()
|
|
|
|
|
# <- (error)
|
|
|
|
|
|
2025-12-17 21:40:43 +00:00
|
|
|
@dataclass
|
|
|
|
|
class KnowledgeRequest:
|
2025-05-07 11:13:21 +01:00
|
|
|
# get-kg-core, delete-kg-core, list-kg-cores, put-kg-core
|
2025-05-08 00:41:45 +01:00
|
|
|
# load-kg-core, unload-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
operation: str = ""
|
2025-05-06 23:44:10 +01:00
|
|
|
|
2025-05-07 11:13:21 +01:00
|
|
|
# list-kg-cores, delete-kg-core, put-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
user: str = ""
|
2025-05-06 23:44:10 +01:00
|
|
|
|
2025-05-08 00:41:45 +01:00
|
|
|
# get-kg-core, list-kg-cores, delete-kg-core, put-kg-core,
|
|
|
|
|
# load-kg-core, unload-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
id: str = ""
|
2025-05-06 23:44:10 +01:00
|
|
|
|
2025-05-08 00:41:45 +01:00
|
|
|
# load-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
flow: str = ""
|
2025-05-08 00:41:45 +01:00
|
|
|
|
|
|
|
|
# load-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
collection: str = ""
|
2025-05-08 00:41:45 +01:00
|
|
|
|
2025-05-07 11:13:21 +01:00
|
|
|
# put-kg-core
|
2025-12-17 21:40:43 +00:00
|
|
|
triples: Triples | None = None
|
|
|
|
|
graph_embeddings: GraphEmbeddings | None = None
|
2025-05-07 11:13:21 +01:00
|
|
|
|
2025-12-17 21:40:43 +00:00
|
|
|
@dataclass
|
|
|
|
|
class KnowledgeResponse:
|
|
|
|
|
error: Error | None = None
|
|
|
|
|
ids: list[str] = field(default_factory=list)
|
|
|
|
|
eos: bool = False # Indicates end of knowledge core stream
|
|
|
|
|
triples: Triples | None = None
|
|
|
|
|
graph_embeddings: GraphEmbeddings | None = None
|
2025-05-06 23:44:10 +01:00
|
|
|
|
Pub/sub abstraction: decouple from Pulsar (#751)
Remove Pulsar-specific concepts from application code so that
the pub/sub backend is swappable via configuration.
Rename translators:
- to_pulsar/from_pulsar → decode/encode across all translator
classes, dispatch handlers, and tests (55+ files)
- from_response_with_completion → encode_with_completion
- Remove pulsar.schema.Record from translator base class
Queue naming (CLASS:TOPICSPACE:TOPIC):
- Replace topic() helper with queue() using new format:
flow:tg:name, request:tg:name, response:tg:name, state:tg:name
- Queue class implies persistence/TTL (no QoS in names)
- Update Pulsar backend map_topic() to parse new format
- Librarian queues use flow class (persistent, for chunking)
- Config push uses state class (persistent, last-value)
- Remove 15 dead topic imports from schema files
- Update init_trustgraph.py namespace: config → state
Confine Pulsar to pulsar_backend.py:
- Delete legacy PulsarClient class from pubsub.py
- Move add_args to add_pubsub_args() with standalone flag
for CLI tools (defaults to localhost)
- PulsarBackendConsumer.receive() catches _pulsar.Timeout,
raises standard TimeoutError
- Remove Pulsar imports from: async_processor, flow_processor,
log_level, all 11 client files, 4 storage writers, gateway
service, gateway config receiver
- Remove log_level/LoggerLevel from client API
- Rewrite tg-monitor-prompts to use backend abstraction
- Update tg-dump-queues to use add_pubsub_args
Also: pubsub-abstraction.md tech spec covering problem statement,
design goals, as-is requirements, candidate broker assessment,
approach, and implementation order.
2026-04-01 20:16:53 +01:00
|
|
|
knowledge_request_queue = queue('knowledge', cls='request')
|
|
|
|
|
knowledge_response_queue = queue('knowledge', cls='response')
|