refactor(phase8-g1): carve export v1 shim to knowledge_base domain (#47)#1677
Merged
Conversation
Per PM scope (msg=7733c905) and Bryce inventory G1: complete the export carve trail started by #1670 (ExportTask ORM) and #1672 (export_collection_task). Pure carve / move; URL contract `/api/v1/export*` and `/api/v1/export-tasks*` unchanged. Changes: - aperag/views/export.py → aperag/domains/knowledge_base/api/export_routes.py (3 routes: create_export_task / get_export_task / download_export; switched User ORM dep → AuthenticatedUser Protocol, matching the canonical KB routes pattern) - aperag/service/export_service.py → aperag/domains/knowledge_base/service/export_service.py (git mv preserves history; replaced view_models.ExportTaskResponse references with bare ExportTaskResponse imported from KB schemas) - ExportTaskResponse schema migrated from aperag/schema/view_models.py to aperag/domains/knowledge_base/schemas.py (added to __all__); view_models.py keeps a backward-compat re-export following the same pattern used for knowledge_graph/retrieval schemas - aperag/app.py: import switched from aperag.views.export to aperag.domains.knowledge_base.api.export_routes; mount prefix remains /api/v1 (D1 hard-cut to /api/v2 deferred to later G3+ batch) Verification: - pytest tests/unit_test/test_modularization_boundaries.py -x → 21 passed (G1-G19 all green; new KB route does not import legacy aggregates) - pytest tests/unit_test/ → 686 passed, 29 skipped (matches phase8 baseline) - grep "from aperag.service.export_service|from aperag.views.export" returns 0 hits in aperag/, tests/, config/ - python -c "from aperag.app import app; ..." confirms 3 export endpoints remain at /api/v1/collections/{id}/export, /api/v1/export-tasks/{id}, /api/v1/export-tasks/{id}/download aperag/service/ retains exactly the 3 permanent seam files (quota_service / prompt_template_service / search_pipeline_service); no Layer A / Layer B violation. Ghost-check: none. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Per @符炫炜 D7 canonical update (msg=30405f5b) + PM msg=3b0c2589:
G1 includes URL prefix migration `/api/v1/export*` → `/api/v2/export*`,
not just file carve.
- aperag/app.py: export_router mount /api/v1 → /api/v2
- aperag/domains/knowledge_base/api/export_routes.py: docstring updated
to reflect D7 v2 hard-cut
- aperag/domains/knowledge_base/service/export_service.py: download_url
template /api/v1/... → /api/v2/...
- web/src/api-v2/schema.d.ts: 3 export route key strings v1 → v2
- web/src/features/collection/client-api.ts: 2 client call paths v1 → v2
- tests/unit_test/test_web_typed_api_contract.py: assertions and comment
updated to expect v2 paths post-D7
Verification:
- pytest tests/unit_test/test_modularization_boundaries.py
tests/unit_test/test_web_typed_api_contract.py -x → 37 passed
- python -c "from aperag.app import app; ..." → 3 export endpoints
now mounted at /api/v2/{collections/{id}/export, export-tasks/{id},
export-tasks/{id}/download}
- grep "/api/v1/export" aperag/ tests/ web/ config/ → 0 hits
(a single unrelated historical comment about KG-eval export remains
in knowledge_graph/api/routes.py:259, untouched)
Ghost-check: none.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 8 task #47 — G1 export v1 shim carve
Closes task #47 (msg=fbcdd2b5) per PM scope (msg=7733c905) + 符炫炜 D2 canonical (ExportTask carve to KB) and Bryce inventory G1.
Summary
aperag/views/export.pyto canonical KB domainaperag/service/export_service.pyto KB domain (completes the trail: cleanup(phase8/task39): legacy ORM carve + old evaluation stack hard-delete + partial unique indexes #1670 ExportTask ORM → cleanup(phase8): move export_collection_task to KB domain (Option β follow-up to #1670) #1672 export_collection_task → feat: models define #47 export_service + route + schema)ExportTaskResponseschema from legacyaperag/schema/view_models.pytoaperag/domains/knowledge_base/schemas.py/api/v1/export*and/api/v1/export-tasks*unchanged (D1 v2 hard-cut deferred to G3+ batch)Files
aperag/domains/knowledge_base/api/export_routes.py— new canonical route (3 routes; usesAuthenticatedUserProtocol per KB pattern)aperag/domains/knowledge_base/schemas.py—ExportTaskResponseclass added +__all__entryaperag/schema/view_models.py—ExportTaskResponsedefinition removed; re-export added (matches existing knowledge_graph / retrieval re-export blocks)aperag/domains/knowledge_base/service/export_service.py— git mv fromaperag/service/export_service.py; replaced 4view_models.ExportTaskResponsewith bareExportTaskResponseaperag/app.py—from aperag.views.export import router→from aperag.domains.knowledge_base.api.export_routes import router; mount prefix/api/v1unchangedaperag/views/export.py— deletedaperag/service/retains exactly the 3 permanent seam files (quota_service.py,prompt_template_service.py,search_pipeline_service.py) per Phase 7 §1 Layer A + Layer B.Acceptance gates
pytest tests/unit_test/test_modularization_boundaries.py -x→ 21 passed (G1-G19 all green; new KB route imports zero legacy aggregates)pytest tests/unit_test/ -x --ignore=objectstore→ 686 passed, 29 skipped (matches Phase 8 first-batch baseline)grep "from aperag\\.service\\.export_service\\|from aperag\\.views\\.export" aperag/ tests/ config/→ 0 hits/api/v1/collections/{id}/export,/api/v1/export-tasks/{task_id},/api/v1/export-tasks/{task_id}/downloadGhost-check
none. No new backend coupling, no behavior change, no scope creep beyond what was needed for G1 to clear.
🤖 Generated with Claude Code