Skip to content

Add shared docs mutation transport, reuse in CLI/HTTP, and extract maintenance helpers#59

Closed
Intrinsical-AI wants to merge 1 commit into
developfrom
codex/review-implementation-for-code-quality-improvements
Closed

Add shared docs mutation transport, reuse in CLI/HTTP, and extract maintenance helpers#59
Intrinsical-AI wants to merge 1 commit into
developfrom
codex/review-implementation-for-code-quality-improvements

Conversation

@Intrinsical-AI
Copy link
Copy Markdown
Owner

Motivation

  • Consolidate and harden transport-level validation for docs mutation payloads to avoid duplicated parsing logic across CLI and HTTP.
  • Reduce duplication in HTTP schemas and CLI payload assembly to prevent semantic drift and make input contracts single-source-of-truth.
  • Improve maintainability of multi-store delete logic by extracting preflight and vector-delete/rebuild steps into small helpers.

Description

  • Add a new module core.services.docs_mutation_transport providing DocsMutationPayload, MutationUpsertPayload, validate_docs_mutation_payload, build_docs_mutation_intent, and build_docs_mutation_intent_from_raw using pydantic for shared transport validation and intent construction.
  • Update the HTTP layer to reuse the shared builder via build_docs_mutation_intent and replace in-module schema duplication with DocsMutateRequest aliasing DocsMutationPayload and UpsertDocItem inheriting from MutationUpsertPayload.
  • Update the CLI command to use build_docs_mutation_intent_from_raw and map pydantic ValidationError/ValueError into a ValueError for consistent error handling.
  • Extract maintenance helpers _preflight_vector_store_or_resolve_embedder and _delete_vector_rows_or_rebuild and wire them into delete_documents_multi_store and delete_external_ids_multi_store to centralize preflight checks and rebuild-on-failure logic while preserving behavior.
  • Add unit tests tests/unit/core/services/test_docs_mutation_transport.py covering normalization, validation, conflict detection, and intent building.

Testing

  • Ran the targeted test set with uv run pytest -q -o addopts='' tests/unit/core/use_cases/test_docs_mutation_refactor.py tests/unit/core/services/test_maintenance.py tests/unit/core/services/test_evaluation.py tests/unit/application/services/test_mutation_ports.py tests/unit/cli/test_cli_mutation_boundary.py tests/unit/http/test_docs_index_ports_wiring.py and observed 50 tests passed.
  • Added tests/unit/core/services/test_docs_mutation_transport.py which exercises the new transport validation and intent builder and passed as part of the run.
  • No automated test failures were introduced by these changes.

Codex Task

@Intrinsical-AI Intrinsical-AI deleted the codex/review-implementation-for-code-quality-improvements branch April 26, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant