From 37e390a07305ee67be085ae70dc378b6da8fd220 Mon Sep 17 00:00:00 2001 From: yuxuanhui Date: Thu, 10 Sep 2026 13:16:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0=E6=9C=AC=E5=9C=B0=E5=90=8C?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E5=9F=BA=E5=87=86=E6=97=B6=E8=87=AA=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=80=9A=E8=BF=87=E5=B9=B6=E8=AE=B0=E4=B8=BA=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 9 +++++ backend/app/jobs.py | 9 ++++- backend/tests/test_alpha_management.py | 37 +++++++++++++++++++ .../src/components/SelfCorrelationPanel.tsx | 7 +++- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c1af51d..a366b39 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,3 +11,12 @@ ### Domain docs 采用 single-context 布局。探索代码库前,阅读 `docs/agents/domain.md`,并按其规则加载领域文档。 + +### Semi MCP + +新增或调整 Semi UI 组件用法(属性、布局、对齐、状态展示、交互、主题样式),排查组件专属行为或进行版本迁移时,优先使用 `semi-mcp` 核对文档与示例。纯业务逻辑修改不触发此查询。 + +- 先从项目依赖及锁文件确认实际版本,发现当前可用的 Semi MCP 工具,再按该版本调用 `get_semi_document`;示例被折叠时使用 `get_semi_code_block`。 +- 文档不足以解释行为时,使用 `get_component_file_list` 定位文件,再按需调用 `get_file_code` 或 `get_function_code` 核对实现。 +- 优先采用组件原生能力,例如 `Descriptions` 的对齐与列数属性、在 `value` 中使用 `Tag` 展示状态;确认原生能力不足后再添加局部样式。 +- 工具不可用或目标版本缺失时,说明限制,改查 Semi 官方文档及本机对应版本源码、类型定义;标明版本差异。已有有效查询结果可在当前任务中复用,实际效果仍需通过适当的类型检查或浏览器验证确认。 diff --git a/backend/app/jobs.py b/backend/app/jobs.py index 2a62762..4a2757f 100644 --- a/backend/app/jobs.py +++ b/backend/app/jobs.py @@ -515,7 +515,7 @@ class Runner: async def check_correlations(self, job_id, alpha_ids): """Check fixed targets against same-region submitted caches, with per-target recovery. - Missing references are reported as incomplete coverage. Authentication, + An empty same-region reference set passes locally with correlation zero. Authentication, transient upstream errors and cancellation retain the task for retry. """ await self.checkpoint(job_id, {"total": len(alpha_ids)}) @@ -564,7 +564,12 @@ class Runner: result["reason"] = "平台未提供目标 Alpha 的地区" elif not reference_ids: result = calculate_correlation([], []) - result["reason"] = "没有同地区已提交 Alpha 可供比较,请先同步已提交 Alpha" + # A local policy default, not a measured Pearson coefficient. + result.update( + status="low", + max_correlation=0.0, + reason="没有同地区已提交 Alpha 可供比较,按本地规则视为通过,自相关值记为 0", + ) else: target = await self.correlation_pnl(job_id, alpha_id) references = [] diff --git a/backend/tests/test_alpha_management.py b/backend/tests/test_alpha_management.py index 0947fc5..22dc004 100644 --- a/backend/tests/test_alpha_management.py +++ b/backend/tests/test_alpha_management.py @@ -353,3 +353,40 @@ async def test_scoped_date_query_parameters_and_no_platform_check(settings): assert "status!" in second and second["hidden"] == "true" assert all(r.method == "GET" and r.url.path == "/users/self/alphas" for r in requests) await client.close() + + +@pytest.mark.parametrize("region", ["USA", None]) +async def test_empty_region_reference_set_passes_with_zero_but_missing_region_does_not( + app, logged_in, region +): + runner = app.state.runner # No credentials or PnL; this branch must stay local. + async with runner.sessions.begin() as db: + for raw in ( + alpha("target", settings={"region": region}), + alpha("pending", settings={"region": "USA"}), + alpha("other-region", status="ACTIVE", settings={"region": "CHN"}), + ): + await upsert_alpha(db, raw) + job = ( + await logged_in.post( + f"{PREFIX}/sync-jobs", json={"kind": "self_correlation", "alpha_ids": ["target"]} + ) + ).json() + await runner.execute(job["id"]) + assert (await result(runner, job["id"])).status == "completed" + report = (await logged_in.get(f"{PREFIX}/alphas/target/self-correlation")).json()["result"] + assert report["candidate_count"] == report["compared_count"] == report["skipped_count"] == 0 + assert report["status"] == ("low" if region else "insufficient_data") + assert report["max_correlation"] == (0.0 if region else None) + assert not report["stale"] and report["matches"] == [] + summary = (await logged_in.get(f"{PREFIX}/alphas?q=target")).json()["items"][0]["local_correlation"] + assert summary["status"] == report["status"] + assert summary["max_correlation"] == report["max_correlation"] + state = (await logged_in.get(f"{PREFIX}/alphas/target/submission")).json() + assert state["can_check"] is bool(region) + if region: + async with runner.sessions.begin() as db: + await upsert_alpha(db, alpha("new-peer", status="ACTIVE")) + report = (await logged_in.get(f"{PREFIX}/alphas/target/self-correlation")).json()["result"] + assert report["stale"] + assert not (await logged_in.get(f"{PREFIX}/alphas/target/submission")).json()["can_check"] diff --git a/frontend/src/components/SelfCorrelationPanel.tsx b/frontend/src/components/SelfCorrelationPanel.tsx index 0e98f71..f104dd2 100644 --- a/frontend/src/components/SelfCorrelationPanel.tsx +++ b/frontend/src/components/SelfCorrelationPanel.tsx @@ -100,7 +100,9 @@ export function SelfCorrelationPanel({ : "grey" } > - {correlationLabels[result.status]} + {result.status === "low" && result.candidate_count === 0 + ? "通过(无本地基准)" + : correlationLabels[result.status]} 计算于 {formatTime(result.calculated_at, timezone)} @@ -139,7 +141,8 @@ export function SelfCorrelationPanel({ {result.status === "insufficient_data" && result.candidate_count === 0 && (

- 没有本地比较基准时可继续下方的平台提交检查;这不代表已通过相关性检查。 + 若目标地区已提供且没有本地比较基准,重新检测后将按通过处理,自相关值记为 + 0。

)} {result.status === "partial" && (