[Debt] Decompose Campaign delivery, report, and version decision paths #83

Closed
opened 2026-07-29 13:25:58 +02:00 by zemion · 2 comments
Owner

Problem

The security/complexity audit still finds decision-heavy Campaign paths in job report assembly, request validation, version build/update/fork, delivery evidence/status reconciliation, sent-copy persistence, and Postbox attachment mapping. These paths affect audit evidence and outcome classification, so blind mechanical splitting is not sufficient.

Hotspots

  • _campaign_jobs_page_response
  • ReportEmailRequest validation
  • build_campaign_version, update_campaign_version, fork_campaign_version_for_edit
  • _JobReportAggregate.add, _job_evidence_row, _final_multichannel_status
  • append_sent_for_job
  • Postbox _attachments

Acceptance criteria

  • Pure decision tables are separated from I/O and persistence.
  • Delivery status precedence and outcome-unknown behavior have exhaustive tests.
  • Evidence writes remain append-only/idempotent where required.
  • Request validation reports actionable field-level errors.
  • Campaign passes the configured Xenon threshold without broad ignores.
## Problem The security/complexity audit still finds decision-heavy Campaign paths in job report assembly, request validation, version build/update/fork, delivery evidence/status reconciliation, sent-copy persistence, and Postbox attachment mapping. These paths affect audit evidence and outcome classification, so blind mechanical splitting is not sufficient. ## Hotspots - `_campaign_jobs_page_response` - `ReportEmailRequest` validation - `build_campaign_version`, `update_campaign_version`, `fork_campaign_version_for_edit` - `_JobReportAggregate.add`, `_job_evidence_row`, `_final_multichannel_status` - `append_sent_for_job` - Postbox `_attachments` ## Acceptance criteria - Pure decision tables are separated from I/O and persistence. - Delivery status precedence and outcome-unknown behavior have exhaustive tests. - Evidence writes remain append-only/idempotent where required. - Request validation reports actionable field-level errors. - Campaign passes the configured Xenon threshold without broad ignores. <!-- campaign-delivery-report-complexity-20260729 -->
Author
Owner

Codex State: reviewed

Reviewed after the current push. This remains open: fresh Xenon still reports decision-heavy Campaign paths in job page response assembly, report request validation, version build/update/fork, evidence aggregation/status precedence, sent-copy persistence, and Postbox attachment mapping. The configured threshold still fails.

## Codex State: reviewed Reviewed after the current push. This remains open: fresh Xenon still reports decision-heavy Campaign paths in job page response assembly, report request validation, version build/update/fork, evidence aggregation/status precedence, sent-copy persistence, and Postbox attachment mapping. The configured threshold still fails.
Author
Owner

Implemented and pushed in dd9592a.

  • Extracted campaign job paging, report aggregation/evidence, version fork/update/build, Postbox attachment mapping, and IMAP append orchestration into focused decision/effect helpers.
  • Added an explicit multichannel delivery decision table with outcome-unknown and temporary-rejection precedence tests across every delivery policy.
  • Report recipient validation now reports the failing list item (to.<index>) while retaining normalization and case-insensitive deduplication.
  • Durable IMAP claims, lost-claim handling, append-attempt evidence, and post-provider persistence failure behavior remain intact and covered by regression tests.

Verification: 262 passed, 16 subtests passed; Ruff clean; Xenon --max-absolute C --max-modules B --max-average A clean.

Implemented and pushed in `dd9592a`. - Extracted campaign job paging, report aggregation/evidence, version fork/update/build, Postbox attachment mapping, and IMAP append orchestration into focused decision/effect helpers. - Added an explicit multichannel delivery decision table with outcome-unknown and temporary-rejection precedence tests across every delivery policy. - Report recipient validation now reports the failing list item (`to.<index>`) while retaining normalization and case-insensitive deduplication. - Durable IMAP claims, lost-claim handling, append-attempt evidence, and post-provider persistence failure behavior remain intact and covered by regression tests. Verification: `262 passed, 16 subtests passed`; Ruff clean; Xenon `--max-absolute C --max-modules B --max-average A` clean.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GovOPlaN/govoplan-campaign#83