Skip to content

cleanup(phase8): move export_collection_task to KB domain (Option β follow-up to #1670)#1672

Merged
earayu merged 2 commits into
mainfrom
bryce/phase8-task39-followup-export-task
Apr 25, 2026
Merged

cleanup(phase8): move export_collection_task to KB domain (Option β follow-up to #1670)#1672
earayu merged 2 commits into
mainfrom
bryce/phase8-task39-followup-export-task

Conversation

@earayu

@earayu earayu commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Tiny carve-finishing follow-up to #1670 (task #39). Now that ExportTask ORM lives in aperag/domains/knowledge_base/db/models.py (carved by #1670), the matching Celery task body can finally move to the KB domain too. This was the Option β plan I committed to in the architect's task #39 thread (msg=e8a6f680).

Changes (pure code move):

  • Move export_collection_task + _build_manifest from config/export_tasks.py to aperag/domains/knowledge_base/tasks.py, pinned with name=\"config.celery_tasks.export_collection_task\" per architect spec (msg=aa120d85), matching the convention of the other KB-domain tasks (collection_init_task / collection_delete_task / etc.).
  • Update the only caller (aperag.service.export_service) to import from the new location.
  • Drop config.export_tasks from config/celery.py include= list.
  • Delete config/export_tasks.py.
  • Update KB models docstring to reflect the task body's new home.

Net: -237 / +220 LOC (effectively pure move; the small delta is dropping the stale from aperag.utils.utils import utc_now re-import inside _build_manifest since it's already imported at module top in tasks.py).

No behavior change. Same task body, same ExportTask ORM, same delay() call site.

Test plan

  • uv run python -m pytest tests/unit_test/test_modularization_boundaries.py -x -q21 passed (G1-G19 + new G20+)
  • uv run python -m pytest tests/unit_test -q --deselect 'tests/unit_test/test_web_typed_api_contract.py::test_phase1_fe_complete_identity_auth_admin_audit_adapter_boundary'676 passed / 29 skipped / 1 deselected / 0 failed
  • uv run ruff check aperag/ tests/ config/ → clean
  • grep -rn 'config.export_tasks\|config/export_tasks\|from config\.export_tasks'0 matches (only caller updated)
  • e2e-http-smoke + e2e-http-provider (per merge gate — runs in CI)

🤖 Generated with Claude Code

earayu added 2 commits April 25, 2026 12:45
…ollow-up)

Carve-finishing follow-up to #1670 (task #39): now that ExportTask ORM
lives in aperag/domains/knowledge_base/db/models.py, the matching Celery
task body can move to the KB domain too.

- Move `export_collection_task` + `_build_manifest` from
  `config/export_tasks.py` to `aperag/domains/knowledge_base/tasks.py`,
  pinned with `name="config.celery_tasks.export_collection_task"` to
  match the convention of the other KB-domain tasks.
- Update the only caller (`aperag.service.export_service`) to import
  from the new location.
- Drop `config.export_tasks` from `config/celery.py` `include=` list.
- Delete `config/export_tasks.py`.
- Update KB models docstring to reflect the task body's new home.

Pure code move + import path update — no behavior change. Gates green
(21/21 boundary, 676 pass / 29 skip / 1 deselect / 0 fail unit suite,
ruff clean).
CI lint-and-unit job runs `ruff format --check` (stricter than `ruff
check`). My local pre-push gate only ran the latter, missing this.
Pure mechanical reformat in the export_collection_task block — no
semantic change. Architect canonical LGTM (msg=ca62c787) and Weston
no-blocker CR (msg=e91a922c) both still apply since the move scope
and task-name pin are unchanged.

Note: indexing/tasks.py also flags ruff format check on origin/main
itself (pre-existing drift carried in by an earlier merge); that file
is outside this PR's move-only scope and not touched here.
@earayu earayu merged commit 0ec48a8 into main Apr 25, 2026
0 of 2 checks passed
@earayu earayu deleted the bryce/phase8-task39-followup-export-task branch April 25, 2026 04:57
earayu added a commit that referenced this pull request Apr 25, 2026
…) (#1677)

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

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>

* refactor(phase8-g1): D7 v2 hard-cut for export endpoints (#47)

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>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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