---
type: "Source File"
title: "!/usr/bin/env python3"
description: "#!/usr/bin/env python3 \"\"\"Add the manual-override escape hatch to publish_gate.claim_slot.\"\"\" import io import py_compile import sys P = \"publish_gate.py\" src = io.open(P, encoding=\"utf-8\").read() if."
resource: "https://www.copecheck.com"
tags: ["copecheck", "main", "source-file", "py"]
timestamp: "2026-09-25T16:30:37Z"
site: "main"
source_path: "copecheck/patch_gate2.py"
---

# !/usr/bin/env python3

Source path: `copecheck/patch_gate2.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-09-25T16:30:37Z`

```py
#!/usr/bin/env python3
"""Add the manual-override escape hatch to publish_gate.claim_slot."""
import io
import py_compile
import sys

P = "publish_gate.py"
src = io.open(P, encoding="utf-8").read()

if "manual_override_active" not in src:
    anchor = '''def today_utc():'''
    assert src.count(anchor) == 1
    src = src.replace(anchor, '''def manual_override_active():
    """True when this process is acting on Ben's behalf rather than a scanner.

    Set COPECHECK_PUBLISH_MANUAL=1 for interactive/manual runs (the URL
    submission processor, an admin CLI). Manual publishes are recorded for
    audit but never blocked and never counted against the daily cap, so Ben
    can always add something himself on a day the scanners have filled it.
    """
    return os.environ.get("COPECHECK_PUBLISH_MANUAL", "").strip().lower() in (
        "1", "true", "yes", "on",
    )


''' + anchor)

    old = "    exempt = 1 if manual else 0"
    assert src.count(old) == 1, "claim_slot exempt line not found"
    src = src.replace(old, "    exempt = 1 if (manual or manual_override_active()) else 0")

    io.open(P, "w", encoding="utf-8").write(src)
    print("publish_gate.py patched with manual override")
else:
    print("publish_gate.py already has manual override")

py_compile.compile(P, doraise=True)
final = io.open(P, encoding="utf-8").read()
assert "manual_override_active()" in final
assert "COPECHECK_PUBLISH_MANUAL" in final
print("VERIFIED publish_gate.py")
```
