dm.py: autoprovision creation check — refuse to adopt parked/already-mapped thread UUIDs (fixes 2026-10-04 heartbeat misroute)

This commit is contained in:
operator-main
2026-10-04 21:16:50 +00:00
parent 1e82f3adba
commit 7902622852
2 changed files with 189 additions and 31 deletions
+62
View File
@@ -656,6 +656,68 @@ def test_wired_dm_send_asserts_post_nav_url_before_send():
"post-send, which is a different (later) check.")
# --------------------------------------------------------------------------
# wiring: dm.py autoprovision creation check (2026-10-04 fix)
# --------------------------------------------------------------------------
_ADOPT_PARKED = "bf7bf3e1-3ee8-4816-9b66-b77b34387986" # the 19:50 incident UUID
_ADOPT_NEW = "aaaaaaaa-1111-2222-3333-444444444444"
def _dm_mod():
return _load("dm_under_test", "dm.py")
def test_wired_adopt_genuine_new_uuid():
dm = _dm_mod()
ok, why = dm.autoprovision_adopt_ok(
_ADOPT_NEW, _ADOPT_PARKED,
{"pipe-1b4579": {"thread_uuid": _ADOPT_PARKED, "agent": "opm"}},
"heartbeat")
assert ok is True and why == "new_thread", (ok, why)
def test_wired_adopt_refuses_parked_thread():
# the 2026-10-04 19:50 UTC incident: captured == pre-create parked UUID
dm = _dm_mod()
ok, why = dm.autoprovision_adopt_ok(
_ADOPT_PARKED, _ADOPT_PARKED,
{"pipe-1b4579": {"thread_uuid": _ADOPT_PARKED, "agent": "opm"}},
"heartbeat")
assert ok is False and "matches_pre_create_parked_thread" in why, (ok, why)
def test_wired_adopt_refuses_already_mapped_elsewhere():
dm = _dm_mod()
ok, why = dm.autoprovision_adopt_ok(
_ADOPT_PARKED, None,
{"pipe-1b4579": {"thread_uuid": _ADOPT_PARKED, "agent": "opm"}},
"heartbeat")
assert ok is False and "already_mapped_under_pipe-1b4579" in why, (ok, why)
def test_wired_adopt_same_target_readopt_allowed():
dm = _dm_mod()
ok, why = dm.autoprovision_adopt_ok(
_ADOPT_PARKED, "99999999-1111-2222-3333-444444444444",
{"pipe-1b4579": {"thread_uuid": _ADOPT_PARKED, "agent": "opm"}},
"pipe-1b4579")
assert ok is True, (ok, why)
def test_wired_adopt_empty_capture_refused():
dm = _dm_mod()
for cap in (None, ""):
ok, why = dm.autoprovision_adopt_ok(cap, _ADOPT_PARKED, {}, "heartbeat")
assert ok is False and "no_uuid_captured" in why, (cap, ok, why)
def test_wired_adopt_fresh_uuid_empty_map():
dm = _dm_mod()
ok, why = dm.autoprovision_adopt_ok(_ADOPT_NEW, None, {}, "heartbeat")
assert ok is True and why == "new_thread", (ok, why)
# --------------------------------------------------------------------------
# runner (also pytest-compatible: plain test_* functions, no args)
# --------------------------------------------------------------------------