R-325 (felhom.eu half): hub_copy_gate accepts the controller gate importing the shared stem list

Once retrieval_promise_gate.py imports customer_copy_vocab and drops its STEMS literal, the drift
check reads "ok — single source" instead of failing on the missing literal. An import only in a
comment, or beside a stale literal, is still drift. Pinned by scripts/test_hub_copy_drift.py.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-05 21:35:08 +02:00
parent 900e6d86e2
commit 7ee00d59a8
2 changed files with 59 additions and 3 deletions
+16 -3
View File
@@ -189,18 +189,31 @@ def scan_stems():
return convictions, seen
def check_drift():
# R-325: the destination — the controller gate IMPORTS the shared list instead of carrying a literal.
# Matched at the start of a line, so an import written only in a `#` comment does not count.
_SHARED_IMPORT_RE = re.compile(
r"^(?:from\s+customer_copy_vocab\s+import\s+[^\n]*\bRETRIEVAL_STEMS\b|import\s+customer_copy_vocab\b)", re.M)
def check_drift(sibling=None):
"""The controller gate's STEMS must equal the shared list. Returns (status, message).
status: "ok" | "drift" | "inconclusive"
R-325: once the controller gate imports `customer_copy_vocab` and carries NO `STEMS` literal of its
own, the two cannot diverge and that is "ok". A literal, if present, is still compared — an import
beside a stale literal is drift. Pinned by scripts/test_hub_copy_drift.py.
"""
sibling = os.path.join(os.path.dirname(_REPO), "felhom-controller",
"controller", "scripts", "retrieval_promise_gate.py")
if sibling is None:
sibling = os.path.join(os.path.dirname(_REPO), "felhom-controller",
"controller", "scripts", "retrieval_promise_gate.py")
if not os.path.exists(sibling):
return "inconclusive", ("the felhom-controller clone is absent, so the shared stem list "
"could not be compared against the gate that also uses it (%s)" % sibling)
text = open(sibling, encoding="utf-8").read()
m = re.search(r"^STEMS\s*=\s*\[(.*?)\]", text, re.M | re.S)
if not m and _SHARED_IMPORT_RE.search(text):
return "ok", "controller gate imports the shared list (customer_copy_vocab.py) — single source"
if not m:
return "drift", "could not find a STEMS list in the controller gate — its shape changed"
theirs = re.findall(r"[\"']([^\"']+)[\"']", m.group(1))