For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Address CodeRabbit findings in ingest container and tests, update test expectations for stable IDs, and confirm CI health.
Architecture: Keep runtime behavior unchanged except for safer configuration defaults and repository loading. Replace brittle path logic with env-configurable or package-resource discovery and centralize repository loading in a helper. Update tests to reflect intended identity contract and improve isolation.
Tech Stack: Python, pytest/pytest-asyncio, SQLAlchemy async, FastAPI DI.
Files:
libs/ingest/application/tests/test_ingest_document_handler.pyStep 1: Write the failing test
1
2
3
4
5
6
async def test_ingest_document_url_without_scheme(self, handler, mock_fetcher):
...
result = await handler.execute(command)
assert result.success is False
assert "Invalid source URL" in result.error
assert not mock_fetcher.fetch_called
Step 2: Run test to verify it fails
Run: python -m pytest libs/ingest/application/tests/test_ingest_document_handler.py::TestIngestDocumentHandler::test_ingest_document_url_without_scheme -v
Expected: FAIL because fetch_called is not asserted.
Step 3: Write minimal implementation
@pytest_asyncio.fixture to @pytest.fixture for mock_repository and mock_fetcher.assert not mock_fetcher.fetch_called to test_ingest_document_url_without_scheme.Step 4: Run test to verify it passes
Run: python -m pytest libs/ingest/application/tests/test_ingest_document_handler.py -v
Expected: PASS.
Step 5: Commit
1
2
git add libs/ingest/application/tests/test_ingest_document_handler.py
git commit -m "test: tighten ingest handler fixtures and URL validation"
Files:
libs/ingest/application/src/container.pyStep 1: Write the failing test
No direct test exists. Add a minimal focused test only if behavior regression is likely; otherwise validate with existing tests and just ci.
Step 2: Implement minimal code
from fastapi import Depends.DATABASE_URL when ENVIRONMENT is not development or test.load_policy_document_repository().INGEST_ROOT or package resource discovery to resolve the repository file path.get_ingest_document_handler and get_get_document_handler synchronous.provide_ingest_handler() and provide_document_handler() signatures.Step 3: Run test to verify it passes
Run: python -m pytest libs/ingest/application/tests/test_ingest_document_handler.py -v
Expected: PASS.
Step 4: Commit
1
2
git add libs/ingest/application/src/container.py
git commit -m "refactor: harden ingest container wiring"
Files:
libs/ingest/adapters/tests/integration/test_handler_integration.pyStep 1: Write the failing test
Add expectations for stable IDs and persisted updated content in test_ingest_document_updates_existing.
Step 2: Run test to verify it fails
Run: python -m pytest libs/ingest/adapters/tests/integration/test_handler_integration.py::TestIngestDocumentIntegration::test_ingest_document_updates_existing -v
Expected: FAIL due to missing assertions and session isolation.
Step 3: Write minimal implementation
Optional import.db_session in a transaction with nested savepoint and rollback after each test.test_ingest_document_updates_existing, assert result2.result.id == original_id and validate stored content is "Updated content" using repository.get(original_id).Step 4: Run test to verify it passes
Run: python -m pytest libs/ingest/adapters/tests/integration/test_handler_integration.py -v
Expected: PASS.
Step 5: Commit
1
2
git add libs/ingest/adapters/tests/integration/test_handler_integration.py
git commit -m "test: isolate ingest integration sessions and assert update semantics"
Files:
tmp/coderabbit_results.mdStep 1: Check off completed tasks
Mark all completed items as [x].
Step 2: Run full CI
Run: just ci
Expected: PASS.
Step 3: Commit
1
2
git add tmp/coderabbit_results.md
git commit -m "chore: check off CodeRabbit tasks"