Untitled Session
2026-05-25 06:31 UTC · 38 messages · cli
You2026-05-25 06:36 UTC
Write 3 detailed TA build briefs for Module 8 (Forms) at /root/.hermes/plans/task-t43/t44/t45-build-plan.md.
Read the PB at /root/.hermes/plans/pb-m8-forms.md for full specs. Each brief must be implementation-ready — TB should be able to code directly from it.
## T43 — Form Engine (the core)
Write to /root/.hermes/plans/task-t43-build-plan.md
Form schema CRUD. 11 field types. Conditional logic engine. Multi-step wizard. Form templates. Versioning. API endpoints.
**Interface**: FormEngineInterface with methods for CRUD forms, fields, conditional rules, templates, versions.
**Key specs from PB:**
- 11 field types: text, email, select, checkbox, radio, textarea, file_upload, stripe_payment, membership_tier, billing_interval, hidden
- Conditional logic as JSON rules: `{field_id, operator, value, action: show/hide/require, target_field_id}`
- Multi-step pages: forms have ordered page groups, each page can have conditional visibility
- Versioning: snapshot schema on each save, stored in profe_form_versions
- Templates: pre-built registration, payment, contact, survey
**Routes:**
- POST/GET forms
- PUT/DELETE forms/{id}
- GET forms/{id}/schema (returns compiled schema for frontend renderer)
- POST forms/{id}/fields
- PUT/DELETE forms/{id}/fields/{fieldId}
- POST forms/{id}/conditional-rules
- POST forms/templates (load from template)
- GET forms/templates
**Migration SQL**: 045_create_profe_form_schemas.sql, 046_create_profe_form_versions.sql. Must have -- UP / -- DOWN markers. Table naming: profe_form_schemas, profe_form_versions. Proper indexes.
## T44 — Form Submissions (the runtime)
Write to /root/.hermes/plans/task-t44-build-plan.md
Entry storage. Post-submit pipeline (8 configurable steps). Stripe Elements integration. WP user creation. Abandoned cart cron. Free vs paid fork.
**Interface**: FormSubmissionsInterface with methods for submit, getSubmission, getSubmissions, exportSubmissions, deleteSubmission, processPipeline, detectAbandoned.
**Pipeline steps (configurable per form):**
1. validate — validate fields + conditional rules + spam check
2. process_payment — create Stripe PaymentIntent, handle result
3. create_wp_user — wp_insert_user, password generated or user-provided
4. assign_membership — set profe_users.membership_level
5. sync_crm — crm_sync->enqueueContactCreate(userId)
6. send_notifications — mail_queue for confirmation + admin alert
7. track_conversion — Google Ads via google_ads_conversion
8. notify_admin — email to admin with submission details
**Abandoned cart:**
- Save submission at each step (status: started / completed / failed / pending_payment / abandoned)
- Cron job: scan for status=started or payment_pending older than 1hr, mark abandoned, fire profe/form/abandoned event
- Stripe webhooks handle payment-stage abandonment (checkout.session.expired)
**Free vs Paid fork:**
- submission.payment_status = null (free, create immediately) / pending (waiting for Stripe webhook) / completed / failed
- For paid: save submission with payment_pending status, return after Stripe webhook to create user
**Routes:**
- POST forms/{formId}/submit (public, CSRF-exempt via nonce in form)
- GET forms/{formId}/submissions (admin)
- GET forms/{formId}/submissions/{id} (admin)
- GET forms/{formId}/export (admin, CSV)
- DELETE forms/{formId}/submissions/{id} (admin, CSRF)
- POST admin/forms/abandoned/scan (admin, trigger cron manually)
**Migration SQL**: 047_create_profe_form_submissions.sql. Must have -- UP / -- DOWN markers. Table: profe_form_submissions with proper indexes for abandoned detection (status + started_at).
## T45 — Form Admin (the UI)
Write to /root/.hermes/plans/task-t45-build-plan.md
React SPA drag-and-drop form builder. Conditional logic visual editor. Analytics dashboard. Entry management.
**Interface**: FormAdminInterface with methods for dashboard stats, builder config, analytics data.
**Key features (these describe what the React SPA needs, not PHP interfaces):**
- Drag-and-drop field palette to canvas
- Each field has settings panel (label, placeholder, required, options for select/radio, conditional logic)
- Conditional logic visual editor: "If [field] [operator] [value] then [action] [target field]"
- Multi-step page management: add/remove/reorder pages
- Preview mode: render the form as user would see it
- Template browser: load/create from templates
- Submission viewer: table with search, filter by status, click to view
- Export button (CSV)
- Analytics dashboard: total submissions, completion rate, abandonment rate, funnel visualization (step-by-step drop-off)
- Form settings: email recipients, success URL, pipeline step toggles, spam settings
**This task's PHP backend provides:**
- GET admin/forms/dashboard — submission stats, funnel data
- GET admin/forms/{id}/analytics — per-form analytics
- GET admin/forms/{id}/submissions — paginated submission list
- GET admin/forms/{id}/export — CSV download
- PUT admin/forms/{id}/settings — update form settings
**Analytics tracking:**
- profe_form_analytics table: form_id, event_type (view/start/step/complete/abandon/payment_start/success/fail), step_number, user_id, created_at
- Frontend fires analytics events via REST API
- Indexes on form_id + event_type + created_at
**Migration SQL**: 048_create_profe_form_analytics.sql. -- UP / -- DOWN markers.
## For ALL briefs
- Each brief: overview, interface contract (exact PHP), DDL, REST routes, dependencies, events, implementation plan, test plan (≥12 tests)
- Migration version numbers: 045-048 for Module 8 (current highest is 052 from Module 7, so use 053-056)
- Table naming: profe_form_ prefix
- Use 2 backslashes in PHP strings: `'Profe\\\\CoreUsers\\\\CoreUsersInterface'`
- No FAULT-011 violations
- All SQL files need -- UP / -- DOWN markers
Donna2026-05-25 06:36 UTC
Let me start by reading the PB and gathering context.
Tool2026-05-25 06:36 UTC
{"content": " 1|# Project Brief: Module 8 — Forms\n 2|\n 3|**Document ID:** PB-M8-FORMS-001\n 4|**Author:** SA\n 5|**Date:** 2026-05-25\n 6|\n 7|---\n 8|\n 9|## §0 Executive Summary\n 10|\n 11|Module 8 (Forms) is the membership funnel front door — every user...
Tool2026-05-25 06:36 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|## ...
Donna2026-05-25 06:36 UTC
Let me read the rest of the PB for pipeline details and other important specs.
Tool2026-05-25 06:36 UTC
{"content": " 501|| `process_payment` | `ProcessPaymentStep` | Create Stripe PaymentIntent via Module 3 `stripe_service->createPaymentIntent()`; store `payment_intent_id`; pause pipeline | Void PaymentIntent if not yet captured |\n 502|| `create_wp_user` | `CreateWpUserStep` | `wp_insert_user()`...
Tool2026-05-25 06:36 UTC
{"total_count": 52, "files": ["/root/profe-modules/migrations/051_create_profe_com_document_categories.sql", "/root/profe-modules/migrations/046_create_profe_com_comments.sql", "/root/profe-modules/migrations/047_create_profe_com_badges.sql", "/root/profe-modules/migrations/050_create_profe_com_docu...
Donna2026-05-25 06:36 UTC
Let me check the existing stubs and the module directory structure.
Tool2026-05-25 06:36 UTC
{"total_count": 0}
Tool2026-05-25 06:36 UTC
{"total_count": 5, "files": ["/root/profe-modules/comment_system/src/CommentSystem/Migration/CreateCommentsMigration.php", "/root/profe-modules/comment_system/src/CommentSystem/CommentSystemModule.php", "/root/profe-modules/stripe_service/src/StripeService/StripeServiceModule.php", "/root/profe-modu...
Donna2026-05-25 06:36 UTC
Let me check an existing module's PHP migration class pattern and the Module class pattern.
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * CreateSubscriptionsMigration — Migration for profe_subscriptions table\n 4| *\n 5| * Registered via DbMigrationInterface in boot().\n 6| * HC-22: IF NOT EXISTS / IF EXISTS guards for idempotent runs.\n 7| *\n 8| * @package Profe\\S...
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * StripeServiceModule — ModuleInstanceInterface implementation for stripe_service\n 4| *\n 5| * HC-01: Stripe SDK used — requires stripe/stripe-php in composer.json.\n 6| * HC-03: API keys via ConfigManagerInterface.\n 7| * HC-04: Test/l...
Donna2026-05-25 06:36 UTC
Now I have complete context. Let me check the existing `FormEngineInterface` references more carefully, then write all three build briefs.
Tool2026-05-25 06:36 UTC
{"total_count": 8, "files": ["/root/profe-modules/form_admin/src/FormAdmin/FormAdminModule.php", "/root/profe-modules/form_admin/src/FormAdmin/FormAdminInterface.php", "/root/profe-modules/form_admin/src/FormAdmin/FormAdminService.php", "/root/profe-modules/form_admin/tests/Unit/FormAdminServiceTest...
Donna2026-05-25 06:36 UTC
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * FormEngineInterface — Service contract\n 4| *\n 5| * @package Profe\\FormEngine\n 6| */\n 7|declare(strict_types=1);\n 8|namespace Profe\\FormEngine;\n 9|interface FormEngineInterface\n 10|{\n 11| public function listI...
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * FormEngineService — Service implementation\n 4| *\n 5| * @package Profe\\FormEngine\n 6| */\n 7|declare(strict_types=1);\n 8|namespace Profe\\FormEngine;\n 9|use Profe\\FormEngine\\Exception\\FormEngineException;\n 10|use Pr...
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * FormAdminInterface — Service contract\n 4| *\n 5| * @package Profe\\FormAdmin\n 6| */\n 7|declare(strict_types=1);\n 8|namespace Profe\\FormAdmin;\n 9|interface FormAdminInterface\n 10|{\n 11| public function listItems...
Tool2026-05-25 06:36 UTC
{"content": " 1|<?php\n 2|/**\n 3| * FormAdminService — Service implementation\n 4| *\n 5| * @package Profe\\FormAdmin\n 6| */\n 7|declare(strict_types=1);\n 8|namespace Profe\\FormAdmin;\n 9|use Profe\\FormAdmin\\Exception\\FormAdminException;\n 10|use Profe\\...
Donna2026-05-25 06:36 UTC
Tool2026-05-25 06:36 UTC
{"total_count": 10, "files": ["/root/profe-modules/form_entries/src/FormEntries/FormEntriesModule.php", "/root/profe-modules/form_entries/tests/Integration/FormEntriesIntegrationTest.php", "/root/profe-modules/form_entries/tests/Fixture/FormEntriesFixtures.php", "/root/profe-modules/form_entries/tes...
Donna2026-05-25 06:36 UTC
Now I have all context. Let me write all 3 build briefs. Starting with T43 — Form Engine.
Tool2026-05-25 06:36 UTC
{"bytes_written": 30050, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-25 06:36 UTC
T43 written. Now writing T44 — Form Submissions.
Tool2026-05-25 06:36 UTC
{"bytes_written": 35931, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-25 06:36 UTC
T44 written. Now writing T45 — Form Admin.
Tool2026-05-25 06:36 UTC
{"bytes_written": 25479, "dirs_created": true, "lint": {"status": "skipped", "message": "No linter for .md files"}}
Donna2026-05-25 06:36 UTC
All three briefs written. Let me verify they exist and are complete.
Tool2026-05-25 06:36 UTC
{"output": "659 /root/.hermes/plans/task-t43-build-plan.md\n 744 /root/.hermes/plans/task-t44-build-plan.md\n 595 /root/.hermes/plans/task-t45-build-plan.md\n 1998 total", "exit_code": 0, "error": null}
Tool2026-05-25 06:36 UTC
{"output": "/root/.hermes/plans/task-t43-build-plan.md:2\n/root/.hermes/plans/task-t44-build-plan.md:2\n/root/.hermes/plans/task-t45-build-plan.md:2", "exit_code": 0, "error": null}
Donna2026-05-25 06:36 UTC
Tool2026-05-25 06:36 UTC
{"output": "/root/.hermes/plans/task-t43-build-plan.md:11\n/root/.hermes/plans/task-t44-build-plan.md:8\n/root/.hermes/plans/task-t45-build-plan.md:8", "exit_code": 0, "error": null}
Tool2026-05-25 06:36 UTC
{"output": "=== Test counts ===\n18\n18\n12", "exit_code": 0, "error": null}
Tool2026-05-25 06:36 UTC
{"output": "/root/.hermes/plans/task-t43-build-plan.md:643:'Profe\\\\\\\\\\\\\\\\CoreUsers\\\\\\\\\\\\\\\\CoreUsersInterface', // 4 backslashes\n/root/.hermes/plans/task-t43-build-plan.md:646:Run `grep -n '\\\\\\\\\\\\\\\\' /root/profe-modules/form_engine/src/FormEngine/FormEngineModule.php` before...
Donna2026-05-25 06:36 UTC
Tool2026-05-25 06:36 UTC
{"output": "=== T43 Sections ===\n## 1. Overview\n## 2. Interface Contract: FormEngineInterface\n## 3. Database Schema\n## 4. REST Routes\n## 5. Dependencies\n## 6. Events Emitted\n## 7. Implementation Plan\n## 8. Seed Data: Form Templates\n## 9. JSON Column Structure Contracts\n## 10. Conditional L...
Donna2026-05-25 06:36 UTC
All three build briefs are complete and verified. Here's the summary:
## What I Did
Read the full PB (753 lines), past faults log (273 lines), existing stub code in `form_engine/`, `form_entries/`, and `form_admin/`, and existing migration files (highest: 053). Then wrote 3 comprehensive TA build briefs.
## Files Created
| File | Lines | Tests Defined |
|------|-------|---------------|
| `/root/.hermes/plans/task-t43-build-plan.md` | 659 | 18 tests (14 min) |
| `/root/.hermes/plans/task-t44-build-plan.md` | 744 | 18 tests (16 min) |
| `/root/.hermes/plans/task-t45-build-plan.md` | 595 | 12 tests (12 min) |
## What Each Brief Contains
**T43 — Form Engine** (`task-t43-build-plan.md`):
- `FormEngineInterface` with 25+ methods covering form CRUD, fields, conditional logic, pages, versions, templates, field type registry
- Migration SQL for `053_create_profe_form_schemas.sql` and `054_create_profe_form_versions.sql` with `-- UP` / `-- DOWN` markers
- 21 REST routes with auth requirements
- Full `ConditionEvaluator` PHP class with 8 operators
- Field Type Registry with 11 field types
- JSON column structure contracts (fields, pages, settings)
- 4 seed template definitions (Registration, Payment, Contact, Survey)
- PHP migration class files
- 6-phase implementation plan
**T44 — Form Submissions** (`task-t44-build-plan.md`):
- `FormSubmissionsInterface` with 12 methods covering submission lifecycle, pipeline, abandoned detection, analytics tracking
- Migration SQL for `055_create_profe_form_submissions.sql` with `-- UP` / `-- DOWN` markers
- 10 REST routes including public submission endpoint and Stripe webhook
- Complete pipeline design: `PipelineStepInterface`, `PipelineContext`, `PipelineResult`, `PipelineRunner` with Saga compensation
- 9 step handler classes (Validate through NotifyAdmin) with compensation actions
- Free vs paid fork logic diagram
- Webhook handler with FAULT-013 signature verification
- Abandoned cart scanner cron design
- Analytics tracking integration points
**T45 — Form Admin** (`task-t45-build-plan.md`):
- `FormAdminInterface` with 10 methods covering dashboard, analytics, form duplication, submission management, CSV export
- Migration SQL for `056_create_profe_form_analytics.sql` with `-- UP` / `-- DOWN` markers
- 10 REST routes for the React SPA backend
- Complete analytics funnel calculation with drop-off rates
- CSV export format with UTF-8 BOM
- Form duplication deep-copy logic with field ID remapping
- JSON response examples for dashboard and analytics
- FAULT-004 CSRF enforcement documentation
## Issues Addressed
- **Migration numbers**: Used 053-056 (corrected from PB's 045-048 since existing migrations go up to 053)
- **FAULT-011**: All briefs show correct 2-backslash patterns and include compliance check sections
- **FAULT-002**: T44 documents every direct `profe_users` query with workaround comments
- **FAULT-004**: T45 enforces CSRF on all admin mutation endpoints
- **FAULT-006**: Each migration SQL file has a corresponding PHP migration class
- **FAULT-013**: T44's Stripe webhook handler verifies signature before processing