Memory Wiki

Untitled Session

2026-05-24 19:46 UTC · 50 messages · cli

You2026-05-24 19:49 UTC
TA: Write 4 build briefs for Module 4 (Email) — T21 (Brevo Service), T22 (Mail Queue), T23 (Email Templates), T24 (Email Admin). Each brief must incorporate FAULT-013 through FAULT-017 fixes as applicable, include interface contracts, schema, events, routes, and min 12 tests per module.
Donna2026-05-24 19:49 UTC
I'll start by reading all the context material to understand the requirements thoroughly.
Tool2026-05-24 19:49 UTC
{"content": " 1|# Project Brief: Module 4 — Email\n 2|\n 3|**Document ID:** PB-M4-EMAIL-001\n 4|**Author:** SA (Super Architect)\n 5|**Date:** 2026-05-24\n 6|**Status:** RECONCILED — reconciled against existing codebase at /root/profe-modules/\n 7|**Build Plan Source:** B...
Tool2026-05-24 19:49 UTC
{"content": " 1|# Past Faults Log — Profe Core Modules\n 2|\n 3|> **Purpose:** Every bug, design miss, and edge case discovered during development is recorded here.\n 4|> Future modules (and future TBs) MUST read this log before writing code.\n 5|\n 6|---\n 7|\n 8|## ...
Tool2026-05-24 19:49 UTC
{"content": " 516|### Module Module 4 — Email (Site Areas: 8, 9, 13)\n 517|\n 518|**Goal:** Brevo transactional email with mail queue.\n 519|\n 520|**Modules (4):** T21-T24\n 521|\n 522|| # | Module | Responsibility | New Tables | Depends On (Locked) |\n 523||---|--------|-----------...
Tool2026-05-24 19:49 UTC
{"total_count": 1, "files": ["/root/.hermes/plans/task-t11-build-plan.md"]}
Donna2026-05-24 19:49 UTC
Now let me read the T11 build plan format and examine the existing code:
Tool2026-05-24 19:49 UTC
{"content": " 1|# Build Plan: T11 — mem_levels (Membership Tier Definitions)\n 2|\n 3|**Module:** Module 2 — Membership\n 4|**Build Order:** 1 of 4 (Module 2)\n 5|**Subsequent Tasks:** T12 (mem_data), T13 (access_control), T14 (member_admin)\n 6|**Status:** PLANNED\n 7|**...
Tool2026-05-24 19:49 UTC
{"total_count": 14, "files": ["/root/profe-modules/brevo_service/src/BrevoService/Migration/CreateBrevoWebhookEventsMigration.php", "/root/profe-modules/brevo_service/tests/Unit/BrevoApiClientTest.php", "/root/profe-modules/brevo_service/tests/Unit/BrevoServiceModuleTest.php", "/root/profe-modules/b...
Tool2026-05-24 19:49 UTC
{"total_count": 14, "files": ["/root/profe-modules/mail_queue/src/MailQueue/Migration/CreateMailQueueMigration.php", "/root/profe-modules/mail_queue/tests/Integration/MailQueueIntegrationTest.php", "/root/profe-modules/mail_queue/tests/Unit/MailQueueRepositoryTest.php", "/root/profe-modules/mail_que...
Tool2026-05-24 19:49 UTC
{"total_count": 14, "files": ["/root/profe-modules/email_templates/src/EmailTemplates/Migration/CreateEmailTemplatesMigration.php", "/root/profe-modules/email_templates/tests/Integration/EmailTemplatesIntegrationTest.php", "/root/profe-modules/email_templates/tests/Unit/EmailTemplatesModuleTest.php"...
Tool2026-05-24 19:49 UTC
{"total_count": 11, "files": ["/root/profe-modules/email_admin/tests/Integration/EmailAdminIntegrationTest.php", "/root/profe-modules/email_admin/tests/Unit/EmailAdminModuleTest.php", "/root/profe-modules/email_admin/tests/Unit/EmailAdminRepositoryTest.php", "/root/profe-modules/email_admin/tests/Un...
Donna2026-05-24 19:49 UTC
Let me look at the existing code files to understand the current implementations:
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * BrevoServiceInterface — Service contract for Brevo API v3 wrapper\n 4| *\n 5| * HC-01: Brevo API v3 REST call wrapper.\n 6| * HC-02: Webhook signature verification via secret matching.\n 7| *\n 8| * @package Profe\\BrevoService\n ...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * BrevoService — Brevo API v3 wrapper implementation\n 4| *\n 5| * FAULT-008: All declared dependencies injected in constructor.\n 6| * HC-01: Brevo API v3 REST call wrapper using wp_remote_post()/wp_remote_get().\n 7| * HC-04: Webhook r...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * BrevoServiceModule — ModuleInstanceInterface implementation for brevo_service\n 4| *\n 5| * HC-04: Webhook route CSRF/Auth exempt (via CsrfMiddleware).\n 6| * HC-07: Migration registered in boot().\n 7| * FAULT-004: Admin POST endpoint...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * BrevoApiClient — Thin HTTP wrapper around Brevo REST API v3\n 4| *\n 5| * HC-01: Uses wp_remote_post() / wp_remote_get() (WordPress HTTP API).\n 6| * HC-05: 15-min transient cache for getAccountInfo().\n 7| * HC-06: Rate limit handling...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * MailQueueInterface — Service contract for email queue\n 4| *\n 5| * HC-01: No email sending during web request — all deferred to queue.\n 6| * HC-02: Idempotency via UNIQUE KEY on idempotency_key.\n 7| * HC-03: Exponential backoff: nex...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * MailQueue — Email queue implementation\n 4| *\n 5| * FAULT-008: All declared dependencies injected in constructor.\n 6| * HC-01: No email sending during web request — all deferred to queue.\n 7| * HC-02: Idempotency via UNIQUE KEY on i...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * MailQueueModule — ModuleInstanceInterface implementation for mail_queue\n 4| *\n 5| * FAULT-004: POST endpoints use checkAdminAccessWithCsrf() calling requireValidNonce().\n 6| * FAULT-01: Factory closure captures $c, never stores containe...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * MailQueueProcessor — Cron processing logic for mail queue\n 4| *\n 5| * HC-01: No email sending during web request — all deferred to queue.\n 6| * HC-03: Exponential backoff: next_retry_at = NOW() + (2^attempts * 60), max 5 retries.\n ...
Donna2026-05-24 19:49 UTC
Now let me read the remaining files:
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailTemplatesInterface — Service contract for email template management\n 4| *\n 5| * HC-01: Template variable substitution via {{variable}} syntax.\n 6| * HC-02: Required variable validation before rendering.\n 7| *\n 8| * @packa...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailTemplates — Email template management implementation\n 4| *\n 5| * FAULT-008: All declared dependencies injected in constructor.\n 6| * HC-01: Template variable substitution via {{variable}} syntax.\n 7| * HC-02: Required variable...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailTemplatesModule — ModuleInstanceInterface implementation for email_templates\n 4| *\n 5| * FAULT-004: CSRF enforced on POST/PUT/DELETE endpoints via checkAdminAccessWithCsrf().\n 6| * FAULT-01: Factory closure captures $c, never store...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailAdminInterface — Service contract for email administration API\n 4| *\n 5| * HC-01: No new tables — reads only from existing profe_* tables.\n 6| * HC-04: Preview does NOT send — pure rendering.\n 7| *\n 8| * @package Profe\\E...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailAdminService — Email administration API implementation\n 4| *\n 5| * FAULT-008: All declared dependencies injected in constructor.\n 6| * HC-01: No new tables — reads only from existing profe_* tables.\n 7| * HC-03: Test email goe...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * EmailAdminModule — ModuleInstanceInterface implementation for email_admin\n 4| *\n 5| * FAULT-004: POST endpoints use checkAdminAccessWithCsrf() calling requireValidNonce().\n 6| * FAULT-01: Factory closure captures $c, never stores contai...
Donna2026-05-24 19:49 UTC
Let me also check the existing migrations and test files:
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * CreateBrevoWebhookEventsMigration — Migration for profe_brevo_webhook_events table\n 4| *\n 5| * FAULT-006: PHP migration class with up/down SQL referencing the SQL file.\n 6| * HC-03: Idempotency via UNIQUE KEY defined in DDL.\n 7| *\...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * CreateEmailTemplatesMigration — Migration for profe_email_templates table\n 4| *\n 5| * FAULT-006: PHP migration class with up/down SQL.\n 6| * HC-05: 27 template IDs pre-defined in seed data.\n 7| *\n 8| * @package Profe\\EmailTem...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|/**\n 3| * BrevoServiceException — Typed exception for Brevo API errors\n 4| *\n 5| * @package Profe\\BrevoService\\Exception\n 6| */\n 7|\n 8|declare(strict_types=1);\n 9|\n 10|namespace Profe\\BrevoService\\Exception;\n 11|\n 1...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|declare(strict_types=1);\n 3|\n 4|namespace Profe\\BrevoService\\Test\\Unit;\n 5|\n 6|use PHPUnit\\Framework\\TestCase;\n 7|use Profe\\BrevoService\\BrevoService;\n 8|use Profe\\BrevoService\\BrevoServiceInterface;\n 9|use Profe\\BrevoSer...
Tool2026-05-24 19:49 UTC
{"content": " 1|<?php\n 2|declare(strict_types=1);\n 3|\n 4|namespace Profe\\MailQueue\\Test\\Unit;\n 5|\n 6|use PHPUnit\\Framework\\TestCase;\n 7|use Profe\\MailQueue\\MailQueue;\n 8|use Profe\\MailQueue\\MailQueueInterface;\n 9|use Profe\\MailQueue\\MailQueuePro...
Donna2026-05-24 19:49 UTC
Let me check the count of test methods in each module:
Tool2026-05-24 19:49 UTC
{"total_count": 21, "matches": [{"path": "/root/profe-modules/brevo_service/tests/Unit/BrevoServiceTest.php", "line": 34, "content": " public function testImplementsBrevoServiceInterface(): void"}, {"path": "/root/profe-modules/brevo_service/tests/Unit/BrevoServiceTest.php", "line": 42, "content"...
Tool2026-05-24 19:49 UTC
{"total_count": 17, "matches": [{"path": "/root/profe-modules/mail_queue/tests/Unit/MailQueueTest.php", "line": 39, "content": " public function testImplementsMailQueueInterface(): void"}, {"path": "/root/profe-modules/mail_queue/tests/Unit/MailQueueTest.php", "line": 47, "content": " public f...
Tool2026-05-24 19:49 UTC
{"total_count": 27, "matches": [{"path": "/root/profe-modules/email_templates/tests/Unit/EmailTemplatesModuleTest.php", "line": 13, "content": " public function testModuleNameReturnsEmailTemplates(): void"}, {"path": "/root/profe-modules/email_templates/tests/Unit/EmailTemplatesModuleTest.php", "...
Tool2026-05-24 19:49 UTC
{"total_count": 18, "matches": [{"path": "/root/profe-modules/email_admin/tests/Unit/EmailAdminServiceTest.php", "line": 42, "content": " public function testImplementsEmailAdminInterface(): void"}, {"path": "/root/profe-modules/email_admin/tests/Unit/EmailAdminServiceTest.php", "line": 50, "cont...
Donna2026-05-24 19:49 UTC
Now I have full context. All 4 modules already have ≥12 tests (21, 17, 27, 18 respectively), but the briefs will incorporate FAULT-013 through FAULT-017 fixes as applicable. Let me create all 4 build briefs now.
Tool2026-05-24 19:49 UTC
{"bytes_written": 19576, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-24 19:49 UTC
T21 done. Now creating T22 (Mail Queue):
Tool2026-05-24 19:49 UTC
{"bytes_written": 22679, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-24 19:49 UTC
T22 done. Now creating T23 (Email Templates):
Tool2026-05-24 19:49 UTC
{"bytes_written": 23520, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-24 19:49 UTC
T23 done. Now creating T24 (Email Admin):
Tool2026-05-24 19:49 UTC
{"bytes_written": 14666, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-24 19:49 UTC
Let me verify all 4 files exist:
Tool2026-05-24 19:49 UTC
{"output": "-rw-r--r-- 1 root root 41930 May 24 08:12 /root/.hermes/plans/task-t20-build-plan.md\n-rw-r--r-- 1 root root 19576 May 24 19:47 /root/.hermes/plans/task-t21-build-plan.md\n-rw-r--r-- 1 root root 22679 May 24 19:48 /root/.hermes/plans/task-t22-build-plan.md\n-rw-r--r-- 1 root root 23520 M...
Donna2026-05-24 19:49 UTC
All 4 build briefs are created. Here's the summary: --- ## Summary: What I Did ### Files Created 1. **`/root/.hermes/plans/task-t21-build-plan.md`** (19.6 KB) — Brevo Service 2. **`/root/.hermes/plans/task-t22-build-plan.md`** (22.7 KB) — Mail Queue 3. **`/root/.hermes/plans/task-t23-build-plan.md`** (23.5 KB) — Email Templates 4. **`/root/.hermes/plans/task-t24-build-plan.md`** (14.7 KB) — Email Admin ### Fault Incorporation Summary | Fault | Description | T21 | T22 | T23 | T24 | |-------|-------------|-----|-----|-----|-----| | **FAULT-013** | Webhook signature verification | ✅ Fix: call `verifyWebhookSignature()` in `handleBrevoWebhook()` before processing; return 401 on mismatch | N/A | N/A | N/A | | **FAULT-014** | Missing `wp_mail()` override | N/A | ✅ Fix: new `WpMailOverride` class hooking `phpmailer_init`; register in `MailQueueModule::boot()` | N/A | N/A | | **FAULT-015** | Template seed data missing | N/A | N/A | ✅ Fix: new `V002__SeedEmailTemplates` migration inserting 27 templates (15 transactional, 5 campaign, 7 system) | N/A | | **FAULT-016** | Zero test coverage | ✅ Verified 21 existing tests; add 4 new for sig verification (target: 25+) | ✅ Verified 17 existing tests; add 5 new for WpMailOverride (target: 22+) | ✅ Verified 27 existing tests; add 4 new for seed migration (target: 31+) | ✅ Verified 18 existing tests; add 2 new for FAULT-017/FAULT-002 (target: 20+) | | **FAULT-017** | Duplicate exception files | ✅ Fix: remove top-level `BrevoServiceException.php`; keep `Exception/` subdir; update imports | ✅ Fix: remove top-level `MailQueueException.php`; keep `Exception/` subdir; update imports | ✅ Fix: remove top-level `EmailTemplateException.php`; keep `Exception/` subdir; update imports | ✅ Fix: remove top-level `EmailAdminException.php`; keep `Exception/` subdir; update imports | ### Additional Faults Cross-Referenced - **FAULT-001** (price_amount comment) — Not applicable to Module 4 (no DECIMAL price columns) - **FAULT-002** (direct `profe_users` queries) — Documented as workaround in T21 (`BrevoService.php`), T22 (`MailQueue.php`), T24 (`EmailAdminRepository.php`) - **FAULT-004** (CSRF enforcement) — Already implemented in all 4 modules via `checkAdminAccessWithCsrf()` calling `requireValidNonce()` - **FAULT-006** (missing migration PHP classes) — All migrations already have PHP classes - **FAULT-007** (undocumented profe_users queries) — Fixed via FAULT-002 workaround comments - **FAULT-008** (dependencies not injected) — All 4 modules verified: constructor injection matches declared dependencies - **FAULT-011** (backslash issue) — Audit step included in all 4 briefs ### Key Findings 1. **All 4 modules already have ≥12 tests** — T21 has 21, T22 has 17, T23 has 27, T24 has 18. The briefs expand coverage further for the fault fixes. 2. **FAULT-013 fix location:** `BrevoServiceModule::handleBrevoWebhook()` — extract `brevo-signature` header, load `brevo.webhook_secret` from config, verify via `BrevoApiClient`, reject with 401 on failure. 3. **FAULT-014 approach:** `phpmailer_init` hook (cleaner than pluggable function override). Intercept PHPMailer, enqueue via `MailQueueInterface::enqueueToEmail()`, clear recipients to prevent WordPress native send. 4. **FAULT-015 seed data:** All 27 template IDs, names, categories, and required variables are documented per PB Appendix B. 5. **FAULT-017 clean-up:** Each module keeps only `src/{Module}/Exception/{Module}Exception.php` and removes the top-level duplicate.