[Debt] Refactor high-complexity campaign validation, sending, and reporting code #54

Closed
opened 2026-07-11 12:51:21 +02:00 by zemion · 3 comments
Owner

Xenon/Radon show several E/F/D-ranked campaign functions. This is the largest maintainability cluster in the full audit.

Classification: structural maintainability work.

Report evidence:

  • validate_campaign_config rank F.
  • validate_campaign_partial rank F.
  • run_mock_campaign_send rank F.
  • build_entry_message rank E.
  • _campaign_workspace_delta_response rank E.
  • generate_campaign_report rank E.
  • send_campaign_job, _update_campaign_after_job rank D.

Suggested next steps:

  • Prioritize validation and message-building first, because they are user-facing and security-adjacent.
  • Extract smaller pure helpers with fixtures for ZIP/attachment/message/report paths.
  • Keep behavior stable and reduce one cluster per PR.

Baseline report directory: audit-reports/govoplan-full-20260711-1238

<!-- codex-audit-full-2026-07-11:campaign-complexity-baseline --> Xenon/Radon show several E/F/D-ranked campaign functions. This is the largest maintainability cluster in the full audit. Classification: **structural maintainability work**. Report evidence: - `validate_campaign_config` rank F. - `validate_campaign_partial` rank F. - `run_mock_campaign_send` rank F. - `build_entry_message` rank E. - `_campaign_workspace_delta_response` rank E. - `generate_campaign_report` rank E. - `send_campaign_job`, `_update_campaign_after_job` rank D. Suggested next steps: - Prioritize validation and message-building first, because they are user-facing and security-adjacent. - Extract smaller pure helpers with fixtures for ZIP/attachment/message/report paths. - Keep behavior stable and reduce one cluster per PR. Baseline report directory: `audit-reports/govoplan-full-20260711-1238`
zemion added the
type
debt
priority
p3
status
ready
module/campaign
codex/ready
labels 2026-07-11 12:51:21 +02:00
zemion added the
audit/complexity
audit/structural
source/security-audit
labels 2026-07-11 16:10:09 +02:00
Author
Owner

Codex State: progress

Summary

  • Current Xenon state after the latest cleanup: validate_campaign_partial and build_entry_message are no longer above threshold.
  • Remaining campaign hotspots are validate_campaign_config and ZIP configuration validation; mock campaign sending; workspace delta/review metadata routing; review-state persistence; campaign report generation; and send-job/update orchestration.
  • Closing newer duplicate tracker govoplan-campaign#58 as superseded by this issue.

Verification

  • xenon --max-absolute C on src/govoplan_campaign still reports the remaining blocks listed above.

Next / Blocked

  • Tackle one cluster at a time, starting with semantic validation or mock sending, with focused fixtures.

Suggested status label: status/in-progress

## Codex State: progress ### Summary - Current Xenon state after the latest cleanup: validate_campaign_partial and build_entry_message are no longer above threshold. - Remaining campaign hotspots are validate_campaign_config and ZIP configuration validation; mock campaign sending; workspace delta/review metadata routing; review-state persistence; campaign report generation; and send-job/update orchestration. - Closing newer duplicate tracker govoplan-campaign#58 as superseded by this issue. ### Verification - `xenon --max-absolute C on src/govoplan_campaign still reports the remaining blocks listed above.` ### Next / Blocked - Tackle one cluster at a time, starting with semantic validation or mock sending, with focused fixtures. Suggested status label: `status/in-progress`
Author
Owner

Codex State: progress

Summary

  • Implemented another campaign complexity slice: semantic campaign validation now delegates global, ZIP, delivery, entries, and file checks; mock campaign send now delegates per-message send/append handling and counters.
  • Current Xenon state: validate_campaign_config, _zip_configuration_issues, and run_mock_campaign_send no longer appear in campaign threshold violations.

Changed Files

  • src/govoplan_campaign/backend/campaign/validation.py
  • src/govoplan_campaign/backend/dev/mock_campaign.py
  • tests/test_partial_validation.py

Verification

  • python -m py_compile src/govoplan_campaign/backend/campaign/validation.py src/govoplan_campaign/backend/dev/mock_campaign.py tests/test_partial_validation.py
  • python -m unittest discover tests
  • xenon passes for validation.py and mock_campaign.py individually

Next / Blocked

  • Remaining campaign complexity is concentrated in router delta/review metadata, review-state persistence, report generation, and send-job orchestration.

Suggested status label: status/in-progress

## Codex State: progress ### Summary - Implemented another campaign complexity slice: semantic campaign validation now delegates global, ZIP, delivery, entries, and file checks; mock campaign send now delegates per-message send/append handling and counters. - Current Xenon state: validate_campaign_config, _zip_configuration_issues, and run_mock_campaign_send no longer appear in campaign threshold violations. ### Changed Files - `src/govoplan_campaign/backend/campaign/validation.py` - `src/govoplan_campaign/backend/dev/mock_campaign.py` - `tests/test_partial_validation.py` ### Verification - `python -m py_compile src/govoplan_campaign/backend/campaign/validation.py src/govoplan_campaign/backend/dev/mock_campaign.py tests/test_partial_validation.py` - `python -m unittest discover tests` - `xenon passes for validation.py and mock_campaign.py individually` ### Next / Blocked - Remaining campaign complexity is concentrated in router delta/review metadata, review-state persistence, report generation, and send-job orchestration. Suggested status label: `status/in-progress`
Author
Owner

Codex State: done

Summary

  • Refactored the remaining campaign complexity hotspots from the audit: validation helpers, mock campaign send flow, report generation, review state handling, workspace delta/review metadata, delivery status finalization, and send_campaign_job orchestration.
  • Full campaign Xenon now passes with --max-absolute C --max-modules B --max-average A.

Changed Files

  • src/govoplan_campaign/backend/campaign/validation.py
  • src/govoplan_campaign/backend/dev/mock_campaign.py
  • src/govoplan_campaign/backend/persistence/versions.py
  • src/govoplan_campaign/backend/reports/campaigns.py
  • src/govoplan_campaign/backend/router.py
  • src/govoplan_campaign/backend/sending/jobs.py
  • tests/test_partial_validation.py

Verification

  • /mnt/DATA/git/govoplan/.venv/bin/xenon --max-absolute C --max-modules B --max-average A src/govoplan_campaign: PASS
  • /mnt/DATA/git/govoplan/.venv/bin/python -m unittest discover tests: PASS (7 tests)
## Codex State: done ### Summary - Refactored the remaining campaign complexity hotspots from the audit: validation helpers, mock campaign send flow, report generation, review state handling, workspace delta/review metadata, delivery status finalization, and send_campaign_job orchestration. - Full campaign Xenon now passes with --max-absolute C --max-modules B --max-average A. ### Changed Files - `src/govoplan_campaign/backend/campaign/validation.py` - `src/govoplan_campaign/backend/dev/mock_campaign.py` - `src/govoplan_campaign/backend/persistence/versions.py` - `src/govoplan_campaign/backend/reports/campaigns.py` - `src/govoplan_campaign/backend/router.py` - `src/govoplan_campaign/backend/sending/jobs.py` - `tests/test_partial_validation.py` ### Verification - `/mnt/DATA/git/govoplan/.venv/bin/xenon --max-absolute C --max-modules B --max-average A src/govoplan_campaign: PASS` - `/mnt/DATA/git/govoplan/.venv/bin/python -m unittest discover tests: PASS (7 tests)`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: add-ideas/govoplan-campaign#54
No description provided.