From 6d4a00789da7596879a2c03f41a0cdc000a6355e Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Fri, 16 Oct 2026 11:31:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=BC=E5=AE=88:=20=E7=8B=82=E6=B0=94?= =?UTF-8?q?=E8=AF=BB=E6=95=B0=E4=B8=8D=E5=86=8D=E5=9B=A0=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E6=94=B6=E5=B7=A5=E8=80=8C=E4=B8=A2=E5=A4=B1;=20=E6=B1=87?= =?UTF-8?q?=E6=80=BB=E7=9A=84"=E6=9C=AA=E6=AF=94=E5=AF=B9"=E5=8F=AA?= =?UTF-8?q?=E7=AE=97=E7=9C=9F=E7=9A=84=E8=AF=A5=E6=AF=94=E5=AF=B9=E7=9A=84?= =?UTF-8?q?=E8=BD=AE=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一、读到就记, 别等走完全程 原先 lunacy_before 只在"走到合成"的路径上才写进报告。走"体力不足提前收工" 的分支时, 狂气明明已经读到了, 报告里却没有 —— 信息白丢。 现在读完立刻记进 _result, 并加一个 converted 字段说明这轮到底合成没有。 二、汇总口径修正 原来把"没合成"的轮次也算进"未比对", 数字虚高、掩盖真问题。 现在只统计 converted && !lunacy_checked 的轮次, 并单独列出来。 表格里也把两种情况分开: 未合成(读到 9699) —— 这轮压根没合成, 没什么可比 未比对 —— 合成过但狂气没读全, 等于没校过 老报告没有 converted 字段, 按结果文本里有没有"合成完成"推断。 实跑立刻见效: 现有 6 轮报告里精确指出"该比对却没比对 1 轮", 就是 10:42 那次真的换到模块、但狂气没读全的运行(它早于 LUNACY/UNACY 修复)。 三、测试 fixture 跟着改 test_unchecked_run_says_so 原来用 result='r' 当输入, 新口径下它被推断成 "没合成", 所以渲染成"未合成" —— 是测试该改而不是代码该改。改用真实结果文本, 并补 2 个用例(没合成的轮次不该混进未比对、老报告按文本推断)。 全套 284/284 通过。 --- scripts/convert_modules.py | 5 ++++- scripts/modules_status.py | 23 +++++++++++++++++------ tests/test_modules_status.py | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/scripts/convert_modules.py b/scripts/convert_modules.py index 4dc4c94..178eb57 100644 --- a/scripts/convert_modules.py +++ b/scripts/convert_modules.py @@ -525,6 +525,9 @@ def main(argv=None): break time.sleep(3) log('合成前狂气(OCR, 作相对比对用): %s' % lunacy_before) + # 读到就记进报告 —— 后面可能因为体力不足提前收工, 那时这条读数不该丢。 + _result['lunacy_before'] = lunacy_before + _result['converted'] = False # 体力读数也要重试。单次读成 None 的话, 下面"体力不足就收工"这层判断会被 # 整个跳过, 于是明明只是体力不够, 却要去点合成、最后报成 FAIL(退出码 1) —— @@ -552,6 +555,7 @@ def main(argv=None): ok, info, got = convert_once() _result['steps'].append({'step': '合成', 'ok': ok, 'info': info}) + _result['converted'] = bool(got) log('合成: %s (%s)' % ('OK' if ok else 'FAIL', info)) time.sleep(2) @@ -583,7 +587,6 @@ def main(argv=None): _result['lunacy_before'] = lunacy_before _result['lunacy_after'] = lunacy_after _result['lunacy_checked'] = (lunacy_before is not None and lunacy_after is not None) - if not args.keep_game: close_game() diff --git a/scripts/modules_status.py b/scripts/modules_status.py index 7e1842a..29b8761 100644 --- a/scripts/modules_status.py +++ b/scripts/modules_status.py @@ -43,12 +43,17 @@ def summarize(rows): checked = r.get('lunacy_checked') if checked is None: # 老报告没这个字段 checked = lb is not None and la is not None + converted = r.get('converted') + if converted is None: + # 老报告没有 converted, 按结果文本推断 + converted = '合成完成' in (r.get('result') or '') out.append({ 'started': r.get('started', '?'), 'ok': bool(r.get('ok')), 'result': r.get('result', ''), 'elapsed_s': r.get('elapsed_s'), 'info': conv.get('info', ''), + 'converted': bool(converted), 'lunacy_before': lb, 'lunacy_after': la, 'lunacy_checked': bool(checked), @@ -61,6 +66,10 @@ def lunacy_cell(r): """狂气那格的显示。没比对上时明说, 不装作校过了。""" if r['lunacy_alarm']: return '⚠️ %s -> %s' % (r['lunacy_before'], r['lunacy_after']) + if not r['converted']: + # 这轮压根没合成, 没什么可比 —— 和"合成过但没读到"是两回事 + n = r['lunacy_before'] + return '未合成(读到 %s)' % n if n is not None else '未合成' if not r['lunacy_checked']: return '未比对' return '%s 前后一致' % r['lunacy_after'] @@ -94,20 +103,22 @@ def main(argv=None): print('还没有合成记录(%s)' % args.dir) return 0 - got = sum(1 for r in rows if '+1' in r['info'] or '模组' in r['info'] and '->' in r['info']) + got = sum(1 for r in rows if r['converted']) fails = [r for r in rows if not r['ok']] alarms = [r for r in rows if r['lunacy_alarm']] - unchecked = [r for r in rows if not r['lunacy_checked']] + # 只统计"真的合成过却没能比对"的 —— 没合成的轮次没什么可比, 混进来会虚高 + unchecked = [r for r in rows if r['converted'] and not r['lunacy_checked']] - print('共 %d 轮: 换到模块 %d 轮, 失败 %d 轮, 狂气告警 %d 轮, 未比对 %d 轮' + print('共 %d 轮: 换到模块 %d 轮, 失败 %d 轮, 狂气告警 %d 轮, 该比对却没比对 %d 轮' % (len(rows), got, len(fails), len(alarms), len(unchecked))) if alarms: print('⚠️ 有狂气告警, 需要人工核查:') for r in alarms: print(' %s %s' % (r['started'], r['result'])) - if unchecked and not alarms: - print(' 提示: 有 %d 轮没读到狂气(前后至少一次是 None), 那几轮等于没校过。' - % len(unchecked)) + if unchecked: + print('⚠️ 这些轮次合成过但狂气没读全, 等于没校过:') + for r in unchecked: + print(' %s %s' % (r['started'], r['result'])) # 连着失败(最新几条都不是好结果)要醒目 —— 那说明流程坏了 streak = 0 for r in rows: diff --git a/tests/test_modules_status.py b/tests/test_modules_status.py index 136add1..8f1830d 100644 --- a/tests/test_modules_status.py +++ b/tests/test_modules_status.py @@ -67,24 +67,52 @@ class LunacyColumnTest(unittest.TestCase): """ def test_checked_run_shows_agreement(self): - r = ms.summarize([{'started': 'x', 'ok': True, 'result': 'r', 'elapsed_s': 10, + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', 'elapsed_s': 10, + 'converted': True, 'lunacy_before': 9699, 'lunacy_after': 9699, 'lunacy_checked': True}])[0] self.assertTrue(r['lunacy_checked']) self.assertIn('9699', ms.lunacy_cell(r)) def test_unchecked_run_says_so(self): - r = ms.summarize([{'started': 'x', 'ok': True, 'result': 'r', 'elapsed_s': 10, + # 合成过但狂气没读全 -> 必须明说"未比对"(不能装作校过了) + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', 'elapsed_s': 10, + 'converted': True, 'lunacy_before': None, 'lunacy_after': 9699, 'lunacy_checked': False}])[0] self.assertFalse(r['lunacy_checked']) - # 不能装作校过了 self.assertEqual(ms.lunacy_cell(r), '未比对') + def test_skipped_run_is_not_counted_as_unchecked(self): + """没合成的轮次没什么可比, 不该混进"该比对却没比对"。 + + 混进去会让这个数字虚高, 掩盖真正有问题的那几轮。 + """ + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '体力不足(4<20), 本轮无需合成', 'elapsed_s': 10, + 'converted': False, 'lunacy_before': 9699, + 'lunacy_checked': False}])[0] + self.assertFalse(r['converted']) + self.assertEqual(ms.lunacy_cell(r), '未合成(读到 9699)') + + def test_old_report_infers_converted_from_result_text(self): + # 老报告没有 converted 字段, 按结果文本推断 + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', + 'elapsed_s': 10}])[0] + self.assertTrue(r['converted']) + r2 = ms.summarize([{'started': 'y', 'ok': True, + 'result': '体力不足(4<20), 本轮无需合成', + 'elapsed_s': 10}])[0] + self.assertFalse(r2['converted']) + def test_alarm_is_visible_in_the_cell(self): r = ms.summarize([{'started': 'x', 'ok': False, 'result': '⚠️ 狂气读数发生变化 9699 -> 6300, 立即停止并人工核查', - 'elapsed_s': 10, 'lunacy_before': 9699, 'lunacy_after': 6300, + 'elapsed_s': 10, 'converted': True, + 'lunacy_before': 9699, 'lunacy_after': 6300, 'lunacy_checked': True}])[0] self.assertTrue(r['lunacy_alarm']) self.assertIn('⚠️', ms.lunacy_cell(r))