Repository navigation
对弈竞猜更新 - #1848
对弈竞猜更新#1848
Conversation
There was a problem hiding this comment.
嘿——我发现了 3 个问题
供 AI 代理使用的提示
请处理本次代码审查中的评论:
## 单独评论
### 评论 1
<location path="tasks/FrogBoss/frog_oas.py" line_range="135-171" />
<code_context>
+ for uid in DASHEN_UIDS:
</code_context>
<issue_to_address>
**issue (performance):** `fetch_predictions` 在下注前会为 26 个 UID 中的每一个执行两次同步 HTTP 请求,但没有总体截止时间或并发机制;在最坏情况下,单个请求的超时会使下注流程阻塞数分钟,导致阵容发生变化或下注结束,而 `do_bet` 还没来得及点击。
**触发条件:** 下注倒计时期间,预测服务响应缓慢或部分不可用时。
**建议修复:** 设置有上限的总体截止时间和/或使用并发请求,并使用截止时间前已收集到的预测结果继续执行,而不是等待所有 UID 完成。
</issue_to_address>
### 评论 2
<location path="tasks/FrogBoss/frog_oas.py" line_range="77-84" />
<code_context>
+ # Unverified newcomers start neutral; verified sources use raw win rate.
++ return correct / total if total else 0.5
+
+ def settle(self, signature, winner):
+ if winner not in ('LEFT', 'RIGHT'):
+ return None
+ # Include already settled records when checking ambiguity: never transfer
+ # an old result to a newer decision with an identical lineup.
+ matches = [e for e in self.events if e.get('kind') == 'decision'
+ and same_lineup(e['signature'], signature)]
+ if len(matches) != 1:
+ self.append('unverified_result', signature=signature, winner=winner,
+ reason='missing_or_ambiguous_decision')
</code_context>
<issue_to_address>
**issue (bug_risk):** `settle` 会在整个历史记录中搜索阵容匹配的决策,并要求匹配结果恰好只有一个;当同一阵容指纹被用于两场比赛时,后续结果会被记录为 `unverified_result`,且两个决策都不会获得结果,因此对于重复阵容,来源可靠性将无法继续学习。
**触发条件:** 历史中的两场比赛存在符合 20 位 `same_lineup` 阈值的阵容时。
**建议修复:** 持久化并传递与当前下注关联的具体决策 ID 或槽位,然后直接结算该决策,而不是仅根据阵容指纹解析。
</issue_to_address>
### 评论 3
<location path="tasks/FrogBoss/script_task.py" line_range="197-198" />
<code_context>
logger.info('Right win')
else:
- result = True
+ result = None
return result
def get_bilibili(self) -> RuleImage:
</code_context>
<issue_to_address>
**issue (bug_risk):** `detect` 被标注为返回 `bool`,其文档字符串也描述了布尔结果,但新的兜底逻辑在无法同时看到结果指示器时返回 `None`;依赖文档所述布尔契约的调用方或重写实现会收到第三种值。
**触发条件:** 既未检测到完整的左方获胜图片对,也未检测到完整的右方获胜图片对时。
**建议修复:** 将类型标注和文档字符串改为 `Optional[bool]`,并说明结果未确定的情况;或者保留布尔契约,并单独处理无法确定的检测结果。
</issue_to_address>Sourcery 评估
需要人工审查。 有 3 个发现需要优先处理;当选择新的 Oas 策略时,外部获取的预测结果和持久化的历史记录会决定自动下注的方向。过期或错误的数据源、阵容匹配结果或评分决策可能导致下注错误的一方,并永久损失已下注的游戏货币;回滚代码也无法挽回这些损失。
阻塞性发现:tasks/FrogBoss/frog_oas.py:171、tasks/FrogBoss/frog_oas.py:84、tasks/FrogBoss/script_task.py:198
Original comment in English
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tasks/FrogBoss/frog_oas.py" line_range="135-171" />
<code_context>
+ for uid in DASHEN_UIDS:
</code_context>
<issue_to_address>
**issue (performance):** `fetch_predictions` performs two synchronous HTTP requests for every one of the 26 UIDs before placing the bet, with no overall deadline or concurrency; in the worst case the per-request timeouts block the betting flow for several minutes, so the lineup changes or betting closes before `do_bet` can click.
**Triggers:** When the prediction service is slow or partially unavailable during the betting countdown.
**Suggested fix:** Use a bounded overall deadline and/or concurrent requests, and proceed with the predictions collected before the deadline instead of waiting for every UID.
</issue_to_address>
### Comment 2
<location path="tasks/FrogBoss/frog_oas.py" line_range="77-84" />
<code_context>
+ # Unverified newcomers start neutral; verified sources use raw win rate.
+ return correct / total if total else 0.5
+
+ def settle(self, signature, winner):
+ if winner not in ('LEFT', 'RIGHT'):
+ return None
+ # Include already settled records when checking ambiguity: never transfer
+ # an old result to a newer decision with an identical lineup.
+ matches = [e for e in self.events if e.get('kind') == 'decision'
+ and same_lineup(e['signature'], signature)]
+ if len(matches) != 1:
+ self.append('unverified_result', signature=signature, winner=winner,
+ reason='missing_or_ambiguous_decision')
</code_context>
<issue_to_address>
**issue (bug_risk):** `settle` searches the entire history for decisions with a matching lineup and requires exactly one match; when the same lineup fingerprint is used in two competitions, the later result is recorded as `unverified_result` and neither decision receives an outcome, so source reliability stops learning for repeated lineups.
**Triggers:** When two competitions in the history have lineups within the 20-bit `same_lineup` threshold.
**Suggested fix:** Persist and carry the specific decision ID or slot associated with the active bet, then settle that decision directly rather than resolving it only from the lineup fingerprint.
</issue_to_address>
### Comment 3
<location path="tasks/FrogBoss/script_task.py" line_range="197-198" />
<code_context>
logger.info('Right win')
else:
- result = True
+ result = None
return result
def get_bilibili(self) -> RuleImage:
</code_context>
<issue_to_address>
**issue (bug_risk):** `detect` is annotated as returning `bool` and its docstring describes a boolean result, but the new fallback returns `None` when the result indicators are not both visible; callers or overrides relying on the documented boolean contract receive a third value.
**Triggers:** When neither complete left-win nor complete right-win image pair is detected.
**Suggested fix:** Change the annotation and docstring to `Optional[bool]` and document the unresolved-result case, or preserve the boolean contract and handle unresolved detection separately.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and when the new Oas strategy is selected, externally fetched predictions and persisted history determine which side is automatically wagered on. A stale or incorrect feed, lineup match, or scoring decision can place bets on the wrong side and permanently lose the wagered in-game currency; reverting the code would not recover those losses.
Blocking findings: tasks/FrogBoss/frog_oas.py:171, tasks/FrogBoss/frog_oas.py:84, tasks/FrogBoss/script_task.py:198
| for uid in DASHEN_UIDS: | ||
| feed_id = None | ||
| try: | ||
| response = session.get('https://inf.ds.163.com/v1/web/feed/basic/getSomeOneFeeds', | ||
| params={'feedTypes': '1,2,3,4,6,7,10,11', 'someOneUid': uid}, timeout=(3, 5)) | ||
| response.raise_for_status() | ||
| feeds = response.json().get('result', {}).get('feeds', []) | ||
| if not feeds: | ||
| history.append('fetch', uid=uid, accepted=False, reason='no_feed') | ||
| continue | ||
| feed_id = feeds[0]['id'] | ||
| response = session.get('https://inf.ds.163.com/v1/web/feed/basic/facade', | ||
| params={'feedId': feed_id}, timeout=(3, 5)) | ||
| response.raise_for_status() | ||
| feed = response.json()['result']['feed'] | ||
| content = feed['content'] | ||
| if isinstance(content, str): | ||
| content = json.loads(content) | ||
| body = content['body']['text'] | ||
| raw_time = feed.get('createTime') | ||
| published = None | ||
| try: | ||
| published = datetime.fromtimestamp(float(raw_time) / 1000) | ||
| except (TypeError, ValueError, OverflowError, OSError): | ||
| pass | ||
| side = parse_side(body) | ||
| fresh = published is not None and published.date() == now.date() and published.hour // 2 == now.hour // 2 and published <= now | ||
| accepted = fresh and side is not None and (uid, feed_id) not in used | ||
| history.append('fetch', uid=uid, feed_id=feed_id, create_time=raw_time, | ||
| body=body, side=side, accepted=accepted, | ||
| reason='accepted' if accepted else 'stale_unknown_ambiguous_or_duplicate') | ||
| if accepted: | ||
| predictions.append(dict(uid=uid, side=side, feed_id=feed_id)) | ||
| except (requests.RequestException, ValueError, KeyError, IndexError, TypeError) as exc: | ||
| history.append('fetch', uid=uid, feed_id=feed_id, accepted=False, | ||
| reason='request_or_parse_error', error=str(exc)) | ||
| return predictions |
There was a problem hiding this comment.
issue (performance): fetch_predictions 在下注前会为 26 个 UID 中的每一个执行两次同步 HTTP 请求,但没有总体截止时间或并发机制;在最坏情况下,单个请求的超时会使下注流程阻塞数分钟,导致阵容发生变化或下注结束,而 do_bet 还没来得及点击。
触发条件: 下注倒计时期间,预测服务响应缓慢或部分不可用时。
建议修复: 设置有上限的总体截止时间和/或使用并发请求,并使用截止时间前已收集到的预测结果继续执行,而不是等待所有 UID 完成。
Original comment in English
issue (performance): fetch_predictions performs two synchronous HTTP requests for every one of the 26 UIDs before placing the bet, with no overall deadline or concurrency; in the worst case the per-request timeouts block the betting flow for several minutes, so the lineup changes or betting closes before do_bet can click.
Triggers: When the prediction service is slow or partially unavailable during the betting countdown.
Suggested fix: Use a bounded overall deadline and/or concurrent requests, and proceed with the predictions collected before the deadline instead of waiting for every UID.
| def settle(self, signature, winner): | ||
| if winner not in ('LEFT', 'RIGHT'): | ||
| return None | ||
| # Include already settled records when checking ambiguity: never transfer | ||
| # an old result to a newer decision with an identical lineup. | ||
| matches = [e for e in self.events if e.get('kind') == 'decision' | ||
| and same_lineup(e['signature'], signature)] | ||
| if len(matches) != 1: |
There was a problem hiding this comment.
issue (bug_risk): settle 会在整个历史记录中搜索阵容匹配的决策,并要求匹配结果恰好只有一个;当同一阵容指纹被用于两场比赛时,后续结果会被记录为 unverified_result,且两个决策都不会获得结果,因此对于重复阵容,来源可靠性将无法继续学习。
触发条件: 历史中的两场比赛存在符合 20 位 same_lineup 阈值的阵容时。
建议修复: 持久化并传递与当前下注关联的具体决策 ID 或槽位,然后直接结算该决策,而不是仅根据阵容指纹解析。
Original comment in English
issue (bug_risk): settle searches the entire history for decisions with a matching lineup and requires exactly one match; when the same lineup fingerprint is used in two competitions, the later result is recorded as unverified_result and neither decision receives an outcome, so source reliability stops learning for repeated lineups.
Triggers: When two competitions in the history have lineups within the 20-bit same_lineup threshold.
Suggested fix: Persist and carry the specific decision ID or slot associated with the active bet, then settle that decision directly rather than resolving it only from the lineup fingerprint.
| result = None | ||
| return result |
There was a problem hiding this comment.
issue (bug_risk): detect 被标注为返回 bool,其文档字符串也描述了布尔结果,但新的兜底逻辑在无法同时看到结果指示器时返回 None;依赖文档所述布尔契约的调用方或重写实现会收到第三种值。
触发条件: 既未检测到完整的左方获胜图片对,也未检测到完整的右方获胜图片对时。
建议修复: 将类型标注和文档字符串改为 Optional[bool],并说明结果未确定的情况;或者保留布尔契约,并单独处理无法确定的检测结果。
Original comment in English
issue (bug_risk): detect is annotated as returning bool and its docstring describes a boolean result, but the new fallback returns None when the result indicators are not both visible; callers or overrides relying on the documented boolean contract receive a third value.
Triggers: When neither complete left-win nor complete right-win image pair is detected.
Suggested fix: Change the annotation and docstring to Optional[bool] and document the unresolved-result case, or preserve the boolean contract and handle unresolved detection separately.
Change Summary
Reconstructed Intent点击此处展开
Observed Constraints点击此处展开
Intent Alignment
Release Risk
Validation Gaps点击此处展开
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
Findings
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
迁移 runhey/OnmyojiAutoScript PR runhey#1848 的提交 86b2a7e。
更新十周年对弈竞猜资源
Sourcery 摘要
更新 FrogBoss 对周年庆资源的下注支持,并引入持久化的 Oas 预测策略。
新功能:
错误修复:
增强功能:
测试:
杂项:
Original summary in English
Summary by Sourcery
Update FrogBoss betting support for the anniversary resources and introduce the persistent Oas prediction strategy.
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: