fix(cron): deliver the drift-skip alert untruncated

The generic failure summarizer caps unrecognized errors at 180 chars,
which cut the drift alert off mid-sentence before the pin command. The
drift branch now formats its own delivery from the guard's full message,
so the one alert the operator gets actually contains the fix.
This commit is contained in:
Victor Kyriazakos 2026-08-13 03:26:13 +00:00 committed by Teknium
parent e6ce8c37f1
commit 422c3eaa18
2 changed files with 14 additions and 5 deletions

View File

@ -4879,12 +4879,17 @@ def run_one_job(
else:
deliver_content = final_response if success else _summarize_cron_failure_for_delivery(job, error)
if drift_skip and not success:
# Drift-skip alert: strip the internal marker from the
# user-facing text (the summarizer passes the message
# through its generic tail).
deliver_content = re.sub(
r"\[drift_skip[^\]]*\]\s*", "", deliver_content
# Drift-skip alert: bypass the generic summarizer's
# 180-char truncation (it would eat the remediation
# command) and strip the internal marker — deliver the
# guard's own actionable message intact.
_drift_text = re.sub(
r"\[drift_skip[^\]]*\]\s*", "", str(error)
).strip()
deliver_content = (
f"⚠️ Cron '{job.get('name') or job['id']}' skipped: "
f"{_drift_text}"
)
# Treat whitespace-only final responses the same as empty
# responses: do not deliver a blank message, and let the
# empty-response guard below mark the run as a soft failure.

View File

@ -92,6 +92,10 @@ class TestDriftAlertOnce:
blob = deliveries[0].lower()
assert "drift" in blob
assert "pin" in blob
# The single alert must carry the complete remediation command —
# the generic summarizer's 180-char truncation must not eat it.
assert "cronjob action=update" in deliveries[0]
assert "[drift_skip" not in deliveries[0]
def test_healed_drift_clears_bit_and_redrift_realerts(self, tmp_path):
job = _job()