Skip to content

refactor(model-platform): drop residual RERANK capability + provider presets (task #47)#1910

Merged
earayu merged 1 commit into
mainfrom
bryce/task-47-rerank-residual-cleanup
Apr 29, 2026
Merged

refactor(model-platform): drop residual RERANK capability + provider presets (task #47)#1910
earayu merged 1 commit into
mainfrom
bryce/task-47-rerank-residual-cleanup

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 29, 2026

Summary

Task #47 fix-forward to task #35 (rerank deletion). huangzhangshu's task #40 verification (msg=23e67c4d) found that the previous PRs left the model_platform domain ModelCapability.RERANK enum value, the dashscope / jina built-in provider presets that listed it, the generated TypeScript schema, and one unit-test contract still treating rerank as a first-class capability. This PR closes those last residues.

PR #1898 (ziang) deleted ModelUseScenario.RETRIEVAL_RERANK and the corresponding model_use rows. PR #1899 (Bryce) deleted the runtime-side aperag/llm/runtime/types.py::ModelCapability.RERANK. PR #1897 (dongdong) cleaned the frontend / docs / SearchRequest.rerank.

What this PR removes

  • aperag/domains/model_platform/schemas.py: ModelCapability.RERANK enum value
  • aperag/domains/model_platform/db/models.py: ModelCapability.RERANK enum value
  • aperag/domains/model_platform/service/model_service.py: the CAPABILITY_SCENARIOS[RERANK] entry, the dashscope BUILTIN_PROVIDERS supported_capabilities=[…, RERANK], the jina BUILTIN_PROVIDERS supported_capabilities=[…, RERANK]
  • web/src/api-v2/schema.d.ts: drop "rerank" from the ModelCapability union
  • tests/unit_test/test_model_platform_v2_contract.py: rewrite the user-level-model-creation test to use EMBEDDING (the test's intent was contract semantics, not the specific capability); drop the default_allowed_scenarios(RERANK) == [] assertion

What this PR adds

  • aperag/migration/versions/20260430034600-3c7d2f81b5e9.py: DELETE FROM model WHERE capability = 'rerank'. Chained after a8f4c2d9e1b7 (which removed the model_use rows) so the enum hard-cut here deserialises existing rows safely.

Test plan

  • uvx ruff@0.15.12 check aperag/ tests/ — pass
  • uvx ruff@0.15.12 format --check aperag/ tests/ — pass
  • uv run --extra test python -m pytest tests/unit_test/test_model_platform_v2_contract.py tests/boundaries/test_no_rerank_in_mcp.py tests/boundaries/test_api_no_cleanup.py tests/boundaries/test_worker_di_parity.py tests/unit_test/test_app_lifespan_no_workers.py -q — 26 passed
  • CI lint-and-unit + e2e-http-smoke + e2e-http-provider
  • huangzhangshu task [Features] support english model openchat #40 final grep gate after this lands: zero active hits for rerank / RERANK in aperag/ + tests/ + web/src/api-v2/ (allowlist = pipeline.py historical comment + test_v1_ghost_guard.py docstring + test_no_rerank_in_mcp.py self-references + the two migrations)

🤖 Generated with Claude Code

…presets

Task #47 fix-forward to task #35: huangzhangshu's task #40 verification
(msg=23e67c4d) found that PR #1898 only deleted the
ModelUseScenario.RETRIEVAL_RERANK scenario and PR #1899 only deleted
the runtime-side ModelCapability.RERANK; the model_platform's domain
ModelCapability.RERANK enum value, the dashscope / jina built-in
provider presets that listed it, the generated TypeScript schema, and
the unit-test contract still kept rerank as a first-class capability.

Deleted
- aperag/domains/model_platform/schemas.py: drop ModelCapability.RERANK
- aperag/domains/model_platform/db/models.py: drop ModelCapability.RERANK
- aperag/domains/model_platform/service/model_service.py: drop
  CAPABILITY_SCENARIOS[RERANK] entry; drop ModelCapability.RERANK from
  the dashscope and jina supported_capabilities lists
- web/src/api-v2/schema.d.ts: drop "rerank" from the ModelCapability
  union (the regenerated schema now has only chat / completion /
  embedding)
- tests/unit_test/test_model_platform_v2_contract.py: rewrite the
  test that exercised RERANK to use EMBEDDING (the test's purpose was
  user-level model-creation contract, not the specific capability);
  drop the default_allowed_scenarios(RERANK) == [] assertion

Added
- aperag/migration/versions/20260430034600-3c7d2f81b5e9.py: DELETE
  FROM model WHERE capability = 'rerank' (chained after a8f4c2d9e1b7
  which removed the model_use rows). Together they let the next
  enum hard-cut deserialise existing rows safely.

Test plan
- ruff check + format --check on aperag/ tests/: pass
- pytest the directly impacted suites
  (test_model_platform_v2_contract + test_no_rerank_in_mcp +
  test_api_no_cleanup + test_worker_di_parity +
  test_app_lifespan_no_workers): 26 passed
- (next) huangzhangshu task #40 final grep gate: aperag/ + tests/ +
  web/src/api-v2/ rerank/RERANK = 0 active hits (allowlist =
  pipeline.py historical comment + test_v1_ghost_guard.py docstring +
  test_no_rerank_in_mcp.py self-references + the two migrations)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@earayu earayu merged commit 1bfa790 into main Apr 29, 2026
10 checks passed
@earayu earayu deleted the bryce/task-47-rerank-residual-cleanup branch April 29, 2026 20:01
earayu added a commit that referenced this pull request Apr 29, 2026
…esson #14 (#1916)

Phase A 全闭环 follow-up sediment(task #32 Phase A close 后启动)。
fold 7 lesson sediment 进 § 四(task #32 + task #35 多轮迭代实证累计)+
fix-forward task #45 PR #1908 NIT defer (mcp-api.md "Phase A 后" → "当前已携带",
per architect msg=04c7962e Option B + dongdong msg=1c08ac8a)。

§ 四 新增 7 lesson:

- Lesson #12 v6 sub-form (v6.1 function / v6.2 endpoint / v6.3 data type
  scope walk) — 架构师 msg=9c5c32d1 升级,task #36 PR #1899 fix-forward²
  L148 case 实战 surface

- Lesson #12 v7 (caller signature → backend schema → runtime fallback
  三层 grep) — task #34 rerank 调研 huangheng msg=e539848f own-up + 架构师
  msg=b12fec5d thoroughness=very thorough trace 实证

- Lesson #12 v7.1 (composite key invariant) — task #32 spec PR #1905
  Weston msg=7500e57d BLOCKER catch + huangheng + 架构师 double own-up

- Lesson #12 v7.1 sub-form (backend 投影层 + acceptance 跨 endpoint
  chained chain 双层 verify) — 架构师 msg=f04b36a8 升级,PR #1909 backend
  textbook (`8d5ffa97`) + PR #1912 acceptance textbook (`eb2a805b`) 配对

- Lesson #13 v2.1 (import-level dual-side rewrite — 删 source 必删 obsolete
  test 文件 / 函数) — task #17 PR #1884 first + task #36 PR #1899
  fix-forward¹ second

- Lesson #13 v2.2 (value-level dual-side rewrite — 删 source 字段 / 数据必
  同步 update stale assertion / count) — task #36 PR #1899 fix-forward²
  L103/L108 first + task #47 PR #1910 contract test second

- Lesson #13 v3 (boundary 不重复事实保证 invariant,只覆盖可能 drift 的
  contract) — 架构师 msg=036dd8b2 升格,task #46 PR #1906 first

- Migration chain 时序 invariant (enum hard-cut PR 必先 chain DELETE FROM
  旧 enum value migration) — task #47 PR #1910 first (`3c7d2f81b5e9` chain
  在 `a8f4c2d9e1b7` 后)

- Lesson #14 (架构 invariant 删除多轮迭代收尾 — sweeping cleanup directive
  单 PR 无法一次性 cover,多轮 grep gate verify + fix-forward task 是工程
  常态) — task #35 6 轮 fix-forward 实证 first (PR #1899/#1897/#1898/
  #1906/#1910/#1911 + task #40 final 验收)

§ 六 sediment 引用追加:
- PR #1909 (`8d5ffa97`) Lesson #12 v7.1 backend 层 textbook
- PR #1912 (`eb2a805b`) Lesson #12 v7.1 acceptance 层 textbook
- task #35 6 轮 fix-forward 收尾 Lesson #14 first-application demo

§ 八 修订记录追加本次 commit timeline。

mcp-api.md L88 fix-forward (per dongdong msg=f1975615 + 架构师 msg=04c7962e
Option B): "task #32 Phase A 后" → "当前已携带(task #32 Phase A 落地,
PR #1909 + PR #1912)"。Phase A 全闭环后用户面文档现状准确。

来源 directive: PM msg=0129c3c5 phase A close 后启动 follow-up 子 PR +
架构师 msg=62e58a18 Phase A close 后立即启动 directive。
earayu added a commit that referenced this pull request Apr 30, 2026
#1943)

* docs(cr-checklist): task #31 Phase A 全闭环后 sediment fold-in 子 PR 2

§ 四 加 6 lesson sediment(task #31 Phase A 4 PR + task #33 P3 PR #1933 codify
累计实证 + multi-PR same-hour multi-source first-principles catch trust-framing
miss)+ § 六 sediment 引用追加 5 PR commit cross-link + § 八 修订记录追加本 PR
fold-in 完整 trail。

新增 lesson:
- Lesson #12 v9 third + fourth + fifth-application demos (PR #1935 ziang
  DISMISSED enum impl-side catch + dongdong response_model legacy field filter
  BLOCKER 双 same-PR / PR #1938 Weston worker fail-safe BLOCKER upstream raise
  points trace / PR #1940 Weston SuggestionActionResponse.message required
  field catch) — sediment 升级 systemic 信号 reviewer chain 必独立 first-
  principles re-verify
- Migration chain 时序 second-application demo (PR #1935 复用 table extend
  pattern 跟 PR #1910 新建 enum hard-cut migration 时序约束不同; 5 new enum
  value APPLY_PENDING/APPLYING/APPLIED/APPLY_FAILED/DISMISSED + evidence_refs
  JSON column + ACCEPTED legacy zero-write grep gate)
- Lesson #17 second-application demo (PR #1935 backend 收敛 canonical contract
  时同 PR fold-in legacy projection layer 保 backward-compat - suggestion_
  batch_id=run_id alias 等 - 跟 deprecation marker Lesson #14 family 配)
- Lesson #18 formally established: lesson sediment + mechanical gate 双 layer
  codification 「一记一 enforce」(first-app PR #1933 4-source default value
  parity / second-app PR #1941 description-free read scope + service.py:845
  bonus catch / third-app PR #1941 fix-forward sister tests 防 whole-file
  exclude 静默削弱 gate)
- mini-pattern 19: spec lock pre-check grep main 实证 enum/contract assumption
  (architect own-up 升级版三层: spec→impl / impl→response_model / impl catch
  path→upstream raise points)
- mini-pattern 20: PR adds response_model wire-up 必跑 model_validate(actual_
  handler_return_shape) boundary gate (PR #1940 first-application demo)

per architect dispatch msg=b6726ac9 + msg=420ca548 sediment trigger A 满足
(task #31 Phase A 4/4 done) 启动 + Phase B B1 lane huangheng owner.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs(cr-checklist): fix cite accuracy NIT per Weston msg=7690b723

2 cite accuracy fixes (Weston framing CR catch):

1. response_model validation failure 状态码: 422 -> 500
   - response_model validation fails 抛 FastAPI ResponseValidationError
   - 通常映射到 HTTP 500,不是 request body 校验的 422
   - 影响 line 745 + line 850 描述 PR #1940 BLOCKER 时的状态码引用

2. GraphMergeSuggestionItem canonical schema 字段实证修正
   - 原写: ... / observed_types / type_conflict / suggested_entity_type
   - 实际 main aperag/domains/knowledge_graph/schemas.py::GraphMergeSuggestionItem
     不含这三字段
   - A4 (PR #1940) 这些字段是 FE-derived display (FE 从 entities /
     suggested_target_entity / evidence_refs 推导),不是 PR #1935 backend
     projection
   - 影响 line 781 sect 4 Lesson #17 second-application demo 描述

per Weston PR #1943 framing CR (msg=7690b723) - sediment cite accuracy
要求把事实漂移修干净,避免 future onboarding reference 时 confuse
422/500 状态码语义 + backend/FE field source attribution。

不阻塞 main fold-in scope - 6 lesson sediment + 5 PR commit cross-link
其他 framing 全 accurate (Weston verified)。

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