diff --git a/apps/api/src/jobs/backup_restore_legacy_backfill_job.py b/apps/api/src/jobs/backup_restore_legacy_backfill_job.py index 04060260c..4d37f9ff5 100644 --- a/apps/api/src/jobs/backup_restore_legacy_backfill_job.py +++ b/apps/api/src/jobs/backup_restore_legacy_backfill_job.py @@ -46,7 +46,10 @@ BACKFILL_IDEMPOTENCY_CHANNEL = "backup_restore_backfill" BACKFILL_DB_CONTRACT_REPAIR_GENERATION = "cost_usd_state_bind_v1" LIVE_RECONCILE_SCHEMA_VERSION = "backup_restore_outbound_reconciler_v1" LIVE_RECONCILE_AGENT_ID = "backup_restore_outbound_reconciler" -LIVE_RECONCILE_IDEMPOTENCY_CHANNEL = "backup_restore_outbound_reconcile" +# ``awooop_run_idempotency.channel_type`` is VARCHAR(32). Keep this durable +# identity explicit and below that limit; the previous 33-character value +# caused PostgreSQL 22001 before a live backup card could be claimed. +LIVE_RECONCILE_IDEMPOTENCY_CHANNEL = "backup_restore_live_reconcile" BACKUP_RESTORE_EVENT_TYPE = "backup_restore_escrow_signal" BACKUP_RESTORE_LANE = "backup_restore_escrow_triage" PROJECTION_SCHEMA_VERSION = "telegram_agent99_dispatch_receipt_projection_v1" diff --git a/apps/api/tests/test_backup_restore_legacy_backfill_job.py b/apps/api/tests/test_backup_restore_legacy_backfill_job.py index 88aee8c88..6d9b59de2 100644 --- a/apps/api/tests/test_backup_restore_legacy_backfill_job.py +++ b/apps/api/tests/test_backup_restore_legacy_backfill_job.py @@ -576,6 +576,16 @@ async def test_live_reconciler_reserves_only_unowned_incomplete_cards( assert "backup-signal:" in sql +def test_live_reconciler_idempotency_channel_fits_durable_schema() -> None: + # awooop_run_idempotency.channel_type is VARCHAR(32). This invariant must + # be checked without relying on a mock database, which cannot reproduce a + # production PostgreSQL 22001 truncation error. + assert job.LIVE_RECONCILE_IDEMPOTENCY_CHANNEL == ( + "backup_restore_live_reconcile" + ) + assert len(job.LIVE_RECONCILE_IDEMPOTENCY_CHANNEL) <= 32 + + @pytest.mark.asyncio async def test_live_reconciler_projects_bounded_agent99_receipt( monkeypatch: pytest.MonkeyPatch,