Skip to content

feat(core,backends): connectors framework — SPI evolution + filesystem/S3/GCS (Step 1.2)#55

Merged
officialCodeWork merged 2 commits into
mainfrom
build/phase-1/step-1.2-connectors-framework
May 24, 2026
Merged

feat(core,backends): connectors framework — SPI evolution + filesystem/S3/GCS (Step 1.2)#55
officialCodeWork merged 2 commits into
mainfrom
build/phase-1/step-1.2-connectors-framework

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Summary

  • Evolve the Connector SPI to ship a resumable ConnectorState watermark with each yielded document — list_documents now returns AsyncIterator[(Document, ConnectorState)]. The old since: datetime argument is gone.
  • New frozen ConnectorState type (connector_id, tenant_id, cursor, last_seen_at, extra); JSON Schema regenerated.
  • Internal Crawler[Raw] base class in rag_backends.connectors._base — iteration scaffold, "fail"/"skip" error policy, monotonic-watermark bookkeeping. Not part of the public SPI surface.
  • Built-in connectors:
    • FilesystemConnector — cross-platform pathlib walk, SHA-256 hashing, sorted absolute-path resume cursor.
    • S3Connectoraioboto3 paginator, ListObjectsV2 continuation-token cursor, MinIO-compatible (reuses existing dep).
    • GCSConnectorgcloud-aio-storage async client, GCS REST nextPageToken cursor; behind the [gcs] extra.
  • PolicyEngine boundary documented: connectors are upstream of policy; enforcement lives at the ingest call site (Step 1.10). Matches the pattern set by the storage backends.

Tests

  • tests/contract/test_connector.py — 8 conformance tests covering empty/seeded listing, tenant isolation, fetch, resume-from-cursor, watermark monotonicity, tenant-mismatch rejection.
  • tests/backends/test_filesystem_connector.py — 9 pure-Python unit tests, no services required.
  • tests/integration/test_s3_connector.py — runs against MinIO via the dev stack; skipped automatically when MinIO is unreachable.
  • tests/integration/test_gcs_connector.py — runs against real GCS; skipped when GOOGLE_APPLICATION_CREDENTIALS or TEST_GCS_BUCKET are absent.
  • spi_signature.py and tests/policy/coverage.py linters pass unchanged.
  • Full local suite: uv run pytest tests/ packages/ -x -q → green (integration suites skipped — no services running locally).
  • uv run mypy packages/core packages/backends apps/gateway → clean.
  • uv run ruff check + format --check → clean.

Documentation

  • docs/reference/connectors.md — public usage: filesystem / S3 / GCS examples, resumable-crawl pattern, error table.
  • docs/architecture/connectors.md — SPI shape rationale (why (doc, state) tuples beat a separate checkpoint()), Crawler design, policy boundary, CDC interaction (Step 1.9), extension points.
  • docs/README.md — index entries added under architecture/ and reference/.

Test plan

  • uv run pytest tests/ packages/ -x -q
  • uv run mypy packages/core packages/backends apps/gateway
  • uv run ruff check . && uv run ruff format --check .
  • uv run python -m rag_core.gen_schemas dist/schemas/ produces only the new ConnectorState.json
  • MinIO integration smoke (run task dev then uv run pytest tests/integration/test_s3_connector.py -m integration)
  • CI matrix green on ubuntu-22.04, macos-14, windows-latest

🤖 Generated with Claude Code

Deep Kumar Singh Kushwah and others added 2 commits May 24, 2026 20:15
…m/S3/GCS (Step 1.2)

Evolves the Connector SPI to ship a resumable watermark with each discovered
document, and lands three built-in connectors plus a shared internal crawler.

Core (rag_core):
- New ConnectorState frozen model (connector_id, tenant_id, cursor,
  last_seen_at, extra) added to rag_core.types and dist/schemas/.
- Connector.list_documents now returns AsyncIterator[(Document, ConnectorState)]
  — replaces the bare `since: datetime` argument. Resumable mid-stream.
- NoopConnector + contract tests updated with resume/watermark/tenant-mismatch
  coverage. spi_signature.py linter passes unchanged.

Backends (rag_backends.connectors):
- Internal Crawler[Raw] base class (iteration scaffold, fail/skip error
  policy, monotonic watermark bookkeeping). Not part of the SPI surface.
- FilesystemConnector: cross-platform pathlib walk, sha256 hashing,
  absolute-path resume cursor, mime detection.
- S3Connector: aioboto3 paginator, ListObjectsV2 continuation token,
  ETag-based content hash, MinIO-compatible.
- GCSConnector: gcloud-aio-storage, GCS REST nextPageToken cursor; behind
  the [gcs] extra (gcloud-aio-storage>=9.3).

Tests:
- tests/contract/test_connector.py — 8 tests (resume, watermark monotonicity,
  tenant-mismatch).
- tests/backends/test_filesystem_connector.py — 9 unit tests, pure-Python.
- tests/integration/test_s3_connector.py — MinIO; skip-if-no-service.
- tests/integration/test_gcs_connector.py — real GCS; skip when ADC absent.

Docs:
- docs/reference/connectors.md — public usage for all three connectors.
- docs/architecture/connectors.md — SPI shape rationale, Crawler design,
  policy boundary (connectors are upstream of PolicyEngine; enforcement
  lives in the Step 1.10 ingest pipeline), CDC interaction, extension points.
- docs/README.md updated.

Tracker:
- Step 1.2 flipped to 🚧 with branch + key deliverables.
- Phase 1 counts: 8→9 done, 8→7 remaining. Total: 21→22 done, 63→62.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tra)

CI runs `uv sync` without the `[gcs]` extra, so `gcloud.aio.storage` is
absent and mypy --strict fails on the GCSConnector import. Add `gcloud.*`
to the missing-imports allowlist alongside the other optional/untyped
backends (aioboto3, asyncpg, etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit 0f84665 into main May 24, 2026
11 checks passed
officialCodeWork added a commit that referenced this pull request May 24, 2026
chore(tracker): sync Step 1.2 → ✅ and log PR #55
officialCodeWork pushed a commit that referenced this pull request May 24, 2026
Conflict was over adjacent rows 1.2 and 1.3. Resolution keeps #56's
update to row 1.2 (✅ with PR #55 link) and this branch's update to
row 1.3 (🚧 with PR #57 link + Step 1.3 deliverables description).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant