20 Apr, 2026
2 commits
-
将 SAT 的 ES 召回与对外 size 解耦,并支持配置化(解决suggest接口size参数取值不同时返回结果不一致的问题) **Problem** When `size=10` vs `size=40`, the SAT (search‑as‑you‑type) ES `_search` used the same `size` value, causing different candidate pool sizes and inconsistent top‑N results after merging with completion suggestions. The `size` parameter incorrectly controlled three things: completion count, SAT ES `size`, and final truncation. **Solution** Introduce dedicated configurable bounds for SAT recall, completely decoupled from the client‑facing `size` (final result count). - Compute SAT ES request size as `min(max(client_size, sat_recall_min), sat_recall_cap)`. - Completion still uses the raw client `size`. - Final merge, sort, and truncation logic (`_finalize_suggestion_list(..., size)`) unchanged. **Configuration** - New dataclass `SuggestionConfig` in `config/schema.py` with fields: - `sat_recall_min: int = 40` - `sat_recall_cap: int = 100` - Root `config.yaml` now supports `suggestion.sat_recall_min` / `suggestion.sat_recall_cap`. - Tenant overrides: `tenant_config.default.suggestion` or `tenant_config.tenants.<id>.suggestion` – only keys to override need to be specified. Merge order: root `SuggestionConfig` → default fragment → tenant fragment. - Sanity check: if `sat_recall_cap < sat_recall_min`, both loader and runtime resolver raise `cap` to at least `min` (warning logged). **Impact** - Small `size` (e.g., 10) still gets a stable SAT candidate pool (minimum `sat_recall_min`). - Large `size` is capped to `sat_recall_cap`, bounding ES query cost. - Final result count remains exactly the HTTP `size` parameter. - Backward compatible: defaults preserve previous behaviour when `sat_recall_min=40, sat_recall_cap=100` and client `size` <=100. **Code changes** - `config/schema.py`: add `SuggestionConfig` and integrate into `AppConfig`. - `suggestion/service.py`: - `_resolve_suggestion_config_for_tenant()`: tenant‑aware config merging. - `SuggestionService._suggest()`: compute `sat_es_size` using the new bounds. - `suggestion/loader.py`: apply same sanity checks and defaults. - Tenant config example: ```yaml tenant_config: tenants: '163': suggestion: sat_recall_cap: 80 ``` **Tests** - `pytest tests/test_suggestions.py` - `pytest tests/ci/test_service_api_contracts.py` All related tests pass. -
变更清单 修复(6 处漂移用例,全部更新到最新实现) - `tests/test_eval_metrics.py` — 整体重写为新的 4 级 label + 级联公式断言,放弃旧的 `RELEVANCE_EXACT/HIGH/LOW/IRRELEVANT` 和硬编码 ERR 值。 - `tests/test_embedding_service_priority.py` — 补齐 `_TextDispatchTask(user_id=...)` 新必填位。 - `tests/test_embedding_pipeline.py` — cache-hit 路径的 `np.allclose` 改用 `np.asarray(..., dtype=float32)` 避开 object-dtype。 - `tests/test_es_query_builder_text_recall_languages.py` — keywords 次 combined_fields 的期望值对齐现行值(`MSM 60% / boost 0.8`)并重命名。 - `tests/test_product_enrich_partial_mode.py` - `test_create_prompt_supports_taxonomy_analysis_kind`:去掉错误假设(fr 不属于任何 taxonomy schema),明确 `(None, None, None)` sentinel 的契约。 - `test_build_index_content_fields_non_apparel_taxonomy_returns_en_only`:fake 模拟真实 schema 行为(unsupported lang 返回空列表),删除"zh 未被调用"的过时断言。 清理历史过渡物(per 开发原则:不保留内部双轨) - 删除 `tests/test_keywords_query.py`(已被 `query/keyword_extractor.py` 生产实现取代的早期原型)。 - `tests/test_facet_api.py` / `tests/test_cnclip_service.py` 移动到 `tests/manual/`,更新 `tests/manual/README.md` 说明分工。 - 重写 `tests/conftest.py`:仅保留 `sys.path` 注入,删除全库无人引用的 `sample_search_config / mock_es_client / test_searcher / temp_config_file` 等 fixture。 - 删除 `tests/test_suggestions.py` 中 13 处残留 `@pytest.mark.unit` 装饰器(模块级 `pytestmark` 已覆盖)。 新建一致性基础设施 - `pytest.ini`:权威配置源。`testpaths = tests`、`norecursedirs = tests/manual`、`--strict-markers`、登记所有子系统 marker + `regression` marker。 - `tests/ci/test_service_api_contracts.py` + 30 个 `tests/test_*.py` 批量贴上 `pytestmark = [pytest.mark.<subsystem>, pytest.mark.regression]`(AST 安全插入,避开多行 import)。 - `scripts/run_regression_tests.sh` 新建,支持 `SUBSYSTEM=<name>` 选子集。 - `scripts/run_ci_tests.sh` 扩容:由原先的 `tests/ci -q` 改为 `contract` marker + `search ∧ regression` 双阶段。 文档统一(删除历史双轨) - 重写 `docs/测试Pipeline说明.md`:删除 `tests/unit/` / `tests/integration/` / `scripts/start_test_environment.sh` 等早已不存在的引用,给出目录约定、marker 表、回归锚点矩阵、覆盖缺口清单、联调脚本用法。 - 删除 `docs/测试回归钩子梳理-2026-04-20.md`(内容已合并进上面一份权威文档,按"一处真相"原则下掉)。 - `docs/DEVELOPER_GUIDE.md §8.2 测试` 改写,指向 pipeline 权威文档。 - `CLAUDE.md` 的 `Testing` 与 `Testing Infrastructure` 两节同步更新。 最终状态 | 指标 | 结果 | |------|------| | 全量 `pytest tests/` | **241 passed** | | `./scripts/run_ci_tests.sh` | 45 passed | | `./scripts/run_regression_tests.sh` | 233 passed | | 子系统子集(示例) | search=45 / rerank=35 / embedding=23 / intent=25 / translation=33 / indexer=17 / suggestion=13 / query=6 / eval=8 / contract=34 | | 未清零的已知缺口 | 见新版 `测试Pipeline说明.md §4`(function_score / facet / image search / config loader / document_transformer 等 6 条) | Pipeline 文档里 §4 的覆盖缺口我没有强行补测用例——那属于"新增覆盖",不是这次清理的范畴;只要后续谁补,把对应 marker 贴上去、从清单里划掉即可。
07 Apr, 2026
2 commits
-
- consolidate suggestion rebuild flow into build_suggestions.sh via --rebuild and remove the redundant rebuild_suggestions.sh wrapper - make suggestion versioned index names use microseconds and handle index-create retries/timeouts without false already_exists failures - treat create requests as successful when the index was created server-side, then explicitly wait for shard readiness and surface allocation diagnostics - clean up freshly created suggestion indices on rebuild failure to avoid leaving red orphan indices behind - make rebuild smoke tests target the local backend by default, with SUGGESTIONS_SMOKE_BASE_URL as the explicit override - add unit coverage for microsecond versioned index names and cleanup on unallocatable index failures
-
2. issues文档
30 Mar, 2026
1 commit
21 Mar, 2026
1 commit
10 Mar, 2026
2 commits
-
和微服务(embedding/translate/rerank)。 **新增文件** - 压测主脚本:[perf_api_benchmark.py](/data/saas-search/scripts/perf_api_benchmark.py:1) - 自定义用例模板:[perf_cases.json.example](/data/saas-search/scripts/perf_cases.json.example:1) **文档更新** - 在接口对接文档增加“接口级压测脚本”章节:[搜索API对接指南.md](/data/saas-search/docs/搜索API对接指南.md:2089) **支持的场景** - `backend_search` -> `POST /search/` - `backend_suggest` -> `GET /search/suggestions` - `embed_text` -> `POST /embed/text` - `translate` -> `POST /translate` - `rerank` -> `POST /rerank` - `all` -> 依次执行上述全部场景 **你可以直接执行的命令** 1. `./.venv/bin/python scripts/perf_api_benchmark.py --scenario backend_suggest --tenant-id 162 --duration 30 --concurrency 50` 2. `./.venv/bin/python scripts/perf_api_benchmark.py --scenario backend_search --tenant-id 162 --duration 30 --concurrency 20` 3. `./.venv/bin/python scripts/perf_api_benchmark.py --scenario all --tenant-id 162 --duration 60 --concurrency 30 --output perf_reports/all.json` 4. `./.venv/bin/python scripts/perf_api_benchmark.py --scenario all --tenant-id 162 --cases-file scripts/perf_cases.json.example --duration 60 --concurrency 40 --output perf_reports/custom_all.json` **可选参数** - `--backend-base` `--embedding-base` `--translator-base` `--reranker-base`:切到你的实际服务地址 - `--max-requests`:限制总请求数 - `--max-errors`:错误达到阈值提前停止 - `--pause`:`all` 模式下场景间暂停 **本地已验证** - `backend_suggest` 小规模并发压测成功(200,成功率 100%) - `backend_search` 小规模并发压测成功(200,成功率 100%) - `translate` 小规模并发压测成功(200,成功率 100%)
07 Mar, 2026
1 commit
02 Mar, 2026
1 commit