code-to10 v6 A14 batch1: workers F601 duplicates and check_transplant E741 renames
(cherry picked from commit 4411186681584bf55e065c654fe909a3320d4a22) Reconcile-conflict: test_skill_transplant_prep artifact count — kept HEAD's finalized 0 refs (2026-11-02 user sign-off deleting §4's 6 references, already in target) with incoming's l→line rename; incoming's 6-ref assertion is pre-finalization and must not overwrite.
This commit is contained in:
1 parent
e00c255011
commit
bd55599859
4 files changed
+26
-29
No files matched your search
@@ -196,9 +196,9 @@ def extract_source(text):
|
||||
if len(matrix) != 1:
|
||||
raise ValueError("auditor matrix row: expected 1, found %d"
|
||||
% len(matrix))
|
||||
main_start = _find_exact(lines, lambda l: l == MAIN_HEADERS[0],
|
||||
main_start = _find_exact(lines, lambda line: line == MAIN_HEADERS[0],
|
||||
"main section heading")
|
||||
honest = _find_exact(lines, lambda l: l.startswith("## 诚实边界"),
|
||||
honest = _find_exact(lines, lambda line: line.startswith("## 诚实边界"),
|
||||
"honesty section heading")
|
||||
if not main_start < honest:
|
||||
raise ValueError("main section does not precede honesty section")
|
||||
@@ -206,15 +206,15 @@ def extract_source(text):
|
||||
while main and main[-1] == "":
|
||||
main.pop()
|
||||
check_start = _find_exact(
|
||||
lines, lambda l: l.startswith("- 审计与推回走了吗?"),
|
||||
lines, lambda line: line.startswith("- 审计与推回走了吗?"),
|
||||
"audit checklist item")
|
||||
check_end = _find_exact(
|
||||
lines, lambda l: l.startswith("- QA 全链路走了吗?"),
|
||||
lines, lambda line: line.startswith("- QA 全链路走了吗?"),
|
||||
"QA checklist item")
|
||||
audit_item = _collect_item(lines, check_start, "悄悄放行?")
|
||||
qa_item = _collect_item(lines, check_end, "重审重跑失败链路了吗?")
|
||||
app_start = _find_exact(
|
||||
lines, lambda l: l.startswith("## 附录角色:") and "auditor" in l,
|
||||
lines, lambda line: line.startswith("## 附录角色:") and "auditor" in line,
|
||||
"appendix auditor chapter")
|
||||
body = lines[app_start + 1:]
|
||||
while body and body[0] == "":
|
||||
@@ -316,15 +316,15 @@ def apply_transplant(source_text, target_text, target_id):
|
||||
tlines = _lines(target_text)
|
||||
report = []
|
||||
# 1. matrix row after the QA row.
|
||||
qa_row = _find_exact(tlines, lambda l: l.startswith("| QA / 测试 |"),
|
||||
qa_row = _find_exact(tlines, lambda line: line.startswith("| QA / 测试 |"),
|
||||
"target QA matrix row")
|
||||
if any(l.startswith("## 附录角色:") and "auditor" in l for l in tlines):
|
||||
if any(line.startswith("## 附录角色:") and "auditor" in line for line in tlines):
|
||||
raise ValueError("target already contains an auditor appendix chapter")
|
||||
out = list(tlines)
|
||||
out.insert(qa_row + 1, hunks["matrix_row"])
|
||||
report.append("matrix row inserted after target QA row")
|
||||
# 2. main section before the honesty heading (re-find after insert).
|
||||
honest = _find_exact(out, lambda l: l.startswith("## 诚实边界"),
|
||||
honest = _find_exact(out, lambda line: line.startswith("## 诚实边界"),
|
||||
"target honesty heading")
|
||||
main, stopped = transform_main(hunks["main"], target_id)
|
||||
report.extend("STOPPED (not applied): " + s for s in stopped)
|
||||
@@ -333,7 +333,7 @@ def apply_transplant(source_text, target_text, target_id):
|
||||
"(%d lines, %d stopped paragraphs)"
|
||||
% (len(main), len(stopped)))
|
||||
# 3. checklist items before "有一项为否".
|
||||
check_end = _find_exact(out, lambda l: "有一项为否" in l,
|
||||
check_end = _find_exact(out, lambda line: "有一项为否" in line,
|
||||
"target checklist end")
|
||||
items = list(hunks["audit_item"])
|
||||
if target_id != "v05":
|
||||
@@ -374,24 +374,24 @@ def check_anchors(source_text, target_text, target_id):
|
||||
return ["source hunks not extractable: %s" % exc]
|
||||
tlines = _lines(target_text)
|
||||
for what, pred in [
|
||||
("target QA matrix row", lambda l: l.startswith("| QA / 测试 |")),
|
||||
("target honesty heading", lambda l: l.startswith("## 诚实边界")),
|
||||
("target checklist end", lambda l: "有一项为否" in l),
|
||||
("target appendix intro", lambda l: l == "## 附录:角色模板(播种随附版)"),
|
||||
("target QA matrix row", lambda line: line.startswith("| QA / 测试 |")),
|
||||
("target honesty heading", lambda line: line.startswith("## 诚实边界")),
|
||||
("target checklist end", lambda line: "有一项为否" in line),
|
||||
("target appendix intro", lambda line: line == "## 附录:角色模板(播种随附版)"),
|
||||
]:
|
||||
if sum(1 for l in tlines if pred(l)) != 1:
|
||||
if sum(1 for line in tlines if pred(line)) != 1:
|
||||
errors.append("anchor %s: expected 1, found %d"
|
||||
% (what, sum(1 for l in tlines if pred(l))))
|
||||
% (what, sum(1 for line in tlines if pred(line))))
|
||||
last_chapter = ("10-iteration" if target_id == "v05"
|
||||
else "08-shared-core")
|
||||
if not any(l.startswith("## 附录角色:%s" % last_chapter) for l in tlines):
|
||||
if not any(line.startswith("## 附录角色:%s" % last_chapter) for line in tlines):
|
||||
errors.append("target appendix lacks last chapter %s" % last_chapter)
|
||||
if any("auditor" in l and l.startswith("## 附录角色:") for l in tlines):
|
||||
if any("auditor" in line and line.startswith("## 附录角色:") for line in tlines):
|
||||
errors.append("target already contains an auditor appendix chapter")
|
||||
for marker in MARKERS[target_id]:
|
||||
if marker not in target_text:
|
||||
errors.append("preserved marker missing in target: %s" % marker)
|
||||
refs = [i + 1 for i, l in enumerate(tlines) if "templates/artifacts" in l]
|
||||
refs = [i + 1 for i, line in enumerate(tlines) if "templates/artifacts" in line]
|
||||
print("anchors: source hunks OK (matrix + main %d lines + 2 checklist "
|
||||
"items + appendix %d lines)"
|
||||
% (len(hunks["main"]), len(hunks["appendix_body"])))
|
||||
@@ -408,8 +408,8 @@ def check_transplanted(target_text, transplanted_text, target_id):
|
||||
for marker in MARKERS[target_id]:
|
||||
if marker not in transplanted_text:
|
||||
errors.append("preserved marker lost: %s" % marker)
|
||||
rows = [l for l in _lines(transplanted_text)
|
||||
if l.startswith("| 独立审计 |")]
|
||||
rows = [line for line in _lines(transplanted_text)
|
||||
if line.startswith("| 独立审计 |")]
|
||||
if len(rows) != 1:
|
||||
errors.append("auditor matrix row: expected 1, found %d" % len(rows))
|
||||
for header in MAIN_HEADERS:
|
||||
|
||||
Reference in new issue
Block a user