Skip to content

feat: add ManagedBy StrEnum for managed_by parameter#1807

Merged
georgeh0 merged 2 commits into
cocoindex-io:v1from
batmany13:feat/managed-by-strenum
Apr 5, 2026
Merged

feat: add ManagedBy StrEnum for managed_by parameter#1807
georgeh0 merged 2 commits into
cocoindex-io:v1from
batmany13:feat/managed-by-strenum

Conversation

@batmany13
Copy link
Copy Markdown
Contributor

@batmany13 batmany13 commented Apr 5, 2026

Summary

  • Introduces a ManagedBy StrEnum in python/cocoindex/connectorkits/target.py with SYSTEM and USER members
  • Replaces all 27 occurrences of Literal["system", "user"] across 6 target connectors (postgres, sqlite, lancedb, doris, qdrant, surrealdb) with target.ManagedBy
  • statediff.py imports ManagedBy from target.py for its own internal use (MutualTrackingRecord, resolve_system_transition) and keeps it in __all__ as a safety net, though no external code currently accesses ManagedBy through statediff
  • Fixes pre-existing mypy type errors in test_sqlite_target.py

Motivation

Scattered Literal["system", "user"] annotations made it easy to introduce typos and provided no IDE autocompletion. A single StrEnum gives a canonical source of truth and better developer experience. Since StrEnum inherits from str, this is fully backward compatible — existing string comparisons and serialization continue to work.

Closes #1806

Test plan

  • uv run mypy — 0 errors (was 7 on base v1, 2 of which are also fixed here)
  • uv run pytest python/ — 495 passed, 70 skipped
  • prek run --all-files — all 14 checks pass

🤖 Generated with Claude Code

Define a common ManagedBy StrEnum in connectorkits/target.py and use it
across all 6 target connectors instead of scattered Literal["system", "user"]
annotations. This gives a single source of truth, better IDE support, and
clearer semantics. Also fixes pre-existing mypy errors in the SQLite target
test by adding a type annotation and using the new enum.

Closes cocoindex-io#1806

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@batmany13
Copy link
Copy Markdown
Contributor Author

hold on, let me fix this, because its setting up the enum in statediff, which is confusing.

Since ManagedBy lives in connectorkits/target.py, connectors should
import it from there (target.ManagedBy) rather than going through
statediff. This makes the provenance clear.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@batmany13
Copy link
Copy Markdown
Contributor Author

ok @georgeh0 @badmonster0 for your review :)

cc @prabhath004

@georgeh0 georgeh0 merged commit 4a91178 into cocoindex-io:v1 Apr 5, 2026
14 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.

2 participants