refactor(phase8/task53/g4d-be): conversation chat ops prefix /api/v1 → /api/v2 (chat-rooted)#1680
Merged
Merged
Conversation
…→ /api/v2 (chat-rooted)
Per architect canonical msg≈2026-04-25 16:18 (Option A — chat-rooted
nesting preserved): chat_router moves from /api/v1 to /api/v2 while
the chat-rooted path layout (/chats/{chat_id}/...) is unchanged.
v2 bot-rooted chat CRUD on bots_router (/bots/{bot_id}/chats/...)
remains untouched and continues to coexist under /api/v2.
Hard-cut, not alias: removes /api/v1/chats/* entirely. The companion
G4d-FE task #54 (@dongdong) regenerates web/src/api-v2/schema.d.ts
and updates FE callers + Hurl + e2e + contract tests to /api/v2.
Routes migrated:
/api/v1/chats/{chat_id}/feedback → /api/v2/...
/api/v1/chats/{chat_id}/turns/{turn_id}/feedback → /api/v2/...
/api/v1/chats/{chat_id}/search → /api/v2/...
/api/v1/chats/{chat_id}/documents → /api/v2/...
/api/v1/chats/{chat_id}/documents/{document_id} → /api/v2/...
Server-internal MCP search call (aperag/mcp/server.py) is retargeted
to /api/v2 in the same commit so the BE-only PR is self-consistent.
Adds tests/unit_test/test_chat_ops_v2_openapi_contract.py with three
contract gates:
1. all chat_router (tags=["chats"]) routes mounted under /api/v2
2. no /api/v1/chats/ ghost remains
3. nesting stays chat-rooted (no /bots/ prefix introduced)
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.
Summary
G4d backend: hard-cut
chat_routermount from/api/v1to/api/v2, keeping the chat-rooted/chats/{chat_id}/...nesting unchanged (Option A canonical, locked by 符炫炜 ≈2026-04-25 16:18 in #模块化重构).Routes migrated
/api/v1/chats/{chat_id}/feedback/api/v2/chats/{chat_id}/feedback/api/v1/chats/{chat_id}/turns/{turn_id}/feedback/api/v2/chats/{chat_id}/turns/{turn_id}/feedback/api/v1/chats/{chat_id}/turns/{turn_id}/feedback/api/v2/chats/{chat_id}/turns/{turn_id}/feedback/api/v1/chats/{chat_id}/search/api/v2/chats/{chat_id}/search/api/v1/chats/{chat_id}/documents/api/v2/chats/{chat_id}/documents/api/v1/chats/{chat_id}/documents/{document_id}/api/v2/chats/{chat_id}/documents/{document_id}bots_routerv2 chat CRUD (/api/v2/bots/{bot_id}/chats/...) is untouched; both routers now coexist under/api/v2with non-overlapping paths.Scope discipline
/api/v1/chats/*removed entirely)aperag/app.py:239— single mount prefix changechat_router/api/v1→/api/v2aperag/mcp/server.py:342— server-internal MCPsearchcall retargeted to keep this PR self-consistent (no FE/external dep)web/src/api-v2/schema.d.tsregen +web/src/features/bot/client-api.tscaller swap + Hurl/e2e +test_web_typed_api_contract.pyassertion update belong to companion task fix: husky hooks #54 G4d-FE (@dongdong claimed)Cross-task sequencing
After this PR merges to main, FE clients calling
/api/v1/chats/...will get 404 until #54 G4d-FE PR also merges. dongdong has #54 claimed and is waiting on this PR's OpenAPI diff to regenschema.d.ts. Coordinate merge windows to keep the gap minimal.Gate
uv run pytest tests/unit_test/test_chat_ops_v2_openapi_contract.py— 3/3 pass (3 new contract gates)uv run pytest tests/unit_test/test_modularization_boundaries.py— 21/21 pass (G1-G19 invariants intact)uv run ruff format --check/ruff check— cleanmake openapi-generateregenerates spec; tracked artifacts inweb/src/api-v2/will be regenerated by fix: husky hooks #54 G4d-FEOpenAPI diff (5 paths)
After regen,
openapi.public.jsonshifts the chat-rooted paths:Bot-rooted chat CRUD (
/api/v2/bots/{bot_id}/chats/...) is unchanged.Test plan
/api/v2/api/v1/chats/ghost remains/bots/prefix)lint-and-unitgreenCloses
Task #53 — Phase 8 第二批 G4d-BE conversation chat ops prefix migrate to /api/v2 (chat-rooted)
🤖 Generated with Claude Code