显式取用人工候选并隔离旧调用方(934d46f)

This commit is contained in:
Codex 2026-11-03 04:15:29 +00:00
parent bd938b21ae
commit 5b75adea85
6 changed files with 16 additions and 6 deletions

View File

@ -710,4 +710,6 @@ PMS 对应路径统一为 `/api/plan/user-candidates`,沿用交易员登录权
完整计划顶层 `user_candidates` 保存本版采用的登记;对应行带 `user_candidate` 和 `user_required`。后者表示候选需要人工来源才能成立。移除、到期及重新登记但尚未发布时,最新计划和逐票核验的 `pending_codes` 阻止旧来源继续被采纳。来源信息进入 PMS 依据指纹、提议与评审材料,既有版本核验和跨日复核继续生效。
新版PMS读取 `/plan` 和 `/plan/check` 时显式发送 `include_user_candidates=1`。未声明支持的调用方只获得系统来源:在前列数量及主题裁剪前剔除仅依靠人工来源的行,缓存也按此选项分开;逐票核验不返回人工专属候选。未升级的PMS和其他既有调用方不会自动吸收新增来源。归档完整版本保留,普通请求的来源过滤不重写历史。
人工来源只接入自主建仓候选链。资金投放命令不会额外吸收仅靠人工来源新增的股票;已有系统来源仍正常参与。盘中加入的合格基础候选可补读已有技术面数据,并进入现有盘中扫描关注范围,不自行生成技术面或择时结论。到期或移除不改变已经建立的持仓管理规则。

View File

@ -788,6 +788,7 @@ def fetch(*, date=None, base=None, path=None, timeout=None, extra_params=None) -
url = base + path
to = int(timeout or 10)
q = dict(extra_params or {})
q['include_user_candidates'] = 1 # 新版 PMS 明确支持人工来源及其失效核验。
if date:
q["date"] = date # date 是我们自己的语义, 不许被 extra 覆盖
try:
@ -923,7 +924,7 @@ def read_current_plan(*, code=None):
import requests
try:
r = requests.get(p['base'].rstrip('/') + '/' + p['path'].strip('/') + '/check',
params={'code': code}, timeout=(1, min(3, max(1, p['timeout']))))
params={'code': code, 'include_user_candidates': 1}, timeout=(1, min(3, max(1, p['timeout']))))
r.raise_for_status()
payload = r.json()
if (not isinstance(payload, dict) or normalize_code(payload.get('check_code')) != code

View File

@ -4,7 +4,7 @@
======================================
运行: docker compose run --rm pms-web python scripts/run_tests.py
test_batch54_units.py 用户候选来源、到期核验、权限与技术面补读 (8例)
test_batch54_units.py 用户候选来源、到期核验、权限、显式取用与技术面补读 (9例)
包含 (例数按 2026-10-26 隔离回归实跑校正):
test_sim_reset_units.py 双账本重置、空仓证据、配置与去重保留、幂等及SQL回滚 (9例)

View File

@ -54,7 +54,7 @@ class AcceptancePathTest(unittest.TestCase):
'main':[{'code':'SZ300693','name':'盛弘股份','score':230,'tier':'强传导','rank':555,
'verdict':'候选','risk':[],'company_review_text':'研究依据'}],'observe':[]}
def response(url,**kw):
self.assertEqual(url,'http://bridge/plan/check');self.assertEqual(kw['params'],{'code':CODE})
self.assertEqual(url,'http://bridge/plan/check');self.assertEqual(kw['params'],{'code':CODE,'include_user_candidates':1})
return SimpleNamespace(raise_for_status=lambda:None,json=lambda:copy.deepcopy(self.raw))
self.http=use('requests.get',side_effect=response)
selected=pf.candidates(record=False,recheck_code=CODE,plan_override=pf.parse_plan(self.raw),route_by_verdict=True)

View File

@ -57,6 +57,13 @@ class UserCandidateTests(unittest.TestCase):
self.assertNotIn(CODE,[r['ts_code'] for r in rows])
self.assertEqual(len(plan['main']),2)
def test_plan_request_explicitly_declares_user_source_support(self):
import requests
response=Mock();response.json.return_value=payload()
with patch.object(requests,'get',return_value=response) as get:
pf.fetch(base='http://plan.test',path='/plan',timeout=3)
self.assertEqual(get.call_args.kwargs['params']['include_user_candidates'],1)
def test_proxy_secret_actor_failure_and_redirect(self):
import requests
from app.services import param_store

View File

@ -316,7 +316,7 @@ def _():
finally:
restore()
# date 是 PMS 自己的语义, extra 里同名键不许赢
assert calls[0]["params"] == {"limit": "1000", "date": "2026-07-29"}, calls[0]["params"]
assert calls[0]["params"] == {"limit": "1000", "date": "2026-07-29", "include_user_candidates": 1}, calls[0]["params"]
# ================================================================ 新鲜度
@ -623,7 +623,7 @@ def _():
finally:
restore()
assert calls[0]["url"] == "http://192.168.16.155:8300/plan", calls
assert calls[0]["params"] == {"date": "2026-07-29"} and calls[0]["timeout"] == 7
assert calls[0]["params"] == {"date": "2026-07-29", "include_user_candidates": 1} and calls[0]["timeout"] == 7
assert p["date"] == "2026-07-29" and p["requested_date"] == "2026-07-29"
assert p["url"].endswith("/plan") and p["fetched_at"] > 0
# 不传 date 时不能带一个 date=None 的空参上去
@ -632,7 +632,7 @@ def _():
pf.fetch(base="http://x:8300", path="/plan", timeout=3)
finally:
restore2()
assert calls2[0]["params"] is None, calls2
assert calls2[0]["params"] == {"include_user_candidates": 1}, calls2
@case("取数·HTTP 报错/JSON 坏掉一律包装成 PlanFeedError, 消息给人看、接口地址进日志")