fix(web3): 日期规则 datetime.strptime 缺模块限定符 → datetime.datetime.strptime
沙箱里 datetime 是模块名(不是 from datetime import datetime),
datetime.strptime / datetime.now 在沙箱里直接 AttributeError。
三处误导性的写法全部修正:
1. backend/core/ai_rule.py
- _DATE_USER_TEMPLATE_INITIAL / _DATE_USER_TEMPLATE_FIX 两份 prompt
把 datetime.strptime 改成 datetime.datetime.strptime,
并加粗警告『绝对不能写成 datetime.strptime(会 AttributeError)』
- 顺手修一笔 def check(value) -> str -> bool 的笔误(多写了 -> str)
2. src/components/RuleModal.vue
- codePlaceholder(date) 改用 datetime.datetime.strptime,
注释里点明沙箱语义
- date 类型的 form-hint 改用 datetime.datetime.strptime,
并加红字 warning 警示『不是 datetime.strptime』
3. tests/test_rule_runner.py
- TestDate 加 test_datetime_strptime_without_module_qualifier_fails_clearly
锁定『datetime.strptime(缺 .datetime.)必然 AttributeError』这个行为,
防止哪天有人悄悄做成兼容(破坏语义清晰度)
注:已有坏规则(如 attendance_in_time 已落库 4 处)用户自行到 UI 改,
按 CLAUDE.md『本工具只做查询』原则不动 DB。
39 条测试全过。
Showing