Skip to content

Add ObjectRepository and state machine unit tests#131

Open
code2tan wants to merge 2 commits into
zilliztech:mainfrom
code2tan:rebuild_repository
Open

Add ObjectRepository and state machine unit tests#131
code2tan wants to merge 2 commits into
zilliztech:mainfrom
code2tan:rebuild_repository

Conversation

@code2tan

@code2tan code2tan commented Jun 24, 2026

Copy link
Copy Markdown

Overview

Lands engine redesign: introduces ObjectRepository to consolidate SQL operations for the objects / object_tasks / connector_jobs / connectors tables out of engine.py into a dedicated
repository layer, and unifies task/job state transitions through a centralized state machine guard.

Key Changes

  • Added ObjectRepository (engine/components/object_repository.py, ~667 lines)

    • Unifies the CRUD SQL for the four metadata tables previously scattered across engine.py.
    • Introduces TaskStatus / JobStatus / ConnectorStatus enums and _TASK_TRANSITIONS / _JOB_TRANSITIONS transition tables to centrally guard state machine legality.
    • advance_task is now the single entry point for advancing state, preventing illegal transitions.
  • Slimmed down engine.py (543 lines changed, -431 / +112 net)

    • Replaces 30+ raw SQL calls with self.objects.* delegation.
    • Principle: pure move + delegation semantics, no behavior change.
  • Added unit tests tests/test_engine_object_repo.py (~613 lines)

    • Covers state transition guards, won == 0 orphan cleanup, and concurrent claim.

Invariant

Preserves the core invariant: a chunk exists in Milvus iff a committed objects row points at it (directory summaries are the deliberate exception). The finalize/cleanup paths preserve this invariant
via the repository layer.

Testing

  • uv run --extra dev pytest: all passing (including the new ObjectRepository / state machine unit tests).
  • ruff format --check + ruff check: clean.

code2t added 2 commits June 24, 2026 15:51
- Introduce `ObjectRepository` class to consolidate SQL operations for `objects`, `object_tasks`, `connector_jobs`, and `connectors` tables.
- Add comprehensive unit tests for the state machine, covering task and job transitions, as well as various repository operations.
- Update `ObjectRepository` constructor to accept `meta` and `cfg` instead of `engine`.
- Adjust method calls to use `self._cfg` for configuration values.
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