实现侧: - 上下文:任务范围拆分为 范围校验/范围授权;索引按可发现口径重建、索引新鲜度改对称差;依赖校验统一快照漂移说明。 - 知识方法:方法与材料读取口径统一;超限方法材料按可选省略,核对路径不再二次计费;删除无合同的读时重算。 - 任务运行:新增 context.usage/tool.denied 事件类型;连接池常驻并在装配生命周期内开关;调用结算与核对分列。 - 效果评测/审校修订/交付连载/作者经验/作品规划:凭据冻结、标定消费、导出补证、事实引文核对等收尾修复。 - 资源加载:能力正文不再夹带索引用的导航注记(该注记此前进入角色与技能的模型提示)。 - 元数据:受保护骨架与代码保护属性对齐;字段校验与内置结构口径同步。 - 基础设施:环境预检进入装配生命周期;数据库连接运行期字段不参与相等比较;索引指纹归一化 jsonb 浮点。 - 删除被替代实现:7 份旧提示词模板与空壳 资料来源 读取器。 用例侧: - 用例身份与导航元信息迁移;夹具补生命周期、同库暴露与模板封存; - 本轮定向修复:方法材料省略、事实引文、迁移回执、额度与暂停用例、慢用例超时预算等。
78 lines
3.2 KiB
Python
78 lines
3.2 KiB
Python
"""专名对照:定位原文、建议称谓,作者例外只对该版本该位置有效。"""
|
|
|
|
import pytest
|
|
|
|
from muse.交付连载.文字校对 import 文字疑点
|
|
from muse.交付连载.模型 import 交付错误
|
|
|
|
|
|
def 章(chapter_id, text, revision=1, document_hash="a" * 64):
|
|
return {
|
|
"chapter_id": chapter_id,
|
|
"revision": revision,
|
|
"document_hash": document_hash,
|
|
"text": text,
|
|
}
|
|
|
|
|
|
@pytest.mark.case_id(
|
|
"NC-r2-c0ed01",
|
|
environment="离线单元",
|
|
given="同一专名在正文出现两处且登记对照称谓",
|
|
when="生成文字疑点",
|
|
then=["两处分别定位并给出建议称谓"],
|
|
contract="docs/系统架构/新版设计/模块设计/B08-交付连载.md",
|
|
)
|
|
def test_专名对照逐处定位并给出建议称谓__c0ed01():
|
|
text = "青禾推门。门外青禾还站着。"
|
|
findings = 文字疑点([章("c1", text)], names={"青禾": "青禾儿"})
|
|
names = [f for f in findings if f["kind"] == "专名对照"]
|
|
assert [f["quote"] for f in names] == ["青禾", "青禾"]
|
|
assert [f["suggestion"] for f in names] == ["青禾儿", "青禾儿"]
|
|
assert [f["start"] for f in names] == [0, text.index("青禾", 1)]
|
|
assert {f["disposition"] for f in names} == {"review"}
|
|
assert names[0]["id"] != names[1]["id"]
|
|
|
|
|
|
@pytest.mark.case_id(
|
|
"NC-r2-c0ed02",
|
|
environment="离线单元",
|
|
given="空专名或对照称谓与原文相同",
|
|
when="生成文字疑点",
|
|
then=["拒绝非法专名对照"],
|
|
contract="docs/系统架构/新版设计/模块设计/B08-交付连载.md",
|
|
)
|
|
def test_空或相同专名对照拒绝__c0ed02():
|
|
chapter = 章("c1", "青禾在场。")
|
|
for names in ({"": "青禾儿"}, {"青禾": ""}, {"青禾": "青禾"}):
|
|
with pytest.raises(交付错误, match="专名对照") as err:
|
|
文字疑点([chapter], names=names)
|
|
assert err.value.错误码 == "COPYEDIT_INVALID"
|
|
|
|
|
|
@pytest.mark.case_id(
|
|
"NC-r2-c0ed03",
|
|
environment="离线单元",
|
|
given="作者对某一处专名命中声明例外",
|
|
when="再次生成文字疑点",
|
|
then=["例外只对该版本该位置生效"],
|
|
contract="docs/系统架构/新版设计/模块设计/B08-交付连载.md",
|
|
)
|
|
def test_作者例外只对该版本该位置有效__c0ed03():
|
|
first = 章("c1", "青禾推门。", revision=1, document_hash="a" * 64)
|
|
second = 章("c2", "青禾推门。", revision=1, document_hash="b" * 64)
|
|
all_findings = 文字疑点([first, second], names={"青禾": "青禾儿"})
|
|
names = [f for f in all_findings if f["kind"] == "专名对照"]
|
|
assert len(names) == 2
|
|
kept = names[0]["id"]
|
|
again = 文字疑点([first, second], names={"青禾": "青禾儿"}, exceptions=(kept,))
|
|
by_id = {f["id"]: f for f in again if f["kind"] == "专名对照"}
|
|
assert by_id[kept]["disposition"] == "preserved"
|
|
other = names[1]["id"]
|
|
assert by_id[other]["disposition"] == "review"
|
|
newer = 章("c1", "青禾推门。", revision=2, document_hash="a" * 64)
|
|
moved = 文字疑点([newer], names={"青禾": "青禾儿"}, exceptions=(kept,))
|
|
assert moved[0]["kind"] == "专名对照"
|
|
assert moved[0]["id"] != kept
|
|
assert moved[0]["disposition"] == "review"
|