diff --git a/tools/repair_preclaim_rebind_attempt.py b/tools/repair_preclaim_rebind_attempt.py index e7983b7..b9d0b62 100644 --- a/tools/repair_preclaim_rebind_attempt.py +++ b/tools/repair_preclaim_rebind_attempt.py @@ -21,9 +21,7 @@ def backup(path: pathlib.Path) -> pathlib.Path: return out def main() -> int: - ap = argparse.ArgumentParser( - description="Allow CAS execution rebind for a never-claimed QUEUED task at attempt=0." - ) + ap = argparse.ArgumentParser(description="Allow pre-claim execution rebind at attempt=0.") ap.add_argument("--rebind", required=True) args = ap.parse_args() @@ -32,45 +30,30 @@ def main() -> int: die(f"missing rebind source: {path}") text = path.read_text(encoding="utf-8") - - old = ( - ' or not isinstance(attempt, int)\n' - ' or isinstance(attempt, bool)\n' - ' or attempt < 1\n' - ' ):\n' - ' raise ExecutionRebindError("EXECUTION_REBIND_INTEGER_INVALID", 400)\n' - ) - new = ( - ' or not isinstance(attempt, int)\n' - ' or isinstance(attempt, bool)\n' - ' or attempt < 0\n' - ' ):\n' - ' raise ExecutionRebindError("EXECUTION_REBIND_INTEGER_INVALID", 400 \n' - ) + old = " or attempt < 1\n" + new = " or attempt < 0\n" if new in text: - print("OK already patched: pre-claim attempt=0 rebind") + print("OK already patched: pre-claim attempt=0") else: count = text.count(old) if count != 1: - die(f"expected exactly one attempt validation block, found {count}") + die(f"expected exactly one attempt<1 guard, found {count}") b = backup(path) - text = text.replace(old, new, 1) - path.write_text(text, encoding="utf-8") - print(f"PATCHED pre-claim attempt=0 rebind; backup={b}") + path.write_text(text.replace(old, new, 1), encoding="utf-8") + print(f"PATCHED pre-claim attempt=0; backup={b}") ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) current = path.read_text(encoding="utf-8") - required_markers = ( - 'or attempt < 0', - 'EXECUTION_REBIND_NON_FAST_FORWARD_DENY', - 'old_expected_branch_oid', - 'new_expected_branch_oid', - ) - missing = [m for m in required_markers if m not in current] - if missing: - die("required marker missing: " + ",".join(missing)) + for marker in ( + "or attempt < 0", + "EXECUTION_REBIND_NON_FAST_FORWARD_DENY", + "old_expected_branch_oid", + "new_expected_branch_oid", + ): + if marker not in current: + die(f"required marker missing: {marker}") print(f"OK syntax: {path}") print("RESULT: PRECLAIM_REBIND_PATCH_OK")