Skip to content

feat(streaming): add event-driven ingestion for issue #891 - #1045

Merged
AmitoVrito merged 12 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-891-streaming-ingestion
Sep 20, 2026
Merged

AmitoVrito merged 12 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-891-streaming-ingestion

Conversation

@DhruvGarg111

Copy link
Copy Markdown
Collaborator

Summary

  • Add an async-first StreamingIngestor pipeline with normalization, batching, backpressure, acknowledgements, retries, and graceful shutdown.
  • Add optional Kafka/Redpanda, Pulsar, AWS Kinesis, Debezium-style CDC, and PostgreSQL logical-replication sources.
  • Add durable SQLite/in-memory checkpoints and idempotent VectorStore, WorldModelRAG, and KnowledgeMesh targets.
  • Preserve event timestamps as valid_at and append distinct temporal WorldModel edges.
  • Add public exports, provider extras, documentation, an example, and a Kafka Testcontainers acceptance test.

Closes #891

Validation

  • uv sync --group dev --locked
  • uv run ruff check src/ tests/
  • uv run ruff format --check src/ tests/
  • uv run mypy
  • uv run deptry src/
  • uv run python scripts/check_async_blocking.py
  • uv lock --check
  • Streaming and public API tests: 27 passed, 1 skipped
  • Local KnowledgeMesh close/reopen and checkpoint replay check passed

The Kafka Testcontainers test is wired into the integration CI job. It could not be run locally because Docker is unavailable.

DhruvGarg111 and others added 11 commits September 16, 2026 18:20
stop() tore the source down before an in-flight batch finished acking,
so a source that had already committed its offset teardown (e.g.
KafkaSource nulling its consumer) could silently no-op the ack for a
batch already upserted into the target, causing spurious redelivery on
restart. A batch lock now serializes the upsert+commit+ack sequence
against stop()'s teardown, while still allowing stop() to interrupt a
source blocked on its next-event wait.

Co-authored-by: Dhruv Garg <[email protected]>
_document_ids only recognized metadata["document_id"], which was set
exclusively by normalize_debezium_event. The default transform used by
Kafka/Kinesis/Pulsar/JSON sources never set it, so delete/tombstone
documents from those sources silently failed to remove the prior
record from the vector store. Reuse the source's message key (the
standard Kafka/Pulsar log-compacted-topic entity identity) as the
default document_id when present, so non-CDC sources get working
delete/tombstone support too.

Co-authored-by: Dhruv Garg <[email protected]>
KafkaSource and PulsarSource never used the injected CheckpointStore
to resume, unlike KinesisSource/PostgresCDCSource, and the docs
implied uniform checkpoint-store-based resume for every source. They
actually resume via their own native consumer-group/subscription
offset commits. Document that distinction directly on the classes so
it isn't silently discovered at restart time.

Co-authored-by: Dhruv Garg <[email protected]>
KnowledgeMeshSink.upsert's post-ingest sequence (mark_file_chunks,
stale-chunk delete, _save_vector_store) had no rollback: if rag.ingest
succeeded but a later step raised, the on-disk mesh index was left
stale relative to what the vector store already had, with no repair
path. Wrap the sequence so _save_vector_store still runs on failure,
persisting whatever mesh-index state was reached instead of losing it.

Co-authored-by: Dhruv Garg <[email protected]>
docs/* is repo-gitignored (internal strategy/plan docs stay local
only, per .gitignore's "Internal docs (not published)" section) with
an explicit per-file allowlist. These two files were committed via
git add -f, bypassing that. The usage guide belongs in the
synapsekit-docs site, not this repo's internal docs/ tree.

Co-authored-by: Dhruv Garg <[email protected]>
…tamps

ingest() fell back to metadata["timestamp"]/["event_timestamp"] when
"valid_at" was absent. Pre-existing loaders (Kafka, Slack, Teams, ...)
already stamp a "timestamp" key for unrelated purposes (message send
time, not extracted-fact validity), so any pre-existing KnowledgeMesh
pipeline ingesting that content would have that value silently
repurposed as valid_at, changing edge_id and time-travel query
results with no streaming code involved. Only "valid_at" -- the key
streaming's ingestor explicitly sets -- is used now.

Co-authored-by: Dhruv Garg <[email protected]>
…dity

upsert_relation forks a relation's edge_id when it re-ingests the same
subject/predicate/object with a different valid_at. Preferring the
extractor's valid_at over the document's own timestamp meant that path
was live for LLM-based extraction: re-running extraction on redelivery
(a checkpoint replay, say) can yield a slightly different LLM-derived
valid_at each time, silently duplicating the edge. The document's own
timestamp -- deterministic for a streamed event -- now wins when both
are present.

Co-authored-by: Dhruv Garg <[email protected]>
upsert_relation's merge branch only ever set edge.valid_until when it
was previously unset, so once any bound was recorded it could never be
corrected. Streaming makes this routine rather than rare: CDC/Kafka
sources emit repeated updates to the same triple, and valid_until also
gates live query filtering, so a wrong early bound would silently and
permanently corrupt "is this fact still valid" results. A newly
supplied valid_until now takes precedence over a stale one.

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Retriggering CI after pushing fixes from review — reopening immediately.

@AmitoVrito AmitoVrito closed this Sep 20, 2026
@AmitoVrito AmitoVrito reopened this Sep 20, 2026
# Conflicts:
#	.github/workflows/ci.yml
@AmitoVrito
AmitoVrito merged commit 1f0199c into SynapseKit:main Sep 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming / event-driven ingestion — keep the knowledge mesh live

2 participants