diff --git a/cloud/skills/software-engineering/tools/check_transplant.py b/cloud/skills/software-engineering/tools/check_transplant.py index 3b22de6..ea62b6e 100644 --- a/cloud/skills/software-engineering/tools/check_transplant.py +++ b/cloud/skills/software-engineering/tools/check_transplant.py @@ -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: diff --git a/cloud/tests/test_skill_transplant_prep.py b/cloud/tests/test_skill_transplant_prep.py index e9d485c..3d47072 100644 --- a/cloud/tests/test_skill_transplant_prep.py +++ b/cloud/tests/test_skill_transplant_prep.py @@ -268,7 +268,7 @@ class TransplantPrepTestCase(unittest.TestCase): self, {"cmd": "apply", "target_id": "v03"}, tmp_o) self.assertEqual(result.returncode, 0, result.stderr) lines = draft.read_text(encoding="utf-8").split("\n") - kept = [l for l in lines if not l.startswith("- 标记行:")] + kept = [line for line in lines if not line.startswith("- 标记行:")] self.assertLess(len(kept), len(lines)) draft.write_text("\n".join(kept), encoding="utf-8") check = subprocess.run( @@ -282,7 +282,7 @@ class TransplantPrepTestCase(unittest.TestCase): # v5 用户定稿(2026-11-02):§4 的 6 处引用经用户签字删除, # 本测试由“钉住 6 处”改为“钉住 0 处”,防止删除后悄悄回潮。 text = SKILL_MD.read_text(encoding="utf-8") - refs = [l for l in text.split("\n") if "templates/artifacts" in l] + refs = [line for line in text.split("\n") if "templates/artifacts" in line] self.assertEqual(len(refs), 0, refs) self.assertIn("## 独立审计与自动推回", text) # 集成基底章节表:审计章在 v0.5 表里编号为 11-auditor diff --git a/cloud/tests/test_v2cov_transplant.py b/cloud/tests/test_v2cov_transplant.py index 62484f3..923a9de 100644 --- a/cloud/tests/test_v2cov_transplant.py +++ b/cloud/tests/test_v2cov_transplant.py @@ -224,9 +224,9 @@ class ExtractTestCase(unittest.TestCase): self.assertEqual(CT._lines("a\nb"), ["a", "b"]) lines = ["x", "y", "x"] with self.assertRaises(ValueError): - CT._find_exact(lines, lambda l: l == "z", "missing") + CT._find_exact(lines, lambda line: line == "z", "missing") with self.assertRaises(ValueError): - CT._find_exact(lines, lambda l: l == "x", "duplicated") + CT._find_exact(lines, lambda line: line == "x", "duplicated") err = io.StringIO() with contextlib.redirect_stderr(err): self.assertEqual(CT.fail("boom"), 1) @@ -431,8 +431,8 @@ class CheckTransplantedTestCase(unittest.TestCase): def test_check_marker_and_matrix_errors(self): draft = self._draft("v03") target = _target_fixture("v03") - dropped = "\n".join(l for l in draft.split("\n") - if not l.startswith("- 标记行:")) + dropped = "\n".join(line for line in draft.split("\n") + if not line.startswith("- 标记行:")) errors = CT.check_transplanted(target, dropped, "v03") self.assertTrue(any("preserved marker lost" in e for e in errors)) no_row = draft.replace("| 独立审计 | 1 | 只写审计记录 | 审计结论 |\n", "") diff --git a/cloud/workers.py b/cloud/workers.py index 681d39b..9729692 100644 --- a/cloud/workers.py +++ b/cloud/workers.py @@ -719,9 +719,6 @@ def _worker_to_dict(row): "address": _get("address"), "last_seen": _get("last_seen"), "created_at": _get("created_at"), - "host": _get("host"), - "pid": _get("pid"), - "address": _get("address"), }