Skip to content

refactor(phase8/task53/g4d-be): conversation chat ops prefix /api/v1 → /api/v2 (chat-rooted)#1680

Merged
earayu merged 1 commit into
mainfrom
chenyexuan/phase8-task53-g4d-be
Apr 25, 2026
Merged

refactor(phase8/task53/g4d-be): conversation chat ops prefix /api/v1 → /api/v2 (chat-rooted)#1680
earayu merged 1 commit into
mainfrom
chenyexuan/phase8-task53-g4d-be

Conversation

@earayu

@earayu earayu commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

G4d backend: hard-cut chat_router mount from /api/v1 to /api/v2, keeping the chat-rooted /chats/{chat_id}/... nesting unchanged (Option A canonical, locked by 符炫炜 ≈2026-04-25 16:18 in #模块化重构).

Routes migrated

Method Old New
GET /api/v1/chats/{chat_id}/feedback /api/v2/chats/{chat_id}/feedback
POST /api/v1/chats/{chat_id}/turns/{turn_id}/feedback /api/v2/chats/{chat_id}/turns/{turn_id}/feedback
DELETE /api/v1/chats/{chat_id}/turns/{turn_id}/feedback /api/v2/chats/{chat_id}/turns/{turn_id}/feedback
POST /api/v1/chats/{chat_id}/search /api/v2/chats/{chat_id}/search
POST /api/v1/chats/{chat_id}/documents /api/v2/chats/{chat_id}/documents
GET /api/v1/chats/{chat_id}/documents/{document_id} /api/v2/chats/{chat_id}/documents/{document_id}

bots_router v2 chat CRUD (/api/v2/bots/{bot_id}/chats/...) is untouched; both routers now coexist under /api/v2 with non-overlapping paths.

Scope discipline

  • Hard cut, not alias per D7-4 canonical (/api/v1/chats/* removed entirely)
  • aperag/app.py:239 — single mount prefix change chat_router /api/v1/api/v2
  • aperag/mcp/server.py:342 — server-internal MCP search call retargeted to keep this PR self-consistent (no FE/external dep)
  • No FE writesweb/src/api-v2/schema.d.ts regen + web/src/features/bot/client-api.ts caller swap + Hurl/e2e + test_web_typed_api_contract.py assertion 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 regen schema.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 — clean
  • make openapi-generate regenerates spec; tracked artifacts in web/src/api-v2/ will be regenerated by fix: husky hooks #54 G4d-FE

OpenAPI diff (5 paths)

After regen, openapi.public.json shifts the chat-rooted paths:

- /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}/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}

Bot-rooted chat CRUD (/api/v2/bots/{bot_id}/chats/...) is unchanged.

Test plan

  • All chat_router routes mounted under /api/v2
  • No /api/v1/chats/ ghost remains
  • Nesting stays chat-rooted (Option A, no /bots/ prefix)
  • CI lint-and-unit green
  • Companion fix: husky hooks #54 G4d-FE merges into main (sequencing dependency)

Closes

Task #53 — Phase 8 第二批 G4d-BE conversation chat ops prefix migrate to /api/v2 (chat-rooted)

🤖 Generated with Claude Code

…→ /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>
@earayu earayu merged commit 13f9e7c into main Apr 25, 2026
0 of 2 checks passed
@earayu earayu deleted the chenyexuan/phase8-task53-g4d-be branch April 25, 2026 08:54
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