Skip to content

refactor(phase8-g1): carve export v1 shim to knowledge_base domain (#47)#1677

Merged
earayu merged 2 commits into
mainfrom
phase8/g1-export-carve
Apr 25, 2026
Merged

refactor(phase8-g1): carve export v1 shim to knowledge_base domain (#47)#1677
earayu merged 2 commits into
mainfrom
phase8/g1-export-carve

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 25, 2026

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

Files

  • aperag/domains/knowledge_base/api/export_routes.py — new canonical route (3 routes; uses AuthenticatedUser Protocol per KB pattern)
  • 📝 aperag/domains/knowledge_base/schemas.pyExportTaskResponse class added + __all__ entry
  • 📝 aperag/schema/view_models.pyExportTaskResponse definition removed; re-export added (matches existing knowledge_graph / retrieval re-export blocks)
  • 📝 aperag/domains/knowledge_base/service/export_service.py — git mv from aperag/service/export_service.py; replaced 4 view_models.ExportTaskResponse with bare ExportTaskResponse
  • 📝 aperag/app.pyfrom aperag.views.export import routerfrom aperag.domains.knowledge_base.api.export_routes import router; mount prefix /api/v1 unchanged
  • aperag/views/export.py — deleted

aperag/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 -x21 passed (G1-G19 all green; new KB route imports zero legacy aggregates)
  • pytest tests/unit_test/ -x --ignore=objectstore686 passed, 29 skipped (matches Phase 8 first-batch baseline)
  • grep "from aperag\\.service\\.export_service\\|from aperag\\.views\\.export" aperag/ tests/ config/0 hits
  • ✅ Routes still mounted at canonical paths: /api/v1/collections/{id}/export, /api/v1/export-tasks/{task_id}, /api/v1/export-tasks/{task_id}/download

Ghost-check

none. No new backend coupling, no behavior change, no scope creep beyond what was needed for G1 to clear.

🤖 Generated with Claude Code

earayu and others added 2 commits April 25, 2026 16:19
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>
@earayu earayu marked this pull request as ready for review April 25, 2026 09:03
@earayu earayu merged commit 940d5bb into main Apr 25, 2026
1 of 2 checks passed
@earayu earayu deleted the phase8/g1-export-carve branch April 25, 2026 09:03
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