Skip to content

refactor(ses): split 7,464-line service.rs into sub-modules#285

Merged
vieiralucas merged 2 commits intomainfrom
worktree-split-ses
Apr 12, 2026
Merged

refactor(ses): split 7,464-line service.rs into sub-modules#285
vieiralucas merged 2 commits intomainfrom
worktree-split-ses

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

  • Splits monolithic 7,464-line service.rs into 9 focused sub-modules
  • mod.rs (3,908 lines): struct, dispatch, helpers, tests
  • misc.rs (1,622 lines): tags, dedicated IPs, import/export jobs
  • configuration_sets.rs (500 lines): config set CRUD + event destinations
  • identities.rs (490 lines): email identity operations
  • contact_lists.rs (440 lines): contact list + contact CRUD
  • templates.rs (222 lines): email template CRUD
  • account.rs (173 lines): account settings, VDM
  • sending.rs (160 lines): SendEmail, SendBulkEmail
  • suppression.rs (120 lines): suppression list operations
  • Updates conformance audit paths for split

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings passes clean
  • All 139 SES unit tests pass
  • CI passes
  • Cubic review passes

Summary by cubic

Split the 7,464-line SES service.rs into 9 focused modules to improve maintainability and navigation. Updated conformance audit to detect both the new module layout and the legacy file so checks continue to pass.

  • Refactors
    • Replaced monolith crates/fakecloud-ses/src/service.rs with: account.rs, configuration_sets.rs, identities.rs, contact_lists.rs, templates.rs, sending.rs, suppression.rs, misc.rs, and mod.rs (struct, dispatch, helpers, tests).
    • Updated crates/fakecloud-conformance/src/audit.rs to include both service/mod.rs and service.rs for SES.
    • No behavior changes; APIs and request handling are unchanged.

Written for commit 8d46b8f. Summary will update on new commits.

Split monolithic service.rs into 9 files following the SSM pattern:
- mod.rs: struct, dispatch, helpers, tests (3,908 lines)
- misc.rs: tags, dedicated IPs, import/export jobs (1,622 lines)
- configuration_sets.rs: config set CRUD + event destinations (500 lines)
- identities.rs: email identity operations (490 lines)
- contact_lists.rs: contact list + contact CRUD (440 lines)
- templates.rs: email template CRUD (222 lines)
- account.rs: account settings, VDM (173 lines)
- sending.rs: SendEmail, SendBulkEmail (160 lines)
- suppression.rs: suppression list operations (120 lines)

Also updates conformance audit paths for the SES split.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 10 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/fakecloud-ses/src/service/misc.rs">

<violation number="1" location="crates/fakecloud-ses/src/service/misc.rs:472">
P2: Managed dedicated IP generation is based on pool count, which can reuse existing IP keys and overwrite another pool’s dedicated IP records after pool deletions/re-creations.</violation>
</file>

<file name="crates/fakecloud-ses/src/service/configuration_sets.rs">

<violation number="1" location="crates/fakecloud-ses/src/service/configuration_sets.rs:356">
P2: Configuration-set existence is checked before taking the write lock, which creates a race where a concurrent delete can still allow insertion of an event destination for a deleted set.</violation>
</file>

<file name="crates/fakecloud-ses/src/service/templates.rs">

<violation number="1" location="crates/fakecloud-ses/src/service/templates.rs:208">
P3: Use a Content-Type that matches the rendered body (text/plain when only Text is present).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


// For MANAGED pools, generate some fake IPs
if scaling_mode == "MANAGED" {
let pool_idx = state.dedicated_ip_pools.len() as u8;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Managed dedicated IP generation is based on pool count, which can reuse existing IP keys and overwrite another pool’s dedicated IP records after pool deletions/re-creations.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-ses/src/service/misc.rs, line 472:

<comment>Managed dedicated IP generation is based on pool count, which can reuse existing IP keys and overwrite another pool’s dedicated IP records after pool deletions/re-creations.</comment>

<file context>
@@ -0,0 +1,1622 @@
+
+        // For MANAGED pools, generate some fake IPs
+        if scaling_mode == "MANAGED" {
+            let pool_idx = state.dedicated_ip_pools.len() as u8;
+            for i in 1..=3 {
+                let ip_addr = format!("198.51.100.{}", pool_idx * 10 + i);
</file context>
Fix with Cubic

) -> Result<AwsResponse, AwsServiceError> {
let body: Value = Self::parse_body(req)?;

let state_read = self.state.read();
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Configuration-set existence is checked before taking the write lock, which creates a race where a concurrent delete can still allow insertion of an event destination for a deleted set.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-ses/src/service/configuration_sets.rs, line 356:

<comment>Configuration-set existence is checked before taking the write lock, which creates a race where a concurrent delete can still allow insertion of an event destination for a deleted set.</comment>

<file context>
@@ -0,0 +1,500 @@
+    ) -> Result<AwsResponse, AwsServiceError> {
+        let body: Value = Self::parse_body(req)?;
+
+        let state_read = self.state.read();
+        if !state_read.configuration_sets.contains_key(config_set_name) {
+            return Ok(Self::json_error(
</file context>
Fix with Cubic

// Build a simplified MIME message
let mut mime = format!("Subject: {}\r\n", rendered_subject);
mime.push_str("MIME-Version: 1.0\r\n");
mime.push_str("Content-Type: text/html; charset=UTF-8\r\n");
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Use a Content-Type that matches the rendered body (text/plain when only Text is present).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-ses/src/service/templates.rs, line 208:

<comment>Use a Content-Type that matches the rendered body (text/plain when only Text is present).</comment>

<file context>
@@ -0,0 +1,222 @@
+        // Build a simplified MIME message
+        let mut mime = format!("Subject: {}\r\n", rendered_subject);
+        mime.push_str("MIME-Version: 1.0\r\n");
+        mime.push_str("Content-Type: text/html; charset=UTF-8\r\n");
+        mime.push_str("\r\n");
+        if let Some(ref html) = rendered_html {
</file context>
Fix with Cubic

# Conflicts:
#	crates/fakecloud-conformance/src/audit.rs
@vieiralucas vieiralucas merged commit dd29383 into main Apr 12, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-split-ses branch April 12, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant