diff --git a/.agents/skills/align/SKILL.md b/.agents/skills/align/SKILL.md
new file mode 100644
index 0000000..d8fd0f1
--- /dev/null
+++ b/.agents/skills/align/SKILL.md
@@ -0,0 +1,37 @@
+---
+name: align
+description: 动手前需求对齐(拷问式,D:\PricingReview 项目)。主人说「对齐」「先对齐」「需求对齐」,或一次改动涉及多轮返工/多种理解可能时主动提出:把设计树的每条分支列出来,逐条给出推荐答案并请主人拍板,全部有答案后才动手写码。源自 mattpocock/skills 的 grill 理念,中文自有实现。
+---
+
+# 动手前对齐(设计树填空)
+
+来历(2026-10-18):骨架/填空那轮多轮返工的教训——外溢、位置错位,本质都是「需求分支没问穿」就动手。本技能把对齐固化成动手前的固定动作。
+
+## 流程
+
+0. **对照决策台账查冲突(红线,决策 107,永久有效)**——把本次要做的事与 `决策台账.md`
+ 相关决策逐一对照:凡是与历史决策**不一致**的(改口径、改行为、换形态、改显示),
+ **当场停下**,列出「与决策 NN 冲突:旧口径是什么、新指令要改成什么、影响什么」,
+ 给出选项请主人选择(维持旧决策 / 按新指令改并修订台账 / 折中)。
+ **主人选择之前不动手**——这一步没有例外。
+1. **一句话复述目标**——按当前理解,主人要的是什么结果(写在哪个软件、哪个动作、什么效果)。复述错了当场就会被纠正,比写完再改便宜。
+2. **列设计树分支**——把所有「有多种理解/多种做法」的决策点列出来,最多 6 条,按影响排序。每条必须:
+ - 用主人的业务语言问(说「金额汇总行」,不说「Unit=元 且 NoTaxPrice=1 的节点」);
+ - 给出**我的推荐答案 + 理由**(不是裸问题);
+ - 标注「不确认就不动手」的硬分支。
+3. **等答案**——主人逐条拍板或纠正。有答案的分支直接进决策台账;主人没答的硬分支**绝不开工**。
+4. **动手**——全部分支有答案后照常实施 → 验收 → 台账登记。
+
+## 什么时候主动提
+
+- 同一个词有两种理解(例:「外溢」到底是爆量还是不显示);
+- 动作落点有歧义(例:新增清单插在最上面还是最后);
+- 涉及第三方软件的识别规则(易达/广联达要什么架子);
+- 数据口径要定(例:系数按什么口径、金额汇总行能不能改价)。
+
+## 红线
+
+- **决策冲突必须停下来请主人选择**(决策 107):与历史决策不一致的改动,未获主人选择前禁止实施。
+- 问的是**业务决策**,不是技术细节——能自己查代码/文件确定的绝不问主人。
+- 一次问完,不要挤牙膏式一条条挤。
+- 对齐结论必须落 `决策台账.md`(当天补记或新决策),口头一致不算数。
diff --git a/.agents/skills/glossary/SKILL.md b/.agents/skills/glossary/SKILL.md
new file mode 100644
index 0000000..122043a
--- /dev/null
+++ b/.agents/skills/glossary/SKILL.md
@@ -0,0 +1,26 @@
+---
+name: glossary
+description: 项目术语表维护(D:\PricingReview\术语表.md)。主人说「术语表」「加术语」「更新术语表」,或会话中出现新的口头约定词(如骨架、填空、外溢、格式画像)时主动提议入表:一条一行、定义不超一行、标注决策号出处,跨会话语义不漂移。源自 mattpocock/skills 的 GLOSSARY 理念。
+---
+
+# 项目术语表维护
+
+文件:`D:\PricingReview\术语表.md`(一页,按拼音/类目排列)。
+
+## 什么时候动
+
+1. **会话里出现新的口头约定词**——主人造的词(骨架、填空、外溢、架子…)或开始反复使用的半技术词。主动提议一条定义,主人点头就入表。
+2. **一个词出现两种理解**(例:「外溢」既被用来指爆量也被用来指不显示)——入表时把两种含义都写清并注明适用场景,或让主人定夺只留一个。
+3. **主人问某个词什么意思**——先查术语表,没有就从台账里考据后补入。
+
+## 条目格式
+
+```
+术语 — 一句话定义(≤1 行,用主人的业务语言)。〔出处:决策 NN / 补记 N〕
+```
+
+## 红线
+
+- 定义必须主人认可过才入表;我自造的理解标注「待主人确认」。
+- 一页放不下就精简旧条目,不拆第二页。
+- 术语表与决策台账冲突时:台账为准,术语表次日更新。
diff --git a/.agents/skills/retro/SKILL.md b/.agents/skills/retro/SKILL.md
new file mode 100644
index 0000000..a9302dc
--- /dev/null
+++ b/.agents/skills/retro/SKILL.md
@@ -0,0 +1,25 @@
+---
+name: retro
+description: 收尾协作回顾(D:\PricingReview\协作改进.md)。主人说「回顾」「收尾回顾」,或一次大收口(合并推送/多轮返工结束)时主动做:复盘本次返工发生在哪、协作方式哪里可以改进,落一条可执行的改进(新 skill、新检查、新口令)。源自 mattpocock/skills 的 retro 理念——台账记业务决策,这里记工作方式本身。
+---
+
+# 收尾协作回顾
+
+文件:`D:\PricingReview\协作改进.md`(追加式,一条一个日期)。
+
+## 流程
+
+1. **找返工点**——本次会话哪里重做了?(需求没问穿、验证只对了一半、查错了文件、修了 A 才发现是 B)每处返工写一句根因。
+2. **提炼成可执行的改进**——必须落成下面四种之一,不许是空话("下次注意"不算):
+ - 新增/修订一个 skill(如 align 对齐、glossary 术语表就是这么来的);
+ - 一个固定检查动作(例:「验证结构不只验属性,要拿对方原生样本对数」);
+ - 一个钩子/脚本(如推送门禁);
+ - 一条写入术语表的新约定。
+3. **落文件**——`协作改进.md` 追加:日期 + 返工根因 + 改进动作 + 状态(已做/待做)。
+4. **顺手就做**——改进动作若是一条 skill 或检查,当场写掉,不留待办。
+
+## 红线
+
+- 只复盘**工作方式**,业务结论归决策台账,不重复记。
+- 每次最多提 2 条——贪多的改进清单没人执行。
+- 已有的改进不重复提,检查它是否被遵守了(例:align skill 有了,本次动手前用了没有)。
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..cd9e9bc
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,32 @@
+# AGENTS.md — 本项目 Agent 长期记忆(每次会话必读)
+
+## 🚫 红线的红线(主人定,2026-10-18,永久有效)
+
+**新指令与历史决策冲突时,必须当场指出冲突点,并请主人决策——禁止自行取舍、禁止静默改口。**
+凡与历史决策(`决策台账.md`)不一致的改动,动手前必须对照台账列明「与决策 NN 冲突」,等主人拍板后再实施。宁可多问一轮,不可擅自变更已定决策。
+
+> 来源:2026-10-18 定额工程量编辑口径反复(决策 90/96 ↔ 实际量编辑),因未指出冲突、自行改口造成多轮返工。主人原话:「要是决策前后矛盾,一定要指出来,并且要主人决策,不能你自己决策。凡是和历史决策不一样的。这个是红线的红线。禁区的禁区。」
+
+## 项目记忆文件(改口径先查这里)
+
+| 文件 | 用途 |
+|---|---|
+| `决策台账.md` | 全部业务决策与实测依据(编号递增,含补记);**新指令先对照它查冲突** |
+| `术语表.md` | 口头约定词的准确定义(骨架/填空/外溢/金额汇总行/锚点0…),歧义词以它为准 |
+| `协作改进.md` | 工作方式复盘与改进(转义校验、样本对数法、自清理规矩…) |
+| `系统规格.md` | 主人的规格原文(只读,走 spec-diff skill 对比) |
+
+## 工作方式铁律(历次返工沉淀,详见 协作改进.md)
+
+1. **验证结构,不能只验属性**——「写了但对方不认」时,第一动作是拿对方软件存的原生样本逐行对,不对着自己的导出件自证。
+2. **前端 .html/.js 改动落盘后,必须抽脚本块逐个 node --check**(转义丢层会让整页 JS 瘫痪)。
+3. **批量改文件用行级手术**,禁用跨行正则替换;落盘后回读打印修改处自检。
+4. **排查/测试产生的批次、会话、临时文件,收尾时自己清理**;只删自己建的,主人的数据绝不碰。
+5. 采纳/新增内容的填空三分类:**有值填值、没算留空、别人的数据擦掉**;架子(结构)严格照被导出文件自己的原生块克隆,不发明、不清零别人有的结构。
+
+## 数值口径速查(详见 术语表.md 与决策台账)
+
+- GCL = 清单工程量 ÷ 定额单位数字前缀;系数存后台(x_qty_coef);采纳挂公式 `GCL×系数`(不落数字)。
+- 定额 Quantity(库里/导出)= 每定额单位的量(÷因子);编辑框 = 实际量(×因子,编制状态可显公式 GCL×系数)。
+- 合价 = 工程量×单价(清单/定额同);金额汇总行(单位=元、单价1)永不回写价格。
+- 消耗量架子(清单级工料机尾表)真值 = Σ(含量×定额量)÷清单量。
diff --git a/CostReview/app/core/export_cos.py b/CostReview/app/core/export_cos.py
index 3a42526..2069c2b 100644
--- a/CostReview/app/core/export_cos.py
+++ b/CostReview/app/core/export_cos.py
@@ -21,6 +21,7 @@
"""
import io
+import json
import re
import struct
import zipfile
@@ -227,7 +228,7 @@ def _norm_parts(tmpl):
return opentag, inner[:spans[0].start()], spans[0].group(0), inner[spans[-1].end():]
-def _norm_xml(n, lres, template=None):
+def _norm_xml(n, lres, template=None, bill_qty=None):
"""定额行:优先克隆源文件同类 Norm 的完整属性集(值除会话字段外原样保留,
与易达的已知可行解一致);没有模板时退回最小形态。会话没算出的数值写 0
(易达同款处理)——占位属性可以在位为 0,但不能缺席。
@@ -257,16 +258,47 @@ def _norm_xml(n, lres, template=None):
if n["Total"] is not None:
a += ' Total="%s"' % n["Total"]
tag = ""
+ def _lres():
+ for it in lres:
+ if not it[0]:
+ continue
+ c, q = it[0], it[1]
+ ex = it[2] if len(it) > 2 else None
+ yield c, q, ex
+
if row_tmpl is None:
kids = "".join('<%s Number="%s" Quantity="%s" NOCost="false" Remark=""/>' % (_LME, _esc(c), _esc(q))
- for c, q in lres if c)
+ for c, q, _ex in _lres())
else:
- kids = "".join(_lme_row(row_tmpl, c, q, express=_esc(q)) for c, q in lres if c)
+ # 决策 106 补记十二:含量行 Express 优先填**历史项目自己的调整式**(如 1611.66*1.2),
+ # 没有算式的退裸含量——采纳定额的换算调整跟着历史项目走。
+ kids = "".join(_lme_row(row_tmpl, c, q, express=_esc(ex) if ex else _esc(q))
+ for c, q, ex in _lres())
if pre or row_tmpl is not None or post:
+ # 数量算式行(ExpressElement):**采纳/新增的定额一律不带**——主人实测:易达对带
+ # 算式行的定额按计算式显示(QGCL 代号 / [24.7157] 方括号值),都不是要的纯数字;
+ # 去掉算式行后易达直接显示 Quantity 属性。原生未动定额的算式行原样保留(原样原则)。
pre, post = _zero_results(pre), _zero_results(post)
- # 换算记录是模板定额自己的操作历史(换机/改价…,决策 101 同类)——新定额没有历史,整行不落
+ pre = re.sub(r']*/>', '', pre)
+ post = re.sub(r']*/>', '', post)
+ # 换算调整记录(补记十三):先剥掉模板的记录(那是模板定额的历史),再按本定额
+ # 会话携带的 x_adjust 重写——采纳定额的调整工艺(GConvInfo 标准换算/R*2,J*2/送桩
+ # 材料含量…)跟历史项目走,主人定「有信息就要搬」。行形态照模板首行克隆。
+ # 换算调整记录(补记十三):先剥掉模板的记录(那是模板定额的历史),再按本定额
+ # 会话携带的 x_adjust 重写——采纳定额的调整工艺(GConvInfo 标准换算/R*2,J*2/送桩
+ # 材料含量…)跟历史项目走,主人定「有信息就要搬」。行形态照模板首行克隆。
+ m_adj = re.search(r']*/>', post)
+ adj_tmpl = m_adj.group(0) if m_adj else ''
post = re.sub(r']*/>', '', post)
post = re.sub(r']*>.*?', '', post)
+ try:
+ adj_vals = json.loads(n.get("x_adjust") or "[]")
+ except (TypeError, ValueError):
+ adj_vals = []
+ if isinstance(adj_vals, list) and adj_vals:
+ rows = "".join(_attr_set(_attr_set(adj_tmpl, "OrderNumber", str(i + 1)), "Value", str(v))
+ for i, v in enumerate(adj_vals))
+ post += rows
return tag + pre + kids + post + ""
return tag + kids + ""
@@ -547,7 +579,15 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
nrm_changed = True
continue
newn = nsp["opentag"]
- for attr in ("Name", "Quantity"):
+ for attr in ("Name", "Quantity", "Total"):
+ if attr == "Total":
+ # 补记十六:改过工程量的定额 合价=工程量×单价(数值相同不重写)
+ if nn["Quantity"] is None or nn["Price"] is None:
+ continue
+ w = "%.2f" % round(float(nn["Quantity"]) * float(nn["Price"]), 2)
+ if not _num_eq(_attr(newn, "Total"), w):
+ newn = _attr_set(newn, "Total", w)
+ continue
if nn[attr] is None or (attr == "Quantity" and _num_eq(_attr(newn, attr), nn[attr])):
continue
w = _fmt_qty(nn[attr], 6) if attr == "Quantity" else nn[attr] # 定额工程量按源文件 6 位小数
@@ -567,7 +607,8 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
# WorkContent 之后(工料机汇总平铺表之前)。此前裸 Norm 插在块尾
# (汇总表和单价计算节点之后),广联达按 schema 解析错位 →
# 采纳定额的工料机外溢到定额层(屏西五路 040301004001 实测)。
- body = "".join(_norm_xml(nn, res_by_norm.get(nn["id"], []), tmpl) for nn in napp)
+ body = "".join(_norm_xml(nn, res_by_norm.get(nn["id"], []), tmpl, bill_qty=b["Quantity"])
+ for nn in napp)
if has_wc and wc_close != -1:
ins = wc_close + len("")
# 决策 99:原生 WorkContent 恒带 Name/Total/Remark 三属性(清单名/清单合价 2 位/空)
@@ -594,7 +635,7 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
inner = txt[nsp["e"] + mk["s"]: nsp["end"] + mk["s"]]
keep |= set(re.findall(r']*?Number="([^"]*)"', inner))
for nn in napp:
- keep |= {c for c, _q in res_by_norm.get(nn["id"], []) if c}
+ keep |= {it[0] for it in res_by_norm.get(nn["id"], []) if it[0]}
have = {c for _s, _e, c in dspans}
for _s, _e, c in dspans:
if c not in keep:
@@ -602,8 +643,33 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
add = [c for c in sorted(keep) if c not in have]
if add:
ins_at = dspans[-1][1] if dspans else tail_start
- kid = "".join(''
- % _esc(c) for c in add)
+ # 决策 106 补记十一:补码行与新增清单同口径——数量按 Σ(含量×定额量)÷清单量
+ # 填真值(此前恒 0)。仅新增码计算(原生码的行保持原值不动)。
+ agg = {}
+ try:
+ bq = float(b["Quantity"]) if b.get("Quantity") is not None else 0.0
+ except (TypeError, ValueError):
+ bq = 0.0
+ for nn in napp:
+ try:
+ nq = float(nn["Quantity"]) if nn["Quantity"] is not None else 0.0
+ except (TypeError, ValueError):
+ nq = 0.0
+ for it in res_by_norm.get(nn["id"], []):
+ cc, qq = it[0], it[1]
+ if cc not in add:
+ continue
+ try:
+ agg[cc] = agg.get(cc, 0.0) + float(qq) * nq
+ except (TypeError, ValueError):
+ pass
+ row_tmpl = txt[dspans[0][0]:dspans[0][1]] if dspans else None
+ kid = ""
+ for c in add:
+ vs = "%.4f" % round((agg.get(c, 0.0) / bq if bq else 0.0), 4)
+ kid += (_lme_row(row_tmpl, c, vs, express=vs) if row_tmpl else
+ '<%s Number="%s" Express="%s" Quantity="%s" Remark=""/>'
+ % (_LME, _esc(c), _esc(vs), _esc(vs)))
edits.append((ins_at, ins_at, kid))
# 新增清单落位:锚点 = 「第 N 条源清单之后」;**锚点 0 = 插在第一条源清单之前**
# (主人在工作台把新增行插到最上面时 x_seq 排最前——此前 0 被当成「无锚点」甩到组尾,
@@ -639,7 +705,8 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
if ' NormIdentity="' in nsp["opentag"]:
nn_tmpl = nsp["opentag"]
break
- norms_xml = [_norm_xml(nn, res_by_norm.get(nn["id"], []), nn_tmpl or norm_tmpl)
+ norms_xml = [_norm_xml(nn, res_by_norm.get(nn["id"], []), nn_tmpl or norm_tmpl,
+ bill_qty=b["Quantity"])
for nn in norms_by_bill.get(b["id"], {}).get("append") or []]
parts.append(_bill_xml(b, tgt["tag"], norms_xml, tmpl_blk or tgt["opentag"], txt=txt))
edits.append((pos, pos, "".join(parts)))
@@ -683,6 +750,22 @@ def _summary_node(fields, template=None):
"" if np_ is None else np_, "" if tp is None else tp, "" if kd is None else kd))
+def _is_amount_aggregate(opentag):
+ """金额汇总行判定(决策 106 补记九):广联达文件里「人工费/管理费」这类汇总行的
+ 惯例是 数量=金额合计、单价恒为 1(元/元恒等)。这类行回写会话里的资源单价
+ (如人工 500 元/工日)会被按 数量×单价 重算 → 人工费爆炸外溢(样例工程实测)。
+ 判据:单位=元 且 原除税价数值=1。"""
+ if (_attr(opentag, "Unit") or "").strip() != "元":
+ return False
+ try:
+ return abs(float(_attr(opentag, "NoTaxPrice") or 0) - 1.0) < 1e-9
+ except (TypeError, ValueError):
+ return False
+
+
+_PRICE_ATTRS = ("NoTaxPrice", "TaxRate", "TaxPrice")
+
+
def transform_unit_summaries(txt, price_updates, added_rows, recode_map=None, recode_children=None):
"""本单位工程的工料机汇总 = 单价被查找的对象(主人口径 5.1/5.3):
①采纳新增的品类行追加到本单位汇总末尾(克隆完整属性集);
@@ -709,6 +792,8 @@ def transform_unit_summaries(txt, price_updates, added_rows, recode_map=None, re
if not span:
continue
s0, e0, _bend, opentag = span
+ if _is_amount_aggregate(opentag):
+ continue # 金额汇总行不回写价格(补记九:人工费外溢实测)
newtag = opentag
for attr, v in (("NoTaxPrice", ntp), ("TaxRate", rate), ("TaxPrice", taxp)):
if v is None:
@@ -845,13 +930,16 @@ def transform_project(txt, added_summaries, hidden_codes, sync_rows=None):
if not span:
continue
s0, e0, _bend, opentag = span
+ aggregate = _is_amount_aggregate(opentag)
newtag = opentag
for attr, want in (("Name", name), ("Specification", spec), ("Unit", unit),
("NoTaxPrice", ntp), ("TaxRate", rate), ("TaxPrice", taxp)):
cur = _attr(newtag, attr)
if cur is None or want is None:
continue
- if attr in ("NoTaxPrice", "TaxRate", "TaxPrice") and _num_eq(cur, want):
+ if aggregate and attr in _PRICE_ATTRS:
+ continue # 金额汇总行价格不回写(补记九)
+ if attr in _PRICE_ATTRS and _num_eq(cur, want):
continue
if attr in ("Name", "Specification", "Unit") and (cur or "").strip() == (want or "").strip():
continue
diff --git a/CostReview/app/core/import_job.py b/CostReview/app/core/import_job.py
index 0fb2320..f0f5fb8 100644
--- a/CostReview/app/core/import_job.py
+++ b/CostReview/app/core/import_job.py
@@ -306,8 +306,17 @@ def parse_std(path, out):
_push_bill(el.attrib) # ★ 容器在 start 就记账
out["cur_norm"] = -1 # 进清单:清掉定额上下文
elif el.tag == "Norm":
- # 定额在 start 就记账:它下面的工料机消耗量要挂到 len(norms)(即它将占的下标)
- out["cur_norm"] = len(out["norms"])
+ # 决策 106 补记十四:广联达把清单级的资源构成行(人工费等,编码=纯数字
+ # 工料机码、单位=元)也写成 元素——那是派生的金额行,不是定额
+ # (样例工程实测:采纳把它当定额带进工作台=人工费外溢)。不占定额下标,
+ # 子元素(含量/调整记录)一并跳过。
+ if (el.attrib.get("Number", "").isdigit()
+ and (el.attrib.get("Unit") or "").strip() == "元"):
+ out["skip_res_norm"] = True
+ out["cur_norm"] = -1
+ else:
+ # 定额在 start 就记账:它下面的工料机消耗量要挂到 len(norms)(即它将占的下标)
+ out["cur_norm"] = len(out["norms"])
elif el.tag in ("DivisionalWorks", "PreliminaryDivisionalWorks"):
# 2026-09-30:分部层 —— 分部分项与措施项目**各有一套**,而且都可能嵌套。
# 「原数据」标签里那张表的「分部」行、以及 ± 目录树全靠它。
@@ -360,12 +369,15 @@ def parse_std(path, out):
tag = el.tag
a = el.attrib
if tag == "Norm":
- # 2026-09-29:补 Quantity / Total(源文件里确实有这两个属性,此前只取了 Price)
- # 元组顺序:idx, 编码, 名称, 单位, 工程量, 单价, 合价
- out["norms"].append((out["cur_bill"], a.get("Number", ""), a.get("Name", ""),
- a.get("Unit", ""), f(a.get("Quantity")),
- f(a.get("Price")), f(a.get("Total"))))
- out["cur_norm"] = -1 # 出这条定额:后面的工料机不再算它的消耗
+ if out.pop("skip_res_norm", False):
+ out["cur_norm"] = -1 # 伪定额(资源构成行)不落库,见 start 侧
+ else:
+ # 2026-09-29:补 Quantity / Total(源文件里确实有这两个属性,此前只取了 Price)
+ # 元组顺序:idx, 编码, 名称, 单位, 工程量, 单价, 合价
+ out["norms"].append((out["cur_bill"], a.get("Number", ""), a.get("Name", ""),
+ a.get("Unit", ""), f(a.get("Quantity")),
+ f(a.get("Price")), f(a.get("Total"))))
+ out["cur_norm"] = -1 # 出这条定额:后面的工料机不再算它的消耗
elif tag == "LabourMaterialsEquipmentsMachinesElement":
# 2026-09-30:定额消耗量。**必须在自己的 end 事件里读属性** ——
# 循环末尾的 el.clear() 会把 attrib 一起清掉,等父元素(Norm)end 再 iter 只能拿到空属性。
@@ -379,7 +391,21 @@ def parse_std(path, out):
if _code:
out.setdefault("lme_res", {}).setdefault(_p, []).append((_code, f(a.get("Quantity"))))
elif _n >= 0 and _code:
- out.setdefault("norm_res", []).append((_n, _code, f(a.get("Quantity"))))
+ # 决策 106 补记十二:含量算式(Express,如 "1611.66*1.2" 换算调整式)
+ # 随含量一起入库——采纳导出时按历史项目的调整式原样填写(此前只存数值,
+ # 调整信息丢失,只能填裸含量)。
+ out.setdefault("norm_res", []).append((_n, _code, f(a.get("Quantity")),
+ a.get("Express") or None))
+
+ elif tag == "NormAdjustmentList":
+ # 补记十三:换算调整记录(GConvInfo 标准换算/R*2, J*2/送桩材料含量…)
+ # 整条搬运——采纳定额的调整工艺跟历史项目走(此前整段丢弃)。
+ # cur_norm 由 Norm 的 start 事件记账,取属性同样要在自己的 end 事件里。
+ _n = out.get("cur_norm", -1)
+ v = a.get("Value") or "" # 原样保真(原生值可带首尾空格,strip 会改字面量)
+ if _n >= 0 and v.strip():
+ # 主人定(补记十五改):导入什么就是什么,原样整串入库,导出原样回填
+ out.setdefault("norm_adj", {}).setdefault(_n, []).append(v)
elif tag == "SummaryOfCost":
# 2026-09-30:单位工程造价构成。同样因为 clear 会清空 attrib,只能在自己的 end 里读。
# 归栈顶那个 UnitWorks(嵌套时内层优先),且每个单位工程只认它的第一个 SummaryOfCost。
@@ -586,21 +612,23 @@ def save(con, kind, out, fn, sha, mtime, meta=None, bid=None):
# 2026-10-17 修正:系数必须先除掉定额单位的数字前缀(10m/100m…),否则 GCL 求值时
# 单位换算双算两遍(前山河 040501004001:10m 定额导出量少 10 倍实测)。
norm_ids = []
- for idx, num, name, unit, qty, price, total in out["norms"]:
+ for norm_idx, (idx, num, name, unit, qty, price, total) in enumerate(out["norms"]):
bid2 = bill_ids[idx] if 0 <= idx < len(bill_ids) else None
bqty = out["bills"][idx][4] if 0 <= idx < len(out["bills"]) else None
coef = (round(qty * unit_prefix(unit) / bqty, 6)
if (qty is not None and bqty not in (None, 0)) else None)
- cur.execute("""INSERT INTO norms(bill_id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef)
- VALUES(?,?,?,?,?,?,?,?)""",
- (bid2, num, name, unit, qty, price, total, coef))
+ cur.execute("""INSERT INTO norms(bill_id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef, x_adjust)
+ VALUES(?,?,?,?,?,?,?,?,?)""",
+ (bid2, num, name, unit, qty, price, total, coef,
+ (lambda vals: json.dumps(vals, ensure_ascii=False) if vals else None)(
+ out.get("norm_adj", {}).get(norm_idx, []))))
norm_ids.append(cur.lastrowid)
# 定额消耗工料机(对应 s_norm_res)
- for nidx, code, q in (out.get("norm_res") or []):
+ for nidx, code, q, express in (out.get("norm_res") or []):
nid = norm_ids[nidx] if 0 <= nidx < len(norm_ids) else None
- cur.execute("INSERT INTO norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
- (nid, code, q))
+ cur.execute("INSERT INTO norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
+ (nid, code, q, express or None))
n_lme = 0
n_lme_errs = 0
diff --git a/CostReview/app/core/session_job.py b/CostReview/app/core/session_job.py
index 8540133..d1feade 100644
--- a/CostReview/app/core/session_job.py
+++ b/CostReview/app/core/session_job.py
@@ -324,6 +324,10 @@ def connect():
("s_lmes", ("x_remark TEXT", "x_hash_semi TEXT")),
# 2026-10-02:台班组成子项的名称(老库没这列,打开工程时 INSERT 会缺列报错)
("s_lme_res", ("name TEXT",)),
+ # 2026-10-18:定额含量算式(换算调整式如 1611.66*1.2,采纳携带;决策 106 补记十二)
+ ("s_norm_res", ("express TEXT",)),
+ # 2026-10-18:定额换算调整记录(JSON,采纳携带;决策 106 补记十三)
+ ("s_norms", ("x_adjust TEXT",)),
):
for col in cols:
try:
@@ -508,20 +512,23 @@ def open_project(con, files, meta, job, sid=None):
# 工程量/合价永远是「—」)。元组顺序:idx, 编码, 名称, 单位, 工程量, 单价, 合价
# 定额入库,同时记下真实 id —— 消耗量要靠它挂(norm_res 里存的是本文件内下标)
norm_ids = []
- for idx, num, nm, unit, qty, price, total in out["norms"]:
+ adj = out.get("norm_adj", {})
+ for norm_idx, (idx, num, nm, unit, qty, price, total) in enumerate(out["norms"]):
bid = bill_ids[idx0 + idx] if 0 <= idx < len(out["bills"]) else None
- cur.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total)
- VALUES(?,?,?,?,?,?,?)""",
- (bid, num, nm, unit, qty, price, total))
+ vals = adj.get(norm_idx, [])
+ cur.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total, x_adjust)
+ VALUES(?,?,?,?,?,?,?,?)""",
+ (bid, num, nm, unit, qty, price, total,
+ json.dumps(vals, ensure_ascii=False) if vals else None))
norm_ids.append(cur.lastrowid)
stat["norm"] += 1
- # 2026-09-30:定额消耗量(定额 → 工料机编码 + 消耗量)。
+ # 2026-09-30:定额消耗量(定额 → 工料机编码 + 消耗量 + 含量算式,补记十二)。
# 有这张表才能回答「某个单位工程用了哪些工料机」——以前工料机只能挂到整个会话。
- for nidx, code, q in (out.get("norm_res") or []):
+ for nidx, code, q, express in (out.get("norm_res") or []):
nid = norm_ids[nidx] if 0 <= nidx < len(norm_ids) else None
- cur.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
- (nid, code, q))
+ cur.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
+ (nid, code, q, express or None))
stat["nres"] = stat.get("nres", 0) + 1
for num, nm, spec, unit, ntp, tax, tp, qty, kind in out["lmes"]:
diff --git a/CostReview/app/server/api_server.py b/CostReview/app/server/api_server.py
index 1561731..4c2d582 100644
--- a/CostReview/app/server/api_server.py
+++ b/CostReview/app/server/api_server.py
@@ -2186,16 +2186,17 @@ def _snap_norms(con, bill_id):
"""一条清单的定额+消耗量快照(仅当定额带状态列才值得回填;无状态返回 [])"""
out = []
for n in con.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total,
- x_tdel, x_adopt, x_src_norm_id, qty_expr
+ x_tdel, x_adopt, x_src_norm_id, qty_expr, x_adjust
FROM s_norms WHERE bill_id=? ORDER BY id""", (bill_id,)):
if not (n["x_tdel"] or n["x_adopt"] or n["x_src_norm_id"] or n["qty_expr"]):
continue # 干净定额:重导自然重建,不 snapshot
res = [list(x) for x in con.execute(
- "SELECT res_code, qty FROM s_norm_res WHERE norm_id=? ORDER BY id", (n["id"],))]
+ "SELECT res_code, qty, express FROM s_norm_res WHERE norm_id=? ORDER BY id", (n["id"],))]
out.append({"Number": n["Number"], "Name": n["Name"], "Unit": n["Unit"],
"Quantity": n["Quantity"], "Price": n["Price"], "Total": n["Total"],
"x_tdel": n["x_tdel"], "x_adopt": n["x_adopt"],
- "x_src_norm_id": n["x_src_norm_id"], "qty_expr": n["qty_expr"], "res": res})
+ "x_src_norm_id": n["x_src_norm_id"], "qty_expr": n["qty_expr"],
+ "x_adjust": n["x_adjust"], "res": res})
return out
@@ -2258,12 +2259,13 @@ def _restore_norms(con, bill_id, norms):
con.execute("DELETE FROM s_norms WHERE bill_id=?", (bill_id,))
for n in norms:
cur = con.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
- x_tdel, x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,?,?,?,?,?,?,?)""",
+ x_tdel, x_adopt, x_src_norm_id, qty_expr, x_adjust) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)""",
(bill_id, n["Number"], n["Name"], n["Unit"], n["Quantity"], n["Price"],
- n["Total"], n["x_tdel"], n["x_adopt"], n["x_src_norm_id"], n.get("qty_expr")))
- for i, (code, qty) in enumerate(n["res"]):
- con.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
- (cur.lastrowid, code, qty))
+ n["Total"], n["x_tdel"], n["x_adopt"], n["x_src_norm_id"], n.get("qty_expr"),
+ n.get("x_adjust")))
+ for i, (code, qty, express) in enumerate(n["res"]):
+ con.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
+ (cur.lastrowid, code, qty, express))
def _bill_state_restore(con, sid, snap):
@@ -2786,6 +2788,10 @@ def api_bill_op(sc, body):
_edit_log(sc, _bill_ekbase(sc, cur_row), ef, _BILL_EDIT_FIELDS, cur_row)
if "Name" in fields or "Attr" in fields:
_bill_rehash(sc, bid)
+ # 补记十六(主人定):改工程量 → 合价 = 工程量×单价(工作台即时同步,导出同口径)
+ if "Quantity" in fields:
+ sc.execute("""UPDATE s_bills SET Total=ROUND(COALESCE(Quantity,0)*COALESCE(Price,0),2)
+ WHERE id=?""", (bid,))
return {"ok": True, "sid": sid}
return {"ok": False, "msg": "未知操作:%s" % op}
@@ -3017,6 +3023,10 @@ def api_norm_edit(sc, body):
_edit_log(sc, _norm_ekbase(sc, cur_row),
{k: fields[k] for k in ("Name", "Quantity") if k in fields},
{"Name": "Name", "Quantity": "Quantity"}, cur_row)
+ # 补记十六(主人定):改工程量(数字) → 合价 = 工程量×单价(工作台即时同步)
+ if "Quantity" in fields:
+ sc.execute("""UPDATE s_norms SET Total=ROUND(COALESCE(Quantity,0)*COALESCE(Price,0),2)
+ WHERE id=?""", (nid,))
out = {"ok": True}
if qty_out is not None:
out["quantity"] = qty_out
@@ -3132,7 +3142,7 @@ def api_bill_adopt(sc, hc, body):
bb = hc.execute("SELECT id, Number, Name, Attr, Unit, Price, Quantity FROM bills WHERE id=?", (src_id,)).fetchone()
if not bb:
return {"ok": False, "msg": "入库项目清单不存在(批次可能已删除)"}
- bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef
+ bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef, x_adjust
FROM norms WHERE bill_id=? ORDER BY id""", (src_id,)).fetchall()
is_new = bool(sb["x_new"])
# 规格 19(2026-10-17 主人定·采纳逻辑变化):采纳定额工程量默认公式 = **GCL×系数**,
@@ -3149,12 +3159,14 @@ def api_bill_adopt(sc, hc, body):
sc.execute("DELETE FROM s_norms WHERE bill_id=?", (bid,))
for nn in bnorms:
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
- x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,?)""",
+ x_adopt, x_src_norm_id, qty_expr, x_adjust)
+ VALUES(?,?,?,?,NULL,?,NULL,1,?,?,?)""",
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
- _gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"])))
- for rr in hc.execute("SELECT res_code, qty FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
- sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
- (cur.lastrowid, rr["res_code"], rr["qty"]))
+ _gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"]),
+ nn["x_adjust"]))
+ for rr in hc.execute("SELECT res_code, qty, express FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
+ sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
+ (cur.lastrowid, rr["res_code"], rr["qty"], rr["express"]))
else:
# 9.3 定额追加 + 原定额转临删 + 清单单价按采纳价覆盖
sc.execute("DELETE FROM s_norm_res WHERE norm_id IN (SELECT id FROM s_norms WHERE bill_id=? AND x_adopt=1)", (bid,))
@@ -3162,12 +3174,14 @@ def api_bill_adopt(sc, hc, body):
sc.execute("UPDATE s_norms SET x_tdel=1 WHERE bill_id=?", (bid,)) # 原有定额 → 临删
for nn in bnorms:
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
- x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,?)""",
+ x_adopt, x_src_norm_id, qty_expr, x_adjust)
+ VALUES(?,?,?,?,NULL,?,NULL,1,?,?,?)""",
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
- _gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"])))
- for rr in hc.execute("SELECT res_code, qty FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
- sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
- (cur.lastrowid, rr["res_code"], rr["qty"]))
+ _gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"]),
+ nn["x_adjust"]))
+ for rr in hc.execute("SELECT res_code, qty, express FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
+ sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty, express) VALUES(?,?,?,?)",
+ (cur.lastrowid, rr["res_code"], rr["qty"], rr["express"]))
bqty = sc.execute("SELECT Quantity FROM s_bills WHERE id=?", (bid,)).fetchone()["Quantity"]
btotal = round((float(bqty) if bqty is not None else 0.0) * (float(new_price) if new_price is not None else 0.0), 2)
sc.execute("UPDATE s_bills SET Price=?, Total=?, x_adopt=1 WHERE id=?", (new_price, btotal, bid))
@@ -3227,14 +3241,22 @@ def _export_session(sc, sid, progress=None):
kind = "prelim" if b["Kind"] == "prelim" else "item"
g = groups.setdefault((b["uw_id"], kind), {"pos": 0, "pairs": [], "news": []})
bd = dict(b)
+ # 补记十六:合价口径——**新增清单** 导出时按 工程量×单价 现算;
+ # 已有清单在编辑保存时已同步(上面的 API 入口),导出按会话现值原样写穿(决策 90)
+ if b["x_new"]:
+ _q, _p2 = f_(b["Quantity"]), f_(b["Price"])
+ bd["Total"] = round((_q or 0) * (_p2 or 0), 2)
if b["x_new"]:
bd["_anchor"] = g["pos"]
+ # 补记十六(主人定):新增清单 合价 = 工程量×单价——工作台不预存合价,导出时现算
+ _q, _p2 = f_(b["Quantity"]), f_(b["Price"])
+ bd["Total"] = round((_q or 0) * (_p2 or 0), 2)
g["news"].append(bd)
else:
g["pos"] += 1
g["pairs"].append((g["pos"], bd))
norms_by_bill = {}
- for nb in sc.execute("""SELECT id, bill_id, Number, Name, Unit, Quantity, Price, Total, x_tdel, x_adopt, x_src_norm_id, qty_expr
+ for nb in sc.execute("""SELECT id, bill_id, Number, Name, Unit, Quantity, Price, Total, x_tdel, x_adopt, x_src_norm_id, qty_expr, x_adjust
FROM s_norms WHERE bill_id IN (SELECT id FROM s_bills WHERE session_id=?)
ORDER BY id""", (sid,)):
entry = norms_by_bill.setdefault(nb["bill_id"], {"source": [], "append": []})
@@ -3269,11 +3291,16 @@ def _export_session(sc, sid, progress=None):
nb["Quantity"], nb["Total"] = row["Quantity"], row["Total"]
finally:
hc.close()
+ # 补记十六:定额 合价 = 工程量×单价(统一口径;单价缺失的行保持原值)
+ for entry in norms_by_bill.values():
+ for nb in entry["append"] + entry["source"]:
+ if nb.get("Quantity") is not None and nb.get("Price") is not None:
+ nb["Total"] = round(float(nb["Quantity"]) * float(nb["Price"]), 2)
res_by_norm = {}
- for rr in sc.execute("""SELECT nr.norm_id, nr.res_code, nr.qty FROM s_norm_res nr
+ for rr in sc.execute("""SELECT nr.norm_id, nr.res_code, nr.qty, nr.express FROM s_norm_res nr
WHERE nr.norm_id IN (SELECT id FROM s_norms
WHERE bill_id IN (SELECT id FROM s_bills WHERE session_id=?))""", (sid,)):
- res_by_norm.setdefault(rr["norm_id"], []).append((rr["res_code"], rr["qty"]))
+ res_by_norm.setdefault(rr["norm_id"], []).append((rr["res_code"], rr["qty"], rr["express"]))
# (uw_id, kind) → uw 键;同 uw 的两种 kind 合成一份 plan
uwmap = {r["id"]: ((r["Number"] or ""), (r["Name"] or ""))
for r in sc.execute("SELECT id, Number, Name FROM s_unit_works WHERE session_id=?", (sid,))}
@@ -4745,6 +4772,8 @@ def _ensure_batch_schema():
AND norms.Quantity IS NOT NULL
AND EXISTS (SELECT 1 FROM bills b WHERE b.id = norms.bill_id
AND b.Quantity IS NOT NULL AND b.Quantity != 0)""")
+ _ensure_cols(c, "norm_res", [("express", "TEXT")]) # 含量算式(换算调整式,补记十二)
+ _ensure_cols(c, "norms", [("x_adjust", "TEXT")]) # 换算调整记录(JSON,补记十三)
_ensure_cols(c, "lmes", [("Quantity", "REAL"), ("Kind", "INTEGER")])
# x_info / x_feat:项目级「基本信息」「项目特征信息」两张卡的数据(与 sessions 对齐)
# x_parser_ver:导入时的解析器版本,用于启动比对「数据是否过期需重导」
diff --git a/CostReview/app/store/schema.sql b/CostReview/app/store/schema.sql
index 6c5c194..de45ff4 100644
--- a/CostReview/app/store/schema.sql
+++ b/CostReview/app/store/schema.sql
@@ -79,7 +79,8 @@ CREATE INDEX IF NOT EXISTS ix_div_uw ON divides(uw_id);
-- 定额消耗工料机(对应 s_norm_res)
CREATE TABLE IF NOT EXISTS norm_res(
id INTEGER PRIMARY KEY,
- norm_id INTEGER, res_code TEXT, qty REAL
+ norm_id INTEGER, res_code TEXT, qty REAL,
+ express TEXT -- 含量算式(换算调整式,如 1611.66*1.2;决策 106 补记十二)
);
CREATE INDEX IF NOT EXISTS ix_nr_norm ON norm_res(norm_id);
CREATE INDEX IF NOT EXISTS ix_nr_code ON norm_res(res_code);
@@ -206,6 +207,7 @@ CREATE TABLE IF NOT EXISTS norms(
Quantity REAL, -- 2026-10-01 加(与 s_norms 对齐)
Price REAL,
Total REAL -- 2026-10-01 加
+, x_adjust TEXT -- 换算调整记录(JSON 数组,Value 串;补记十三)
);
CREATE INDEX IF NOT EXISTS ix_norm_bill ON norms(bill_id);
diff --git a/CostReview/app/store/session.sql b/CostReview/app/store/session.sql
index 514418c..fcf36ad 100644
--- a/CostReview/app/store/session.sql
+++ b/CostReview/app/store/session.sql
@@ -84,6 +84,8 @@ CREATE TABLE IF NOT EXISTS s_norms(
x_tdel INTEGER DEFAULT 0, -- 定额临删(批次B 采纳语义用)——决策 67 预埋
x_adopt INTEGER DEFAULT 0, -- 采纳标记(批次B)——决策 67 预埋
x_src_norm_id INTEGER -- 来源定额 id(取消采纳撤行用,批次B)——决策 67 预埋
+,
+ x_adjust TEXT -- 换算调整记录(JSON;采纳携带,补记十三)
);
CREATE INDEX IF NOT EXISTS ix_sn_bill ON s_norms(bill_id);
@@ -95,7 +97,8 @@ CREATE TABLE IF NOT EXISTS s_norm_res(
id INTEGER PRIMARY KEY,
norm_id INTEGER, -- 对应 s_norms.id
res_code TEXT, -- 工料机编码(对 s_lmes.Number)
- qty REAL -- 消耗量
+ qty REAL, -- 消耗量
+ express TEXT -- 含量算式(换算调整式,采纳携带;决策 106 补记十二)
);
CREATE INDEX IF NOT EXISTS ix_snr_norm ON s_norm_res(norm_id);
CREATE INDEX IF NOT EXISTS ix_snr_code ON s_norm_res(res_code);
diff --git a/CostReview/app/tests/test_export_structure.py b/CostReview/app/tests/test_export_structure.py
index 17b6396..4c9299d 100644
--- a/CostReview/app/tests/test_export_structure.py
+++ b/CostReview/app/tests/test_export_structure.py
@@ -85,11 +85,12 @@ def test_appended_norm_keeps_innards():
"""采纳定额追加进原有清单:innards 一并克隆(此前裸 Norm 同样过不了结构关)。"""
out = xcos._norm_xml(NEW_NORM, [("00010010", 594.0)], xcos._full_norm_block(RICH_BILL))
norm = _parse(out)
- assert [c.tag for c in norm] == ["ExpressElement", "ManageFees",
+ # 补记二十一:采纳定额不带数量算式行(Express 大于 Quantity,易达会按算式显示代号/方括号)
+ assert [c.tag for c in norm] == ["ManageFees",
"LabourMaterialsEquipmentsMachinesElement",
"UnitPriceCalculationOfItem", "UnitPriceCalculationOfItem"]
assert all(c.get("Total") == "0" for c in norm.findall("UnitPriceCalculationOfItem"))
- assert norm.find("ExpressElement").get("Express") == "" # 表达式文本清空(别人的公式带 QGCL 但量是别人的)
+ assert norm.findall("ExpressElement") == [] # 补记二十一:采纳定额不带数量算式行(易达才显示纯数字,不带方括号)
assert norm.get("Remark") == "" # 决策 101 口径不变
@@ -248,6 +249,177 @@ def test_new_bill_top_anchor_position(server):
assert txt.index('Name="顶部新增清单"') < txt.index('Number="B001"'), "新增清单应在第一条源清单之前"
+def test_amount_aggregate_row_price_never_synced():
+ """决策 106 补记九:广联达文件的「人工费」类汇总行是金额汇总行(数量=金额合计、
+ 单价恒 1、单位=元)。会话里合并改价把它的单价改成资源口径(如人工 500 元/工日)
+ 后,导出同步不得回写——原文件 数量×500 会让 Glodon 人工费爆炸外溢(样例工程实测)。"""
+ txt = (''
+ ''
+ ''
+ '')
+ sync = [("00010010", "人工费", "", "元", 500.0, 0.0, 500.0),
+ ("990101015", "履带式推土机", "", "台班", 1232.54, 0.0, 1232.54)]
+ out = xcos.transform_project(txt, [], [], sync_rows=sync)
+ agg = re.search(r']*', out).group(0)
+ assert 'NoTaxPrice="1"' in agg and 'TaxPrice="1"' in agg # 金额汇总行价格不动
+ mac = re.search(r']*', out).group(0)
+ assert 'NoTaxPrice="1232.54"' in mac # 正常资源行照常回写
+ assert xcos._is_amount_aggregate(
+ '')
+ assert not xcos._is_amount_aggregate(
+ '')
+
+
+def test_adoption_carries_express_adjustment(server):
+ """决策 106 补记十二:定额换算调整式(含量 Express,如人工费 *1.2)跟历史项目走——
+ 导入捕获入库 → 采纳携带 → 导出按算式原样填写(此前只存数值,调整信息丢失)。"""
+ import hashlib
+ import sqlite3
+ import uuid
+ proj = "调整式工程-" + uuid.uuid4().hex[:6]
+ bills = [("010101001001", "挖单独土方", "1、x", "m3", 10000, 126.17)]
+ p = H.make_cos4(str(server["src_dir"] / ("expr_%s_raw.cos4" % proj[-6:])), proj, bills)
+ # 给夹具的定额工料机行补上换算算式(模拟广联达原生 Express)
+ z = _zipfile.ZipFile(p) if False else zipfile.ZipFile(p)
+ buf = io.BytesIO()
+ with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zo:
+ for nm in z.namelist():
+ d = z.read(nm)
+ if nm.lower() != "project.xml":
+ d = d.replace(b'Quantity="1.5"/>', b'Quantity="1.5" Express="1.5*1.2"/>')
+ d = d.replace(b'', txt, _re.S)
+ print('ADOPTED NORM BLOCK:', mm.group(0)[:600] if mm else '(N-1 不在导出中)')
+ print('txt has N-1:', 'N-1' in txt, '| txt len:', len(txt))
+ assert 'Express="1.5*1.2"' in txt # 导出按历史调整式填写
+
+
+
+def test_resource_pseudo_norm_skipped_on_import(server):
+ """决策 106 补记十四:广联达把清单级资源构成行(人工费等,编码=纯数字工料机码、
+ 单位=元)也写成 元素——不是定额,导入即滤掉(此前被采纳当定额带进
+ 工作台=人工费外溢实测);真定额与调整记录不受影响。"""
+ import hashlib
+ import sqlite3
+ import uuid
+ proj = "伪定额过滤工程-" + uuid.uuid4().hex[:6]
+ bills = [("010101001001", "挖单独土方", "1、x", "m3", 10000, 126.17)]
+ p = H.make_cos4(str(server["src_dir"] / ("pseudo_%s_raw.cos4" % proj[-6:])), proj, bills)
+ z = zipfile.ZipFile(p)
+ buf = io.BytesIO()
+ with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zo:
+ for nm in z.namelist():
+ d = z.read(nm)
+ if nm.lower() != "project.xml":
+ pseudo = ('').encode("utf-8")
+ d = d.replace(b'', b'' + pseudo + b'')
+ zo.writestr(nm, d)
+ raw = buf.getvalue()
+ hp = os.path.join(str(server["root"]), "CostReview", "data", "source_files",
+ "%s_pseudo.cos4" % hashlib.sha256(raw).hexdigest())
+ with open(hp, "wb") as f:
+ f.write(raw)
+ imp = post(server, "/api/admin/import", dict(H.META, path=hp, name=proj))
+ assert imp["ok"] is True, imp
+ hc = sqlite3.connect(server["db"])
+ n = hc.execute("SELECT COUNT(*) FROM norms WHERE Number='00010010'").fetchone()[0]
+ hc.close()
+ assert n == 0, n # 伪定额不落批次库
+ audit = {"name": proj, "province": H.META["province"], "city": H.META["city"],
+ "district": H.META["district"], "period_from": H.PERIOD_202607,
+ "period_to": H.PERIOD_202607, "file_kind": 1}
+ sid = post(server, "/api/audit", dict(audit, path=hp))["session_id"]
+ sc = sqlite3.connect(server["sessdb"])
+ n2 = sc.execute("SELECT COUNT(*) FROM s_norms WHERE Number='00010010'").fetchone()[0]
+ n3 = sc.execute("SELECT COUNT(*) FROM s_norms").fetchone()[0]
+ sc.close()
+ assert n2 == 0 and n3 >= 1, (n2, n3) # 工作台也不出现(外溢源头掐断)
+
+
+def test_edited_totals_follow_qty_times_price(server):
+ """决策 106 补记十六(主人定):清单/定额 合价 = 工程量×单价——
+ 改工程量后(工作台保存时 + 导出兜底)合价跟着走;数值相同不产生字节改动。"""
+ import hashlib
+ import sqlite3
+ import uuid
+ proj = "合价口径工程-" + uuid.uuid4().hex[:6]
+ bills = [("B001", "挖单独土方", "1、x", "m3", 10, 500)]
+ p = H.make_cos4(str(server["src_dir"] / ("total_%s_raw.cos4" % proj[-6:])), proj, bills)
+ raw = open(p, "rb").read()
+ hp = os.path.join(str(server["root"]), "CostReview", "data", "source_files",
+ "%s_total.cos4" % hashlib.sha256(raw).hexdigest())
+ with open(hp, "wb") as f:
+ f.write(raw)
+ imp = post(server, "/api/admin/import", dict(H.META, path=hp, name=proj))
+ assert imp["ok"] is True, imp
+ audit = {"name": proj, "province": H.META["province"], "city": H.META["city"],
+ "district": H.META["district"], "period_from": H.PERIOD_202607,
+ "period_to": H.PERIOD_202607, "file_kind": 1}
+ sid = post(server, "/api/audit", dict(audit, path=hp))["session_id"]
+ rows = get(server, "/api/session/rows", session_id=sid, type="bill")["rows"]
+ bill_id = [r[0] for r in rows if r[1] == "B001"][0]
+ norm_id = sqlite3.connect(server["sessdb"]).execute(
+ "SELECT id FROM s_norms WHERE bill_id=?", (bill_id,)).fetchone()[0]
+ # 改清单工程量 10→20:合价 = 20×500
+ r = post(server, "/api/session/bill/op", {"session_id": sid, "op": "edit",
+ "bill_id": bill_id, "fields": {"Quantity": "20"}})
+ assert r["ok"] is True, r
+ tb = sqlite3.connect(server["sessdb"]).execute(
+ "SELECT Total FROM s_bills WHERE id=?", (bill_id,)).fetchone()[0]
+ assert abs(tb - 10000) < 0.01, tb # 工作台保存即同步
+ # 改定额工程量 10→15(数字):合价 = 15×80
+ r = post(server, "/api/session/norm/op", {"session_id": sid, "norm_id": norm_id,
+ "fields": {"Quantity": "15"}})
+ assert r["ok"] is True, r
+ tn = sqlite3.connect(server["sessdb"]).execute(
+ "SELECT Total FROM s_norms WHERE id=?", (norm_id,)).fetchone()[0]
+ assert abs(tn - 1200) < 0.01, tn # 15×80
+ zf = _export_zip(server, sid)
+ txt = "".join(zf.read(n).decode("utf-8", errors="replace") for n in zf.namelist()
+ if n.lower() != "project.xml")
+ assert 'Total="10000.0"' in txt, "清单合价应=20×500"
+ assert 'Total="1200.00"' in txt, "定额合价应=15×80"
+
+
def _export_zip(server, sid):
resp = server["client"].get("/api/session/export", params={"session_id": sid})
if not resp.headers["content-type"].startswith("application/zip"):
diff --git a/CostReview/app/ui/workbench.html b/CostReview/app/ui/workbench.html
index 4c7f8bc..4436f60 100644
--- a/CostReview/app/ui/workbench.html
+++ b/CostReview/app/ui/workbench.html
@@ -951,8 +951,17 @@ document.addEventListener('dblclick', function(e){
editCell(td, api, id, field, (cur0==='—'?'':cur0));
});
function editCell(td, api, id, field, cur){
- const inp = document.createElement('input');
+ // 项目特征是多行文本(fmtAttr 显示自带换行):input 会把换行整段剥掉,保存即黏团、
+ // 导出也无法按编号恢复(2026-10-18 主人实测「点了再导出排序就不行」)——Attr 用 textarea,
+ // 换行原样保存、导出原样回填;Enter=换行,Ctrl+Enter 或点开别处=保存。
+ const multi = (field === 'Attr');
+ const inp = document.createElement(multi ? 'textarea' : 'input');
inp.className = 'cellin'; inp.value = cur; inp.spellcheck = false;
+ if(multi){
+ inp.rows = Math.min(8, Math.max(3, cur.split('\n').length + 1));
+ inp.style.width = '100%'; inp.style.boxSizing = 'border-box';
+ inp.title = 'Enter 换行;Ctrl+Enter 或点其他位置保存';
+ }
td.textContent = ''; td.appendChild(inp);
inp.focus(); inp.select();
let done = false;
@@ -971,6 +980,7 @@ function editCell(td, api, id, field, cur){
await refreshRaw();
};
inp.addEventListener('keydown', ev=>{
+ if(multi && ev.key==='Enter' && !ev.ctrlKey){ return; } // 换行用,不保存
if(ev.key==='Enter'){ ev.preventDefault(); fin(true); }
else if(ev.key==='Escape'){ fin(false); }
});
@@ -1043,7 +1053,7 @@ function grpNormQtyEdit(td, tr, cur0){
if(!r.ok){ $('msg').textContent = r.msg || '保存失败'; td.textContent = cur0; return; }
// 决策 96:界面永远显示求值数字;公式原文收进 data-expr/悬停提示(双击再改还能取到)
td.textContent = r.quantity != null ? numG(r.quantity) : '—';
- if(r.expr){ td.dataset.expr = r.expr; td.title = '公式:' + r.expr + '(按清单工程量求值,双击可改公式)'; }
+ if(r.expr){ td.dataset.expr = r.expr; td.title = '公式:' + r.expr + '(按清单工程量求值,双击再改还能取到)'; }
else { delete td.dataset.expr; td.removeAttribute('title'); }
$('msg').textContent = '已保存' + (r.quantity != null ? ':= ' + numG(r.quantity) : '');
loadEditLog().then(()=>{ markGroupEH('tb1'); markGroupEH('tb2'); }); // ⑮ 红三角即时点亮
diff --git a/test/core_intent_coverage/README.md b/test/core_intent_coverage/README.md
new file mode 100644
index 0000000..97228d8
--- /dev/null
+++ b/test/core_intent_coverage/README.md
@@ -0,0 +1,38 @@
+# core_intent_coverage —— 核心设计意图覆盖核验工具包
+
+## 它是什么
+一个**只读、零污染**的静态核验工具:把你最怕"改坏"的那几条业务口径(设计意图)
+列成 `intents.json`,扫描 `CostReview/app` 源码与 `app/tests` 测试,报告这些意图
+**有没有被现有 p0/p1 测试真正断言到**。
+
+直接服务于「上市前第一步:功能验收 + 回归」——
+先确认既有测试是不是真把你的设计设想编码成了断言,而不是只在跑 happy-path 冒烟。
+
+## 安全边界(硬规矩)
+- **绝不 import 任何 app 模块** → 不会触发 app 副作用、不会写库。
+- **绝不向 `CostReview/` 写任何文件** → 输出只落在本包 `out/`。
+- 对工程目录只做 `open(..., 'r')`。
+
+## 怎么跑
+```bash
+cd D:/PricingReview/test/core_intent_coverage
+python run.py
+# 或自定义路径:
+python run.py --app D:/PricingReview/CostReview/app --tests D:/PricingReview/CostReview/app/tests
+```
+零依赖(仅 Python 标准库,3.9+)。
+
+## 输出
+- `out/report.md` —— 人读报告(每条意图:源码是否存在 / 是否被测试覆盖 / 强度 / 断言数 / 命中测试)。
+- `out/report.json` —— 机读,便于后续接入台账或 CI。
+
+## 已知局限(诚实声明)
+1. 这是**静态启发式**扫描(子串匹配 + 按 `test_` 函数分块统计 assert 数),
+ 不等于运行态验证。它告诉你"哪里可能有断言",但**不保证断言逻辑正确**。
+2. 标记词(markers)是关键词近似,可能误报/漏报;请结合 `report.md` 人工核对。
+3. "在结果上修改"指的是**完善本工具的 `intents.json` / 调标记词**(改的是工具自己的配置,
+ 不是你的软件代码)。若要在 `CostReview` 里**新增测试补缺口**,按你的规矩须由你/我显式确认后再动。
+
+## 与 `CostReview/app/tests` 的关系
+`app/tests` 是**真正的测试用例**(会跑、会动 DB,靠 `api_harness` 隔离副本)。
+本工具是**元层检查器**:只读它们,不重复它们,不改它们。
diff --git a/test/core_intent_coverage/__init__.py b/test/core_intent_coverage/__init__.py
new file mode 100644
index 0000000..1c41ebd
--- /dev/null
+++ b/test/core_intent_coverage/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+"""core_intent_coverage —— 核心设计意图覆盖核验工具包。
+
+只读、零污染:只扫描 CostReview 的源码与测试文本,绝不 import 工程模块,
+绝不向工程目录写文件。输出仅落在本包 out/ 目录。
+"""
diff --git a/test/core_intent_coverage/checker.py b/test/core_intent_coverage/checker.py
new file mode 100644
index 0000000..b2183cf
--- /dev/null
+++ b/test/core_intent_coverage/checker.py
@@ -0,0 +1,208 @@
+# -*- coding: utf-8 -*-
+"""核心设计意图覆盖核验(只读、零污染)。
+
+用途:
+ 主人最怕"改坏"的那几条业务口径(设计意图)有没有被现有 p0/p1 测试真正断言到。
+做法:
+ 纯文本静态扫描——只读取 CostReview 的源码与测试,绝不 import、绝不写回。
+输出:
+ out/report.md(人读)+ out/report.json(机读),落在工具包自己的 out/ 目录。
+
+安全边界(硬规矩,违反即删):
+ - 不 import 任何 app 模块(避免触发 app 副作用 / 写库)。
+ - 不向 CostReview/ 写任何文件(输出只落本工具包 out/)。
+ - 只 open(..., 'r'),对工程目录绝不 open(..., 'w')。
+"""
+import json
+import os
+import re
+import sys
+from pathlib import Path
+
+BASE = Path(__file__).resolve().parent
+DEFAULT_INTENTS = str(BASE / "intents.json")
+APP_DEFAULT = r"D:/PricingReview/CostReview/app"
+TESTS_DEFAULT = r"D:/PricingReview/CostReview/app/tests"
+OUT_DEFAULT = str(BASE / "out")
+
+
+def _iter_py(root):
+ root = Path(root)
+ if root.is_file() and root.suffix == ".py":
+ yield root
+ return
+ if not root.is_dir():
+ return
+ for p in root.rglob("*.py"):
+ if "__pycache__" in p.parts:
+ continue
+ yield p
+
+
+def scan_source(app_dir, markers):
+ """返回 {marker: [(rel, lineno, snippet)]} 与 matched_files 集合。"""
+ hits = {m: [] for m in markers}
+ matched_files = set()
+ app_dir = Path(app_dir)
+ for p in _iter_py(app_dir):
+ try:
+ text = p.read_text(encoding="utf-8", errors="replace")
+ except Exception:
+ continue
+ rel = str(p.relative_to(app_dir)) if p.is_relative_to(app_dir) else str(p)
+ for i, line in enumerate(text.splitlines(), 1):
+ for m in markers:
+ if m in line:
+ hits[m].append((rel, i, line.strip()[:120]))
+ matched_files.add(rel)
+ return hits, matched_files
+
+
+def scan_tests(tests_dir, markers):
+ """对每个 marker,返回命中的 (file, func, assert_count) 列表(按 test 函数分块)。"""
+ results = {m: [] for m in markers}
+ tests_dir = Path(tests_dir)
+ for p in _iter_py(tests_dir):
+ try:
+ text = p.read_text(encoding="utf-8", errors="replace")
+ except Exception:
+ continue
+ rel = str(p.relative_to(tests_dir)) if p.is_relative_to(tests_dir) else str(p)
+ lines = text.splitlines()
+ cur_func, cur_start = None, 0
+ for i, line in enumerate(lines, 1):
+ m = re.match(r"\s*def\s+(test_\w+)\s*\(", line)
+ if m:
+ if cur_func is not None:
+ _classify(results, markers, rel, cur_func, lines[cur_start:i])
+ cur_func, cur_start = m.group(1), i - 1
+ if cur_func is not None:
+ _classify(results, markers, rel, cur_func, lines[cur_start:])
+ return results
+
+
+def _classify(results, markers, rel, func, seg):
+ """按 test_ 函数分块,统计:(a) 函数内总 assert 数;
+ (b) 与意图标记词邻近(±WINDOW 行)的 assert 数 —— 这才是"该意图被真正断言"的口径。"""
+ seg_text = "\n".join(seg)
+ WINDOW = 3
+ marker_lines = set()
+ for idx, line in enumerate(seg):
+ for m in markers:
+ if m in line:
+ marker_lines.add(idx)
+ total_asserts = 0
+ intent_asserts = 0
+ for idx, line in enumerate(seg):
+ if re.search(r"\bassert\b", line):
+ total_asserts += 1
+ if any(abs(idx - ml) <= WINDOW for ml in marker_lines):
+ intent_asserts += 1
+ for m in markers:
+ if m in seg_text:
+ results[m].append({"file": rel, "func": func,
+ "asserts": total_asserts,
+ "intent_asserts": intent_asserts})
+
+
+def run(intents_path, app_dir, tests_dir, out_dir):
+ intents = json.loads(Path(intents_path).read_text(encoding="utf-8"))
+ rows = []
+ for it in intents:
+ src_markers = it.get("source_markers", [])
+ test_markers = it.get("test_markers") or src_markers
+ shits, sfiles = (scan_source(app_dir, src_markers)
+ if src_markers else ({}, set()))
+ thits = scan_tests(tests_dir, test_markers)
+ test_refs = []
+ for lst in thits.values():
+ test_refs.extend(lst)
+ seen, uniq = set(), []
+ for r in test_refs:
+ k = (r["file"], r["func"])
+ if k in seen:
+ continue
+ seen.add(k)
+ uniq.append(r)
+ source_present = bool(sfiles)
+ covered = len(uniq) > 0
+ real_asserts = sum(r["intent_asserts"] for r in uniq)
+ if covered and real_asserts > 0:
+ strength = "强(邻近有断言)"
+ elif covered:
+ strength = "弱(仅引用无邻近断言)"
+ else:
+ strength = "未覆盖"
+ rows.append({
+ "id": it.get("id"),
+ "name": it.get("name"),
+ "desc": it.get("desc", ""),
+ "source_present": source_present,
+ "source_files": sorted(sfiles),
+ "covered": covered,
+ "strength": strength,
+ "assert_count": real_asserts,
+ "test_refs": uniq,
+ })
+ out_dir = Path(out_dir)
+ out_dir.mkdir(parents=True, exist_ok=True)
+ md = _render_md(rows)
+ md_path = out_dir / "report.md"
+ jsn_path = out_dir / "report.json"
+ md_path.write_text(md, encoding="utf-8")
+ jsn_path.write_text(json.dumps(rows, ensure_ascii=False, indent=2),
+ encoding="utf-8")
+ return rows, md_path, jsn_path
+
+
+def _render_md(rows):
+ lines = ["# 核心设计意图覆盖核验报告", "",
+ f"> 生成方式:只读静态扫描,未 import / 未修改 CostReview 任何文件。", ""]
+ covered = sum(1 for r in rows if r["covered"])
+ lines.append(f"总意图数:**{len(rows)}** | 已覆盖:**{covered}** | 未覆盖:**{len(rows) - covered}**")
+ lines.append("")
+ for r in rows:
+ tag = "✅" if r["covered"] else "❌"
+ lines.append(f"## [{tag}] {r['id']} {r['name']}")
+ lines.append(f"- 描述:{r['desc']}")
+ lines.append(f"- 源码存在:{r['source_present']} | 测试覆盖:{r['covered']} | "
+ f"强度:**{r['strength']}** | 邻近断言数:{r['assert_count']}")
+ if r["source_files"]:
+ lines.append(f"- 源码命中文件:{', '.join(r['source_files'])}")
+ if r["test_refs"]:
+ lines.append("- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):")
+ for t in r["test_refs"]:
+ lines.append(f" - `{t['file']}::{t['func']}` (intent={t['intent_asserts']} / total={t['asserts']})")
+ lines.append("")
+ return "\n".join(lines)
+
+
+def main(argv=None):
+ argv = argv or sys.argv[1:]
+ intents_path, app_dir = DEFAULT_INTENTS, APP_DEFAULT
+ tests_dir, out_dir = TESTS_DEFAULT, OUT_DEFAULT
+ i = 0
+ while i < len(argv):
+ a = argv[i]
+ if a in ("-h", "--help"):
+ print(__doc__)
+ return 0
+ if a == "--intents":
+ intents_path = argv[i + 1]; i += 2; continue
+ if a == "--app":
+ app_dir = argv[i + 1]; i += 2; continue
+ if a == "--tests":
+ tests_dir = argv[i + 1]; i += 2; continue
+ if a == "--out":
+ out_dir = argv[i + 1]; i += 2; continue
+ i += 1
+ if not os.path.isabs(intents_path):
+ intents_path = str(BASE / intents_path)
+ rows, md_path, jsn_path = run(intents_path, app_dir, tests_dir, out_dir)
+ print(f"报告已生成:\n {md_path}\n {jsn_path}")
+ print(f"已覆盖 {sum(1 for r in rows if r['covered'])}/{len(rows)} 条设计意图")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/test/core_intent_coverage/intents.json b/test/core_intent_coverage/intents.json
new file mode 100644
index 0000000..4903aa5
--- /dev/null
+++ b/test/core_intent_coverage/intents.json
@@ -0,0 +1,58 @@
+[
+ {
+ "id": "INT-01",
+ "name": "价格导入:一个块=一个批次",
+ "desc": "HTML 一个顶层块=一批次;期次优先级 块名→文件名→弹框;批次名 多块用块名/单块用弹框名。",
+ "source_markers": ["x_imported_at", "批次", "块名", "一个块"],
+ "test_markers": ["批次", "块", "import"]
+ },
+ {
+ "id": "INT-02",
+ "name": "工料机/价格分表存储 + 判批次用 kind",
+ "desc": "x_rows_lme 只存工料机数,x_rows_price 只存价格数;判断批次有没有工料机一律用 kind='project',永远别用行数。",
+ "source_markers": ["x_rows_lme", "x_rows_price", "kind='project'", "kind=\"project\""],
+ "test_markers": ["x_rows_lme", "x_rows_price", "kind"]
+ },
+ {
+ "id": "INT-03",
+ "name": "会话↔后台批次同源绑定",
+ "desc": "靠 batches.x_src_hash == sessions.src_name(都是 sha256_原名)只认同源文件;工作台只读,绑定/改绑只在后台。",
+ "source_markers": ["x_src_hash", "src_name"],
+ "test_markers": ["x_src_hash", "src_name"]
+ },
+ {
+ "id": "INT-04",
+ "name": "列表排序口径",
+ "desc": "排序 x_period_end_m DESC, x_imported_at DESC, id DESC(期次最新最前)。",
+ "source_markers": ["x_period_end_m", "x_imported_at"],
+ "test_markers": ["x_period_end_m", "x_imported_at", "排序"]
+ },
+ {
+ "id": "INT-05",
+ "name": "序号递减口径",
+ "desc": "序号 seq = total - ((page-1)*size + i)(首行=总数递减)。",
+ "source_markers": ["seq", "page", "size"],
+ "test_markers": ["seq", "page", "size"]
+ },
+ {
+ "id": "INT-06",
+ "name": "询价附件项目专属",
+ "desc": "询价附件=项目专属,lmes 与 prices 零交叉,附件挂 lmes 天然只落项目;代码显式断言 kind='project'。",
+ "source_markers": ["kind='project'", "lmes", "询价附件"],
+ "test_markers": ["询价", "附件", "lmes"]
+ },
+ {
+ "id": "INT-07",
+ "name": "数据源字典口径",
+ "desc": "dict_region + dict_org(cat: publisher|builder);录入类下拉只取字典,过滤类下拉取 字典∪库里实际值。",
+ "source_markers": ["dict_region", "dict_org", "publisher", "builder"],
+ "test_markers": ["dict_region", "dict_org"]
+ },
+ {
+ "id": "INT-08",
+ "name": "信息价期次优先级",
+ "desc": "价格导入期次优先级 块名→文件名→弹框;一个块=一个批次。",
+ "source_markers": ["期次", "弹框", "块名"],
+ "test_markers": ["期次", "弹框"]
+ }
+]
diff --git a/test/core_intent_coverage/out/report.json b/test/core_intent_coverage/out/report.json
new file mode 100644
index 0000000..57d4762
--- /dev/null
+++ b/test/core_intent_coverage/out/report.json
@@ -0,0 +1,1070 @@
+[
+ {
+ "id": "INT-01",
+ "name": "价格导入:一个块=一个批次",
+ "desc": "HTML 一个顶层块=一批次;期次优先级 块名→文件名→弹框;批次名 多块用块名/单块用弹框名。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_cos.py",
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\price_html.py",
+ "core\\price_xlsx.py",
+ "core\\session_job.py",
+ "server\\api_server.py",
+ "server\\mcp_server.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_api_upgrade.py",
+ "tests\\test_export_structure.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_lme_uw_card.py",
+ "tests\\test_match_tiers.py",
+ "tests\\test_norm_op.py",
+ "tests\\test_price_redesign.py",
+ "tests\\test_unit_core.py",
+ "tools\\backfill_lme_lib.py",
+ "tools\\check_parity.py",
+ "tools\\gen_price_mock.py",
+ "tools\\gen_project_mock.py",
+ "tools\\purge_batches.py",
+ "tools\\rebuild_batch_db.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 104,
+ "test_refs": [
+ {
+ "file": "test_api_p1.py",
+ "func": "test_inq_lifecycle",
+ "asserts": 12,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_adopt_flow",
+ "asserts": 8,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_clear_mock_keeps_real",
+ "asserts": 3,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_rejects_empty_class",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_single_and_dup",
+ "asserts": 8,
+ "intent_asserts": 8
+ },
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_via_admin_api",
+ "asserts": 4,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_via_audit_open",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_price_batch_rejected",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_resource_pseudo_norm_skipped_on_import",
+ "asserts": 3,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_coef_unit_prefix_no_double_count",
+ "asserts": 4,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_strict_first_loose_last",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_rank_combined_with_filters",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_match_tiers.py",
+ "func": "test_disabled_batch_excluded",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_match_tiers.py",
+ "func": "test_period_distance_sort_and_window",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_norm_op.py",
+ "func": "test_norm_ntdel_export_omits",
+ "asserts": 8,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_dirs_tree_and_counts",
+ "asserts": 9,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_prices_filter_and_export",
+ "asserts": 11,
+ "intent_asserts": 8
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_price_html_parse_and_records",
+ "asserts": 8,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_price_xlsx_parse_and_template",
+ "asserts": 10,
+ "intent_asserts": 5
+ },
+ {
+ "file": "test_api_group.py",
+ "func": "test_group_conservation_and_name_layer",
+ "asserts": 9,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_new_bill_full_structure_cos",
+ "asserts": 12,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_clean_attr_strips_and_guard",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_guess_period",
+ "asserts": 4,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_price_html_rejects_non_data",
+ "asserts": 2,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_gate_off_and_status",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_project_ok",
+ "asserts": 10,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_encrypted_rejected",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_unknown_rejected",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_xml_rejected",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_outside_path_rejected",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_dup_confirm_then_force",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_search_bill_self_excluded",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_search_lme",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_hist_search_kw",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_delete_batch_cascade",
+ "asserts": 6,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_batch_row_edit_whitelist",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_attach_lifecycle",
+ "asserts": 10,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_enabled_toggle",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_xlsx_import",
+ "asserts": 12,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_dict_roundtrip",
+ "asserts": 7,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_export_ext.py",
+ "func": "test_ext_follows_source",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_new_bill_top_anchor_position",
+ "asserts": 4,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_adoption_carries_express_adjustment",
+ "asserts": 6,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_repo_pinned_keys_prod_key_self_consistent",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_validate_matrix",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_error_never_echoes_content",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_loopback_http_dev_only",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_happy_path",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_conflict_needs_explicit_confirm",
+ "asserts": 5,
+ "intent_asserts": 5
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_same_instance_no_confirm_needed",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_import_high_water_preserved",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_license_verify.py",
+ "func": "test_revoked_key",
+ "asserts": 0,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_license_verify.py",
+ "func": "test_non_p256_key_rejected_at_ring_build",
+ "asserts": 0,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_export_recode_renames_mother_and_rebuilds_children",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_export_recode_childless_renames_only",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_op.py",
+ "func": "test_adopt_gcl_default_and_price_overwrite",
+ "asserts": 7,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_op.py",
+ "func": "test_qty_export_follows_source_pattern",
+ "asserts": 6,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_large_project_import_and_open",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_read_not_starved_under_write",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_dir_add_rename_move_seq",
+ "asserts": 11,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_dir_del_rows_fall_uncat",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_row_crud_and_hash",
+ "asserts": 11,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_sniff",
+ "asserts": 1,
+ "intent_asserts": 0
+ }
+ ]
+ },
+ {
+ "id": "INT-02",
+ "name": "工料机/价格分表存储 + 判批次用 kind",
+ "desc": "x_rows_lme 只存工料机数,x_rows_price 只存价格数;判断批次有没有工料机一律用 kind='project',永远别用行数。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "server\\api_server.py",
+ "tests\\test_api_p0.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_price_redesign.py",
+ "tools\\backfill_lme_lib.py",
+ "tools\\gen_price_mock.py",
+ "tools\\gen_project_mock.py",
+ "tools\\test_parse_std.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 50,
+ "test_refs": [
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_project_ok",
+ "asserts": 10,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_xlsx_import",
+ "asserts": 12,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_single_and_dup",
+ "asserts": 8,
+ "intent_asserts": 8
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_row_crud_and_hash",
+ "asserts": 11,
+ "intent_asserts": 5
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_import_dup_confirm_then_force",
+ "asserts": 3,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_inq_lifecycle",
+ "asserts": 12,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_clear_mock_keeps_real",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_rejects_empty_class",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_via_audit_open",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_price_batch_rejected",
+ "asserts": 2,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_new_bill_top_anchor_position",
+ "asserts": 4,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_adoption_carries_express_adjustment",
+ "asserts": 6,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_resource_pseudo_norm_skipped_on_import",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_export_structure.py",
+ "func": "test_coef_unit_prefix_no_double_count",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_rank_combined_with_filters",
+ "asserts": 2,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_license_import.py",
+ "func": "test_repo_pinned_keys_prod_key_self_consistent",
+ "asserts": 4,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_license_verify.py",
+ "func": "test_package_vectors_canonical_matches",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_merge_child_group_repoints_unit_mothers_and_replaces_children",
+ "asserts": 9,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_http_lme_price_end_to_end",
+ "asserts": 10,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_norm_op.py",
+ "func": "test_norm_unadopt_hard_delete",
+ "asserts": 6,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_collision_row_takes_summary_whole",
+ "asserts": 2,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_large_project_import_and_open",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_read_not_starved_under_write",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_prices_filter_and_export",
+ "asserts": 11,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_sim_weighted_token_veto",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_lme_list_where_kind_cast",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_parse_std_structure",
+ "asserts": 14,
+ "intent_asserts": 9
+ }
+ ]
+ },
+ {
+ "id": "INT-03",
+ "name": "会话↔后台批次同源绑定",
+ "desc": "靠 batches.x_src_hash == sessions.src_name(都是 sha256_原名)只认同源文件;工作台只读,绑定/改绑只在后台。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_cos.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\session_job.py",
+ "server\\api_server.py",
+ "tests\\test_api_upgrade.py",
+ "tests\\test_export_ext.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_lme_proj_source.py",
+ "tests\\test_lme_uw_card.py",
+ "tests\\test_match_tiers.py",
+ "tests\\test_norm_res_name.py",
+ "tests\\test_source_guards.py",
+ "tests\\test_stopwords.py",
+ "tools\\backfill_lme_lib.py",
+ "tools\\gen_price_mock.py",
+ "tools\\gen_project_mock.py",
+ "tools\\purge_batches.py",
+ "tools\\test_parse_std.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 4,
+ "test_refs": [
+ {
+ "file": "test_api_upgrade.py",
+ "func": "test_upgrade_via_audit_open",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_export_ext.py",
+ "func": "test_ext_follows_source",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_source_guards.py",
+ "func": "test_reopen_with_new_file_syncs_src_and_remarks",
+ "asserts": 9,
+ "intent_asserts": 3
+ }
+ ]
+ },
+ {
+ "id": "INT-04",
+ "name": "列表排序口径",
+ "desc": "排序 x_period_end_m DESC, x_imported_at DESC, id DESC(期次最新最前)。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\search_demo.py",
+ "server\\api_server.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_match_tiers.py",
+ "tests\\test_stopwords.py",
+ "tools\\gen_price_mock.py",
+ "tools\\gen_project_mock.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 15,
+ "test_refs": [
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_xlsx_import",
+ "asserts": 12,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_single_and_dup",
+ "asserts": 8,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_api_group.py",
+ "func": "test_group_conservation_and_name_layer",
+ "asserts": 9,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_group_order.py",
+ "func": "test_kw_group_mixed_by_tsum",
+ "asserts": 4,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_loose_flag_matches_rank",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_merge_groups_keep_composite_rows",
+ "asserts": 5,
+ "intent_asserts": 3
+ }
+ ]
+ },
+ {
+ "id": "INT-05",
+ "name": "序号递减口径",
+ "desc": "序号 seq = total - ((page-1)*size + i)(首行=总数递减)。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_cos.py",
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\price_xlsx.py",
+ "core\\session_job.py",
+ "server\\api_server.py",
+ "server\\license_client\\gate.py",
+ "shell.py",
+ "tests\\test_api_group.py",
+ "tests\\test_group_order.py",
+ "tests\\test_grp_units.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_lme_price.py",
+ "tests\\test_lme_proj_source.py",
+ "tests\\test_match_tiers.py",
+ "tests\\test_norm_res_name.py",
+ "tests\\test_perf_baseline.py",
+ "tests\\test_price_redesign.py",
+ "tests\\test_stopwords.py",
+ "tools\\check_parity.py",
+ "tools\\gen_price_mock.py",
+ "tools\\health_check.py",
+ "tools\\purge_batches.py",
+ "tools\\rebuild_batch_db.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 16,
+ "test_refs": [
+ {
+ "file": "test_api_group.py",
+ "func": "test_group_keyword_layer",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_group_order.py",
+ "func": "test_kw_group_mixed_by_tsum",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_merge_child_group_repoints_unit_mothers_and_replaces_children",
+ "asserts": 9,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_merge_groups_keep_composite_rows",
+ "asserts": 5,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_dirs_tree_and_counts",
+ "asserts": 9,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_dir_add_rename_move_seq",
+ "asserts": 11,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_pagination_rank_stable",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_large_project_import_and_open",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_read_not_starved_under_write",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_prices_filter_and_export",
+ "asserts": 11,
+ "intent_asserts": 4
+ },
+ {
+ "file": "test_stopwords.py",
+ "func": "test_stop_before_limit_pagination",
+ "asserts": 2,
+ "intent_asserts": 2
+ }
+ ]
+ },
+ {
+ "id": "INT-06",
+ "name": "询价附件项目专属",
+ "desc": "询价附件=项目专属,lmes 与 prices 零交叉,附件挂 lmes 天然只落项目;代码显式断言 kind='project'。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\search_demo.py",
+ "core\\session_job.py",
+ "server\\api_server.py",
+ "tests\\api_harness.py",
+ "tests\\test_api_p0.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_lme_price.py",
+ "tests\\test_lme_proj_source.py",
+ "tests\\test_lme_uw_card.py",
+ "tests\\test_norm_res_name.py",
+ "tests\\test_perf_baseline.py",
+ "tests\\test_unit_core.py",
+ "tools\\backfill_lme_lib.py",
+ "tools\\check_parity.py",
+ "tools\\gen_price_mock.py",
+ "tools\\gen_project_mock.py",
+ "tools\\purge_batches.py",
+ "tools\\rebuild_batch_db.py",
+ "tools\\test_parse_std.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 34,
+ "test_refs": [
+ {
+ "file": "test_api_p1.py",
+ "func": "test_attach_lifecycle",
+ "asserts": 10,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_inq_lifecycle",
+ "asserts": 12,
+ "intent_asserts": 11
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_adopt_flow",
+ "asserts": 8,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_price_redesign.py",
+ "func": "test_prices_filter_and_export",
+ "asserts": 11,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_audit_open_reuse_and_remark",
+ "asserts": 9,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_api_p0.py",
+ "func": "test_delete_batch_cascade",
+ "asserts": 6,
+ "intent_asserts": 5
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_raw_uw_rows_are_nine_wide_with_taxrate_at_7",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_raw_proj_fallback_nine_wide_taxrate_at_7",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_raw_proj_fallback_without_taxrate_column",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_raw_uw_agg_fallback_nine_wide_taxrate_at_7",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_lme_proj_source.py",
+ "func": "test_migrate_rekeys_events_and_gate",
+ "asserts": 4,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_name_prefers_unit_summary",
+ "asserts": 2,
+ "intent_asserts": 2
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_legacy_chain_intact",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_prices_filled_from_summary_when_missing",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_collision_row_takes_summary_whole",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_perf_baseline.py",
+ "func": "test_large_project_import_and_open",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_parse_std_structure",
+ "asserts": 14,
+ "intent_asserts": 7
+ }
+ ]
+ },
+ {
+ "id": "INT-07",
+ "name": "数据源字典口径",
+ "desc": "dict_region + dict_org(cat: publisher|builder);录入类下拉只取字典,过滤类下拉取 字典∪库里实际值。",
+ "source_present": true,
+ "source_files": [
+ "core\\match.py",
+ "server\\api_server.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_api_upgrade.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_price_redesign.py",
+ "tests\\test_stopwords.py",
+ "tools\\gen_price_mock.py"
+ ],
+ "covered": false,
+ "strength": "未覆盖",
+ "assert_count": 0,
+ "test_refs": []
+ },
+ {
+ "id": "INT-08",
+ "name": "信息价期次优先级",
+ "desc": "价格导入期次优先级 块名→文件名→弹框;一个块=一个批次。",
+ "source_present": true,
+ "source_files": [
+ "core\\export_xlsx.py",
+ "core\\import_job.py",
+ "core\\match.py",
+ "core\\price_html.py",
+ "core\\price_xlsx.py",
+ "core\\search_demo.py",
+ "core\\session_job.py",
+ "server\\api_server.py",
+ "tests\\api_harness.py",
+ "tests\\test_api_p0.py",
+ "tests\\test_api_p1.py",
+ "tests\\test_kw_tier.py",
+ "tests\\test_lme_price.py",
+ "tests\\test_match_tiers.py",
+ "tests\\test_norm_res_name.py",
+ "tests\\test_unit_core.py",
+ "tools\\check_parity.py"
+ ],
+ "covered": true,
+ "strength": "强(邻近有断言)",
+ "assert_count": 15,
+ "test_refs": [
+ {
+ "file": "test_api_p0.py",
+ "func": "test_batch_row_edit_whitelist",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_xlsx_import",
+ "asserts": 12,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_api_p1.py",
+ "func": "test_price_import_single_and_dup",
+ "asserts": 8,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_strict_first_loose_last",
+ "asserts": 1,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_kw_tier.py",
+ "func": "test_pagination_rank_stable",
+ "asserts": 2,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_match_tiers.py",
+ "func": "test_period_distance_sort_and_window",
+ "asserts": 3,
+ "intent_asserts": 3
+ },
+ {
+ "file": "test_unit_core.py",
+ "func": "test_sniff",
+ "asserts": 1,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_sub_composition_rows_are_editable",
+ "asserts": 2,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_merge_still_registers_codes_after_refactor",
+ "asserts": 3,
+ "intent_asserts": 1
+ },
+ {
+ "file": "test_lme_price.py",
+ "func": "test_merge_group_includes_child_rows_with_flag",
+ "asserts": 3,
+ "intent_asserts": 0
+ },
+ {
+ "file": "test_norm_res_name.py",
+ "func": "test_merge_groups_keep_composite_rows",
+ "asserts": 5,
+ "intent_asserts": 0
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/test/core_intent_coverage/out/report.md b/test/core_intent_coverage/out/report.md
new file mode 100644
index 0000000..78655ba
--- /dev/null
+++ b/test/core_intent_coverage/out/report.md
@@ -0,0 +1,190 @@
+# 核心设计意图覆盖核验报告
+
+> 生成方式:只读静态扫描,未 import / 未修改 CostReview 任何文件。
+
+总意图数:**8** | 已覆盖:**7** | 未覆盖:**1**
+
+## [✅] INT-01 价格导入:一个块=一个批次
+- 描述:HTML 一个顶层块=一批次;期次优先级 块名→文件名→弹框;批次名 多块用块名/单块用弹框名。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:104
+- 源码命中文件:core\export_cos.py, core\export_xlsx.py, core\import_job.py, core\match.py, core\price_html.py, core\price_xlsx.py, core\session_job.py, server\api_server.py, server\mcp_server.py, tests\test_api_p1.py, tests\test_api_upgrade.py, tests\test_export_structure.py, tests\test_kw_tier.py, tests\test_lme_uw_card.py, tests\test_match_tiers.py, tests\test_norm_op.py, tests\test_price_redesign.py, tests\test_unit_core.py, tools\backfill_lme_lib.py, tools\check_parity.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\rebuild_batch_db.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_p1.py::test_inq_lifecycle` (intent=3 / total=12)
+ - `test_api_p1.py::test_adopt_flow` (intent=1 / total=8)
+ - `test_api_p1.py::test_clear_mock_keeps_real` (intent=2 / total=3)
+ - `test_api_p1.py::test_price_import_rejects_empty_class` (intent=1 / total=1)
+ - `test_api_p1.py::test_price_import_single_and_dup` (intent=8 / total=8)
+ - `test_api_upgrade.py::test_upgrade_via_admin_api` (intent=2 / total=4)
+ - `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=1 / total=3)
+ - `test_api_upgrade.py::test_upgrade_price_batch_rejected` (intent=2 / total=2)
+ - `test_export_structure.py::test_resource_pseudo_norm_skipped_on_import` (intent=2 / total=3)
+ - `test_export_structure.py::test_coef_unit_prefix_no_double_count` (intent=1 / total=4)
+ - `test_kw_tier.py::test_strict_first_loose_last` (intent=0 / total=1)
+ - `test_kw_tier.py::test_rank_combined_with_filters` (intent=2 / total=2)
+ - `test_match_tiers.py::test_disabled_batch_excluded` (intent=1 / total=1)
+ - `test_match_tiers.py::test_period_distance_sort_and_window` (intent=3 / total=3)
+ - `test_norm_op.py::test_norm_ntdel_export_omits` (intent=4 / total=8)
+ - `test_price_redesign.py::test_dirs_tree_and_counts` (intent=2 / total=9)
+ - `test_price_redesign.py::test_prices_filter_and_export` (intent=8 / total=11)
+ - `test_unit_core.py::test_price_html_parse_and_records` (intent=4 / total=8)
+ - `test_unit_core.py::test_price_xlsx_parse_and_template` (intent=5 / total=10)
+ - `test_api_group.py::test_group_conservation_and_name_layer` (intent=4 / total=9)
+ - `test_export_structure.py::test_new_bill_full_structure_cos` (intent=0 / total=12)
+ - `test_unit_core.py::test_clean_attr_strips_and_guard` (intent=3 / total=3)
+ - `test_unit_core.py::test_guess_period` (intent=4 / total=4)
+ - `test_unit_core.py::test_price_html_rejects_non_data` (intent=1 / total=2)
+ - `test_api_p0.py::test_gate_off_and_status` (intent=0 / total=2)
+ - `test_api_p0.py::test_import_project_ok` (intent=3 / total=10)
+ - `test_api_p0.py::test_import_encrypted_rejected` (intent=1 / total=1)
+ - `test_api_p0.py::test_import_unknown_rejected` (intent=1 / total=1)
+ - `test_api_p0.py::test_import_xml_rejected` (intent=1 / total=1)
+ - `test_api_p0.py::test_import_outside_path_rejected` (intent=1 / total=1)
+ - `test_api_p0.py::test_import_dup_confirm_then_force` (intent=3 / total=3)
+ - `test_api_p0.py::test_search_bill_self_excluded` (intent=0 / total=4)
+ - `test_api_p0.py::test_search_lme` (intent=0 / total=2)
+ - `test_api_p0.py::test_hist_search_kw` (intent=0 / total=4)
+ - `test_api_p0.py::test_delete_batch_cascade` (intent=1 / total=6)
+ - `test_api_p0.py::test_batch_row_edit_whitelist` (intent=0 / total=3)
+ - `test_api_p1.py::test_attach_lifecycle` (intent=1 / total=10)
+ - `test_api_p1.py::test_enabled_toggle` (intent=1 / total=3)
+ - `test_api_p1.py::test_price_xlsx_import` (intent=2 / total=12)
+ - `test_api_p1.py::test_dict_roundtrip` (intent=0 / total=7)
+ - `test_export_ext.py::test_ext_follows_source` (intent=1 / total=1)
+ - `test_export_structure.py::test_new_bill_top_anchor_position` (intent=1 / total=4)
+ - `test_export_structure.py::test_adoption_carries_express_adjustment` (intent=1 / total=6)
+ - `test_license_import.py::test_repo_pinned_keys_prod_key_self_consistent` (intent=0 / total=4)
+ - `test_license_import.py::test_import_validate_matrix` (intent=2 / total=2)
+ - `test_license_import.py::test_import_error_never_echoes_content` (intent=3 / total=3)
+ - `test_license_import.py::test_import_loopback_http_dev_only` (intent=2 / total=2)
+ - `test_license_import.py::test_import_happy_path` (intent=3 / total=3)
+ - `test_license_import.py::test_import_conflict_needs_explicit_confirm` (intent=5 / total=5)
+ - `test_license_import.py::test_import_same_instance_no_confirm_needed` (intent=1 / total=1)
+ - `test_license_import.py::test_import_high_water_preserved` (intent=2 / total=2)
+ - `test_license_verify.py::test_revoked_key` (intent=0 / total=0)
+ - `test_license_verify.py::test_non_p256_key_rejected_at_ring_build` (intent=0 / total=0)
+ - `test_lme_price.py::test_export_recode_renames_mother_and_rebuilds_children` (intent=0 / total=3)
+ - `test_lme_price.py::test_export_recode_childless_renames_only` (intent=0 / total=2)
+ - `test_norm_op.py::test_adopt_gcl_default_and_price_overwrite` (intent=0 / total=7)
+ - `test_norm_op.py::test_qty_export_follows_source_pattern` (intent=2 / total=6)
+ - `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
+ - `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
+ - `test_price_redesign.py::test_dir_add_rename_move_seq` (intent=0 / total=11)
+ - `test_price_redesign.py::test_dir_del_rows_fall_uncat` (intent=0 / total=4)
+ - `test_price_redesign.py::test_row_crud_and_hash` (intent=1 / total=11)
+ - `test_unit_core.py::test_sniff` (intent=0 / total=1)
+
+## [✅] INT-02 工料机/价格分表存储 + 判批次用 kind
+- 描述:x_rows_lme 只存工料机数,x_rows_price 只存价格数;判断批次有没有工料机一律用 kind='project',永远别用行数。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:50
+- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, server\api_server.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_price_redesign.py, tools\backfill_lme_lib.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\test_parse_std.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_p0.py::test_import_project_ok` (intent=4 / total=10)
+ - `test_api_p1.py::test_price_xlsx_import` (intent=4 / total=12)
+ - `test_api_p1.py::test_price_import_single_and_dup` (intent=8 / total=8)
+ - `test_price_redesign.py::test_row_crud_and_hash` (intent=5 / total=11)
+ - `test_api_p0.py::test_import_dup_confirm_then_force` (intent=2 / total=3)
+ - `test_api_p1.py::test_inq_lifecycle` (intent=1 / total=12)
+ - `test_api_p1.py::test_clear_mock_keeps_real` (intent=0 / total=3)
+ - `test_api_p1.py::test_price_import_rejects_empty_class` (intent=1 / total=1)
+ - `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=3 / total=3)
+ - `test_api_upgrade.py::test_upgrade_price_batch_rejected` (intent=1 / total=2)
+ - `test_export_structure.py::test_new_bill_top_anchor_position` (intent=1 / total=4)
+ - `test_export_structure.py::test_adoption_carries_express_adjustment` (intent=2 / total=6)
+ - `test_export_structure.py::test_resource_pseudo_norm_skipped_on_import` (intent=1 / total=3)
+ - `test_export_structure.py::test_coef_unit_prefix_no_double_count` (intent=0 / total=4)
+ - `test_kw_tier.py::test_rank_combined_with_filters` (intent=1 / total=2)
+ - `test_license_import.py::test_repo_pinned_keys_prod_key_self_consistent` (intent=1 / total=4)
+ - `test_license_verify.py::test_package_vectors_canonical_matches` (intent=2 / total=2)
+ - `test_lme_price.py::test_merge_child_group_repoints_unit_mothers_and_replaces_children` (intent=0 / total=9)
+ - `test_lme_price.py::test_http_lme_price_end_to_end` (intent=1 / total=10)
+ - `test_norm_op.py::test_norm_unadopt_hard_delete` (intent=0 / total=6)
+ - `test_norm_res_name.py::test_collision_row_takes_summary_whole` (intent=1 / total=2)
+ - `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
+ - `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
+ - `test_price_redesign.py::test_prices_filter_and_export` (intent=1 / total=11)
+ - `test_unit_core.py::test_sim_weighted_token_veto` (intent=0 / total=2)
+ - `test_unit_core.py::test_lme_list_where_kind_cast` (intent=0 / total=1)
+ - `test_unit_core.py::test_parse_std_structure` (intent=9 / total=14)
+
+## [✅] INT-03 会话↔后台批次同源绑定
+- 描述:靠 batches.x_src_hash == sessions.src_name(都是 sha256_原名)只认同源文件;工作台只读,绑定/改绑只在后台。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:4
+- 源码命中文件:core\export_cos.py, core\import_job.py, core\match.py, core\session_job.py, server\api_server.py, tests\test_api_upgrade.py, tests\test_export_ext.py, tests\test_kw_tier.py, tests\test_lme_proj_source.py, tests\test_lme_uw_card.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_source_guards.py, tests\test_stopwords.py, tools\backfill_lme_lib.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\test_parse_std.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=0 / total=3)
+ - `test_export_ext.py::test_ext_follows_source` (intent=1 / total=1)
+ - `test_source_guards.py::test_reopen_with_new_file_syncs_src_and_remarks` (intent=3 / total=9)
+
+## [✅] INT-04 列表排序口径
+- 描述:排序 x_period_end_m DESC, x_imported_at DESC, id DESC(期次最新最前)。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:15
+- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\search_demo.py, server\api_server.py, tests\test_api_p1.py, tests\test_kw_tier.py, tests\test_match_tiers.py, tests\test_stopwords.py, tools\gen_price_mock.py, tools\gen_project_mock.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_p1.py::test_price_xlsx_import` (intent=3 / total=12)
+ - `test_api_p1.py::test_price_import_single_and_dup` (intent=4 / total=8)
+ - `test_api_group.py::test_group_conservation_and_name_layer` (intent=4 / total=9)
+ - `test_group_order.py::test_kw_group_mixed_by_tsum` (intent=1 / total=4)
+ - `test_kw_tier.py::test_loose_flag_matches_rank` (intent=0 / total=1)
+ - `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=3 / total=5)
+
+## [✅] INT-05 序号递减口径
+- 描述:序号 seq = total - ((page-1)*size + i)(首行=总数递减)。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:16
+- 源码命中文件:core\export_cos.py, core\export_xlsx.py, core\import_job.py, core\match.py, core\price_xlsx.py, core\session_job.py, server\api_server.py, server\license_client\gate.py, shell.py, tests\test_api_group.py, tests\test_group_order.py, tests\test_grp_units.py, tests\test_kw_tier.py, tests\test_lme_price.py, tests\test_lme_proj_source.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_perf_baseline.py, tests\test_price_redesign.py, tests\test_stopwords.py, tools\check_parity.py, tools\gen_price_mock.py, tools\health_check.py, tools\purge_batches.py, tools\rebuild_batch_db.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_group.py::test_group_keyword_layer` (intent=0 / total=3)
+ - `test_group_order.py::test_kw_group_mixed_by_tsum` (intent=0 / total=4)
+ - `test_lme_price.py::test_merge_child_group_repoints_unit_mothers_and_replaces_children` (intent=3 / total=9)
+ - `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=1 / total=5)
+ - `test_price_redesign.py::test_dirs_tree_and_counts` (intent=1 / total=9)
+ - `test_price_redesign.py::test_dir_add_rename_move_seq` (intent=2 / total=11)
+ - `test_kw_tier.py::test_pagination_rank_stable` (intent=2 / total=2)
+ - `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
+ - `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
+ - `test_price_redesign.py::test_prices_filter_and_export` (intent=4 / total=11)
+ - `test_stopwords.py::test_stop_before_limit_pagination` (intent=2 / total=2)
+
+## [✅] INT-06 询价附件项目专属
+- 描述:询价附件=项目专属,lmes 与 prices 零交叉,附件挂 lmes 天然只落项目;代码显式断言 kind='project'。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:34
+- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\search_demo.py, core\session_job.py, server\api_server.py, tests\api_harness.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_lme_price.py, tests\test_lme_proj_source.py, tests\test_lme_uw_card.py, tests\test_norm_res_name.py, tests\test_perf_baseline.py, tests\test_unit_core.py, tools\backfill_lme_lib.py, tools\check_parity.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\rebuild_batch_db.py, tools\test_parse_std.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_p1.py::test_attach_lifecycle` (intent=0 / total=10)
+ - `test_api_p1.py::test_inq_lifecycle` (intent=11 / total=12)
+ - `test_api_p1.py::test_adopt_flow` (intent=3 / total=8)
+ - `test_price_redesign.py::test_prices_filter_and_export` (intent=3 / total=11)
+ - `test_api_p0.py::test_audit_open_reuse_and_remark` (intent=2 / total=9)
+ - `test_api_p0.py::test_delete_batch_cascade` (intent=5 / total=6)
+ - `test_lme_price.py::test_raw_uw_rows_are_nine_wide_with_taxrate_at_7` (intent=0 / total=4)
+ - `test_lme_price.py::test_raw_proj_fallback_nine_wide_taxrate_at_7` (intent=0 / total=4)
+ - `test_lme_price.py::test_raw_proj_fallback_without_taxrate_column` (intent=0 / total=1)
+ - `test_lme_price.py::test_raw_uw_agg_fallback_nine_wide_taxrate_at_7` (intent=0 / total=4)
+ - `test_lme_proj_source.py::test_migrate_rekeys_events_and_gate` (intent=0 / total=4)
+ - `test_norm_res_name.py::test_name_prefers_unit_summary` (intent=2 / total=2)
+ - `test_norm_res_name.py::test_legacy_chain_intact` (intent=1 / total=1)
+ - `test_norm_res_name.py::test_prices_filled_from_summary_when_missing` (intent=0 / total=1)
+ - `test_norm_res_name.py::test_collision_row_takes_summary_whole` (intent=0 / total=2)
+ - `test_perf_baseline.py::test_large_project_import_and_open` (intent=0 / total=3)
+ - `test_unit_core.py::test_parse_std_structure` (intent=7 / total=14)
+
+## [❌] INT-07 数据源字典口径
+- 描述:dict_region + dict_org(cat: publisher|builder);录入类下拉只取字典,过滤类下拉取 字典∪库里实际值。
+- 源码存在:True | 测试覆盖:False | 强度:**未覆盖** | 邻近断言数:0
+- 源码命中文件:core\match.py, server\api_server.py, tests\test_api_p1.py, tests\test_api_upgrade.py, tests\test_kw_tier.py, tests\test_price_redesign.py, tests\test_stopwords.py, tools\gen_price_mock.py
+
+## [✅] INT-08 信息价期次优先级
+- 描述:价格导入期次优先级 块名→文件名→弹框;一个块=一个批次。
+- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:15
+- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\price_html.py, core\price_xlsx.py, core\search_demo.py, core\session_job.py, server\api_server.py, tests\api_harness.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_kw_tier.py, tests\test_lme_price.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_unit_core.py, tools\check_parity.py
+- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
+ - `test_api_p0.py::test_batch_row_edit_whitelist` (intent=3 / total=3)
+ - `test_api_p1.py::test_price_xlsx_import` (intent=3 / total=12)
+ - `test_api_p1.py::test_price_import_single_and_dup` (intent=3 / total=8)
+ - `test_kw_tier.py::test_strict_first_loose_last` (intent=0 / total=1)
+ - `test_kw_tier.py::test_pagination_rank_stable` (intent=0 / total=2)
+ - `test_match_tiers.py::test_period_distance_sort_and_window` (intent=3 / total=3)
+ - `test_unit_core.py::test_sniff` (intent=1 / total=1)
+ - `test_lme_price.py::test_sub_composition_rows_are_editable` (intent=1 / total=2)
+ - `test_lme_price.py::test_merge_still_registers_codes_after_refactor` (intent=1 / total=3)
+ - `test_lme_price.py::test_merge_group_includes_child_rows_with_flag` (intent=0 / total=3)
+ - `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=0 / total=5)
diff --git a/test/core_intent_coverage/pyproject.toml b/test/core_intent_coverage/pyproject.toml
new file mode 100644
index 0000000..08a81b7
--- /dev/null
+++ b/test/core_intent_coverage/pyproject.toml
@@ -0,0 +1,10 @@
+[project]
+name = "core-intent-coverage"
+version = "0.1.0"
+description = "只读静态核验:核心设计意图是否被 p0/p1 测试真正断言覆盖(零污染,不 import 工程)"
+requires-python = ">=3.9"
+dependencies = []
+
+[build-system]
+requires = ["setuptools>=61"]
+build-backend = "setuptools.build_meta"
diff --git a/test/core_intent_coverage/run.py b/test/core_intent_coverage/run.py
new file mode 100644
index 0000000..fbf6ff1
--- /dev/null
+++ b/test/core_intent_coverage/run.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+"""入口:python run.py [--app ...] [--tests ...] [--intents ...] [--out ...]"""
+import os
+import sys
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from checker import main # noqa: E402
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/test/上市前测试覆盖度台账.md b/test/上市前测试覆盖度台账.md
new file mode 100644
index 0000000..7d09914
--- /dev/null
+++ b/test/上市前测试覆盖度台账.md
@@ -0,0 +1,41 @@
+# 上市前测试覆盖度台账
+
+> 生成日期:2026-10-18
+> 对照基准:软件上市前 11 类测试(按严重程度分四档)
+> 方法说明:**基于文件名 + 关键词扫描的初判**,非逐文件源码精读;精准度需后续读源码确认。
+> 工程位置:`D:/PricingReview/CostReview/`,测试根 `app/tests` + `app/tools`(pytest.ini: testpaths)
+
+## 覆盖度总览
+
+| # | 测试类别 | 覆盖度 | 现有对应资产 | 主要缺口 |
+|---|---------|--------|-------------|---------|
+| 1 | 功能/验收 | ✅ 强 | `test_api_p0/p1`、`test_lme_*`、`test_norm_*`、`test_export_*`、`test_group_*`、`test_kw_*`、`test_match_*`、`test_mcp_switch`、`test_unit_core`(30+ 用例) | 缺端到端 UAT 脚本 |
+| 2 | 回归 | ✅ 强 | 上述全套 + 预推送门禁 `pytest -m "not perf"` | 无 |
+| 3 | 安全 | ◐ 部分 | `test_license_hardening/verify/client`、`test_source_guards`、`test_wipe` | **缺注入/越权/加密壳(`.cos4` 加壳)防护/传输安全** |
+| 4 | 性能 | ◐ 弱 | `test_perf_baseline.py`(perf 标记,软阈值告警不失败) | 仅 1 文件、软门禁、缺峰值/压力 |
+| 5 | 兼容性 | ✗ 缺失 | 仅散见编码(gbk/utf)处理,无系统用例 | 缺 OS/浏览器/**广联达格式互通**专门测试 |
+| 6 | 稳定性 | ✗ 缺失 | 无 | 缺长时运行/内存泄漏/假死(锁库死等) |
+| 7 | 安装/部署/升级 | ◐ 部分 | `test_api_upgrade.py`(升级 API 逻辑) | 缺安装包/部署/真实升级路径 |
+| 8 | 数据迁移 | ◐ 部分 | upgrade 测试触及 schema | 缺"保数据"迁移专项 |
+| 9 | 易用性/UI | ✗ 缺失 | 无(后端/api 为主) | 缺 UI/交互测试 |
+| 10 | 国际化/本地化 | ✗ 缺失 | 无 | 按需 |
+| 11 | 灾备/容错 | ✗ 缺失 | `source_guards`/`wipe` 触及部分容错 | 缺断网/断电/进程被杀恢复 |
+
+## 关键结论
+
+- 第 1、2 类(功能/验收 + 回归)是上市前**地基**,必须先确认;第 4 类(性能)属第二梯队,功能没对之前先测性能会被推翻。
+- 工程 `CostReview/app` 内**不含** `.cos4` 解毒逻辑(仅有 `app/core/export_cos.py` 负责导出);解毒属「读取COS」技能,是外部逻辑,**不纳入本工程测试范围**。
+- 本工程现有安全覆盖:`test_license_*`、`test_source_guards`、`test_wipe`(授权加固 + 数据源防护);真实缺口在 注入/越权/传输安全(非 cos4 加壳)。
+
+## 建议优先级(下一步)
+
+1. **第 1/2 类·功能验收 + 回归(第一步内容)**:核验现有 `test_api_p0/p1` + 预推送门禁是否真正编码了「设计设想/验收标准」,而非仅 happy-path 冒烟。
+ —— 这正是"功能是否完全按设想、改后是否仍正常、有无新 bug"的答案,优先确认。
+2. **第 3 类·安全(工程自身)**:补 注入/越权/传输安全;cos4 解密不在此列(外部技能)。
+3. **第 4 类·性能(后端/数据库)**:现有 `test_perf_baseline.py` 已是软阈值基线;待功能稳定后再做峰值/压力硬门禁。
+4. **第 5 类·兼容性 / 第 6 类·稳定性**:广联达互通 + 长时运行/锁库死假死。
+
+## 配套交付物
+
+- `D:/PricingReview/test/上市前测试覆盖度台账.md` — 本台账(唯一交付物)。
+- 测试工具约定:若委托我建测试工具,均为**独立于 `CostReview` 代码**的自有工具,按"一个工具一个包"置于 `D:\PricingReview\test\` 下,不修改工程源码、不散放。
diff --git a/决策台账.md b/决策台账.md
index 2313c28..92b20b4 100644
--- a/决策台账.md
+++ b/决策台账.md
@@ -2823,3 +2823,133 @@ Express 填值 ②清单级字面量 QtyFormula 清空 ③附加块保真 ④位
导出侧本轮沉淀:整块克隆(骨架+填空三分类)、锚点0=首条之前、同点插入保序、
特征换行恢复、Express 填值、字面量公式清空、zip 附加块保真;系数 GCL 口径
(导入/迁移/兜底三处收口)+ 存量会话公式一次性修复。202 项测试全绿。
+**决策 106 补记十(同日,广联达「采纳部分人工费外溢」)**:样例工程(会话24)实测——
+广联达文件里「人工费(00010010)」汇总行是**金额汇总行**:数量=金额合计(4142082.6 元)、
+单价恒 1、单位=元;会话合并改价把它按资源口径改成 500(元/工日)后,导出同步回写
+→ Glodon 按数量×单价重算 → 人工费爆炸外溢。修复:`_is_amount_aggregate`(单位=元 且
+原除税价=1)判定的金额汇总行,项目级/单位级汇总同步**一律不回写价格**(名称/改码仍可);
+用户手动合并的正常资源行(机械 1232.54 等)照常回写。样例工程重导实测:00010010 保持
+1/1,机械合并价正常落盘。203 passed(新增回归 1 项)。
+**决策 106 补记十一(同日,主人问「采纳定额是否也按新增处理」)**:确认采纳定额自
+决策 106 起就与新增清单同一条整块克隆流水线(Norm 范围填空,宿主清单不剪切),无需改。
+顺路补齐最后一处不同步:既有清单追加采纳定额时,清单级消耗量架子**新增码**此前恒填 0,
+现与新增清单同口径按 Σ(含量×定额量)÷清单量 填真值(原生码行保持原值不动;行形态照
+文件现有尾表行克隆)。样例工程重导实测:新增码行带真值(0.0002/0.0016 等),人工费
+汇总行保持 1/1;撤下的 36 行 = 临删原定额随块省略(9.3 语义,预期)。203 passed。
+**决策 106 补记十二(同日,主人问「定额调整部分是否也按历史项目填写,如人工费*1.2」)**:
+是——此前只存含量数值、算式丢失。全链补齐:导入捕获定额工料机的 Express 属性
+(换算调整式,如 1611.66*1.2)入库(norm_res/s_norm_res 新增 express 列,批量/会话两侧
+补列迁移);采纳携带(9.1/9.3 两处 + 快照恢复 + 打开工程四处全部接线);导出 `_norm_xml`
+含量行 Express **优先填历史项目自己的调整式**,无算式退裸含量(行模板无 Express 属性的
+格式不造该属性)。存量批次是旧解析器入库的、算式未捕获——**需重新导入一次**才有算式。
+204 passed(新增端到端回归 1 项)。
+**决策 106 补记十三(同日,主人给 NormAdjustmentList 样本并附测试件「广联达测试定额调整.COS4」)**:
+主人指正——要搬的是**换算调整记录**(GConvInfo 标准换算/R*2,J*2/送桩材料含量…,含 OrderNumber
++Value),不只是含量算式;此前导出按决策 101 把模板记录一刀切丢弃。修正全链:
+导入捕获 NormAdjustmentList(Value 串)→ norms.x_adjust(JSON)(批/会两库补列)→
+采纳携带(9.1/9.3+快照恢复+打开工程)→ 导出 `_norm_xml` 先剥模板记录、再按本定额携带的
+x_adjust 重写(OrderNumber 重排、行形态照模板首行克隆)=「把历史项目的调整记录填进现有
+框架」。捕获分支初版误嵌工料机分支内永不可达——已移外层链(教训:新 elif 要挂对层级)。
+端到端实测(批次 33 重导→会话 28→采纳 010101001001):采纳定额 A1-1-5/A1-3-1 的
+GConvInfo 记录原样落进导出(4 条=2 原生+2 采纳),人工费汇总行保持 1/1。204 passed。
+注:存量批次/会话需重导/重开一次才有调整记录。
+**补记十三续(同日,保真校验揪出归属错位)**:主人提醒「库里的格式不一致会导致导出件
+不被识别」——逐字节往返校验揪出真 bug:save 循环元组首元素是 **cur_bill(清单下标)**,
+却拿它当 **定额下标** 去 norm_adj 里查——调整记录张冠李戴(A1-1-40 的记录落到 A1-1-5
+头上)。修:两处(import_job.save / session_job 打开工程)改 enumerate 按定额下标查。
+干净重放+真实往返双验证:批次 35 A1-1-40/A1-3-1 各归其位、会话携带、导出 2 条
+GConvInfo 记录原样、人工费汇总行保持 1。另:Value/Express 捕获改**原样保真不 strip**
+(易达原生值带尾随空格)。测试批次 30-35/会话 27-30 为排查残留,可后台删。
+**决策 106 补记十四(同日,主人报「新增清单到工作台就外溢」——另一处外溢,在工作台自己肚子里)**:
+广联达把清单级的资源构成行(人工费等,编码=纯数字工料机码如 00010010、单位=元、
+金额=含量×1.2)也写成 元素(属性与真定额全同,连 IsNorm 都是 true)。
+导入照单全收 → 采纳把 00010010 当定额带进工作台(Qty 889.9911=GCL 公式跑出来的垃圾值)。
+修复:parse_std 的 Norm start 侧判定(编码纯数字 + 单位=元)→ 不占定额下标、cur_norm=-1
+(子元素含量/调整记录一并跳过),end 侧不落库。真定额/调整记录/算式不受影响。
+⚠️ start 事件块里读属性必须用 el.attrib(a 是 end 块的变量,跨事件残留是坑,本次踩中)。
+存量会话(如 24)需重开清洗。205 passed(新增伪定额过滤回归 1 项)。
+**决策 106 补记十五(同日,两件收口)**:
+①**调整记录原样回填**(主人定「他导入什么就是什么,我们只负责原样回填」)——撤销 GConvInfo
+拆分方案:NormAdjustmentList 的 Value 整串原样入库、原样导出,不做任何形态转换。广联达
+能显示换算列表(主人截图实测),勾选状态不在文件数据里(原生件同样不勾,主人可自验)。
+②**工作台特征编辑换行丢失**(主人报「点了再导出排序就不行」):特征格双击编辑用单行
+input,预填的显示文本带换行 → 浏览器把 input 换行整段剥掉 → 保存黏团、导出无法按编号
+恢复。修复:Attr 编辑改 textarea(Enter 换行、Ctrl+Enter/点开别处保存),换行原样入库
+原样导出。⚠️ 原值取自 td.textContent(fmtAttr 显示文本,自带换行)——数据无损。
+205 passed。
+**决策 106 补记十五续(同日,「最近审核点打开项目没反应」真凶)**:补记十五的 textarea
+补丁首次落盘时,JS 字符串里的换行转义(\n)被写成了**真实换行**——一个字符之差,整个
+工作台页面脚本语法报错:页面能显示、所有 JS 全死 → 最近审核点打开项目毫无反应。
+已修正(cur.split('\n') 转义归位),三页内联脚本 node --check 全部通过;后端直接调用
+api_audit 实测正常(此前已验)。教训入协作改进.md:前端内联脚本改动必须语法校验。
+**决策 106 补记十六(同日,主人定「合价=工程量×单价」口径)**:
+①新增清单:导出时 合价=工程量×单价 现算(工作台不预存合价);
+②清单/定额 行内改工程量:保存瞬间 合价=工程量×单价 同步入库(工作台合价列即时正确),
+导出按会话现值**原样写穿**(决策 90 语义不变,两者不打架——曾试图导出统一重算,
+与「价格写穿」冲突,已改为编辑时算好的分工);
+③采纳定额:合价=求值工程量×单价(决策 90 原有)+ 导出统一兜底;
+④源定额改工程量(数字):同 ②③ 双保险;数值相同不产生字节改动(_num_eq 护栏)。
+「汇总不重复」现状确认:分部/章节汇总我们从不写(软件自算);伪定额聚合行导入即滤
+(补记十四);清单级消耗量架子=含量数据非汇总,保留。205→206 passed(新增合价口径回归)。
+注:主人报的「导出加了 [10000]」未能定位(全文件方括号扫描仅 [04290110]=调整记录正文)——
+待截图标注具体位置。
+**决策 106 补记十七(同日,主人定「定额工程量编辑 = 实际量」显示输出关系)**:
+主人实测口径 + 原件三样本验证(D7-5-13 10m3 存 2.367970、D1-1-39 1000m3 存 3.866520、
+易达 A1-2-48 100m 存 19.01——**原文件定额 Quantity 一律 = 每定额单位的量(÷因子)**;
+ExpressElement 算式行的 Quantity = 清单工程量)。落地:
+①格子空闲显示 = 每定额单位的量(不变);②双击编辑框 = **实际量**(×因子,如 23.6797),
+输入实际量,保存 ÷ 因子入库(此前预填公式原文/裸数值——口径混乱);③导出 = 每定额单位
+(不变);④组表编辑框同口径。实施中连环踩坑:heredoc 转义丢层(\b 变退格符 0x08、\n 变
+真实换行)——正则失效 + 前端语法错(补记十五续的那次瘫痪同源),已全部按行重建修复。
+工作台前端无自动化测试——JS 改动落盘后必须 node --check(协作改进已有此条,本次再犯,
+升级为:改完必须跑三页校验脚本)。206 passed。
+**决策 106 补记十八(同日,易达「QGCL/[24.7157]」显示 + 采纳反应慢)**:
+①易达工程量列显示 QGCL 代号或 [24.7157] 方括号值的根因:定额的**数量算式行**
+(ExpressElement,Express=QGCL 或空)。原文件原生定额自带 QGCL 算式(D1-1-39 与原件
+逐字节一致——原样保留,广联达显示数字、易达显示算式=两软件对同一数据的显示差异);
+采纳定额此前算式行被清空(Express=""/Quantity=0)→ 易达按默认 QGCL 处理显示 [清单量]
+且不除单位因子。修复:采纳定额的算式行 Express/Quantity = **本定额求值数量的纯数字
+文本**(数值自洽,易达显示数字;广联达样件亦有纯数字算式形态)。原生未动定额的 QGCL
+保持原样(原样保留原则)——若主人也要转数字,属新需求待定。
+②采纳反应慢:后端实测秒回(本机直调 ok);当时慢疑为排查进程占库锁(已全退出)。
+测试性采纳已 unadopt 清理(3 品类行回收)。206 passed。
+**决策 106 补记十九(同日,主人再定「编制状态显示 GCL*1,系数这时候用上」)**:
+撤销补记十六的「实际量编辑口径」——定额工程量双击编辑**恢复决策 96 原行为**:预填公式原文
+(GCL*1.0,系数就在这里用/可改),接受数字、四则与 GCL 公式;格子显示与导出=按当时清单量
+求值(÷单位因子后的每定额单位量)。新增清单与挂定额两条场景均如此。合价口径(补记十六)
+不变。恢复过程把 grpNormQtyEdit 整段重写清障(多轮补丁叠出的重复声明已清)。206 passed。
+**决策 106 补记二十(同日,算式行口径最终定稿)**:主人连续纠偏后定稿——
+①定额数量算式行(ExpressElement):**采纳/新增的定额,Express 与 Quantity 都写本定额
+求值数量的纯数字**(如 10);**原生未动定额的 QGCL 等算式行原样保留**(各家软件用自己的
+代号表达与清单量的关系,不翻译、不折腾——中途试过的"清单量版"与"全文件转数字版"均已
+撤销);②工作台双击编辑 = 编制状态,显示公式原文 GCL×系数(系数这时候用上),可改公式
+或输数字;③格子空闲与导出 = 每定额单位的量(÷因子)。全程以原文件三样本自行验证
+(D7-5-13 10m3=2.367970、D1-1-39 1000m3=3.866520、易达 A1-2-48 100m=19.01)。
+206 passed。桌面 220kV 审核版已更新为最终形态。
+
+## 决策 107(2026-10-18,主人定·红线的红线):决策前后矛盾必须指出并请主人决策
+
+**主人原话**:「要是决策前后矛盾,一定要指出来,并且要主人决策,不能你自己决策。凡是和历史决策不一样的。这个是红线的红线。禁区的禁区,并且记入长期记忆。」
+
+**规则**:新指令/新理解与历史决策(本台账)冲突时——
+①当场指出冲突点(对照台账列明「与决策 NN 冲突」,冲突在哪、影响什么);
+②请主人决策(给出可选项与推荐,但决定权在主人);
+③**禁止**自行取舍、静默改口、以"新理解"覆盖旧决策而不声明。
+**落地**:AGENTS.md 已建(长期记忆入口,红线置顶,含记忆文件索引与工作铁律);
+align skill 增加动手前强制「对照台账查冲突」步骤。
+
+**溯源**:2026-10-18 定额工程量编辑口径——决策 90/96 已定「编辑框预填公式原文 GCL×系数」,
+实施中因主人一句「编辑框显示实际量」自行改成实际量口径、未指出与决策 90/96 的冲突,
+返工多轮后主人追问「你怎么没有严格按他们的来?你私自做的决定?」——遂立此红线。
+**决策 106 补记二十一(同日,主人发现规律并定稿)**:主人点破易达规则——**公式大于数字:
+Quantity 与 Express 同时出现时,易达采用 Express**。故采纳/新增定额的算式行(ExpressElement)
+**一律不写**(此前写纯数字算式,易达仍加方括号显示 [24.7157])——去掉算式行后,易达回落
+显示 Quantity 属性的纯数字。原生未动定额的算式行原样保留(原文件如此,广联达/易达显示
+差异属软件行为;是否统一转数字待主人后续拍板)。206 passed。
+**决策 106 补记二十二(同日,主人拍板定稿·按骨架实施)**:主人发现易达规则「公式大于数字:
+Quantity 与 Express 同时出现时采用 Express」,并拍板——**采纳/新增定额一律不写数量算式行
+(ExpressElement)**,易达回落显示 Quantity 属性的纯数字。冲突核对(决策 107 首次执行):
+①与决策 90/96 无冲突(那是工作台内部的 GCL 公式机制,不涉及文件算式行);
+②取代补记二十的「纯数字算式行」写法——那是本轮我的过渡实现,未经主人确认,由主人亲自
+推翻并定稿;③与「原样保留」原则的取舍(采纳定额比原生少一行算式)已由主人拍板接受。
+代码现状与之一致(采纳定额 0 条算式行),206 passed。桌面对照件已更新。
diff --git a/协作改进.md b/协作改进.md
new file mode 100644
index 0000000..1fbe78a
--- /dev/null
+++ b/协作改进.md
@@ -0,0 +1,41 @@
+# 协作改进
+
+> 追加式。每次收口复盘:返工根因 → 可执行改进(新 skill / 固定检查 / 钩子 / 术语)。业务结论归决策台账,这里只记工作方式。
+
+---
+
+## 2026-10-18(骨架/外溢/位置多轮返工复盘)
+
+1. **验证结构,不能只验属性**——广联达拒收多轮的根因:验证只对了"属性集与原生一致",没对子节点结构(骨架)。今后凡"写了但对方不认",第一动作是**拿对方软件存的原生样本逐行对**,不对着自己的导出件自证。
+ 状态:已做(整块克隆 + 样本对数排查法,测A/B/C 隔离件沿用)。
+2. **动手前对齐设计树**——外溢、位置错位两轮返工的根因是需求分支没问穿。已做成 `align` skill(动手前列分支逐条拍板)。
+ 状态:已做。
+3. **术语固化防歧义**——"外溢"一词歧义过一轮。已做成 `glossary` skill + 术语表。
+ 状态:已做。
+
+## 待观察
+
+- 采纳到既有清单时,消耗量架子**新增码**已填真值;原生码行保持原值(重算会大面积改写原生字节)——待主人实测后定要不要全量重算。
+- 存量批次/会话吃"重导/重开才有新字段"这一条(算式、调整记录),要不要做一个"检测旧解析器版本提示重导"的提示。
+
+## 2026-10-18(第二则:排查残留主人代删)
+
+**返工根因**:排查伪定额问题产生的测试批次(33/34/35)和会话(27/28/30)留在库里,主人提醒「以后你要自己删掉」。
+**改进动作(已做,长期有效)**:凡是排查/测试产生的批次、会话、临时文件(含桌面验证件确认后),**收尾时自己清理**,不留清单让主人动手;删之前先核对名字与创建时间,只删自己建的,主人的数据绝不碰。
+
+## 2026-10-18(第三则:前端一处转义写错 → 整页脚本瘫痪)
+
+**返工根因**:改 workbench.html 特征编辑器时,JS 字符串换行转义写成了真实换行(python
+字符串 \n 少一层转义),页面脚本语法错误 → 整页 JS 瘫痪,主人看到「所有按钮都没反应」。
+**改进动作(已做,长期有效)**:凡是 .html 内联